libmsr  0.3.0
A friendlier interface to accessing MSRs on Intel platforms
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Functions
libmsr_error.c File Reference
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libmsr_error.h"
Include dependency graph for libmsr_error.c:

Functions

void libmsr_error_message (int err, char *msg, size_t size)
 Convert error code to brief libmsr error message.
 
char * get_libmsr_error_message (int err)
 Get brief libmsr error message based on error code.
 
void libmsr_error_handler (const char *desc, int err, const char *host, const char *filename, int line)
 Display error message to user.
 

Function Documentation

char* get_libmsr_error_message ( int  err)

Get brief libmsr error message based on error code.

Parameters
[in]errlibmsr_error_e error code, positive values are system errors, negative values are libmsr errors. LIBMSR_ERROR_RUNTIME is assumed if error code is 0.
Returns
Default libmsr error message.
void libmsr_error_handler ( const char *  desc,
int  err,
const char *  host,
const char *  filename,
int  line 
)

Display error message to user.

This is the generic libmsr error handling API. Use this function to report when errors arise. If an error is not defined in libmsr_error_e, add it to the aforementioned enum with the next sequential error code and define its brief error message in the / source file.

Parameters
[in]descExtension to default libmsr error message.
[in]errlibmsr_error_e error code, positive values are system errors, negative values are libmsr errors. LIBMSR_ERROR_RUNTIME is assumed if error code is 0.
[in]hostHostname environment variable.
[in]filenameName of source file where error occurred (use standard predefined macro FILE).
[in]lineLine number in source file where error occurred (use standard predefined macro LINE).
void libmsr_error_message ( int  err,
char *  msg,
size_t  size 
)

Convert error code to brief libmsr error message.

Parameters
[in]errlibmsr_error_e error code, positive values are system errors, negative values are libmsr errors. LIBMSR_ERROR_RUNTIME is assumed if error code is 0.
[in]sizeMax length (in bytes) of brief libmsr error message.
[out]msgBrief libmsr error message.