]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared: Make sure ip-protocol-xxx.h headers include <netinet/in.h>
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 30 Apr 2025 19:48:39 +0000 (21:48 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 1 May 2025 14:58:10 +0000 (16:58 +0200)
These headers use macros from <netinet/in.h> so let's make sure they
include the header.

src/shared/meson.build
tools/generate-gperfs.py

index 5fc9cdc9a56ab7ab191551c3d877148288b90eeb..782f4b26250c3afc34b35caa344b3c4602f8f97d 100644 (file)
@@ -279,7 +279,7 @@ gperf_file = custom_target(
         fname,
         input : ip_protocol_list_txt,
         output : fname,
-        command : [generate_gperfs, 'ip_protocol', 'IPPROTO_', '@INPUT@'],
+        command : [generate_gperfs, 'ip_protocol', 'IPPROTO_', '@INPUT@', '<netinet/in.h>'],
         capture : true)
 
 fname = 'ip-protocol-from-name.h'
index 1e22a6140612d488579d3622e2e5e73d7e67d4fe..fc349b43faed5cd2d44bfab9106bbcf5b0319891 100755 (executable)
@@ -9,18 +9,23 @@ Generate %-from-name.gperf from %-list.txt
 import sys
 
 if __name__ == '__main__':
-    if len(sys.argv) != 4:
-        sys.exit(f'Usage: {sys.argv[0]} name prefix file')
+    if len(sys.argv) < 4:
+        sys.exit(f'Usage: {sys.argv[0]} name prefix file [includes...]')
 
-    name, prefix, file = sys.argv[1:]
+    name, prefix, file, *includes = sys.argv[1:]
+    includes = [f"#include {i}" for i in includes]
 
-    print("""\
-%{
-_Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
+    # Older versions of python don't allow backslashes
+    # in f-strings so use chr(10) for newlines and chr(92)
+    # for backslashes instead as a workaround.
+    print(f"""\
+%{{
+_Pragma("GCC diagnostic ignored {chr(92)}"-Wimplicit-fallthrough{chr(92)}"")
 #if __GNUC__ >= 15
-_Pragma("GCC diagnostic ignored \\"-Wzero-as-null-pointer-constant\\"")
+_Pragma("GCC diagnostic ignored {chr(92)}"-Wzero-as-null-pointer-constant{chr(92)}"")
 #endif
-%}""")
+{chr(10).join(includes)}
+%}}""")
     print(f"""\
 struct {name}_name {{ const char* name; int id; }};
 %null-strings