From 7a11384177517b437d9656ba18f1ea3134b95a98 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 21 Nov 2018 17:17:25 +0100 Subject: [PATCH] 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 --- repos/dde_linux/run/usb_rndis.run | 2 +- repos/gems/run/ssh_terminal.run | 2 +- repos/gems/run/tcp_terminal.run | 2 +- .../depot_download_manager/gen_fetchurl.cc | 1 - .../app/depot_download_manager/gen_verify.cc | 1 - .../src/app/sculpt_manager/runtime/update.cc | 1 - repos/gems/src/server/ssh_terminal/target.mk | 2 +- repos/gems/src/server/tcp_terminal/target.mk | 2 +- repos/libports/lib/mk/egl_i965.mk | 2 +- repos/libports/lib/mk/icu.mk | 2 +- repos/libports/lib/mk/libc.mk | 8 +- repos/libports/lib/mk/libusb.mk | 2 +- repos/libports/lib/mk/mesa.inc | 2 +- repos/libports/lib/mk/pthread.mk | 12 -- repos/libports/lib/mk/qt5_core.mk | 2 +- repos/libports/lib/mk/qt5_jscore.mk | 2 +- repos/libports/lib/mk/sdl.mk | 2 +- repos/libports/lib/symbols/libc | 138 ++++++++++-------- repos/libports/ports/libc.hash | 2 +- repos/libports/recipes/api/libc/content.mk | 2 - .../libports/recipes/pkg/qt5_textedit/runtime | 1 - .../recipes/pkg/test-libc_pipe/runtime | 1 - .../libports/recipes/pkg/test-pthread/runtime | 1 - repos/libports/run/avplay.run | 2 +- repos/libports/run/fetchurl.inc | 1 - repos/libports/run/libc_select.run | 2 +- repos/libports/run/libc_vfs_select.run | 2 +- repos/libports/run/mesa.inc | 2 +- repos/libports/run/sdl.run | 2 +- repos/libports/run/smartcard.run | 2 +- repos/libports/src/app/fetchurl/target.mk | 2 +- repos/libports/src/lib/libc/dummies.cc | 1 - .../src/lib/libc/patches/pthread_cancel.patch | 10 -- .../src/lib/{pthread => libc}/rwlock.cc | 0 .../src/lib/{pthread => libc}/semaphore.cc | 0 .../src/lib/{pthread => libc}/thread.cc | 3 +- .../src/lib/{pthread => libc}/thread.h | 0 .../lib/{pthread => libc}/thread_create.cc | 40 +++-- repos/libports/src/lib/libc/thread_create.h | 24 +++ repos/libports/src/test/libc_pipe/target.mk | 2 +- repos/libports/src/test/libc_select/target.mk | 2 +- repos/libports/src/test/pthread/target.mk | 2 +- repos/ports/lib/mk/jvm.inc | 2 +- .../ports/lib/mk/spec/nova/virtualbox-nova.mk | 1 - .../lib/mk/spec/nova/virtualbox5-nova.mk | 1 - repos/ports/recipes/pkg/arora/runtime | 1 - .../recipes/pkg/vbox5-nova-sculpt/runtime | 1 - repos/ports/recipes/src/vbox5-nova/content.mk | 3 +- repos/ports/run/dosbox.run | 2 +- repos/ports/run/java.run | 2 +- repos/ports/run/vbox5_genode_usb_hid.run | 2 +- repos/ports/run/verify.run | 2 +- repos/ports/run/virtualbox.run | 2 +- repos/ports/run/virtualbox_auto.inc | 2 +- repos/ports/run/virtualbox_nic_router.run | 1 - repos/ports/src/app/verify/target.mk | 2 +- repos/ports/src/virtualbox/libc.cc | 8 +- repos/ports/src/virtualbox/target.inc | 3 +- repos/ports/src/virtualbox/thread.cc | 19 +-- repos/ports/src/virtualbox5/target.inc | 3 +- 60 files changed, 178 insertions(+), 170 deletions(-) delete mode 100644 repos/libports/lib/mk/pthread.mk delete mode 100644 repos/libports/src/lib/libc/patches/pthread_cancel.patch rename repos/libports/src/lib/{pthread => libc}/rwlock.cc (100%) rename repos/libports/src/lib/{pthread => libc}/semaphore.cc (100%) rename repos/libports/src/lib/{pthread => libc}/thread.cc (99%) rename repos/libports/src/lib/{pthread => libc}/thread.h (100%) rename repos/libports/src/lib/{pthread => libc}/thread_create.cc (59%) create mode 100644 repos/libports/src/lib/libc/thread_create.h diff --git a/repos/dde_linux/run/usb_rndis.run b/repos/dde_linux/run/usb_rndis.run index 73d84dd79d..01aba84459 100644 --- a/repos/dde_linux/run/usb_rndis.run +++ b/repos/dde_linux/run/usb_rndis.run @@ -104,7 +104,7 @@ install_config $config # generic modules set boot_modules { 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 test-terminal_echo vfs_lwip.lib.so diff --git a/repos/gems/run/ssh_terminal.run b/repos/gems/run/ssh_terminal.run index c1523767e8..a8e20ba2a5 100644 --- a/repos/gems/run/ssh_terminal.run +++ b/repos/gems/run/ssh_terminal.run @@ -143,7 +143,7 @@ set boot_modules { core ld.lib.so init timer nic_drv rtc_drv report_rom 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 posix.lib.so libcrypto.lib.so libssh.lib.so zlib.lib.so ncurses.lib.so vfs_jitterentropy.lib.so ssh_terminal diff --git a/repos/gems/run/tcp_terminal.run b/repos/gems/run/tcp_terminal.run index 8c75cd6d6d..022fb2e150 100644 --- a/repos/gems/run/tcp_terminal.run +++ b/repos/gems/run/tcp_terminal.run @@ -90,7 +90,7 @@ install_config $config set boot_modules { core ld.lib.so init timer 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 test-terminal_echo vfs_lwip.lib.so diff --git a/repos/gems/src/app/depot_download_manager/gen_fetchurl.cc b/repos/gems/src/app/depot_download_manager/gen_fetchurl.cc index 9ecc38b4e4..a7c4482b10 100644 --- a/repos/gems/src/app/depot_download_manager/gen_fetchurl.cc +++ b/repos/gems/src/app/depot_download_manager/gen_fetchurl.cc @@ -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, "vfs.lib.so"); gen_parent_rom_route(xml, "zlib.lib.so"); - gen_parent_rom_route(xml, "pthread.lib.so"); gen_parent_route (xml); gen_parent_route (xml); gen_parent_route (xml); diff --git a/repos/gems/src/app/depot_download_manager/gen_verify.cc b/repos/gems/src/app/depot_download_manager/gen_verify.cc index 66b1f7e4d7..1daefec6a5 100644 --- a/repos/gems/src/app/depot_download_manager/gen_verify.cc +++ b/repos/gems/src/app/depot_download_manager/gen_verify.cc @@ -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_rom_route(xml, "libc.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_route (xml); gen_parent_route (xml); diff --git a/repos/gems/src/app/sculpt_manager/runtime/update.cc b/repos/gems/src/app/sculpt_manager/runtime/update.cc index abcdb59668..76f117a931 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/update.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/update.cc @@ -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, "libarchive.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, "installation", "config -> managed/installation"); gen_parent_route (xml); diff --git a/repos/gems/src/server/ssh_terminal/target.mk b/repos/gems/src/server/ssh_terminal/target.mk index 1137fe1559..7b107a97fb 100644 --- a/repos/gems/src/server/ssh_terminal/target.mk +++ b/repos/gems/src/server/ssh_terminal/target.mk @@ -1,5 +1,5 @@ TARGET = ssh_terminal SRC_CC = main.cc -LIBS = base libc pthread libssh libc_pipe +LIBS = base libc libssh libc_pipe CC_CXX_WARN_STRICT = diff --git a/repos/gems/src/server/tcp_terminal/target.mk b/repos/gems/src/server/tcp_terminal/target.mk index 58025a52c0..029143c18c 100644 --- a/repos/gems/src/server/tcp_terminal/target.mk +++ b/repos/gems/src/server/tcp_terminal/target.mk @@ -1,5 +1,5 @@ TARGET = tcp_terminal SRC_CC = main.cc -LIBS = libc pthread libc_pipe +LIBS = libc libc_pipe CC_CXX_WARN_STRICT = diff --git a/repos/libports/lib/mk/egl_i965.mk b/repos/libports/lib/mk/egl_i965.mk index fcd6a5822c..2484f08346 100644 --- a/repos/libports/lib/mk/egl_i965.mk +++ b/repos/libports/lib/mk/egl_i965.mk @@ -1,5 +1,5 @@ SHARED_LIB = yes -LIBS = libc egl i965 pthread +LIBS = libc egl i965 include $(REP_DIR)/lib/mk/mesa-common.inc diff --git a/repos/libports/lib/mk/icu.mk b/repos/libports/lib/mk/icu.mk index 5190e764c9..7e63d31698 100644 --- a/repos/libports/lib/mk/icu.mk +++ b/repos/libports/lib/mk/icu.mk @@ -90,7 +90,7 @@ CC_OPT += -D__intptr_t_defined CC_WARN += -Wno-deprecated-declarations -LIBS = stdcxx pthread +LIBS = stdcxx vpath % $(ICU_DIR)/source/common vpath % $(ICU_DIR)/source/i18n diff --git a/repos/libports/lib/mk/libc.mk b/repos/libports/lib/mk/libc.mk index ddd57604dd..e89ac6994d 100644 --- a/repos/libports/lib/mk/libc.mk +++ b/repos/libports/lib/mk/libc.mk @@ -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 \ getpwent.cc +# +# Pthreads +# +SRC_CC += semaphore.cc rwlock.cc \ + thread.cc thread_create.cc + CC_OPT_sysctl += -Wno-write-strings INC_DIR += $(REP_DIR)/src/lib/libc @@ -43,5 +49,3 @@ vpath % $(LIBC_DIR)/lib/libc/string # SHARED_LIB = yes LD_OPT += --version-script=$(REP_DIR)/src/lib/libc/Version.def - -CC_CXX_WARN_STRICT = diff --git a/repos/libports/lib/mk/libusb.mk b/repos/libports/lib/mk/libusb.mk index 3937854709..0307ebf139 100644 --- a/repos/libports/lib/mk/libusb.mk +++ b/repos/libports/lib/mk/libusb.mk @@ -1,5 +1,5 @@ LIBUSB_DIR := $(call select_from_ports,libusb)/src/lib/libusb -LIBS += libc libc_pipe pthread +LIBS += libc libc_pipe # find 'config.h' INC_DIR += $(REP_DIR)/src/lib/libusb diff --git a/repos/libports/lib/mk/mesa.inc b/repos/libports/lib/mk/mesa.inc index a89c4108fd..258ad18788 100644 --- a/repos/libports/lib/mk/mesa.inc +++ b/repos/libports/lib/mk/mesa.inc @@ -1,5 +1,5 @@ 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 diff --git a/repos/libports/lib/mk/pthread.mk b/repos/libports/lib/mk/pthread.mk deleted file mode 100644 index 528fea209d..0000000000 --- a/repos/libports/lib/mk/pthread.mk +++ /dev/null @@ -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 = diff --git a/repos/libports/lib/mk/qt5_core.mk b/repos/libports/lib/mk/qt5_core.mk index 0e1034f3f7..83e8166402 100644 --- a/repos/libports/lib/mk/qt5_core.mk +++ b/repos/libports/lib/mk/qt5_core.mk @@ -29,6 +29,6 @@ include $(REP_DIR)/lib/mk/qt5.inc SRC_CC += libc_dummies.cc 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 = diff --git a/repos/libports/lib/mk/qt5_jscore.mk b/repos/libports/lib/mk/qt5_jscore.mk index 55830128f3..631e6585e7 100644 --- a/repos/libports/lib/mk/qt5_jscore.mk +++ b/repos/libports/lib/mk/qt5_jscore.mk @@ -17,6 +17,6 @@ QT_INCPATH += qtwebkit/Source/JavaScriptCore/generated 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 = diff --git a/repos/libports/lib/mk/sdl.mk b/repos/libports/lib/mk/sdl.mk index 9751ad47c9..fce329750a 100644 --- a/repos/libports/lib/mk/sdl.mk +++ b/repos/libports/lib/mk/sdl.mk @@ -82,7 +82,7 @@ SRC_C += cdrom/SDL_cdrom.c \ INC_DIR += $(SDL_DIR)/src/cdrom # we need libc -LIBS = libc pthread mesa_api +LIBS = libc mesa_api # backend path vpath % $(REP_DIR)/src/lib/sdl diff --git a/repos/libports/lib/symbols/libc b/repos/libports/lib/symbols/libc index a3c06c7b17..b75d1d6958 100644 --- a/repos/libports/lib/symbols/libc +++ b/repos/libports/lib/symbols/libc @@ -494,65 +494,71 @@ pread T printf T pselect W psignal T -pthread_atfork W -pthread_attr_destroy W -pthread_attr_getdetachstate W -pthread_attr_getguardsize W -pthread_attr_getinheritsched W -pthread_attr_getschedparam W -pthread_attr_getschedpolicy W -pthread_attr_getscope W -pthread_attr_getstackaddr W -pthread_attr_getstacksize W -pthread_attr_init W -pthread_attr_setdetachstate W -pthread_attr_setguardsize W -pthread_attr_setinheritsched W -pthread_attr_setschedparam W -pthread_attr_setschedpolicy W -pthread_attr_setscope W -pthread_attr_setstackaddr W -pthread_attr_setstacksize W -pthread_cleanup_pop W -pthread_cleanup_push W -pthread_cond_broadcast W -pthread_cond_destroy W -pthread_cond_init W -pthread_cond_signal W -pthread_cond_timedwait W -pthread_cond_wait W +pthread_atfork T +pthread_attr_destroy T +pthread_attr_getdetachstate T +pthread_attr_getguardsize T +pthread_attr_getinheritsched T +pthread_attr_get_np T +pthread_attr_getschedparam T +pthread_attr_getschedpolicy T +pthread_attr_getscope T +pthread_attr_getstack T +pthread_attr_getstackaddr T +pthread_attr_getstacksize T +pthread_attr_init T +pthread_attr_setdetachstate T +pthread_attr_setguardsize T +pthread_attr_setinheritsched T +pthread_attr_setschedparam T +pthread_attr_setschedpolicy T +pthread_attr_setscope T +pthread_attr_setstackaddr T +pthread_attr_setstacksize T +pthread_cancel T +pthread_cleanup_pop T +pthread_cleanup_push T +pthread_cond_broadcast T +pthread_cond_destroy T +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_detach W -pthread_equal W -pthread_exit W -pthread_getspecific W -pthread_join W -pthread_key_create W -pthread_key_delete W -pthread_kill W -pthread_main_np W -pthread_mutex_destroy W -pthread_mutex_init W -pthread_mutex_lock W -pthread_mutex_trylock W -pthread_mutex_unlock W -pthread_mutexattr_destroy W -pthread_mutexattr_init W -pthread_mutexattr_settype W -pthread_once W -pthread_rwlock_destroy W -pthread_rwlock_init W -pthread_rwlock_rdlock W -pthread_rwlock_tryrdlock W -pthread_rwlock_trywrlock W -pthread_rwlock_unlock W -pthread_rwlock_wrlock W -pthread_self W -pthread_setcancelstate W -pthread_setcanceltype W -pthread_setspecific W -pthread_sigmask W -pthread_testcancel W +pthread_detach T +pthread_equal T +pthread_exit T +pthread_getspecific T +pthread_join T +pthread_key_create T +pthread_key_delete T +pthread_kill T +pthread_main_np T +pthread_mutex_destroy T +pthread_mutex_init T +pthread_mutex_lock T +pthread_mutex_trylock T +pthread_mutex_unlock T +pthread_mutexattr_destroy T +pthread_mutexattr_init T +pthread_mutexattr_settype T +pthread_once T +pthread_rwlock_destroy T +pthread_rwlock_init T +pthread_rwlock_rdlock T +pthread_rwlock_tryrdlock T +pthread_rwlock_trywrlock T +pthread_rwlock_unlock T +pthread_rwlock_wrlock T +pthread_self T +pthread_setcancelstate T +pthread_setcanceltype T +pthread_setspecific T +pthread_sigmask T +pthread_testcancel T ptsname T putc T putc_unlocked T @@ -607,9 +613,19 @@ sched_yield W seed48 T seekdir T select W +sem_close T semctl T +sem_destroy T +sem_getvalue T semget W +sem_init T +sem_open T semop W +sem_post T +sem_timedwait T +sem_trywait T +sem_unlink T +sem_wait T send T sendto T setbuf T @@ -914,7 +930,6 @@ _CurrentRuneLocale D 8 __isinff T __isinfl T - # # Public interface between Genode-component code and the libc runtime # @@ -928,6 +943,11 @@ _ZN4Libc19Select_handler_baseD1Ev T _ZN4Libc19Select_handler_baseD2Ev T _ZN4Libc10resume_allEv 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 diff --git a/repos/libports/ports/libc.hash b/repos/libports/ports/libc.hash index 3016ab30aa..92e9fd3b44 100644 --- a/repos/libports/ports/libc.hash +++ b/repos/libports/ports/libc.hash @@ -1 +1 @@ -5a5de5baab6e3ce23f24012a7604abf070fa990c +c9cbd0d0fe35cc19c71295a02d67ecbe09a14573 diff --git a/repos/libports/recipes/api/libc/content.mk b/repos/libports/recipes/api/libc/content.mk index 487eb54b0d..e994ff1dab 100644 --- a/repos/libports/recipes/api/libc/content.mk +++ b/repos/libports/recipes/api/libc/content.mk @@ -1,8 +1,6 @@ MIRROR_FROM_REP_DIR := lib/import/import-libc.mk \ lib/symbols/libc \ lib/symbols/libm \ - lib/mk/pthread.mk \ - src/lib/pthread content: $(MIRROR_FROM_REP_DIR) diff --git a/repos/libports/recipes/pkg/qt5_textedit/runtime b/repos/libports/recipes/pkg/qt5_textedit/runtime index 60bce0aa5c..3000dac5c5 100644 --- a/repos/libports/recipes/pkg/qt5_textedit/runtime +++ b/repos/libports/recipes/pkg/qt5_textedit/runtime @@ -20,7 +20,6 @@ - diff --git a/repos/libports/recipes/pkg/test-libc_pipe/runtime b/repos/libports/recipes/pkg/test-libc_pipe/runtime index 54f47137b5..93d58cd4a9 100644 --- a/repos/libports/recipes/pkg/test-libc_pipe/runtime +++ b/repos/libports/recipes/pkg/test-libc_pipe/runtime @@ -12,7 +12,6 @@ - diff --git a/repos/libports/recipes/pkg/test-pthread/runtime b/repos/libports/recipes/pkg/test-pthread/runtime index f46aac114a..ef0067f085 100644 --- a/repos/libports/recipes/pkg/test-pthread/runtime +++ b/repos/libports/recipes/pkg/test-pthread/runtime @@ -12,7 +12,6 @@ - diff --git a/repos/libports/run/avplay.run b/repos/libports/run/avplay.run index d99b97dd9f..472cc67978 100644 --- a/repos/libports/run/avplay.run +++ b/repos/libports/run/avplay.run @@ -113,7 +113,7 @@ install_config $config append boot_modules { 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 avresample.lib.so mediafile diff --git a/repos/libports/run/fetchurl.inc b/repos/libports/run/fetchurl.inc index 4d053182eb..eb25c4ad49 100644 --- a/repos/libports/run/fetchurl.inc +++ b/repos/libports/run/fetchurl.inc @@ -110,7 +110,6 @@ set boot_modules { libcrypto.lib.so libssh.lib.so libssl.lib.so - pthread.lib.so timer zlib.lib.so report_rom diff --git a/repos/libports/run/libc_select.run b/repos/libports/run/libc_select.run index bf6123d046..ae30cb6c80 100644 --- a/repos/libports/run/libc_select.run +++ b/repos/libports/run/libc_select.run @@ -68,7 +68,7 @@ install_config $config set boot_modules { core init timer terminal_crosslink 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 } diff --git a/repos/libports/run/libc_vfs_select.run b/repos/libports/run/libc_vfs_select.run index 164bb83667..74e730e27a 100644 --- a/repos/libports/run/libc_vfs_select.run +++ b/repos/libports/run/libc_vfs_select.run @@ -77,7 +77,7 @@ install_config $config set boot_modules { core init timer terminal_crosslink vfs 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 } diff --git a/repos/libports/run/mesa.inc b/repos/libports/run/mesa.inc index 36704c8610..ecb1c64ada 100644 --- a/repos/libports/run/mesa.inc +++ b/repos/libports/run/mesa.inc @@ -179,7 +179,7 @@ set boot_modules { core init ld.lib.so timer nitpicker pointer liquid_fb 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 expat.lib.so glapi.lib.so diff --git a/repos/libports/run/sdl.run b/repos/libports/run/sdl.run index ab985fc2c8..5329af4ec9 100644 --- a/repos/libports/run/sdl.run +++ b/repos/libports/run/sdl.run @@ -85,7 +85,7 @@ set boot_modules { core init timer 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 diff --git a/repos/libports/run/smartcard.run b/repos/libports/run/smartcard.run index e5a95f1cda..6674689bc1 100644 --- a/repos/libports/run/smartcard.run +++ b/repos/libports/run/smartcard.run @@ -112,7 +112,7 @@ install_config $config set boot_modules { core init timer usb_drv test-smartcard 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 } diff --git a/repos/libports/src/app/fetchurl/target.mk b/repos/libports/src/app/fetchurl/target.mk index 35e5c65ca5..0ef5399f94 100644 --- a/repos/libports/src/app/fetchurl/target.mk +++ b/repos/libports/src/app/fetchurl/target.mk @@ -1,3 +1,3 @@ TARGET = fetchurl -LIBS += curl libc ld pthread +LIBS += curl libc ld SRC_CC = component.cc diff --git a/repos/libports/src/lib/libc/dummies.cc b/repos/libports/src/lib/libc/dummies.cc index 88219f9255..9b30fc976e 100644 --- a/repos/libports/src/lib/libc/dummies.cc +++ b/repos/libports/src/lib/libc/dummies.cc @@ -91,7 +91,6 @@ DUMMY(void *, 0, ___mtctxres, (void)) DUMMY(void *, 0, __nsdefaultsrc, (void)) DUMMY(int , -1, _nsdispatch, (void)) 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(void *, 0, sbrk, (intptr_t)) DUMMY(int , -1, sched_setparam, (pid_t, const sched_param *)) diff --git a/repos/libports/src/lib/libc/patches/pthread_cancel.patch b/repos/libports/src/lib/libc/patches/pthread_cancel.patch deleted file mode 100644 index 68f6661471..0000000000 --- a/repos/libports/src/lib/libc/patches/pthread_cancel.patch +++ /dev/null @@ -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 *) diff --git a/repos/libports/src/lib/pthread/rwlock.cc b/repos/libports/src/lib/libc/rwlock.cc similarity index 100% rename from repos/libports/src/lib/pthread/rwlock.cc rename to repos/libports/src/lib/libc/rwlock.cc diff --git a/repos/libports/src/lib/pthread/semaphore.cc b/repos/libports/src/lib/libc/semaphore.cc similarity index 100% rename from repos/libports/src/lib/pthread/semaphore.cc rename to repos/libports/src/lib/libc/semaphore.cc diff --git a/repos/libports/src/lib/pthread/thread.cc b/repos/libports/src/lib/libc/thread.cc similarity index 99% rename from repos/libports/src/lib/pthread/thread.cc rename to repos/libports/src/lib/libc/thread.cc index dda602b6c0..81b8380c94 100644 --- a/repos/libports/src/lib/pthread/thread.cc +++ b/repos/libports/src/lib/libc/thread.cc @@ -22,8 +22,7 @@ #include #include /* malloc, free */ #include "thread.h" - -#include /* libc suspend/resume */ +#include "task.h" using namespace Genode; diff --git a/repos/libports/src/lib/pthread/thread.h b/repos/libports/src/lib/libc/thread.h similarity index 100% rename from repos/libports/src/lib/pthread/thread.h rename to repos/libports/src/lib/libc/thread.h diff --git a/repos/libports/src/lib/pthread/thread_create.cc b/repos/libports/src/lib/libc/thread_create.cc similarity index 59% rename from repos/libports/src/lib/pthread/thread_create.cc rename to repos/libports/src/lib/libc/thread_create.cc index a1042e4793..305f9896fa 100644 --- a/repos/libports/src/lib/pthread/thread_create.cc +++ b/repos/libports/src/lib/libc/thread_create.cc @@ -14,11 +14,28 @@ * under the terms of the GNU Affero General Public License version 3. */ -#include - -#include -#include +#include "thread_create.h" #include "thread.h" +#include + + +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" { @@ -29,17 +46,8 @@ extern "C" ? (*attr)->stack_size : Libc::Component::stack_size(); - pthread_t thread_obj = new pthread(start_routine, arg, stack_size, - "pthread", nullptr, - Genode::Affinity::Location()); - - if (!thread_obj) - return EAGAIN; - - *thread = thread_obj; - - thread_obj->start(); - - return 0; + return Libc::pthread_create(thread, start_routine, arg, stack_size, + "pthread", nullptr, + Genode::Affinity::Location()); } } diff --git a/repos/libports/src/lib/libc/thread_create.h b/repos/libports/src/lib/libc/thread_create.h new file mode 100644 index 0000000000..94027687cd --- /dev/null +++ b/repos/libports/src/lib/libc/thread_create.h @@ -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 +#include + +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); +} diff --git a/repos/libports/src/test/libc_pipe/target.mk b/repos/libports/src/test/libc_pipe/target.mk index cc4eb46d9c..fb24f59585 100644 --- a/repos/libports/src/test/libc_pipe/target.mk +++ b/repos/libports/src/test/libc_pipe/target.mk @@ -1,5 +1,5 @@ TARGET = test-libc_pipe -LIBS = base posix libc_pipe pthread +LIBS = base posix libc_pipe SRC_CC = main.cc CC_CXX_WARN_STRICT = diff --git a/repos/libports/src/test/libc_select/target.mk b/repos/libports/src/test/libc_select/target.mk index e0af098936..efaffb7023 100644 --- a/repos/libports/src/test/libc_select/target.mk +++ b/repos/libports/src/test/libc_select/target.mk @@ -1,5 +1,5 @@ TARGET = test-libc_select SRC_CC = main.cc -LIBS = posix stdcxx pthread libc_pipe +LIBS = posix stdcxx libc_pipe CC_CXX_WARN_STRICT = diff --git a/repos/libports/src/test/pthread/target.mk b/repos/libports/src/test/pthread/target.mk index 90b6b249b2..708ba92f23 100644 --- a/repos/libports/src/test/pthread/target.mk +++ b/repos/libports/src/test/pthread/target.mk @@ -1,5 +1,5 @@ TARGET = test-pthread SRC_CC = main.cc -LIBS = base posix pthread +LIBS = base posix CC_CXX_WARN_STRICT = diff --git a/repos/ports/lib/mk/jvm.inc b/repos/ports/lib/mk/jvm.inc index 72b09fc7c7..7e3d6e46cb 100644 --- a/repos/ports/lib/mk/jvm.inc +++ b/repos/ports/lib/mk/jvm.inc @@ -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/jvmtiEnterTrace.cpp -LIBS = stdcxx pthread jzip jimage nio jnet ffi +LIBS = stdcxx jzip jimage nio jnet ffi SHARED_LIB = yes HOTSPOT_BASE = $(call select_from_ports,jdk)/src/app/jdk/hotspot/src JDK_GENERATED = $(call select_from_ports,jdk_generated)/src/app/jdk diff --git a/repos/ports/lib/mk/spec/nova/virtualbox-nova.mk b/repos/ports/lib/mk/spec/nova/virtualbox-nova.mk index 712864902e..9de4f8e50e 100644 --- a/repos/ports/lib/mk/spec/nova/virtualbox-nova.mk +++ b/repos/ports/lib/mk/spec/nova/virtualbox-nova.mk @@ -11,7 +11,6 @@ LIBS += stdcxx SRC_CC = sup.cc pgm.cc 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/include diff --git a/repos/ports/lib/mk/spec/nova/virtualbox5-nova.mk b/repos/ports/lib/mk/spec/nova/virtualbox5-nova.mk index b3d58dd8f9..7f71f9fef0 100644 --- a/repos/ports/lib/mk/spec/nova/virtualbox5-nova.mk +++ b/repos/ports/lib/mk/spec/nova/virtualbox5-nova.mk @@ -5,7 +5,6 @@ LIBS += stdcxx SRC_CC = sup.cc pgm.cc INC_DIR += $(call select_from_repositories,src/lib/libc) -INC_DIR += $(call select_from_repositories,src/lib/pthread) INC_DIR += $(VIRTUALBOX_DIR)/VBoxAPIWrap diff --git a/repos/ports/recipes/pkg/arora/runtime b/repos/ports/recipes/pkg/arora/runtime index 718b88da4d..575258d8e8 100644 --- a/repos/ports/recipes/pkg/arora/runtime +++ b/repos/ports/recipes/pkg/arora/runtime @@ -23,7 +23,6 @@ - diff --git a/repos/ports/recipes/pkg/vbox5-nova-sculpt/runtime b/repos/ports/recipes/pkg/vbox5-nova-sculpt/runtime index 1809bff76c..8378b5df2b 100755 --- a/repos/ports/recipes/pkg/vbox5-nova-sculpt/runtime +++ b/repos/ports/recipes/pkg/vbox5-nova-sculpt/runtime @@ -17,7 +17,6 @@ - diff --git a/repos/ports/recipes/src/vbox5-nova/content.mk b/repos/ports/recipes/src/vbox5-nova/content.mk index 18801082b4..489e48bf61 100644 --- a/repos/ports/recipes/src/vbox5-nova/content.mk +++ b/repos/ports/recipes/src/vbox5-nova/content.mk @@ -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.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 \ lib/import/import-qemu-usb_include.mk \ lib/mk/qemu-usb_include.mk \ diff --git a/repos/ports/run/dosbox.run b/repos/ports/run/dosbox.run index e47b765e44..fee095848f 100644 --- a/repos/ports/run/dosbox.run +++ b/repos/ports/run/dosbox.run @@ -123,7 +123,7 @@ append boot_modules { ld.lib.so libc.lib.so vfs.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 } diff --git a/repos/ports/run/java.run b/repos/ports/run/java.run index c39618f2a6..5853c9397c 100644 --- a/repos/ports/run/java.run +++ b/repos/ports/run/java.run @@ -91,7 +91,7 @@ set boot_modules { java.lib.so jvm.lib.so jzip.lib.so jimage.lib.so libc.lib.so libm.lib.so libc_pipe.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 classes.tar hello.tar } diff --git a/repos/ports/run/vbox5_genode_usb_hid.run b/repos/ports/run/vbox5_genode_usb_hid.run index fb09b6e7bd..943f49dc38 100644 --- a/repos/ports/run/vbox5_genode_usb_hid.run +++ b/repos/ports/run/vbox5_genode_usb_hid.run @@ -217,7 +217,7 @@ set boot_modules { virtualbox5-nova usb_hid.iso 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 qemu-usb.lib.so } diff --git a/repos/ports/run/verify.run b/repos/ports/run/verify.run index 6de4321ddd..f9a555dcd8 100644 --- a/repos/ports/run/verify.run +++ b/repos/ports/run/verify.run @@ -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 -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 " diff --git a/repos/ports/run/virtualbox.run b/repos/ports/run/virtualbox.run index 814b0b2cfb..bd04791e72 100644 --- a/repos/ports/run/virtualbox.run +++ b/repos/ports/run/virtualbox.run @@ -310,7 +310,7 @@ lappend_if [expr $use_gui] boot_modules nit_fb lappend_if [expr $use_gui] boot_modules pointer 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 qemu-usb.lib.so } diff --git a/repos/ports/run/virtualbox_auto.inc b/repos/ports/run/virtualbox_auto.inc index 46cab02c9d..bf95916a85 100644 --- a/repos/ports/run/virtualbox_auto.inc +++ b/repos/ports/run/virtualbox_auto.inc @@ -367,7 +367,7 @@ install_config $config append boot_modules { core init timer 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 libiconv.lib.so stdcxx.lib.so qemu-usb.lib.so diff --git a/repos/ports/run/virtualbox_nic_router.run b/repos/ports/run/virtualbox_nic_router.run index 25dd3eb937..214b03d6de 100644 --- a/repos/ports/run/virtualbox_nic_router.run +++ b/repos/ports/run/virtualbox_nic_router.run @@ -376,7 +376,6 @@ append boot_modules { virtualbox_nic_router.vbox } append boot_modules { ld.lib.so } append boot_modules { libc.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_terminal.lib.so } append boot_modules { libiconv.lib.so } diff --git a/repos/ports/src/app/verify/target.mk b/repos/ports/src/app/verify/target.mk index fb16f2bb9e..4578909e72 100644 --- a/repos/ports/src/app/verify/target.mk +++ b/repos/ports/src/app/verify/target.mk @@ -1,6 +1,6 @@ TARGET = verify 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 diff --git a/repos/ports/src/virtualbox/libc.cc b/repos/ports/src/virtualbox/libc.cc index fab0629f04..f49ef596a1 100644 --- a/repos/ports/src/virtualbox/libc.cc +++ b/repos/ports/src/virtualbox/libc.cc @@ -25,8 +25,6 @@ #include #include /* open */ -#include "libc_errno.h" - /* Genode specific Vbox include */ #include "vmm.h" @@ -248,8 +246,10 @@ extern "C" int _sigprocmask() */ extern "C" int statfs(const char *path, struct statfs *buf) { - if (!buf) - return Libc::Errno(EFAULT); + if (!buf) { + errno = EFAULT; + return -1; + } int fd = open(path, 0); diff --git a/repos/ports/src/virtualbox/target.inc b/repos/ports/src/virtualbox/target.inc index a3f7f2389b..50448b7cf2 100644 --- a/repos/ports/src/virtualbox/target.inc +++ b/repos/ports/src/virtualbox/target.inc @@ -27,12 +27,11 @@ LIBS += virtualbox-bios virtualbox-recompiler virtualbox-runtime \ virtualbox-storage virtualbox-zlib virtualbox-liblzf \ virtualbox-xml virtualbox-main -LIBS += pthread libc_terminal libc_pipe libiconv +LIBS += libc_terminal libc_pipe libiconv LIBS += qemu-usb INC_DIR += $(call select_from_repositories,src/lib/libc) -INC_DIR += $(call select_from_repositories,src/lib/pthread) INC_DIR += $(VBOX_DIR)/Runtime/include diff --git a/repos/ports/src/virtualbox/thread.cc b/repos/ports/src/virtualbox/thread.cc index 446099199e..5c9952fefb 100644 --- a/repos/ports/src/virtualbox/thread.cc +++ b/repos/ports/src/virtualbox/thread.cc @@ -17,7 +17,7 @@ #include /* Genode libc pthread binding */ -#include "thread.h" +#include #include "sup.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()) - pthread(start_routine, arg, stack_size, rtthread->szName, - cpu_connection(rtthread->enmType), - Genode::Affinity::Location()); - - if (!thread_obj) - return EAGAIN; - - *thread = thread_obj; - - thread_obj->start(); - - return 0; + return Libc::pthread_create(thread, start_routine, arg, + stack_size, rtthread->szName, + cpu_connection(rtthread->enmType), + Genode::Affinity::Location()); } extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, diff --git a/repos/ports/src/virtualbox5/target.inc b/repos/ports/src/virtualbox5/target.inc index 29ede9247b..f7594a1afe 100644 --- a/repos/ports/src/virtualbox5/target.inc +++ b/repos/ports/src/virtualbox5/target.inc @@ -28,12 +28,11 @@ LIBS += virtualbox5-bios virtualbox5-recompiler virtualbox5-runtime \ virtualbox5-xml virtualbox5-main virtualbox5-apiwrap \ virtualbox5-dis -LIBS += pthread libc_terminal libc_pipe libiconv +LIBS += libc_terminal libc_pipe libiconv LIBS += qemu-usb INC_DIR += $(call select_from_repositories,src/lib/libc) -INC_DIR += $(call select_from_repositories,src/lib/pthread) INC_DIR += $(VBOX_DIR)/Runtime/include