diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:49:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:49:46 +0000 |
commit | 50b37d4a27d3295a29afca2286f1a5a086142cec (patch) | |
tree | 9212f763934ee090ef72d823f559f52ce387f268 /m4/fr_check_struct_has_member.m4 | |
parent | Initial commit. (diff) | |
download | freeradius-50b37d4a27d3295a29afca2286f1a5a086142cec.tar.xz freeradius-50b37d4a27d3295a29afca2286f1a5a086142cec.zip |
Adding upstream version 3.2.1+dfsg.upstream/3.2.1+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 +]) |