18 #ifndef _BOILERPLATE_LIBC_H 19 #define _BOILERPLATE_LIBC_H 30 #include <xeno_config.h> 32 #include <boilerplate/compiler.h> 34 #if !HAVE_DECL_PTHREAD_PRIO_NONE 43 static inline int fork(
void)
50 #ifndef HAVE_PTHREAD_ATFORK 53 int pthread_atfork(
void (*prepare)(
void),
void (*parent)(
void),
59 #error "fork() without pthread_atfork()" 63 #ifndef HAVE_PTHREAD_GETATTR_NP 65 int pthread_getattr_np(pthread_t th, pthread_attr_t *attr)
71 #ifndef HAVE_PTHREAD_CONDATTR_SETCLOCK 76 return clock_id == CLOCK_REALTIME ? 0 : ENOSYS;
80 #ifndef HAVE_PTHREAD_CONDATTR_GETCLOCK 83 clockid_t *__restrict__ clock_id)
85 *clock_id = CLOCK_REALTIME;
91 #ifndef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL 96 return protocol == PTHREAD_PRIO_NONE ? 0 : ENOSYS;
100 #ifndef HAVE_PTHREAD_MUTEXATTR_GETPROTOCOL 103 __restrict__ attr,
int *__restrict__ protocol)
105 *protocol = PTHREAD_PRIO_NONE;
111 #ifndef HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING 113 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr,
120 #ifndef HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING 122 int pthread_mutexattr_getprioceiling(
const pthread_mutexattr_t *
124 int *__restrict prioceiling)
130 #ifndef HAVE_PTHREAD_MUTEX_SETPRIOCEILING 134 int *__restrict old_ceiling)
140 #ifndef HAVE_PTHREAD_MUTEX_GETPRIOCEILING 143 int *__restrict prioceiling)
149 #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP 152 int pthread_attr_setaffinity_np(pthread_attr_t *attr,
153 size_t cpusetsize,
const cpu_set_t *cpuset)
155 if (CPU_ISSET(0, cpuset) && CPU_COUNT(cpuset) == 1)
161 #ifndef HAVE_PTHREAD_SETAFFINITY_NP 163 int pthread_setaffinity_np(pthread_t thread,
size_t cpusetsize,
164 const cpu_set_t *cpuset)
166 if (CPU_ISSET(0, cpuset) && CPU_COUNT(cpuset) == 1)
172 #ifndef HAVE_PTHREAD_SETSCHEDPRIO 175 int pthread_setschedprio(pthread_t thread,
int prio)
177 struct sched_param param;
184 param.sched_priority = prio;
191 #if !defined(HAVE_CLOCK_NANOSLEEP) && defined(CONFIG_XENO_MERCURY) 199 const struct timespec *request,
200 struct timespec *remain)
202 struct timespec now, tmp;
207 tmp.tv_sec -= now.tv_sec;
208 tmp.tv_nsec -= now.tv_nsec;
209 if (tmp.tv_nsec < 0) {
211 tmp.tv_nsec += 1000000000;
219 #ifndef HAVE_SCHED_GETCPU 224 __weak
int sched_getcpu(
void)
230 #ifndef HAVE_SHM_OPEN 231 __weak
int shm_open(
const char *name,
int oflag, mode_t mode)
238 #ifndef HAVE_SHM_UNLINK 239 __weak
int shm_unlink(
const char *name)
246 #ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP 247 #define pthread_mutexattr_setrobust_np(__attr, __robust) \ 251 #if !defined(HAVE_PTHREAD_SETNAME_NP) && defined(CONFIG_XENO_MERCURY) 261 #if defined(__COBALT_WRAP__) || defined(__IN_XENO__) 267 #ifndef HAVE_CLOCK_NANOSLEEP 269 const struct timespec *request,
270 struct timespec *remain);
273 #ifndef HAVE_PTHREAD_SETNAME_NP 278 #ifndef PTHREAD_STACK_DEFAULT 279 #define PTHREAD_STACK_DEFAULT \ 281 int __ret = PTHREAD_STACK_MIN; \ int pthread_getschedparam(pthread_t thread, int *__restrict__ policy, struct sched_param *__restrict__ param)
Get the scheduling policy and parameters of the specified thread.
Definition: thread.c:738
int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clk_id)
Get the clock selection attribute from a condition variable attributes object.
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int proto)
Set the protocol attribute of a mutex attributes object.
int pthread_mutex_getprioceiling(pthread_mutex_t *__restrict mutex, int *__restrict old_ceiling)
Get a mutex's priority ceiling.
Definition: mutex.c:772
int pthread_setname_np(pthread_t thread, const char *name)
Set a thread name.
Definition: thread.c:408
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *proto)
Get the protocol attribute from a mutex attributes object.
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param)
Set the scheduling policy and parameters of the specified thread.
Definition: thread.c:548
int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clk_id)
Set the clock selection attribute of a condition variable attributes object.
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
Sleep some amount of time.
Definition: clock.c:356
int clock_gettime(clockid_t clock_id, struct timespec *tp)
Read the specified clock.
Definition: clock.c:183
int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict mutex, int prioceiling, int *__restrict old_ceiling)
Set a mutex's priority ceiling.
Definition: mutex.c:720
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
Sleep some amount of time.
Definition: clock.c:311