chiark / gitweb /
Fix lookup_errno by adding a gperf length parameter detection.
authorSven Eden <yamakuzure@gmx.net>
Thu, 12 Jan 2017 08:28:02 +0000 (09:28 +0100)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:22:32 +0000 (10:22 +0100)
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
configure.ac
src/basic/errno-list.c
src/login/logind.h

index 8e3f7b3cd043d35919d7aaa03bf902d353cd22d4..24f4d0dd69963610d5c018a8a346dd28d3cc1584 100644 (file)
@@ -232,7 +232,29 @@ AC_CHECK_SIZEOF(rlim_t,,[
        #include <sys/resource.h>
 ])
 
        #include <sys/resource.h>
 ])
 
- # ------------------------------------------------------------------------------
+GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)"
+
+AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([
+                #include <string.h>
+                const char * in_word_set(const char *, size_t);
+                $GPERF_TEST]
+        )],
+        [GPERF_LEN_TYPE=size_t],
+        [AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM([
+                        #include <string.h>
+                        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
 AC_ARG_WITH([python],
 # we use python to build the man page index
 have_python=no
 AC_ARG_WITH([python],
index fff37eb3e8438717d5c668b15c9d6eda899a597d..f7f33bb44ae72c4bfd9783c49765c4dae83ce0c6 100644 (file)
 
 #include <string.h>
 
 
 #include <string.h>
 
+#include "config.h"
 #include "util.h"
 #include "errno-list.h"
 
 static const struct errno_name* lookup_errno(register const char *str,
 #include "util.h"
 #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"
 
 #include "errno-to-name.h"
 #include "errno-from-name.h"
index ff96074134edf3b4ab1d5849a54dd08b938d8764..306709e5bb132a1041cd91e5dbe9df5010dd05ed 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdbool.h>
 #include <libudev.h>
 
 #include <stdbool.h>
 #include <libudev.h>
 
+#include "config.h"
 #include "sd-event.h"
 #include "sd-bus.h"
 #include "list.h"
 #include "sd-event.h"
 #include "sd-bus.h"
 #include "list.h"
@@ -179,7 +180,7 @@ int manager_unit_is_active(Manager *manager, const char *unit);
 int manager_job_is_active(Manager *manager, const char *path);
 
 /* gperf lookup function */
 int manager_job_is_active(Manager *manager, const char *path);
 
 /* gperf lookup function */
-const struct ConfigPerfItem* logind_gperf_lookup (const char *str, size_t len);
+const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
 
 int manager_set_lid_switch_ignore(Manager *m, usec_t until);
 
 
 int manager_set_lid_switch_ignore(Manager *m, usec_t until);