data_type
large_stringclasses
3 values
source
large_stringclasses
29 values
code
large_stringlengths
98
49.4M
filepath
large_stringlengths
5
161
message
large_stringclasses
234 values
commit
large_stringclasses
234 values
subject
large_stringclasses
418 values
critique
large_stringlengths
101
1.26M
metadata
dict
source
musl
#include <wchar.h> wchar_t *wcsncpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n) { wchar_t *a = d; while (n && *s) n--, *d++ = *s++; wmemset(d, 0, n); return a; }
src/string/wcsncpy.c
null
null
null
null
null
source
musl
#include <wchar.h> size_t wcsnlen(const wchar_t *s, size_t n) { const wchar_t *z = wmemchr(s, 0, n); if (z) n = z-s; return n; }
src/string/wcsnlen.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcspbrk(const wchar_t *s, const wchar_t *b) { s += wcscspn(s, b); return *s ? (wchar_t *)s : NULL; }
src/string/wcspbrk.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcsrchr(const wchar_t *s, wchar_t c) { const wchar_t *p; for (p=s+wcslen(s); p>=s && *p!=c; p--); return p>=s ? (wchar_t *)p : 0; }
src/string/wcsrchr.c
null
null
null
null
null
source
musl
#include <wchar.h> size_t wcsspn(const wchar_t *s, const wchar_t *c) { const wchar_t *a; for (a=s; *s && wcschr(c, *s); s++); return s-a; }
src/string/wcsspn.c
null
null
null
null
null
source
musl
#include <wchar.h> #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) static wchar_t *twoway_wcsstr(const wchar_t *h, const wchar_t *n) { const wchar_t *z; size_t l, ip, jp, k, p, ms, p0, mem, mem0; /* Computing length of needle */ for (l=0; n[l] && h[l]; l++); if (n[l]) return 0; /* hit the ...
src/string/wcsstr.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcstok(wchar_t *restrict s, const wchar_t *restrict sep, wchar_t **restrict p) { if (!s && !(s = *p)) return NULL; s += wcsspn(s, sep); if (!*s) return *p = 0; *p = s + wcscspn(s, sep); if (**p) *(*p)++ = 0; else *p = 0; return s; }
src/string/wcstok.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcswcs(const wchar_t *haystack, const wchar_t *needle) { return wcsstr(haystack, needle); }
src/string/wcswcs.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n) { for (; n && *s != c; n--, s++); return n ? (wchar_t *)s : 0; }
src/string/wmemchr.c
null
null
null
null
null
source
musl
#include <wchar.h> int wmemcmp(const wchar_t *l, const wchar_t *r, size_t n) { for (; n && *l==*r; n--, l++, r++); return n ? (*l < *r ? -1 : *l > *r) : 0; }
src/string/wmemcmp.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wmemcpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n) { wchar_t *a = d; while (n--) *d++ = *s++; return a; }
src/string/wmemcpy.c
null
null
null
null
null
source
musl
#include <wchar.h> #include <stdint.h> wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n) { wchar_t *d0 = d; if (d == s) return d; if ((uintptr_t)d-(uintptr_t)s < n * sizeof *d) while (n--) d[n] = s[n]; else while (n--) *d++ = *s++; return d0; }
src/string/wmemmove.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wmemset(wchar_t *d, wchar_t c, size_t n) { wchar_t *ret = d; while (n--) *d++ = c; return ret; }
src/string/wmemset.c
null
null
null
null
null
source
musl
/* * memcpy - copy memory area * * Copyright (c) 2012-2020, Arm Limited. * SPDX-License-Identifier: MIT */ /* Assumptions: * * ARMv8-a, AArch64, unaligned accesses. * */ #define dstin x0 #define src x1 #define count x2 #define dst x3 #define srcend x4 #define dstend x5 #define A_l x6 #defin...
src/string/aarch64/memcpy.S
null
null
null
null
null
source
musl
/* * memset - fill memory with a constant byte * * Copyright (c) 2012-2020, Arm Limited. * SPDX-License-Identifier: MIT */ /* Assumptions: * * ARMv8-a, AArch64, Advanced SIMD, unaligned accesses. * */ #define dstin x0 #define val x1 #define valw w1 #define count x2 #define dst x3 #define dsten...
src/string/aarch64/memset.S
null
null
null
null
null
source
musl
.syntax unified .global __aeabi_memcpy8 .global __aeabi_memcpy4 .global __aeabi_memcpy .global __aeabi_memmove8 .global __aeabi_memmove4 .global __aeabi_memmove .type __aeabi_memcpy8,%function .type __aeabi_memcpy4,%function .type __aeabi_memcpy,%function .type __aeabi_memmove8,%function .type __aeabi_memmove4,%funct...
src/string/arm/__aeabi_memcpy.s
null
null
null
null
null
source
musl
.syntax unified .global __aeabi_memclr8 .global __aeabi_memclr4 .global __aeabi_memclr .global __aeabi_memset8 .global __aeabi_memset4 .global __aeabi_memset .type __aeabi_memclr8,%function .type __aeabi_memclr4,%function .type __aeabi_memclr,%function .type __aeabi_memset8,%function .type __aeabi_memset4,%function ....
src/string/arm/__aeabi_memset.s
null
null
null
null
null
source
musl
/* * Copyright (C) 2008 The Android Open Source Project * All rights reserved. * * are met: * notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. ...
src/string/arm/memcpy.S
null
null
null
null
null
source
musl
.global memcpy .global __memcpy_fwd .hidden __memcpy_fwd .type memcpy,@function memcpy: __memcpy_fwd: push %esi push %edi mov 12(%esp),%edi mov 16(%esp),%esi mov 20(%esp),%ecx mov %edi,%eax cmp $4,%ecx jc 1f test $3,%edi jz 1f 2: movsb dec %ecx test $3,%edi jnz 2b 1: mov %ecx,%edx shr $2,%ecx rep movsl ...
src/string/i386/memcpy.s
null
null
null
null
null
source
musl
.global memmove .type memmove,@function memmove: mov 4(%esp),%eax sub 8(%esp),%eax cmp 12(%esp),%eax .hidden __memcpy_fwd jae __memcpy_fwd push %esi push %edi mov 12(%esp),%edi mov 16(%esp),%esi mov 20(%esp),%ecx lea -1(%edi,%ecx),%edi lea -1(%esi,%ecx),%esi std rep movsb cld lea 1(%edi),%eax pop %edi ...
src/string/i386/memmove.s
null
null
null
null
null
source
musl
.global memset .type memset,@function memset: mov 12(%esp),%ecx cmp $62,%ecx ja 2f mov 8(%esp),%dl mov 4(%esp),%eax test %ecx,%ecx jz 1f mov %dl,%dh mov %dl,(%eax) mov %dl,-1(%eax,%ecx) cmp $2,%ecx jbe 1f mov %dx,1(%eax) mov %dx,(-1-2)(%eax,%ecx) cmp $6,%ecx jbe 1f shl $16,%edx mov 8(%esp),%dl m...
src/string/i386/memset.s
null
null
null
null
null
source
musl
.global memcpy .global __memcpy_fwd .hidden __memcpy_fwd .type memcpy,@function memcpy: __memcpy_fwd: mov %rdi,%rax cmp $8,%rdx jc 1f test $7,%edi jz 1f 2: movsb dec %rdx test $7,%edi jnz 2b 1: mov %rdx,%rcx shr $3,%rcx rep movsq and $7,%edx jz 1f 2: movsb dec %edx jnz 2b 1: ret
src/string/x86_64/memcpy.s
null
null
null
null
null
source
musl
.global memmove .type memmove,@function memmove: mov %rdi,%rax sub %rsi,%rax cmp %rdx,%rax .hidden __memcpy_fwd jae __memcpy_fwd mov %rdx,%rcx lea -1(%rdi,%rdx),%rdi lea -1(%rsi,%rdx),%rsi std rep movsb cld lea 1(%rdi),%rax ret
src/string/x86_64/memmove.s
null
null
null
null
null
source
musl
.global memset .type memset,@function memset: movzbq %sil,%rax mov $0x101010101010101,%r8 imul %r8,%rax cmp $126,%rdx ja 2f test %edx,%edx jz 1f mov %sil,(%rdi) mov %sil,-1(%rdi,%rdx) cmp $2,%edx jbe 1f mov %ax,1(%rdi) mov %ax,(-1-2)(%rdi,%rdx) cmp $6,%edx jbe 1f mov %eax,(1+2)(%rdi) mov %eax,(-1-...
src/string/x86_64/memset.s
null
null
null
null
null
source
musl
#include <time.h> #include <stdint.h> #include "pthread_impl.h" /* This assumes that a check for the template size has already been made */ char *__randname(char *template) { int i; struct timespec ts; unsigned long r; __clock_gettime(CLOCK_REALTIME, &ts); r = ts.tv_sec + ts.tv_nsec + __pthread_self()->tid * ...
src/temp/__randname.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdlib.h> #include <errno.h> #include <sys/stat.h> char *mkdtemp(char *template) { size_t l = strlen(template); int retries = 100; if (l<6 || memcmp(template+l-6, "XXXXXX", 6)) { errno = EINVAL; return 0; } do { __randname(template+l-6); if (!mkdir(template, 0700)) return t...
src/temp/mkdtemp.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <stdlib.h> int mkostemp(char *template, int flags) { return __mkostemps(template, 0, flags); }
src/temp/mkostemp.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> int __mkostemps(char *template, int len, int flags) { size_t l = strlen(template); if (l<6 || len>l-6 || memcmp(template+l-len-6, "XXXXXX", 6)) { errno = EINVAL; return -1; } flags -= flags & ...
src/temp/mkostemps.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <stdlib.h> int mkstemps(char *template, int len) { return __mkostemps(template, len, 0); }
src/temp/mkstemps.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <string.h> #include <stdlib.h> #include <errno.h> #include <sys/stat.h> char *mktemp(char *template) { size_t l = strlen(template); int retries = 100; struct stat st; if (l < 6 || memcmp(template+l-6, "XXXXXX", 6)) { errno = EINVAL; *template = 0; return template; } do { __...
src/temp/mktemp.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <termios.h> #include <sys/ioctl.h> speed_t cfgetospeed(const struct termios *tio) { return tio->c_cflag & CBAUD; } speed_t cfgetispeed(const struct termios *tio) { return (tio->c_cflag & CIBAUD) / (CIBAUD/CBAUD); }
src/termios/cfgetospeed.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <termios.h> void cfmakeraw(struct termios *t) { t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); t->c_oflag &= ~OPOST; t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); t->c_cflag &= ~(CSIZE|PARENB); t->c_cflag |= CS8; t->c_cc[VMIN] = 1; t->c_cc[VTIME] = 0; }
src/termios/cfmakeraw.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <termios.h> #include <sys/ioctl.h> #include <errno.h> int cfsetospeed(struct termios *tio, speed_t speed) { if (speed & ~CBAUD) { errno = EINVAL; return -1; } tio->c_cflag &= ~CBAUD; tio->c_cflag |= speed; return 0; } int cfsetispeed(struct termios *tio, speed_t speed) { if (spe...
src/termios/cfsetospeed.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <termios.h> #include <sys/ioctl.h> #include <errno.h> int cfsetspeed(struct termios *tio, speed_t speed) { int r = cfsetospeed(tio, speed); if (!r) cfsetispeed(tio, 0); return r; }
src/termios/cfsetspeed.c
null
null
null
null
null
source
musl
#include <termios.h> #include <sys/ioctl.h> #include "syscall.h" int tcdrain(int fd) { return syscall_cp(SYS_ioctl, fd, TCSBRK, 1); }
src/termios/tcdrain.c
null
null
null
null
null
source
musl
#include <termios.h> #include <sys/ioctl.h> int tcflow(int fd, int action) { return ioctl(fd, TCXONC, action); }
src/termios/tcflow.c
null
null
null
null
null
source
musl
#include <termios.h> #include <sys/ioctl.h> int tcflush(int fd, int queue) { return ioctl(fd, TCFLSH, queue); }
src/termios/tcflush.c
null
null
null
null
null
source
musl
#include <termios.h> #include <sys/ioctl.h> int tcgetattr(int fd, struct termios *tio) { if (ioctl(fd, TCGETS, tio)) return -1; return 0; }
src/termios/tcgetattr.c
null
null
null
null
null
source
musl
#include <termios.h> #include <sys/ioctl.h> pid_t tcgetsid(int fd) { int sid; if (ioctl(fd, TIOCGSID, &sid) < 0) return -1; return sid; }
src/termios/tcgetsid.c
null
null
null
null
null
source
musl
#include <termios.h> #include <sys/ioctl.h> #include "syscall.h" int tcgetwinsize(int fd, struct winsize *wsz) { return syscall(SYS_ioctl, fd, TIOCGWINSZ, wsz); }
src/termios/tcgetwinsize.c
null
null
null
null
null
source
musl
#include <termios.h> #include <sys/ioctl.h> int tcsendbreak(int fd, int dur) { /* nonzero duration is implementation-defined, so ignore it */ return ioctl(fd, TCSBRK, 0); }
src/termios/tcsendbreak.c
null
null
null
null
null
source
musl
#include <termios.h> #include <sys/ioctl.h> #include <errno.h> int tcsetattr(int fd, int act, const struct termios *tio) { if (act < 0 || act > 2) { errno = EINVAL; return -1; } return ioctl(fd, TCSETS+act, tio); }
src/termios/tcsetattr.c
null
null
null
null
null
source
musl
#include <termios.h> #include <sys/ioctl.h> #include "syscall.h" int tcsetwinsize(int fd, const struct winsize *wsz) { return syscall(SYS_ioctl, fd, TIOCSWINSZ, wsz); }
src/termios/tcsetwinsize.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" /* This lock primitive combines a flag (in the sign bit) and a * congestion count (= threads inside the critical section, CS) in a * single int that is accessed through atomic operations. The states * of the int for value x are: * * x == 0: unlocked and no thread inside the critical sect...
src/thread/__lock.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int __set_thread_area(void *p) { #ifdef SYS_set_thread_area return __syscall(SYS_set_thread_area, p); #else return -ENOSYS; #endif }
src/thread/__set_thread_area.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" #include "syscall.h" hidden long __syscall_cp_c(); static long sccp(syscall_arg_t nr, syscall_arg_t u, syscall_arg_t v, syscall_arg_t w, syscall_arg_t x, syscall_arg_t y, syscall_arg_t z) { return __syscall(nr, u, v, w, x, y, z); } weak_alias(sccp, __sysca...
src/thread/__syscall_cp.c
null
null
null
null
null
source
musl
#include <pthread.h> #include <time.h> #include <errno.h> #include "futex.h" #include "syscall.h" #include "pthread_impl.h" #define IS32BIT(x) !((x)+0x80000000ULL>>32) #define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) static int __futex4_cp(volatile void *addr, int op, int val, const struct time...
src/thread/__timedwait.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" void *__tls_get_addr(tls_mod_off_t *v) { pthread_t self = __pthread_self(); return (void *)(self->dtv[v[0]] + v[1]); }
src/thread/__tls_get_addr.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" #include "atomic.h" #include "syscall.h" /* cheat and reuse CRTJMP macro from dynlink code */ #include "dynlink.h" static void *unmap_base; static size_t unmap_size; static char shared_stack[256]; static void do_unmap() { __syscall(SYS_munmap, unmap_base, unmap_size); __syscall(SYS_exit); ...
src/thread/__unmapself.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" void __wait(volatile int *addr, volatile int *waiters, int val, int priv) { int spins=100; if (priv) priv = FUTEX_PRIVATE; while (spins-- && (!waiters || !*waiters)) { if (*addr==val) a_spin(); else return; } if (waiters) a_inc(waiters); while (*addr==val) { __syscall(SYS_futex, a...
src/thread/__wait.c
null
null
null
null
null
source
musl
#include <threads.h> #include <pthread.h> void call_once(once_flag *flag, void (*func)(void)) { __pthread_once(flag, func); }
src/thread/call_once.c
null
null
null
null
null
source
musl
#include <errno.h> #include "pthread_impl.h" int __clone(int (*func)(void *), void *stack, int flags, void *arg, ...) { return -ENOSYS; }
src/thread/clone.c
null
null
null
null
null
source
musl
#include <threads.h> #include <pthread.h> int cnd_broadcast(cnd_t *c) { /* This internal function never fails, and always returns zero, * which matches the value thrd_success is defined with. */ return __private_cond_signal((pthread_cond_t *)c, -1); }
src/thread/cnd_broadcast.c
null
null
null
null
null
source
musl
#include <threads.h> #include <pthread.h> int cnd_signal(cnd_t *c) { /* This internal function never fails, and always returns zero, * which matches the value thrd_success is defined with. */ return __private_cond_signal((pthread_cond_t *)c, 1); }
src/thread/cnd_signal.c
null
null
null
null
null
source
musl
#include <threads.h> #include <pthread.h> #include <errno.h> int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts) { int ret = __pthread_cond_timedwait((pthread_cond_t *)c, (pthread_mutex_t *)m, ts); switch (ret) { /* May also return EINVAL or EPERM. */ default: return ...
src/thread/cnd_timedwait.c
null
null
null
null
null
source
musl
#include <threads.h> int cnd_wait(cnd_t *c, mtx_t *m) { /* Calling cnd_timedwait with a null pointer is an extension. * It is convenient here to avoid duplication of the logic * for return values. */ return cnd_timedwait(c, m, 0); }
src/thread/cnd_wait.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" unsigned __default_stacksize = DEFAULT_STACK_SIZE; unsigned __default_guardsize = DEFAULT_GUARD_SIZE;
src/thread/default_attr.c
null
null
null
null
null
source
musl
#include <pthread.h> static pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; void __inhibit_ptc() { pthread_rwlock_wrlock(&lock); } void __acquire_ptc() { pthread_rwlock_rdlock(&lock); } void __release_ptc() { pthread_rwlock_unlock(&lock); }
src/thread/lock_ptc.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" #include <threads.h> int mtx_init(mtx_t *m, int type) { *m = (mtx_t){ ._m_type = ((type&mtx_recursive) ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL), }; return thrd_success; }
src/thread/mtx_init.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" #include <threads.h> int mtx_lock(mtx_t *m) { if (m->_m_type == PTHREAD_MUTEX_NORMAL && !a_cas(&m->_m_lock, 0, EBUSY)) return thrd_success; /* Calling mtx_timedlock with a null pointer is an extension. * It is convenient, here to avoid duplication of the logic * for return values. */ ...
src/thread/mtx_lock.c
null
null
null
null
null
source
musl
#include <threads.h> #include <pthread.h> #include <errno.h> int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts) { int ret = __pthread_mutex_timedlock((pthread_mutex_t *)m, ts); switch (ret) { default: return thrd_error; case 0: return thrd_success; case ETIMEDOUT: return thrd_...
src/thread/mtx_timedlock.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" #include <threads.h> int mtx_trylock(mtx_t *m) { if (m->_m_type == PTHREAD_MUTEX_NORMAL) return (a_cas(&m->_m_lock, 0, EBUSY) & EBUSY) ? thrd_busy : thrd_success; int ret = __pthread_mutex_trylock((pthread_mutex_t *)m); switch (ret) { default: return thrd_error; case 0: return ...
src/thread/mtx_trylock.c
null
null
null
null
null
source
musl
#include <threads.h> #include <pthread.h> int mtx_unlock(mtx_t *mtx) { /* The only cases where pthread_mutex_unlock can return an * error are undefined behavior for C11 mtx_unlock, so we can * assume it does not return an error and simply tail call. */ return __pthread_mutex_unlock((pthread_mutex_t *)mtx); }
src/thread/mtx_unlock.c
null
null
null
null
null
source
musl
#include <pthread.h> #include <errno.h> #include "libc.h" #include "lock.h" #define malloc __libc_malloc #define calloc undef #define realloc undef #define free undef static struct atfork_funcs { void (*prepare)(void); void (*parent)(void); void (*child)(void); struct atfork_funcs *prev, *next; } *funcs; static ...
src/thread/pthread_atfork.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state) { *state = a->_a_detach; return 0; } int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size) { *size = a->_a_guardsize; return 0; } int pthread_attr_getinheritsched(const pthread_attr_t *r...
src/thread/pthread_attr_get.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_attr_init(pthread_attr_t *a) { *a = (pthread_attr_t){0}; __acquire_ptc(); a->_a_stacksize = __default_stacksize; a->_a_guardsize = __default_guardsize; __release_ptc(); return 0; }
src/thread/pthread_attr_init.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_attr_setdetachstate(pthread_attr_t *a, int state) { if (state > 1U) return EINVAL; a->_a_detach = state; return 0; }
src/thread/pthread_attr_setdetachstate.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_attr_setguardsize(pthread_attr_t *a, size_t size) { if (size > SIZE_MAX/8) return EINVAL; a->_a_guardsize = size; return 0; }
src/thread/pthread_attr_setguardsize.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" #include "syscall.h" int pthread_attr_setinheritsched(pthread_attr_t *a, int inherit) { if (inherit > 1U) return EINVAL; a->_a_sched = inherit; return 0; }
src/thread/pthread_attr_setinheritsched.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_attr_setschedparam(pthread_attr_t *restrict a, const struct sched_param *restrict param) { a->_a_prio = param->sched_priority; return 0; }
src/thread/pthread_attr_setschedparam.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_attr_setschedpolicy(pthread_attr_t *a, int policy) { a->_a_policy = policy; return 0; }
src/thread/pthread_attr_setschedpolicy.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_attr_setscope(pthread_attr_t *a, int scope) { switch (scope) { case PTHREAD_SCOPE_SYSTEM: return 0; case PTHREAD_SCOPE_PROCESS: return ENOTSUP; default: return EINVAL; } }
src/thread/pthread_attr_setscope.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_attr_setstack(pthread_attr_t *a, void *addr, size_t size) { if (size-PTHREAD_STACK_MIN > SIZE_MAX/4) return EINVAL; a->_a_stackaddr = (size_t)addr + size; a->_a_stacksize = size; return 0; }
src/thread/pthread_attr_setstack.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_attr_setstacksize(pthread_attr_t *a, size_t size) { if (size-PTHREAD_STACK_MIN > SIZE_MAX/4) return EINVAL; a->_a_stackaddr = 0; a->_a_stacksize = size; return 0; }
src/thread/pthread_attr_setstacksize.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_barrier_destroy(pthread_barrier_t *b) { if (b->_b_limit < 0) { if (b->_b_lock) { int v; a_or(&b->_b_lock, INT_MIN); while ((v = b->_b_lock) & INT_MAX) __wait(&b->_b_lock, 0, v, 0); } __vm_wait(); } return 0; }
src/thread/pthread_barrier_destroy.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_barrier_init(pthread_barrier_t *restrict b, const pthread_barrierattr_t *restrict a, unsigned count) { if (count-1 > INT_MAX-1) return EINVAL; *b = (pthread_barrier_t){ ._b_limit = count-1 | (a?a->__attr:0) }; return 0; }
src/thread/pthread_barrier_init.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" static int pshared_barrier_wait(pthread_barrier_t *b) { int limit = (b->_b_limit & INT_MAX) + 1; int ret = 0; int v, w; if (limit==1) return PTHREAD_BARRIER_SERIAL_THREAD; while ((v=a_cas(&b->_b_lock, 0, limit))) __wait(&b->_b_lock, &b->_b_waiters, v, 0); /* Wait for <limit> thread...
src/thread/pthread_barrier_wait.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_barrierattr_destroy(pthread_barrierattr_t *a) { return 0; }
src/thread/pthread_barrierattr_destroy.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_barrierattr_init(pthread_barrierattr_t *a) { *a = (pthread_barrierattr_t){0}; return 0; }
src/thread/pthread_barrierattr_init.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_barrierattr_setpshared(pthread_barrierattr_t *a, int pshared) { if (pshared > 1U) return EINVAL; a->__attr = pshared ? INT_MIN : 0; return 0; }
src/thread/pthread_barrierattr_setpshared.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <string.h> #include "pthread_impl.h" #include "syscall.h" hidden long __cancel(), __syscall_cp_asm(), __syscall_cp_c(); long __cancel() { pthread_t self = __pthread_self(); if (self->canceldisable == PTHREAD_CANCEL_ENABLE || self->cancelasync) pthread_exit(PTHREAD_CANCELED); self->ca...
src/thread/pthread_cancel.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" static void dummy(struct __ptcb *cb) { } weak_alias(dummy, __do_cleanup_push); weak_alias(dummy, __do_cleanup_pop); void _pthread_cleanup_push(struct __ptcb *cb, void (*f)(void *), void *x) { cb->__f = f; cb->__x = x; __do_cleanup_push(cb); } void _pthread_cleanup_pop(struct __ptcb *cb, ...
src/thread/pthread_cleanup_push.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_cond_broadcast(pthread_cond_t *c) { if (!c->_c_shared) return __private_cond_signal(c, -1); if (!c->_c_waiters) return 0; a_inc(&c->_c_seq); __wake(&c->_c_seq, -1, 0); return 0; }
src/thread/pthread_cond_broadcast.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_cond_destroy(pthread_cond_t *c) { if (c->_c_shared && c->_c_waiters) { int cnt; a_or(&c->_c_waiters, 0x80000000); a_inc(&c->_c_seq); __wake(&c->_c_seq, -1, 0); while ((cnt = c->_c_waiters) & 0x7fffffff) __wait(&c->_c_waiters, 0, cnt, 0); } return 0; }
src/thread/pthread_cond_destroy.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_cond_init(pthread_cond_t *restrict c, const pthread_condattr_t *restrict a) { *c = (pthread_cond_t){0}; if (a) { c->_c_clock = a->__attr & 0x7fffffff; if (a->__attr>>31) c->_c_shared = (void *)-1; } return 0; }
src/thread/pthread_cond_init.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_cond_signal(pthread_cond_t *c) { if (!c->_c_shared) return __private_cond_signal(c, 1); if (!c->_c_waiters) return 0; a_inc(&c->_c_seq); __wake(&c->_c_seq, 1, 0); return 0; }
src/thread/pthread_cond_signal.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" /* * struct waiter * * Waiter objects have automatic storage on the waiting thread, and * are used in building a linked list representing waiters currently * waiting on the condition variable or a group of waiters woken * together by a broadcast or signal; in the case of signal, this is...
src/thread/pthread_cond_timedwait.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_cond_wait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m) { return pthread_cond_timedwait(c, m, 0); }
src/thread/pthread_cond_wait.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_condattr_init(pthread_condattr_t *a) { *a = (pthread_condattr_t){0}; return 0; }
src/thread/pthread_condattr_init.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_condattr_setclock(pthread_condattr_t *a, clockid_t clk) { if (clk < 0 || clk-2U < 2) return EINVAL; a->__attr &= 0x80000000; a->__attr |= clk; return 0; }
src/thread/pthread_condattr_setclock.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_condattr_setpshared(pthread_condattr_t *a, int pshared) { if (pshared > 1U) return EINVAL; a->__attr &= 0x7fffffff; a->__attr |= (unsigned)pshared<<31; return 0; }
src/thread/pthread_condattr_setpshared.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include "pthread_impl.h" #include "stdio_impl.h" #include "libc.h" #include "lock.h" #include <sys/mman.h> #include <string.h> #include <stddef.h> static void dummy_0() { } weak_alias(dummy_0, __acquire_ptc); weak_alias(dummy_0, __release_ptc); weak_alias(dummy_0, __pthread_tsd_run_dtors); weak_al...
src/thread/pthread_create.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" #include <threads.h> static int __pthread_detach(pthread_t t) { /* If the cas fails, detach state is either already-detached * or exiting/exited, and pthread_join will trap or cleanup. */ if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != DT_JOINABLE) { int cs; __pthread_setcanc...
src/thread/pthread_detach.c
null
null
null
null
null
source
musl
#include <pthread.h> #include <threads.h> static int __pthread_equal(pthread_t a, pthread_t b) { return a==b; } weak_alias(__pthread_equal, pthread_equal); weak_alias(__pthread_equal, thrd_equal);
src/thread/pthread_equal.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include "pthread_impl.h" #include "libc.h" #include <sys/mman.h> int pthread_getattr_np(pthread_t t, pthread_attr_t *a) { *a = (pthread_attr_t){0}; a->_a_detach = t->detach_state>=DT_DETACHED; a->_a_guardsize = t->guard_size; if (t->stack) { a->_a_stackaddr = (uintptr_t)t->stack; a->_a_sta...
src/thread/pthread_getattr_np.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" int pthread_getcpuclockid(pthread_t t, clockid_t *clockid) { *clockid = (-t->tid-1)*8U + 6; return 0; }
src/thread/pthread_getcpuclockid.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <fcntl.h> #include <unistd.h> #include <sys/prctl.h> #include "pthread_impl.h" int pthread_getname_np(pthread_t thread, char *name, size_t len) { int fd, cs, status = 0; char f[sizeof "/proc/self/task//comm" + 3*sizeof(int)]; if (len < 16) return ERANGE; if (thread == pthread_self()...
src/thread/pthread_getname_np.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" #include "lock.h" int pthread_getschedparam(pthread_t t, int *restrict policy, struct sched_param *restrict param) { int r; sigset_t set; __block_app_sigs(&set); LOCK(t->killlock); if (!t->tid) { r = ESRCH; } else { r = -__syscall(SYS_sched_getparam, t->tid, param); if (!r) { *...
src/thread/pthread_getschedparam.c
null
null
null
null
null
source
musl
#include "pthread_impl.h" #include <threads.h> static void *__pthread_getspecific(pthread_key_t k) { struct pthread *self = __pthread_self(); return self->tsd[k]; } weak_alias(__pthread_getspecific, pthread_getspecific); weak_alias(__pthread_getspecific, tss_get);
src/thread/pthread_getspecific.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include "pthread_impl.h" #include <sys/mman.h> static void dummy1(pthread_t t) { } weak_alias(dummy1, __tl_sync); static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec *at) { int state, cs, r = 0; __pthread_testcancel(); __pthread_setcancelstate(PTHREAD_CANCEL_DISABL...
src/thread/pthread_join.c
null
null
null
null
null