compat_compiler.h File Reference

Utility macros to handle different features and behavior in different compilers. More...

#include "orconfig.h"
#include <inttypes.h>

Go to the source code of this file.


#define CHECK_PRINTF(formatIdx, firstArg)
#define CHECK_SCANF(formatIdx, firstArg)
#define GCC_VERSION   0
#define DISABLE_GCC_WARNING(warning)
#define ENABLE_GCC_WARNING(warning)
#define __func__   "???"
#define ENUM_BF(t)   t
#define ATTR_CONST
#define ATTR_WUR
#define PREDICT_LIKELY(exp)   (exp)
#define PREDICT_UNLIKELY(exp)   (exp)
#define STMT_NIL   (void)0
#define STMT_VOID(a)   while (0) { (void)(a); }
#define STMT_BEGIN   do {
#define STMT_END   } while (0)
#define OP_LT   <
#define OP_GT   >
#define OP_GE   >=
#define OP_LE   <=
#define OP_EQ   ==
#define OP_NE   !=
#define STRUCT_VAR_P(st, off)   ((void*) ( ((char*)(st)) + (off) ) )
#define SUBTYPE_P(p, subtype, basemember)   ((void*) ( ((char*)(p)) - offsetof(subtype, basemember) ))
#define ARRAY_LENGTH(x)   ((sizeof(x)) / sizeof(x[0]))
#define EAT_SEMICOLON   struct dummy_semicolon_eater__

Detailed Description

Utility macros to handle different features and behavior in different compilers.

Definition in file compat_compiler.h.

Macro Definition Documentation


#define ARRAY_LENGTH (   x)    ((sizeof(x)) / sizeof(x[0]))

Macro: Yields the number of elements in array x.

Definition at line 218 of file compat_compiler.h.


#define EAT_SEMICOLON   struct dummy_semicolon_eater__

"Eat" a semicolon that somebody puts at the end of a top-level macro.

Frequently, we want to declare a macro that people will use at file scope, and we want to allow people to put a semicolon after the macro.

This declaration of a struct can be repeated any number of times, and takes a trailing semicolon afterwards.

Definition at line 229 of file compat_compiler.h.


#define ENUM_BF (   t)    t

Wrapper for having a bitfield of an enumerated type. Where possible, we just use the enumerated type (so the compiler can help us and notice problems), but if enumerated types are unsigned, we must use unsigned, so that the loss of precision doesn't make large values negative.

Definition at line 122 of file compat_compiler.h.


#define STMT_NIL   (void)0

Expands to a syntactically valid empty statement.

Definition at line 162 of file compat_compiler.h.


#define STMT_VOID (   a)    while (0) { (void)(a); }

Expands to a syntactically valid empty statement, explicitly (void)ing its argument.

Definition at line 166 of file compat_compiler.h.


#define STRUCT_VAR_P (   st,
)    ((void*) ( ((char*)(st)) + (off) ) )

Macro: yield a pointer to the field at position off within the structure st. Example:

  struct a { int foo; int bar; } x;
  ptrdiff_t bar_offset = offsetof(struct a, bar);
  int *bar_p = STRUCT_VAR_P(&x, bar_offset);
  *bar_p = 3;

Definition at line 203 of file compat_compiler.h.


#define SUBTYPE_P (   p,
)    ((void*) ( ((char*)(p)) - offsetof(subtype, basemember) ))

Macro: yield a pointer to an enclosing structure given a pointer to a substructure at offset off. Example:

  struct base { ... };
  struct subtype { int x; struct base b; } x;
  struct base *bp = &x.base;
  struct *sp = SUBTYPE_P(bp, struct subtype, b);

Definition at line 214 of file compat_compiler.h.