mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-16 03:17:00 +08:00
Add missing pthread_barrier_t.
Supply a simple implementation of the missing pthread_barrier_t type and functions, for macOS. Discussion: https://postgr.es/m/20200227180100.zyvjwzcpiokfsqm2%40alap3.anarazel.de
This commit is contained in:
@ -424,6 +424,9 @@
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#undef HAVE_PTHREAD
|
||||
|
||||
/* Define to 1 if you have the `pthread_barrier_wait' function. */
|
||||
#undef HAVE_PTHREAD_BARRIER_WAIT
|
||||
|
||||
/* Define to 1 if you have the `pthread_is_threaded_np' function. */
|
||||
#undef HAVE_PTHREAD_IS_THREADED_NP
|
||||
|
||||
|
||||
41
src/include/port/pg_pthread.h
Normal file
41
src/include/port/pg_pthread.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* Declarations for missing POSIX thread components.
|
||||
*
|
||||
* Currently this supplies an implementation of pthread_barrier_t for the
|
||||
* benefit of macOS, which lacks it. These declarations are not in port.h,
|
||||
* because that'd require <pthread.h> to be included by every translation
|
||||
* unit.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef PG_PTHREAD_H
|
||||
#define PG_PTHREAD_H
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#ifndef HAVE_PTHREAD_BARRIER_WAIT
|
||||
|
||||
#ifndef PTHREAD_BARRIER_SERIAL_THREAD
|
||||
#define PTHREAD_BARRIER_SERIAL_THREAD (-1)
|
||||
#endif
|
||||
|
||||
typedef struct pg_pthread_barrier
|
||||
{
|
||||
bool sense; /* we only need a one bit phase */
|
||||
int count; /* number of threads expected */
|
||||
int arrived; /* number of threads that have arrived */
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
} pthread_barrier_t;
|
||||
|
||||
extern int pthread_barrier_init(pthread_barrier_t *barrier,
|
||||
const void *attr,
|
||||
int count);
|
||||
extern int pthread_barrier_wait(pthread_barrier_t *barrier);
|
||||
extern int pthread_barrier_destroy(pthread_barrier_t *barrier);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user