libmsr
0.3.0
A friendlier interface to accessing MSRs on Intel platforms
|
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libmsr_error.h"
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. | |
char* get_libmsr_error_message | ( | int | err | ) |
Get brief libmsr error message based on error code.
[in] | err | libmsr_error_e error code, positive values are system errors, negative values are libmsr errors. LIBMSR_ERROR_RUNTIME is assumed if error code is 0. |
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.
[in] | desc | Extension to default libmsr error message. |
[in] | err | libmsr_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] | host | Hostname environment variable. |
[in] | filename | Name of source file where error occurred (use standard predefined macro FILE). |
[in] | line | Line 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.
[in] | err | libmsr_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] | size | Max length (in bytes) of brief libmsr error message. |
[out] | msg | Brief libmsr error message. |