Add libpthread.
This commit is contained in:
parent
8411dce330
commit
c8a3a858b0
16
Makefile
16
Makefile
|
@ -3,7 +3,19 @@ MAKEFILE_NOT_MEANT_FOR_SORTIX=1
|
|||
include compiler.mak
|
||||
include version.mak
|
||||
|
||||
MODULES=doc libc libm dispd games mkinitrd utils bench ext mbr kernel
|
||||
MODULES=\
|
||||
doc \
|
||||
libc \
|
||||
libm \
|
||||
libpthread \
|
||||
dispd \
|
||||
bench \
|
||||
ext \
|
||||
games \
|
||||
mbr \
|
||||
mkinitrd \
|
||||
utils \
|
||||
kernel
|
||||
|
||||
ifndef SYSROOT
|
||||
SYSROOT:=$(shell pwd)/sysroot
|
||||
|
@ -64,7 +76,7 @@ sysroot-fsh:
|
|||
|
||||
.PHONY: sysroot-base-headers
|
||||
sysroot-base-headers: sysroot-fsh
|
||||
(for D in libc libm kernel; do ($(MAKE) -C $$D install-headers $(SUBMAKE_OPTIONS) DESTDIR="$(SYSROOT)") || exit $$?; done)
|
||||
(for D in libc libm libpthread kernel; do ($(MAKE) -C $$D install-headers $(SUBMAKE_OPTIONS) DESTDIR="$(SYSROOT)") || exit $$?; done)
|
||||
|
||||
.PHONY: sysroot-system
|
||||
sysroot-system: sysroot-fsh sysroot-base-headers
|
||||
|
|
|
@ -455,6 +455,16 @@ large parts of user-land if you update this library.
|
|||
make
|
||||
make install
|
||||
|
||||
### Building the Pthread Library ###
|
||||
|
||||
The Pthread Library (libpthread) provides a threading implementation through the
|
||||
standard header <pthread.h> as known from POSIX. Like the C library, you will
|
||||
likely want to recompile large parts of user-land if you update this library.
|
||||
|
||||
cd /src/libpthread
|
||||
make
|
||||
make install
|
||||
|
||||
### Building the Display Daemon ###
|
||||
|
||||
The dispd library allows processes to communicate with the dispd server that
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||
|
||||
This file is part of Sortix.
|
||||
|
||||
|
@ -27,8 +27,19 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#if __STDC_HOSTED__
|
||||
#include <__/pthread.h>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if __STDC_HOSTED__
|
||||
#ifndef __pthread_attr_t_defined
|
||||
#define __pthread_attr_t_defined
|
||||
typedef __pthread_attr_t pthread_attr_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SIGEV_NONE 0
|
||||
#define SIGEV_SIGNAL 1
|
||||
#define SIGEV_THREAD 2
|
||||
|
@ -45,8 +56,11 @@ struct sigevent
|
|||
int sigev_signo;
|
||||
union sigval sigev_value;
|
||||
void (*sigev_notify_function)(union sigval);
|
||||
/*pthread_attr_t* sigev_notify_attributes;*/
|
||||
#if __STDC_HOSTED__
|
||||
pthread_attr_t* sigev_notify_attributes;
|
||||
#else
|
||||
void* sigev_notify_attributes;
|
||||
#endif
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -586,7 +586,7 @@ ifeq ($(HOST),x86_64-sortix)
|
|||
LIBK_FLAGS:=$(LIBK_FLAGS) -mno-red-zone -mno-mmx -mno-sse -mno-sse2
|
||||
endif
|
||||
|
||||
BINS=libc.a libdl.a libg.a libpthread.a librt.a $(CRTOBJ)
|
||||
BINS=libc.a libdl.a libg.a librt.a $(CRTOBJ)
|
||||
BINSKERNEL=libk.a
|
||||
INSTALLLIBS:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINS))
|
||||
INSTALLLIBSKERNEL:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINSKERNEL))
|
||||
|
@ -614,9 +614,6 @@ libg.a:
|
|||
libk.a: $(LIBK_OBJS)
|
||||
$(HOSTAR) rcs $@ $(LIBK_OBJS)
|
||||
|
||||
libpthread.a:
|
||||
$(HOSTAR) rcs $@
|
||||
|
||||
librt.a:
|
||||
$(HOSTAR) rcs $@
|
||||
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
#define __sortix_libc__ 1
|
||||
|
||||
/* Detect whether we are a core system library. */
|
||||
#if defined(__is_sortix_libc) || defined(__is_sortix_libm)
|
||||
#if defined(__is_sortix_libc) || \
|
||||
defined(__is_sortix_libm) || \
|
||||
defined(__is_sortix_libpthread)
|
||||
#if !defined(__is_sortix_system_library)
|
||||
#define __is_sortix_system_library
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
#include <sys/__/types.h>
|
||||
|
||||
#if __STDC_HOSTED__
|
||||
#include <__/pthread.h>
|
||||
#endif
|
||||
|
||||
#include <sortix/signal.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
@ -55,8 +59,19 @@ typedef __pid_t pid_t;
|
|||
typedef __time_t time_t;
|
||||
#endif
|
||||
|
||||
/* TODO: pthread_t */
|
||||
/* TODO: pthread_attr_t */
|
||||
#if __STDC_HOSTED__
|
||||
|
||||
#ifndef __pthread_attr_t_defined
|
||||
#define __pthread_attr_t_defined
|
||||
typedef __pthread_attr_t pthread_attr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_t_defined
|
||||
#define __pthread_t_defined
|
||||
typedef __pthread_t pthread_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -191,7 +206,8 @@ int kill(pid_t, int);
|
|||
int killpg(pid_t, int);
|
||||
void psiginfo(const siginfo_t*, const char*);
|
||||
void psignal(int, const char*);
|
||||
int pthread_sigmask(int, const sigset_t* __restrict, sigset_t* __restrict);
|
||||
/* TODO: int pthread_kill(pthread_t, int); */
|
||||
/* TODO: int pthread_sigmask(int, const sigset_t* __restrict, sigset_t* __restrict); */
|
||||
int raise(int sig);
|
||||
int sigaction(int, const struct sigaction* __restrict, struct sigaction* __restrict);
|
||||
int sigaddset(sigset_t*, int);
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#include <sys/cdefs.h>
|
||||
|
||||
#include <sys/__/types.h>
|
||||
#if __STDC_HOSTED__
|
||||
#include <__/pthread.h>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
@ -145,8 +148,73 @@ typedef __uid_t uid_t;
|
|||
typedef __useconds_t useconds_t;
|
||||
#endif
|
||||
|
||||
#if !defined(__is_sortix_kernel)
|
||||
/* TODO: pthread*_t */
|
||||
#if __STDC_HOSTED__
|
||||
|
||||
#ifndef __pthread_attr_t_defined
|
||||
#define __pthread_attr_t_defined
|
||||
typedef __pthread_attr_t pthread_attr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_barrier_t_defined
|
||||
#define __pthread_barrier_t_defined
|
||||
typedef __pthread_barrier_t pthread_barrier_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_barrierattr_t_defined
|
||||
#define __pthread_barrierattr_t_defined
|
||||
typedef __pthread_barrierattr_t pthread_barrierattr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_cond_t_defined
|
||||
#define __pthread_cond_t_defined
|
||||
typedef __pthread_cond_t pthread_cond_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_condattr_t_defined
|
||||
#define __pthread_condattr_t_defined
|
||||
typedef __pthread_condattr_t pthread_condattr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_key_t_defined
|
||||
#define __pthread_key_t_defined
|
||||
typedef __pthread_key_t pthread_key_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_mutex_t_defined
|
||||
#define __pthread_mutex_t_defined
|
||||
typedef __pthread_mutex_t pthread_mutex_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_mutexattr_t_defined
|
||||
#define __pthread_mutexattr_t_defined
|
||||
typedef __pthread_mutexattr_t pthread_mutexattr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_once_t_defined
|
||||
#define __pthread_once_t_defined
|
||||
typedef __pthread_once_t pthread_once_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_rwlock_t_defined
|
||||
#define __pthread_rwlock_t_defined
|
||||
typedef __pthread_rwlock_t pthread_rwlock_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_rwlockattr_t_defined
|
||||
#define __pthread_rwlockattr_t_defined
|
||||
typedef __pthread_rwlockattr_t pthread_rwlockattr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_spinlock_t_defined
|
||||
#define __pthread_spinlock_t_defined
|
||||
typedef __pthread_spinlock_t pthread_spinlock_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_t_defined
|
||||
#define __pthread_t_defined
|
||||
typedef __pthread_t pthread_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*******************************************************************************/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C" { char* program_invocation_name; }
|
||||
|
@ -59,6 +60,9 @@ extern "C" void initialize_standard_library(int argc, char* argv[])
|
|||
// It's probably best to initialize the Unix signals early on.
|
||||
init_signal();
|
||||
|
||||
// Initialize pthreads and stuff like thread-local storage.
|
||||
pthread_initialize();
|
||||
|
||||
// Initialize the dynamic heap.
|
||||
_init_heap();
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
*.a
|
||||
*.o
|
|
@ -0,0 +1,44 @@
|
|||
SOFTWARE_MEANT_FOR_SORTIX=1
|
||||
include ../compiler.mak
|
||||
include ../version.mak
|
||||
include ../dirs.mak
|
||||
|
||||
OPTLEVEL?=-O2 -g
|
||||
CXXFLAGS?=$(OPTLEVEL)
|
||||
CPPFLAGS?=
|
||||
|
||||
CPPFLAGS:=$(CPPFLAGS) -D__is_sortix_libpthread -I include
|
||||
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
|
||||
|
||||
OBJS=\
|
||||
pthread_initialize.o \
|
||||
|
||||
BINS:=libpthread.a
|
||||
|
||||
# Main build rules.
|
||||
all: $(BINS)
|
||||
|
||||
.PHONY: headers clean install install-headers libs install-libs
|
||||
|
||||
headers:
|
||||
|
||||
libs: $(BINS)
|
||||
|
||||
libpthread.a: $(OBJS)
|
||||
$(HOSTAR) rcs $@ $(OBJS)
|
||||
|
||||
%.o: %.c++
|
||||
$(HOSTCXX) -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)
|
|
@ -0,0 +1,68 @@
|
|||
/*******************************************************************************
|
||||
|
||||
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.h
|
||||
Thread API.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef INCLUDE____PTHREAD_H
|
||||
#define INCLUDE____PTHREAD_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <sys/__/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __sortix_libpthread__ 1
|
||||
|
||||
typedef int __pthread_attr_t;
|
||||
|
||||
typedef int __pthread_barrier_t;
|
||||
|
||||
typedef int __pthread_barrierattr_t;
|
||||
|
||||
typedef int __pthread_cond_t;
|
||||
|
||||
typedef int __pthread_condattr_t;
|
||||
|
||||
typedef int __pthread_key_t;
|
||||
|
||||
typedef int __pthread_mutex_t;
|
||||
|
||||
typedef int __pthread_mutexattr_t;
|
||||
|
||||
typedef int __pthread_once_t;
|
||||
|
||||
typedef int __pthread_rwlock_t;
|
||||
|
||||
typedef int __pthread_rwlockattr_t;
|
||||
|
||||
typedef int __pthread_spinlock_t;
|
||||
|
||||
#if defined(__is_sortix_libpthread)
|
||||
typedef struct pthread* __pthread_t;
|
||||
#else
|
||||
typedef struct __pthread* __pthread_t;
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
|
@ -0,0 +1,254 @@
|
|||
/*******************************************************************************
|
||||
|
||||
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.h
|
||||
Thread API.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef INCLUDE_PTHREAD_H
|
||||
#define INCLUDE_PTHREAD_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <sys/__/types.h>
|
||||
|
||||
#include <sched.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(__is_sortix_libpthread)
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(__is_sortix_libpthread)
|
||||
#include <sortix/uthread.h>
|
||||
#endif
|
||||
|
||||
#include <__/pthread.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* TODO: #define PTHREAD_BARRIER_SERIAL_THREAD */
|
||||
/* TODO: #define PTHREAD_CANCEL_ASYNCHRONOUS */
|
||||
/* TODO: #define PTHREAD_CANCEL_ENABLE */
|
||||
/* TODO: #define PTHREAD_CANCEL_DEFERRED */
|
||||
/* TODO: #define PTHREAD_CANCEL_DISABLE */
|
||||
/* TODO: #define PTHREAD_CANCELED */
|
||||
/* TODO: #define PTHREAD_CREATE_DETACHED */
|
||||
/* TODO: #define PTHREAD_CREATE_JOINABLE */
|
||||
/* TODO: #define PTHREAD_EXPLICIT_SCHED */
|
||||
/* TODO: #define PTHREAD_INHERIT_SCHED */
|
||||
/* TODO: #define PTHREAD_MUTEX_DEFAULT */
|
||||
/* TODO: #define PTHREAD_MUTEX_ERRORCHECK */
|
||||
/* TODO: #define PTHREAD_MUTEX_NORMAL */
|
||||
/* TODO: #define PTHREAD_MUTEX_RECURSIVE */
|
||||
/* TODO: #define PTHREAD_MUTEX_ROBUST */
|
||||
/* TODO: #define PTHREAD_MUTEX_STALLED */
|
||||
/* TODO: #define PTHREAD_ONCE_INIT */
|
||||
/* TODO: #define PTHREAD_PRIO_INHERIT */
|
||||
/* TODO: #define PTHREAD_PRIO_NONE */
|
||||
/* TODO: #define PTHREAD_PRIO_PROTECT */
|
||||
/* TODO: #define PTHREAD_PROCESS_SHARED */
|
||||
/* TODO: #define PTHREAD_PROCESS_PRIVATE */
|
||||
/* TODO: #define PTHREAD_SCOPE_PROCESS */
|
||||
/* TODO: #define PTHREAD_SCOPE_SYSTEM */
|
||||
|
||||
#ifndef __pthread_attr_t_defined
|
||||
#define __pthread_attr_t_defined
|
||||
typedef __pthread_attr_t pthread_attr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_barrier_t_defined
|
||||
#define __pthread_barrier_t_defined
|
||||
typedef __pthread_barrier_t pthread_barrier_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_barrierattr_t_defined
|
||||
#define __pthread_barrierattr_t_defined
|
||||
typedef __pthread_barrierattr_t pthread_barrierattr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_cond_t_defined
|
||||
#define __pthread_cond_t_defined
|
||||
typedef __pthread_cond_t pthread_cond_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_condattr_t_defined
|
||||
#define __pthread_condattr_t_defined
|
||||
typedef __pthread_condattr_t pthread_condattr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_key_t_defined
|
||||
#define __pthread_key_t_defined
|
||||
typedef __pthread_key_t pthread_key_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_mutex_t_defined
|
||||
#define __pthread_mutex_t_defined
|
||||
typedef __pthread_mutex_t pthread_mutex_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_mutexattr_t_defined
|
||||
#define __pthread_mutexattr_t_defined
|
||||
typedef __pthread_mutexattr_t pthread_mutexattr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_once_t_defined
|
||||
#define __pthread_once_t_defined
|
||||
typedef __pthread_once_t pthread_once_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_rwlock_t_defined
|
||||
#define __pthread_rwlock_t_defined
|
||||
typedef __pthread_rwlock_t pthread_rwlock_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_rwlockattr_t_defined
|
||||
#define __pthread_rwlockattr_t_defined
|
||||
typedef __pthread_rwlockattr_t pthread_rwlockattr_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_spinlock_t_defined
|
||||
#define __pthread_spinlock_t_defined
|
||||
typedef __pthread_spinlock_t pthread_spinlock_t;
|
||||
#endif
|
||||
|
||||
#ifndef __pthread_t_defined
|
||||
#define __pthread_t_defined
|
||||
typedef __pthread_t pthread_t;
|
||||
#endif
|
||||
|
||||
#if defined(__is_sortix_libpthread)
|
||||
struct pthread
|
||||
{
|
||||
struct uthread uthread;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define PTHREAD_COND_INITIALIZER 0
|
||||
#define PTHREAD_MUTEX_INITIALIZER 0
|
||||
#define PTHREAD_RWLOCK_INITIALIZER 0
|
||||
|
||||
void pthread_initialize(void);
|
||||
|
||||
/* TODO: pthread_atfork */
|
||||
/* TODO: pthread_attr_destroy */
|
||||
/* TODO: pthread_attr_getdetachstate */
|
||||
/* TODO: pthread_attr_getguardsize */
|
||||
/* TODO: pthread_attr_getinheritsched */
|
||||
/* TODO: pthread_attr_getschedparam */
|
||||
/* TODO: pthread_attr_getschedpolicy */
|
||||
/* TODO: pthread_attr_getscope */
|
||||
/* TODO: pthread_attr_getstack */
|
||||
/* TODO: pthread_attr_getstacksize */
|
||||
/* TODO: pthread_attr_init */
|
||||
/* TODO: pthread_attr_setdetachstate */
|
||||
/* TODO: pthread_attr_setguardsize */
|
||||
/* TODO: pthread_attr_setinheritsched */
|
||||
/* TODO: pthread_attr_setschedparam */
|
||||
/* TODO: pthread_attr_setschedpolicy */
|
||||
/* TODO: pthread_attr_setscope */
|
||||
/* TODO: pthread_attr_setstack */
|
||||
/* TODO: pthread_attr_setstacksize */
|
||||
/* TODO: pthread_barrier_destroy */
|
||||
/* TODO: pthread_barrier_init */
|
||||
/* TODO: pthread_barrier_wait */
|
||||
/* TODO: pthread_barrierattr_destroy */
|
||||
/* TODO: pthread_barrierattr_getpshared */
|
||||
/* TODO: pthread_barrierattr_init */
|
||||
/* TODO: pthread_barrierattr_setpshared */
|
||||
/* TODO: pthread_cancel */
|
||||
/* TODO: pthread_cleanup_pop */
|
||||
/* TODO: pthread_cleanup_push */
|
||||
/* TODO: pthread_cond_broadcast */
|
||||
/* TODO: pthread_cond_destroy */
|
||||
/* TODO: pthread_cond_init */
|
||||
/* TODO: pthread_cond_signal */
|
||||
/* TODO: pthread_cond_timedwait */
|
||||
/* TODO: pthread_cond_wait */
|
||||
/* TODO: pthread_condattr_destroy */
|
||||
/* TODO: pthread_condattr_getclock */
|
||||
/* TODO: pthread_condattr_getpshared */
|
||||
/* TODO: pthread_condattr_init */
|
||||
/* TODO: pthread_condattr_setclock */
|
||||
/* TODO: pthread_condattr_setpshared */
|
||||
/* TODO: pthread_create */
|
||||
/* TODO: pthread_detach */
|
||||
/* TODO: pthread_equal */
|
||||
/* TODO: pthread_exit */
|
||||
/* TODO: pthread_getconcurrency */
|
||||
/* TODO: pthread_getcpuclockid */
|
||||
/* TODO: pthread_getschedparam */
|
||||
/* TODO: pthread_getspecific */
|
||||
/* TODO: pthread_join */
|
||||
/* TODO: pthread_key_create */
|
||||
/* TODO: pthread_key_delete */
|
||||
/* TODO: pthread_mutex_consistent */
|
||||
/* TODO: pthread_mutex_destroy */
|
||||
/* TODO: pthread_mutex_getprioceiling */
|
||||
/* TODO: pthread_mutex_init */
|
||||
/* TODO: pthread_mutex_lock */
|
||||
/* TODO: pthread_mutex_setprioceiling */
|
||||
/* TODO: pthread_mutex_timedlock */
|
||||
/* TODO: pthread_mutex_trylock */
|
||||
/* TODO: pthread_mutex_unlock */
|
||||
/* TODO: pthread_mutexattr_destroy */
|
||||
/* TODO: pthread_mutexattr_getprioceiling */
|
||||
/* TODO: pthread_mutexattr_getprotocol */
|
||||
/* TODO: pthread_mutexattr_getpshared */
|
||||
/* TODO: pthread_mutexattr_getrobust */
|
||||
/* TODO: pthread_mutexattr_gettype */
|
||||
/* TODO: pthread_mutexattr_init */
|
||||
/* TODO: pthread_mutexattr_setprioceiling */
|
||||
/* TODO: pthread_mutexattr_setprotocol */
|
||||
/* TODO: pthread_mutexattr_setpshared */
|
||||
/* TODO: pthread_mutexattr_setrobust */
|
||||
/* TODO: pthread_mutexattr_settype */
|
||||
/* TODO: pthread_once */
|
||||
/* TODO: pthread_rwlock_destroy */
|
||||
/* TODO: pthread_rwlock_init */
|
||||
/* TODO: pthread_rwlock_rdlock */
|
||||
/* TODO: pthread_rwlock_timedrdlock */
|
||||
/* TODO: pthread_rwlock_timedwrlock */
|
||||
/* TODO: pthread_rwlock_tryrdlock */
|
||||
/* TODO: pthread_rwlock_trywrlock */
|
||||
/* TODO: pthread_rwlock_unlock */
|
||||
/* TODO: pthread_rwlock_wrlock */
|
||||
/* TODO: pthread_rwlockattr_destroy */
|
||||
/* TODO: pthread_rwlockattr_getpshared */
|
||||
/* TODO: pthread_rwlockattr_init */
|
||||
/* TODO: pthread_rwlockattr_setpshared */
|
||||
/* TODO: pthread_self */
|
||||
/* TODO: pthread_setcancelstate */
|
||||
/* TODO: pthread_setcanceltype */
|
||||
/* TODO: pthread_setconcurrency */
|
||||
/* TODO: pthread_setschedparam */
|
||||
/* TODO: pthread_setschedprio */
|
||||
/* TODO: pthread_setspecific */
|
||||
/* TODO: pthread_spin_destroy */
|
||||
/* TODO: pthread_spin_init */
|
||||
/* TODO: pthread_spin_lock */
|
||||
/* TODO: pthread_spin_trylock */
|
||||
/* TODO: pthread_spin_unlock */
|
||||
/* TODO: pthread_testcancel */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
|
@ -0,0 +1,69 @@
|
|||
/*******************************************************************************
|
||||
|
||||
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 <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sortix/elf-note.h>
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
|
@ -19,6 +19,7 @@ clean:
|
|||
$(MAKE) -B -C $(SRCDIR)/doc clean
|
||||
$(MAKE) -B -C $(SRCDIR)/libc clean
|
||||
$(MAKE) -B -C $(SRCDIR)/libm clean
|
||||
$(MAKE) -B -C $(SRCDIR)/libpthread clean
|
||||
$(MAKE) -B -C $(SRCDIR)/dispd clean
|
||||
$(MAKE) -B -C $(SRCDIR)/bench clean
|
||||
$(MAKE) -B -C $(SRCDIR)/games clean
|
||||
|
@ -57,6 +58,7 @@ system-headers_internal:
|
|||
$(MAKE) -B -C $(SRCDIR)/kernel install-headers DESTDIR=$(ROOT)
|
||||
$(MAKE) -B -C $(SRCDIR)/libc install-headers DESTDIR=$(ROOT)
|
||||
$(MAKE) -B -C $(SRCDIR)/libm install-headers DESTDIR=$(ROOT)
|
||||
$(MAKE) -B -C $(SRCDIR)/libpthread install-headers DESTDIR=$(ROOT)
|
||||
|
||||
# Rebuild and install the entire system.
|
||||
system:
|
||||
|
@ -65,6 +67,7 @@ system:
|
|||
$(MAKE) -B -C $(SRCDIR)/doc install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||
$(MAKE) -B -C $(SRCDIR)/libc install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||
$(MAKE) -B -C $(SRCDIR)/libm install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||
$(MAKE) -B -C $(SRCDIR)/libpthread install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||
$(MAKE) -B -C $(SRCDIR)/dispd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||
$(MAKE) -B -C $(SRCDIR)/games install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||
$(MAKE) -B -C $(SRCDIR)/mkinitrd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||
|
|
Loading…
Reference in New Issue