2019-05-20 13:15:23 +08:00
|
|
|
const std = @import("../std.zig");
|
|
|
|
const assert = std.debug.assert;
|
|
|
|
const builtin = @import("builtin");
|
|
|
|
const macho = std.macho;
|
|
|
|
|
2019-05-30 06:55:42 +08:00
|
|
|
usingnamespace @import("../os/bits.zig");
|
2018-08-25 15:07:37 +08:00
|
|
|
|
2018-05-31 22:56:59 +08:00
|
|
|
extern "c" fn __error() *c_int;
|
2018-06-04 13:09:15 +08:00
|
|
|
pub extern "c" fn _NSGetExecutablePath(buf: [*]u8, bufsize: *u32) c_int;
|
2018-08-24 04:11:34 +08:00
|
|
|
pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header;
|
2018-01-05 04:30:22 +08:00
|
|
|
|
2019-05-20 13:15:23 +08:00
|
|
|
pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize;
|
2017-03-23 14:59:58 +08:00
|
|
|
|
2018-04-19 02:55:42 +08:00
|
|
|
pub extern "c" fn mach_absolute_time() u64;
|
2018-05-31 22:56:59 +08:00
|
|
|
pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void;
|
2018-04-19 02:55:42 +08:00
|
|
|
|
2018-07-09 13:23:47 +08:00
|
|
|
pub extern "c" fn kevent64(
|
|
|
|
kq: c_int,
|
|
|
|
changelist: [*]const kevent64_s,
|
|
|
|
nchanges: c_int,
|
|
|
|
eventlist: [*]kevent64_s,
|
|
|
|
nevents: c_int,
|
|
|
|
flags: c_uint,
|
|
|
|
timeout: ?*const timespec,
|
|
|
|
) c_int;
|
2018-07-08 14:43:30 +08:00
|
|
|
|
2019-02-19 05:47:30 +08:00
|
|
|
const mach_hdr = if (@sizeOf(usize) == 8) mach_header_64 else mach_header;
|
|
|
|
|
2018-08-24 04:11:34 +08:00
|
|
|
/// The value of the link editor defined symbol _MH_EXECUTE_SYM is the address
|
|
|
|
/// of the mach header in a Mach-O executable file type. It does not appear in
|
|
|
|
/// any file type other than a MH_EXECUTE file type. The type of the symbol is
|
|
|
|
/// absolute as the header is not part of any section.
|
2019-02-19 05:47:30 +08:00
|
|
|
/// This symbol is populated when linking the system's libc, which is guaranteed
|
|
|
|
/// on this operating system. However when building object files or libraries,
|
|
|
|
/// the system libc won't be linked until the final executable. So we
|
|
|
|
/// export a weak symbol here, to be overridden by the real one.
|
|
|
|
pub extern "c" var _mh_execute_header: mach_hdr = undefined;
|
|
|
|
comptime {
|
2019-10-24 13:06:03 +08:00
|
|
|
if (std.Target.current.isDarwin()) {
|
2019-06-20 05:11:36 +08:00
|
|
|
@export("_mh_execute_header", _mh_execute_header, .Weak);
|
2019-05-20 13:15:23 +08:00
|
|
|
}
|
2019-02-19 05:47:30 +08:00
|
|
|
}
|
2018-08-24 04:11:34 +08:00
|
|
|
|
2018-08-25 15:07:37 +08:00
|
|
|
pub const mach_header_64 = macho.mach_header_64;
|
|
|
|
pub const mach_header = macho.mach_header;
|
|
|
|
|
2017-03-23 14:59:58 +08:00
|
|
|
pub const _errno = __error;
|
2017-08-27 12:11:09 +08:00
|
|
|
|
2019-05-20 13:15:23 +08:00
|
|
|
pub extern "c" fn mach_host_self() mach_port_t;
|
|
|
|
pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t;
|
|
|
|
pub extern "c" fn host_get_clock_service(host: host_t, clock_id: clock_id_t, clock_serv: ?[*]clock_serv_t) kern_return_t;
|
|
|
|
pub extern "c" fn mach_port_deallocate(task: ipc_space_t, name: mach_port_name_t) kern_return_t;
|
2017-08-27 12:11:09 +08:00
|
|
|
|
2019-05-20 13:15:23 +08:00
|
|
|
pub fn sigaddset(set: *sigset_t, signo: u5) void {
|
|
|
|
set.* |= u32(1) << (signo - 1);
|
2018-07-08 14:43:30 +08:00
|
|
|
}
|
2019-05-30 04:36:38 +08:00
|
|
|
|
|
|
|
pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
|