The Tiny HTM Library
src/common.c
Go to the documentation of this file.
00001 
00005 #include "tinyhtm/common.h"
00006 
00007 #ifdef __cplusplus
00008 extern "C" {
00009 #endif
00010 
00011 
00012 static const char * const _htm_inv_errcode =
00013     "Invalid error code passed to htm_errmsg()";
00014 
00015 static const char * const _htm_errmsg[HTM_NUM_CODES] = {
00016     /* HTM_OK */        "Success",
00017     /* HTM_ENOMEM */    "Memory allocation or reallocation failed",
00018     /* HTM_ENULLPTR */  "NULL pointer",
00019     /* HTM_ENANINF */   "Value is NaN or +/-Inf",
00020     /* HTM_EZERONORM */ "Vector has zero norm",
00021     /* HTM_ELAT */      "Latitude angle not in range [-90, 90] degrees",
00022     /* HTM_EANG */      "Radius, width, height or angle is negative or too large",
00023     /* HTM_EHEMIS */    "Vectors (vertices/points) are not hemispherical",
00024     /* HTM_ELEN */      "Too many/too few array elements (vertices/points)",
00025     /* HTM_EDEGEN */    "Vectors (vertices/points) are degenerate",
00026     /* HTM_EID */       "Invalid HTM ID",
00027     /* HTM_ELEVEL */    "Invalid HTM subdivision level",
00028     /* HTM_EIO */       "IO operation failed",
00029     /* HTM_EMMAN */     "Failed to mmap(), madvise(), or mlock()",
00030     /* HTM_EINV */      "Invalid argument",
00031     /* HTM_ETREE */     "Invalid HTM tree file, or tree/data file mismatch"
00032 };
00033 
00034 
00035 const char * htm_errmsg(enum htm_errcode err)
00036 {
00037     if ((int) err < 0 || err >= HTM_NUM_CODES) {
00038         return _htm_inv_errcode;
00039     }
00040     return _htm_errmsg[err];
00041 }
00042 
00043 
00044 #ifdef __cplusplus
00045 }
00046 #endif
00047