Commit ebf2a7e9b9

Sébastien Marie <semarie@online.fr>
2021-01-12 06:39:46
add pthread_key functions
1 parent 8ea2b40
Changed files (2)
lib/std/c/openbsd.zig
@@ -33,6 +33,7 @@ pub const pthread_spinlock_t = extern struct {
 pub const pthread_attr_t = extern struct {
     inner: ?*c_void = null,
 };
+pub const pthread_key_t = c_int;
 
 pub const sem_t = ?*opaque {};
 
lib/std/c.zig
@@ -271,6 +271,10 @@ pub extern "c" fn pthread_atfork(
     parent: ?fn () callconv(.C) void,
     child: ?fn () callconv(.C) void,
 ) c_int;
+pub extern "c" fn pthread_key_create(key: *pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) c_int;
+pub extern "c" fn pthread_key_delete(key: pthread_key_t) c_int;
+pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*c_void;
+pub extern "c" fn pthread_setspecific(key: pthread_key_t, value: ?*c_void) c_int;
 pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int;
 pub extern "c" fn sem_destroy(sem: *sem_t) c_int;
 pub extern "c" fn sem_post(sem: *sem_t) c_int;