summaryrefslogtreecommitdiff
path: root/include/libHX/defs.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-05-16 16:33:21 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-05-16 16:33:21 +0200
commit6d36bb20f860c069631bc50dce7e332c80a54730 (patch)
tree3c93f2c8fe52626c61083812c728435252e59608 /include/libHX/defs.h
parent246015cb71b7f0a599d1870185d73f2326adb911 (diff)
parenta1bdcfa3ca8af4ddb69ee57d716aa943cf3fe94a (diff)
Update upstream source from tag 'upstream/3.25'
Update to upstream version '3.25' with Debian dir ee1976ad65a32f96556b498dbf1b74cdefdfeda5
Diffstat (limited to 'include/libHX/defs.h')
-rw-r--r--include/libHX/defs.h29
1 files changed, 7 insertions, 22 deletions
diff --git a/include/libHX/defs.h b/include/libHX/defs.h
index 9ecdd32..1ace518 100644
--- a/include/libHX/defs.h
+++ b/include/libHX/defs.h
@@ -2,23 +2,14 @@
#define _LIBHX_DEFS_H 1
#ifdef __cplusplus
-# define FIELD_SIZEOF(type, member) \
- sizeof(static_cast<type *>(NULL)->member)
-# define HXsizeof_member(type, member) FIELD_SIZEOF(type, member)
-# define HXtypeof_member(type, member) \
- __typeof__(static_cast<type *>(NULL)->member)
-# if defined(__GNUC__) && __GNUC__ >= 4 && !defined(offsetof)
- /*
- * This is here so most programs can skip inclusion
- * of stddef.h just to get offsetof.
- */
-# define offsetof(type, member) __builtin_offsetof(type, member)
-# endif
-# ifndef offsetof
-# define offsetof(type, member) \
- reinterpret_cast<long>(&(static_cast<type *>(NULL)->member))
+# define HXsizeof_member(type, member) sizeof(type::member)
+# if __cplusplus >= 201100L
+# define HXtypeof_member(type, member) decltype(type::member)
+# else
+# define HXtypeof_member(type, member) __typeof__(type::member))
# endif
# ifndef containerof
+# include <cstddef>
# define containerof(var, type, member) reinterpret_cast<type *>( \
reinterpret_cast<char *>(var) - offsetof(type, member))
# endif
@@ -139,14 +130,8 @@ static __inline__ new_type signed_cast(unsigned char *expr)
# ifndef reinterpret_cast
# define reinterpret_cast(type, expr) ((type)(expr))
# endif
-# if defined(__GNUC__) && __GNUC__ >= 4 && !defined(offsetof)
-# define offsetof(type, member) __builtin_offsetof(type, member)
-# endif
-# ifndef offsetof
-# define offsetof(type, member) \
- reinterpret_cast(long, &(static_cast(type *, NULL)->member))
-# endif
# ifndef containerof
+# include <stddef.h>
# define containerof(var, type, member) reinterpret_cast(type *, \
reinterpret_cast(char *, var) - offsetof(type, member))
# endif