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_ATTR_SETAFFINITY_NP 114 int pthread_attr_setaffinity_np(pthread_attr_t *attr,
115 size_t cpusetsize,
const cpu_set_t *cpuset)
117 if (CPU_ISSET(0, cpuset) && CPU_COUNT(cpuset) == 1)
123 #ifndef HAVE_PTHREAD_SETAFFINITY_NP 125 int pthread_setaffinity_np(pthread_t thread,
size_t cpusetsize,
126 const cpu_set_t *cpuset)
128 if (CPU_ISSET(0, cpuset) && CPU_COUNT(cpuset) == 1)
134 #if !defined(HAVE_CLOCK_NANOSLEEP) && defined(CONFIG_XENO_MERCURY) 142 const struct timespec *request,
143 struct timespec *remain)
145 struct timespec now, tmp;
150 tmp.tv_sec -= now.tv_sec;
151 tmp.tv_nsec -= now.tv_nsec;
152 if (tmp.tv_nsec < 0) {
154 tmp.tv_nsec += 1000000000;
162 #ifndef HAVE_SCHED_GETCPU 167 __weak
int sched_getcpu(
void)
173 #ifndef HAVE_SHM_OPEN 174 __weak
int shm_open(
const char *name,
int oflag, mode_t mode)
181 #ifndef HAVE_SHM_UNLINK 182 __weak
int shm_unlink(
const char *name)
189 #ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP 190 #define pthread_mutexattr_setrobust_np(__attr, __robust) \ 194 #if !defined(HAVE_PTHREAD_SETNAME_NP) && defined(CONFIG_XENO_MERCURY) 204 #if defined(__COBALT_WRAP__) || defined(__IN_XENO__) 210 #ifndef HAVE_CLOCK_NANOSLEEP 212 const struct timespec *request,
213 struct timespec *remain);
216 #ifndef HAVE_PTHREAD_SETNAME_NP 221 #ifndef PTHREAD_STACK_DEFAULT 222 #define PTHREAD_STACK_DEFAULT \ 224 int __ret = PTHREAD_STACK_MIN; \ 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:448
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:335
int clock_gettime(clockid_t clock_id, struct timespec *tp)
Read the specified clock.
Definition: clock.c:181
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
Sleep some amount of time.
Definition: clock.c:291