aboutsummaryrefslogtreecommitdiff
path: root/lib/std/dynamic_library.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-09-15 14:46:31 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-09-15 14:51:08 -0700
commitf3ebfcae3882c03da84821abed40167ea07a8c78 (patch)
treef1b759c94cba5b020a9ffb141fc62cb686fc5f04 /lib/std/dynamic_library.zig
parent111a2dcf3ad53c0c8ad2c9e7c9bd042b81e90c82 (diff)
parent0395b35cee8d4082cc40b0dcd0298f797f42309d (diff)
downloadzig-f3ebfcae3882c03da84821abed40167ea07a8c78.tar.gz
zig-f3ebfcae3882c03da84821abed40167ea07a8c78.zip
Merge remote-tracking branch 'origin/master' into llvm13
Conflicts: * cmake/Findclang.cmake * cmake/Findlld.cmake * cmake/Findllvm.cmake In master branch, more search paths were added to these files with "12" in the path. In this commit I updated them to "13". * src/stage1/codegen.cpp * src/zig_llvm.cpp * src/zig_llvm.h In master branch, ZigLLVMBuildCmpXchg is improved to add `is_single_threaded`. However, the LLVM 13 C API has this already, and in the llvm13 branch, ZigLLVMBuildCmpXchg is deleted in favor of the C API. In this commit I updated stage2 to use the LLVM 13 C API rather than depending on an improved ZigLLVMBuildCmpXchg. Additionally, src/target.zig largestAtomicBits needed to be updated to include the new m68k ISA.
Diffstat (limited to 'lib/std/dynamic_library.zig')
-rw-r--r--lib/std/dynamic_library.zig26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig
index bd07003bad..fb4cefed0a 100644
--- a/lib/std/dynamic_library.zig
+++ b/lib/std/dynamic_library.zig
@@ -115,7 +115,7 @@ pub const ElfDynLib = struct {
/// Trusts the file. Malicious file will be able to execute arbitrary code.
pub fn open(path: []const u8) !ElfDynLib {
- const fd = try os.open(path, 0, os.O_RDONLY | os.O_CLOEXEC);
+ const fd = try os.open(path, 0, os.O.RDONLY | os.O.CLOEXEC);
defer os.close(fd);
const stat = try os.fstat(fd);
@@ -126,8 +126,8 @@ pub const ElfDynLib = struct {
const file_bytes = try os.mmap(
null,
mem.alignForward(size, mem.page_size),
- os.PROT_READ,
- os.MAP_PRIVATE,
+ os.PROT.READ,
+ os.MAP.PRIVATE,
fd,
0,
);
@@ -160,12 +160,12 @@ pub const ElfDynLib = struct {
}
const dynv = maybe_dynv orelse return error.MissingDynamicLinkingInformation;
- // Reserve the entire range (with no permissions) so that we can do MAP_FIXED below.
+ // Reserve the entire range (with no permissions) so that we can do MAP.FIXED below.
const all_loaded_mem = try os.mmap(
null,
virt_addr_end,
- os.PROT_NONE,
- os.MAP_PRIVATE | os.MAP_ANONYMOUS,
+ os.PROT.NONE,
+ os.MAP.PRIVATE | os.MAP.ANONYMOUS,
-1,
0,
);
@@ -197,7 +197,7 @@ pub const ElfDynLib = struct {
ptr,
extended_memsz,
prot,
- os.MAP_PRIVATE | os.MAP_FIXED,
+ os.MAP.PRIVATE | os.MAP.FIXED,
fd,
ph.p_offset - extra_bytes,
);
@@ -206,7 +206,7 @@ pub const ElfDynLib = struct {
ptr,
extended_memsz,
prot,
- os.MAP_PRIVATE | os.MAP_FIXED | os.MAP_ANONYMOUS,
+ os.MAP.PRIVATE | os.MAP.FIXED | os.MAP.ANONYMOUS,
-1,
0,
);
@@ -294,10 +294,10 @@ pub const ElfDynLib = struct {
}
fn elfToMmapProt(elf_prot: u64) u32 {
- var result: u32 = os.PROT_NONE;
- if ((elf_prot & elf.PF_R) != 0) result |= os.PROT_READ;
- if ((elf_prot & elf.PF_W) != 0) result |= os.PROT_WRITE;
- if ((elf_prot & elf.PF_X) != 0) result |= os.PROT_EXEC;
+ var result: u32 = os.PROT.NONE;
+ if ((elf_prot & elf.PF_R) != 0) result |= os.PROT.READ;
+ if ((elf_prot & elf.PF_W) != 0) result |= os.PROT.WRITE;
+ if ((elf_prot & elf.PF_X) != 0) result |= os.PROT.EXEC;
return result;
}
};
@@ -373,7 +373,7 @@ pub const DlDynlib = struct {
pub fn openZ(path_c: [*:0]const u8) !DlDynlib {
return DlDynlib{
- .handle = system.dlopen(path_c, system.RTLD_LAZY) orelse {
+ .handle = system.dlopen(path_c, system.RTLD.LAZY) orelse {
return error.FileNotFound;
},
};