commit c9f7b4d356a453a01aa77a6bb74ca7ef49732c08 Author: Mike Gilbert Date: Tue Jan 10 02:39:05 2017 -0500 build-sys: add check for gperf lookup function signature (#5055) gperf-3.1 generates lookup functions that take a size_t length parameter instead of unsigned int. Test for this at configure time. Fixes: https://github.com/systemd/systemd/issues/5039 diff --git a/configure.ac b/configure.ac index 11bd46c..d58fff5 100644 --- a/configure.ac +++ b/configure.ac @@ -255,6 +255,28 @@ AC_CHECK_SIZEOF(rlim_t,,[ #include ]) +GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)" + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ + #include + const char * in_word_set(const char *, size_t); + $GPERF_TEST] + )], + [GPERF_LEN_TYPE=size_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ + #include + const char * in_word_set(const char *, unsigned); + $GPERF_TEST] + )], + [GPERF_LEN_TYPE=unsigned], + [AC_MSG_ERROR([** unable to determine gperf len type])] + )] +) + +AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type]) + # ------------------------------------------------------------------------------ # we use python to build the man page index have_python=no diff --git a/src/shared/af-list.c b/src/shared/af-list.c index 3fac9c5..4b291d1 100644 --- a/src/shared/af-list.c +++ b/src/shared/af-list.c @@ -23,7 +23,7 @@ #include "af-list.h" #include "macro.h" -static const struct af_name* lookup_af(register const char *str, register unsigned int len); +static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len); #include "af-from-name.h" #include "af-to-name.h" diff --git a/src/shared/arphrd-list.c b/src/shared/arphrd-list.c index 6792d1e..2d598dc 100644 --- a/src/shared/arphrd-list.c +++ b/src/shared/arphrd-list.c @@ -23,7 +23,7 @@ #include "arphrd-list.h" #include "macro.h" -static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len); +static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len); #include "arphrd-from-name.h" #include "arphrd-to-name.h" diff --git a/src/shared/cap-list.c b/src/shared/cap-list.c index 3e773a0..d68cc78 100644 --- a/src/shared/cap-list.c +++ b/src/shared/cap-list.c @@ -26,7 +26,7 @@ #include "parse-util.h" #include "util.h" -static const struct capability_name* lookup_capability(register const char *str, register unsigned int len); +static const struct capability_name* lookup_capability(register const char *str, register GPERF_LEN_TYPE len); #include "cap-from-name.h" #include "cap-to-name.h" diff --git a/src/shared/errno-list.c b/src/shared/errno-list.c index 31b66ba..c6a01ee 100644 --- a/src/shared/errno-list.c +++ b/src/shared/errno-list.c @@ -23,7 +23,7 @@ #include "errno-list.h" static const struct errno_name* lookup_errno(register const char *str, - register unsigned int len); + register GPERF_LEN_TYPE len); #include "errno-to-name.h" #include "errno-from-name.h" diff --git a/src/login/logind.h b/src/login/logind.h index 086fa1e..7556ee2 100644 --- a/src/login/logind.h +++ b/src/login/logind.h @@ -182,7 +182,7 @@ int manager_unit_is_active(Manager *manager, const char *unit); int manager_job_is_active(Manager *manager, const char *path); /* gperf lookup function */ -const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length); +const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE length); int manager_set_lid_switch_ignore(Manager *m, usec_t until);