mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Convert libpthread to C and merge into libc.
This commit is contained in:
parent
01b59c1947
commit
8e988c1bf1
65 changed files with 622 additions and 688 deletions
3
Makefile
3
Makefile
|
|
@ -7,7 +7,6 @@ MODULES=\
|
||||||
doc \
|
doc \
|
||||||
libc \
|
libc \
|
||||||
libm \
|
libm \
|
||||||
libpthread \
|
|
||||||
dispd \
|
dispd \
|
||||||
libmount \
|
libmount \
|
||||||
bench \
|
bench \
|
||||||
|
|
@ -126,7 +125,7 @@ sysroot-fsh:
|
||||||
.PHONY: sysroot-base-headers
|
.PHONY: sysroot-base-headers
|
||||||
sysroot-base-headers: sysroot-fsh
|
sysroot-base-headers: sysroot-fsh
|
||||||
export SYSROOT="$(SYSROOT)" && \
|
export SYSROOT="$(SYSROOT)" && \
|
||||||
(for D in libc libm libpthread kernel; do ($(MAKE) -C $$D install-headers DESTDIR="$(SYSROOT)") || exit $$?; done)
|
(for D in libc libm kernel; do ($(MAKE) -C $$D install-headers DESTDIR="$(SYSROOT)") || exit $$?; done)
|
||||||
|
|
||||||
.PHONY: sysroot-system
|
.PHONY: sysroot-system
|
||||||
sysroot-system: sysroot-fsh sysroot-base-headers
|
sysroot-system: sysroot-fsh sysroot-base-headers
|
||||||
|
|
|
||||||
|
|
@ -399,6 +399,50 @@ netdb/setservent.o \
|
||||||
poll/poll.o \
|
poll/poll.o \
|
||||||
poll/ppoll.o \
|
poll/ppoll.o \
|
||||||
psctl/psctl.o \
|
psctl/psctl.o \
|
||||||
|
pthread/pthread_attr_destroy.o \
|
||||||
|
pthread/pthread_attr_getdetachstate.o \
|
||||||
|
pthread/pthread_attr_getstacksize.o \
|
||||||
|
pthread/pthread_attr_init.o \
|
||||||
|
pthread/pthread_attr_setdetachstate.o \
|
||||||
|
pthread/pthread_attr_setstacksize.o \
|
||||||
|
pthread/pthread_condattr_destroy.o \
|
||||||
|
pthread/pthread_condattr_getclock.o \
|
||||||
|
pthread/pthread_condattr_init.o \
|
||||||
|
pthread/pthread_condattr_setclock.o \
|
||||||
|
pthread/pthread_cond_broadcast.o \
|
||||||
|
pthread/pthread_cond_destroy.o \
|
||||||
|
pthread/pthread_cond_init.o \
|
||||||
|
pthread/pthread_cond_signal.o \
|
||||||
|
pthread/pthread_cond_timedwait.o \
|
||||||
|
pthread/pthread_cond_wait.o \
|
||||||
|
pthread/pthread_create.o \
|
||||||
|
pthread/pthread_detach.o \
|
||||||
|
pthread/pthread_equal.o \
|
||||||
|
pthread/pthread_exit.o \
|
||||||
|
pthread/pthread_getspecific.o \
|
||||||
|
pthread/pthread_join.o \
|
||||||
|
pthread/pthread_key_create.o \
|
||||||
|
pthread/pthread_key_delete.o \
|
||||||
|
pthread/pthread_keys.o \
|
||||||
|
pthread/pthread_mutexattr_destroy.o \
|
||||||
|
pthread/pthread_mutexattr_gettype.o \
|
||||||
|
pthread/pthread_mutexattr_init.o \
|
||||||
|
pthread/pthread_mutexattr_settype.o \
|
||||||
|
pthread/pthread_mutex_destroy.o \
|
||||||
|
pthread/pthread_mutex_init.o \
|
||||||
|
pthread/pthread_mutex_lock.o \
|
||||||
|
pthread/pthread_mutex_trylock.o \
|
||||||
|
pthread/pthread_mutex_unlock.o \
|
||||||
|
pthread/pthread_once.o \
|
||||||
|
pthread/pthread_rwlock_destroy.o \
|
||||||
|
pthread/pthread_rwlock_init.o \
|
||||||
|
pthread/pthread_rwlock_rdlock.o \
|
||||||
|
pthread/pthread_rwlock_tryrdlock.o \
|
||||||
|
pthread/pthread_rwlock_trywrlock.o \
|
||||||
|
pthread/pthread_rwlock_unlock.o \
|
||||||
|
pthread/pthread_rwlock_wrlock.o \
|
||||||
|
pthread/pthread_self.o \
|
||||||
|
pthread/pthread_setspecific.o \
|
||||||
pwd/bcrypt_newhash.o \
|
pwd/bcrypt_newhash.o \
|
||||||
pwd/endpwent.o \
|
pwd/endpwent.o \
|
||||||
pwd/fgetpwent.o \
|
pwd/fgetpwent.o \
|
||||||
|
|
@ -413,10 +457,18 @@ pwd/openpw.o \
|
||||||
pwd/setpwent.o \
|
pwd/setpwent.o \
|
||||||
sched/sched_yield.o \
|
sched/sched_yield.o \
|
||||||
scram/scram.o \
|
scram/scram.o \
|
||||||
|
semaphore/sem_destroy.o \
|
||||||
|
semaphore/sem_getvalue.o \
|
||||||
|
semaphore/sem_init.o \
|
||||||
|
semaphore/sem_post.o \
|
||||||
|
semaphore/sem_timedwait.o \
|
||||||
|
semaphore/sem_trywait.o \
|
||||||
|
semaphore/sem_wait.o \
|
||||||
signal/kill.o \
|
signal/kill.o \
|
||||||
signal/killpg.o \
|
signal/killpg.o \
|
||||||
signal/psiginfo.o \
|
signal/psiginfo.o \
|
||||||
signal/psignal.o \
|
signal/psignal.o \
|
||||||
|
signal/pthread_sigmask.o \
|
||||||
signal/raise.o \
|
signal/raise.o \
|
||||||
signal/sigaction.o \
|
signal/sigaction.o \
|
||||||
signal/sigaltstack.o \
|
signal/sigaltstack.o \
|
||||||
|
|
@ -696,7 +748,7 @@ ifeq ($(HOST),x86_64-sortix)
|
||||||
LIBK_FLAGS:=$(LIBK_FLAGS) -mno-red-zone -mno-mmx -mno-sse -mno-sse2
|
LIBK_FLAGS:=$(LIBK_FLAGS) -mno-red-zone -mno-mmx -mno-sse -mno-sse2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BINS=libc.a libdl.a librt.a $(CRTOBJ)
|
BINS=libc.a libdl.a libpthread.a librt.a $(CRTOBJ)
|
||||||
BINSKERNEL=libk.a
|
BINSKERNEL=libk.a
|
||||||
INSTALLLIBS:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINS))
|
INSTALLLIBS:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINS))
|
||||||
INSTALLLIBSKERNEL:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINSKERNEL))
|
INSTALLLIBSKERNEL:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINSKERNEL))
|
||||||
|
|
@ -721,6 +773,9 @@ libdl.a:
|
||||||
libk.a: $(LIBK_OBJS)
|
libk.a: $(LIBK_OBJS)
|
||||||
$(AR) rcs $@ $(LIBK_OBJS)
|
$(AR) rcs $@ $(LIBK_OBJS)
|
||||||
|
|
||||||
|
libpthread.a:
|
||||||
|
$(AR) rcs $@
|
||||||
|
|
||||||
librt.a:
|
librt.a:
|
||||||
$(AR) rcs $@
|
$(AR) rcs $@
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,20 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__/pthread.h
|
__/pthread.h
|
||||||
Thread API.
|
Thread API.
|
||||||
|
|
@ -33,9 +33,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __sortix_libpthread__ 1
|
#if defined(__is_sortix_libc)
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
__SIZE_TYPE__ stack_size;
|
__SIZE_TYPE__ stack_size;
|
||||||
|
|
@ -53,7 +51,7 @@ typedef int __pthread_barrier_t;
|
||||||
|
|
||||||
typedef int __pthread_barrierattr_t;
|
typedef int __pthread_barrierattr_t;
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
struct pthread_cond_elem* first;
|
struct pthread_cond_elem* first;
|
||||||
|
|
@ -69,7 +67,7 @@ typedef struct
|
||||||
} __pthread_cond_t;
|
} __pthread_cond_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
__clock_t clock;
|
__clock_t clock;
|
||||||
|
|
@ -83,7 +81,7 @@ typedef struct
|
||||||
|
|
||||||
typedef __SIZE_TYPE__ __pthread_key_t;
|
typedef __SIZE_TYPE__ __pthread_key_t;
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned long lock;
|
unsigned long lock;
|
||||||
|
|
@ -101,7 +99,7 @@ typedef struct
|
||||||
} __pthread_mutex_t;
|
} __pthread_mutex_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
|
|
@ -113,7 +111,7 @@ typedef struct
|
||||||
} __pthread_mutexattr_t;
|
} __pthread_mutexattr_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
__pthread_mutex_t lock;
|
__pthread_mutex_t lock;
|
||||||
|
|
@ -127,7 +125,7 @@ typedef struct
|
||||||
} __pthread_once_t;
|
} __pthread_once_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
__pthread_cond_t reader_condition;
|
__pthread_cond_t reader_condition;
|
||||||
|
|
@ -151,7 +149,7 @@ typedef struct
|
||||||
} __pthread_rwlock_t;
|
} __pthread_rwlock_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
} __pthread_rwlockattr_t;
|
} __pthread_rwlockattr_t;
|
||||||
|
|
@ -163,7 +161,7 @@ typedef struct
|
||||||
|
|
||||||
typedef int __pthread_spinlock_t;
|
typedef int __pthread_spinlock_t;
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
typedef struct pthread* __pthread_t;
|
typedef struct pthread* __pthread_t;
|
||||||
#else
|
#else
|
||||||
typedef struct __pthread* __pthread_t;
|
typedef struct __pthread* __pthread_t;
|
||||||
|
|
@ -29,8 +29,7 @@
|
||||||
|
|
||||||
/* Detect whether we are a core system library. */
|
/* Detect whether we are a core system library. */
|
||||||
#if defined(__is_sortix_libc) || \
|
#if defined(__is_sortix_libc) || \
|
||||||
defined(__is_sortix_libm) || \
|
defined(__is_sortix_libm)
|
||||||
defined(__is_sortix_libpthread)
|
|
||||||
#if !defined(__is_sortix_system_library)
|
#if !defined(__is_sortix_system_library)
|
||||||
#define __is_sortix_system_library
|
#define __is_sortix_system_library
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,20 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread.h
|
pthread.h
|
||||||
Thread API.
|
Thread API.
|
||||||
|
|
@ -32,12 +32,12 @@
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
#include <sortix/uthread.h>
|
#include <sortix/uthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ typedef __pthread_spinlock_t pthread_spinlock_t;
|
||||||
typedef __pthread_t pthread_t;
|
typedef __pthread_t pthread_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
struct pthread
|
struct pthread
|
||||||
{
|
{
|
||||||
struct uthread uthread;
|
struct uthread uthread;
|
||||||
|
|
@ -151,7 +151,7 @@ struct pthread
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
struct pthread_cond_elem
|
struct pthread_cond_elem
|
||||||
{
|
{
|
||||||
struct pthread_cond_elem* next;
|
struct pthread_cond_elem* next;
|
||||||
|
|
@ -170,9 +170,7 @@ struct pthread_cond_elem
|
||||||
|
|
||||||
#define PTHREAD_ONCE_INIT { PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, 0 }
|
#define PTHREAD_ONCE_INIT { PTHREAD_NORMAL_MUTEX_INITIALIZER_NP, 0 }
|
||||||
|
|
||||||
void pthread_initialize(void);
|
#if defined(__is_sortix_libc)
|
||||||
|
|
||||||
#if defined(__is_sortix_libpthread)
|
|
||||||
|
|
||||||
struct pthread_key
|
struct pthread_key
|
||||||
{
|
{
|
||||||
|
|
@ -2,20 +2,20 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
semaphore.h
|
semaphore.h
|
||||||
Semaphore API.
|
Semaphore API.
|
||||||
|
|
@ -35,7 +35,7 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
#if defined(__is_sortix_libpthread)
|
#if defined(__is_sortix_libc)
|
||||||
int value;
|
int value;
|
||||||
#else
|
#else
|
||||||
int __value;
|
int __value;
|
||||||
|
|
@ -105,17 +105,17 @@ extern "C" {
|
||||||
#define _POSIX_SPIN_LOCKS 200809L
|
#define _POSIX_SPIN_LOCKS 200809L
|
||||||
/*TODO: _POSIX_SPORADIC_SERVER - Research what this is. */
|
/*TODO: _POSIX_SPORADIC_SERVER - Research what this is. */
|
||||||
/*TODO: _POSIX_SYNCHRONIZED_IO - Research what this is. */
|
/*TODO: _POSIX_SYNCHRONIZED_IO - Research what this is. */
|
||||||
/*TODO: _POSIX_THREAD_ATTR_STACKADDR - Research what this is, cooperate with libpthread. */
|
/*TODO: _POSIX_THREAD_ATTR_STACKADDR - Research what this is. */
|
||||||
/*TODO: _POSIX_THREAD_ATTR_STACKSIZE - Research what this is, cooperate with libpthread. */
|
/*TODO: _POSIX_THREAD_ATTR_STACKSIZE - Research what this is. */
|
||||||
#define _POSIX_THREAD_CPUTIME 200809L
|
#define _POSIX_THREAD_CPUTIME 200809L
|
||||||
/*TODO: _POSIX_THREAD_PRIO_INHERIT - Research what this is, cooperate with libpthread. */
|
/*TODO: _POSIX_THREAD_PRIO_INHERIT - Research what this is. */
|
||||||
/*TODO: _POSIX_THREAD_PRIO_PROTECT - Research what this is, cooperate with libpthread. */
|
/*TODO: _POSIX_THREAD_PRIO_PROTECT - Research what this is. */
|
||||||
/*TODO: _POSIX_THREAD_PRIORITY_SCHEDULING - Research what this is, cooperate with libpthread. */
|
/*TODO: _POSIX_THREAD_PRIORITY_SCHEDULING - Research what this is. */
|
||||||
/*TODO: _POSIX_THREAD_PROCESS_SHARED - Research what this is, cooperate with libpthread. */
|
/*TODO: _POSIX_THREAD_PROCESS_SHARED - Research what this is. */
|
||||||
/*TODO: _POSIX_THREAD_ROBUST_PRIO_INHERIT - Research what this is, cooperate with libpthread. */
|
/*TODO: _POSIX_THREAD_ROBUST_PRIO_INHERIT - Research what this is. */
|
||||||
/*TODO: _POSIX_THREAD_ROBUST_PRIO_PROTECT - Research what this is, cooperate with libpthread. */
|
/*TODO: _POSIX_THREAD_ROBUST_PRIO_PROTECT - Research what this is. */
|
||||||
#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
|
#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
|
||||||
/*TODO: _POSIX_THREAD_SPORADIC_SERVER - Research what this is, cooperate with libpthread. */
|
/*TODO: _POSIX_THREAD_SPORADIC_SERVER - Research what this is. */
|
||||||
#define _POSIX_THREADS 200809L
|
#define _POSIX_THREADS 200809L
|
||||||
#define _POSIX_TIMEOUTS 200809L
|
#define _POSIX_TIMEOUTS 200809L
|
||||||
#define _POSIX_TIMERS 200809L
|
#define _POSIX_TIMERS 200809L
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@
|
||||||
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
init/init.c
|
init/init.c
|
||||||
Initializes the process by setting up the heap, signal handling, static
|
Initializes the standard library.
|
||||||
memory and other useful things.
|
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <elf.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -39,12 +39,48 @@ static char* find_last_elem(char* str)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Emit an ELF note containing the size and alignment of struct pthread.
|
||||||
|
__attribute__((used))
|
||||||
|
static void elf_note_sortix_pthread_size(void)
|
||||||
|
{
|
||||||
|
asm volatile (
|
||||||
|
".pushsection .note.sortix,\"a\",@note\n\t"
|
||||||
|
".align 4\n\t"
|
||||||
|
".long 2f-1f\n\t" // namesz
|
||||||
|
".long 4f-3f\n\t" // descsz
|
||||||
|
".long %c0\n" // type
|
||||||
|
"1:\n\t"
|
||||||
|
".string \"Sortix\"\n" // name
|
||||||
|
"2:\n\t"
|
||||||
|
".align 4\n"
|
||||||
|
"3:\n\t"
|
||||||
|
#if defined(__x86_64__)
|
||||||
|
".quad %c1\n"
|
||||||
|
".quad %c2\n"
|
||||||
|
#elif defined(__i386__)
|
||||||
|
".long %c1\n"
|
||||||
|
".long %c2\n"
|
||||||
|
#endif
|
||||||
|
"4:\n\t"
|
||||||
|
".align 4\n\t"
|
||||||
|
".popsection\n\t"
|
||||||
|
:: "n"(ELF_NOTE_SORTIX_UTHREAD_SIZE),
|
||||||
|
"n"(sizeof(struct pthread)),
|
||||||
|
"n"(alignof(struct pthread))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void initialize_standard_library(int argc, char* argv[])
|
void initialize_standard_library(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
const char* argv0 = argc ? argv[0] : "";
|
const char* argv0 = argc ? argv[0] : "";
|
||||||
program_invocation_name = (char*) argv0;
|
program_invocation_name = (char*) argv0;
|
||||||
program_invocation_short_name = find_last_elem((char*) argv0);
|
program_invocation_short_name = find_last_elem((char*) argv0);
|
||||||
|
|
||||||
// Initialize pthreads.
|
struct pthread* self = pthread_self();
|
||||||
pthread_initialize();
|
self->join_lock = (pthread_mutex_t) PTHREAD_NORMAL_MUTEX_INITIALIZER_NP;
|
||||||
|
self->join_lock.lock = 1 /* LOCKED_VALUE */;
|
||||||
|
self->join_lock.type = PTHREAD_MUTEX_NORMAL;
|
||||||
|
self->join_lock.owner = (unsigned long) self;
|
||||||
|
self->detach_lock = (pthread_mutex_t) PTHREAD_NORMAL_MUTEX_INITIALIZER_NP;
|
||||||
|
self->detach_state = PTHREAD_CREATE_JOINABLE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,29 +2,30 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_attr_destroy.c++
|
pthread/pthread_attr_destroy.c
|
||||||
Destroys a thread attributes object.
|
Destroys a thread attributes object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_attr_destroy(pthread_attr_t* /*attr*/)
|
int pthread_attr_destroy(pthread_attr_t* attr)
|
||||||
{
|
{
|
||||||
|
(void) attr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,29 +2,28 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_attr_getdetachstate.c++
|
pthread/pthread_attr_getdetachstate.c
|
||||||
Gets the requested detach state in a thread attribute object.
|
Gets the requested detach state in a thread attribute object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detach_state)
|
int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detach_state)
|
||||||
{
|
{
|
||||||
return *detach_state = attr->detach_state, 0;
|
return *detach_state = attr->detach_state, 0;
|
||||||
|
|
@ -2,29 +2,28 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_attr_getstacksize.c++
|
pthread/pthread_attr_getstacksize.c
|
||||||
Gets the requested stack size in a thread attribute object.
|
Gets the requested stack size in a thread attribute object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_attr_getstacksize(const pthread_attr_t* restrict attr,
|
int pthread_attr_getstacksize(const pthread_attr_t* restrict attr,
|
||||||
size_t* restrict stack_size_ptr)
|
size_t* restrict stack_size_ptr)
|
||||||
{
|
{
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014, 2015.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014, 2015.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_attr_init.c++
|
pthread/pthread_attr_init.c
|
||||||
Initialize a thread attributes object.
|
Initialize a thread attributes object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
static const unsigned long DEFAULT_STACK_SIZE = 80 * 1024;
|
static const unsigned long DEFAULT_STACK_SIZE = 80 * 1024;
|
||||||
|
|
||||||
extern "C" int pthread_attr_init(pthread_attr_t* attr)
|
int pthread_attr_init(pthread_attr_t* attr)
|
||||||
{
|
{
|
||||||
memset(attr, 0, sizeof(*attr));
|
memset(attr, 0, sizeof(*attr));
|
||||||
attr->stack_size = DEFAULT_STACK_SIZE;
|
attr->stack_size = DEFAULT_STACK_SIZE;
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_attr_setdetachstate.c++
|
pthread/pthread_attr_setdetachstate.c
|
||||||
Sets the requested detach state in a thread attribute object.
|
Sets the requested detach state in a thread attribute object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_attr_setdetachstate(pthread_attr_t* attr, int detach_state)
|
int pthread_attr_setdetachstate(pthread_attr_t* attr, int detach_state)
|
||||||
{
|
{
|
||||||
if ( detach_state != PTHREAD_CREATE_JOINABLE &&
|
if ( detach_state != PTHREAD_CREATE_JOINABLE &&
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_attr_setstacksize.c++
|
pthread/pthread_attr_setstacksize.c
|
||||||
Sets the requested stack size in a thread attribute object.
|
Sets the requested stack size in a thread attribute object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_attr_setstacksize(pthread_attr_t* attr, size_t stack_size)
|
int pthread_attr_setstacksize(pthread_attr_t* attr, size_t stack_size)
|
||||||
{
|
{
|
||||||
attr->stack_size = stack_size;
|
attr->stack_size = stack_size;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2,32 +2,33 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_cond_broadcast.c++
|
pthread/pthread_cond_broadcast.c
|
||||||
Broadcasts a condition.
|
Broadcasts a condition.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_cond_broadcast(pthread_cond_t* cond)
|
int pthread_cond_broadcast(pthread_cond_t* cond)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
while ( cond->first )
|
while ( cond->first )
|
||||||
if ( int ret = pthread_cond_signal(cond) )
|
if ( (ret = pthread_cond_signal(cond)) )
|
||||||
return ret;
|
return ret;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,29 +2,30 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_cond_destroy.c++
|
pthread/pthread_cond_destroy.c
|
||||||
Destroys a condition variable.
|
Destroys a condition variable.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_cond_destroy(pthread_cond_t* restrict /*cond*/)
|
int pthread_cond_destroy(pthread_cond_t* restrict cond)
|
||||||
{
|
{
|
||||||
|
(void) cond;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,29 +2,28 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_cond_init.c++
|
pthread/pthread_cond_init.c
|
||||||
Initializes a condition variable.
|
Initializes a condition variable.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_cond_init(pthread_cond_t* restrict cond,
|
int pthread_cond_init(pthread_cond_t* restrict cond,
|
||||||
const pthread_condattr_t* restrict attr)
|
const pthread_condattr_t* restrict attr)
|
||||||
{
|
{
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_cond_signal.c++
|
pthread/pthread_cond_signal.c
|
||||||
Signals a condition.
|
Signals a condition.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_cond_signal(pthread_cond_t* cond)
|
int pthread_cond_signal(pthread_cond_t* cond)
|
||||||
{
|
{
|
||||||
struct pthread_cond_elem* elem = cond->first;
|
struct pthread_cond_elem* elem = cond->first;
|
||||||
if ( !elem )
|
if ( !elem )
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_cond_timedwait.c++
|
pthread/pthread_cond_timedwait.c
|
||||||
Waits on a condition or until a timeout happens.
|
Waits on a condition or until a timeout happens.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -29,7 +29,6 @@
|
||||||
#include <timespec.h>
|
#include <timespec.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_cond_timedwait(pthread_cond_t* restrict cond,
|
int pthread_cond_timedwait(pthread_cond_t* restrict cond,
|
||||||
pthread_mutex_t* restrict mutex,
|
pthread_mutex_t* restrict mutex,
|
||||||
const struct timespec* restrict abstime)
|
const struct timespec* restrict abstime)
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_cond_wait.c++
|
pthread/pthread_cond_wait.c
|
||||||
Waits on a condition.
|
Waits on a condition.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -28,7 +28,6 @@
|
||||||
#include <timespec.h>
|
#include <timespec.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_cond_wait(pthread_cond_t* restrict cond,
|
int pthread_cond_wait(pthread_cond_t* restrict cond,
|
||||||
pthread_mutex_t* restrict mutex)
|
pthread_mutex_t* restrict mutex)
|
||||||
{
|
{
|
||||||
|
|
@ -2,29 +2,30 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_condattr_destroy.c++
|
pthread/pthread_condattr_destroy.c
|
||||||
Destroys a condition variable attributes object.
|
Destroys a condition variable attributes object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_condattr_destroy(pthread_condattr_t* /*attr*/)
|
int pthread_condattr_destroy(pthread_condattr_t* attr)
|
||||||
{
|
{
|
||||||
|
(void) attr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,29 +2,28 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_condattr_getclock.c++
|
pthread/pthread_condattr_getclock.c
|
||||||
Gets the requested clock in a cond attribute object.
|
Gets the requested clock in a cond attribute object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_condattr_getclock(const pthread_condattr_t* restrict attr,
|
int pthread_condattr_getclock(const pthread_condattr_t* restrict attr,
|
||||||
clockid_t* restrict clock)
|
clockid_t* restrict clock)
|
||||||
{
|
{
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_condattr_init.c++
|
pthread/pthread_condattr_init.c
|
||||||
Initialize a condition variable attributes object.
|
Initialize a condition variable attributes object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern "C" int pthread_condattr_init(pthread_condattr_t* attr)
|
int pthread_condattr_init(pthread_condattr_t* attr)
|
||||||
{
|
{
|
||||||
memset(attr, 0, sizeof(*attr));
|
memset(attr, 0, sizeof(*attr));
|
||||||
attr->clock = CLOCK_REALTIME;
|
attr->clock = CLOCK_REALTIME;
|
||||||
|
|
@ -2,29 +2,28 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_condattr_setclock.c++
|
pthread/pthread_condattr_setclock.c
|
||||||
Sets the requested clock in a cond attribute object.
|
Sets the requested clock in a cond attribute object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock)
|
int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock)
|
||||||
{
|
{
|
||||||
return attr->clock = clock, 0;
|
return attr->clock = clock, 0;
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_create.c++
|
pthread/pthread_create.c
|
||||||
Creates a new thread.
|
Creates a new thread.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <stdalign.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
@ -47,27 +48,27 @@ static void pthread_entrance(struct pthread* thread)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
const unsigned long FLAGS_CARRY = 1 << 0; // 0x000001
|
static const unsigned long FLAGS_CARRY = 1 << 0; // 0x000001
|
||||||
const unsigned long FLAGS_RESERVED1 = 1 << 1; // 0x000002, read as one
|
static const unsigned long FLAGS_RESERVED1 = 1 << 1; // 0x000002, read as one
|
||||||
const unsigned long FLAGS_PARITY = 1 << 2; // 0x000004
|
static const unsigned long FLAGS_PARITY = 1 << 2; // 0x000004
|
||||||
const unsigned long FLAGS_RESERVED2 = 1 << 3; // 0x000008
|
static const unsigned long FLAGS_RESERVED2 = 1 << 3; // 0x000008
|
||||||
const unsigned long FLAGS_AUX = 1 << 4; // 0x000010
|
static const unsigned long FLAGS_AUX = 1 << 4; // 0x000010
|
||||||
const unsigned long FLAGS_RESERVED3 = 1 << 5; // 0x000020
|
static const unsigned long FLAGS_RESERVED3 = 1 << 5; // 0x000020
|
||||||
const unsigned long FLAGS_ZERO = 1 << 6; // 0x000040
|
static const unsigned long FLAGS_ZERO = 1 << 6; // 0x000040
|
||||||
const unsigned long FLAGS_SIGN = 1 << 7; // 0x000080
|
static const unsigned long FLAGS_SIGN = 1 << 7; // 0x000080
|
||||||
const unsigned long FLAGS_TRAP = 1 << 8; // 0x000100
|
static const unsigned long FLAGS_TRAP = 1 << 8; // 0x000100
|
||||||
const unsigned long FLAGS_INTERRUPT = 1 << 9; // 0x000200
|
static const unsigned long FLAGS_INTERRUPT = 1 << 9; // 0x000200
|
||||||
const unsigned long FLAGS_DIRECTION = 1 << 10; // 0x000400
|
static const unsigned long FLAGS_DIRECTION = 1 << 10; // 0x000400
|
||||||
const unsigned long FLAGS_OVERFLOW = 1 << 11; // 0x000800
|
static const unsigned long FLAGS_OVERFLOW = 1 << 11; // 0x000800
|
||||||
const unsigned long FLAGS_IOPRIVLEVEL = 1 << 12 | 1 << 13;
|
static const unsigned long FLAGS_IOPRIVLEVEL = 1 << 12 | 1 << 13;
|
||||||
const unsigned long FLAGS_NESTEDTASK = 1 << 14; // 0x004000
|
static const unsigned long FLAGS_NESTEDTASK = 1 << 14; // 0x004000
|
||||||
const unsigned long FLAGS_RESERVED4 = 1 << 15; // 0x008000
|
static const unsigned long FLAGS_RESERVED4 = 1 << 15; // 0x008000
|
||||||
const unsigned long FLAGS_RESUME = 1 << 16; // 0x010000
|
static const unsigned long FLAGS_RESUME = 1 << 16; // 0x010000
|
||||||
const unsigned long FLAGS_VIRTUAL8086 = 1 << 17; // 0x020000
|
static const unsigned long FLAGS_VIRTUAL8086 = 1 << 17; // 0x020000
|
||||||
const unsigned long FLAGS_ALIGNCHECK = 1 << 18; // 0x040000
|
static const unsigned long FLAGS_ALIGNCHECK = 1 << 18; // 0x040000
|
||||||
const unsigned long FLAGS_VIRTINTR = 1 << 19; // 0x080000
|
static const unsigned long FLAGS_VIRTINTR = 1 << 19; // 0x080000
|
||||||
const unsigned long FLAGS_VIRTINTRPEND = 1 << 20; // 0x100000
|
static const unsigned long FLAGS_VIRTINTRPEND = 1 << 20; // 0x100000
|
||||||
const unsigned long FLAGS_ID = 1 << 21; // 0x200000
|
static const unsigned long FLAGS_ID = 1 << 21; // 0x200000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__i386__)
|
#if defined(__i386__)
|
||||||
|
|
@ -122,7 +123,6 @@ static void setup_thread_state(struct pthread* thread, struct tfork* regs)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_create(pthread_t* restrict thread_ptr,
|
int pthread_create(pthread_t* restrict thread_ptr,
|
||||||
const pthread_attr_t* restrict attr,
|
const pthread_attr_t* restrict attr,
|
||||||
void* (*entry_function)(void*),
|
void* (*entry_function)(void*),
|
||||||
|
|
@ -198,11 +198,11 @@ int pthread_create(pthread_t* restrict thread_ptr,
|
||||||
thread->uthread.tls_size = tls_size;
|
thread->uthread.tls_size = tls_size;
|
||||||
thread->uthread.arg_mmap = self->uthread.arg_mmap;
|
thread->uthread.arg_mmap = self->uthread.arg_mmap;
|
||||||
thread->uthread.arg_size = self->uthread.arg_size;
|
thread->uthread.arg_size = self->uthread.arg_size;
|
||||||
thread->join_lock = PTHREAD_NORMAL_MUTEX_INITIALIZER_NP;
|
thread->join_lock = (pthread_mutex_t) PTHREAD_NORMAL_MUTEX_INITIALIZER_NP;
|
||||||
thread->join_lock.lock = 1 /* LOCKED_VALUE */;
|
thread->join_lock.lock = 1 /* LOCKED_VALUE */;
|
||||||
thread->join_lock.type = PTHREAD_MUTEX_NORMAL;
|
thread->join_lock.type = PTHREAD_MUTEX_NORMAL;
|
||||||
thread->join_lock.owner = (unsigned long) thread;
|
thread->join_lock.owner = (unsigned long) thread;
|
||||||
thread->detach_lock = PTHREAD_NORMAL_MUTEX_INITIALIZER_NP;
|
thread->detach_lock = (pthread_mutex_t) PTHREAD_NORMAL_MUTEX_INITIALIZER_NP;
|
||||||
thread->detach_state = attr->detach_state;
|
thread->detach_state = attr->detach_state;
|
||||||
thread->entry_function = entry_function;
|
thread->entry_function = entry_function;
|
||||||
thread->entry_cookie = entry_cookie;
|
thread->entry_cookie = entry_cookie;
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_detach.c++
|
pthread/pthread_detach.c
|
||||||
Detach a thread.
|
Detach a thread.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_detach(pthread_t thread)
|
int pthread_detach(pthread_t thread)
|
||||||
{
|
{
|
||||||
if ( pthread_mutex_trylock(&thread->detach_lock) != 0 )
|
if ( pthread_mutex_trylock(&thread->detach_lock) != 0 )
|
||||||
return pthread_join(thread, NULL);
|
return pthread_join(thread, NULL);
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_equal.c++
|
pthread/pthread_equal.c
|
||||||
Compares thread identities.
|
Compares thread identities.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_equal(pthread_t t1, pthread_t t2)
|
int pthread_equal(pthread_t t1, pthread_t t2)
|
||||||
{
|
{
|
||||||
return t1 == t2 ? 1 : 0;
|
return t1 == t2 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_exit.c++
|
pthread/pthread_exit.c
|
||||||
Exits the current thread.
|
Exits the current thread.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,11 +25,11 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
__attribute__((__noreturn__))
|
__attribute__((__noreturn__))
|
||||||
void pthread_exit(void* return_value)
|
void pthread_exit(void* return_value)
|
||||||
{
|
{
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_getspecific.c++
|
pthread/pthread_getspecific.c
|
||||||
Thread-specific data management.
|
Thread-specific data management.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" void* pthread_getspecific(pthread_key_t key)
|
void* pthread_getspecific(pthread_key_t key)
|
||||||
{
|
{
|
||||||
struct pthread* thread = pthread_self();
|
struct pthread* thread = pthread_self();
|
||||||
|
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_join.c++
|
pthread/pthread_join.c
|
||||||
Wait for thread termination.
|
Wait for thread termination.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
extern "C" int pthread_join(pthread_t thread, void** result_ptr)
|
int pthread_join(pthread_t thread, void** result_ptr)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&thread->join_lock);
|
pthread_mutex_lock(&thread->join_lock);
|
||||||
pthread_mutex_unlock(&thread->join_lock);
|
pthread_mutex_unlock(&thread->join_lock);
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_key_create.c++
|
pthread/pthread_key_create.c
|
||||||
Thread-specific data key creation.
|
Thread-specific data key creation.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -26,11 +26,11 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void noop_destructor(void*)
|
static void noop_destructor(void* ctx)
|
||||||
{
|
{
|
||||||
|
(void) ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_key_create(pthread_key_t* key, void (*destructor)(void*))
|
int pthread_key_create(pthread_key_t* key, void (*destructor)(void*))
|
||||||
{
|
{
|
||||||
if ( !destructor )
|
if ( !destructor )
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_key_delete.c++
|
pthread/pthread_key_delete.c
|
||||||
Thread-specific data key deletion.
|
Thread-specific data key deletion.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern "C" int pthread_key_delete(pthread_key_t key)
|
int pthread_key_delete(pthread_key_t key)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&__pthread_keys_lock);
|
pthread_mutex_lock(&__pthread_keys_lock);
|
||||||
|
|
||||||
31
libc/pthread/pthread_keys.c
Normal file
31
libc/pthread/pthread_keys.c
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
pthread/pthread_keys.c
|
||||||
|
pthread_keys global variables.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
pthread_mutex_t __pthread_keys_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
||||||
|
struct pthread_key* __pthread_keys = NULL;
|
||||||
|
size_t __pthread_keys_used = 0;
|
||||||
|
size_t __pthread_keys_length = 0;
|
||||||
|
|
@ -2,29 +2,30 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_mutex_destroy.c++
|
pthread/pthread_mutex_destroy.c
|
||||||
Destroys a mutex.
|
Destroys a mutex.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_mutex_destroy(pthread_mutex_t* /*mutex*/)
|
int pthread_mutex_destroy(pthread_mutex_t* mutex)
|
||||||
{
|
{
|
||||||
|
(void) mutex;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,29 +2,28 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_mutex_init.c++
|
pthread/pthread_mutex_init.c
|
||||||
Initializes a mutex.
|
Initializes a mutex.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_mutex_init(pthread_mutex_t* restrict mutex,
|
int pthread_mutex_init(pthread_mutex_t* restrict mutex,
|
||||||
const pthread_mutexattr_t* restrict attr)
|
const pthread_mutexattr_t* restrict attr)
|
||||||
{
|
{
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_mutex_lock.c++
|
pthread/pthread_mutex_lock.c
|
||||||
Locks a mutex.
|
Locks a mutex.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
static const unsigned long UNLOCKED_VALUE = 0;
|
static const unsigned long UNLOCKED_VALUE = 0;
|
||||||
static const unsigned long LOCKED_VALUE = 1;
|
static const unsigned long LOCKED_VALUE = 1;
|
||||||
|
|
||||||
extern "C" int pthread_mutex_lock(pthread_mutex_t* mutex)
|
int pthread_mutex_lock(pthread_mutex_t* mutex)
|
||||||
{
|
{
|
||||||
while ( !__sync_bool_compare_and_swap(&mutex->lock, UNLOCKED_VALUE, LOCKED_VALUE) )
|
while ( !__sync_bool_compare_and_swap(&mutex->lock, UNLOCKED_VALUE, LOCKED_VALUE) )
|
||||||
{
|
{
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_mutex_trylock.c++
|
pthread/pthread_mutex_trylock.c
|
||||||
Attempts to lock a mutex.
|
Attempts to lock a mutex.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
static const unsigned long UNLOCKED_VALUE = 0;
|
static const unsigned long UNLOCKED_VALUE = 0;
|
||||||
static const unsigned long LOCKED_VALUE = 1;
|
static const unsigned long LOCKED_VALUE = 1;
|
||||||
|
|
||||||
extern "C" int pthread_mutex_trylock(pthread_mutex_t* mutex)
|
int pthread_mutex_trylock(pthread_mutex_t* mutex)
|
||||||
{
|
{
|
||||||
if ( !__sync_bool_compare_and_swap(&mutex->lock, UNLOCKED_VALUE, LOCKED_VALUE) )
|
if ( !__sync_bool_compare_and_swap(&mutex->lock, UNLOCKED_VALUE, LOCKED_VALUE) )
|
||||||
{
|
{
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_mutex_unlock.c++
|
pthread/pthread_mutex_unlock.c
|
||||||
Unlocks a mutex.
|
Unlocks a mutex.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
static const unsigned long UNLOCKED_VALUE = 0;
|
static const unsigned long UNLOCKED_VALUE = 0;
|
||||||
static const unsigned long LOCKED_VALUE = 1;
|
static const unsigned long LOCKED_VALUE = 1;
|
||||||
|
|
||||||
extern "C" int pthread_mutex_unlock(pthread_mutex_t* mutex)
|
int pthread_mutex_unlock(pthread_mutex_t* mutex)
|
||||||
{
|
{
|
||||||
if ( mutex->type == PTHREAD_MUTEX_RECURSIVE && mutex->recursion )
|
if ( mutex->type == PTHREAD_MUTEX_RECURSIVE && mutex->recursion )
|
||||||
return mutex->recursion--, 0;
|
return mutex->recursion--, 0;
|
||||||
|
|
@ -2,29 +2,30 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_mutexattr_destroy.c++
|
pthread/pthread_mutexattr_destroy.c
|
||||||
Destroys a mutex attributes object.
|
Destroys a mutex attributes object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_mutexattr_destroy(pthread_mutexattr_t* /*attr*/)
|
int pthread_mutexattr_destroy(pthread_mutexattr_t* attr)
|
||||||
{
|
{
|
||||||
|
(void) attr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,29 +2,28 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_mutexattr_gettype.c++
|
pthread/pthread_mutexattr_gettype.c
|
||||||
Gets the requested mutex type in a mutex attribute object.
|
Gets the requested mutex type in a mutex attribute object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_mutexattr_gettype(pthread_mutexattr_t* restrict attr,
|
int pthread_mutexattr_gettype(pthread_mutexattr_t* restrict attr,
|
||||||
int* restrict type)
|
int* restrict type)
|
||||||
{
|
{
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_mutexattr_init.c++
|
pthread/pthread_mutexattr_init.c
|
||||||
Initialize a mutex attributes object.
|
Initialize a mutex attributes object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern "C" int pthread_mutexattr_init(pthread_mutexattr_t* attr)
|
int pthread_mutexattr_init(pthread_mutexattr_t* attr)
|
||||||
{
|
{
|
||||||
memset(attr, 0, sizeof(*attr));
|
memset(attr, 0, sizeof(*attr));
|
||||||
attr->type = PTHREAD_MUTEX_DEFAULT;
|
attr->type = PTHREAD_MUTEX_DEFAULT;
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_mutexattr_settype.c++
|
pthread/pthread_mutexattr_settype.c
|
||||||
Sets the requested mutex type in a mutex attribute object.
|
Sets the requested mutex type in a mutex attribute object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type)
|
int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type)
|
||||||
{
|
{
|
||||||
return attr->type = type, 0;
|
return attr->type = type, 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,29 +2,28 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_once.c++
|
pthread/pthread_once.c
|
||||||
Dynamic package initialization.
|
Dynamic package initialization.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_once(pthread_once_t* once_control, void (*init_routine)(void))
|
int pthread_once(pthread_once_t* once_control, void (*init_routine)(void))
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&once_control->lock);
|
pthread_mutex_lock(&once_control->lock);
|
||||||
|
|
@ -2,29 +2,30 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_rwlock_destroy.c++
|
pthread/pthread_rwlock_destroy.c
|
||||||
Destroys a read-write lock.
|
Destroys a read-write lock.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_rwlock_destroy(pthread_rwlock_t* /*rwlock*/)
|
int pthread_rwlock_destroy(pthread_rwlock_t* rwlock)
|
||||||
{
|
{
|
||||||
|
(void) rwlock;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,32 +2,32 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_rwlock_init.c++
|
pthread/pthread_rwlock_init.c
|
||||||
Initializes a read-write lock.
|
Initializes a read-write lock.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_rwlock_init(pthread_rwlock_t* restrict rwlock,
|
int pthread_rwlock_init(pthread_rwlock_t* restrict rwlock,
|
||||||
const pthread_rwlockattr_t* restrict /*attr*/)
|
const pthread_rwlockattr_t* restrict attr)
|
||||||
{
|
{
|
||||||
*rwlock = PTHREAD_RWLOCK_INITIALIZER;
|
(void) attr;
|
||||||
|
*rwlock = (pthread_rwlock_t) PTHREAD_RWLOCK_INITIALIZER;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_rwlock_rdlock.c++
|
pthread/pthread_rwlock_rdlock.c
|
||||||
Acquires read access to a read-write lock.
|
Acquires read access to a read-write lock.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_rwlock_rdlock(pthread_rwlock_t* rwlock)
|
int pthread_rwlock_rdlock(pthread_rwlock_t* rwlock)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&rwlock->request_mutex);
|
pthread_mutex_lock(&rwlock->request_mutex);
|
||||||
rwlock->pending_readers++;
|
rwlock->pending_readers++;
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_rwlock_tryrdlock.c++
|
pthread/pthread_rwlock_tryrdlock.c
|
||||||
Attempts to acquire read access to a read-write lock.
|
Attempts to acquire read access to a read-write lock.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,9 +25,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_rwlock_tryrdlock(pthread_rwlock_t* rwlock)
|
int pthread_rwlock_tryrdlock(pthread_rwlock_t* rwlock)
|
||||||
{
|
{
|
||||||
if ( int ret = pthread_mutex_trylock(&rwlock->request_mutex) )
|
int ret;
|
||||||
|
if ( (ret = pthread_mutex_trylock(&rwlock->request_mutex)) )
|
||||||
return errno = ret;
|
return errno = ret;
|
||||||
while ( rwlock->num_writers || rwlock->pending_writers )
|
while ( rwlock->num_writers || rwlock->pending_writers )
|
||||||
{
|
{
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_rwlock_trywrlock.c++
|
pthread/pthread_rwlock_trywrlock.c
|
||||||
Attempts to acquire write access to a read-write lock.
|
Attempts to acquire write access to a read-write lock.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,9 +25,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_rwlock_trywrlock(pthread_rwlock_t* rwlock)
|
int pthread_rwlock_trywrlock(pthread_rwlock_t* rwlock)
|
||||||
{
|
{
|
||||||
if ( int ret = pthread_mutex_trylock(&rwlock->request_mutex) )
|
int ret;
|
||||||
|
if ( (ret = pthread_mutex_trylock(&rwlock->request_mutex)) )
|
||||||
return errno = ret;
|
return errno = ret;
|
||||||
if ( rwlock->num_readers || rwlock->num_writers )
|
if ( rwlock->num_readers || rwlock->num_writers )
|
||||||
{
|
{
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_rwlock_unlock.c++
|
pthread/pthread_rwlock_unlock.c
|
||||||
Releases hold of a read-write lock.
|
Releases hold of a read-write lock.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_rwlock_unlock(pthread_rwlock_t* rwlock)
|
int pthread_rwlock_unlock(pthread_rwlock_t* rwlock)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&rwlock->request_mutex);
|
pthread_mutex_lock(&rwlock->request_mutex);
|
||||||
if ( rwlock->num_writers )
|
if ( rwlock->num_writers )
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_rwlock_wrlock.c++
|
pthread/pthread_rwlock_wrlock.c
|
||||||
Acquires write access to a read-write lock.
|
Acquires write access to a read-write lock.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_rwlock_wrlock(pthread_rwlock_t* rwlock)
|
int pthread_rwlock_wrlock(pthread_rwlock_t* rwlock)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&rwlock->request_mutex);
|
pthread_mutex_lock(&rwlock->request_mutex);
|
||||||
rwlock->pending_writers++;
|
rwlock->pending_writers++;
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_rwlockattr_destroy.c++
|
pthread/pthread_rwlockattr_destroy.c
|
||||||
Destroys a read-write lock attributes object.
|
Destroys a read-write lock attributes object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" int pthread_rwlockattr_destroy(pthread_rwlockattr_t* /*attr*/)
|
int pthread_rwlockattr_destroy(pthread_rwlockattr_t* attr)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_rwlockattr_init.c++
|
pthread/pthread_rwlockattr_init.c
|
||||||
Initialize a read-write lock attributes object.
|
Initialize a read-write lock attributes object.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern "C" int pthread_rwlockattr_init(pthread_rwlockattr_t* attr)
|
int pthread_rwlockattr_init(pthread_rwlockattr_t* attr)
|
||||||
{
|
{
|
||||||
memset(attr, 0, sizeof(*attr));
|
memset(attr, 0, sizeof(*attr));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_self.c++
|
pthread/pthread_self.c
|
||||||
Returns the identity of the current thread.
|
Returns the identity of the current thread.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" pthread_t pthread_self(void)
|
pthread_t pthread_self(void)
|
||||||
{
|
{
|
||||||
pthread_t current_thread;
|
pthread_t current_thread;
|
||||||
#if defined(__i386__)
|
#if defined(__i386__)
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_setspecific.c++
|
pthread/pthread_setspecific.c
|
||||||
Thread-specific data management.
|
Thread-specific data management.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern "C" int pthread_setspecific(pthread_key_t key, const void* value_const)
|
int pthread_setspecific(pthread_key_t key, const void* value_const)
|
||||||
{
|
{
|
||||||
void* value = (void*) value_const;
|
void* value = (void*) value_const;
|
||||||
|
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
sem_destroy.c++
|
semaphore/sem_destroy.c
|
||||||
Destroy a semaphore.
|
Destroy a semaphore.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
extern "C" int sem_destroy(sem_t* sem)
|
int sem_destroy(sem_t* sem)
|
||||||
{
|
{
|
||||||
(void) sem;
|
(void) sem;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
sem_getvalue.c++
|
semaphore/sem_getvalue.c
|
||||||
Get the value of a semaphore.
|
Get the value of a semaphore.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
extern "C" int sem_getvalue(sem_t* restrict sem, int* restrict value_ptr)
|
int sem_getvalue(sem_t* restrict sem, int* restrict value_ptr)
|
||||||
{
|
{
|
||||||
*value_ptr = __atomic_load_n(&sem->value, __ATOMIC_SEQ_CST);
|
*value_ptr = __atomic_load_n(&sem->value, __ATOMIC_SEQ_CST);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
sem_init.c++
|
semaphore/sem_init.c
|
||||||
Initialize a semaphore.
|
Initialize a semaphore.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
extern "C" int sem_init(sem_t* sem, int pshared, unsigned int value)
|
int sem_init(sem_t* sem, int pshared, unsigned int value)
|
||||||
{
|
{
|
||||||
if ( pshared )
|
if ( pshared )
|
||||||
return errno = ENOSYS, -1;
|
return errno = ENOSYS, -1;
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
sem_post.c++
|
semaphore/sem_post.c
|
||||||
Unlock a semaphore.
|
Unlock a semaphore.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -25,8 +25,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
extern "C" int sem_post(sem_t* sem)
|
int sem_post(sem_t* sem)
|
||||||
{
|
{
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
sem_timedwait.c++
|
semaphore/sem_timedwait.c
|
||||||
Lock a semaphore.
|
Lock a semaphore.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <timespec.h>
|
#include <timespec.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int sem_timedwait(sem_t* restrict sem, const struct timespec* restrict abstime)
|
int sem_timedwait(sem_t* restrict sem, const struct timespec* restrict abstime)
|
||||||
{
|
{
|
||||||
if ( sem_trywait(sem) == 0 )
|
if ( sem_trywait(sem) == 0 )
|
||||||
|
|
@ -2,30 +2,31 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
sem_trywait.c++
|
semaphore/sem_trywait.c
|
||||||
Lock a semaphore.
|
Lock a semaphore.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
extern "C" int sem_trywait(sem_t* sem)
|
int sem_trywait(sem_t* sem)
|
||||||
{
|
{
|
||||||
int old_value = __atomic_load_n(&sem->value, __ATOMIC_SEQ_CST);
|
int old_value = __atomic_load_n(&sem->value, __ATOMIC_SEQ_CST);
|
||||||
if ( old_value <= 0 )
|
if ( old_value <= 0 )
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
sem_wait.c++
|
semaphore/sem_wait.c
|
||||||
Lock a semaphore.
|
Lock a semaphore.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
extern "C" int sem_wait(sem_t* sem)
|
int sem_wait(sem_t* sem)
|
||||||
{
|
{
|
||||||
if ( sem_trywait(sem) == 0 )
|
if ( sem_trywait(sem) == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
Copyright(C) Jonas 'Sortie' Termansen 2014.
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
License for more details.
|
License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pthread_sigmask.c++
|
signal/pthread_sigmask.c
|
||||||
Examine and change blocked signals.
|
Examine and change blocked signals.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C"
|
|
||||||
int pthread_sigmask(int how,
|
int pthread_sigmask(int how,
|
||||||
const sigset_t* restrict set,
|
const sigset_t* restrict set,
|
||||||
sigset_t* restrict oldset)
|
sigset_t* restrict oldset)
|
||||||
2
libpthread/.gitignore
vendored
2
libpthread/.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
||||||
*.a
|
|
||||||
*.o
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
SOFTWARE_MEANT_FOR_SORTIX=1
|
|
||||||
include ../build-aux/platform.mak
|
|
||||||
include ../build-aux/compiler.mak
|
|
||||||
include ../build-aux/version.mak
|
|
||||||
include ../build-aux/dirs.mak
|
|
||||||
|
|
||||||
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
|
|
||||||
CXXFLAGS?=$(OPTLEVEL)
|
|
||||||
CPPFLAGS?=
|
|
||||||
|
|
||||||
CPPFLAGS:=$(CPPFLAGS) -D__is_sortix_libpthread -I include
|
|
||||||
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
|
|
||||||
|
|
||||||
OBJS=\
|
|
||||||
pthread_attr_destroy.o \
|
|
||||||
pthread_attr_getdetachstate.o \
|
|
||||||
pthread_attr_getstacksize.o \
|
|
||||||
pthread_attr_init.o \
|
|
||||||
pthread_attr_setdetachstate.o \
|
|
||||||
pthread_attr_setstacksize.o \
|
|
||||||
pthread_condattr_destroy.o \
|
|
||||||
pthread_condattr_getclock.o \
|
|
||||||
pthread_condattr_init.o \
|
|
||||||
pthread_condattr_setclock.o \
|
|
||||||
pthread_cond_broadcast.o \
|
|
||||||
pthread_cond_destroy.o \
|
|
||||||
pthread_cond_init.o \
|
|
||||||
pthread_cond_signal.o \
|
|
||||||
pthread_cond_timedwait.o \
|
|
||||||
pthread_cond_wait.o \
|
|
||||||
pthread_create.o \
|
|
||||||
pthread_detach.o \
|
|
||||||
pthread_equal.o \
|
|
||||||
pthread_exit.o \
|
|
||||||
pthread_getspecific.o \
|
|
||||||
pthread_initialize.o \
|
|
||||||
pthread_join.o \
|
|
||||||
pthread_key_create.o \
|
|
||||||
pthread_key_delete.o \
|
|
||||||
pthread_mutexattr_destroy.o \
|
|
||||||
pthread_mutexattr_gettype.o \
|
|
||||||
pthread_mutexattr_init.o \
|
|
||||||
pthread_mutexattr_settype.o \
|
|
||||||
pthread_mutex_destroy.o \
|
|
||||||
pthread_mutex_init.o \
|
|
||||||
pthread_mutex_lock.o \
|
|
||||||
pthread_mutex_trylock.o \
|
|
||||||
pthread_mutex_unlock.o \
|
|
||||||
pthread_once.o \
|
|
||||||
pthread_rwlock_destroy.o \
|
|
||||||
pthread_rwlock_init.o \
|
|
||||||
pthread_rwlock_rdlock.o \
|
|
||||||
pthread_rwlock_tryrdlock.o \
|
|
||||||
pthread_rwlock_trywrlock.o \
|
|
||||||
pthread_rwlock_unlock.o \
|
|
||||||
pthread_rwlock_wrlock.o \
|
|
||||||
pthread_self.o \
|
|
||||||
pthread_setspecific.o \
|
|
||||||
pthread_sigmask.o \
|
|
||||||
sem_destroy.o \
|
|
||||||
sem_getvalue.o \
|
|
||||||
sem_init.o \
|
|
||||||
sem_post.o \
|
|
||||||
sem_timedwait.o \
|
|
||||||
sem_trywait.o \
|
|
||||||
sem_wait.o \
|
|
||||||
|
|
||||||
BINS:=libpthread.a
|
|
||||||
|
|
||||||
# Main build rules.
|
|
||||||
all: $(BINS)
|
|
||||||
|
|
||||||
.PHONY: headers clean install install-headers libs install-libs
|
|
||||||
|
|
||||||
headers:
|
|
||||||
|
|
||||||
libs: $(BINS)
|
|
||||||
|
|
||||||
libpthread.a: $(OBJS)
|
|
||||||
$(AR) rcs $@ $(OBJS)
|
|
||||||
|
|
||||||
%.o: %.c++
|
|
||||||
$(CXX) -std=gnu++11 -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(BINS) $(OBJS) *.o
|
|
||||||
|
|
||||||
# Installation into sysroot.
|
|
||||||
install: install-headers install-libs
|
|
||||||
|
|
||||||
install-headers: headers
|
|
||||||
cp -RTv include $(DESTDIR)$(INCLUDEDIR)
|
|
||||||
|
|
||||||
install-libs:
|
|
||||||
mkdir -p $(DESTDIR)$(LIBDIR)
|
|
||||||
cp -P libpthread.a $(DESTDIR)$(LIBDIR)
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
|
||||||
|
|
||||||
This file is part of Sortix libpthread.
|
|
||||||
|
|
||||||
Sortix libpthread is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
option) any later version.
|
|
||||||
|
|
||||||
Sortix libpthread is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
||||||
License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
|
||||||
along with Sortix libpthread. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
pthread_initialize.c++
|
|
||||||
Prepares the process for pthread usage.
|
|
||||||
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include <elf.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
extern "C" { pthread_mutex_t __pthread_keys_lock =
|
|
||||||
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; }
|
|
||||||
extern "C" { struct pthread_key* __pthread_keys = NULL; }
|
|
||||||
extern "C" { size_t __pthread_keys_used = 0; }
|
|
||||||
extern "C" { size_t __pthread_keys_length = 0; }
|
|
||||||
|
|
||||||
// Emit an ELF note containing the size and alignment of struct pthread.
|
|
||||||
__attribute__((used))
|
|
||||||
static void elf_note_sortix_pthread_size()
|
|
||||||
{
|
|
||||||
asm volatile (
|
|
||||||
".pushsection .note.sortix,\"a\",@note\n\t"
|
|
||||||
".align 4\n\t"
|
|
||||||
".long 2f-1f\n\t" // namesz
|
|
||||||
".long 4f-3f\n\t" // descsz
|
|
||||||
".long %c0\n" // type
|
|
||||||
"1:\n\t"
|
|
||||||
".string \"Sortix\"\n" // name
|
|
||||||
"2:\n\t"
|
|
||||||
".align 4\n"
|
|
||||||
"3:\n\t"
|
|
||||||
#if defined(__x86_64__)
|
|
||||||
".quad %c1\n"
|
|
||||||
".quad %c2\n"
|
|
||||||
#elif defined(__i386__)
|
|
||||||
".long %c1\n"
|
|
||||||
".long %c2\n"
|
|
||||||
#endif
|
|
||||||
"4:\n\t"
|
|
||||||
".align 4\n\t"
|
|
||||||
".popsection\n\t"
|
|
||||||
:: "n"(ELF_NOTE_SORTIX_UTHREAD_SIZE),
|
|
||||||
"n"(sizeof(struct pthread)),
|
|
||||||
"n"(alignof(struct pthread))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void pthread_initialize(void)
|
|
||||||
{
|
|
||||||
struct pthread* self = pthread_self();
|
|
||||||
|
|
||||||
self->join_lock = PTHREAD_NORMAL_MUTEX_INITIALIZER_NP;
|
|
||||||
self->join_lock.lock = 1 /* LOCKED_VALUE */;
|
|
||||||
self->join_lock.type = PTHREAD_MUTEX_NORMAL;
|
|
||||||
self->join_lock.owner = (unsigned long) self;
|
|
||||||
self->detach_lock = PTHREAD_NORMAL_MUTEX_INITIALIZER_NP;
|
|
||||||
self->detach_state = PTHREAD_CREATE_JOINABLE;
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue