18 #ifndef _BOILERPLATE_LIBC_H
19 #define _BOILERPLATE_LIBC_H
28 #include <xeno_config.h>
30 #include <boilerplate/compiler.h>
32 #if defined(__UCLIBC__) && !defined(UCLIBC_HAS_THREADS_NATIVE)
41 static inline int fork(
void)
48 #ifndef HAVE_PTHREAD_ATFORK
51 int pthread_atfork(
void (*prepare)(
void),
void (*parent)(
void),
57 #error "fork() without pthread_atfork()"
61 #ifndef HAVE_PTHREAD_GETATTR_NP
63 int pthread_getattr_np(pthread_t th, pthread_attr_t *attr)
69 #ifndef HAVE_PTHREAD_CONDATTR_SETCLOCK
74 return clock_id == CLOCK_REALTIME ? 0 : ENOSYS;
78 #ifndef HAVE_PTHREAD_CONDATTR_GETCLOCK
81 clockid_t *__restrict__ clock_id)
83 *clock_id = CLOCK_REALTIME;
89 #ifndef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
94 return protocol == PTHREAD_PRIO_NONE ? 0 : ENOSYS;
98 #ifndef HAVE_PTHREAD_MUTEXATTR_GETPROTOCOL
101 __restrict__ attr,
int *__restrict__ protocol)
103 *protocol = PTHREAD_PRIO_NONE;
109 #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP
112 int pthread_attr_setaffinity_np(pthread_attr_t *attr,
113 size_t cpusetsize,
const cpu_set_t *cpuset)
115 if (CPU_ISSET(0, cpuset) && CPU_COUNT(cpuset) == 1)
121 #if !defined(HAVE_CLOCK_NANOSLEEP) && defined(CONFIG_XENO_MERCURY)
129 const struct timespec *request,
130 struct timespec *remain)
132 struct timespec now, tmp;
137 tmp.tv_sec -= now.tv_sec;
138 tmp.tv_nsec -= now.tv_nsec;
139 if (tmp.tv_nsec < 0) {
141 tmp.tv_nsec += 1000000000;
153 const struct timespec *request,
154 struct timespec *remain);
157 #ifndef HAVE_SCHED_GETCPU
162 __weak
inline int sched_getcpu(
void)
168 #ifndef HAVE_SHM_OPEN
169 __weak
inline int shm_open(
const char *name,
int oflag, mode_t mode)
176 #ifndef HAVE_SHM_UNLINK
177 __weak
inline int shm_unlink(
const char *name)
184 #ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP
185 #define pthread_mutexattr_setrobust_np(__attr, __robust) \
189 #if !defined(HAVE_PTHREAD_SETNAME_NP) && defined(CONFIG_XENO_MERCURY)
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_setname_np(pthread_t thread, const char *name)
Set a thread name.
Definition: thread.c:439
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *proto)
Get the protocol attribute from a mutex attributes object.
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:330
int clock_gettime(clockid_t clock_id, struct timespec *tp)
Read the specified clock.
Definition: clock.c:179
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
Sleep some amount of time.
Definition: clock.c:287