[sr-dev] git:master: core:sr_module If offsetof is not found in stddef. h define it as a macro

Marius Zbihlei marius.zbihlei at 1and1.ro
Tue Aug 17 10:26:14 CEST 2010


Module: sip-router
Branch: master
Commit: b4c42f7bf36ce7a51fa51c316d1231d621b28362
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b4c42f7bf36ce7a51fa51c316d1231d621b28362

Author: Marius Zbihlei <marius.zbihlei at 1and1.ro>
Committer: Marius Zbihlei <marius.zbihlei at 1and1.ro>
Date:   Tue Aug 17 11:24:43 2010 +0300

core:sr_module If offsetof is not found in stddef.h define it as a macro

This is very unlikely; the macro uses the null pointer dereference

---

 sr_module.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/sr_module.c b/sr_module.c
index e4f94a3..421f1b7 100644
--- a/sr_module.c
+++ b/sr_module.c
@@ -101,11 +101,15 @@ struct sr_module* modules=0;
 	extern struct module_exports sl_exports;
 #endif
 
+#ifndef offsetof
+#warning "use null pointer dereference for offsetof"
+#define offsetof(st, m) \
+		((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))
+#endif
 
 int mod_response_cbk_no=0;
 response_function* mod_response_cbks=0;
 
-
 /* initializes statically built (compiled in) modules*/
 int register_builtin_modules()
 {




More information about the sr-dev mailing list