Browse Source

core: add ROUND_UP() macro

v0.9.1-release
Ben Noordhuis 13 years ago
parent
commit
a58659cd4a
  1. 10
      src/node_internals.h

10
src/node_internals.h

@ -29,17 +29,21 @@ namespace node {
#ifndef offset_of
// g++ in strict mode complains loudly about the system offsetof() macro
// because it uses NULL as the base address.
#define offset_of(type, member) \
# define offset_of(type, member) \
((intptr_t) ((char *) &(((type *) 8)->member) - 8))
#endif
#ifndef container_of
#define container_of(ptr, type, member) \
# define container_of(ptr, type, member) \
((type *) ((char *) (ptr) - offset_of(type, member)))
#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
# define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
#endif
#ifndef ROUND_UP
# define ROUND_UP(a, b) ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a))
#endif
// this would have been a template function were it not for the fact that g++

Loading…
Cancel
Save