libmooshika
Macros
utils.h File Reference
#include "atomics.h"

Go to the source code of this file.

Macros

#define ERROR_LOG(fmt, args...)   fprintf(stderr, "ERROR: %s (%d), %s: " fmt "\n", __FILE__, __LINE__, __func__, ##args)
 
#define INFO_LOG(debug, fmt, args...)   if (debug) fprintf(stderr, "INFO: %s (%d), %s: " fmt "\n", __FILE__, __LINE__, __func__, ##args)
 
#define TEST_Z(x)   do { int retval; if ( (retval=x)) { ERROR_LOG("error: " #x " failed (returned %d, errno %d).", retval, errno ); exit(retval); } } while (0)
 
#define TEST_NZ(x)   do { if (!(x)) { ERROR_LOG("error: " #x " failed (returned zero/null. errno=%d).", errno); exit(-1); }} while (0)
 
#define set_size(val, unit)
 
#define NSEC_IN_SEC   1000000000
 
#define MSK_MAX_RESVPORT   1023
 
#define MSK_MIN_RESVPORT   512
 

Macro Definition Documentation

#define ERROR_LOG (   fmt,
  args... 
)    fprintf(stderr, "ERROR: %s (%d), %s: " fmt "\n", __FILE__, __LINE__, __func__, ##args)

Referenced by __attribute__(), callback_recv(), and main().

#define INFO_LOG (   debug,
  fmt,
  args... 
)    if (debug) fprintf(stderr, "INFO: %s (%d), %s: " fmt "\n", __FILE__, __LINE__, __func__, ##args)
#define MSK_MAX_RESVPORT   1023
#define MSK_MIN_RESVPORT   512
#define NSEC_IN_SEC   1000000000
#define set_size (   val,
  unit 
)
Value:
do { \
switch(unit[0]) { \
case 'k': \
case 'K': \
val *= 1024; \
break; \
case 'm': \
case 'M': \
val *= 1024 * 1024; \
break; \
case 'g': \
case 'G': \
val *= 1024 * 1024 * 1024; \
break; \
default: \
ERROR_LOG("unknown unit '%c'", unit[0]); \
val = 0; \
} \
} while (0)
#define ERROR_LOG(fmt, args...)
Definition: utils.h:1

Referenced by main().

#define TEST_NZ (   x)    do { if (!(x)) { ERROR_LOG("error: " #x " failed (returned zero/null. errno=%d).", errno); exit(-1); }} while (0)
#define TEST_Z (   x)    do { int retval; if ( (retval=x)) { ERROR_LOG("error: " #x " failed (returned %d, errno %d).", retval, errno ); exit(retval); } } while (0)