Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
pg_pthread.h42 linesDownload Raw Back to port
1/*-------------------------------------------------------------------------2 *3 * Declarations for missing POSIX thread components.4 *5 *	  Currently this supplies an implementation of pthread_barrier_t for the6 *	  benefit of macOS, which lacks it.  These declarations are not in port.h,7 *	  because that'd require <pthread.h> to be included by every translation8 *	  unit.9 *10 *-------------------------------------------------------------------------11 */12 13#ifndef PG_PTHREAD_H14#define PG_PTHREAD_H15 16#include <pthread.h>17 18#ifndef HAVE_PTHREAD_BARRIER_WAIT19 20#ifndef PTHREAD_BARRIER_SERIAL_THREAD21#define PTHREAD_BARRIER_SERIAL_THREAD (-1)22#endif23 24typedef struct pg_pthread_barrier25{26	bool		sense;			/* we only need a one bit phase */27	int			count;			/* number of threads expected */28	int			arrived;		/* number of threads that have arrived */29	pthread_mutex_t mutex;30	pthread_cond_t cond;31} pthread_barrier_t;32 33extern int	pthread_barrier_init(pthread_barrier_t *barrier,34								 const void *attr,35								 int count);36extern int	pthread_barrier_wait(pthread_barrier_t *barrier);37extern int	pthread_barrier_destroy(pthread_barrier_t *barrier);38 39#endif40 41#endif42 
codekingpro/portable-devtools · Team Ai