aboutsummaryrefslogtreecommitdiff
path: root/hurd
AgeCommit message (Collapse)Author
2022-09-26Use atomic_exchange_release/acquireWilco Dijkstra
Rename atomic_exchange_rel/acq to use atomic_exchange_release/acquire since these map to the standard C11 atomic builtins. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-08-29hurd: Fix vm_size_t incoherenciesSamuel Thibault
In gnumach, 3e1702a65fb3 ("add rpc_versions for vm types") changed the type of vm_size_t, making it always a unsigned long. This made it incompatible on x86 with size_t. Even if we may want to revert it to unsigned int, it's better to fix the types of parameters according to the .defs files.
2022-04-13Replace {u}int_fast{16|32} with {u}int32_tNoah Goldstein
On 32-bit machines this has no affect. On 64-bit machines {u}int_fast{16|32} are set as {u}int64_t which is often not ideal. Particularly x86_64 this change both saves code size and may save instruction cost. Full xcheck passes on x86_64.
2022-01-16hurd: Make RPC input array parameters constSamuel Thibault
This follows mig's cf4bcc3f1435 ("Also add const qualifiers on server side")
2022-01-16hurd: optimize exec cleanupSamuel Thibault
When ports are nul we do not need to request their deallocation. It is also useless to look for them in portnames.
2022-01-15hurd: Fix exec() leak on proc_task2proc failureSamuel Thibault
env is allocated after args, so should be freed before it.
2022-01-04hurd: nuke all unknown ports on execSamuel Thibault
Ports which are not in the ports table or dtable will not make sense for the new program, so we can nuke them. Actually we shall, otherwise we would be leaking various ports, for instance the file_t of the executed program itself.
2022-01-04hurd: Fix auth port leakSamuel Thibault
If access() was used before exec, _hurd_id.rid_auth would cache an "effective" auth port. We do not want this to leak into the executed program.
2022-01-02hurd: Implement _S_msg_get_dtableSamuel Thibault
This will be needed for implementing lsof.
2022-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert
I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
2021-12-28hurd: Fix static-PIE startupSamuel Thibault
hurd initialization stages use RUN_HOOK to run various initialization functions. That is however using absolute addresses which need to be relocated, which is done later by csu. We can however easily make the linker compute relative addresses which thus don't need a relocation. The new SET_RELHOOK and RUN_RELHOOK macros implement this.
2021-12-28hurd: let csu initialize tlsSamuel Thibault
Since 9cec82de715b ("htl: Initialize later"), we let csu initialize pthreads. We can thus let it initialize tls later too, to better align with the generic order. Initialization however accesses ports which links/unlinks into the sigstate for unwinding. We can however easily skip that during initialization.
2021-11-28hurd: Let report-wait use a weak reference to _hurd_itimer_threadSamuel Thibault
libc.so.0.3 does not seem to need this defined any more.
2021-09-03Remove "Contributed by" linesSiddhesh Poyarekar
We stopped adding "Contributed by" or similar lines in sources in 2012 in favour of git logs and keeping the Contributors section of the glibc manual up to date. Removing these lines makes the license header a bit more consistent across files and also removes the possibility of error in attribution when license blocks or files are copied across since the contributed-by lines don't actually reflect reality in those cases. Move all "Contributed by" and similar lines (Written by, Test by, etc.) into a new file CONTRIBUTED-BY to retain record of these contributions. These contributors are also mentioned in manual/contrib.texi, so we just maintain this additional record as a courtesy to the earlier developers. The following scripts were used to filter a list of files to edit in place and to clean up the CONTRIBUTED-BY file respectively. These were not added to the glibc sources because they're not expected to be of any use in future given that this is a one time task: https://gist.github.com/siddhesh/b5ecac94eabfd72ed2916d6d8157e7dc https://gist.github.com/siddhesh/15ea1f5e435ace9774f485030695ee02 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-08-10hurd: Add support for AT_NO_AUTOMOUNTSamuel Thibault
2021-08-03hurd: Avoid spurious warningSamuel Thibault
Compilers missing some flow analysis may think ss may be used uninitialized.
2021-04-12hurd: Export _hurd_libc_proc_initSamuel Thibault
hurd's libdiskfs needs to be able to call _hurd_init + _hurd_libc_proc_init for bootstrap initialization.
2021-03-23hurd: handle EINTR during critical sectionsSamuel Thibault
During critical sections, signal handling is deferred and thus RPCs return EINTR, even if SA_RESTART is set. We thus have to restart the whole critical section in that case. This also adds HURD_CRITICAL_UNLOCK in the cases where one wants to break the section in the middle.
2021-01-02Update copyright dates with scripts/update-copyrightsPaul Eggert
I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
2020-12-26hurd: set sigaction for signal preemptors in arch-independent fileSamuel Thibault
Instead of having the arch-specific trampoline setup code detect whether preemption happened or not, we'd rather pass it the sigaction. In the future, this may also allow to change sa_flags from post_signal().
2020-12-21Hurd: make sigstates hold a reference on thread portsRichard Braun
This change is required in order to correctly release per-thread resources. Directly reusing the threading library reference isn't possible since the sigstate is also used early in the main thread, before threading is initialized. * hurd/hurd/signal.h (_hurd_self_sigstate): Drop thread reference after calling _hurd_thread_sigstate. (_hurd_critical_section_lock): Likewise. * hurd/hurdsig.c (_hurd_thread_sigstate): Add a reference on the thread. (_hurd_sigstate_delete): Drop thread reference.
2020-12-21hurd: implement SA_SIGINFO signal handlers.Jeremie Koenig
SA_SIGINFO is actually just another way of expressing what we were already passing over with struct sigcontext. This just introduces the SIGINFO interface and fixes the posix values when that interface is requested by the application.
2020-12-19hurd: Also turn KERN_INVALID_ADDRESS to EINVALSamuel Thibault
When e.g. mmap is passed an invalid address we would return KERN_INVALID_ADDRESS, while POSIX applications would expect EINVAL.
2020-12-16hurd: Add __libc_open and __libc_closeSamuel Thibault
Needed by libpthread for sem_open and sem_close
2020-12-16hurd: Add __lll_abstimed_wait_intrSamuel Thibault
For semaphores, we need an interruptible version of low-level locks.
2020-12-16hurd: make lll_* take a variable instead of a ptrSamuel Thibault
To be coherent with other ports, let's make lll_* take a variable, and rename those that keep taking a ptr into __lll_*.
2020-12-16hurd: Rename LLL_INITIALIZER to LLL_LOCK_INITIALIZERSamuel Thibault
To get coherent with other ports.
2020-12-03htl: Add missing symbolsSamuel Thibault
hurd/hurdsig.c needs to detect whether __pthread_detach and __pthread_create are available, so they need to be exposed.
2020-11-23hurd report-wait: Fix stpcpy usageSamuel Thibault
We shall not overflow the size of the description parameter. This makes describe_number and describe_port behave like strpcpy (except for not filling all the end of buffer with zeroes) and _S_msg_report_wait use series of stpncpy-like call. If we were to overflow, we can now detect it and return ENOMEM.
2020-11-23hurd S_msg_report_wait: Fix detecting fd portsSamuel Thibault
_hurd_init_dtable stays set to non-NULL, so we have to run through both _hurd_init_dtable and _hurd_dtable.
2020-11-23hurd S_msg_report_wait: Fix reporting portsSamuel Thibault
This fixes the parameter order of MSG_EXAMINE, thus fixing the detection of e.g. fd ports for nicer output in ps WAIT output.
2020-11-22hurd: Fix strcpy callsSamuel Thibault
strcpy cannot be used with overlapping buffer, we have to use memmove instead. strcpy also cannot be safely used when the destination buffer is smaller that the source, we need to use strncpy to truncate the source if needed.
2020-11-22hurd: Fix _S_msg_get/set_env_variable prototypeSamuel Thibault
_S_msg_get_env_variable and _S_msg_set_env_variable are taking string_t, not char *. Fixes a warning with gcc 11.
2020-11-15hurd: Remove some remnants of cthreadsSamuel Thibault
Libc has actually been using mach's lock-internal.h mutex for a long time already.
2020-11-13hurd: initialize libpthread before starting the signal threadSamuel Thibault
We cannot rely on csu calling __pthread_initialize_minimal before posixland_init, in some cases _init gets called before that.
2020-11-13hurd: Make _hurd_libc_proc_init idempotentSamuel Thibault
For the cases where _init is getting called several times during startup. Better clean pointers anyway.
2020-11-11hurd: Notify the proc server later during initializationSamuel Thibault
Notifying the proc server is an involved task, and unleashes various signal handling etc. so we have to do this after e.g. ifunc relocations are completed.
2020-11-11htl: Initialize laterSamuel Thibault
Since htl does not actually need a stack switch, we can initialize it like nptl is, avoiding all sorts of startup issues with ifunc. More precisely, htl defines __pthread_initialize_minimal instead of the elder _cthread_init_routine. We can then drop the stack switching dances.
2020-08-05hurd: Rework sbrkSamuel Thibault
Making the brk start exactly at the end of the main application binary was requiring to get it through the _end symbol, which does not work any more with recent toolchains, and actually produces in libc.so a confusing external _end symbol that produces odd results, see https://sourceware.org/bugzilla/show_bug.cgi?id=23499 Trying to do so is quite outdated anyway with the tendency for address randomization. Using _end was also allowing to include the main binary data within the RLIMIT_DATA, but this also seems outdated with dynamic library loading, and nowadays' memory consumption via malloc and mmap rather than statically-allocated data. This adds a BRK_START macro in <vm_param.h> that just tells where we want to start the brk, and thus removes the _end symbol. * sysdeps/mach/hurd/i386/vm_param.h: New file. * sysdeps/mach/hurd/brk.c: Use BRK_START as brk start instead of _end. Also ignore __data_start. * hurd/Versions: Remove _end symbol. * sysdeps/mach/hurd/i386/libc.abilist: Remove _end symbol.
2020-06-28hurd: Add remaining cancelation pointsSamuel Thibault
* hurd/hurdselect.c: Include <sysdep-cancel.h>. (_hurd_select): Surround call to __mach_msg with enabling async cancel. * sysdeps/mach/hurd/accept4.c: Include <sysdep-cancel.h>. (__libc_accept4): Surround call to __socket_accept with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/connect.c: Include <sysdep-cancel.h>. (__connect): Surround call to __file_name_lookup and __socket_connect with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/fdatasync.c: Include <sysdep-cancel.h>. (fdatasync): Surround call to __file_sync with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/fsync.c: Include <sysdep-cancel.h>. (fsync): Surround call to __file_sync with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/ioctl.c: Include <sysdep-cancel.h>. (__ioctl): When request is TIOCDRAIN, surround call to send_rpc with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/msync.c: Include <sysdep-cancel.h>. (msync): Surround call to __vm_object_sync with enabling async cancel. * sysdeps/mach/hurd/sigsuspend.c: Include <sysdep-cancel.h>. (__sigsuspend): Surround call to __mach_msg with enabling async cancel. * sysdeps/mach/hurd/sigwait.c: Include <sysdep-cancel.h>. (__sigwait): Surround wait code with enabling async cancel. * sysdeps/mach/msync.c: Include <sysdep-cancel.h>. (msync): Surround call to __vm_msync with enabling async cancel. * sysdeps/mach/sleep.c: Include <sysdep-cancel.h>. (__sleep): Surround call to __mach_msg with enabling async cancel. * sysdeps/mach/usleep.c: Include <sysdep-cancel.h>. (usleep): Surround call to __vm_msync with enabling async cancel.
2020-06-28hurd: clean fd and port on thread cancelSamuel Thibault
HURD_*PORT_USE link fd and port with a stack-stored structure, so on thread cancel we need to cleanup this. * hurd/fd-cleanup.c: New file. * hurd/port-cleanup.c (_hurd_port_use_cleanup): New function. * hurd/Makefile (routines): Add fd-cleanup. * sysdeps/hurd/include/hurd.h (__USEPORT_CANCEL): New macro. * sysdeps/hurd/include/hurd/fd.h (_hurd_fd_port_use_data): New structure. (_hurd_fd_port_use_cleanup): New prototype. (HURD_DPORT_USE_CANCEL, HURD_FD_PORT_USE_CANCEL): New macros. * sysdeps/hurd/include/hurd/port.h (_hurd_port_use_data): New structure. (_hurd_port_use_cleanup): New prototype. (HURD_PORT_USE_CANCEL): New macro. * hurd/hurd/fd.h (HURD_FD_PORT_USE): Also refer to HURD_FD_PORT_USE_CANCEL. * hurd/hurd.h (__USEPORT): Also refer to __USEPORT_CANCEL. * hurd/hurd/port.h (HURD_PORT_USE): Also refer to HURD_PORT_USE_CANCEL. * hurd/fd-read.c (_hurd_fd_read): Call HURD_FD_PORT_USE_CANCEL instead of HURD_FD_PORT_USE. * hurd/fd-write.c (_hurd_fd_write): Likewise. * sysdeps/mach/hurd/send.c (__send): Call HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/sendmsg.c (__libc_sendmsg): Likewise. * sysdeps/mach/hurd/sendto.c (__sendto): Likewise. * sysdeps/mach/hurd/recv.c (__recv): Likewise. * sysdeps/mach/hurd/recvfrom.c (__recvfrom): Likewise. * sysdeps/mach/hurd/recvmsg.c (__libc_recvmsg): Call __USEPORT_CANCEL instead of __USEPORT, and HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE.
2020-06-07hurd: Fix hang in _hurd_raise_signal from pthread_killSamuel Thibault
When ss is not NULL, it is assumed to be locked. * hurd/hurd-raise.c (_hurd_raise_signal): Unlock before returning an error if ss is not NULL.
2020-06-07hurd: Reject raising invalid signalsSamuel Thibault
* hurd/hurd-raise.c (_hurd_raise_signal): Return EINVAL if signo <= 0 or signo >= NSI.
2020-05-28Hurd: Move <hurd/sigpreempt.h> internals into wrapper headerFlorian Weimer
_hurdsig_preemptors and _hurdsig_preempted_set are not ABI symbols, so do not declare them. HURD_PREEMPT_SIGNAL_P is an implementation detail, so move it as well. Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2020-05-28Hurd: Use __sigmask in favor of deprecated sigmaskFlorian Weimer
This fixes various build errors due to deprecation warnings. Fixes commit 02802fafcf6e11ea3f998f685035ffe568dfddeb ("signal: Deprecate additional legacy signal handling functions"). Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2020-05-28hurd: Fix pselect atomicitySamuel Thibault
In case the signal arrives before the __mach_msg call, we need to catch between the sigprocmask call and the __mach_msg call. Let's just reuse the support for sigsuspend to make the signal send a message that our __mach_msg call will just receive. * hurd/hurdselect.c (_hurd_select): Add sigport and ss variables. When sigmask is not NULL, create a sigport port and register as ss->suspended. Add it to the portset. When we receive a message on it, set error to EINTR. Clean up sigport and portset appropriately. * hurd/hurdsig.c (wake_sigsuspend): Note that pselect also uses it.
2020-05-26htl: Add clock variantsSamuel Thibault
* htl/pt-join.c (__pthread_join): Move implementation to... (__pthread_join_common): ... new function. Add try, timed and clock support. (__pthread_join): Reimplement on top of __pthread_join_common. (__pthread_tryjoin_np, __pthread_timedjoin_np, __pthread_clockjoin_np): Implement on top of __pthread_join_common. (pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np): New aliases. * hurd/hurdlock.c (__lll_abstimed_wait, __lll_abstimed_xwait, __lll_abstimed_lock): Check for supported clock. * sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal): Add clockid parameter and support it. (__pthread_cond_timedwait): Pass -1 as clockid. (__pthread_cond_clockwait): New function. (pthread_cond_clockwait): New alias. * sysdeps/htl/pt-cond-wait.c (__pthread_cond_timedwait_internal): Update prototype. (__pthread_cond_wait): Pass -1 as clockid. * sysdeps/htl/pt-rwlock-timedrdlock.c (__pthread_rwlock_timedrdlock_internal): Add clockid parameter, and support id. (__pthread_rwlock_clockrdlock): New function. (pthread_rwlock_clockrdlock): New alias. * sysdeps/htl/pt-rwlock-rdlock.c (__pthread_rwlock_timedrdlock_internal): Update prototype. (__pthread_rwlock_rdlock): Pass -1 as clockid. * sysdeps/htl/pt-rwlock-timedwrlock.c (__pthread_rwlock_timedwrlock_internal): Add clockid parameter, and support id. (__pthread_rwlock_clockwrlock): New function. (pthread_rwlock_clockwrlock): New alias. * sysdeps/htl/pt-rwlock-wrlock.c (__pthread_rwlock_timedwrlock_internal): Update prototype. (__pthread_rwlock_wrlock): Pass -1 as clockid. * sysdeps/mach/hurd/htl/pt-mutex-timedlock.c (__pthread_mutex_timedlock): Move implementation to (__pthread_mutex_clocklock): New function with additional clockid parameter and support it. (pthread_mutex_clocklock): New alias. (__pthread_mutex_timedlock): Reimplement on top of __pthread_mutex_clocklock. * sysdeps/htl/pthread.h (pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np, pthread_mutex_clocklock, pthread_cond_clockwait, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock): New prototypes. * sysdeps/htl/pthreadP.h (__pthread_cond_clockwait): New prototype. * htl/Versions (GLIBC_2.32): Add pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock, pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np. * sysdeps/mach/hurd/i386/libpthread.abilist (pthread_clockjoin_np, pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock, pthread_timedjoin_np, pthread_tryjoin_np): New functions. * nptl/tst-abstime.c, nptl/tst-join10.c, nptl/tst-join11.c, nptl/tst-join12.c, nptl/tst-join13.c, nptl/tst-join14.c, nptl/tst-join2.c, nptl/tst-join3.c, nptl/tst-join8.c, nptl/tst-join9.c, nptl/tst-mutex-errorcheck.c, nptl/tst-pthread-mutexattr.c, nptl/tst-mutex11.c, nptl/tst-mutex5.c, nptl/tst-mutex7.c, nptl/tst-mutex7robus.c, nptl/tst-mutex9.c, nptl/tst-rwlock12.c, nptl/tst-rwlock14.c: Move to sysdeps/pthread. * sysdeps/pthread/tst-mutex8.c: Move back to nptl. * nptl/Makefile (tests): Move tst-mutex5, tst-mutex7, tst-mutex7robust, tst-mutex9, tst-mutex11, tst-rwlock12, tst-rwlock14, tst-join2, tst-join3, tst-join8, tst-join9 tst-join10, tst-join11, tst-join12, tst-join13, tst-join14, tst-abstime, tst-mutex-errorcheck, tst-pthread-mutexattr to ... * sysdeps/pthread/Makefile (tests): ... here.
2020-05-11hurd: Add missing sigstate members initializationSamuel Thibault
* hurd/hurdsig.c (_hurd_thread_sigstate): Initialize critical_section_lock, active_resources, cancel, and cancel_hook fields.
2020-03-29hurd: Make O_TRUNC update mtime/ctimeSamuel Thibault
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Call __file_utimens after __file_set_size.
2020-02-15hurd: Add THREAD_GET/SETMEM/_NCSamuel Thibault
Store them in the TCB, and use them for accessing _hurd_sigstate.