| author | |
| committer | |
| log | 8f5c333ebe6631629be3b88d797a03b1d677d439 |
| tree | 4efdeeee8434dcbc0f694eff367adecee521f00f |
| parent | 928d43f61a9b08fd9c83964c34a29cca85839226 |
| parent | 04d5e07d407af5382ec5e721dee485855928318f |
| signature |
audit all contributions by @devnexen for correctness and delete unnecessary libc ABI bits17 files changed, 146 insertions(+), 1793 deletions(-)
lib/std/Thread.zig+1-1| ... | @@ -695,7 +695,7 @@ const PosixThreadImpl = struct { | ... | @@ -695,7 +695,7 @@ const PosixThreadImpl = struct { |
| 695 | defer assert(c.pthread_attr_destroy(&attr) == .SUCCESS); | 695 | defer assert(c.pthread_attr_destroy(&attr) == .SUCCESS); |
| 696 | 696 | ||
| 697 | // Use the same set of parameters used by the libc-less impl. | 697 | // Use the same set of parameters used by the libc-less impl. |
| 698 | const stack_size = @max(config.stack_size, c.PTHREAD_STACK_MIN); | 698 | const stack_size = @max(config.stack_size, 16 * 1024); |
| 699 | assert(c.pthread_attr_setstacksize(&attr, stack_size) == .SUCCESS); | 699 | assert(c.pthread_attr_setstacksize(&attr, stack_size) == .SUCCESS); |
| 700 | assert(c.pthread_attr_setguardsize(&attr, std.mem.page_size) == .SUCCESS); | 700 | assert(c.pthread_attr_setguardsize(&attr, std.mem.page_size) == .SUCCESS); |
| 701 | 701 |
lib/std/c.zig-5| ... | @@ -408,11 +408,6 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int; | ... | @@ -408,11 +408,6 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int; |
| 408 | 408 | ||
| 409 | pub extern "c" fn if_nametoindex([*:0]const u8) c_int; | 409 | pub extern "c" fn if_nametoindex([*:0]const u8) c_int; |
| 410 | 410 | ||
| 411 | pub extern "c" fn timer_create(clockid: c.clockid_t, sevp: *c.sigevent, timerid: *c.timer_t) c_int; | ||
| 412 | pub extern "c" fn timer_delete(timerid: c.timer_t) c_int; | ||
| 413 | pub extern "c" fn timer_settime(timerid: c.timer_t, flags: c_int, new_value: *const c.itimerspec, old_value: *c.itimerspec) c_int; | ||
| 414 | pub extern "c" fn timer_gettime(timerid: c.timer_t, flags: c_int, curr_value: *c.itimerspec) c_int; | ||
| 415 | |||
| 416 | pub usingnamespace if (builtin.os.tag == .linux and builtin.target.isMusl()) struct { | 411 | pub usingnamespace if (builtin.os.tag == .linux and builtin.target.isMusl()) struct { |
| 417 | // musl does not implement getcontext | 412 | // musl does not implement getcontext |
| 418 | pub const getcontext = std.os.linux.getcontext; | 413 | pub const getcontext = std.os.linux.getcontext; |
lib/std/c/darwin.zig+5-332| ... | @@ -161,67 +161,13 @@ pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header; | ... | @@ -161,67 +161,13 @@ pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header; |
| 161 | pub extern "c" fn _dyld_get_image_vmaddr_slide(image_index: u32) usize; | 161 | pub extern "c" fn _dyld_get_image_vmaddr_slide(image_index: u32) usize; |
| 162 | pub extern "c" fn _dyld_get_image_name(image_index: u32) [*:0]const u8; | 162 | pub extern "c" fn _dyld_get_image_name(image_index: u32) [*:0]const u8; |
| 163 | 163 | ||
| 164 | pub const COPYFILE = struct { | 164 | pub const COPYFILE_ACL = 1 << 0; |
| 165 | pub const ACL = 1 << 0; | 165 | pub const COPYFILE_STAT = 1 << 1; |
| 166 | pub const STAT = 1 << 1; | 166 | pub const COPYFILE_XATTR = 1 << 2; |
| 167 | pub const XATTR = 1 << 2; | 167 | pub const COPYFILE_DATA = 1 << 3; |
| 168 | pub const DATA = 1 << 3; | ||
| 169 | pub const SECURITY = COPYFILE.STAT | COPYFILE.ACL; | ||
| 170 | pub const METADATA = COPYFILE.SECURITY | COPYFILE.XATTR; | ||
| 171 | pub const ALL = COPYFILE.METADATA | COPYFILE.DATA; | ||
| 172 | pub const RECURSIVE = 1 << 15; | ||
| 173 | pub const CHECK = 1 << 16; | ||
| 174 | pub const EXCL = 1 << 17; | ||
| 175 | pub const NOFOLLOW_SRC = 1 << 18; | ||
| 176 | pub const NOFOLLOW_DST = 1 << 19; | ||
| 177 | pub const MOVE = 1 << 20; | ||
| 178 | pub const UNLINK = 1 << 21; | ||
| 179 | pub const NOFOLLOW = COPYFILE.NOFOLLOW_SRC | NOFOLLOW_DST; | ||
| 180 | pub const PACK = 1 << 22; | ||
| 181 | pub const UNPACK = 1 << 23; | ||
| 182 | pub const CLONE = 1 << 24; | ||
| 183 | pub const CLONE_FORCE = 1 << 25; | ||
| 184 | pub const RUN_IN_PLACE = 1 << 26; | ||
| 185 | pub const DATA_SPARSE = 1 << 27; | ||
| 186 | pub const PRESERVE_DST_TRACKED = 1 << 28; | ||
| 187 | pub const VERBOSE = 1 << 30; | ||
| 188 | pub const RECURSE_ERROR = 0; | ||
| 189 | pub const RECURSE_FILE = 1; | ||
| 190 | pub const RECURSE_DIR = 2; | ||
| 191 | pub const RECURSE_DIR_CLEANUP = 3; | ||
| 192 | pub const COPY_DATA = 4; | ||
| 193 | pub const COPY_XATTR = 5; | ||
| 194 | pub const START = 1; | ||
| 195 | pub const FINISH = 2; | ||
| 196 | pub const ERR = 3; | ||
| 197 | pub const PROGRESS = 4; | ||
| 198 | pub const CONTINUE = 0; | ||
| 199 | pub const SKIP = 1; | ||
| 200 | pub const QUIT = 2; | ||
| 201 | pub const STATE_SRC_FD = 1; | ||
| 202 | pub const STATE_SRC_FILENAME = 2; | ||
| 203 | pub const STATE_DST_FD = 3; | ||
| 204 | pub const STATE_DST_FILENAME = 4; | ||
| 205 | pub const STATE_QUARANTINE = 5; | ||
| 206 | pub const STATE_STATUS_CB = 6; | ||
| 207 | pub const STATE_STATUS_CTX = 7; | ||
| 208 | pub const STATE_COPIED = 8; | ||
| 209 | pub const STATE_XATTRNAME = 9; | ||
| 210 | pub const STATE_WAS_CLONED = 10; | ||
| 211 | pub const STATE_SRC_BSIZE = 11; | ||
| 212 | pub const STATE_DST_BSIZE = 12; | ||
| 213 | pub const STATE_BSIZE = 13; | ||
| 214 | pub const DISABLE_VAR: [*]u8 = "COPYFILE_DISABLE"; | ||
| 215 | }; | ||
| 216 | 168 | ||
| 217 | pub const copyfile_state_t = *opaque {}; | 169 | pub const copyfile_state_t = *opaque {}; |
| 218 | pub const copyfile_flags_t = u32; | 170 | pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: u32) c_int; |
| 219 | pub extern "c" fn fcopyfile(from: fd_t, to: fd_t, state: ?copyfile_state_t, flags: copyfile_flags_t) c_int; | ||
| 220 | pub extern "c" fn copyfile(from: [*:0]u8, to: [*:0]u8, state: ?copyfile_state_t, flags: copyfile_flags_t) c_int; | ||
| 221 | pub extern "c" fn copyfile_state_alloc() copyfile_state_t; | ||
| 222 | pub extern "c" fn copyfile_state_free(state: copyfile_state_t) void; | ||
| 223 | pub extern "c" fn copyfile_state_get(s: copyfile_state_t, flag: u32, dst: ?*anyopaque) c_int; | ||
| 224 | pub extern "c" fn copyfile_state_set(s: copyfile_state_t, flag: u32, dst: ?*const anyopaque) c_int; | ||
| 225 | 171 | ||
| 226 | pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; | 172 | pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; |
| 227 | pub const realpath = @"realpath$DARWIN_EXTSN"; | 173 | pub const realpath = @"realpath$DARWIN_EXTSN"; |
| ... | @@ -949,35 +895,7 @@ pub extern "c" fn pthread_attr_get_qos_class_np(attr: *pthread_attr_t, qos_class | ... | @@ -949,35 +895,7 @@ pub extern "c" fn pthread_attr_get_qos_class_np(attr: *pthread_attr_t, qos_class |
| 949 | pub extern "c" fn pthread_set_qos_class_self_np(qos_class: qos_class_t, relative_priority: c_int) c_int; | 895 | pub extern "c" fn pthread_set_qos_class_self_np(qos_class: qos_class_t, relative_priority: c_int) c_int; |
| 950 | pub extern "c" fn pthread_get_qos_class_np(pthread: std.c.pthread_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int; | 896 | pub extern "c" fn pthread_get_qos_class_np(pthread: std.c.pthread_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int; |
| 951 | 897 | ||
| 952 | pub const CCryptorStatus = enum(i32) { | ||
| 953 | /// Operation completed | ||
| 954 | kCCSuccess = 0, | ||
| 955 | /// Illegal parameter | ||
| 956 | kCCParamError = -4300, | ||
| 957 | /// Provided buffer too small | ||
| 958 | kCCBufferTooSmall = -4301, | ||
| 959 | /// Failed memory allocation | ||
| 960 | kCCMemoryFailure = -4302, | ||
| 961 | /// Size alignment issue | ||
| 962 | kCCAlignmentError = -4303, | ||
| 963 | /// Decoding issue | ||
| 964 | kCCDecodeError = -4304, | ||
| 965 | /// Call not implemented | ||
| 966 | kCCUnimplemented = -4305, | ||
| 967 | kCCOverflow = -4306, | ||
| 968 | kCCRNGFailure = -4307, | ||
| 969 | /// Unspecified error | ||
| 970 | kCCUnspecifiedError = -4308, | ||
| 971 | kCCCallSequenceError = -4309, | ||
| 972 | kCCKeySizeError = -4310, | ||
| 973 | /// Invalid key | ||
| 974 | kCCInvalidKey = -4311, | ||
| 975 | }; | ||
| 976 | |||
| 977 | pub const CCRNGStatus = CCryptorStatus; | ||
| 978 | |||
| 979 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | 898 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; |
| 980 | pub extern "c" fn CCRandomGenerateBytes(bytes: ?*anyopaque, count: usize) CCRNGStatus; | ||
| 981 | 899 | ||
| 982 | // Grand Central Dispatch is exposed by libSystem. | 900 | // Grand Central Dispatch is exposed by libSystem. |
| 983 | pub extern "c" fn dispatch_release(object: *anyopaque) void; | 901 | pub extern "c" fn dispatch_release(object: *anyopaque) void; |
| ... | @@ -3926,248 +3844,3 @@ pub extern "c" fn os_signpost_interval_begin(log: os_log_t, signpos: os_signpost | ... | @@ -3926,248 +3844,3 @@ pub extern "c" fn os_signpost_interval_begin(log: os_log_t, signpos: os_signpost |
| 3926 | pub extern "c" fn os_signpost_interval_end(log: os_log_t, signpos: os_signpost_id_t, func: [*]const u8, ...) void; | 3844 | pub extern "c" fn os_signpost_interval_end(log: os_log_t, signpos: os_signpost_id_t, func: [*]const u8, ...) void; |
| 3927 | pub extern "c" fn os_signpost_id_make_with_pointer(log: os_log_t, ptr: ?*anyopaque) os_signpost_id_t; | 3845 | pub extern "c" fn os_signpost_id_make_with_pointer(log: os_log_t, ptr: ?*anyopaque) os_signpost_id_t; |
| 3928 | pub extern "c" fn os_signpost_enabled(log: os_log_t) bool; | 3846 | pub extern "c" fn os_signpost_enabled(log: os_log_t) bool; |
| 3929 | |||
| 3930 | pub extern "c" fn proc_listpids(tpe: u32, tinfo: u32, buffer: ?*anyopaque, buffersize: c_int) c_int; | ||
| 3931 | pub extern "c" fn proc_listallpids(buffer: ?*anyopaque, buffersize: c_int) c_int; | ||
| 3932 | pub extern "c" fn proc_listpgrppids(pgrpid: pid_t, buffer: ?*anyopaque, buffersize: c_int) c_int; | ||
| 3933 | pub extern "c" fn proc_listchildpids(ppid: pid_t, buffer: ?*anyopaque, buffersize: c_int) c_int; | ||
| 3934 | pub extern "c" fn proc_pidinfo(pid: c_int, flavor: c_int, arg: u64, buffer: ?*anyopaque, buffersize: c_int) c_int; | ||
| 3935 | pub extern "c" fn proc_name(pid: c_int, buffer: ?*anyopaque, buffersize: u32) c_int; | ||
| 3936 | pub extern "c" fn proc_pidpath(pid: c_int, buffer: ?*anyopaque, buffersize: u32) c_int; | ||
| 3937 | |||
| 3938 | pub const MIN = struct { | ||
| 3939 | pub const INCORE = 0x1; | ||
| 3940 | pub const REFERENCED = 0x2; | ||
| 3941 | pub const MODIFIED = 0x4; | ||
| 3942 | pub const REFERENCED_OTHER = 0x8; | ||
| 3943 | pub const MODIFIED_OTHER = 0x10; | ||
| 3944 | pub const PAGED_OUT = 0x20; | ||
| 3945 | pub const COPIED = 0x40; | ||
| 3946 | pub const ANONYMOUS = 0x80; | ||
| 3947 | }; | ||
| 3948 | |||
| 3949 | pub extern "c" fn mincore(addr: *align(std.mem.page_size) const anyopaque, length: usize, vec: [*]u8) c_int; | ||
| 3950 | pub extern "c" fn os_proc_available_memory() usize; | ||
| 3951 | |||
| 3952 | pub const thread_affinity_policy = extern struct { | ||
| 3953 | tag: integer_t, | ||
| 3954 | }; | ||
| 3955 | |||
| 3956 | pub const thread_policy_flavor_t = natural_t; | ||
| 3957 | pub const thread_policy_t = [*]integer_t; | ||
| 3958 | pub const thread_affinity_policy_data_t = thread_affinity_policy; | ||
| 3959 | pub const thread_affinity_policy_t = [*]thread_affinity_policy; | ||
| 3960 | |||
| 3961 | pub const THREAD_AFFINITY = struct { | ||
| 3962 | pub const POLICY = 0; | ||
| 3963 | pub const POLICY_COUNT = @as(mach_msg_type_number_t, @intCast(@sizeOf(thread_affinity_policy_data_t) / @sizeOf(integer_t))); | ||
| 3964 | }; | ||
| 3965 | |||
| 3966 | /// cpu affinity api | ||
| 3967 | /// albeit it is also available on arm64, it always fails as in this architecture there is no sense of | ||
| 3968 | /// individual cpus (high performance cpus group and low consumption one), thus the pthread QOS api is more appropriate in this case. | ||
| 3969 | pub extern "c" fn thread_affinity_get(thread: thread_act_t, flavor: thread_policy_flavor_t, info: thread_policy_t, infocnt: [*]mach_msg_type_number_t, default: *boolean_t) kern_return_t; | ||
| 3970 | pub extern "c" fn thread_affinity_set(thread: thread_act_t, flavor: thread_policy_flavor_t, info: thread_policy_t, infocnt: mach_msg_type_number_t) kern_return_t; | ||
| 3971 | |||
| 3972 | pub const cpu_type_t = integer_t; | ||
| 3973 | pub const cpu_subtype_t = integer_t; | ||
| 3974 | pub const cpu_threadtype_t = integer_t; | ||
| 3975 | pub const host_flavor_t = integer_t; | ||
| 3976 | pub const host_info_t = *integer_t; | ||
| 3977 | pub const host_info64_t = *integer_t; | ||
| 3978 | pub const host_can_has_debugger_info = extern struct { | ||
| 3979 | can_has_debugger: boolean_t, | ||
| 3980 | }; | ||
| 3981 | pub const host_can_has_debugger_info_data_t = host_can_has_debugger_info; | ||
| 3982 | pub const host_can_has_debugger_info_t = *host_can_has_debugger_info; | ||
| 3983 | |||
| 3984 | pub const host_sched_info = extern struct { | ||
| 3985 | min_timeout: integer_t, | ||
| 3986 | min_quantum: integer_t, | ||
| 3987 | }; | ||
| 3988 | pub const host_sched_info_data_t = host_sched_info; | ||
| 3989 | pub const host_sched_info_t = *host_sched_info; | ||
| 3990 | |||
| 3991 | pub const kernel_resource_sizes = extern struct { | ||
| 3992 | task: natural_t, | ||
| 3993 | thread: natural_t, | ||
| 3994 | port: natural_t, | ||
| 3995 | memory_region: natural_t, | ||
| 3996 | memory_object: natural_t, | ||
| 3997 | }; | ||
| 3998 | |||
| 3999 | pub const kernel_resource_sizes_data_t = kernel_resource_sizes; | ||
| 4000 | pub const kernel_resource_sizes_t = *kernel_resource_sizes; | ||
| 4001 | |||
| 4002 | pub const host_priority_info = extern struct { | ||
| 4003 | kernel_priority: integer_t, | ||
| 4004 | system_priority: integer_t, | ||
| 4005 | server_priority: integer_t, | ||
| 4006 | user_priority: integer_t, | ||
| 4007 | depress_priority: integer_t, | ||
| 4008 | idle_priority: integer_t, | ||
| 4009 | minimum_priority: integer_t, | ||
| 4010 | maximum_priority: integer_t, | ||
| 4011 | }; | ||
| 4012 | |||
| 4013 | pub const host_priority_info_data_t = host_priority_info; | ||
| 4014 | pub const host_priority_info_t = *host_priority_info; | ||
| 4015 | |||
| 4016 | pub const CPU_STATE_MAX = 4; | ||
| 4017 | |||
| 4018 | pub const host_cpu_load_info = extern struct { | ||
| 4019 | cpu_ticks: [CPU_STATE_MAX]natural_t, | ||
| 4020 | }; | ||
| 4021 | |||
| 4022 | pub const host_cpu_load_info_data_t = host_cpu_load_info; | ||
| 4023 | pub const host_cpu_load_info_t = *host_cpu_load_info; | ||
| 4024 | |||
| 4025 | pub const host_load_info = extern struct { | ||
| 4026 | avenrun: [3]integer_t, | ||
| 4027 | mach_factor: [3]integer_t, | ||
| 4028 | }; | ||
| 4029 | |||
| 4030 | pub const host_load_info_data_t = host_load_info; | ||
| 4031 | pub const host_load_info_t = *host_load_info; | ||
| 4032 | |||
| 4033 | pub const host_preferred_user_arch = extern struct { | ||
| 4034 | cpu_type: cpu_type_t, | ||
| 4035 | cpu_subtype: cpu_subtype_t, | ||
| 4036 | }; | ||
| 4037 | |||
| 4038 | pub const host_preferred_user_arch_data_t = host_preferred_user_arch; | ||
| 4039 | pub const host_preferred_user_arch_t = *host_preferred_user_arch; | ||
| 4040 | |||
| 4041 | fn HostCount(comptime HT: type) mach_msg_type_number_t { | ||
| 4042 | return @as(mach_msg_type_number_t, @intCast(@sizeOf(HT) / @sizeOf(integer_t))); | ||
| 4043 | } | ||
| 4044 | |||
| 4045 | pub const HOST = struct { | ||
| 4046 | pub const BASIC_INFO = 1; | ||
| 4047 | pub const SCHED_INFO = 3; | ||
| 4048 | pub const RESOURCE_SIZES = 4; | ||
| 4049 | pub const PRIORITY_INFO = 5; | ||
| 4050 | pub const SEMAPHORE_TRAPS = 7; | ||
| 4051 | pub const MACH_MSG_TRAPS = 8; | ||
| 4052 | pub const VM_PURGEABLE = 9; | ||
| 4053 | pub const DEBUG_INFO_INTERNAL = 10; | ||
| 4054 | pub const CAN_HAS_DEBUGGER = 11; | ||
| 4055 | pub const PREFERRED_USER_ARCH = 12; | ||
| 4056 | pub const LOAD_INFO = 1; | ||
| 4057 | pub const VM_INFO = 2; | ||
| 4058 | pub const CPU_LOAD_INFO = 3; | ||
| 4059 | pub const VM_INFO64 = 4; | ||
| 4060 | pub const EXTMOD_INFO64 = 5; | ||
| 4061 | pub const EXPIRED_TASK_INFO = 6; | ||
| 4062 | pub const CAN_HAS_DEBUGGER_COUNT = HostCount(host_can_has_debugger_info_data_t); | ||
| 4063 | pub const SCHED_INFO_COUNT = HostCount(host_sched_info_data_t); | ||
| 4064 | pub const RESOURCES_SIZES_COUNT = HostCount(kernel_resource_sizes_data_t); | ||
| 4065 | pub const PRIORITY_INFO_COUNT = HostCount(host_priority_info_data_t); | ||
| 4066 | pub const CPU_LOAD_INFO_COUNT = HostCount(host_cpu_load_info_data_t); | ||
| 4067 | pub const LOAD_INFO_COUNT = HostCount(host_load_info_data_t); | ||
| 4068 | pub const PREFERRED_USER_ARCH_COUNT = HostCount(host_preferred_user_arch_data_t); | ||
| 4069 | pub const VM_INFO_COUNT = HostCount(vm_statistics_data_t); | ||
| 4070 | pub const VM_INFO64_COUNT = HostCount(vm_statistics64_data_t); | ||
| 4071 | pub const EXTMOD_INFO64_COUNT = HostCount(vm_extmod_statistics_data_t); | ||
| 4072 | }; | ||
| 4073 | |||
| 4074 | pub const host_basic_info = extern struct { | ||
| 4075 | max_cpus: integer_t, | ||
| 4076 | avail_cpus: integer_t, | ||
| 4077 | memory_size: natural_t, | ||
| 4078 | cpu_type: cpu_type_t, | ||
| 4079 | cpu_subtype: cpu_subtype_t, | ||
| 4080 | cpu_threadtype: cpu_threadtype_t, | ||
| 4081 | physical_cpu: integer_t, | ||
| 4082 | physical_cpu_max: integer_t, | ||
| 4083 | logical_cpu: integer_t, | ||
| 4084 | logical_cpu_max: integer_t, | ||
| 4085 | max_mem: u64, | ||
| 4086 | }; | ||
| 4087 | |||
| 4088 | pub extern "c" fn host_info(host: host_t, flavor: host_flavor_t, info_out: host_info_t, info_outCnt: [*]mach_msg_type_number_t) kern_return_t; | ||
| 4089 | pub extern "c" fn host_statistics(priv: host_t, flavor: host_flavor_t, info_out: host_info_t, info_outCnt: [*]mach_msg_type_number_t) kern_return_t; | ||
| 4090 | pub extern "c" fn host_statistics64(priv: host_t, flavor: host_flavor_t, info_out: host_info64_t, info64_outCnt: [*]mach_msg_type_number_t) kern_return_t; | ||
| 4091 | |||
| 4092 | pub const vm_statistics = extern struct { | ||
| 4093 | free_count: natural_t, | ||
| 4094 | active_count: natural_t, | ||
| 4095 | inactive_count: natural_t, | ||
| 4096 | wire_count: natural_t, | ||
| 4097 | zero_fill_count: natural_t, | ||
| 4098 | reactivations: natural_t, | ||
| 4099 | pageins: natural_t, | ||
| 4100 | pageouts: natural_t, | ||
| 4101 | faults: natural_t, | ||
| 4102 | cow_faults: natural_t, | ||
| 4103 | lookups: natural_t, | ||
| 4104 | hits: natural_t, | ||
| 4105 | purgeable_count: natural_t, | ||
| 4106 | purges: natural_t, | ||
| 4107 | speculative_count: natural_t, | ||
| 4108 | }; | ||
| 4109 | |||
| 4110 | pub const vm_statistics_t = *vm_statistics; | ||
| 4111 | pub const vm_statistics_data_t = vm_statistics; | ||
| 4112 | |||
| 4113 | pub const vm_statistics64 align(8) = extern struct { | ||
| 4114 | free_count: natural_t, | ||
| 4115 | active_count: natural_t, | ||
| 4116 | inactive_count: natural_t, | ||
| 4117 | wire_count: natural_t, | ||
| 4118 | zero_fill_count: u64, | ||
| 4119 | reactivations: u64, | ||
| 4120 | pageins: u64, | ||
| 4121 | pageouts: u64, | ||
| 4122 | faults: u64, | ||
| 4123 | cow_faults: u64, | ||
| 4124 | lookups: u64, | ||
| 4125 | hits: u64, | ||
| 4126 | purges: u64, | ||
| 4127 | purgeable_count: natural_t, | ||
| 4128 | speculative_count: natural_t, | ||
| 4129 | decompressions: u64, | ||
| 4130 | compressions: u64, | ||
| 4131 | swapins: u64, | ||
| 4132 | swapouts: u64, | ||
| 4133 | compressor_page_count: natural_t, | ||
| 4134 | throttled_count: natural_t, | ||
| 4135 | external_page_count: natural_t, | ||
| 4136 | internal_page_count: natural_t, | ||
| 4137 | total_uncompressed_pages_in_compressor: u64, | ||
| 4138 | }; | ||
| 4139 | |||
| 4140 | pub const vm_statistics64_t = *vm_statistics64; | ||
| 4141 | pub const vm_statistics64_data_t = vm_statistics64; | ||
| 4142 | |||
| 4143 | pub const vm_extmod_statistics align(8) = extern struct { | ||
| 4144 | task_for_pid_count: i64, | ||
| 4145 | task_for_pid_caller_count: i64, | ||
| 4146 | thread_creation_count: i64, | ||
| 4147 | thread_creation_caller_count: i64, | ||
| 4148 | thread_set_state_count: i64, | ||
| 4149 | thread_set_state_caller_count: i64, | ||
| 4150 | }; | ||
| 4151 | |||
| 4152 | pub const vm_extmod_statistics_t = *vm_extmod_statistics; | ||
| 4153 | pub const vm_extmod_statistics_data_t = vm_extmod_statistics; | ||
| 4154 | |||
| 4155 | pub extern "c" fn vm_stats(info: ?*anyopaque, count: *c_uint) kern_return_t; | ||
| 4156 | |||
| 4157 | /// TODO refines if necessary | ||
| 4158 | pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) { | ||
| 4159 | .arm, .aarch64 => 16 * 1024, | ||
| 4160 | else => 8 * 1024, | ||
| 4161 | }; | ||
| 4162 | |||
| 4163 | pub const _SYS_NAMELEN = 256; | ||
| 4164 | |||
| 4165 | pub const utsname = extern struct { | ||
| 4166 | sysname: [255:0]u8, | ||
| 4167 | nodename: [255:0]u8, | ||
| 4168 | release: [255:0]u8, | ||
| 4169 | version: [255:0]u8, | ||
| 4170 | machine: [255:0]u8, | ||
| 4171 | }; | ||
| 4172 | |||
| 4173 | pub extern "c" fn uname(u: *utsname) c_int; |
lib/std/c/dragonfly.zig+7-29| ... | @@ -21,7 +21,6 @@ pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*an | ... | @@ -21,7 +21,6 @@ pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*an |
| 21 | pub extern "c" fn lwp_gettid() c_int; | 21 | pub extern "c" fn lwp_gettid() c_int; |
| 22 | 22 | ||
| 23 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | 23 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; |
| 24 | pub extern "c" fn malloc_usable_size(?*const anyopaque) usize; | ||
| 25 | 24 | ||
| 26 | pub const pthread_mutex_t = extern struct { | 25 | pub const pthread_mutex_t = extern struct { |
| 27 | inner: ?*anyopaque = null, | 26 | inner: ?*anyopaque = null, |
| ... | @@ -889,13 +888,13 @@ pub const cmsghdr = extern struct { | ... | @@ -889,13 +888,13 @@ pub const cmsghdr = extern struct { |
| 889 | cmsg_type: c_int, | 888 | cmsg_type: c_int, |
| 890 | }; | 889 | }; |
| 891 | pub const msghdr = extern struct { | 890 | pub const msghdr = extern struct { |
| 892 | name: ?*anyopaque, | 891 | msg_name: ?*anyopaque, |
| 893 | namelen: socklen_t, | 892 | msg_namelen: socklen_t, |
| 894 | iov: [*]iovec, | 893 | msg_iov: [*]iovec, |
| 895 | iovlen: c_int, | 894 | msg_iovlen: c_int, |
| 896 | control: ?*anyopaque, | 895 | msg_control: ?*anyopaque, |
| 897 | controllen: socklen_t, | 896 | msg_controllen: socklen_t, |
| 898 | flags: c_int, | 897 | msg_flags: c_int, |
| 899 | }; | 898 | }; |
| 900 | pub const cmsgcred = extern struct { | 899 | pub const cmsgcred = extern struct { |
| 901 | cmcred_pid: pid_t, | 900 | cmcred_pid: pid_t, |
| ... | @@ -1144,24 +1143,3 @@ pub const POLL = struct { | ... | @@ -1144,24 +1143,3 @@ pub const POLL = struct { |
| 1144 | pub const HUP = 0x0010; | 1143 | pub const HUP = 0x0010; |
| 1145 | pub const NVAL = 0x0020; | 1144 | pub const NVAL = 0x0020; |
| 1146 | }; | 1145 | }; |
| 1147 | |||
| 1148 | pub const SIGEV = struct { | ||
| 1149 | pub const NONE = 0; | ||
| 1150 | pub const SIGNAL = 1; | ||
| 1151 | pub const THREAD = 2; | ||
| 1152 | }; | ||
| 1153 | |||
| 1154 | pub const sigevent = extern struct { | ||
| 1155 | sigev_notify: c_int, | ||
| 1156 | __sigev_u: extern union { | ||
| 1157 | __sigev_signo: c_int, | ||
| 1158 | __sigev_notify_kqueue: c_int, | ||
| 1159 | __sigev_notify_attributes: ?*pthread_attr_t, | ||
| 1160 | }, | ||
| 1161 | sigev_value: sigval, | ||
| 1162 | sigev_notify_function: ?*const fn (sigval) callconv(.C) void, | ||
| 1163 | }; | ||
| 1164 | |||
| 1165 | pub const PTHREAD_STACK_MIN = 16 * 1024; | ||
| 1166 | |||
| 1167 | pub const timer_t = *opaque {}; |
lib/std/c/emscripten.zig-2| ... | @@ -9,5 +9,3 @@ pub const pthread_rwlock_t = extern struct { | ... | @@ -9,5 +9,3 @@ pub const pthread_rwlock_t = extern struct { |
| 9 | }; | 9 | }; |
| 10 | const __SIZEOF_PTHREAD_COND_T = 48; | 10 | const __SIZEOF_PTHREAD_COND_T = 48; |
| 11 | const __SIZEOF_PTHREAD_MUTEX_T = 28; | 11 | const __SIZEOF_PTHREAD_MUTEX_T = 28; |
| 12 | |||
| 13 | pub const PTHREAD_STACK_MIN = 2048; |
lib/std/c/freebsd.zig+22-913| ... | @@ -5,80 +5,12 @@ const maxInt = std.math.maxInt; | ... | @@ -5,80 +5,12 @@ const maxInt = std.math.maxInt; |
| 5 | const iovec = std.os.iovec; | 5 | const iovec = std.os.iovec; |
| 6 | const iovec_const = std.os.iovec_const; | 6 | const iovec_const = std.os.iovec_const; |
| 7 | 7 | ||
| 8 | pub const CPU_SETSIZE = 256; | ||
| 9 | pub const cpuset_t = extern struct { | ||
| 10 | __bits: [(CPU_SETSIZE + (@bitSizeOf(c_long) - 1)) / @bitSizeOf(c_long)]c_long, | ||
| 11 | }; | ||
| 12 | |||
| 13 | fn __BIT_COUNT(bits: []const c_long) c_long { | ||
| 14 | var count: c_long = 0; | ||
| 15 | for (bits) |b| { | ||
| 16 | count += @popCount(b); | ||
| 17 | } | ||
| 18 | return count; | ||
| 19 | } | ||
| 20 | |||
| 21 | fn __BIT_MASK(s: usize) c_long { | ||
| 22 | var x = s % CPU_SETSIZE; | ||
| 23 | return @as(c_long, @bitCast(@as(c_ulong, @intCast(1)) << @as(u6, @intCast(x)))); | ||
| 24 | } | ||
| 25 | |||
| 26 | pub fn CPU_COUNT(set: cpuset_t) c_int { | ||
| 27 | return @as(c_int, @intCast(__BIT_COUNT(set.__bits[0..]))); | ||
| 28 | } | ||
| 29 | |||
| 30 | pub fn CPU_ZERO(set: *cpuset_t) void { | ||
| 31 | @memset((set.*).__bits[0..], 0); | ||
| 32 | } | ||
| 33 | |||
| 34 | pub fn CPU_SET(cpu: usize, set: *cpuset_t) void { | ||
| 35 | const x = cpu / @sizeOf(c_long); | ||
| 36 | if (x < @sizeOf(cpuset_t)) { | ||
| 37 | (set.*).__bits[x] |= __BIT_MASK(x); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | pub fn CPU_ISSET(cpu: usize, set: cpuset_t) bool { | ||
| 42 | const x = cpu / @sizeOf(c_long); | ||
| 43 | if (x < @sizeOf(cpuset_t)) { | ||
| 44 | return set.__bits[x] & __BIT_MASK(x) != 0; | ||
| 45 | } | ||
| 46 | return false; | ||
| 47 | } | ||
| 48 | |||
| 49 | pub fn CPU_CLR(cpu: usize, set: *cpuset_t) void { | ||
| 50 | const x = cpu / @sizeOf(c_long); | ||
| 51 | if (x < @sizeOf(cpuset_t)) { | ||
| 52 | (set.*).__bits[x] &= !__BIT_MASK(x); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | pub const cpulevel_t = c_int; | ||
| 57 | pub const cpuwhich_t = c_int; | ||
| 58 | pub const id_t = i64; | ||
| 59 | |||
| 60 | pub const CPU_LEVEL_ROOT: cpulevel_t = 1; | ||
| 61 | pub const CPU_LEVEL_CPUSET: cpulevel_t = 2; | ||
| 62 | pub const CPU_LEVEL_WHICH: cpulevel_t = 3; | ||
| 63 | pub const CPU_WHICH_TID: cpuwhich_t = 1; | ||
| 64 | pub const CPU_WHICH_PID: cpuwhich_t = 2; | ||
| 65 | pub const CPU_WHICH_CPUSET: cpuwhich_t = 3; | ||
| 66 | pub const CPU_WHICH_IRQ: cpuwhich_t = 4; | ||
| 67 | pub const CPU_WHICH_JAIL: cpuwhich_t = 5; | ||
| 68 | pub const CPU_WHICH_DOMAIN: cpuwhich_t = 6; | ||
| 69 | pub const CPU_WHICH_INTRHANDLER: cpuwhich_t = 7; | ||
| 70 | pub const CPU_WHICH_ITHREAD: cpuwhich_t = 8; | ||
| 71 | pub const CPU_WHICH_TIDPID: cpuwhich_t = 8; | ||
| 72 | |||
| 73 | extern "c" fn __error() *c_int; | 8 | extern "c" fn __error() *c_int; |
| 74 | pub const _errno = __error; | 9 | pub const _errno = __error; |
| 75 | 10 | ||
| 76 | pub extern "c" var malloc_options: [*:0]const u8; | ||
| 77 | |||
| 78 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) isize; | 11 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) isize; |
| 79 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | 12 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; |
| 80 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; | 13 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; |
| 81 | pub extern "c" fn getentropy(buf_ptr: [*]u8, buf_len: usize) c_int; | ||
| 82 | 14 | ||
| 83 | pub extern "c" fn pthread_getthreadid_np() c_int; | 15 | pub extern "c" fn pthread_getthreadid_np() c_int; |
| 84 | pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void; | 16 | pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void; |
| ... | @@ -88,21 +20,10 @@ pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | ... | @@ -88,21 +20,10 @@ pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; |
| 88 | 20 | ||
| 89 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | 21 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; |
| 90 | pub extern "c" fn malloc_usable_size(?*const anyopaque) usize; | 22 | pub extern "c" fn malloc_usable_size(?*const anyopaque) usize; |
| 91 | pub extern "c" fn reallocf(?*anyopaque, usize) ?*anyopaque; | ||
| 92 | 23 | ||
| 93 | pub extern "c" fn getpid() pid_t; | 24 | pub extern "c" fn getpid() pid_t; |
| 94 | 25 | ||
| 95 | pub extern "c" fn kinfo_getfile(pid: pid_t, cntp: *c_int) ?[*]kinfo_file; | 26 | pub extern "c" fn kinfo_getfile(pid: pid_t, cntp: *c_int) ?[*]kinfo_file; |
| 96 | pub extern "c" fn kinfo_getvmmap(pid: pid_t, cntp: *c_int) ?[*]kinfo_vmentry; | ||
| 97 | pub extern "c" fn kinfo_getproc(pid: pid_t) ?*kinfo_proc; | ||
| 98 | pub extern "c" fn kinfo_getvmobject(cntp: *c_int) ?[*]kinfo_vmobject; | ||
| 99 | pub extern "c" fn kinfo_getswapvmobject(cntp: *c_int) ?[*]kinfo_vmobject; | ||
| 100 | |||
| 101 | pub extern "c" fn cpuset_getaffinity(level: cpulevel_t, which: cpuwhich_t, id: id_t, setsize: usize, mask: *cpuset_t) c_int; | ||
| 102 | pub extern "c" fn cpuset_setaffinity(level: cpulevel_t, which: cpuwhich_t, id: id_t, setsize: usize, mask: *const cpuset_t) c_int; | ||
| 103 | pub extern "c" fn sched_getaffinity(pid: pid_t, cpusetsz: usize, cpuset: *cpuset_t) c_int; | ||
| 104 | pub extern "c" fn sched_setaffinity(pid: pid_t, cpusetsz: usize, cpuset: *const cpuset_t) c_int; | ||
| 105 | pub extern "c" fn sched_getcpu() c_int; | ||
| 106 | 27 | ||
| 107 | pub const sf_hdtr = extern struct { | 28 | pub const sf_hdtr = extern struct { |
| 108 | headers: [*]const iovec_const, | 29 | headers: [*]const iovec_const, |
| ... | @@ -355,36 +276,36 @@ pub const Flock = extern struct { | ... | @@ -355,36 +276,36 @@ pub const Flock = extern struct { |
| 355 | 276 | ||
| 356 | pub const msghdr = extern struct { | 277 | pub const msghdr = extern struct { |
| 357 | /// Optional address. | 278 | /// Optional address. |
| 358 | name: ?*sockaddr, | 279 | msg_name: ?*sockaddr, |
| 359 | /// Size of address. | 280 | /// Size of address. |
| 360 | namelen: socklen_t, | 281 | msg_namelen: socklen_t, |
| 361 | /// Scatter/gather array. | 282 | /// Scatter/gather array. |
| 362 | iov: [*]iovec, | 283 | msg_iov: [*]iovec, |
| 363 | /// Number of elements in msg_iov. | 284 | /// Number of elements in msg_iov. |
| 364 | iovlen: i32, | 285 | msg_iovlen: i32, |
| 365 | /// Ancillary data. | 286 | /// Ancillary data. |
| 366 | control: ?*anyopaque, | 287 | msg_control: ?*anyopaque, |
| 367 | /// Ancillary data buffer length. | 288 | /// Ancillary data buffer length. |
| 368 | controllen: socklen_t, | 289 | msg_controllen: socklen_t, |
| 369 | /// Flags on received message. | 290 | /// Flags on received message. |
| 370 | flags: i32, | 291 | msg_flags: i32, |
| 371 | }; | 292 | }; |
| 372 | 293 | ||
| 373 | pub const msghdr_const = extern struct { | 294 | pub const msghdr_const = extern struct { |
| 374 | /// Optional address. | 295 | /// Optional address. |
| 375 | name: ?*const sockaddr, | 296 | msg_name: ?*const sockaddr, |
| 376 | /// Size of address. | 297 | /// Size of address. |
| 377 | namelen: socklen_t, | 298 | msg_namelen: socklen_t, |
| 378 | /// Scatter/gather array. | 299 | /// Scatter/gather array. |
| 379 | iov: [*]iovec_const, | 300 | msg_iov: [*]iovec_const, |
| 380 | /// Number of elements in msg_iov. | 301 | /// Number of elements in msg_iov. |
| 381 | iovlen: i32, | 302 | msg_iovlen: i32, |
| 382 | /// Ancillary data. | 303 | /// Ancillary data. |
| 383 | control: ?*anyopaque, | 304 | msg_control: ?*anyopaque, |
| 384 | /// Ancillary data buffer length. | 305 | /// Ancillary data buffer length. |
| 385 | controllen: socklen_t, | 306 | msg_controllen: socklen_t, |
| 386 | /// Flags on received message. | 307 | /// Flags on received message. |
| 387 | flags: i32, | 308 | msg_flags: i32, |
| 388 | }; | 309 | }; |
| 389 | 310 | ||
| 390 | pub const Stat = extern struct { | 311 | pub const Stat = extern struct { |
| ... | @@ -523,43 +444,10 @@ pub const sockaddr = extern struct { | ... | @@ -523,43 +444,10 @@ pub const sockaddr = extern struct { |
| 523 | 444 | ||
| 524 | pub const CAP_RIGHTS_VERSION = 0; | 445 | pub const CAP_RIGHTS_VERSION = 0; |
| 525 | 446 | ||
| 526 | pub const cap_rights_t = extern struct { | 447 | pub const cap_rights = extern struct { |
| 527 | cr_rights: [CAP_RIGHTS_VERSION + 2]u64, | 448 | rights: [CAP_RIGHTS_VERSION + 2]u64, |
| 528 | }; | 449 | }; |
| 529 | 450 | ||
| 530 | pub const CAP = struct { | ||
| 531 | pub fn RIGHT(idx: u6, bit: u64) u64 { | ||
| 532 | return (@as(u64, @intCast(1)) << (57 + idx)) | bit; | ||
| 533 | } | ||
| 534 | pub const READ = CAP.RIGHT(0, 0x0000000000000001); | ||
| 535 | pub const WRITE = CAP.RIGHT(0, 0x0000000000000002); | ||
| 536 | pub const SEEK_TELL = CAP.RIGHT(0, 0x0000000000000004); | ||
| 537 | pub const SEEK = CAP.SEEK_TELL | 0x0000000000000008; | ||
| 538 | pub const PREAD = CAP.SEEK | CAP.READ; | ||
| 539 | pub const PWRITE = CAP.SEEK | CAP.WRITE; | ||
| 540 | pub const MMAP = CAP.RIGHT(0, 0x0000000000000010); | ||
| 541 | pub const MMAP_R = CAP.MMAP | CAP.SEEK | CAP.READ; | ||
| 542 | pub const MMAP_W = CAP.MMAP | CAP.SEEK | CAP.WRITE; | ||
| 543 | pub const MMAP_X = CAP.MMAP | CAP.SEEK | 0x0000000000000020; | ||
| 544 | pub const MMAP_RW = CAP.MMAP_R | CAP.MMAP_W; | ||
| 545 | pub const MMAP_RX = CAP.MMAP_R | CAP.MMAP_X; | ||
| 546 | pub const MMAP_WX = CAP.MMAP_W | CAP.MMAP_X; | ||
| 547 | pub const MMAP_RWX = CAP.MMAP_R | CAP.MMAP_W | CAP.MMAP_X; | ||
| 548 | pub const CREATE = CAP.RIGHT(0, 0x0000000000000040); | ||
| 549 | pub const FEXECVE = CAP.RIGHT(0, 0x0000000000000080); | ||
| 550 | pub const FSYNC = CAP.RIGHT(0, 0x0000000000000100); | ||
| 551 | pub const FTRUNCATE = CAP.RIGHT(0, 0x0000000000000200); | ||
| 552 | }; | ||
| 553 | |||
| 554 | pub extern "c" fn __cap_rights_init(version: c_int, rights: ?*cap_rights_t, ...) ?*cap_rights_t; | ||
| 555 | pub extern "c" fn __cap_rights_set(rights: ?*cap_rights_t, ...) ?*cap_rights_t; | ||
| 556 | pub extern "c" fn __cap_rights_clear(rights: ?*cap_rights_t, ...) ?*cap_rights_t; | ||
| 557 | pub extern "c" fn __cap_rights_is_set(rights: ?*const cap_rights_t, ...) bool; | ||
| 558 | pub extern "c" fn cap_rights_merge(dst: ?*cap_rights_t, src: ?*const cap_rights_t) ?*cap_rights_t; | ||
| 559 | pub extern "c" fn cap_rights_remove(dst: ?*cap_rights_t, src: ?*const cap_rights_t) ?*cap_rights_t; | ||
| 560 | pub extern "c" fn cap_rights_contains(dst: ?*const cap_rights_t, src: ?*const cap_rights_t) bool; | ||
| 561 | pub extern "c" fn cap_rights_is_valid(rights: ?*const cap_rights_t) bool; | ||
| 562 | |||
| 563 | pub const kinfo_file = extern struct { | 451 | pub const kinfo_file = extern struct { |
| 564 | /// Size of this record. | 452 | /// Size of this record. |
| 565 | /// A zero value is for the sentinel record at the end of an array. | 453 | /// A zero value is for the sentinel record at the end of an array. |
| ... | @@ -661,7 +549,7 @@ pub const kinfo_file = extern struct { | ... | @@ -661,7 +549,7 @@ pub const kinfo_file = extern struct { |
| 661 | // Reserved for future use. | 549 | // Reserved for future use. |
| 662 | _spare: c_int, | 550 | _spare: c_int, |
| 663 | /// Capability rights. | 551 | /// Capability rights. |
| 664 | cap_rights: cap_rights_t, | 552 | cap_rights: cap_rights, |
| 665 | /// Reserved for future cap_rights | 553 | /// Reserved for future cap_rights |
| 666 | _cap_spare: u64, | 554 | _cap_spare: u64, |
| 667 | /// Path to file, if any. | 555 | /// Path to file, if any. |
| ... | @@ -675,248 +563,6 @@ comptime { | ... | @@ -675,248 +563,6 @@ comptime { |
| 675 | std.debug.assert(@alignOf(kinfo_file) == @sizeOf(u64)); | 563 | std.debug.assert(@alignOf(kinfo_file) == @sizeOf(u64)); |
| 676 | } | 564 | } |
| 677 | 565 | ||
| 678 | pub const kinfo_vmentry = extern struct { | ||
| 679 | structsize: c_int, | ||
| 680 | type: c_int, | ||
| 681 | start: u64, | ||
| 682 | end: u64, | ||
| 683 | offset: u64, | ||
| 684 | vn_fileid: u64, | ||
| 685 | vn_fsid_freebsd11: u32, | ||
| 686 | flags: c_int, | ||
| 687 | resident: c_int, | ||
| 688 | private_resident: c_int, | ||
| 689 | protection: c_int, | ||
| 690 | ref_count: c_int, | ||
| 691 | shadow_count: c_int, | ||
| 692 | vn_type: c_int, | ||
| 693 | vn_size: u64, | ||
| 694 | vn_rdev_freebsd11: u32, | ||
| 695 | vn_mode: u16, | ||
| 696 | status: u16, | ||
| 697 | type_spec: extern union { | ||
| 698 | _vn_fsid: u64, | ||
| 699 | _obj: u64, | ||
| 700 | }, | ||
| 701 | vn_rdev: u64, | ||
| 702 | _ispare: [8]c_int, | ||
| 703 | rpath: [PATH_MAX]u8, | ||
| 704 | }; | ||
| 705 | |||
| 706 | pub const KINFO_VMENTRY_SIZE = 1160; | ||
| 707 | |||
| 708 | comptime { | ||
| 709 | std.debug.assert(@sizeOf(kinfo_vmentry) == KINFO_VMENTRY_SIZE); | ||
| 710 | } | ||
| 711 | |||
| 712 | pub const WMESGLEN = 8; | ||
| 713 | pub const LOCKNAMELEN = 8; | ||
| 714 | pub const TDNAMLEN = 16; | ||
| 715 | pub const COMMLEN = 19; | ||
| 716 | pub const MAXCOMLEN = 19; | ||
| 717 | pub const KI_EMULNAMELEN = 16; | ||
| 718 | pub const KI_NGROUPS = 16; | ||
| 719 | pub const LOGNAMELEN = 17; | ||
| 720 | pub const LOGINCLASSLEN = 17; | ||
| 721 | |||
| 722 | pub const KI_NSPARE_INT = 2; | ||
| 723 | pub const KI_NSPARE_LONG = 12; | ||
| 724 | pub const KI_NSPARE_PTR = 5; | ||
| 725 | |||
| 726 | pub const RUSAGE_SELF = 0; | ||
| 727 | pub const RUSAGE_CHILDREN = -1; | ||
| 728 | pub const RUSAGE_THREAD = 1; | ||
| 729 | |||
| 730 | pub const proc = opaque {}; | ||
| 731 | pub const thread = opaque {}; | ||
| 732 | pub const vnode = opaque {}; | ||
| 733 | pub const filedesc = opaque {}; | ||
| 734 | pub const pwddesc = opaque {}; | ||
| 735 | pub const vmspace = opaque {}; | ||
| 736 | pub const pcb = opaque {}; | ||
| 737 | pub const lwpid_t = i32; | ||
| 738 | pub const fixpt_t = u32; | ||
| 739 | pub const vm_size_t = usize; | ||
| 740 | pub const segsz_t = isize; | ||
| 741 | |||
| 742 | pub const itimerval = extern struct { | ||
| 743 | interval: timeval, | ||
| 744 | value: timeval, | ||
| 745 | }; | ||
| 746 | |||
| 747 | pub const pstats = extern struct { | ||
| 748 | cru: rusage, | ||
| 749 | timer: [3]itimerval, | ||
| 750 | prof: extern struct { | ||
| 751 | base: u8, | ||
| 752 | size: c_ulong, | ||
| 753 | off: c_ulong, | ||
| 754 | scale: c_ulong, | ||
| 755 | }, | ||
| 756 | start: timeval, | ||
| 757 | }; | ||
| 758 | |||
| 759 | pub const user = extern struct { | ||
| 760 | stats: pstats, | ||
| 761 | kproc: kinfo_proc, | ||
| 762 | }; | ||
| 763 | |||
| 764 | pub const pargs = extern struct { | ||
| 765 | ref: c_uint, | ||
| 766 | length: c_uint, | ||
| 767 | args: [1]u8, | ||
| 768 | }; | ||
| 769 | |||
| 770 | pub const priority = extern struct { | ||
| 771 | class: u8, | ||
| 772 | level: u8, | ||
| 773 | native: u8, | ||
| 774 | user: u8, | ||
| 775 | }; | ||
| 776 | |||
| 777 | pub const rusage = extern struct { | ||
| 778 | utime: timeval, | ||
| 779 | stime: timeval, | ||
| 780 | maxrss: c_long, | ||
| 781 | ixrss: c_long, | ||
| 782 | idrss: c_long, | ||
| 783 | isrss: c_long, | ||
| 784 | minflt: c_long, | ||
| 785 | majflt: c_long, | ||
| 786 | nswap: c_long, | ||
| 787 | inblock: c_long, | ||
| 788 | oublock: c_long, | ||
| 789 | msgsnd: c_long, | ||
| 790 | msgrcv: c_long, | ||
| 791 | nsignals: c_long, | ||
| 792 | nvcsw: c_long, | ||
| 793 | nivcsw: c_long, | ||
| 794 | }; | ||
| 795 | |||
| 796 | pub const kinfo_proc = extern struct { | ||
| 797 | structsize: c_int, | ||
| 798 | layout: c_int, | ||
| 799 | args: *pargs, | ||
| 800 | paddr: *proc, | ||
| 801 | addr: *user, | ||
| 802 | tracep: *vnode, | ||
| 803 | textvp: *vnode, | ||
| 804 | fd: *filedesc, | ||
| 805 | vmspace: *vmspace, | ||
| 806 | wchan: ?*const anyopaque, | ||
| 807 | pid: pid_t, | ||
| 808 | ppid: pid_t, | ||
| 809 | pgid: pid_t, | ||
| 810 | tpgid: pid_t, | ||
| 811 | sid: pid_t, | ||
| 812 | tsid: pid_t, | ||
| 813 | jobc: c_short, | ||
| 814 | spare_short1: c_short, | ||
| 815 | tdev_freebsd11: u32, | ||
| 816 | siglist: sigset_t, | ||
| 817 | sigmask: sigset_t, | ||
| 818 | sigignore: sigset_t, | ||
| 819 | sigcatch: sigset_t, | ||
| 820 | uid: uid_t, | ||
| 821 | ruid: uid_t, | ||
| 822 | svuid: uid_t, | ||
| 823 | rgid: gid_t, | ||
| 824 | svgid: gid_t, | ||
| 825 | ngroups: c_short, | ||
| 826 | spare_short2: c_short, | ||
| 827 | groups: [KI_NGROUPS]gid_t, | ||
| 828 | size: vm_size_t, | ||
| 829 | rssize: segsz_t, | ||
| 830 | swrss: segsz_t, | ||
| 831 | tsize: segsz_t, | ||
| 832 | dsize: segsz_t, | ||
| 833 | ssize: segsz_t, | ||
| 834 | xstat: c_ushort, | ||
| 835 | acflag: c_ushort, | ||
| 836 | pctcpu: fixpt_t, | ||
| 837 | estcpu: c_uint, | ||
| 838 | slptime: c_uint, | ||
| 839 | swtime: c_uint, | ||
| 840 | cow: c_uint, | ||
| 841 | runtime: u64, | ||
| 842 | start: timeval, | ||
| 843 | childtime: timeval, | ||
| 844 | flag: c_long, | ||
| 845 | kiflag: c_long, | ||
| 846 | traceflag: c_int, | ||
| 847 | stat: u8, | ||
| 848 | nice: i8, | ||
| 849 | lock: u8, | ||
| 850 | rqindex: u8, | ||
| 851 | oncpu_old: u8, | ||
| 852 | lastcpu_old: u8, | ||
| 853 | tdname: [TDNAMLEN + 1]u8, | ||
| 854 | wmesg: [WMESGLEN + 1]u8, | ||
| 855 | login: [LOGNAMELEN + 1]u8, | ||
| 856 | lockname: [LOCKNAMELEN + 1]u8, | ||
| 857 | comm: [COMMLEN + 1]u8, | ||
| 858 | emul: [KI_EMULNAMELEN + 1]u8, | ||
| 859 | loginclass: [LOGINCLASSLEN + 1]u8, | ||
| 860 | moretdname: [MAXCOMLEN - TDNAMLEN + 1]u8, | ||
| 861 | sparestrings: [46]u8, | ||
| 862 | spareints: [KI_NSPARE_INT]c_int, | ||
| 863 | tdev: u64, | ||
| 864 | oncpu: c_int, | ||
| 865 | lastcpu: c_int, | ||
| 866 | tracer: c_int, | ||
| 867 | flag2: c_int, | ||
| 868 | fibnum: c_int, | ||
| 869 | cr_flags: c_uint, | ||
| 870 | jid: c_int, | ||
| 871 | numthreads: c_int, | ||
| 872 | tid: lwpid_t, | ||
| 873 | pri: priority, | ||
| 874 | rusage: rusage, | ||
| 875 | rusage_ch: rusage, | ||
| 876 | pcb: *pcb, | ||
| 877 | stack: ?*anyopaque, | ||
| 878 | udata: ?*anyopaque, | ||
| 879 | tdaddr: *thread, | ||
| 880 | pd: *pwddesc, | ||
| 881 | spareptrs: [KI_NSPARE_PTR]?*anyopaque, | ||
| 882 | sparelongs: [KI_NSPARE_LONG]c_long, | ||
| 883 | sflag: c_long, | ||
| 884 | tdflag: c_long, | ||
| 885 | }; | ||
| 886 | |||
| 887 | pub const KINFO_PROC_SIZE = switch (builtin.cpu.arch) { | ||
| 888 | .x86 => 768, | ||
| 889 | .arm => 816, | ||
| 890 | else => 1088, | ||
| 891 | }; | ||
| 892 | |||
| 893 | comptime { | ||
| 894 | assert(@sizeOf(kinfo_proc) == KINFO_PROC_SIZE); | ||
| 895 | } | ||
| 896 | |||
| 897 | pub const kinfo_vmobject = extern struct { | ||
| 898 | structsize: c_int, | ||
| 899 | tpe: c_int, | ||
| 900 | size: u64, | ||
| 901 | vn_fileid: u64, | ||
| 902 | vn_fsid_freebsd11: u32, | ||
| 903 | ref_count: c_int, | ||
| 904 | shadow_count: c_int, | ||
| 905 | memattr: c_int, | ||
| 906 | resident: u64, | ||
| 907 | active: u64, | ||
| 908 | inactive: u64, | ||
| 909 | type_spec: extern union { | ||
| 910 | _vn_fsid: u64, | ||
| 911 | _backing_obj: u64, | ||
| 912 | }, | ||
| 913 | me: u64, | ||
| 914 | _qspare: [6]u64, | ||
| 915 | swapped: u32, | ||
| 916 | _ispare: [7]u32, | ||
| 917 | path: [PATH_MAX]u8, | ||
| 918 | }; | ||
| 919 | |||
| 920 | pub const CTL = struct { | 566 | pub const CTL = struct { |
| 921 | pub const KERN = 1; | 567 | pub const KERN = 1; |
| 922 | pub const DEBUG = 5; | 568 | pub const DEBUG = 5; |
| ... | @@ -1396,11 +1042,6 @@ pub const DT = struct { | ... | @@ -1396,11 +1042,6 @@ pub const DT = struct { |
| 1396 | pub const WHT = 14; | 1042 | pub const WHT = 14; |
| 1397 | }; | 1043 | }; |
| 1398 | 1044 | ||
| 1399 | pub const accept_filter = extern struct { | ||
| 1400 | af_name: [16]u8, | ||
| 1401 | af_args: [240]u8, | ||
| 1402 | }; | ||
| 1403 | |||
| 1404 | /// add event to kq (implies enable) | 1045 | /// add event to kq (implies enable) |
| 1405 | pub const EV_ADD = 0x0001; | 1046 | pub const EV_ADD = 0x0001; |
| 1406 | 1047 | ||
| ... | @@ -1682,47 +1323,15 @@ pub const mcontext_t = switch (builtin.cpu.arch) { | ... | @@ -1682,47 +1323,15 @@ pub const mcontext_t = switch (builtin.cpu.arch) { |
| 1682 | rflags: u64, | 1323 | rflags: u64, |
| 1683 | rsp: u64, | 1324 | rsp: u64, |
| 1684 | ss: u64, | 1325 | ss: u64, |
| 1685 | len: c_long, | 1326 | len: u64, |
| 1686 | fpformat: c_long, | 1327 | fpformat: u64, |
| 1687 | ownedfp: c_long, | 1328 | ownedfp: u64, |
| 1688 | fpstate: [64]c_long align(16), | 1329 | fpstate: [64]u64 align(16), |
| 1689 | fsbase: u64, | 1330 | fsbase: u64, |
| 1690 | gsbase: u64, | 1331 | gsbase: u64, |
| 1691 | xfpustate: u64, | 1332 | xfpustate: u64, |
| 1692 | xfpustate_len: u64, | 1333 | xfpustate_len: u64, |
| 1693 | spare: [4]c_long, | 1334 | spare: [4]u64, |
| 1694 | }, | ||
| 1695 | .x86 => extern struct { | ||
| 1696 | onstack: u32, | ||
| 1697 | gs: u32, | ||
| 1698 | fs: u32, | ||
| 1699 | es: u32, | ||
| 1700 | ds: u32, | ||
| 1701 | edi: u32, | ||
| 1702 | esi: u32, | ||
| 1703 | ebp: u32, | ||
| 1704 | isp: u32, | ||
| 1705 | ebx: u32, | ||
| 1706 | edx: u32, | ||
| 1707 | ecx: u32, | ||
| 1708 | eax: u32, | ||
| 1709 | trapno: u32, | ||
| 1710 | err: u32, | ||
| 1711 | eip: u32, | ||
| 1712 | cs: u32, | ||
| 1713 | eflags: u32, | ||
| 1714 | esp: u32, | ||
| 1715 | ss: u32, | ||
| 1716 | len: c_int, | ||
| 1717 | fpformat: c_int, | ||
| 1718 | ownedfp: c_int, | ||
| 1719 | flags: u32, | ||
| 1720 | fpstate: [128]c_int align(16), | ||
| 1721 | fsbase: u32, | ||
| 1722 | gsbase: u32, | ||
| 1723 | xpustate: u32, | ||
| 1724 | xpustate_len: u32, | ||
| 1725 | spare2: [4]c_int, | ||
| 1726 | }, | 1335 | }, |
| 1727 | .aarch64 => extern struct { | 1336 | .aarch64 => extern struct { |
| 1728 | gpregs: extern struct { | 1337 | gpregs: extern struct { |
| ... | @@ -2002,45 +1611,6 @@ pub const AT = struct { | ... | @@ -2002,45 +1611,6 @@ pub const AT = struct { |
| 2002 | pub const REMOVEDIR = 0x0800; | 1611 | pub const REMOVEDIR = 0x0800; |
| 2003 | /// Fail if not under dirfd | 1612 | /// Fail if not under dirfd |
| 2004 | pub const BENEATH = 0x1000; | 1613 | pub const BENEATH = 0x1000; |
| 2005 | /// elf_common constants | ||
| 2006 | pub const NULL = 0; | ||
| 2007 | pub const IGNORE = 1; | ||
| 2008 | pub const EXECFD = 2; | ||
| 2009 | pub const PHDR = 3; | ||
| 2010 | pub const PHENT = 4; | ||
| 2011 | pub const PHNUM = 5; | ||
| 2012 | pub const PAGESZ = 6; | ||
| 2013 | pub const BASE = 7; | ||
| 2014 | pub const FLAGS = 8; | ||
| 2015 | pub const ENTRY = 9; | ||
| 2016 | pub const NOTELF = 10; | ||
| 2017 | pub const UID = 11; | ||
| 2018 | pub const EUID = 12; | ||
| 2019 | pub const GID = 13; | ||
| 2020 | pub const EGID = 14; | ||
| 2021 | pub const EXECPATH = 15; | ||
| 2022 | pub const CANARY = 16; | ||
| 2023 | pub const CANARYLEN = 17; | ||
| 2024 | pub const OSRELDATE = 18; | ||
| 2025 | pub const NCPUS = 19; | ||
| 2026 | pub const PAGESIZES = 20; | ||
| 2027 | pub const PAGESIZESLEN = 21; | ||
| 2028 | pub const TIMEKEEP = 22; | ||
| 2029 | pub const STACKPROT = 23; | ||
| 2030 | pub const EHDRFLAGS = 24; | ||
| 2031 | pub const HWCAP = 25; | ||
| 2032 | pub const HWCAP2 = 26; | ||
| 2033 | pub const BSDFLAGS = 27; | ||
| 2034 | pub const ARGC = 28; | ||
| 2035 | pub const ARGV = 29; | ||
| 2036 | pub const ENVC = 30; | ||
| 2037 | pub const ENVV = 31; | ||
| 2038 | pub const PS_STRINGS = 32; | ||
| 2039 | pub const FXRNG = 33; | ||
| 2040 | pub const KPRLOAD = 34; | ||
| 2041 | pub const USRSTACKBASE = 35; | ||
| 2042 | pub const USRSTACKLIM = 36; | ||
| 2043 | pub const COUNT = 37; | ||
| 2044 | }; | 1614 | }; |
| 2045 | 1615 | ||
| 2046 | pub const addrinfo = extern struct { | 1616 | pub const addrinfo = extern struct { |
| ... | @@ -2373,468 +1943,7 @@ pub const NAME_MAX = 255; | ... | @@ -2373,468 +1943,7 @@ pub const NAME_MAX = 255; |
| 2373 | pub const MFD = struct { | 1943 | pub const MFD = struct { |
| 2374 | pub const CLOEXEC = 0x0001; | 1944 | pub const CLOEXEC = 0x0001; |
| 2375 | pub const ALLOW_SEALING = 0x0002; | 1945 | pub const ALLOW_SEALING = 0x0002; |
| 2376 | pub const HUGETLB = 0x00000004; | ||
| 2377 | pub const HUGE_MASK = 0xFC000000; | ||
| 2378 | pub const HUGE_SHIFT = 26; | ||
| 2379 | pub const HUGE_64KB = 16 << HUGE_SHIFT; | ||
| 2380 | pub const HUGE_512KB = 19 << HUGE_SHIFT; | ||
| 2381 | pub const HUGE_1MB = 20 << HUGE_SHIFT; | ||
| 2382 | pub const HUGE_2MB = 21 << HUGE_SHIFT; | ||
| 2383 | pub const HUGE_8MB = 23 << HUGE_SHIFT; | ||
| 2384 | pub const HUGE_16MB = 24 << HUGE_SHIFT; | ||
| 2385 | pub const HUGE_32MB = 25 << HUGE_SHIFT; | ||
| 2386 | pub const HUGE_256MB = 28 << HUGE_SHIFT; | ||
| 2387 | pub const HUGE_512MB = 29 << HUGE_SHIFT; | ||
| 2388 | pub const HUGE_1GB = 30 << HUGE_SHIFT; | ||
| 2389 | pub const HUGE_2GB = 31 << HUGE_SHIFT; | ||
| 2390 | pub const HUGE_16GB = 34 << HUGE_SHIFT; | ||
| 2391 | }; | 1946 | }; |
| 2392 | 1947 | ||
| 2393 | pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; | 1948 | pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; |
| 2394 | pub extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*off_t, fd_out: fd_t, off_out: ?*off_t, len: usize, flags: u32) usize; | 1949 | pub extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*off_t, fd_out: fd_t, off_out: ?*off_t, len: usize, flags: u32) usize; |
| 2395 | |||
| 2396 | pub const idtype_t = enum(c_int) { | ||
| 2397 | P_PID = 0, | ||
| 2398 | P_PPID = 1, | ||
| 2399 | P_PGID = 2, | ||
| 2400 | P_SID = 3, | ||
| 2401 | P_CID = 4, | ||
| 2402 | P_UID = 5, | ||
| 2403 | P_GID = 6, | ||
| 2404 | P_ALL = 7, | ||
| 2405 | P_LWPID = 8, | ||
| 2406 | P_TASKID = 9, | ||
| 2407 | P_PROJID = 10, | ||
| 2408 | P_POOLID = 11, | ||
| 2409 | P_JAILID = 12, | ||
| 2410 | P_CTID = 13, | ||
| 2411 | P_CPUID = 14, | ||
| 2412 | P_PSETID = 15, | ||
| 2413 | }; | ||
| 2414 | |||
| 2415 | pub const PROC = struct { | ||
| 2416 | // constants for the id_t argument | ||
| 2417 | pub const SPROTECT: id_t = 1; | ||
| 2418 | pub const REAP_ACQUIRE: id_t = 2; | ||
| 2419 | pub const REAP_RELEASE: id_t = 3; | ||
| 2420 | pub const REAP_STATUS: id_t = 4; | ||
| 2421 | pub const REAP_GETPIDS: id_t = 5; | ||
| 2422 | pub const REAP_KILL: id_t = 6; | ||
| 2423 | pub const TRACE_CTL: id_t = 7; | ||
| 2424 | pub const TRACE_STATUS: id_t = 8; | ||
| 2425 | pub const TRACECAP_CTL = 9; | ||
| 2426 | pub const TRACECAP_STATUS: id_t = 10; | ||
| 2427 | pub const PDEATHSIG_CTL: id_t = 11; | ||
| 2428 | pub const PDEATHSIG_STATUS: id_t = 12; | ||
| 2429 | pub const ASLR_CTL: id_t = 13; | ||
| 2430 | pub const ASLR_STATUS: id_t = 14; | ||
| 2431 | pub const PROTMAX_CTL: id_t = 15; | ||
| 2432 | pub const PROTMAX_STATUS: id_t = 16; | ||
| 2433 | pub const STACKGAP_CTL: id_t = 17; | ||
| 2434 | pub const STACKGAP_STATUS: id_t = 18; | ||
| 2435 | pub const NO_NEW_PRIVS_CTL: id_t = 19; | ||
| 2436 | pub const NO_NEW_PRIVS_STATUS: id_t = 20; | ||
| 2437 | pub const WXMAP_CTL: id_t = 21; | ||
| 2438 | pub const WXMAP_STATUS: id_t = 22; | ||
| 2439 | |||
| 2440 | // constants for the operations | ||
| 2441 | pub const TRACE_CTL_ENABLE = 1; | ||
| 2442 | pub const TRACE_CTL_DISABLE = 2; | ||
| 2443 | pub const TRACE_CTL_DISABLE_EXEC = 3; | ||
| 2444 | pub const TRAPCAP_CTL_ENABLE = 1; | ||
| 2445 | pub const TRAPCAP_CTL_DISABLE = 2; | ||
| 2446 | pub const ASLR_FORCE_ENABLE = 1; | ||
| 2447 | pub const ASLR_FORCE_DISABLE = 2; | ||
| 2448 | pub const ASLR_FORCE_NOFORCE = 3; | ||
| 2449 | pub const ASLR_FORCE_ACTIVE = 0x80000000; | ||
| 2450 | pub const PROTMAX_FORCE_ENABLE = 1; | ||
| 2451 | pub const PROTMAX_FORCE_DISABLE = 2; | ||
| 2452 | pub const PROTMAX_FORCE_NOFORCE = 3; | ||
| 2453 | pub const PROTMAX_FORCE_ACTIVE = 0x80000000; | ||
| 2454 | pub const STACKGAP_ENABLE = 0x0001; | ||
| 2455 | pub const STACKGAP_DISABLE = 0x0002; | ||
| 2456 | pub const STACKGAP_ENABLE_EXEC = 0x0004; | ||
| 2457 | pub const STACKGAP_DISABLE_EXEC = 0x0008; | ||
| 2458 | pub const NO_NEW_PRIVS_ENABLE = 1; | ||
| 2459 | pub const NO_NEW_PRIVS_DISABLE = 2; | ||
| 2460 | pub const WX_MAPPINGS_PERMIT = 0x0001; | ||
| 2461 | pub const WX_MAPPINGS_DISALLOW_EXEC = 0x0002; | ||
| 2462 | pub const WX_MAPPINGS_ENFORCE = 0x80000000; | ||
| 2463 | pub const PROCCTL_MD_MIN = 0x10000000; | ||
| 2464 | // x86_64-only constants | ||
| 2465 | pub const KPTI = switch (builtin.cpu.arch) { | ||
| 2466 | .x86_64 => struct { | ||
| 2467 | pub const CTL = PROC.PROCCTL_MD_MIN; | ||
| 2468 | pub const STATUS = PROC.PROCCTL_MD_MIN + 1; | ||
| 2469 | pub const CTL_ENABLE_ON_EXEC = 1; | ||
| 2470 | pub const CTL_DISABLE_ON_EXEC = 2; | ||
| 2471 | pub const STATUS_ACTIVE = 0x80000000; | ||
| 2472 | }, | ||
| 2473 | else => void, | ||
| 2474 | }; | ||
| 2475 | pub const LA = switch (builtin.cpu.arch) { | ||
| 2476 | .x86_64 => struct { | ||
| 2477 | pub const CTL = PROC.PROCCTL_MD_MIN + 2; | ||
| 2478 | pub const STATUS = PROC.PROCCTL_MD_MIN + 3; | ||
| 2479 | pub const CTL_LA48_ON_EXEC = 1; | ||
| 2480 | pub const CTL_LA57_ON_EXEC = 2; | ||
| 2481 | pub const CTL_DEFAULT_ON_EXEC = 3; | ||
| 2482 | pub const STATUS_LA48 = 0x01000000; | ||
| 2483 | pub const STATUS_LA57 = 0x02000000; | ||
| 2484 | }, | ||
| 2485 | else => void, | ||
| 2486 | }; | ||
| 2487 | }; | ||
| 2488 | |||
| 2489 | pub const PPROT = struct { | ||
| 2490 | pub fn OP(x: i32) i32 { | ||
| 2491 | return x & 0xf; | ||
| 2492 | } | ||
| 2493 | pub const SET = 1; | ||
| 2494 | pub const CLEAR = 2; | ||
| 2495 | pub fn FLAGS(x: i32) i32 { | ||
| 2496 | return x & !0xf; | ||
| 2497 | } | ||
| 2498 | pub const DESCEND = 0x10; | ||
| 2499 | pub const INHERIT = 0x20; | ||
| 2500 | }; | ||
| 2501 | |||
| 2502 | pub const REAPER = struct { | ||
| 2503 | pub const STATUS_OWNED = 0x00000001; | ||
| 2504 | pub const STATUS_REALINIT = 0x00000002; | ||
| 2505 | pub const PIDINFO_VALID = 0x00000001; | ||
| 2506 | pub const PIDINFO_CHILD = 0x00000002; | ||
| 2507 | pub const PIDINFO_REAPER = 0x00000004; | ||
| 2508 | pub const KILL_CHILDREN = 0x00000001; | ||
| 2509 | pub const KILL_SUBTREE = 0x00000002; | ||
| 2510 | }; | ||
| 2511 | |||
| 2512 | pub const procctl_reaper_status = extern struct { | ||
| 2513 | rs_flags: u32, | ||
| 2514 | rs_children: u32, | ||
| 2515 | rs_descendants: u32, | ||
| 2516 | rs_reaper: pid_t, | ||
| 2517 | rs_pid: pid_t, | ||
| 2518 | rs_pad0: [15]u32, | ||
| 2519 | }; | ||
| 2520 | |||
| 2521 | pub const procctl_reaper_pidinfo = extern struct { | ||
| 2522 | pi_pid: pid_t, | ||
| 2523 | pi_subtree: pid_t, | ||
| 2524 | pi_flags: u32, | ||
| 2525 | pi_pad0: [15]u32, | ||
| 2526 | }; | ||
| 2527 | |||
| 2528 | pub const procctl_reaper_pids = extern struct { | ||
| 2529 | rp_count: u32, | ||
| 2530 | rp_pad0: [15]u32, | ||
| 2531 | rp_pids: [*]procctl_reaper_pidinfo, | ||
| 2532 | }; | ||
| 2533 | |||
| 2534 | pub const procctl_reaper_kill = extern struct { | ||
| 2535 | rk_sig: c_int, | ||
| 2536 | rk_flags: u32, | ||
| 2537 | rk_subtree: pid_t, | ||
| 2538 | rk_killed: u32, | ||
| 2539 | rk_fpid: pid_t, | ||
| 2540 | rk_pad0: [15]u32, | ||
| 2541 | }; | ||
| 2542 | |||
| 2543 | pub extern "c" fn procctl(idtype: idtype_t, id: id_t, cmd: c_int, data: ?*anyopaque) c_int; | ||
| 2544 | |||
| 2545 | pub const SHM = struct { | ||
| 2546 | pub const ALLOW_SEALING = 0x00000001; | ||
| 2547 | pub const GROW_ON_WRWITE = 0x00000002; | ||
| 2548 | pub const LARGEPAGE = 0x00000004; | ||
| 2549 | pub const LARGEPAGE_ALLOC_DEFAULT = 0; | ||
| 2550 | pub const LARGEPAGE_ALLOC_NOWAIT = 1; | ||
| 2551 | pub const LARGEPAGE_ALLOC_HARD = 2; | ||
| 2552 | }; | ||
| 2553 | |||
| 2554 | pub const shm_largeconf = extern struct { | ||
| 2555 | psind: c_int, | ||
| 2556 | alloc_policy: c_int, | ||
| 2557 | pad: [10]c_int, | ||
| 2558 | }; | ||
| 2559 | |||
| 2560 | pub extern "c" fn shm_create_largepage(path: [*:0]const u8, flags: c_int, psind: c_int, alloc_policy: c_int, mode: mode_t) c_int; | ||
| 2561 | |||
| 2562 | pub extern "c" fn elf_aux_info(aux: c_int, buf: ?*anyopaque, buflen: c_int) c_int; | ||
| 2563 | |||
| 2564 | pub const lwpid = i32; | ||
| 2565 | |||
| 2566 | pub const SIGEV = struct { | ||
| 2567 | pub const NONE = 0; | ||
| 2568 | pub const SIGNAL = 1; | ||
| 2569 | pub const THREAD = 2; | ||
| 2570 | pub const KEVENT = 3; | ||
| 2571 | pub const THREAD_ID = 4; | ||
| 2572 | }; | ||
| 2573 | |||
| 2574 | pub const sigevent = extern struct { | ||
| 2575 | sigev_notify: c_int, | ||
| 2576 | sigev_signo: c_int, | ||
| 2577 | sigev_value: sigval, | ||
| 2578 | _sigev_un: extern union { | ||
| 2579 | _threadid: lwpid, | ||
| 2580 | _sigev_thread: extern struct { | ||
| 2581 | _function: ?*const fn (sigval) callconv(.C) void, | ||
| 2582 | _attribute: ?**pthread_attr_t, | ||
| 2583 | }, | ||
| 2584 | _kevent_flags: c_ushort, | ||
| 2585 | __spare__: [8]c_long, | ||
| 2586 | }, | ||
| 2587 | }; | ||
| 2588 | |||
| 2589 | pub const timer_t = *opaque {}; | ||
| 2590 | |||
| 2591 | pub const MIN = struct { | ||
| 2592 | pub const INCORE = 0x1; | ||
| 2593 | pub const REFERENCED = 0x2; | ||
| 2594 | pub const MODIFIED = 0x4; | ||
| 2595 | pub const REFERENCED_OTHER = 0x8; | ||
| 2596 | pub const MODIFIED_OTHER = 0x10; | ||
| 2597 | pub const SUPER = 0x60; | ||
| 2598 | pub fn PSIND(i: u32) u32 { | ||
| 2599 | return (i << 5) & SUPER; | ||
| 2600 | } | ||
| 2601 | }; | ||
| 2602 | |||
| 2603 | pub extern "c" fn mincore( | ||
| 2604 | addr: *align(std.mem.page_size) const anyopaque, | ||
| 2605 | length: usize, | ||
| 2606 | vec: [*]u8, | ||
| 2607 | ) c_int; | ||
| 2608 | |||
| 2609 | pub const MAXMEMDOM = 8; | ||
| 2610 | pub const domainid_t = u8; | ||
| 2611 | |||
| 2612 | pub const LIST_ENTRY = opaque {}; | ||
| 2613 | |||
| 2614 | pub const DOMAINSET = struct { | ||
| 2615 | pub const POLICY_INVALID = 0; | ||
| 2616 | pub const POLICY_ROUNDROBIN = 1; | ||
| 2617 | pub const POLICY_FIRSTOUCH = 2; | ||
| 2618 | pub const POLICY_PREFER = 3; | ||
| 2619 | pub const POLICY_INTERLEAVE = 4; | ||
| 2620 | pub const POLICY_MAX = DOMAINSET.POLICY_INTERLEAVE; | ||
| 2621 | }; | ||
| 2622 | |||
| 2623 | pub const DOMAINSET_SIZE = 256; | ||
| 2624 | pub const domainset_t = extern struct { | ||
| 2625 | __bits: [(DOMAINSET_SIZE + (@sizeOf(domainset) - 1)) / @bitSizeOf(domainset)]domainset, | ||
| 2626 | }; | ||
| 2627 | |||
| 2628 | pub fn DOMAINSET_COUNT(set: domainset_t) c_int { | ||
| 2629 | return @as(c_int, @intCast(__BIT_COUNT(set.__bits[0..]))); | ||
| 2630 | } | ||
| 2631 | |||
| 2632 | pub const domainset = extern struct { | ||
| 2633 | link: LIST_ENTRY, | ||
| 2634 | mask: domainset_t, | ||
| 2635 | policy: u16, | ||
| 2636 | prefer: domainid_t, | ||
| 2637 | cnt: domainid_t, | ||
| 2638 | order: [MAXMEMDOM]domainid_t, | ||
| 2639 | }; | ||
| 2640 | |||
| 2641 | pub extern "c" fn cpuset_getdomain(level: cpulevel_t, which: cpuwhich_t, id: id_t, len: usize, domain: *domainset_t, r: *c_int) c_int; | ||
| 2642 | pub extern "c" fn cpuset_setdomain(level: cpulevel_t, which: cpuwhich_t, id: id_t, len: usize, domain: *const domainset_t, r: c_int) c_int; | ||
| 2643 | |||
| 2644 | const ioctl_cmd = enum(u32) { | ||
| 2645 | VOID = 0x20000000, | ||
| 2646 | OUT = 0x40000000, | ||
| 2647 | IN = 0x80000000, | ||
| 2648 | INOUT = ioctl_cmd.IN | ioctl_cmd.OUT, | ||
| 2649 | DIRMASK = ioctl_cmd.VOID | ioctl_cmd.IN | ioctl_cmd.OUT, | ||
| 2650 | }; | ||
| 2651 | |||
| 2652 | fn ioImpl(cmd: ioctl_cmd, op: u8, nr: u8, comptime IT: type) u32 { | ||
| 2653 | return @as(u32, @bitCast(@intFromEnum(cmd) | @as(u32, @intCast(@as(u8, @truncate(@sizeOf(IT))))) << 16 | @as(u32, @intCast(op)) << 8 | nr)); | ||
| 2654 | } | ||
| 2655 | |||
| 2656 | pub fn IO(op: u8, nr: u8) u32 { | ||
| 2657 | return ioImpl(ioctl_cmd.VOID, op, nr, 0); | ||
| 2658 | } | ||
| 2659 | |||
| 2660 | pub fn IOR(op: u8, nr: u8, comptime IT: type) u32 { | ||
| 2661 | return ioImpl(ioctl_cmd.OUT, op, nr, @sizeOf(IT)); | ||
| 2662 | } | ||
| 2663 | |||
| 2664 | pub fn IOW(op: u8, nr: u8, comptime IT: type) u32 { | ||
| 2665 | return ioImpl(ioctl_cmd.IN, op, nr, @sizeOf(IT)); | ||
| 2666 | } | ||
| 2667 | |||
| 2668 | pub fn IOWR(op: u8, nr: u8, comptime IT: type) u32 { | ||
| 2669 | return ioImpl(ioctl_cmd.INOUT, op, nr, @sizeOf(IT)); | ||
| 2670 | } | ||
| 2671 | |||
| 2672 | pub const RF = struct { | ||
| 2673 | pub const NAMEG = 1 << 0; | ||
| 2674 | pub const ENVG = 1 << 1; | ||
| 2675 | /// copy file descriptors table | ||
| 2676 | pub const FDG = 1 << 2; | ||
| 2677 | pub const NOTEG = 1 << 3; | ||
| 2678 | /// creates a new process | ||
| 2679 | pub const PROC = 1 << 4; | ||
| 2680 | /// shares address space | ||
| 2681 | pub const MEM = 1 << 5; | ||
| 2682 | /// detaches the child | ||
| 2683 | pub const NOWAIT = 1 << 6; | ||
| 2684 | pub const CNAMEG = 1 << 10; | ||
| 2685 | pub const CENVG = 1 << 11; | ||
| 2686 | /// distinct file descriptor table | ||
| 2687 | pub const CFDG = 1 << 12; | ||
| 2688 | /// thread support | ||
| 2689 | pub const THREAD = 1 << 13; | ||
| 2690 | /// shares signal handlers | ||
| 2691 | pub const SIGSHARE = 1 << 14; | ||
| 2692 | /// emits SIGUSR1 on exit | ||
| 2693 | pub const LINUXTHPN = 1 << 16; | ||
| 2694 | /// child in stopped state | ||
| 2695 | pub const STOPPED = 1 << 17; | ||
| 2696 | /// use high pid id | ||
| 2697 | pub const HIGHPID = 1 << 18; | ||
| 2698 | /// selects signal flag for parent notification | ||
| 2699 | pub const SIGSZMB = 1 << 19; | ||
| 2700 | pub fn SIGNUM(f: u32) u32 { | ||
| 2701 | return f >> 20; | ||
| 2702 | } | ||
| 2703 | pub fn SIGFLAGS(f: u32) u32 { | ||
| 2704 | return f << 20; | ||
| 2705 | } | ||
| 2706 | }; | ||
| 2707 | |||
| 2708 | pub extern "c" fn rfork(flags: c_int) c_int; | ||
| 2709 | |||
| 2710 | pub const PTRACE = struct { | ||
| 2711 | pub const EXC = 0x0001; | ||
| 2712 | pub const SCE = 0x0002; | ||
| 2713 | pub const SCX = 0x0004; | ||
| 2714 | pub const SYSCALL = (PTRACE.SCE | PTRACE.SCX); | ||
| 2715 | pub const FORK = 0x0008; | ||
| 2716 | pub const LWP = 0x0010; | ||
| 2717 | pub const VFORK = 0x0020; | ||
| 2718 | pub const DEFAULT = PTRACE.EXEC; | ||
| 2719 | }; | ||
| 2720 | |||
| 2721 | pub const PT = struct { | ||
| 2722 | pub const TRACE_ME = 0; | ||
| 2723 | pub const READ_I = 1; | ||
| 2724 | pub const READ_D = 2; | ||
| 2725 | pub const WRITE_I = 4; | ||
| 2726 | pub const WRITE_D = 5; | ||
| 2727 | pub const CONTINUE = 7; | ||
| 2728 | pub const KILL = 8; | ||
| 2729 | pub const STEP = 9; | ||
| 2730 | pub const ATTACH = 10; | ||
| 2731 | pub const DETACH = 11; | ||
| 2732 | pub const IO = 12; | ||
| 2733 | pub const LWPINFO = 13; | ||
| 2734 | pub const GETNUMLWPS = 14; | ||
| 2735 | pub const GETLWPLIST = 15; | ||
| 2736 | pub const CLEARSTEP = 16; | ||
| 2737 | pub const SETSTEP = 17; | ||
| 2738 | pub const SUSPEND = 18; | ||
| 2739 | pub const RESUME = 19; | ||
| 2740 | pub const TO_SCE = 20; | ||
| 2741 | pub const TO_SCX = 21; | ||
| 2742 | pub const SYSCALL = 22; | ||
| 2743 | pub const FOLLOW_FORK = 23; | ||
| 2744 | pub const LWP_EVENTS = 24; | ||
| 2745 | pub const GET_EVENT_MASK = 25; | ||
| 2746 | pub const SET_EVENT_MASK = 26; | ||
| 2747 | pub const GET_SC_ARGS = 27; | ||
| 2748 | pub const GET_SC_RET = 28; | ||
| 2749 | pub const COREDUMP = 29; | ||
| 2750 | pub const GETREGS = 33; | ||
| 2751 | pub const SETREGS = 34; | ||
| 2752 | pub const GETFPREGS = 35; | ||
| 2753 | pub const SETFPREGS = 36; | ||
| 2754 | pub const GETDBREGS = 37; | ||
| 2755 | pub const SETDBREGS = 38; | ||
| 2756 | pub const VM_TIMESTAMP = 40; | ||
| 2757 | pub const VM_ENTRY = 41; | ||
| 2758 | pub const GETREGSET = 42; | ||
| 2759 | pub const SETREGSET = 43; | ||
| 2760 | pub const SC_REMOTE = 44; | ||
| 2761 | pub const FIRSTMACH = 64; | ||
| 2762 | }; | ||
| 2763 | |||
| 2764 | pub const ptrace_io_desc = extern struct { | ||
| 2765 | op: c_int, | ||
| 2766 | offs: ?*anyopaque, | ||
| 2767 | addr: ?*anyopaque, | ||
| 2768 | len: usize, | ||
| 2769 | }; | ||
| 2770 | |||
| 2771 | pub const PIOD = struct { | ||
| 2772 | pub const READ_D = 1; | ||
| 2773 | pub const WRITE_D = 2; | ||
| 2774 | pub const READ_I = 3; | ||
| 2775 | pub const WRITE_I = 4; | ||
| 2776 | }; | ||
| 2777 | |||
| 2778 | pub const ptrace_lwpinfo = extern struct { | ||
| 2779 | lwpid: lwpid_t, | ||
| 2780 | event: c_int, | ||
| 2781 | flags: c_int, | ||
| 2782 | sigmask: sigset_t, | ||
| 2783 | siglist: sigset_t, | ||
| 2784 | siginfo: siginfo_t, | ||
| 2785 | tdname: [MAXCOMLEN + 1]u8, | ||
| 2786 | child_pid: pid_t, | ||
| 2787 | syscall_code: c_uint, | ||
| 2788 | syscall_narg: c_uint, | ||
| 2789 | }; | ||
| 2790 | |||
| 2791 | pub const ptrace_sc_ret = extern struct { | ||
| 2792 | retval: [2]isize, | ||
| 2793 | err: c_int, | ||
| 2794 | }; | ||
| 2795 | |||
| 2796 | pub const ptrace_vm_entry = extern struct { | ||
| 2797 | entry: c_int, | ||
| 2798 | timestamp: c_int, | ||
| 2799 | start: c_ulong, | ||
| 2800 | end: c_ulong, | ||
| 2801 | offset: c_ulong, | ||
| 2802 | prot: c_uint, | ||
| 2803 | pathlen: c_uint, | ||
| 2804 | fileid: c_long, | ||
| 2805 | fsid: u32, | ||
| 2806 | pve_path: ?[*:0]u8, | ||
| 2807 | }; | ||
| 2808 | |||
| 2809 | pub const ptrace_coredump = extern struct { | ||
| 2810 | fd: c_int, | ||
| 2811 | flags: u32, | ||
| 2812 | limit: isize, | ||
| 2813 | }; | ||
| 2814 | |||
| 2815 | pub const ptrace_cs_remote = extern struct { | ||
| 2816 | ret: ptrace_sc_ret, | ||
| 2817 | syscall: c_uint, | ||
| 2818 | nargs: c_uint, | ||
| 2819 | args: *isize, | ||
| 2820 | }; | ||
| 2821 | |||
| 2822 | pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: [*:0]u8, data: c_int) c_int; | ||
| 2823 | |||
| 2824 | /// TODO refines if necessary | ||
| 2825 | pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) { | ||
| 2826 | .x86, .powerpc => 4 * 512, | ||
| 2827 | else => 4 * 1024, | ||
| 2828 | }; | ||
| 2829 | |||
| 2830 | pub const SYS_NMLN = 256; | ||
| 2831 | |||
| 2832 | pub const utsname = extern struct { | ||
| 2833 | sysname: [255:0]u8, | ||
| 2834 | nodename: [255:0]u8, | ||
| 2835 | release: [255:0]u8, | ||
| 2836 | version: [255:0]u8, | ||
| 2837 | machine: [255:0]u8, | ||
| 2838 | }; | ||
| 2839 | |||
| 2840 | pub extern "c" fn uname(u: *utsname) c_int; |
lib/std/c/haiku.zig+8-43| ... | @@ -5,15 +5,11 @@ const maxInt = std.math.maxInt; | ... | @@ -5,15 +5,11 @@ const maxInt = std.math.maxInt; |
| 5 | const iovec = std.os.iovec; | 5 | const iovec = std.os.iovec; |
| 6 | const iovec_const = std.os.iovec_const; | 6 | const iovec_const = std.os.iovec_const; |
| 7 | 7 | ||
| 8 | const status_t = i32; | ||
| 9 | |||
| 10 | extern "c" fn _errnop() *c_int; | 8 | extern "c" fn _errnop() *c_int; |
| 11 | 9 | ||
| 12 | pub const _errno = _errnop; | 10 | pub const _errno = _errnop; |
| 13 | 11 | ||
| 14 | pub extern "c" fn find_directory(which: directory_which, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) status_t; | 12 | pub extern "c" fn find_directory(which: c_int, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) u64; |
| 15 | |||
| 16 | pub extern "c" fn find_path(codePointer: ?*const u8, baseDirectory: path_base_directory, subPath: ?[*:0]const u8, pathBuffer: [*:0]u8, bufferSize: usize) status_t; | ||
| 17 | 13 | ||
| 18 | pub extern "c" fn find_thread(thread_name: ?*anyopaque) i32; | 14 | pub extern "c" fn find_thread(thread_name: ?*anyopaque) i32; |
| 19 | 15 | ||
| ... | @@ -173,25 +169,25 @@ pub const Flock = extern struct { | ... | @@ -173,25 +169,25 @@ pub const Flock = extern struct { |
| 173 | 169 | ||
| 174 | pub const msghdr = extern struct { | 170 | pub const msghdr = extern struct { |
| 175 | /// optional address | 171 | /// optional address |
| 176 | name: ?*sockaddr, | 172 | msg_name: ?*sockaddr, |
| 177 | 173 | ||
| 178 | /// size of address | 174 | /// size of address |
| 179 | namelen: socklen_t, | 175 | msg_namelen: socklen_t, |
| 180 | 176 | ||
| 181 | /// scatter/gather array | 177 | /// scatter/gather array |
| 182 | iov: [*]iovec, | 178 | msg_iov: [*]iovec, |
| 183 | 179 | ||
| 184 | /// # elements in msg_iov | 180 | /// # elements in msg_iov |
| 185 | iovlen: i32, | 181 | msg_iovlen: i32, |
| 186 | 182 | ||
| 187 | /// ancillary data | 183 | /// ancillary data |
| 188 | control: ?*anyopaque, | 184 | msg_control: ?*anyopaque, |
| 189 | 185 | ||
| 190 | /// ancillary data buffer len | 186 | /// ancillary data buffer len |
| 191 | controllen: socklen_t, | 187 | msg_controllen: socklen_t, |
| 192 | 188 | ||
| 193 | /// flags on received message | 189 | /// flags on received message |
| 194 | flags: i32, | 190 | msg_flags: i32, |
| 195 | }; | 191 | }; |
| 196 | 192 | ||
| 197 | pub const off_t = i64; | 193 | pub const off_t = i64; |
| ... | @@ -1024,13 +1020,6 @@ pub const directory_which = enum(c_int) { | ... | @@ -1024,13 +1020,6 @@ pub const directory_which = enum(c_int) { |
| 1024 | _, | 1020 | _, |
| 1025 | }; | 1021 | }; |
| 1026 | 1022 | ||
| 1027 | // TODO fill out if needed | ||
| 1028 | pub const path_base_directory = enum(c_int) { | ||
| 1029 | B_FIND_PATH_IMAGE_PATH = 1000, | ||
| 1030 | }; | ||
| 1031 | |||
| 1032 | pub const B_APP_IMAGE_SYMBOL = null; | ||
| 1033 | |||
| 1034 | pub const cc_t = u8; | 1023 | pub const cc_t = u8; |
| 1035 | pub const speed_t = u8; | 1024 | pub const speed_t = u8; |
| 1036 | pub const tcflag_t = u32; | 1025 | pub const tcflag_t = u32; |
| ... | @@ -1049,27 +1038,3 @@ pub const termios = extern struct { | ... | @@ -1049,27 +1038,3 @@ pub const termios = extern struct { |
| 1049 | }; | 1038 | }; |
| 1050 | 1039 | ||
| 1051 | pub const MSG_NOSIGNAL = 0x0800; | 1040 | pub const MSG_NOSIGNAL = 0x0800; |
| 1052 | |||
| 1053 | pub const SIGEV = struct { | ||
| 1054 | pub const NONE = 0; | ||
| 1055 | pub const SIGNAL = 1; | ||
| 1056 | pub const THREAD = 2; | ||
| 1057 | }; | ||
| 1058 | |||
| 1059 | pub const sigval = extern union { | ||
| 1060 | int: c_int, | ||
| 1061 | ptr: ?*anyopaque, | ||
| 1062 | }; | ||
| 1063 | |||
| 1064 | pub const sigevent = extern struct { | ||
| 1065 | sigev_notify: c_int, | ||
| 1066 | sigev_signo: c_int, | ||
| 1067 | sigev_value: sigval, | ||
| 1068 | sigev_notify_function: ?*const fn (sigval) callconv(.C) void, | ||
| 1069 | sigev_notify_attributes: ?*pthread_attr_t, | ||
| 1070 | }; | ||
| 1071 | |||
| 1072 | /// TODO refines if necessary | ||
| 1073 | pub const PTHREAD_STACK_MIN = 2 * 4096; | ||
| 1074 | |||
| 1075 | pub extern "c" fn malloc_usable_size(?*anyopaque) usize; |
lib/std/c/linux.zig-34| ... | @@ -13,10 +13,6 @@ pub const ARCH = linux.ARCH; | ... | @@ -13,10 +13,6 @@ pub const ARCH = linux.ARCH; |
| 13 | pub const AT = linux.AT; | 13 | pub const AT = linux.AT; |
| 14 | pub const CLOCK = linux.CLOCK; | 14 | pub const CLOCK = linux.CLOCK; |
| 15 | pub const CPU_COUNT = linux.CPU_COUNT; | 15 | pub const CPU_COUNT = linux.CPU_COUNT; |
| 16 | pub const CPU_SET = linux.CPU_SET; | ||
| 17 | pub const CPU_ISSET = linux.CPU_ISSET; | ||
| 18 | pub const CPU_CLR = linux.CPU_CLR; | ||
| 19 | pub const CPU_ZERO = linux.CPU_ZERO; | ||
| 20 | pub const E = linux.E; | 16 | pub const E = linux.E; |
| 21 | pub const Elf_Symndx = linux.Elf_Symndx; | 17 | pub const Elf_Symndx = linux.Elf_Symndx; |
| 22 | pub const F = linux.F; | 18 | pub const F = linux.F; |
| ... | @@ -100,7 +96,6 @@ pub const stack_t = linux.stack_t; | ... | @@ -100,7 +96,6 @@ pub const stack_t = linux.stack_t; |
| 100 | pub const tcflag_t = linux.tcflag_t; | 96 | pub const tcflag_t = linux.tcflag_t; |
| 101 | pub const termios = linux.termios; | 97 | pub const termios = linux.termios; |
| 102 | pub const time_t = linux.time_t; | 98 | pub const time_t = linux.time_t; |
| 103 | pub const timer_t = linux.timer_t; | ||
| 104 | pub const timespec = linux.timespec; | 99 | pub const timespec = linux.timespec; |
| 105 | pub const timeval = linux.timeval; | 100 | pub const timeval = linux.timeval; |
| 106 | pub const timezone = linux.timezone; | 101 | pub const timezone = linux.timezone; |
| ... | @@ -250,7 +245,6 @@ pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_ | ... | @@ -250,7 +245,6 @@ pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_ |
| 250 | 245 | ||
| 251 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; | 246 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; |
| 252 | pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int; | 247 | pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int; |
| 253 | pub extern "c" fn sched_setaffinity(pid: c_int, size: usize, set: *const cpu_set_t) c_int; | ||
| 254 | pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int; | 248 | pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int; |
| 255 | pub extern "c" fn epoll_ctl(epfd: fd_t, op: c_uint, fd: fd_t, event: ?*epoll_event) c_int; | 249 | pub extern "c" fn epoll_ctl(epfd: fd_t, op: c_uint, fd: fd_t, event: ?*epoll_event) c_int; |
| 256 | pub extern "c" fn epoll_create1(flags: c_uint) c_int; | 250 | pub extern "c" fn epoll_create1(flags: c_uint) c_int; |
| ... | @@ -351,18 +345,6 @@ const __SIZEOF_PTHREAD_MUTEX_T = switch (native_abi) { | ... | @@ -351,18 +345,6 @@ const __SIZEOF_PTHREAD_MUTEX_T = switch (native_abi) { |
| 351 | }; | 345 | }; |
| 352 | const __SIZEOF_SEM_T = 4 * @sizeOf(usize); | 346 | const __SIZEOF_SEM_T = 4 * @sizeOf(usize); |
| 353 | 347 | ||
| 354 | /// TODO refines if necessary | ||
| 355 | pub const PTHREAD_STACK_MIN = switch (native_abi) { | ||
| 356 | .musl, .musleabi, .musleabihf => 2048, | ||
| 357 | .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (native_arch) { | ||
| 358 | .aarch64, .arm, .armeb, .powerpc, .powerpc64, .powerpc64le, .loongarch32, .loongarch64 => 131072, | ||
| 359 | .sparc64 => 24576, | ||
| 360 | else => 16 * 1024, | ||
| 361 | }, | ||
| 362 | .android => if (@sizeOf(usize) == 8) 16 * 1024 else 8 * 1024, | ||
| 363 | else => 16 * 1024, | ||
| 364 | }; | ||
| 365 | |||
| 366 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E; | 348 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E; |
| 367 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; | 349 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; |
| 368 | 350 | ||
| ... | @@ -389,19 +371,3 @@ pub const dirent64 = struct { | ... | @@ -389,19 +371,3 @@ pub const dirent64 = struct { |
| 389 | d_type: u8, | 371 | d_type: u8, |
| 390 | d_name: [256]u8, | 372 | d_name: [256]u8, |
| 391 | }; | 373 | }; |
| 392 | |||
| 393 | pub const MPOL = struct { | ||
| 394 | pub const F_NODE = 1 << 0; | ||
| 395 | pub const F_ADDR = 1 << 1; | ||
| 396 | pub const F_MEMS_ALLOWED = 1 << 2; | ||
| 397 | /// flags for SYS_mbind | ||
| 398 | pub const MF_STRICT = 1 << 0; | ||
| 399 | pub const MF_MOVE = 1 << 1; | ||
| 400 | pub const MF_MOVE_ALL = 1 << 2; | ||
| 401 | pub const MF_LAZY = 1 << 3; | ||
| 402 | pub const MF_INTERNAL = 1 << 4; | ||
| 403 | pub const MF_VALID = MPOL.MF_STRICT | MPOL.MF_MOVE | MPOL.MOVE_ALL; | ||
| 404 | }; | ||
| 405 | |||
| 406 | pub extern "c" fn getcpu(cpu: *c_uint, node: *c_uint) c_int; | ||
| 407 | pub extern "c" fn sched_getcpu() c_int; |
lib/std/c/minix.zig-2| ... | @@ -16,5 +16,3 @@ const __SIZEOF_PTHREAD_MUTEX_T = switch (builtin.abi) { | ... | @@ -16,5 +16,3 @@ const __SIZEOF_PTHREAD_MUTEX_T = switch (builtin.abi) { |
| 16 | }, | 16 | }, |
| 17 | else => unreachable, | 17 | else => unreachable, |
| 18 | }; | 18 | }; |
| 19 | |||
| 20 | pub const PTHREAD_STACK_MIN = 16 * 1024; |
lib/std/c/netbsd.zig+14-134| ... | @@ -121,21 +121,9 @@ pub const pthread_attr_t = extern struct { | ... | @@ -121,21 +121,9 @@ pub const pthread_attr_t = extern struct { |
| 121 | }; | 121 | }; |
| 122 | 122 | ||
| 123 | pub const sem_t = ?*opaque {}; | 123 | pub const sem_t = ?*opaque {}; |
| 124 | pub const cpuset_t = opaque {}; | ||
| 125 | pub const cpuid_t = c_ulong; | ||
| 126 | 124 | ||
| 127 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*anyopaque) E; | 125 | pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*anyopaque) E; |
| 128 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; | 126 | pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E; |
| 129 | pub extern "c" fn pthread_setaffinity_np(thread: std.c.pthread_t, size: usize, set: ?*cpuset_t) c_int; | ||
| 130 | pub extern "c" fn pthread_getaffinity_np(thread: std.c.pthread_t, size: usize, set: ?*cpuset_t) c_int; | ||
| 131 | |||
| 132 | pub extern "c" fn cpuset_create() ?*cpuset_t; | ||
| 133 | pub extern "c" fn cpuset_destroy(set: ?*cpuset_t) void; | ||
| 134 | pub extern "c" fn cpuset_zero(set: ?*cpuset_t) void; | ||
| 135 | pub extern "c" fn cpuset_set(cpu: cpuid_t, set: ?*cpuset_t) c_int; | ||
| 136 | pub extern "c" fn cpuset_clr(cpu: cpuid_t, set: ?*cpuset_t) c_int; | ||
| 137 | pub extern "c" fn cpuset_isset(cpu: cpuid_t, set: ?*const cpuset_t) c_int; | ||
| 138 | pub extern "c" fn cpuset_size(set: ?*cpuset_t) usize; | ||
| 139 | 127 | ||
| 140 | pub const blkcnt_t = i64; | 128 | pub const blkcnt_t = i64; |
| 141 | pub const blksize_t = i32; | 129 | pub const blksize_t = i32; |
| ... | @@ -253,48 +241,48 @@ pub const EAI_MAX = 15; | ... | @@ -253,48 +241,48 @@ pub const EAI_MAX = 15; |
| 253 | 241 | ||
| 254 | pub const msghdr = extern struct { | 242 | pub const msghdr = extern struct { |
| 255 | /// optional address | 243 | /// optional address |
| 256 | name: ?*sockaddr, | 244 | msg_name: ?*sockaddr, |
| 257 | 245 | ||
| 258 | /// size of address | 246 | /// size of address |
| 259 | namelen: socklen_t, | 247 | msg_namelen: socklen_t, |
| 260 | 248 | ||
| 261 | /// scatter/gather array | 249 | /// scatter/gather array |
| 262 | iov: [*]iovec, | 250 | msg_iov: [*]iovec, |
| 263 | 251 | ||
| 264 | /// # elements in msg_iov | 252 | /// # elements in msg_iov |
| 265 | iovlen: i32, | 253 | msg_iovlen: i32, |
| 266 | 254 | ||
| 267 | /// ancillary data | 255 | /// ancillary data |
| 268 | control: ?*anyopaque, | 256 | msg_control: ?*anyopaque, |
| 269 | 257 | ||
| 270 | /// ancillary data buffer len | 258 | /// ancillary data buffer len |
| 271 | controllen: socklen_t, | 259 | msg_controllen: socklen_t, |
| 272 | 260 | ||
| 273 | /// flags on received message | 261 | /// flags on received message |
| 274 | flags: i32, | 262 | msg_flags: i32, |
| 275 | }; | 263 | }; |
| 276 | 264 | ||
| 277 | pub const msghdr_const = extern struct { | 265 | pub const msghdr_const = extern struct { |
| 278 | /// optional address | 266 | /// optional address |
| 279 | name: ?*const sockaddr, | 267 | msg_name: ?*const sockaddr, |
| 280 | 268 | ||
| 281 | /// size of address | 269 | /// size of address |
| 282 | namelen: socklen_t, | 270 | msg_namelen: socklen_t, |
| 283 | 271 | ||
| 284 | /// scatter/gather array | 272 | /// scatter/gather array |
| 285 | iov: [*]const iovec_const, | 273 | msg_iov: [*]const iovec_const, |
| 286 | 274 | ||
| 287 | /// # elements in msg_iov | 275 | /// # elements in msg_iov |
| 288 | iovlen: i32, | 276 | msg_iovlen: i32, |
| 289 | 277 | ||
| 290 | /// ancillary data | 278 | /// ancillary data |
| 291 | control: ?*const anyopaque, | 279 | msg_control: ?*const anyopaque, |
| 292 | 280 | ||
| 293 | /// ancillary data buffer len | 281 | /// ancillary data buffer len |
| 294 | controllen: socklen_t, | 282 | msg_controllen: socklen_t, |
| 295 | 283 | ||
| 296 | /// flags on received message | 284 | /// flags on received message |
| 297 | flags: i32, | 285 | msg_flags: i32, |
| 298 | }; | 286 | }; |
| 299 | 287 | ||
| 300 | /// The stat structure used by libc. | 288 | /// The stat structure used by libc. |
| ... | @@ -485,11 +473,6 @@ pub const AF = struct { | ... | @@ -485,11 +473,6 @@ pub const AF = struct { |
| 485 | pub const MAX = 37; | 473 | pub const MAX = 37; |
| 486 | }; | 474 | }; |
| 487 | 475 | ||
| 488 | pub const accept_filter_arg = extern struct { | ||
| 489 | af_name: [16]u8, | ||
| 490 | af_args: [240]u8, | ||
| 491 | }; | ||
| 492 | |||
| 493 | pub const in_port_t = u16; | 476 | pub const in_port_t = u16; |
| 494 | pub const sa_family_t = u8; | 477 | pub const sa_family_t = u8; |
| 495 | 478 | ||
| ... | @@ -579,12 +562,6 @@ pub const PROT = struct { | ... | @@ -579,12 +562,6 @@ pub const PROT = struct { |
| 579 | pub const READ = 1; | 562 | pub const READ = 1; |
| 580 | pub const WRITE = 2; | 563 | pub const WRITE = 2; |
| 581 | pub const EXEC = 4; | 564 | pub const EXEC = 4; |
| 582 | pub fn MPROTECT(flag: u32) u32 { | ||
| 583 | return flag << 3; | ||
| 584 | } | ||
| 585 | pub fn MPROTECT_EXTRACT(flag: u32) u32 { | ||
| 586 | return (flag >> 3) & 0x7; | ||
| 587 | } | ||
| 588 | }; | 565 | }; |
| 589 | 566 | ||
| 590 | pub const CLOCK = struct { | 567 | pub const CLOCK = struct { |
| ... | @@ -614,27 +591,6 @@ pub const MAP = struct { | ... | @@ -614,27 +591,6 @@ pub const MAP = struct { |
| 614 | pub const ANON = 0x1000; | 591 | pub const ANON = 0x1000; |
| 615 | pub const ANONYMOUS = ANON; | 592 | pub const ANONYMOUS = ANON; |
| 616 | pub const STACK = 0x2000; | 593 | pub const STACK = 0x2000; |
| 617 | |||
| 618 | pub const ALIGNMENT_SHIFT = 24; | ||
| 619 | pub fn ALIGNED(n: u32) u32 { | ||
| 620 | return n << ALIGNMENT_SHIFT; | ||
| 621 | } | ||
| 622 | pub const ALIGNMENT_64KB = MAP.ALIGNED(0xff); | ||
| 623 | pub const ALIGNMENT_16MB = MAP.ALIGNED(16); | ||
| 624 | pub const ALIGNMENT_4GB = MAP.ALIGNED(32); | ||
| 625 | pub const ALIGNMENT_1TB = MAP.ALIGNED(40); | ||
| 626 | pub const ALIGNMENT_256TB = MAP.ALIGNED(48); | ||
| 627 | pub const ALIGNMENT_64PB = MAP.ALIGNED(56); | ||
| 628 | }; | ||
| 629 | |||
| 630 | pub const MADV = struct { | ||
| 631 | pub const NORMAL = 0; | ||
| 632 | pub const RANDOM = 1; | ||
| 633 | pub const SEQUENTIAL = 2; | ||
| 634 | pub const WILLNEED = 3; | ||
| 635 | pub const DONTNEED = 4; | ||
| 636 | pub const SPACEAVAIL = 5; | ||
| 637 | pub const FREE = 6; | ||
| 638 | }; | 594 | }; |
| 639 | 595 | ||
| 640 | pub const MSF = struct { | 596 | pub const MSF = struct { |
| ... | @@ -1665,79 +1621,3 @@ pub const POLL = struct { | ... | @@ -1665,79 +1621,3 @@ pub const POLL = struct { |
| 1665 | pub const HUP = 0x0010; | 1621 | pub const HUP = 0x0010; |
| 1666 | pub const NVAL = 0x0020; | 1622 | pub const NVAL = 0x0020; |
| 1667 | }; | 1623 | }; |
| 1668 | |||
| 1669 | pub const SIGEV = struct { | ||
| 1670 | pub const NONE = 0; | ||
| 1671 | pub const SIGNAL = 1; | ||
| 1672 | pub const THREAD = 2; | ||
| 1673 | }; | ||
| 1674 | |||
| 1675 | pub const sigval = extern union { | ||
| 1676 | int: c_int, | ||
| 1677 | ptr: ?*anyopaque, | ||
| 1678 | }; | ||
| 1679 | |||
| 1680 | pub const sigevent = extern struct { | ||
| 1681 | sigev_notify: c_int, | ||
| 1682 | sigev_signo: c_int, | ||
| 1683 | sigev_value: sigval, | ||
| 1684 | sigev_notify_function: ?*const fn (sigval) callconv(.C) void, | ||
| 1685 | sigev_notify_attributes: ?*pthread_attr_t, | ||
| 1686 | }; | ||
| 1687 | |||
| 1688 | pub const PTRACE = struct { | ||
| 1689 | pub const FORK = 0x0001; | ||
| 1690 | pub const VFORK = 0x0002; | ||
| 1691 | pub const VFORK_DONE = 0x0004; | ||
| 1692 | pub const LWP_CREATE = 0x0008; | ||
| 1693 | pub const LWP_EXIT = 0x0010; | ||
| 1694 | pub const POSIX_SPAWN = 0x0020; | ||
| 1695 | }; | ||
| 1696 | |||
| 1697 | pub const PT = struct { | ||
| 1698 | pub const TRACE_ME = 0; | ||
| 1699 | pub const READ_I = 1; | ||
| 1700 | pub const READ_D = 2; | ||
| 1701 | pub const WRITE_I = 4; | ||
| 1702 | pub const WRITE_D = 5; | ||
| 1703 | pub const CONTINUE = 7; | ||
| 1704 | pub const KILL = 8; | ||
| 1705 | pub const ATTACH = 9; | ||
| 1706 | pub const DETACH = 10; | ||
| 1707 | pub const IO = 11; | ||
| 1708 | pub const DUMPCORE = 11; | ||
| 1709 | pub const LWPINFO = 12; | ||
| 1710 | }; | ||
| 1711 | |||
| 1712 | pub const ptrace_event = extern struct { | ||
| 1713 | set_event: c_int, | ||
| 1714 | }; | ||
| 1715 | |||
| 1716 | pub const ptrace_state = extern struct { | ||
| 1717 | report_event: c_int, | ||
| 1718 | _option: extern union { | ||
| 1719 | other_pid: pid_t, | ||
| 1720 | lwp: lwpid_t, | ||
| 1721 | }, | ||
| 1722 | }; | ||
| 1723 | |||
| 1724 | pub const ptrace_io_desc = extern struct { | ||
| 1725 | op: c_int, | ||
| 1726 | offs: ?*anyopaque, | ||
| 1727 | addr: ?*anyopaque, | ||
| 1728 | len: usize, | ||
| 1729 | }; | ||
| 1730 | |||
| 1731 | pub const PIOD = struct { | ||
| 1732 | pub const READ_D = 1; | ||
| 1733 | pub const WRITE_D = 2; | ||
| 1734 | pub const READ_I = 3; | ||
| 1735 | pub const WRITE_I = 4; | ||
| 1736 | }; | ||
| 1737 | |||
| 1738 | pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: ?*anyopaque, data: c_int) c_int; | ||
| 1739 | |||
| 1740 | /// TODO refines if necessary | ||
| 1741 | pub const PTHREAD_STACK_MIN = 16 * 1024; | ||
| 1742 | |||
| 1743 | pub const timer_t = *opaque {}; |
lib/std/c/openbsd.zig+49-71| ... | @@ -252,22 +252,16 @@ pub const EAI_MAX = 15; | ... | @@ -252,22 +252,16 @@ pub const EAI_MAX = 15; |
| 252 | pub const msghdr = extern struct { | 252 | pub const msghdr = extern struct { |
| 253 | /// optional address | 253 | /// optional address |
| 254 | name: ?*sockaddr, | 254 | name: ?*sockaddr, |
| 255 | |||
| 256 | /// size of address | 255 | /// size of address |
| 257 | namelen: socklen_t, | 256 | namelen: socklen_t, |
| 258 | |||
| 259 | /// scatter/gather array | 257 | /// scatter/gather array |
| 260 | iov: [*]iovec, | 258 | iov: [*]iovec, |
| 261 | 259 | /// # elements in iov | |
| 262 | /// # elements in msg_iov | ||
| 263 | iovlen: c_uint, | 260 | iovlen: c_uint, |
| 264 | |||
| 265 | /// ancillary data | 261 | /// ancillary data |
| 266 | control: ?*anyopaque, | 262 | control: ?*anyopaque, |
| 267 | |||
| 268 | /// ancillary data buffer len | 263 | /// ancillary data buffer len |
| 269 | controllen: socklen_t, | 264 | controllen: socklen_t, |
| 270 | |||
| 271 | /// flags on received message | 265 | /// flags on received message |
| 272 | flags: c_int, | 266 | flags: c_int, |
| 273 | }; | 267 | }; |
| ... | @@ -275,22 +269,16 @@ pub const msghdr = extern struct { | ... | @@ -275,22 +269,16 @@ pub const msghdr = extern struct { |
| 275 | pub const msghdr_const = extern struct { | 269 | pub const msghdr_const = extern struct { |
| 276 | /// optional address | 270 | /// optional address |
| 277 | name: ?*const sockaddr, | 271 | name: ?*const sockaddr, |
| 278 | |||
| 279 | /// size of address | 272 | /// size of address |
| 280 | namelen: socklen_t, | 273 | namelen: socklen_t, |
| 281 | |||
| 282 | /// scatter/gather array | 274 | /// scatter/gather array |
| 283 | iov: [*]const iovec_const, | 275 | iov: [*]const iovec_const, |
| 284 | 276 | /// # elements in iov | |
| 285 | /// # elements in msg_iov | ||
| 286 | iovlen: c_uint, | 277 | iovlen: c_uint, |
| 287 | |||
| 288 | /// ancillary data | 278 | /// ancillary data |
| 289 | control: ?*const anyopaque, | 279 | control: ?*const anyopaque, |
| 290 | |||
| 291 | /// ancillary data buffer len | 280 | /// ancillary data buffer len |
| 292 | controllen: socklen_t, | 281 | controllen: socklen_t, |
| 293 | |||
| 294 | /// flags on received message | 282 | /// flags on received message |
| 295 | flags: c_int, | 283 | flags: c_int, |
| 296 | }; | 284 | }; |
| ... | @@ -466,16 +454,6 @@ pub const MAP = struct { | ... | @@ -466,16 +454,6 @@ pub const MAP = struct { |
| 466 | pub const CONCEAL = 0x8000; | 454 | pub const CONCEAL = 0x8000; |
| 467 | }; | 455 | }; |
| 468 | 456 | ||
| 469 | pub const MADV = struct { | ||
| 470 | pub const NORMAL = 0; | ||
| 471 | pub const RANDOM = 1; | ||
| 472 | pub const SEQUENTIAL = 2; | ||
| 473 | pub const WILLNEED = 3; | ||
| 474 | pub const DONTNEED = 4; | ||
| 475 | pub const SPACEAVAIL = 5; | ||
| 476 | pub const FREE = 6; | ||
| 477 | }; | ||
| 478 | |||
| 479 | pub const MSF = struct { | 457 | pub const MSF = struct { |
| 480 | pub const ASYNC = 1; | 458 | pub const ASYNC = 1; |
| 481 | pub const INVALIDATE = 2; | 459 | pub const INVALIDATE = 2; |
| ... | @@ -1102,54 +1080,55 @@ comptime { | ... | @@ -1102,54 +1080,55 @@ comptime { |
| 1102 | } | 1080 | } |
| 1103 | 1081 | ||
| 1104 | pub usingnamespace switch (builtin.cpu.arch) { | 1082 | pub usingnamespace switch (builtin.cpu.arch) { |
| 1105 | .x86_64 => struct { | 1083 | .x86_64 => struct {}, |
| 1106 | pub const ucontext_t = extern struct { | 1084 | else => struct {}, |
| 1107 | sc_rdi: c_long, | 1085 | }; |
| 1108 | sc_rsi: c_long, | 1086 | |
| 1109 | sc_rdx: c_long, | 1087 | pub const ucontext_t = switch (builtin.cpu.arch) { |
| 1110 | sc_rcx: c_long, | 1088 | .x86_64 => extern struct { |
| 1111 | sc_r8: c_long, | 1089 | sc_rdi: c_long, |
| 1112 | sc_r9: c_long, | 1090 | sc_rsi: c_long, |
| 1113 | sc_r10: c_long, | 1091 | sc_rdx: c_long, |
| 1114 | sc_r11: c_long, | 1092 | sc_rcx: c_long, |
| 1115 | sc_r12: c_long, | 1093 | sc_r8: c_long, |
| 1116 | sc_r13: c_long, | 1094 | sc_r9: c_long, |
| 1117 | sc_r14: c_long, | 1095 | sc_r10: c_long, |
| 1118 | sc_r15: c_long, | 1096 | sc_r11: c_long, |
| 1119 | sc_rbp: c_long, | 1097 | sc_r12: c_long, |
| 1120 | sc_rbx: c_long, | 1098 | sc_r13: c_long, |
| 1121 | sc_rax: c_long, | 1099 | sc_r14: c_long, |
| 1122 | sc_gs: c_long, | 1100 | sc_r15: c_long, |
| 1123 | sc_fs: c_long, | 1101 | sc_rbp: c_long, |
| 1124 | sc_es: c_long, | 1102 | sc_rbx: c_long, |
| 1125 | sc_ds: c_long, | 1103 | sc_rax: c_long, |
| 1126 | sc_trapno: c_long, | 1104 | sc_gs: c_long, |
| 1127 | sc_err: c_long, | 1105 | sc_fs: c_long, |
| 1128 | sc_rip: c_long, | 1106 | sc_es: c_long, |
| 1129 | sc_cs: c_long, | 1107 | sc_ds: c_long, |
| 1130 | sc_rflags: c_long, | 1108 | sc_trapno: c_long, |
| 1131 | sc_rsp: c_long, | 1109 | sc_err: c_long, |
| 1132 | sc_ss: c_long, | 1110 | sc_rip: c_long, |
| 1133 | 1111 | sc_cs: c_long, | |
| 1134 | sc_fpstate: *anyopaque, // struct fxsave64 * | 1112 | sc_rflags: c_long, |
| 1135 | __sc_unused: c_int, | 1113 | sc_rsp: c_long, |
| 1136 | sc_mask: c_int, | 1114 | sc_ss: c_long, |
| 1137 | sc_cookie: c_long, | 1115 | |
| 1138 | }; | 1116 | sc_fpstate: *anyopaque, // struct fxsave64 * |
| 1117 | __sc_unused: c_int, | ||
| 1118 | sc_mask: c_int, | ||
| 1119 | sc_cookie: c_long, | ||
| 1139 | }, | 1120 | }, |
| 1140 | .aarch64 => struct { | 1121 | .aarch64 => extern struct { |
| 1141 | pub const ucontext_t = extern struct { | 1122 | __sc_unused: c_int, |
| 1142 | __sc_unused: c_int, | 1123 | sc_mask: c_int, |
| 1143 | sc_mask: c_int, | 1124 | sc_sp: c_ulong, |
| 1144 | sc_sp: c_ulong, | 1125 | sc_lr: c_ulong, |
| 1145 | sc_lr: c_ulong, | 1126 | sc_elr: c_ulong, |
| 1146 | sc_elr: c_ulong, | 1127 | sc_spsr: c_ulong, |
| 1147 | sc_spsr: c_ulong, | 1128 | sc_x: [30]c_ulong, |
| 1148 | sc_x: [30]c_ulong, | 1129 | sc_cookie: c_long, |
| 1149 | sc_cookie: c_long, | ||
| 1150 | }; | ||
| 1151 | }, | 1130 | }, |
| 1152 | else => struct {}, | 1131 | else => @compileError("missing ucontext_t type definition"), |
| 1153 | }; | 1132 | }; |
| 1154 | 1133 | ||
| 1155 | pub const sigset_t = c_uint; | 1134 | pub const sigset_t = c_uint; |
| ... | @@ -1645,7 +1624,6 @@ pub const HW = struct { | ... | @@ -1645,7 +1624,6 @@ pub const HW = struct { |
| 1645 | pub const POWER = 26; | 1624 | pub const POWER = 26; |
| 1646 | }; | 1625 | }; |
| 1647 | 1626 | ||
| 1648 | /// TODO refines if necessary | ||
| 1649 | pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) { | 1627 | pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) { |
| 1650 | .sparc64 => 1 << 13, | 1628 | .sparc64 => 1 << 13, |
| 1651 | .mips64 => 1 << 14, | 1629 | .mips64 => 1 << 14, |
lib/std/c/solaris.zig+14-38| ... | @@ -16,7 +16,6 @@ pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; | ... | @@ -16,7 +16,6 @@ pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; |
| 16 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | 16 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; |
| 17 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; | 17 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; |
| 18 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; | 18 | pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; |
| 19 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; | ||
| 20 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | 19 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; |
| 21 | pub extern "c" fn sysconf(sc: c_int) i64; | 20 | pub extern "c" fn sysconf(sc: c_int) i64; |
| 22 | pub extern "c" fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) c_int; | 21 | pub extern "c" fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) c_int; |
| ... | @@ -183,36 +182,36 @@ pub const EAI_MAX = 14; | ... | @@ -183,36 +182,36 @@ pub const EAI_MAX = 14; |
| 183 | 182 | ||
| 184 | pub const msghdr = extern struct { | 183 | pub const msghdr = extern struct { |
| 185 | /// optional address | 184 | /// optional address |
| 186 | name: ?*sockaddr, | 185 | msg_name: ?*sockaddr, |
| 187 | /// size of address | 186 | /// size of address |
| 188 | namelen: socklen_t, | 187 | msg_namelen: socklen_t, |
| 189 | /// scatter/gather array | 188 | /// scatter/gather array |
| 190 | iov: [*]iovec, | 189 | msg_iov: [*]iovec, |
| 191 | /// # elements in msg_iov | 190 | /// # elements in msg_iov |
| 192 | iovlen: i32, | 191 | msg_iovlen: i32, |
| 193 | /// ancillary data | 192 | /// ancillary data |
| 194 | control: ?*anyopaque, | 193 | msg_control: ?*anyopaque, |
| 195 | /// ancillary data buffer len | 194 | /// ancillary data buffer len |
| 196 | controllen: socklen_t, | 195 | msg_controllen: socklen_t, |
| 197 | /// flags on received message | 196 | /// flags on received message |
| 198 | flags: i32, | 197 | msg_flags: i32, |
| 199 | }; | 198 | }; |
| 200 | 199 | ||
| 201 | pub const msghdr_const = extern struct { | 200 | pub const msghdr_const = extern struct { |
| 202 | /// optional address | 201 | /// optional address |
| 203 | name: ?*const sockaddr, | 202 | msg_name: ?*const sockaddr, |
| 204 | /// size of address | 203 | /// size of address |
| 205 | namelen: socklen_t, | 204 | msg_namelen: socklen_t, |
| 206 | /// scatter/gather array | 205 | /// scatter/gather array |
| 207 | iov: [*]const iovec_const, | 206 | msg_iov: [*]const iovec_const, |
| 208 | /// # elements in msg_iov | 207 | /// # elements in msg_iov |
| 209 | iovlen: i32, | 208 | msg_iovlen: i32, |
| 210 | /// ancillary data | 209 | /// ancillary data |
| 211 | control: ?*const anyopaque, | 210 | msg_control: ?*const anyopaque, |
| 212 | /// ancillary data buffer len | 211 | /// ancillary data buffer len |
| 213 | controllen: socklen_t, | 212 | msg_controllen: socklen_t, |
| 214 | /// flags on received message | 213 | /// flags on received message |
| 215 | flags: i32, | 214 | msg_flags: i32, |
| 216 | }; | 215 | }; |
| 217 | 216 | ||
| 218 | pub const cmsghdr = extern struct { | 217 | pub const cmsghdr = extern struct { |
| ... | @@ -1927,26 +1926,3 @@ pub fn IOW(io_type: u8, nr: u8, comptime IOT: type) i32 { | ... | @@ -1927,26 +1926,3 @@ pub fn IOW(io_type: u8, nr: u8, comptime IOT: type) i32 { |
| 1927 | pub fn IOWR(io_type: u8, nr: u8, comptime IOT: type) i32 { | 1926 | pub fn IOWR(io_type: u8, nr: u8, comptime IOT: type) i32 { |
| 1928 | return ioImpl(.read_write, io_type, nr, IOT); | 1927 | return ioImpl(.read_write, io_type, nr, IOT); |
| 1929 | } | 1928 | } |
| 1930 | |||
| 1931 | pub const SIGEV = struct { | ||
| 1932 | pub const NONE = 0; | ||
| 1933 | pub const SIGNAL = 1; | ||
| 1934 | pub const THREAD = 2; | ||
| 1935 | }; | ||
| 1936 | |||
| 1937 | pub const sigval = extern union { | ||
| 1938 | int: c_int, | ||
| 1939 | ptr: ?*anyopaque, | ||
| 1940 | }; | ||
| 1941 | |||
| 1942 | pub const sigevent = extern struct { | ||
| 1943 | sigev_notify: c_int, | ||
| 1944 | sigev_signo: c_int, | ||
| 1945 | sigev_value: sigval, | ||
| 1946 | sigev_notify_function: ?*const fn (sigval) callconv(.C) void, | ||
| 1947 | sigev_notify_attributes: ?*pthread_attr_t, | ||
| 1948 | }; | ||
| 1949 | |||
| 1950 | pub const PTHREAD_STACK_MIN = if (@sizeOf(usize) == 8) 8 * 1024 else 4 * 1024; | ||
| 1951 | |||
| 1952 | pub const timer_t = *opaque {}; |
lib/std/c/wasi.zig-2| ... | @@ -119,5 +119,3 @@ pub const POLL = struct { | ... | @@ -119,5 +119,3 @@ pub const POLL = struct { |
| 119 | pub const HUP = 0x2000; | 119 | pub const HUP = 0x2000; |
| 120 | pub const NVAL = 0x4000; | 120 | pub const NVAL = 0x4000; |
| 121 | }; | 121 | }; |
| 122 | |||
| 123 | pub const PTHREAD_STACK_MIN = 16 * 1024; |
lib/std/fs.zig+2-10| ... | @@ -2934,7 +2934,6 @@ pub const OpenSelfExeError = error{ | ... | @@ -2934,7 +2934,6 @@ pub const OpenSelfExeError = error{ |
| 2934 | /// On Windows, file paths cannot contain these characters: | 2934 | /// On Windows, file paths cannot contain these characters: |
| 2935 | /// '/', '*', '?', '"', '<', '>', '|' | 2935 | /// '/', '*', '?', '"', '<', '>', '|' |
| 2936 | BadPathName, | 2936 | BadPathName, |
| 2937 | Overflow, | ||
| 2938 | Unexpected, | 2937 | Unexpected, |
| 2939 | } || os.OpenError || SelfExePathError || os.FlockError; | 2938 | } || os.OpenError || SelfExePathError || os.FlockError; |
| 2940 | 2939 | ||
| ... | @@ -3014,14 +3013,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { | ... | @@ -3014,14 +3013,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 3014 | // TODO could this slice from 0 to out_len instead? | 3013 | // TODO could this slice from 0 to out_len instead? |
| 3015 | return mem.sliceTo(out_buffer, 0); | 3014 | return mem.sliceTo(out_buffer, 0); |
| 3016 | }, | 3015 | }, |
| 3017 | .haiku => { | 3016 | .openbsd, .haiku => { |
| 3018 | // The only possible issue when looking for the self image path is | ||
| 3019 | // when the buffer is too short. | ||
| 3020 | if (os.find_path(os.B_APP_IMAGE_SYMBOL, os.path_base_directory.B_FIND_IMAGE_PATH, null, out_buffer.ptr, out_buffer.len) != 0) | ||
| 3021 | return error.Overflow; | ||
| 3022 | return mem.sliceTo(out_buffer, 0); | ||
| 3023 | }, | ||
| 3024 | .openbsd => { | ||
| 3025 | // OpenBSD doesn't support getting the path of a running process, so try to guess it | 3017 | // OpenBSD doesn't support getting the path of a running process, so try to guess it |
| 3026 | if (os.argv.len == 0) | 3018 | if (os.argv.len == 0) |
| 3027 | return error.FileNotFound; | 3019 | return error.FileNotFound; |
| ... | @@ -3120,7 +3112,7 @@ const CopyFileRawError = error{SystemResources} || os.CopyFileRangeError || os.S | ... | @@ -3120,7 +3112,7 @@ const CopyFileRawError = error{SystemResources} || os.CopyFileRangeError || os.S |
| 3120 | // No metadata is transferred over. | 3112 | // No metadata is transferred over. |
| 3121 | fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t, maybe_size: ?u64) CopyFileRawError!void { | 3113 | fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t, maybe_size: ?u64) CopyFileRawError!void { |
| 3122 | if (comptime builtin.target.isDarwin()) { | 3114 | if (comptime builtin.target.isDarwin()) { |
| 3123 | const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE.DATA); | 3115 | const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA); |
| 3124 | switch (os.errno(rc)) { | 3116 | switch (os.errno(rc)) { |
| 3125 | .SUCCESS => return, | 3117 | .SUCCESS => return, |
| 3126 | .INVAL => unreachable, | 3118 | .INVAL => unreachable, |
lib/std/os.zig+21-79| ... | @@ -146,12 +146,7 @@ pub const addrinfo = system.addrinfo; | ... | @@ -146,12 +146,7 @@ pub const addrinfo = system.addrinfo; |
| 146 | pub const blkcnt_t = system.blkcnt_t; | 146 | pub const blkcnt_t = system.blkcnt_t; |
| 147 | pub const blksize_t = system.blksize_t; | 147 | pub const blksize_t = system.blksize_t; |
| 148 | pub const clock_t = system.clock_t; | 148 | pub const clock_t = system.clock_t; |
| 149 | pub const cpu_set_t = if (builtin.os.tag == .linux) | 149 | pub const cpu_set_t = system.cpu_set_t; |
| 150 | system.cpu_set_t | ||
| 151 | else if (builtin.os.tag == .freebsd) | ||
| 152 | freebsd.cpuset_t | ||
| 153 | else | ||
| 154 | u32; | ||
| 155 | pub const dev_t = system.dev_t; | 150 | pub const dev_t = system.dev_t; |
| 156 | pub const dl_phdr_info = system.dl_phdr_info; | 151 | pub const dl_phdr_info = system.dl_phdr_info; |
| 157 | pub const empty_sigset = system.empty_sigset; | 152 | pub const empty_sigset = system.empty_sigset; |
| ... | @@ -517,18 +512,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void { | ... | @@ -517,18 +512,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void { |
| 517 | return; | 512 | return; |
| 518 | } | 513 | } |
| 519 | switch (builtin.os.tag) { | 514 | switch (builtin.os.tag) { |
| 520 | .macos, .ios => { | 515 | .netbsd, .openbsd, .macos, .ios, .tvos, .watchos => { |
| 521 | const rc = darwin.CCRandomGenerateBytes(buffer.ptr, buffer.len); | ||
| 522 | if (rc != darwin.CCRNGStatus.kCCSuccess) { | ||
| 523 | if (rc == darwin.CCRNGStatus.kCCParamError or rc == darwin.CCRNGStatus.kCCBufferTooSmall) { | ||
| 524 | return error.InvalidHandle; | ||
| 525 | } else { | ||
| 526 | return error.SystemResources; | ||
| 527 | } | ||
| 528 | } | ||
| 529 | return; | ||
| 530 | }, | ||
| 531 | .netbsd, .openbsd, .tvos, .watchos => { | ||
| 532 | system.arc4random_buf(buffer.ptr, buffer.len); | 516 | system.arc4random_buf(buffer.ptr, buffer.len); |
| 533 | return; | 517 | return; |
| 534 | }, | 518 | }, |
| ... | @@ -1001,7 +985,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { | ... | @@ -1001,7 +985,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { |
| 1001 | if (have_pread_but_not_preadv) { | 985 | if (have_pread_but_not_preadv) { |
| 1002 | // We could loop here; but proper usage of `preadv` must handle partial reads anyway. | 986 | // We could loop here; but proper usage of `preadv` must handle partial reads anyway. |
| 1003 | // So we simply read into the first vector only. | 987 | // So we simply read into the first vector only. |
| 1004 | if (iov.len == 0) return @as(usize, @intCast(0)); | 988 | if (iov.len == 0) return 0; |
| 1005 | const first = iov[0]; | 989 | const first = iov[0]; |
| 1006 | return pread(fd, first.iov_base[0..first.iov_len], offset); | 990 | return pread(fd, first.iov_base[0..first.iov_len], offset); |
| 1007 | } | 991 | } |
| ... | @@ -4707,8 +4691,11 @@ pub fn sysctl( | ... | @@ -4707,8 +4691,11 @@ pub fn sysctl( |
| 4707 | newp: ?*anyopaque, | 4691 | newp: ?*anyopaque, |
| 4708 | newlen: usize, | 4692 | newlen: usize, |
| 4709 | ) SysCtlError!void { | 4693 | ) SysCtlError!void { |
| 4710 | if (builtin.os.tag == .wasi or builtin.os.tag == .haiku) { | 4694 | if (builtin.os.tag == .wasi) { |
| 4711 | @compileError("unsupported OS"); | 4695 | @panic("unsupported"); // TODO should be compile error, not panic |
| 4696 | } | ||
| 4697 | if (builtin.os.tag == .haiku) { | ||
| 4698 | @panic("unsupported"); // TODO should be compile error, not panic | ||
| 4712 | } | 4699 | } |
| 4713 | 4700 | ||
| 4714 | const name_len = math.cast(c_uint, name.len) orelse return error.NameTooLong; | 4701 | const name_len = math.cast(c_uint, name.len) orelse return error.NameTooLong; |
| ... | @@ -4729,8 +4716,11 @@ pub fn sysctlbynameZ( | ... | @@ -4729,8 +4716,11 @@ pub fn sysctlbynameZ( |
| 4729 | newp: ?*anyopaque, | 4716 | newp: ?*anyopaque, |
| 4730 | newlen: usize, | 4717 | newlen: usize, |
| 4731 | ) SysCtlError!void { | 4718 | ) SysCtlError!void { |
| 4732 | if (builtin.os.tag == .wasi or builtin.os.tag == .haiku) { | 4719 | if (builtin.os.tag == .wasi) { |
| 4733 | @compileError("unsupported OS"); | 4720 | @panic("unsupported"); // TODO should be compile error, not panic |
| 4721 | } | ||
| 4722 | if (builtin.os.tag == .haiku) { | ||
| 4723 | @panic("unsupported"); // TODO should be compile error, not panic | ||
| 4734 | } | 4724 | } |
| 4735 | 4725 | ||
| 4736 | switch (errno(system.sysctlbyname(name, oldp, oldlenp, newp, newlen))) { | 4726 | switch (errno(system.sysctlbyname(name, oldp, oldlenp, newp, newlen))) { |
| ... | @@ -5494,64 +5484,16 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { | ... | @@ -5494,64 +5484,16 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { |
| 5494 | } | 5484 | } |
| 5495 | 5485 | ||
| 5496 | pub const SchedGetAffinityError = error{PermissionDenied} || UnexpectedError; | 5486 | pub const SchedGetAffinityError = error{PermissionDenied} || UnexpectedError; |
| 5497 | pub const SchedSetAffinityError = error{ InvalidCpu, PermissionDenied } || UnexpectedError; | ||
| 5498 | 5487 | ||
| 5499 | pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t { | 5488 | pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t { |
| 5500 | var set: cpu_set_t = undefined; | 5489 | var set: cpu_set_t = undefined; |
| 5501 | if (builtin.os.tag == .linux) { | 5490 | switch (errno(system.sched_getaffinity(pid, @sizeOf(cpu_set_t), &set))) { |
| 5502 | switch (errno(system.sched_getaffinity(pid, @sizeOf(cpu_set_t), &set))) { | 5491 | .SUCCESS => return set, |
| 5503 | .SUCCESS => return set, | 5492 | .FAULT => unreachable, |
| 5504 | .FAULT => unreachable, | 5493 | .INVAL => unreachable, |
| 5505 | .INVAL => unreachable, | 5494 | .SRCH => unreachable, |
| 5506 | .SRCH => unreachable, | 5495 | .PERM => return error.PermissionDenied, |
| 5507 | .PERM => return error.PermissionDenied, | 5496 | else => |err| return unexpectedErrno(err), |
| 5508 | else => |err| return unexpectedErrno(err), | ||
| 5509 | } | ||
| 5510 | } else if (builtin.os.tag == .freebsd) { | ||
| 5511 | switch (errno(freebsd.cpuset_getaffinity(freebsd.CPU_LEVEL_WHICH, freebsd.CPU_WHICH_PID, pid, @sizeOf(cpu_set_t), &set))) { | ||
| 5512 | .SUCCESS => return set, | ||
| 5513 | .FAULT => unreachable, | ||
| 5514 | .INVAL => unreachable, | ||
| 5515 | .SRCH => unreachable, | ||
| 5516 | .EDEADLK => unreachable, | ||
| 5517 | .PERM => return error.PermissionDenied, | ||
| 5518 | else => |err| return unexpectedErrno(err), | ||
| 5519 | } | ||
| 5520 | } else { | ||
| 5521 | @compileError("unsupported platform"); | ||
| 5522 | } | ||
| 5523 | } | ||
| 5524 | |||
| 5525 | pub fn sched_setaffinity(pid: pid_t, cpus: []usize) SchedSetAffinityError!cpu_set_t { | ||
| 5526 | var set: cpu_set_t = undefined; | ||
| 5527 | if (builtin.os.tag == .linux) { | ||
| 5528 | system.CPU_ZERO(&set); | ||
| 5529 | for (cpus) |cpu| { | ||
| 5530 | system.CPU_SET(cpu, &set); | ||
| 5531 | } | ||
| 5532 | switch (errno(system.sched_setaffinity(pid, @sizeOf(cpu_set_t), &set))) { | ||
| 5533 | .SUCCESS => return set, | ||
| 5534 | .FAULT => unreachable, | ||
| 5535 | .SRCH => unreachable, | ||
| 5536 | .INVAL => return error.InvalidCpu, | ||
| 5537 | .PERM => return error.PermissionDenied, | ||
| 5538 | else => |err| return unexpectedErrno(err), | ||
| 5539 | } | ||
| 5540 | } else if (builtin.os.tag == .freebsd) { | ||
| 5541 | freebsd.CPU_ZERO(&set); | ||
| 5542 | for (cpus) |cpu| { | ||
| 5543 | freebsd.CPU_SET(cpu, &set); | ||
| 5544 | } | ||
| 5545 | switch (errno(freebsd.cpuset_setaffinity(freebsd.CPU_LEVEL_WHICH, freebsd.CPU_WHICH_PID, pid, @sizeOf(cpu_set_t), &set))) { | ||
| 5546 | .SUCCESS => return set, | ||
| 5547 | .FAULT => unreachable, | ||
| 5548 | .SRCH => unreachable, | ||
| 5549 | .INVAL => return error.InvalidCpu, | ||
| 5550 | .PERM => return error.PermissionDenied, | ||
| 5551 | else => |err| return unexpectedErrno(err), | ||
| 5552 | } | ||
| 5553 | } else { | ||
| 5554 | @compileError("unsupported platform"); | ||
| 5555 | } | 5497 | } |
| 5556 | } | 5498 | } |
| 5557 | 5499 | ||
| ... | @@ -5695,7 +5637,7 @@ pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 { | ... | @@ -5695,7 +5637,7 @@ pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 { |
| 5695 | else => |err| return unexpectedErrno(err), | 5637 | else => |err| return unexpectedErrno(err), |
| 5696 | } | 5638 | } |
| 5697 | } | 5639 | } |
| 5698 | if (builtin.os.tag == .linux or builtin.os.tag == .macos or builtin.os.tag == .freebsd) { | 5640 | if (builtin.os.tag == .linux) { |
| 5699 | const uts = uname(); | 5641 | const uts = uname(); |
| 5700 | const hostname = mem.sliceTo(&uts.nodename, 0); | 5642 | const hostname = mem.sliceTo(&uts.nodename, 0); |
| 5701 | const result = name_buffer[0..hostname.len]; | 5643 | const result = name_buffer[0..hostname.len]; |
lib/std/os/linux.zig-90| ... | @@ -1520,28 +1520,6 @@ pub fn sched_getaffinity(pid: pid_t, size: usize, set: *cpu_set_t) usize { | ... | @@ -1520,28 +1520,6 @@ pub fn sched_getaffinity(pid: pid_t, size: usize, set: *cpu_set_t) usize { |
| 1520 | return 0; | 1520 | return 0; |
| 1521 | } | 1521 | } |
| 1522 | 1522 | ||
| 1523 | pub fn getcpu(cpu: *u32, node: *u32) usize { | ||
| 1524 | return syscall3(.getcpu, @intFromPtr(cpu), @intFromPtr(node), 0); | ||
| 1525 | } | ||
| 1526 | |||
| 1527 | pub fn sched_getcpu() usize { | ||
| 1528 | var cpu: u32 = undefined; | ||
| 1529 | const rc = syscall3(.getcpu, @intFromPtr(&cpu), 0, 0); | ||
| 1530 | if (@as(isize, @bitCast(rc)) < 0) return rc; | ||
| 1531 | return @as(usize, @intCast(cpu)); | ||
| 1532 | } | ||
| 1533 | |||
| 1534 | /// libc has no wrapper for this syscall | ||
| 1535 | pub fn mbind(addr: ?*anyopaque, len: u32, mode: i32, nodemask: *const u32, maxnode: u32, flags: u32) usize { | ||
| 1536 | return syscall6(.mbind, @intFromPtr(addr), len, @as(usize, @bitCast(@as(isize, mode))), @intFromPtr(nodemask), maxnode, flags); | ||
| 1537 | } | ||
| 1538 | |||
| 1539 | pub fn sched_setaffinity(pid: pid_t, size: usize, set: *const cpu_set_t) usize { | ||
| 1540 | const rc = syscall3(.sched_setaffinity, @as(usize, @bitCast(@as(isize, pid))), size, @intFromPtr(set)); | ||
| 1541 | if (@as(isize, @bitCast(rc)) < 0) return rc; | ||
| 1542 | return 0; | ||
| 1543 | } | ||
| 1544 | |||
| 1545 | pub fn epoll_create() usize { | 1523 | pub fn epoll_create() usize { |
| 1546 | return epoll_create1(0); | 1524 | return epoll_create1(0); |
| 1547 | } | 1525 | } |
| ... | @@ -1591,43 +1569,6 @@ pub fn timerfd_settime(fd: i32, flags: u32, new_value: *const itimerspec, old_va | ... | @@ -1591,43 +1569,6 @@ pub fn timerfd_settime(fd: i32, flags: u32, new_value: *const itimerspec, old_va |
| 1591 | return syscall4(.timerfd_settime, @as(usize, @bitCast(@as(isize, fd))), flags, @intFromPtr(new_value), @intFromPtr(old_value)); | 1569 | return syscall4(.timerfd_settime, @as(usize, @bitCast(@as(isize, fd))), flags, @intFromPtr(new_value), @intFromPtr(old_value)); |
| 1592 | } | 1570 | } |
| 1593 | 1571 | ||
| 1594 | pub const sigevent = extern struct { | ||
| 1595 | value: sigval, | ||
| 1596 | signo: i32, | ||
| 1597 | inotify: i32, | ||
| 1598 | libc_priv_impl: opaque {}, | ||
| 1599 | }; | ||
| 1600 | |||
| 1601 | // Flags for sigevent sigev_inotify's field | ||
| 1602 | pub const SIGEV = enum(i32) { | ||
| 1603 | NONE = 0, | ||
| 1604 | SIGNAL = 1, | ||
| 1605 | THREAD = 2, | ||
| 1606 | THREAD_ID = 4, | ||
| 1607 | }; | ||
| 1608 | |||
| 1609 | pub const timer_t = ?*anyopaque; | ||
| 1610 | |||
| 1611 | pub fn timer_create(clockid: i32, sevp: *sigevent, timerid: *timer_t) usize { | ||
| 1612 | var t: timer_t = undefined; | ||
| 1613 | const rc = syscall3(.timer_create, @as(usize, @bitCast(@as(isize, clockid))), @intFromPtr(sevp), @intFromPtr(&t)); | ||
| 1614 | if (@as(isize, @bitCast(rc)) < 0) return rc; | ||
| 1615 | timerid.* = t; | ||
| 1616 | return rc; | ||
| 1617 | } | ||
| 1618 | |||
| 1619 | pub fn timer_delete(timerid: timer_t) usize { | ||
| 1620 | return syscall1(.timer_delete, timerid); | ||
| 1621 | } | ||
| 1622 | |||
| 1623 | pub fn timer_gettime(timerid: timer_t, curr_value: *itimerspec) usize { | ||
| 1624 | return syscall2(.timer_gettime, @intFromPtr(timerid), @intFromPtr(curr_value)); | ||
| 1625 | } | ||
| 1626 | |||
| 1627 | pub fn timer_settime(timerid: timer_t, flags: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize { | ||
| 1628 | return syscall4(.timer_settime, @intFromPtr(timerid), @as(usize, @bitCast(@as(isize, flags))), @intFromPtr(new_value), @intFromPtr(old_value)); | ||
| 1629 | } | ||
| 1630 | |||
| 1631 | // Flags for the 'setitimer' system call | 1572 | // Flags for the 'setitimer' system call |
| 1632 | pub const ITIMER = enum(i32) { | 1573 | pub const ITIMER = enum(i32) { |
| 1633 | REAL = 0, | 1574 | REAL = 0, |
| ... | @@ -3597,11 +3538,6 @@ pub const CPU_SETSIZE = 128; | ... | @@ -3597,11 +3538,6 @@ pub const CPU_SETSIZE = 128; |
| 3597 | pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; | 3538 | pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; |
| 3598 | pub const cpu_count_t = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8)); | 3539 | pub const cpu_count_t = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8)); |
| 3599 | 3540 | ||
| 3600 | fn cpu_mask(s: usize) cpu_count_t { | ||
| 3601 | var x = s & (CPU_SETSIZE * 8); | ||
| 3602 | return @as(cpu_count_t, @intCast(1)) << @as(u4, @intCast(x)); | ||
| 3603 | } | ||
| 3604 | |||
| 3605 | pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { | 3541 | pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { |
| 3606 | var sum: cpu_count_t = 0; | 3542 | var sum: cpu_count_t = 0; |
| 3607 | for (set) |x| { | 3543 | for (set) |x| { |
| ... | @@ -3610,32 +3546,6 @@ pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { | ... | @@ -3610,32 +3546,6 @@ pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { |
| 3610 | return sum; | 3546 | return sum; |
| 3611 | } | 3547 | } |
| 3612 | 3548 | ||
| 3613 | pub fn CPU_ZERO(set: *cpu_set_t) void { | ||
| 3614 | @memset(set, 0); | ||
| 3615 | } | ||
| 3616 | |||
| 3617 | pub fn CPU_SET(cpu: usize, set: *cpu_set_t) void { | ||
| 3618 | const x = cpu / @sizeOf(usize); | ||
| 3619 | if (x < @sizeOf(cpu_set_t)) { | ||
| 3620 | (set.*)[x] |= cpu_mask(x); | ||
| 3621 | } | ||
| 3622 | } | ||
| 3623 | |||
| 3624 | pub fn CPU_ISSET(cpu: usize, set: cpu_set_t) bool { | ||
| 3625 | const x = cpu / @sizeOf(usize); | ||
| 3626 | if (x < @sizeOf(cpu_set_t)) { | ||
| 3627 | return set[x] & cpu_mask(x) != 0; | ||
| 3628 | } | ||
| 3629 | return false; | ||
| 3630 | } | ||
| 3631 | |||
| 3632 | pub fn CPU_CLR(cpu: usize, set: *cpu_set_t) void { | ||
| 3633 | const x = cpu / @sizeOf(usize); | ||
| 3634 | if (x < @sizeOf(cpu_set_t)) { | ||
| 3635 | (set.*)[x] &= !cpu_mask(x); | ||
| 3636 | } | ||
| 3637 | } | ||
| 3638 | |||
| 3639 | pub const MINSIGSTKSZ = switch (native_arch) { | 3549 | pub const MINSIGSTKSZ = switch (native_arch) { |
| 3640 | .x86, .x86_64, .arm, .mipsel => 2048, | 3550 | .x86, .x86_64, .arm, .mipsel => 2048, |
| 3641 | .aarch64 => 5120, | 3551 | .aarch64 => 5120, |
lib/std/process.zig+3-8| ... | @@ -1163,17 +1163,12 @@ pub fn totalSystemMemory() TotalSystemMemoryError!usize { | ... | @@ -1163,17 +1163,12 @@ pub fn totalSystemMemory() TotalSystemMemoryError!usize { |
| 1163 | .linux => { | 1163 | .linux => { |
| 1164 | return totalSystemMemoryLinux() catch return error.UnknownTotalSystemMemory; | 1164 | return totalSystemMemoryLinux() catch return error.UnknownTotalSystemMemory; |
| 1165 | }, | 1165 | }, |
| 1166 | .freebsd, .netbsd, .dragonfly, .macos => { | 1166 | .freebsd => { |
| 1167 | var physmem: c_ulong = undefined; | 1167 | var physmem: c_ulong = undefined; |
| 1168 | var len: usize = @sizeOf(c_ulong); | 1168 | var len: usize = @sizeOf(c_ulong); |
| 1169 | const name = switch (builtin.os.tag) { | 1169 | os.sysctlbynameZ("hw.physmem", &physmem, &len, null, 0) catch |err| switch (err) { |
| 1170 | .macos => "hw.memsize", | ||
| 1171 | .netbsd => "hw.physmem64", | ||
| 1172 | else => "hw.physmem", | ||
| 1173 | }; | ||
| 1174 | os.sysctlbynameZ(name, &physmem, &len, null, 0) catch |err| switch (err) { | ||
| 1175 | error.NameTooLong, error.UnknownName => unreachable, | 1170 | error.NameTooLong, error.UnknownName => unreachable, |
| 1176 | else => return error.UnknownTotalSystemMemory, | 1171 | else => |e| return e, |
| 1177 | }; | 1172 | }; |
| 1178 | return @as(usize, @intCast(physmem)); | 1173 | return @as(usize, @intCast(physmem)); |
| 1179 | }, | 1174 | }, |