add offsetof helper

This commit is contained in:
Doug MacEachern 2006-12-18 05:51:45 +00:00
parent 963cfaa843
commit 7f039d6033
1 changed files with 7 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#ifndef WIN32 #ifndef WIN32
#include <unistd.h> #include <unistd.h>
#include <stddef.h>
#ifndef DARWIN #ifndef DARWIN
#include <strings.h> #include <strings.h>
#endif #endif
@ -100,6 +101,12 @@
#define strnEQ(s1, s2, n) (strncmp(s1, s2, n) == 0) #define strnEQ(s1, s2, n) (strncmp(s1, s2, n) == 0)
#endif #endif
#ifdef offsetof
#define sigar_offsetof offsetof
#else
#define sigar_offsetof(type, field) ((size_t)(&((type *)0)->field))
#endif
#define SIGAR_MSEC 1000L #define SIGAR_MSEC 1000L
#define SIGAR_NSEC 1000000000L #define SIGAR_NSEC 1000000000L