gcc4 build fix.

* offsetof is not allowed on non-POD types so we need to use
offset_of_member (gcc2 accepts offsetof, and C++11 relaxed the
constraints on where it is allowed so it should work there too)
* we have offset_of_member as a workaround until we switch to C++11,
move it from khash (which is soon to be removed) to list.h which is the
other place where it is used (for this one single call in our whole
codebase)

Also fix a typo in vfs.cpp.
This commit is contained in:
Adrien Destugues
2015-01-12 19:04:33 +01:00
parent 63fdcb8e7e
commit 3395fdcd6a
3 changed files with 12 additions and 9 deletions
-7
View File
@@ -12,13 +12,6 @@
#include <util/StringHash.h>
// The use of offsetof() on non-PODs is invalid. Since many structs use
// templated members (i.e. DoublyLinkedList) which makes them non-PODs we
// can't use offsetof() anymore. This macro does the same, but requires an
// instance of the object in question.
#define offset_of_member(OBJECT, MEMBER) \
((size_t)((char*)&OBJECT.MEMBER - (char*)&OBJECT))
// can be allocated on the stack
typedef struct hash_iterator {
void *current;
+9
View File
@@ -20,6 +20,15 @@
* you don't have to care about the difference between a link and an item.
*/
// The use of offsetof() on non-PODs is invalid. Since many structs use
// templated members (i.e. DoublyLinkedList) which makes them non-PODs we
// can't use offsetof() anymore. This macro does the same, but requires an
// instance of the object in question.
#define offset_of_member(OBJECT, MEMBER) \
((size_t)((char*)&OBJECT.MEMBER - (char*)&OBJECT))
typedef struct list_link list_link;
/* The object that is put into the list must begin with these