diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:11:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:11:00 +0000 |
commit | af754e596a8dbb05ed8580c342e7fe02e08b28e0 (patch) | |
tree | b2f334c2b55ede42081aa6710a72da784547d8ea /m4/fr_check_struct_has_member.m4 | |
parent | Initial commit. (diff) | |
download | freeradius-af754e596a8dbb05ed8580c342e7fe02e08b28e0.tar.xz freeradius-af754e596a8dbb05ed8580c342e7fe02e08b28e0.zip |
Adding upstream version 3.2.3+dfsg.upstream/3.2.3+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'm4/fr_check_struct_has_member.m4')
-rw-r--r-- | m4/fr_check_struct_has_member.m4 | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/m4/fr_check_struct_has_member.m4 b/m4/fr_check_struct_has_member.m4 new file mode 100644 index 0000000..57d8b02 --- /dev/null +++ b/m4/fr_check_struct_has_member.m4 @@ -0,0 +1,36 @@ +dnl # +dnl # Look for a header file in a number of places. +dnl # +dnl # Usage: FR_CHECK_STRUCT_HAS_MEMBER([#include <foo.h>], [struct foo], member) +dnl # If the member is defined, then the variable +dnl # ac_cv_type_struct_foo_has_member is set to 'yes' +dnl # +AC_DEFUN([FR_CHECK_STRUCT_HAS_MEMBER], [ + AC_MSG_CHECKING([for $3 in $2]) + +dnl BASED on 'offsetof': +dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +dnl + + AC_TRY_COMPILE([ +$1 +#ifdef HAVE_STDDEF_H +#include <stddef.h> +#endif +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER) +#endif +], + [ int foo = offsetof($2, $3) ], + has_element=" ", + has_element=) + + ac_safe_type=`echo "$2" | sed 'y% %_%'` + if test "x$has_element" != "x"; then + AC_MSG_RESULT(yes) + eval "ac_cv_type_${ac_safe_type}_has_$3=yes" + else + AC_MSG_RESULT(no) + eval "ac_cv_type_${ac_safe_type}_has_$3=" + fi +]) |