Files | |
| file | eg_macros.h |
Code Location Utility: | |
this are utility macros to print information about where we are.
| |
| #define | __EG_PRINTLOC2__ __EG_PRINTLOC2F__(stderr) |
| #define | __EG_PRINTLOC2F__(F) fprintf(((F==0)?stderr:F),"in %s (%s:%d)\n",__func__,__FILE__,__LINE__) |
| #define | __EG_PRINTLOC__ __EG_PRINTLOCF__(stderr) |
| #define | __EG_PRINTLOCF__(F) fprintf(((F==0)?stderr:F),", in %s (%s:%d)\n",__func__,__FILE__,__LINE__) |
Number Types Definitions: | |
| Define (as its name suggest) an internal identifier for the given type. this definitions are provided to select different types of data at compile time, thus allowing us to provide limited template support. | |
| #define | DBL_TYPE 0 |
| #define | FLOAT128_TYPE 13 |
| #define | FLT_TYPE 1 |
| #define | FP10_TYPE 3 |
| #define | FP20_TYPE 4 |
| #define | FP25_TYPE 6 |
| #define | FP28_TYPE 5 |
| #define | GNU_MP_F 10 |
| #define | GNU_MP_Q 9 |
| #define | GNU_MP_Z 8 |
| #define | INT_TYPE 2 |
| #define | LDBL_TYPE 11 |
| #define | LLINT_TYPE 12 |
Algorithms Return Status | |
| Here we define some general status for algorithms, the exact meaning should be sought in the actual algorithm definition, but the definitions here provide a first overview of their meaning. | |
| #define | EG_ALGSTAT_ERROR 3 |
| the algorithm stop because of some unforeseen error | |
| #define | EG_ALGSTAT_NUMERROR 2 |
| the algorithm stop because of some numerical problem | |
| #define | EG_ALGSTAT_PARTIAL 1 |
| the algorithm could only partially finish | |
| #define | EG_ALGSTAT_SUCCESS 0 |
| the algorithm finish successfully. | |
External C-library functions: | |
| Here we define some C-library functions that for some weird reason can't be found at compile time but are present at linking time | |
| double | drand48 (void) |
| int | finite (double) |
| int | getopt (int, char *const *, const char *) |
| long | lrand48 (void) |
| long | random (void) |
| void | srandom (unsigned int) |
| char * | optarg |
Defines | |
| #define | ADVCHECKRVAL(A, B) |
| this macro test if a value is non zero, if it is it print where is it and return B. The idea is to use it to check return values of functions | |
| #define | ADVTESTL(level, cond, rval,) |
| This macro test a condition 'cond' when the debug level used at compile time is at least 'level'. If the condition is true, it print the message and return the 'rval' value. | |
| #define | CHECKRVAL(A) |
| this macro test if a value is non zero, if it is it print where is it and return 1. The idea is to use it to check return values of functions | |
| #define | CHECKRVALG(A, B) |
| this function, if the input is non zero, print a message of function, file and line and then goto the second parameter | |
| #define | EGcontainerOf(ptr, type, member) |
| given a pointer to a member of a structure, return the pointer to the head of the structure. (idea taken from Linux Kernel). | |
| #define | EGoffsetOf(type, member) ((size_t) &((type *)0)->member) |
| return the offset of a member inside a structure. | |
| #define | EGosGetData(data, osN, type) (*((type*)(((char*)data)+osN))) |
| retrieve the data of type 'type' in the structure 'data' that is located in the offset 'osN'. | |
| #define | EGosGetOffset(my_struct, my_member) EGoffsetOf(my_struct,my_member) |
| This is a redifinition of an old function to the newer implementation provided by EGoffsetOf. It return the offset of a member inside a structure. | |
| #define | EGosSetData(data, osN, type, val) (EGosGetData(data,osN,type)=val) |
| set the data of type 'type' in the structure 'data' that is located in the offset 'osN' to the value 'val'. | |
| #define | EGRAND_MAX RAND_MAX |
| Define the real rand_max value of (random). In linux machines is as RAND_MAX, but in SUN is 2^31-1. | |
| #define | EXIT(A,) |
| This macro is to print error messages and exit the program with code one from the current function, it also print the file and line where this happend. | |
| #define | EXITL(L, A,) |
| This macro is to print error messages and to return with value one from the current function, it also print the file and line where this happend, but the condition is looked only if the debug level is at least L. | |
| #define | EXITRVAL(A) |
| this macro test if a value is non zero, if it is it print where is it and exit 1. The idea is to use it to check return values of functions, and the calling function can't return a status, and then we are forced to exit. | |
| #define | HAVE_GNU_MP 1 |
| #define | MESSAGE(A,) |
| This macro print messages to the screen when the debug level is as big as the first parameter, if the debug level is zero we eliminate the code and reduce it to the empty instruction. | |
| #define | MESSAGEF(A, F,) |
| This macro print messages to the screen when the debug level is as big as the first parameter, if the debug level is zero we eliminate the code and reduce it to the empty instruction. | |
| #define | nullCopy ((EGcopy_f)0) |
| Define a null copy function. | |
| #define | OUTPUT(A,) |
| This macro print messages to the screen when the verbose level is as big as the first parameter, if the verbose level is zero we eliminate the code and reduce it to the empty instruction. | |
| #define | PTRTEST(ptr, rval) |
| this macro check if the value of a pointer is not bellow the first 64Kb, if so it return the given value | |
| #define | TEST(A,) |
| This macro is to print error messages and to return with value one from the current function, it also print the file and line where this happend. | |
| #define | TESTG(A, B,) |
| This macro is to print error messages and to return with value one from the current function, it also print the file and line where this happend. | |
| #define | TESTL(L, A,) |
| This macro is to print error messages and to return with value one from the current function, it also print the file and line where this happend, but the condition is looked only if the debug level is at least L. | |
| #define | typeof __typeof__ |
| We define the GNU C extension typeof if necesary. | |
| #define | WARNING(A,) |
| This macro print messages to the screen when the condition A is true. | |
| #define | WARNINGL(L, A,) |
| This macro print messages to the screen when the condition A is true .if the debug level is one we don't print any warning message. if the debug level is zero we eliminate the code and reduce it to the empty instruction. | |
Typedefs | |
| typedef void *(* | EGcopy_f )(void *p) |
| Defione copy functions, these functions return copy of objects but with independent storage space, there are two versions, one that require a memory pool from where to look for memory, and another where we don't care about that.... the place from where the memory was asked for depend on the function, se the function definition for details. Note that if the is no more memory available the function should call exit(1). This is only intended as a readibility help. | |
|
|
Definition at line 148 of file eg_macros.h. |
|
|
Definition at line 147 of file eg_macros.h. |
|
|
Definition at line 146 of file eg_macros.h. |
|
|
Definition at line 145 of file eg_macros.h. |
|
|
Value: ({\
if(A){\
__EG_PRINTLOC2__;\
return B;}})
Definition at line 287 of file eg_macros.h. |
|
|
Value: ({\
if((DEBUG>=level)&&(cond)){\
fprintf(stderr,__VA_ARGS__);\
__EG_PRINTLOC__;\
return rval;}})
Definition at line 296 of file eg_macros.h. |
|
|
Value: ({\
if(A){\
__EG_PRINTLOC2__;\
return A;}})
Definition at line 306 of file eg_macros.h. |
|
|
Value: ({\
if(A){\
__EG_PRINTLOC2__;\
goto B;}})
Definition at line 314 of file eg_macros.h. |
|
|
C double type. Definition at line 355 of file eg_macros.h. |
|
|
the algorithm stop because of some unforeseen error
Definition at line 418 of file eg_macros.h. |
|
|
the algorithm stop because of some numerical problem
Definition at line 416 of file eg_macros.h. |
|
|
the algorithm could only partially finish
Definition at line 414 of file eg_macros.h. |
|
|
the algorithm finish successfully.
Definition at line 412 of file eg_macros.h. |
|
|
Value: ({\
typeof(((type *)0)->member) *const __EGcOf_ptr = (ptr);\
(type *)( (char*)__EGcOf_ptr - EGoffsetOf(type,member));})
Definition at line 119 of file eg_macros.h. |
|
|
return the offset of a member inside a structure.
Definition at line 109 of file eg_macros.h. |
|
|
retrieve the data of type 'type' in the structure 'data' that is located in the offset 'osN'.
Definition at line 335 of file eg_macros.h. |
|
|
This is a redifinition of an old function to the newer implementation provided by EGoffsetOf. It return the offset of a member inside a structure.
Definition at line 346 of file eg_macros.h. |
|
|
set the data of type 'type' in the structure 'data' that is located in the offset 'osN' to the value 'val'.
Definition at line 340 of file eg_macros.h. |
|
|
Define the real rand_max value of (random). In linux machines is as RAND_MAX, but in SUN is 2^31-1.
Definition at line 323 of file eg_macros.h. |
|
|
Value: ({if(A){\
fprintf(stderr,__VA_ARGS__);\
__EG_PRINTLOC__;\
exit(1);}})
Definition at line 278 of file eg_macros.h. |
|
|
Value: ({\
if(L<=DEBUG){\
if(A){\
fprintf(stderr,__VA_ARGS__);\
__EG_PRINTLOC__;\
exit(1);}}})
Definition at line 157 of file eg_macros.h. |
|
|
Value: ({\
if(A){\
__EG_PRINTLOC2__;\
exit(1);}})
Definition at line 269 of file eg_macros.h. |
|
|
SoftFloat 128-bit floating point numbner Definition at line 385 of file eg_macros.h. |
|
|
C float type. Definition at line 357 of file eg_macros.h. |
|
|
EGlib EGfp10_t type, this is an implementation of fixed precision arithmetic with 10 bits for fractional representation. Definition at line 362 of file eg_macros.h. |
|
|
EGlib EGfp20_t type, this is an implementation of fixed precision arithmetic with 20 bits for fractional representation. Definition at line 365 of file eg_macros.h. |
|
|
EGlib EGfp25_t type, this is an implementation of fixed precision arithmetic with 25 bits for fractional representation. Definition at line 371 of file eg_macros.h. |
|
|
EGlib EGfp28_t type, this is an implementation of fixed precision arithmetic with 28 bits for fractional representation. Definition at line 368 of file eg_macros.h. |
|
|
GNU_MP library mpf_t type Definition at line 378 of file eg_macros.h. |
|
|
GNU_MP library mpq_t type Definition at line 376 of file eg_macros.h. |
|
|
GNU_MP library mpz_t type Definition at line 374 of file eg_macros.h. |
|
|
Definition at line 93 of file eg_macros.h. |
|
|
C int type. Definition at line 359 of file eg_macros.h. |
|
|
C long double type Definition at line 381 of file eg_macros.h. |
|
|
C long long int type Definition at line 383 of file eg_macros.h. |
|
|
Value: ({\
if(A <= DEBUG ){\
fprintf(stderr,__VA_ARGS__);\
__EG_PRINTLOC__;}})
Definition at line 217 of file eg_macros.h. |
|
|
Value: ({\
if(A <= DEBUG ){\
fprintf(((F==0)?stderr:F),__VA_ARGS__);\
__EG_PRINTLOCF__(F);}})
Definition at line 208 of file eg_macros.h. |
|
|
Define a null copy function.
Definition at line 403 of file eg_macros.h. |
|
|
Value: ({\
if(A <= VERBOSE_LEVEL ){\
fprintf(stderr,__VA_ARGS__);}})
Definition at line 227 of file eg_macros.h. |
|
|
Value: {\
if(ptr) ADVTESTL(0,((size_t)(ptr)) < (1U<<16),rval, \
"%s=%p is not a valid pointer",\
#ptr, (void*)(ptr));}
Definition at line 179 of file eg_macros.h. |
|
|
Value: ({\
if(A){\
fprintf(stderr,__VA_ARGS__);\
__EG_PRINTLOC__;\
return 1;}})
Definition at line 198 of file eg_macros.h. |
|
|
Value: ({\
if(A){\
fprintf(stderr,__VA_ARGS__);\
__EG_PRINTLOC__;\
goto B;}})
Definition at line 188 of file eg_macros.h. |
|
|
Value: ({\
if(L<=DEBUG){\
if(A){\
fprintf(stderr,__VA_ARGS__);\
__EG_PRINTLOC__;\
return 1;}}})
Definition at line 169 of file eg_macros.h. |
|
|
We define the GNU C extension typeof if necesary.
Definition at line 99 of file eg_macros.h. |
|
|
Value: ({if(A){\
fprintf(stderr,"WARNING: ");\
fprintf(stderr,__VA_ARGS__);\
__EG_PRINTLOC__;}})
Definition at line 259 of file eg_macros.h. |
|
|
Value: ({\
if((A)&&(DEBUG>=L)){\
fprintf(stderr,"WARNING: ");\
fprintf(stderr,__VA_ARGS__);\
__EG_PRINTLOC__;}})
Definition at line 239 of file eg_macros.h. |
|
|
Defione copy functions, these functions return copy of objects but with independent storage space, there are two versions, one that require a memory pool from where to look for memory, and another where we don't care about that.... the place from where the memory was asked for depend on the function, se the function definition for details. Note that if the is no more memory available the function should call exit(1). This is only intended as a readibility help.
Definition at line 398 of file eg_macros.h. |
|
|
|
|
|
|
|
||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.4.5