Commit 8635275202

Andrew Kelley <andrew@ziglang.org>
2021-11-30 22:26:59
remove linux header files that have case conflicts
similar commit from the past: c73cd05468fba4bba5762a654aacdd9d90ecd272 This also modifies tools/update-linux-headers.zig to remove these same files for next time to prevent a regression. closes #10249
1 parent 51df63a
Changed files (9)
lib
libc
include
any-linux-any
tools
lib/libc/include/any-linux-any/linux/netfilter/xt_CONNMARK.h
@@ -1,7 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _XT_CONNMARK_H_target
-#define _XT_CONNMARK_H_target
-
-#include <linux/netfilter/xt_connmark.h>
-
-#endif /*_XT_CONNMARK_H_target*/
\ No newline at end of file
lib/libc/include/any-linux-any/linux/netfilter/xt_DSCP.h
@@ -1,27 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/* x_tables module for setting the IPv4/IPv6 DSCP field
- *
- * (C) 2002 Harald Welte <laforge@gnumonks.org>
- * based on ipt_FTOS.c (C) 2000 by Matthew G. Marsh <mgm@paktronix.com>
- * This software is distributed under GNU GPL v2, 1991
- *
- * See RFC2474 for a description of the DSCP field within the IP Header.
- *
- * xt_DSCP.h,v 1.7 2002/03/14 12:03:13 laforge Exp
-*/
-#ifndef _XT_DSCP_TARGET_H
-#define _XT_DSCP_TARGET_H
-#include <linux/netfilter/xt_dscp.h>
-#include <linux/types.h>
-
-/* target info */
-struct xt_DSCP_info {
-	__u8 dscp;
-};
-
-struct xt_tos_target_info {
-	__u8 tos_value;
-	__u8 tos_mask;
-};
-
-#endif /* _XT_DSCP_TARGET_H */
\ No newline at end of file
lib/libc/include/any-linux-any/linux/netfilter/xt_MARK.h
@@ -1,7 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _XT_MARK_H_target
-#define _XT_MARK_H_target
-
-#include <linux/netfilter/xt_mark.h>
-
-#endif /*_XT_MARK_H_target */
\ No newline at end of file
lib/libc/include/any-linux-any/linux/netfilter/xt_RATEEST.h
@@ -1,17 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _XT_RATEEST_TARGET_H
-#define _XT_RATEEST_TARGET_H
-
-#include <linux/types.h>
-#include <linux/if.h>
-
-struct xt_rateest_target_info {
-	char			name[IFNAMSIZ];
-	__s8			interval;
-	__u8		ewma_log;
-
-	/* Used internally by the kernel */
-	struct xt_rateest	*est __attribute__((aligned(8)));
-};
-
-#endif /* _XT_RATEEST_TARGET_H */
\ No newline at end of file
lib/libc/include/any-linux-any/linux/netfilter/xt_TCPMSS.h
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _XT_TCPMSS_H
-#define _XT_TCPMSS_H
-
-#include <linux/types.h>
-
-struct xt_tcpmss_info {
-	__u16 mss;
-};
-
-#define XT_TCPMSS_CLAMP_PMTU 0xffff
-
-#endif /* _XT_TCPMSS_H */
\ No newline at end of file
lib/libc/include/any-linux-any/linux/netfilter_ipv4/ipt_ECN.h
@@ -1,34 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/* Header file for iptables ipt_ECN target
- *
- * (C) 2002 by Harald Welte <laforge@gnumonks.org>
- *
- * This software is distributed under GNU GPL v2, 1991
- * 
- * ipt_ECN.h,v 1.3 2002/05/29 12:17:40 laforge Exp
-*/
-#ifndef _IPT_ECN_TARGET_H
-#define _IPT_ECN_TARGET_H
-
-#include <linux/types.h>
-#include <linux/netfilter/xt_DSCP.h>
-
-#define IPT_ECN_IP_MASK	(~XT_DSCP_MASK)
-
-#define IPT_ECN_OP_SET_IP	0x01	/* set ECN bits of IPv4 header */
-#define IPT_ECN_OP_SET_ECE	0x10	/* set ECE bit of TCP header */
-#define IPT_ECN_OP_SET_CWR	0x20	/* set CWR bit of TCP header */
-
-#define IPT_ECN_OP_MASK		0xce
-
-struct ipt_ECN_info {
-	__u8 operation;	/* bitset of operations */
-	__u8 ip_ect;	/* ECT codepoint of IPv4 header, pre-shifted */
-	union {
-		struct {
-			__u8 ece:1, cwr:1; /* TCP ECT bits */
-		} tcp;
-	} proto;
-};
-
-#endif /* _IPT_ECN_TARGET_H */
\ No newline at end of file
lib/libc/include/any-linux-any/linux/netfilter_ipv4/ipt_TTL.h
@@ -1,24 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/* TTL modification module for IP tables
- * (C) 2000 by Harald Welte <laforge@netfilter.org> */
-
-#ifndef _IPT_TTL_H
-#define _IPT_TTL_H
-
-#include <linux/types.h>
-
-enum {
-	IPT_TTL_SET = 0,
-	IPT_TTL_INC,
-	IPT_TTL_DEC
-};
-
-#define IPT_TTL_MAXMODE	IPT_TTL_DEC
-
-struct ipt_TTL_info {
-	__u8	mode;
-	__u8	ttl;
-};
-
-
-#endif
\ No newline at end of file
lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6t_HL.h
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/* Hop Limit modification module for ip6tables
- * Maciej Soltysiak <solt@dns.toxicfilms.tv>
- * Based on HW's TTL module */
-
-#ifndef _IP6T_HL_H
-#define _IP6T_HL_H
-
-#include <linux/types.h>
-
-enum {
-	IP6T_HL_SET = 0,
-	IP6T_HL_INC,
-	IP6T_HL_DEC
-};
-
-#define IP6T_HL_MAXMODE	IP6T_HL_DEC
-
-struct ip6t_HL_info {
-	__u8	mode;
-	__u8	hop_limit;
-};
-
-
-#endif
\ No newline at end of file
tools/update-linux-headers.zig
@@ -130,10 +130,10 @@ const TargetToHash = std.ArrayHashMap(DestTarget, []const u8, DestTarget.HashCon
 const PathTable = std.StringHashMap(*TargetToHash);
 
 pub fn main() !void {
-    var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
-    const allocator = &arena.allocator;
-    const args = try std.process.argsAlloc(allocator);
-    var search_paths = std.ArrayList([]const u8).init(allocator);
+    var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
+    const arena = &arena_state.allocator;
+    const args = try std.process.argsAlloc(arena);
+    var search_paths = std.ArrayList([]const u8).init(arena);
     var opt_out_dir: ?[]const u8 = null;
 
     var arg_i: usize = 1;
@@ -161,8 +161,8 @@ pub fn main() !void {
     const out_dir = opt_out_dir orelse usageAndExit(args[0]);
     const generic_name = "any-linux-any";
 
-    var path_table = PathTable.init(allocator);
-    var hash_to_contents = HashToContents.init(allocator);
+    var path_table = PathTable.init(arena);
+    var hash_to_contents = HashToContents.init(arena);
     var max_bytes_saved: usize = 0;
     var total_bytes: usize = 0;
 
@@ -173,10 +173,10 @@ pub fn main() !void {
             .arch = linux_target.arch,
         };
         search: for (search_paths.items) |search_path| {
-            const target_include_dir = try std.fs.path.join(allocator, &.{
+            const target_include_dir = try std.fs.path.join(arena, &.{
                 search_path, linux_target.name, "include",
             });
-            var dir_stack = std.ArrayList([]const u8).init(allocator);
+            var dir_stack = std.ArrayList([]const u8).init(arena);
             try dir_stack.append(target_include_dir);
 
             while (dir_stack.popOrNull()) |full_dir_name| {
@@ -190,16 +190,16 @@ pub fn main() !void {
                 var dir_it = dir.iterate();
 
                 while (try dir_it.next()) |entry| {
-                    const full_path = try std.fs.path.join(allocator, &[_][]const u8{ full_dir_name, entry.name });
+                    const full_path = try std.fs.path.join(arena, &[_][]const u8{ full_dir_name, entry.name });
                     switch (entry.kind) {
                         .Directory => try dir_stack.append(full_path),
                         .File => {
-                            const rel_path = try std.fs.path.relative(allocator, target_include_dir, full_path);
+                            const rel_path = try std.fs.path.relative(arena, target_include_dir, full_path);
                             const max_size = 2 * 1024 * 1024 * 1024;
-                            const raw_bytes = try std.fs.cwd().readFileAlloc(allocator, full_path, max_size);
+                            const raw_bytes = try std.fs.cwd().readFileAlloc(arena, full_path, max_size);
                             const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
                             total_bytes += raw_bytes.len;
-                            const hash = try allocator.alloc(u8, 32);
+                            const hash = try arena.alloc(u8, 32);
                             hasher = Blake3.init(.{});
                             hasher.update(rel_path);
                             hasher.update(trimmed);
@@ -223,8 +223,8 @@ pub fn main() !void {
                             }
                             const path_gop = try path_table.getOrPut(rel_path);
                             const target_to_hash = if (path_gop.found_existing) path_gop.value_ptr.* else blk: {
-                                const ptr = try allocator.create(TargetToHash);
-                                ptr.* = TargetToHash.init(allocator);
+                                const ptr = try arena.create(TargetToHash);
+                                ptr.* = TargetToHash.init(arena);
                                 path_gop.value_ptr.* = ptr;
                                 break :blk ptr;
                             };
@@ -251,7 +251,7 @@ pub fn main() !void {
     // gets their header in a separate arch directory.
     var path_it = path_table.iterator();
     while (path_it.next()) |path_kv| {
-        var contents_list = std.ArrayList(*Contents).init(allocator);
+        var contents_list = std.ArrayList(*Contents).init(arena);
         {
             var hash_it = path_kv.value_ptr.*.iterator();
             while (hash_it.next()) |hash_kv| {
@@ -263,7 +263,7 @@ pub fn main() !void {
         const best_contents = contents_list.popOrNull().?;
         if (best_contents.hit_count > 1) {
             // worth it to make it generic
-            const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* });
+            const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* });
             try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
             try std.fs.cwd().writeFile(full_path, best_contents.bytes);
             best_contents.is_generic = true;
@@ -288,12 +288,27 @@ pub fn main() !void {
                 .specific => |a| @tagName(a),
                 else => @tagName(dest_target.arch),
             };
-            const out_subpath = try std.fmt.allocPrint(allocator, "{s}-linux-any", .{arch_name});
-            const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, out_subpath, path_kv.key_ptr.* });
+            const out_subpath = try std.fmt.allocPrint(arena, "{s}-linux-any", .{arch_name});
+            const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, out_subpath, path_kv.key_ptr.* });
             try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
             try std.fs.cwd().writeFile(full_path, contents.bytes);
         }
     }
+
+    const bad_files = [_][]const u8{
+        "any-linux-any/linux/netfilter/xt_CONNMARK.h",
+        "any-linux-any/linux/netfilter/xt_DSCP.h",
+        "any-linux-any/linux/netfilter/xt_MARK.h",
+        "any-linux-any/linux/netfilter/xt_RATEEST.h",
+        "any-linux-any/linux/netfilter/xt_TCPMSS.h",
+        "any-linux-any/linux/netfilter_ipv4/ipt_ECN.h",
+        "any-linux-any/linux/netfilter_ipv4/ipt_TTL.h",
+        "any-linux-any/linux/netfilter_ipv6/ip6t_HL.h",
+    };
+    for (bad_files) |bad_file| {
+        const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, bad_file });
+        try std.fs.cwd().deleteFile(full_path);
+    }
 }
 
 fn usageAndExit(arg0: []const u8) noreturn {