Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Commit

Permalink
protect offset macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmens committed Nov 16, 2018
1 parent f9b83fb commit f7a092f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions be-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <unistd.h>
#include <mosquitto.h>
#include <mosquitto_plugin.h>
#include <mosquitto_broker.h>
#include "log.h"
#include "hash.h"
#include "backends.h"
Expand Down Expand Up @@ -95,11 +96,13 @@ static inline bool dllist_empty(const dllist * thiz)
return (thiz->head.next == &thiz->head);
}

#if !(defined(offsetof))
#if defined(__GNUC__) && __GNUC__ >= 4
#define offsetof(type, member) __builtin_offsetof(type, member)
#else
#define offsetof(type, member) ((size_t)&((type*)NULL)->member)
#endif
#endif

#define dllist_entry_element(ptr, type, member) \
(type*)((char*)(void*)ptr + offsetof(type, member))
Expand Down

0 comments on commit f7a092f

Please sign in to comment.