Definition in file eg_macros.h.
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include "eg_config.h"
Include dependency graph for eg_macros.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
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__) |
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. | |
Mathematical Constants | |
Here we define some mathematical constants needed in some parts of the code that are of general use | |
#define | EG_M_PI 3.1415926535897932384626433832795029L |
definition of ![]() | |
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 | 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 | 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 | TESTERRNOIF(__value) |
, if a non-zero value is given as an argument, check the errno stored in the system, print the related message, and return the non-zero given parameter, otherwise, do nothing. | |
#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. |