shithub: npe

ref: 90023a5672f380bcb343528a63e1c1df441387c2
dir: /libnpe_pthread/pthread_once.c/

View raw version
#include <npe.h>
#include <pthread.h>
#include "_pthread.h"

enum {
	Done = 13666,
};

int
pthread_once(pthread_once_t *once, void (*init_routine)(void))
{
	if(once->done != Done){
		qlock(once);
		if(once->done != Done){
			once->done = Done;
			init_routine();
		}
		qunlock(once);
	}

	return 0;
}