Commit 3e467c778a

David CARLIER <devnexen@gmail.com>
2023-04-05 14:13:30
std: add os_log/signpost api (sort of linux's perf event equivalent) subset.
1 parent d92b5fc
Changed files (1)
lib
lib/std/c/darwin.zig
@@ -3814,3 +3814,35 @@ pub fn machTaskForPid(pid: std.os.pid_t) MachError!MachTask {
 pub fn machTaskForSelf() MachTask {
     return .{ .port = mach_task_self() };
 }
+
+pub const os_signpost_id_t = u64;
+
+pub const OS_SIGNPOST_ID_NULL: os_signpost_id_t = 0;
+pub const OS_SIGNPOST_ID_INVALID: os_signpost_id_t = !0;
+pub const OS_SIGNPOST_ID_EXCLUSIVE: os_signpost_id_t = 0xeeeeb0b5b2b2eeee;
+
+pub const os_log_t = opaque {};
+pub const os_log_type_t = enum(u8) {
+    /// default messages always captures
+    OS_LOG_TYPE_DEFAULT = 0x00,
+    /// messages with additional infos
+    OS_LOG_TYPE_INFO = 0x01,
+    /// debug messages
+    OS_LOG_TYPE_DEBUG = 0x02,
+    /// error messages
+    OS_LOG_TYPE_ERROR = 0x10,
+    /// unexpected conditions messages
+    OS_LOG_TYPE_FAULT = 0x11,
+};
+
+pub const OS_LOG_CATEGORY_POINTS_OF_INTEREST: *const u8 = "PointsOfInterest";
+pub const OS_LOG_CATEGORY_DYNAMIC_TRACING: *const u8 = "DynamicTracing";
+pub const OS_LOG_CATEGORY_DYNAMIC_STACK_TRACING: *const u8 = "DynamicStackTracing";
+
+pub extern "c" fn os_log_create(subsystem: [*]const u8, category: [*]const u8) os_log_t;
+pub extern "c" fn os_log_type_enabled(log: os_log_t, tpe: os_log_type_t) bool;
+pub extern "c" fn os_signpost_id_generate(log: os_log_t) os_signpost_id_t;
+pub extern "c" fn os_signpost_interval_begin(log: os_log_t, signpos: os_signpost_id_t, func: [*]const u8, ...) void;
+pub extern "c" fn os_signpost_interval_end(log: os_log_t, signpos: os_signpost_id_t, func: [*]const u8, ...) void;
+pub extern "c" fn os_signpost_id_make_with_pointer(log: os_log_t, ptr: ?*anyopaque) os_signpost_id_t;
+pub extern "c" fn os_signpost_enabled(log: os_log_t) bool;