Merge pthread into libc library

The pthread API is considered a standard feature of libc so better to
simply merge it with the libc. Pthreads are in fact already a part of
the libc in the form of weak symbols. This merger is also a prerequisite
for better integrating pthreads with the libc I/O task.

Fix #3054
This commit is contained in:
Emery Hemingway 2018-11-21 17:17:25 +01:00 committed by Christian Helmuth
parent fe322b8e82
commit 7a11384177
60 changed files with 178 additions and 170 deletions

View File

@ -104,7 +104,7 @@ install_config $config
# generic modules # generic modules
set boot_modules { set boot_modules {
core ld.lib.so init timer usb_drv core ld.lib.so init timer usb_drv
libc.lib.so vfs.lib.so libc_pipe.lib.so lwip_legacy.lib.so pthread.lib.so libc.lib.so vfs.lib.so libc_pipe.lib.so lwip_legacy.lib.so
tcp_terminal tcp_terminal
test-terminal_echo test-terminal_echo
vfs_lwip.lib.so vfs_lwip.lib.so

View File

@ -143,7 +143,7 @@ set boot_modules {
core ld.lib.so init timer nic_drv rtc_drv report_rom core ld.lib.so init timer nic_drv rtc_drv report_rom
noux test-terminal_echo noux test-terminal_echo
libc.lib.so pthread.lib.so libm.lib.so vfs.lib.so libc.lib.so libm.lib.so vfs.lib.so
vfs_lxip.lib.so lxip.lib.so libc_pipe.lib.so libc_noux.lib.so vfs_lxip.lib.so lxip.lib.so libc_pipe.lib.so libc_noux.lib.so
posix.lib.so libcrypto.lib.so libssh.lib.so zlib.lib.so ncurses.lib.so posix.lib.so libcrypto.lib.so libssh.lib.so zlib.lib.so ncurses.lib.so
vfs_jitterentropy.lib.so ssh_terminal vfs_jitterentropy.lib.so ssh_terminal

View File

@ -90,7 +90,7 @@ install_config $config
set boot_modules { set boot_modules {
core ld.lib.so init timer core ld.lib.so init timer
nic_drv nic_drv
libc.lib.so vfs.lib.so pthread.lib.so lwip_legacy.lib.so libc_pipe.lib.so libc.lib.so vfs.lib.so lwip_legacy.lib.so libc_pipe.lib.so
tcp_terminal tcp_terminal
test-terminal_echo test-terminal_echo
vfs_lwip.lib.so vfs_lwip.lib.so

View File

@ -99,7 +99,6 @@ void Depot_download_manager::gen_fetchurl_start_content(Xml_generator &xml,
gen_parent_rom_route(xml, "libcrypto.lib.so"); gen_parent_rom_route(xml, "libcrypto.lib.so");
gen_parent_rom_route(xml, "vfs.lib.so"); gen_parent_rom_route(xml, "vfs.lib.so");
gen_parent_rom_route(xml, "zlib.lib.so"); gen_parent_rom_route(xml, "zlib.lib.so");
gen_parent_rom_route(xml, "pthread.lib.so");
gen_parent_route<Cpu_session> (xml); gen_parent_route<Cpu_session> (xml);
gen_parent_route<Pd_session> (xml); gen_parent_route<Pd_session> (xml);
gen_parent_route<Log_session> (xml); gen_parent_route<Log_session> (xml);

View File

@ -78,7 +78,6 @@ void Depot_download_manager::gen_verify_start_content(Xml_generator &xml,
gen_parent_unscoped_rom_route(xml, "ld.lib.so"); gen_parent_unscoped_rom_route(xml, "ld.lib.so");
gen_parent_rom_route(xml, "libc.lib.so"); gen_parent_rom_route(xml, "libc.lib.so");
gen_parent_rom_route(xml, "libm.lib.so"); gen_parent_rom_route(xml, "libm.lib.so");
gen_parent_rom_route(xml, "pthread.lib.so");
gen_parent_rom_route(xml, "vfs.lib.so"); gen_parent_rom_route(xml, "vfs.lib.so");
gen_parent_route<Cpu_session> (xml); gen_parent_route<Cpu_session> (xml);
gen_parent_route<Pd_session> (xml); gen_parent_route<Pd_session> (xml);

View File

@ -54,7 +54,6 @@ void Sculpt::gen_update_start_content(Xml_generator &xml)
gen_parent_rom_route(xml, "zlib.lib.so"); gen_parent_rom_route(xml, "zlib.lib.so");
gen_parent_rom_route(xml, "libarchive.lib.so"); gen_parent_rom_route(xml, "libarchive.lib.so");
gen_parent_rom_route(xml, "liblzma.lib.so"); gen_parent_rom_route(xml, "liblzma.lib.so");
gen_parent_rom_route(xml, "pthread.lib.so");
gen_parent_rom_route(xml, "config", "depot_download.config"); gen_parent_rom_route(xml, "config", "depot_download.config");
gen_parent_rom_route(xml, "installation", "config -> managed/installation"); gen_parent_rom_route(xml, "installation", "config -> managed/installation");
gen_parent_route<Cpu_session> (xml); gen_parent_route<Cpu_session> (xml);

View File

@ -1,5 +1,5 @@
TARGET = ssh_terminal TARGET = ssh_terminal
SRC_CC = main.cc SRC_CC = main.cc
LIBS = base libc pthread libssh libc_pipe LIBS = base libc libssh libc_pipe
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -1,5 +1,5 @@
TARGET = tcp_terminal TARGET = tcp_terminal
SRC_CC = main.cc SRC_CC = main.cc
LIBS = libc pthread libc_pipe LIBS = libc libc_pipe
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -1,5 +1,5 @@
SHARED_LIB = yes SHARED_LIB = yes
LIBS = libc egl i965 pthread LIBS = libc egl i965
include $(REP_DIR)/lib/mk/mesa-common.inc include $(REP_DIR)/lib/mk/mesa-common.inc

View File

@ -90,7 +90,7 @@ CC_OPT += -D__intptr_t_defined
CC_WARN += -Wno-deprecated-declarations CC_WARN += -Wno-deprecated-declarations
LIBS = stdcxx pthread LIBS = stdcxx
vpath % $(ICU_DIR)/source/common vpath % $(ICU_DIR)/source/common
vpath % $(ICU_DIR)/source/i18n vpath % $(ICU_DIR)/source/i18n

View File

@ -19,6 +19,12 @@ SRC_CC = atexit.cc dummies.cc rlimit.cc sysctl.cc \
socket_operations.cc task.cc socket_fs_plugin.cc syscall.cc \ socket_operations.cc task.cc socket_fs_plugin.cc syscall.cc \
getpwent.cc getpwent.cc
#
# Pthreads
#
SRC_CC += semaphore.cc rwlock.cc \
thread.cc thread_create.cc
CC_OPT_sysctl += -Wno-write-strings CC_OPT_sysctl += -Wno-write-strings
INC_DIR += $(REP_DIR)/src/lib/libc INC_DIR += $(REP_DIR)/src/lib/libc
@ -43,5 +49,3 @@ vpath % $(LIBC_DIR)/lib/libc/string
# #
SHARED_LIB = yes SHARED_LIB = yes
LD_OPT += --version-script=$(REP_DIR)/src/lib/libc/Version.def LD_OPT += --version-script=$(REP_DIR)/src/lib/libc/Version.def
CC_CXX_WARN_STRICT =

View File

@ -1,5 +1,5 @@
LIBUSB_DIR := $(call select_from_ports,libusb)/src/lib/libusb LIBUSB_DIR := $(call select_from_ports,libusb)/src/lib/libusb
LIBS += libc libc_pipe pthread LIBS += libc libc_pipe
# find 'config.h' # find 'config.h'
INC_DIR += $(REP_DIR)/src/lib/libusb INC_DIR += $(REP_DIR)/src/lib/libusb

View File

@ -1,5 +1,5 @@
SHARED_LIB = yes SHARED_LIB = yes
LIBS = libc stdcxx expat glapi pthread mesa_api LIBS = libc stdcxx expat glapi mesa_api
include $(REP_DIR)/lib/mk/mesa-common.inc include $(REP_DIR)/lib/mk/mesa-common.inc

View File

@ -1,12 +0,0 @@
SRC_CC = semaphore.cc rwlock.cc \
thread.cc thread_create.cc
LIBS += libc
INC_DIR += $(REP_DIR)/src/lib
vpath % $(REP_DIR)/src/lib/pthread
SHARED_LIB = yes
CC_CXX_WARN_STRICT =

View File

@ -29,6 +29,6 @@ include $(REP_DIR)/lib/mk/qt5.inc
SRC_CC += libc_dummies.cc SRC_CC += libc_dummies.cc
vpath libc_dummies.cc $(REP_DIR)/src/lib/qt5 vpath libc_dummies.cc $(REP_DIR)/src/lib/qt5
LIBS += zlib pcre16 libc libm libc_pipe pthread LIBS += zlib pcre16 libc libm libc_pipe
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -17,6 +17,6 @@ QT_INCPATH += qtwebkit/Source/JavaScriptCore/generated
include $(REP_DIR)/lib/mk/qt5.inc include $(REP_DIR)/lib/mk/qt5.inc
LIBS += qt5_network qt5_core icu pthread libc libm LIBS += qt5_network qt5_core icu libc libm
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -82,7 +82,7 @@ SRC_C += cdrom/SDL_cdrom.c \
INC_DIR += $(SDL_DIR)/src/cdrom INC_DIR += $(SDL_DIR)/src/cdrom
# we need libc # we need libc
LIBS = libc pthread mesa_api LIBS = libc mesa_api
# backend path # backend path
vpath % $(REP_DIR)/src/lib/sdl vpath % $(REP_DIR)/src/lib/sdl

View File

@ -494,65 +494,71 @@ pread T
printf T printf T
pselect W pselect W
psignal T psignal T
pthread_atfork W pthread_atfork T
pthread_attr_destroy W pthread_attr_destroy T
pthread_attr_getdetachstate W pthread_attr_getdetachstate T
pthread_attr_getguardsize W pthread_attr_getguardsize T
pthread_attr_getinheritsched W pthread_attr_getinheritsched T
pthread_attr_getschedparam W pthread_attr_get_np T
pthread_attr_getschedpolicy W pthread_attr_getschedparam T
pthread_attr_getscope W pthread_attr_getschedpolicy T
pthread_attr_getstackaddr W pthread_attr_getscope T
pthread_attr_getstacksize W pthread_attr_getstack T
pthread_attr_init W pthread_attr_getstackaddr T
pthread_attr_setdetachstate W pthread_attr_getstacksize T
pthread_attr_setguardsize W pthread_attr_init T
pthread_attr_setinheritsched W pthread_attr_setdetachstate T
pthread_attr_setschedparam W pthread_attr_setguardsize T
pthread_attr_setschedpolicy W pthread_attr_setinheritsched T
pthread_attr_setscope W pthread_attr_setschedparam T
pthread_attr_setstackaddr W pthread_attr_setschedpolicy T
pthread_attr_setstacksize W pthread_attr_setscope T
pthread_cleanup_pop W pthread_attr_setstackaddr T
pthread_cleanup_push W pthread_attr_setstacksize T
pthread_cond_broadcast W pthread_cancel T
pthread_cond_destroy W pthread_cleanup_pop T
pthread_cond_init W pthread_cleanup_push T
pthread_cond_signal W pthread_cond_broadcast T
pthread_cond_timedwait W pthread_cond_destroy T
pthread_cond_wait W pthread_cond_init T
pthread_cond_signal T
pthread_cond_timedwait T
pthread_cond_wait T
pthread_condattr_destroy T
pthread_condattr_init T
pthread_condattr_setclock T
pthread_create W pthread_create W
pthread_detach W pthread_detach T
pthread_equal W pthread_equal T
pthread_exit W pthread_exit T
pthread_getspecific W pthread_getspecific T
pthread_join W pthread_join T
pthread_key_create W pthread_key_create T
pthread_key_delete W pthread_key_delete T
pthread_kill W pthread_kill T
pthread_main_np W pthread_main_np T
pthread_mutex_destroy W pthread_mutex_destroy T
pthread_mutex_init W pthread_mutex_init T
pthread_mutex_lock W pthread_mutex_lock T
pthread_mutex_trylock W pthread_mutex_trylock T
pthread_mutex_unlock W pthread_mutex_unlock T
pthread_mutexattr_destroy W pthread_mutexattr_destroy T
pthread_mutexattr_init W pthread_mutexattr_init T
pthread_mutexattr_settype W pthread_mutexattr_settype T
pthread_once W pthread_once T
pthread_rwlock_destroy W pthread_rwlock_destroy T
pthread_rwlock_init W pthread_rwlock_init T
pthread_rwlock_rdlock W pthread_rwlock_rdlock T
pthread_rwlock_tryrdlock W pthread_rwlock_tryrdlock T
pthread_rwlock_trywrlock W pthread_rwlock_trywrlock T
pthread_rwlock_unlock W pthread_rwlock_unlock T
pthread_rwlock_wrlock W pthread_rwlock_wrlock T
pthread_self W pthread_self T
pthread_setcancelstate W pthread_setcancelstate T
pthread_setcanceltype W pthread_setcanceltype T
pthread_setspecific W pthread_setspecific T
pthread_sigmask W pthread_sigmask T
pthread_testcancel W pthread_testcancel T
ptsname T ptsname T
putc T putc T
putc_unlocked T putc_unlocked T
@ -607,9 +613,19 @@ sched_yield W
seed48 T seed48 T
seekdir T seekdir T
select W select W
sem_close T
semctl T semctl T
sem_destroy T
sem_getvalue T
semget W semget W
sem_init T
sem_open T
semop W semop W
sem_post T
sem_timedwait T
sem_trywait T
sem_unlink T
sem_wait T
send T send T
sendto T sendto T
setbuf T setbuf T
@ -914,7 +930,6 @@ _CurrentRuneLocale D 8
__isinff T __isinff T
__isinfl T __isinfl T
# #
# Public interface between Genode-component code and the libc runtime # Public interface between Genode-component code and the libc runtime
# #
@ -928,6 +943,11 @@ _ZN4Libc19Select_handler_baseD1Ev T
_ZN4Libc19Select_handler_baseD2Ev T _ZN4Libc19Select_handler_baseD2Ev T
_ZN4Libc10resume_allEv T _ZN4Libc10resume_allEv T
_ZN4Libc7suspendERNS_15Suspend_functorEm T _ZN4Libc7suspendERNS_15Suspend_functorEm T
_Z16pthread_registryv T
_ZN16Pthread_registry6insertEP7pthread T
_ZN16Pthread_registry6removeEP7pthread T
_ZN16Pthread_registry8containsEP7pthread T
_ZN4Libc14pthread_createEPP7pthreadPFPvS3_ES3_mPKcPN6Genode11Cpu_sessionENS8_8Affinity8LocationE T
# #
# Libc plugin interface # Libc plugin interface

View File

@ -1 +1 @@
5a5de5baab6e3ce23f24012a7604abf070fa990c c9cbd0d0fe35cc19c71295a02d67ecbe09a14573

View File

@ -1,8 +1,6 @@
MIRROR_FROM_REP_DIR := lib/import/import-libc.mk \ MIRROR_FROM_REP_DIR := lib/import/import-libc.mk \
lib/symbols/libc \ lib/symbols/libc \
lib/symbols/libm \ lib/symbols/libm \
lib/mk/pthread.mk \
src/lib/pthread
content: $(MIRROR_FROM_REP_DIR) content: $(MIRROR_FROM_REP_DIR)

View File

@ -20,7 +20,6 @@
<rom label="libpng.lib.so"/> <rom label="libpng.lib.so"/>
<rom label="mesa.lib.so"/> <rom label="mesa.lib.so"/>
<rom label="pcre16.lib.so"/> <rom label="pcre16.lib.so"/>
<rom label="pthread.lib.so"/>
<rom label="qt5_core.lib.so"/> <rom label="qt5_core.lib.so"/>
<rom label="qt5_dejavusans.tar"/> <rom label="qt5_dejavusans.tar"/>
<rom label="qt5_gui.lib.so"/> <rom label="qt5_gui.lib.so"/>

View File

@ -12,7 +12,6 @@
<rom label="vfs.lib.so"/> <rom label="vfs.lib.so"/>
<rom label="libm.lib.so"/> <rom label="libm.lib.so"/>
<rom label="libc_pipe.lib.so"/> <rom label="libc_pipe.lib.so"/>
<rom label="pthread.lib.so"/>
<rom label="posix.lib.so"/> <rom label="posix.lib.so"/>
<rom label="test-libc_pipe"/> <rom label="test-libc_pipe"/>
</content> </content>

View File

@ -12,7 +12,6 @@
<rom label="libm.lib.so"/> <rom label="libm.lib.so"/>
<rom label="posix.lib.so"/> <rom label="posix.lib.so"/>
<rom label="vfs.lib.so"/> <rom label="vfs.lib.so"/>
<rom label="pthread.lib.so"/>
<rom label="test-pthread"/> <rom label="test-pthread"/>
</content> </content>

View File

@ -113,7 +113,7 @@ install_config $config
append boot_modules { append boot_modules {
core init timer } [audio_drv_binary] { avplay core init timer } [audio_drv_binary] { avplay
ld.lib.so libc.lib.so vfs.lib.so vfs.lib.so vfs.lib.so libm.lib.so pthread.lib.so zlib.lib.so sdl.lib.so ld.lib.so libc.lib.so vfs.lib.so vfs.lib.so vfs.lib.so libm.lib.so zlib.lib.so sdl.lib.so
avfilter.lib.so avutil.lib.so avcodec.lib.so avformat.lib.so swscale.lib.so avfilter.lib.so avutil.lib.so avcodec.lib.so avformat.lib.so swscale.lib.so
avresample.lib.so avresample.lib.so
mediafile mediafile

View File

@ -110,7 +110,6 @@ set boot_modules {
libcrypto.lib.so libcrypto.lib.so
libssh.lib.so libssh.lib.so
libssl.lib.so libssl.lib.so
pthread.lib.so
timer timer
zlib.lib.so zlib.lib.so
report_rom report_rom

View File

@ -68,7 +68,7 @@ install_config $config
set boot_modules { set boot_modules {
core init timer terminal_crosslink core init timer terminal_crosslink
test-libc_counter-source test-libc_select test-libc_counter-source test-libc_select
ld.lib.so libc.lib.so vfs.lib.so libm.lib.so stdcxx.lib.so pthread.lib.so ld.lib.so libc.lib.so vfs.lib.so libm.lib.so stdcxx.lib.so
libc_pipe.lib.so posix.lib.so libc_pipe.lib.so posix.lib.so
} }

View File

@ -77,7 +77,7 @@ install_config $config
set boot_modules { set boot_modules {
core init timer terminal_crosslink vfs core init timer terminal_crosslink vfs
test-libc_counter-source test-libc_select test-libc_counter-source test-libc_select
ld.lib.so libc.lib.so vfs.lib.so libm.lib.so stdcxx.lib.so pthread.lib.so ld.lib.so libc.lib.so vfs.lib.so libm.lib.so stdcxx.lib.so
libc_pipe.lib.so posix.lib.so libc_pipe.lib.so posix.lib.so
} }

View File

@ -179,7 +179,7 @@ set boot_modules {
core init ld.lib.so timer nitpicker pointer liquid_fb core init ld.lib.so timer nitpicker pointer liquid_fb
launchpad launchpad
libc.lib.so vfs.lib.so libm.lib.so pthread.lib.so libc.lib.so vfs.lib.so libm.lib.so
egl.lib.so mesa.lib.so stdcxx.lib.so egl.lib.so mesa.lib.so stdcxx.lib.so
expat.lib.so glapi.lib.so expat.lib.so glapi.lib.so

View File

@ -85,7 +85,7 @@ set boot_modules {
core init core init
timer timer
test-sdl test-sdl
ld.lib.so libc.lib.so vfs.lib.so libm.lib.so sdl.lib.so pthread.lib.so ld.lib.so libc.lib.so vfs.lib.so libm.lib.so sdl.lib.so
} }
# platform-specific modules # platform-specific modules

View File

@ -112,7 +112,7 @@ install_config $config
set boot_modules { set boot_modules {
core init timer usb_drv test-smartcard core init timer usb_drv test-smartcard
ld.lib.so pcsc-lite.lib.so ccid.lib.so libusb.lib.so ld.lib.so pcsc-lite.lib.so ccid.lib.so libusb.lib.so
libc.lib.so vfs.lib.so libm.lib.so libc_pipe.lib.so pthread.lib.so posix.lib.so libc.lib.so vfs.lib.so libm.lib.so libc_pipe.lib.so posix.lib.so
Info.plist Info.plist
} }

View File

@ -1,3 +1,3 @@
TARGET = fetchurl TARGET = fetchurl
LIBS += curl libc ld pthread LIBS += curl libc ld
SRC_CC = component.cc SRC_CC = component.cc

View File

@ -91,7 +91,6 @@ DUMMY(void *, 0, ___mtctxres, (void))
DUMMY(void *, 0, __nsdefaultsrc, (void)) DUMMY(void *, 0, __nsdefaultsrc, (void))
DUMMY(int , -1, _nsdispatch, (void)) DUMMY(int , -1, _nsdispatch, (void))
DUMMY(long , -1, pathconf, (const char *, int)) DUMMY(long , -1, pathconf, (const char *, int))
DUMMY(int , -1, pthread_create, (pthread_t *, const pthread_attr_t *, void *(*)(void *), void *))
DUMMY(int , -1, rmdir, (const char *)) DUMMY(int , -1, rmdir, (const char *))
DUMMY(void *, 0, sbrk, (intptr_t)) DUMMY(void *, 0, sbrk, (intptr_t))
DUMMY(int , -1, sched_setparam, (pid_t, const sched_param *)) DUMMY(int , -1, sched_setparam, (pid_t, const sched_param *))

View File

@ -1,10 +0,0 @@
+++ src/lib/libc/lib/libc/gen/_pthread_stubs.c
@@ -253,7 +253,7 @@
STUB_FUNC2(pthread_attr_setschedparam, PJT_ATTR_SETSCHEDPARAM, int, void *, void *)
STUB_FUNC2(pthread_attr_setschedpolicy, PJT_ATTR_SETSCHEDPOLICY, int, void *, int)
STUB_FUNC2(pthread_attr_setscope, PJT_ATTR_SETSCOPE, int, void *, int)
-STUB_FUNC1(pthread_cancel, PJT_CANCEL, int, void *)
+/* STUB_FUNC1(pthread_cancel, PJT_CANCEL, int, void *) */
STUB_FUNC1(pthread_cleanup_pop, PJT_CLEANUP_POP, int, int)
STUB_FUNC2(pthread_cleanup_push, PJT_CLEANUP_PUSH, void, void *, void *)
STUB_FUNC3(pthread_cond_timedwait, PJT_COND_TIMEDWAIT, int, void *, void *, void *)

View File

@ -22,8 +22,7 @@
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> /* malloc, free */ #include <stdlib.h> /* malloc, free */
#include "thread.h" #include "thread.h"
#include "task.h"
#include <libc/task.h> /* libc suspend/resume */
using namespace Genode; using namespace Genode;

View File

@ -14,11 +14,28 @@
* under the terms of the GNU Affero General Public License version 3. * under the terms of the GNU Affero General Public License version 3.
*/ */
#include <base/thread.h> #include "thread_create.h"
#include <errno.h>
#include <pthread.h>
#include "thread.h" #include "thread.h"
#include <errno.h>
int Libc::pthread_create(pthread_t *thread,
void *(*start_routine) (void *), void *arg,
size_t stack_size, char const * name,
Genode::Cpu_session * cpu, Genode::Affinity::Location location)
{
pthread_t thread_obj = new pthread(start_routine, arg,
stack_size, name, cpu, location);
if (!thread_obj)
return EAGAIN;
*thread = thread_obj;
thread_obj->start();
return 0;
}
extern "C" extern "C"
{ {
@ -29,17 +46,8 @@ extern "C"
? (*attr)->stack_size ? (*attr)->stack_size
: Libc::Component::stack_size(); : Libc::Component::stack_size();
pthread_t thread_obj = new pthread(start_routine, arg, stack_size, return Libc::pthread_create(thread, start_routine, arg, stack_size,
"pthread", nullptr, "pthread", nullptr,
Genode::Affinity::Location()); Genode::Affinity::Location());
if (!thread_obj)
return EAGAIN;
*thread = thread_obj;
thread_obj->start();
return 0;
} }
} }

View File

@ -0,0 +1,24 @@
/*
* \brief Create custom pthreads with native CPU sessions and affinities
* \author Emery Hemingway
* \date 2018-11-22
*
* The Libc::pthread_create symbol is exported for the sake of Vbox
*/
/*
* Copyright (C) 2018 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <pthread.h>
#include <base/thread.h>
namespace Libc {
int pthread_create(pthread_t *thread,
void *(*start_routine) (void *), void *arg,
size_t stack_size, char const * name,
Genode::Cpu_session * cpu, Genode::Affinity::Location location);
}

View File

@ -1,5 +1,5 @@
TARGET = test-libc_pipe TARGET = test-libc_pipe
LIBS = base posix libc_pipe pthread LIBS = base posix libc_pipe
SRC_CC = main.cc SRC_CC = main.cc
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -1,5 +1,5 @@
TARGET = test-libc_select TARGET = test-libc_select
SRC_CC = main.cc SRC_CC = main.cc
LIBS = posix stdcxx pthread libc_pipe LIBS = posix stdcxx libc_pipe
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -1,5 +1,5 @@
TARGET = test-pthread TARGET = test-pthread
SRC_CC = main.cc SRC_CC = main.cc
LIBS = base posix pthread LIBS = base posix
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -2,7 +2,7 @@
# /build/jdk/openjdk-jdk9-jdk9/build/linux-x86_64-normal-zero-release/hotspot/variant-zero/gensrc/jvmtifiles/jvmtiEnter.cpp # /build/jdk/openjdk-jdk9-jdk9/build/linux-x86_64-normal-zero-release/hotspot/variant-zero/gensrc/jvmtifiles/jvmtiEnter.cpp
# /build/jdk/openjdk-jdk9-jdk9/build/linux-x86_64-normal-zero-release/hotspot/variant-zero/gensrc/jvmtifiles/jvmtiEnterTrace.cpp # /build/jdk/openjdk-jdk9-jdk9/build/linux-x86_64-normal-zero-release/hotspot/variant-zero/gensrc/jvmtifiles/jvmtiEnterTrace.cpp
LIBS = stdcxx pthread jzip jimage nio jnet ffi LIBS = stdcxx jzip jimage nio jnet ffi
SHARED_LIB = yes SHARED_LIB = yes
HOTSPOT_BASE = $(call select_from_ports,jdk)/src/app/jdk/hotspot/src HOTSPOT_BASE = $(call select_from_ports,jdk)/src/app/jdk/hotspot/src
JDK_GENERATED = $(call select_from_ports,jdk_generated)/src/app/jdk JDK_GENERATED = $(call select_from_ports,jdk_generated)/src/app/jdk

View File

@ -11,7 +11,6 @@ LIBS += stdcxx
SRC_CC = sup.cc pgm.cc SRC_CC = sup.cc pgm.cc
INC_DIR += $(call select_from_repositories,src/lib/libc) INC_DIR += $(call select_from_repositories,src/lib/libc)
INC_DIR += $(call select_from_repositories,src/lib/pthread)
INC_DIR += $(VBOX_DIR)/Main/xml INC_DIR += $(VBOX_DIR)/Main/xml
INC_DIR += $(VBOX_DIR)/Main/include INC_DIR += $(VBOX_DIR)/Main/include

View File

@ -5,7 +5,6 @@ LIBS += stdcxx
SRC_CC = sup.cc pgm.cc SRC_CC = sup.cc pgm.cc
INC_DIR += $(call select_from_repositories,src/lib/libc) INC_DIR += $(call select_from_repositories,src/lib/libc)
INC_DIR += $(call select_from_repositories,src/lib/pthread)
INC_DIR += $(VIRTUALBOX_DIR)/VBoxAPIWrap INC_DIR += $(VIRTUALBOX_DIR)/VBoxAPIWrap

View File

@ -23,7 +23,6 @@
<rom label="libpng.lib.so"/> <rom label="libpng.lib.so"/>
<rom label="mesa.lib.so"/> <rom label="mesa.lib.so"/>
<rom label="pcre16.lib.so"/> <rom label="pcre16.lib.so"/>
<rom label="pthread.lib.so"/>
<rom label="qt5_core.lib.so"/> <rom label="qt5_core.lib.so"/>
<rom label="qt5_dejavusans.tar"/> <rom label="qt5_dejavusans.tar"/>
<rom label="qt5_gui.lib.so"/> <rom label="qt5_gui.lib.so"/>

View File

@ -17,7 +17,6 @@
<rom label="libc_pipe.lib.so"/> <rom label="libc_pipe.lib.so"/>
<rom label="libc_terminal.lib.so"/> <rom label="libc_terminal.lib.so"/>
<rom label="libm.lib.so"/> <rom label="libm.lib.so"/>
<rom label="pthread.lib.so"/>
<rom label="libiconv.lib.so"/> <rom label="libiconv.lib.so"/>
<rom label="qemu-usb.lib.so"/> <rom label="qemu-usb.lib.so"/>
<rom label="stdcxx.lib.so"/> <rom label="stdcxx.lib.so"/>

View File

@ -52,7 +52,8 @@ MIRROR_FROM_LIBPORTS := lib/mk/libc_pipe.mk \
src/lib/libc/libc_mem_alloc.cc \ src/lib/libc/libc_mem_alloc.cc \
src/lib/libc/libc_mem_alloc.h \ src/lib/libc/libc_mem_alloc.h \
src/lib/libc/libc_init.h \ src/lib/libc/libc_init.h \
src/lib/libc/libc_errno.h \ src/lib/libc/thread_create.h \
src/lib/libc/thread.h \
include/libc-plugin \ include/libc-plugin \
lib/import/import-qemu-usb_include.mk \ lib/import/import-qemu-usb_include.mk \
lib/mk/qemu-usb_include.mk \ lib/mk/qemu-usb_include.mk \

View File

@ -123,7 +123,7 @@ append boot_modules {
ld.lib.so ld.lib.so
libc.lib.so vfs.lib.so libc.lib.so vfs.lib.so
libm.lib.so libpng.lib.so libm.lib.so libpng.lib.so
stdcxx.lib.so sdl.lib.so sdl_net.lib.so pthread.lib.so zlib.lib.so stdcxx.lib.so sdl.lib.so sdl_net.lib.so zlib.lib.so
dosbox dosbox.tar dosbox dosbox.tar
} }

View File

@ -91,7 +91,7 @@ set boot_modules {
java.lib.so jvm.lib.so jzip.lib.so jimage.lib.so java.lib.so jvm.lib.so jzip.lib.so jimage.lib.so
libc.lib.so libm.lib.so libc_pipe.lib.so libc.lib.so libm.lib.so libc_pipe.lib.so
zlib.lib.so nio.lib.so jnet.lib.so zlib.lib.so nio.lib.so jnet.lib.so
posix.lib.so pthread.lib.so stdcxx.lib.so ffi.lib.so posix.lib.so stdcxx.lib.so ffi.lib.so
vfs.lib.so vfs.lib.so
classes.tar hello.tar classes.tar hello.tar
} }

View File

@ -217,7 +217,7 @@ set boot_modules {
virtualbox5-nova virtualbox5-nova
usb_hid.iso usb_hid.iso
vm_genode_usb_hid.vbox vm_genode_usb_hid.vbox
ld.lib.so libc.lib.so vfs.lib.so libm.lib.so pthread.lib.so libc_pipe.lib.so ld.lib.so libc.lib.so vfs.lib.so libm.lib.so libc_pipe.lib.so
libc_terminal.lib.so libiconv.lib.so stdcxx.lib.so libc_terminal.lib.so libiconv.lib.so stdcxx.lib.so
qemu-usb.lib.so qemu-usb.lib.so
} }

View File

@ -47,7 +47,7 @@ exec tar cf [run_dir]/genode/test.tar -C [genode_dir]/repos/ports/src/app/verify
file copy [genode_dir]/depot/nfeske/pubkey [run_dir]/genode/pubkey file copy [genode_dir]/depot/nfeske/pubkey [run_dir]/genode/pubkey
build_boot_image { verify libc.lib.so vfs.lib.so pthread.lib.so } build_boot_image { verify libc.lib.so vfs.lib.so }
append qemu_args " -nographic " append qemu_args " -nographic "

View File

@ -310,7 +310,7 @@ lappend_if [expr $use_gui] boot_modules nit_fb
lappend_if [expr $use_gui] boot_modules pointer lappend_if [expr $use_gui] boot_modules pointer
append boot_modules { append boot_modules {
ld.lib.so libc.lib.so vfs.lib.so libm.lib.so pthread.lib.so libc_pipe.lib.so ld.lib.so libc.lib.so vfs.lib.so libm.lib.so libc_pipe.lib.so
libc_terminal.lib.so libiconv.lib.so stdcxx.lib.so libc_terminal.lib.so libiconv.lib.so stdcxx.lib.so
qemu-usb.lib.so qemu-usb.lib.so
} }

View File

@ -367,7 +367,7 @@ install_config $config
append boot_modules { append boot_modules {
core init timer core init timer
part_blk ahci_drv fs_rom part_blk ahci_drv fs_rom
ld.lib.so libc.lib.so vfs.lib.so libm.lib.so pthread.lib.so ld.lib.so libc.lib.so vfs.lib.so libm.lib.so
libc_pipe.lib.so libc_terminal.lib.so libc_pipe.lib.so libc_terminal.lib.so
libiconv.lib.so stdcxx.lib.so libiconv.lib.so stdcxx.lib.so
qemu-usb.lib.so qemu-usb.lib.so

View File

@ -376,7 +376,6 @@ append boot_modules { virtualbox_nic_router.vbox }
append boot_modules { ld.lib.so } append boot_modules { ld.lib.so }
append boot_modules { libc.lib.so } append boot_modules { libc.lib.so }
append boot_modules { libm.lib.so } append boot_modules { libm.lib.so }
append boot_modules { pthread.lib.so }
append boot_modules { libc_pipe.lib.so } append boot_modules { libc_pipe.lib.so }
append boot_modules { libc_terminal.lib.so } append boot_modules { libc_terminal.lib.so }
append boot_modules { libiconv.lib.so } append boot_modules { libiconv.lib.so }

View File

@ -1,6 +1,6 @@
TARGET = verify TARGET = verify
SRC_CC = main.cc SRC_CC = main.cc
LIBS = base libc pthread libgcrypt LIBS = base libc libgcrypt
GNUPG_SRC_DIR := $(call select_from_ports,gnupg)/src/app/gnupg/g10 GNUPG_SRC_DIR := $(call select_from_ports,gnupg)/src/app/gnupg/g10

View File

@ -25,8 +25,6 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> /* open */ #include <fcntl.h> /* open */
#include "libc_errno.h"
/* Genode specific Vbox include */ /* Genode specific Vbox include */
#include "vmm.h" #include "vmm.h"
@ -248,8 +246,10 @@ extern "C" int _sigprocmask()
*/ */
extern "C" int statfs(const char *path, struct statfs *buf) extern "C" int statfs(const char *path, struct statfs *buf)
{ {
if (!buf) if (!buf) {
return Libc::Errno(EFAULT); errno = EFAULT;
return -1;
}
int fd = open(path, 0); int fd = open(path, 0);

View File

@ -27,12 +27,11 @@ LIBS += virtualbox-bios virtualbox-recompiler virtualbox-runtime \
virtualbox-storage virtualbox-zlib virtualbox-liblzf \ virtualbox-storage virtualbox-zlib virtualbox-liblzf \
virtualbox-xml virtualbox-main virtualbox-xml virtualbox-main
LIBS += pthread libc_terminal libc_pipe libiconv LIBS += libc_terminal libc_pipe libiconv
LIBS += qemu-usb LIBS += qemu-usb
INC_DIR += $(call select_from_repositories,src/lib/libc) INC_DIR += $(call select_from_repositories,src/lib/libc)
INC_DIR += $(call select_from_repositories,src/lib/pthread)
INC_DIR += $(VBOX_DIR)/Runtime/include INC_DIR += $(VBOX_DIR)/Runtime/include

View File

@ -17,7 +17,7 @@
#include <cpu_session/connection.h> #include <cpu_session/connection.h>
/* Genode libc pthread binding */ /* Genode libc pthread binding */
#include "thread.h" #include <thread_create.h>
#include "sup.h" #include "sup.h"
#include "vmm.h" #include "vmm.h"
@ -98,19 +98,10 @@ static int create_thread(pthread_t *thread, const pthread_attr_t *attr,
*/ */
} }
pthread_t thread_obj = new (vmm_heap()) return Libc::pthread_create(thread, start_routine, arg,
pthread(start_routine, arg, stack_size, rtthread->szName, stack_size, rtthread->szName,
cpu_connection(rtthread->enmType), cpu_connection(rtthread->enmType),
Genode::Affinity::Location()); Genode::Affinity::Location());
if (!thread_obj)
return EAGAIN;
*thread = thread_obj;
thread_obj->start();
return 0;
} }
extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr,

View File

@ -28,12 +28,11 @@ LIBS += virtualbox5-bios virtualbox5-recompiler virtualbox5-runtime \
virtualbox5-xml virtualbox5-main virtualbox5-apiwrap \ virtualbox5-xml virtualbox5-main virtualbox5-apiwrap \
virtualbox5-dis virtualbox5-dis
LIBS += pthread libc_terminal libc_pipe libiconv LIBS += libc_terminal libc_pipe libiconv
LIBS += qemu-usb LIBS += qemu-usb
INC_DIR += $(call select_from_repositories,src/lib/libc) INC_DIR += $(call select_from_repositories,src/lib/libc)
INC_DIR += $(call select_from_repositories,src/lib/pthread)
INC_DIR += $(VBOX_DIR)/Runtime/include INC_DIR += $(VBOX_DIR)/Runtime/include