check for typeof() and define HAVE_TYPEOF if available so that we use

the proper implementation of __container_of from xorg's list.h

ok kettenis@
This commit is contained in:
robert 2017-07-27 15:24:55 +00:00
parent e1e9d732f3
commit 06a1409c9f
4 changed files with 69 additions and 0 deletions

View File

@ -129,6 +129,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if typeof works with your compiler. */
#undef HAVE_TYPEOF
/* Enable udev-based monitor hotplug detection */
#undef HAVE_UDEV
@ -257,3 +260,6 @@
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to __typeof__ if your compiler spells it that way. */
#undef typeof

View File

@ -18527,6 +18527,61 @@ fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for typeof syntax and keyword spelling" >&5
$as_echo_n "checking for typeof syntax and keyword spelling... " >&6; }
if ${ac_cv_c_typeof+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_cv_c_typeof=no
for ac_kw in typeof __typeof__ no; do
test $ac_kw = no && break
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
int value;
typedef struct {
char a [1
+ ! (($ac_kw (value))
(($ac_kw (value)) 0 < ($ac_kw (value)) -1
? ($ac_kw (value)) - 1
: ~ (~ ($ac_kw (value)) 0
<< sizeof ($ac_kw (value)))))]; }
ac__typeof_type_;
return
(! ((void) ((ac__typeof_type_ *) 0), 0));
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_typeof=$ac_kw
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
test $ac_cv_c_typeof != no && break
done
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_typeof" >&5
$as_echo "$ac_cv_c_typeof" >&6; }
if test $ac_cv_c_typeof != no; then
$as_echo "#define HAVE_TYPEOF 1" >>confdefs.h
if test $ac_cv_c_typeof != typeof; then
cat >>confdefs.h <<_ACEOF
#define typeof $ac_cv_c_typeof
_ACEOF
fi
fi
# Platform specific settings
case $host_os in
*linux*)

View File

@ -65,6 +65,8 @@ AC_SYS_LARGEFILE
# Check for common libc routines redefined by os.h
AC_CHECK_FUNCS([strlcpy strlcat strndup], [], [])
AC_C_TYPEOF
# Platform specific settings
case $host_os in
*linux*)

View File

@ -305,9 +305,15 @@ list_is_empty(const struct list *head)
#define list_last_entry(ptr, type, member) \
list_entry((ptr)->prev, type, member)
/*
* Do not redefine __container_of, we better off using the one in xorg/list.h.
*/
#ifndef __container_of
#define __container_of(ptr, sample, member) \
(void *)((char *)(ptr) \
- ((char *)&(sample)->member - (char *)(sample)))
#endif
/**
* Loop through the list given by head and set pos to struct in the list.
*