more apple

master
leitner 9 months ago
parent 3003b1cfba
commit 962bcbd917

@ -1,6 +1,6 @@
#include "io.h" #include "io.h"
#include <stdio.h> #include <stdio.h>
#if defined(__dietlibc__) || defined(__linux__) #if !defined(PTHREAD) && (defined(__dietlibc__) || defined(__linux__))
#define THRD #define THRD
#include <threads.h> #include <threads.h>
#else #else
@ -33,6 +33,12 @@ int worker(void* arg) {
return 0; return 0;
} }
#ifndef THRD
void* workerwrapper(void* arg) {
return (void*)(uintptr_t)worker(arg);
}
#endif
int main() { int main() {
iom_init(&c); iom_init(&c);
if (iom_add(&c,0,IOM_READ)==-1) { if (iom_add(&c,0,IOM_READ)==-1) {
@ -50,7 +56,7 @@ int main() {
#ifdef THRD #ifdef THRD
if (thrd_create(&x[i],worker,(void*)(uintptr_t)i)==-1) if (thrd_create(&x[i],worker,(void*)(uintptr_t)i)==-1)
#else #else
if (pthread_create(&x[i],0,worker,(void*)(uintptr_t)i)==-1) if (pthread_create(&x[i],0,workerwrapper,(void*)(uintptr_t)i)==-1)
#endif #endif
{ {
perror("thrd_create"); perror("thrd_create");
@ -66,7 +72,8 @@ int main() {
#ifdef THRD #ifdef THRD
if (thrd_join(x[i],&r)==-1) if (thrd_join(x[i],&r)==-1)
#else #else
if (pthread_join(x[i],&r)==-1) void* tmp;
if (pthread_join(x[i],&tmp)==-1, r=(int)(uintptr_t)tmp)
#endif #endif
{ {
perror("thrd_join"); perror("thrd_join");

Loading…
Cancel
Save