shithub: npe

Download patch

ref: 56b539819f0062e370b9834f0e44afaf46a4018a
parent: 1791bae9029685d63bf022ae1cb06093dbce598e
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Mar 15 12:40:30 EDT 2025

pthread: define certain types in the public header (thanks zamfofex)

--- a/include/npe/pthread.h
+++ b/include/npe/pthread.h
@@ -3,6 +3,14 @@
 
 #pragma lib "libnpe_pthread.a"
 
+#ifndef nil
+#include <u.h>
+#endif
+#ifndef nelem
+#include <libc.h>
+#include <thread.h>
+#endif
+
 typedef struct pthread_attr_t pthread_attr_t;
 typedef struct pthread_cond_t pthread_cond_t;
 typedef struct pthread_mutex_t pthread_mutex_t;
@@ -10,11 +18,24 @@
 typedef uintptr pthread_t;
 
 #pragma incomplete pthread_attr_t
-#pragma incomplete pthread_cond_t
-#pragma incomplete pthread_mutex_t
-#pragma incomplete pthread_once_t
 
+struct pthread_cond_t {
+	Rendez;
+	QLock lock;
+};
+
+struct pthread_once_t {
+	QLock;
+	int done;
+};
+
+struct pthread_mutex_t {
+	QLock;
+};
+
+#define PTHREAD_COND_INITIALIZER {0}
 #define PTHREAD_ONCE_INIT {0}
+#define PTHREAD_MUTEX_INITIALIZER {0}
 
 int pthread_create(pthread_t *pt, pthread_attr_t *attr, void *(*f)(void *), void *arg);
 int pthread_join(pthread_t thread, void **retval);
--- a/libnpe_pthread/_pthread.h
+++ b/libnpe_pthread/_pthread.h
@@ -1,25 +1,9 @@
-#include <npe.h>
-#include <pthread.h>
-#include <thread.h>
+#include "pthread.h"
 
 typedef struct npe_pthread_t npe_pthread_t;
 
 struct pthread_attr_t {
 	unsigned stack_size;
-};
-
-struct pthread_cond_t {
-	Rendez;
-	QLock lock;
-};
-
-struct pthread_once_t {
-	QLock;
-	int done;
-};
-
-struct pthread_mutex_t {
-	QLock;
 };
 
 struct npe_pthread_t {
--