# Checks for typedefs, structures, and compiler characteristics.
lldp_CHECK___PROGNAME
+lldp_CHECK_ALIGNOF
# Checks for library functions.
AC_CONFIG_LIBOBJ_DIR([src/compat])
--- /dev/null
+#
+# lldp_CHECK_ALIGNOF
+#
+AC_DEFUN([lldp_CHECK_ALIGNOF],[
+ AC_CACHE_CHECK([whether compiler understands __alignof__], lldp_cv_check_alignof, [
+ AC_TRY_COMPILE([],
+ [ return __alignof__(long); ],
+ [ lldp_cv_check_alignof="yes" ],
+ [ lldp_cv_check_alignof="no" ])
+ ])
+ if test x"$lldp_cv_check_alignof" = x"yes"; then
+ AC_DEFINE([HAVE_ALIGNOF], [1], [Define if __alignof__ operator is available])
+ fi
+])
#include "lldpd-structs.h"
/* Stolen from CCAN */
-#define ALIGNOF(t) ((sizeof(t) > 1)?((char *)(&((struct { char c; t _h; } *)0)->_h) - (char *)0):1)
+#if HAVE_ALIGNOF
+# define ALIGNOF(t) (__alignof__(t))
+#else
+# define ALIGNOF(t) ((sizeof(t) > 1)?((char *)(&((struct { char c; t _h; } *)0)->_h) - (char *)0):1)
+#endif
/* A serialized object */
struct marshal_serialized {