Skip to content

Commit 10f7d7d

Browse files
committed
std: reorganization that allows new usingnamespace semantics
The proposal #9629 is now accepted, usingnamespace stays but no longer puts identifiers in scope.
1 parent ea70916 commit 10f7d7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2115
-2072
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ set(ZIG_STAGE2_SOURCES
431431
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig"
432432
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
433433
"${CMAKE_SOURCE_DIR}/lib/std/os/windows.zig"
434-
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/bits.zig"
435434
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig"
436435
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/win32error.zig"
437436
"${CMAKE_SOURCE_DIR}/lib/std/Progress.zig"

lib/std/builtin.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub const code_model = builtin.code_model;
2727
/// used rather than `explicit_subsystem`.
2828
/// On non-Windows targets, this is `null`.
2929
pub const subsystem: ?std.Target.SubSystem = blk: {
30-
if (@hasDecl(builtin, "explicit_subsystem")) break :blk explicit_subsystem;
30+
if (@hasDecl(builtin, "explicit_subsystem")) break :blk builtin.explicit_subsystem;
3131
switch (os.tag) {
3232
.windows => {
3333
if (is_test) {

lib/std/c.zig

Lines changed: 211 additions & 287 deletions
Large diffs are not rendered by default.

lib/std/c/darwin.zig

Lines changed: 117 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const builtin = @import("builtin");
44
const macho = std.macho;
55
const native_arch = builtin.target.cpu.arch;
66
const maxInt = std.math.maxInt;
7+
const iovec_const = std.os.iovec_const;
78

89
extern "c" fn __error() *c_int;
910
pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
@@ -84,8 +85,6 @@ pub const _errno = __error;
8485
pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int;
8586
pub extern "c" fn mach_host_self() mach_port_t;
8687
pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t;
87-
pub extern "c" fn host_get_clock_service(host: host_t, clock_id: clock_id_t, clock_serv: ?[*]clock_serv_t) kern_return_t;
88-
pub extern "c" fn mach_port_deallocate(task: ipc_space_t, name: mach_port_name_t) kern_return_t;
8988

9089
pub const sf_hdtr = extern struct {
9190
headers: [*]const iovec_const,
@@ -1550,19 +1549,17 @@ pub fn S_IWHT(m: u32) bool {
15501549

15511550
pub const HOST_NAME_MAX = 72;
15521551

1553-
pub const AT_FDCWD = -2;
1554-
1555-
/// Use effective ids in access check
1556-
pub const AT_EACCESS = 0x0010;
1557-
1558-
/// Act on the symlink itself not the target
1559-
pub const AT_SYMLINK_NOFOLLOW = 0x0020;
1560-
1561-
/// Act on target of symlink
1562-
pub const AT_SYMLINK_FOLLOW = 0x0040;
1563-
1564-
/// Path refers to directory
1565-
pub const AT_REMOVEDIR = 0x0080;
1552+
pub const AT = struct {
1553+
pub const FDCWD = -2;
1554+
/// Use effective ids in access check
1555+
pub const EACCESS = 0x0010;
1556+
/// Act on the symlink itself not the target
1557+
pub const SYMLINK_NOFOLLOW = 0x0020;
1558+
/// Act on target of symlink
1559+
pub const SYMLINK_FOLLOW = 0x0040;
1560+
/// Path refers to directory
1561+
pub const REMOVEDIR = 0x0080;
1562+
};
15661563

15671564
pub const addrinfo = extern struct {
15681565
flags: i32,
@@ -1590,164 +1587,117 @@ pub const RTLD = struct {
15901587
pub const MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
15911588
};
15921589

1593-
/// duplicate file descriptor
1594-
pub const F_DUPFD = 0;
1595-
1596-
/// get file descriptor flags
1597-
pub const F_GETFD = 1;
1598-
1599-
/// set file descriptor flags
1600-
pub const F_SETFD = 2;
1601-
1602-
/// get file status flags
1603-
pub const F_GETFL = 3;
1604-
1605-
/// set file status flags
1606-
pub const F_SETFL = 4;
1607-
1608-
/// get SIGIO/SIGURG proc/pgrp
1609-
pub const F_GETOWN = 5;
1610-
1611-
/// set SIGIO/SIGURG proc/pgrp
1612-
pub const F_SETOWN = 6;
1613-
1614-
/// get record locking information
1615-
pub const F_GETLK = 7;
1616-
1617-
/// set record locking information
1618-
pub const F_SETLK = 8;
1619-
1620-
/// F_SETLK; wait if blocked
1621-
pub const F_SETLKW = 9;
1622-
1623-
/// F_SETLK; wait if blocked, return on timeout
1624-
pub const F_SETLKWTIMEOUT = 10;
1625-
pub const F_FLUSH_DATA = 40;
1626-
1627-
/// Used for regression test
1628-
pub const F_CHKCLEAN = 41;
1629-
1630-
/// Preallocate storage
1631-
pub const F_PREALLOCATE = 42;
1632-
1633-
/// Truncate a file without zeroing space
1634-
pub const F_SETSIZE = 43;
1635-
1636-
/// Issue an advisory read async with no copy to user
1637-
pub const F_RDADVISE = 44;
1638-
1639-
/// turn read ahead off/on for this fd
1640-
pub const F_RDAHEAD = 45;
1641-
1642-
/// turn data caching off/on for this fd
1643-
pub const F_NOCACHE = 48;
1644-
1645-
/// file offset to device offset
1646-
pub const F_LOG2PHYS = 49;
1647-
1648-
/// return the full path of the fd
1649-
pub const F_GETPATH = 50;
1650-
1651-
/// fsync + ask the drive to flush to the media
1652-
pub const F_FULLFSYNC = 51;
1653-
1654-
/// find which component (if any) is a package
1655-
pub const F_PATHPKG_CHECK = 52;
1656-
1657-
/// "freeze" all fs operations
1658-
pub const F_FREEZE_FS = 53;
1659-
1660-
/// "thaw" all fs operations
1661-
pub const F_THAW_FS = 54;
1662-
1663-
/// turn data caching off/on (globally) for this file
1664-
pub const F_GLOBAL_NOCACHE = 55;
1665-
1666-
/// add detached signatures
1667-
pub const F_ADDSIGS = 59;
1668-
1669-
/// add signature from same file (used by dyld for shared libs)
1670-
pub const F_ADDFILESIGS = 61;
1671-
1672-
/// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes
1673-
/// should not be used (i.e. its ok to temporaily create cached pages)
1674-
pub const F_NODIRECT = 62;
1675-
1676-
///Get the protection class of a file from the EA, returns int
1677-
pub const F_GETPROTECTIONCLASS = 63;
1678-
1679-
///Set the protection class of a file for the EA, requires int
1680-
pub const F_SETPROTECTIONCLASS = 64;
1681-
1682-
///file offset to device offset, extended
1683-
pub const F_LOG2PHYS_EXT = 65;
1684-
1685-
///get record locking information, per-process
1686-
pub const F_GETLKPID = 66;
1687-
1688-
///Mark the file as being the backing store for another filesystem
1689-
pub const F_SETBACKINGSTORE = 70;
1690-
1691-
///return the full path of the FD, but error in specific mtmd circumstances
1692-
pub const F_GETPATH_MTMINFO = 71;
1693-
1694-
///Returns the code directory, with associated hashes, to the caller
1695-
pub const F_GETCODEDIR = 72;
1696-
1697-
///No SIGPIPE generated on EPIPE
1698-
pub const F_SETNOSIGPIPE = 73;
1699-
1700-
///Status of SIGPIPE for this fd
1701-
pub const F_GETNOSIGPIPE = 74;
1702-
1703-
///For some cases, we need to rewrap the key for AKS/MKB
1704-
pub const F_TRANSCODEKEY = 75;
1705-
1706-
///file being written to a by single writer... if throttling enabled, writes
1707-
///may be broken into smaller chunks with throttling in between
1708-
pub const F_SINGLE_WRITER = 76;
1709-
1710-
///Get the protection version number for this filesystem
1711-
pub const F_GETPROTECTIONLEVEL = 77;
1712-
1713-
///Add detached code signatures (used by dyld for shared libs)
1714-
pub const F_FINDSIGS = 78;
1715-
1716-
///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
1717-
pub const F_ADDFILESIGS_FOR_DYLD_SIM = 83;
1718-
1719-
///fsync + issue barrier to drive
1720-
pub const F_BARRIERFSYNC = 85;
1721-
1722-
///Add signature from same file, return end offset in structure on success
1723-
pub const F_ADDFILESIGS_RETURN = 97;
1724-
1725-
///Check if Library Validation allows this Mach-O file to be mapped into the calling process
1726-
pub const F_CHECK_LV = 98;
1727-
1728-
///Deallocate a range of the file
1729-
pub const F_PUNCHHOLE = 99;
1730-
1731-
///Trim an active file
1732-
pub const F_TRIM_ACTIVE_FILE = 100;
1590+
pub const F = struct {
1591+
/// duplicate file descriptor
1592+
pub const DUPFD = 0;
1593+
/// get file descriptor flags
1594+
pub const GETFD = 1;
1595+
/// set file descriptor flags
1596+
pub const SETFD = 2;
1597+
/// get file status flags
1598+
pub const GETFL = 3;
1599+
/// set file status flags
1600+
pub const SETFL = 4;
1601+
/// get SIGIO/SIGURG proc/pgrp
1602+
pub const GETOWN = 5;
1603+
/// set SIGIO/SIGURG proc/pgrp
1604+
pub const SETOWN = 6;
1605+
/// get record locking information
1606+
pub const GETLK = 7;
1607+
/// set record locking information
1608+
pub const SETLK = 8;
1609+
/// F.SETLK; wait if blocked
1610+
pub const SETLKW = 9;
1611+
/// F.SETLK; wait if blocked, return on timeout
1612+
pub const SETLKWTIMEOUT = 10;
1613+
pub const FLUSH_DATA = 40;
1614+
/// Used for regression test
1615+
pub const CHKCLEAN = 41;
1616+
/// Preallocate storage
1617+
pub const PREALLOCATE = 42;
1618+
/// Truncate a file without zeroing space
1619+
pub const SETSIZE = 43;
1620+
/// Issue an advisory read async with no copy to user
1621+
pub const RDADVISE = 44;
1622+
/// turn read ahead off/on for this fd
1623+
pub const RDAHEAD = 45;
1624+
/// turn data caching off/on for this fd
1625+
pub const NOCACHE = 48;
1626+
/// file offset to device offset
1627+
pub const LOG2PHYS = 49;
1628+
/// return the full path of the fd
1629+
pub const GETPATH = 50;
1630+
/// fsync + ask the drive to flush to the media
1631+
pub const FULLFSYNC = 51;
1632+
/// find which component (if any) is a package
1633+
pub const PATHPKG_CHECK = 52;
1634+
/// "freeze" all fs operations
1635+
pub const FREEZE_FS = 53;
1636+
/// "thaw" all fs operations
1637+
pub const THAW_FS = 54;
1638+
/// turn data caching off/on (globally) for this file
1639+
pub const GLOBAL_NOCACHE = 55;
1640+
/// add detached signatures
1641+
pub const ADDSIGS = 59;
1642+
/// add signature from same file (used by dyld for shared libs)
1643+
pub const ADDFILESIGS = 61;
1644+
/// used in conjunction with F.NOCACHE to indicate that DIRECT, synchonous writes
1645+
/// should not be used (i.e. its ok to temporaily create cached pages)
1646+
pub const NODIRECT = 62;
1647+
///Get the protection class of a file from the EA, returns int
1648+
pub const GETPROTECTIONCLASS = 63;
1649+
///Set the protection class of a file for the EA, requires int
1650+
pub const SETPROTECTIONCLASS = 64;
1651+
///file offset to device offset, extended
1652+
pub const LOG2PHYS_EXT = 65;
1653+
///get record locking information, per-process
1654+
pub const GETLKPID = 66;
1655+
///Mark the file as being the backing store for another filesystem
1656+
pub const SETBACKINGSTORE = 70;
1657+
///return the full path of the FD, but error in specific mtmd circumstances
1658+
pub const GETPATH_MTMINFO = 71;
1659+
///Returns the code directory, with associated hashes, to the caller
1660+
pub const GETCODEDIR = 72;
1661+
///No SIGPIPE generated on EPIPE
1662+
pub const SETNOSIGPIPE = 73;
1663+
///Status of SIGPIPE for this fd
1664+
pub const GETNOSIGPIPE = 74;
1665+
///For some cases, we need to rewrap the key for AKS/MKB
1666+
pub const TRANSCODEKEY = 75;
1667+
///file being written to a by single writer... if throttling enabled, writes
1668+
///may be broken into smaller chunks with throttling in between
1669+
pub const SINGLE_WRITER = 76;
1670+
///Get the protection version number for this filesystem
1671+
pub const GETPROTECTIONLEVEL = 77;
1672+
///Add detached code signatures (used by dyld for shared libs)
1673+
pub const FINDSIGS = 78;
1674+
///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
1675+
pub const ADDFILESIGS_FOR_DYLD_SIM = 83;
1676+
///fsync + issue barrier to drive
1677+
pub const BARRIERFSYNC = 85;
1678+
///Add signature from same file, return end offset in structure on success
1679+
pub const ADDFILESIGS_RETURN = 97;
1680+
///Check if Library Validation allows this Mach-O file to be mapped into the calling process
1681+
pub const CHECK_LV = 98;
1682+
///Deallocate a range of the file
1683+
pub const PUNCHHOLE = 99;
1684+
///Trim an active file
1685+
pub const TRIM_ACTIVE_FILE = 100;
1686+
///mark the dup with FD_CLOEXEC
1687+
pub const DUPFD_CLOEXEC = 67;
1688+
/// shared or read lock
1689+
pub const RDLCK = 1;
1690+
/// unlock
1691+
pub const UNLCK = 2;
1692+
/// exclusive or write lock
1693+
pub const WRLCK = 3;
1694+
};
17331695

17341696
pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000;
17351697

1736-
///mark the dup with FD_CLOEXEC
1737-
pub const F_DUPFD_CLOEXEC = 67;
1738-
17391698
///close-on-exec flag
17401699
pub const FD_CLOEXEC = 1;
17411700

1742-
/// shared or read lock
1743-
pub const F_RDLCK = 1;
1744-
1745-
/// unlock
1746-
pub const F_UNLCK = 2;
1747-
1748-
/// exclusive or write lock
1749-
pub const F_WRLCK = 3;
1750-
17511701
pub const LOCK = struct {
17521702
pub const SH = 1;
17531703
pub const EX = 2;

0 commit comments

Comments
 (0)