From 3deda15e21ea3a8138d5b628f2649bbbfe7fa910 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 24 Aug 2021 13:43:41 -0700 Subject: std.os reorganization, avoiding `usingnamespace` The main purpose of this branch is to explore avoiding the `usingnamespace` feature of the zig language, specifically with regards to `std.os` and related functionality. If this experiment is successful, it will provide a data point on whether or not it would be practical to entirely remove `usingnamespace` from the language. In this commit, `usingnamespace` has been completely eliminated from the Linux x86_64 compilation path, aside from io_uring. The behavior tests pass, however that's as far as this branch goes. It is very breaking, and a lot more work is needed before it could be considered mergeable. I wanted to put a pull requset up early so that zig programmers have time to provide feedback. This is progress towards closing #6600 since it clarifies where the actual "owner" of each declaration is, and reduces the number of different ways to import the same declarations. One of the main organizational strategies used here is to do namespacing with real namespaces (e.g. structs) rather than by having declarations share a common prefix (the C strategy). It's no coincidence that `usingnamespace` has similar semantics to `#include` and becomes much less necessary when using proper namespaces. --- lib/std/os/bits/linux/securebits.zig | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 lib/std/os/bits/linux/securebits.zig (limited to 'lib/std/os/bits/linux/securebits.zig') diff --git a/lib/std/os/bits/linux/securebits.zig b/lib/std/os/bits/linux/securebits.zig deleted file mode 100644 index a23ced3cf2..0000000000 --- a/lib/std/os/bits/linux/securebits.zig +++ /dev/null @@ -1,35 +0,0 @@ -fn issecure_mask(comptime x: comptime_int) comptime_int { - return 1 << x; -} - -pub const SECUREBITS_DEFAULT = 0x00000000; - -pub const SECURE_NOROOT = 0; -pub const SECURE_NOROOT_LOCKED = 1; - -pub const SECBIT_NOROOT = issecure_mask(SECURE_NOROOT); -pub const SECBIT_NOROOT_LOCKED = issecure_mask(SECURE_NOROOT_LOCKED); - -pub const SECURE_NO_SETUID_FIXUP = 2; -pub const SECURE_NO_SETUID_FIXUP_LOCKED = 3; - -pub const SECBIT_NO_SETUID_FIXUP = issecure_mask(SECURE_NO_SETUID_FIXUP); -pub const SECBIT_NO_SETUID_FIXUP_LOCKED = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED); - -pub const SECURE_KEEP_CAPS = 4; -pub const SECURE_KEEP_CAPS_LOCKED = 5; - -pub const SECBIT_KEEP_CAPS = issecure_mask(SECURE_KEEP_CAPS); -pub const SECBIT_KEEP_CAPS_LOCKED = issecure_mask(SECURE_KEEP_CAPS_LOCKED); - -pub const SECURE_NO_CAP_AMBIENT_RAISE = 6; -pub const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED = 7; - -pub const SECBIT_NO_CAP_AMBIENT_RAISE = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE); -pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED); - -pub const SECURE_ALL_BITS = issecure_mask(SECURE_NOROOT) | - issecure_mask(SECURE_NO_SETUID_FIXUP) | - issecure_mask(SECURE_KEEP_CAPS) | - issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE); -pub const SECURE_ALL_LOCKS = SECURE_ALL_BITS << 1; -- cgit v1.2.3