about summary refs log tree commit diff
path: root/hurd
Commit message (Collapse)AuthorAgeFilesLines
* Add bits/types/ wrappers for stddef.h and stdarg.h types.Zack Weinberg2020-01-084-24/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We rely on the compiler's stddef.h and stdarg.h to define size_t, ptrdiff_t, wchar_t, NULL, and __gnuc_va_list, and to implement a convention that allows us to request the definition of a specific one: for instance #define __need_size_t #include <stddef.h> is expected to define size_t but not any of the other things stddef.h defines. This patch hides that convention behind a set of bits/types/ headers, which allows check-obsolete-constructs.py to verify that none of our headers include these headers unconditionally. (Both of them define at least one item in the user namespace that no other header is supposed to expose.) It will also facilitate coping with compilers that don’t implement the __need convention. (That scenario is not hypothetical, see the next patch.) Only public headers use the new bits headers. Non-public headers and .c files in our codebase, that were formerly defining __need macros, now just include stddef.h and/or stdarg.h without any __need macros. A few files didn’t need to be including stddef.h / stdarg.h at all. Uses of NULL in public headers that aren’t expected to define NULL are changed to a bare 0. bits/NULL.h is only used by headers that are expected to define NULL. malloc.h and printf.h were, in fact, including stddef.h and/or stdarg.h unconditionally; they no longer do that. This broke a few of our test cases, which are fixed by adding appropriate inclusions to the relevant .c files. * stdlib/bits/NULL.h * stdlib/bits/types/__va_list.h * stdlib/bits/types/ptrdiff_t.h * stdlib/bits/types/size_t.h * stdlib/bits/types/va_list.h * stdlib/bits/types/wchar_t.h: New headers defining a single type or macro each. * stdlib/Makefile: Install new headers. * include/bits/NULL.h * include/bits/types/__va_list.h * include/bits/types/ptrdiff_t.h * include/bits/types/size_t.h * include/bits/types/va_list.h * include/bits/types/wchar_t.h: New wrapper headers. * malloc/malloc.h: Don’t include stdio.h or stddef.h. Include bits/NULL.h, bits/types/size_t.h, bits/types/ptrdiff_t.h, and bits/types/FILE.h. * stdio-common/printf.h: Don’t include stddef.h or stdarg.h. Include bits/types/size_t.h, bits/types/wchar_t.h, and bits/types/__va_list.h. Use __gnuc_va_list instead of va_list in prototypes. * libio/bits/types/struct_FILE.h: Include bits/types/size_t.h. * misc/sys/param.h: Include features.h. * sysvipc/sys/msg.h: Include bits/msq.h after all bits/types/ headers. * sysvipc/sys/sem.h: Include bits/sem.h after all bits/types/ headers. * sysvipc/sys/shm.h: Include bits/shm.h after all bits/types/ headers. * hurd/hurd/signal.h: Don’t use NULL. * hurd/hurd/ioctl.h: Don’t include stdarg.h. * hurd/hurd/userlink.h: Don’t include stddef.h. Don’t use NULL. * intl/libintl.h: Don’t include stddef.h. Don’t use NULL. * intl/gettext.c, intl/ngettext.c: Include stddef.h unconditionally. Don’t define any __need macros first. Don’t include stdlib.h. * sysdeps/posix/sigignore.c:, sysdeps/posix/sigset.c: Don’t include errno.h or string.h. * malloc/tst-malloc-thread-fail.c: Include stddef.h. * malloc/tst-malloc_info.c: Include stdio.h. * stdio-common/tst-vfprintf-user-type.c: Include stdarg.h. * string/tst-cmp.c: Include stdio.h. * debug/wcpcpy_chk.c, iconv/loop.c, iconv/skeleton.c * signal/sighold.c, signal/sigrelse.c, stdio-common/tempname.c * sysdeps/generic/ldsodefs.h, sysdeps/nptl/libc-lock.h * sysdeps/nptl/libc-lockP.h, sysdeps/posix/waitid.c * wcsmbs/wcstol_l.c, wcsmbs/wcstoll_l.c, wcsmbs/wcstoul_l.c * wcsmbs/wcstoull_l.c, sysdeps/posix/sigignore.c * sysdeps/posix/sigset.c: Don’t define __need macros before including stddef.h. * bits/socket.h, bits/types/stack_t.h, dirent/dirent.h * dlfcn/dlfcn.h, gmon/sys/profil.h, grp/grp.h, gshadow/gshadow.h * hurd/hurd/signal.h, hurd/hurd/sigpreempt.h, iconv/gconv.h * include/set-hooks.h, include/stdio.h, inet/aliases.h * io/sys/sendfile.h, libio/stdio.h, misc/bits/types/struct_iovec.h * misc/search.h, misc/sys/mman.h, misc/syslog.h, posix/glob.h * posix/sched.h, posix/sys/types.h, posix/unistd.h * posix/wordexp.h, pwd/pwd.h, shadow/shadow.h, signal/signal.h * socket/sys/socket.h, stdlib/alloca.h, stdlib/monetary.h * stdlib/stdlib.h, stdlib/sys/random.h, string/string.h * string/strings.h, sunrpc/rpc/netdb.h * sysdeps/htl/bits/types/struct___pthread_attr.h * sysdeps/mach/hurd/bits/socket.h * sysdeps/unix/sysv/linux/bits/socket.h * sysdeps/unix/sysv/linux/bits/types/stack_t.h * sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h * sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h * sysdeps/unix/sysv/linux/scsi/sg.h * sysdeps/unix/sysv/linux/sys/sysctl.h * sysvipc/sys/msg.h, sysvipc/sys/sem.h, sysvipc/sys/shm.h * time/time.h, wcsmbs/uchar.h, wcsmbs/wchar.h: Use bits/types/size_t.h instead of __need_size_t. * iconv/gconv.h, iconv/iconv.h, libio/libio.h * stdlib/inttypes.h, stdlib/stdlib.h, wcsmbs/wchar.h: Use bits/types/wchar_t.h instead of __need_wchar_t. * libio/stdio.h, locale/locale.h, misc/sys/param.h * posix/sched.h, posix/unistd.h, stdlib/stdlib.h * string/string.h, sysdeps/unix/sysv/linux/bits/sigcontext.h * time/time.h, wcsmbs/wchar.h: Use bits/NULL.h instead of __need_NULL. * libio/stdio.h, misc/err.h: Use bits/types/__va_list.h instead of __need___va_list. * libio/stdio.h: Use bits/types/va_list.h instead of manually defining va_list. * hurd/hurd/userlink.h, misc/sys/mman.h, posix/sched.h * sysdeps/mach/hurd/bits/socket.h * sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h * wcsmbs/wchar.h: Reorganize includes; no semantic effect. * stdlib/stdlib.h: Normalize format of multiple include guard. * sysdeps/unix/sysv/linux/bits/sigcontext.h: Annotate workarounds for kernel header bugs. * sysdeps/unix/sysv/linux/aarch64/sys/user.h * sysdeps/unix/sysv/linux/arm/sys/user.h * sysdeps/unix/sysv/linux/m68k/sys/user.h * sysdeps/unix/sysv/linux/microblaze/sys/user.h * sysdeps/unix/sysv/linux/nios2/sys/user.h * sysdeps/unix/sysv/linux/s390/sys/user.h * sysdeps/unix/sysv/linux/x86/sys/user.h Include features.h. * sysdeps/unix/sysv/linux/alpha/sys/user.h * sysdeps/unix/sysv/linux/ia64/sys/user.h * sysdeps/unix/sysv/linux/mips/sys/user.h * sysdeps/unix/sysv/linux/powerpc/sys/user.h * sysdeps/unix/sysv/linux/sh/sys/user.h * sysdeps/unix/sysv/linux/sparc/sys/user.h Include features.h and bits/types/size_t.h, in that order. Include kernel headers, if any, after those two. Don’t include stddef.h or sys/types.h. * scripts/check-obsolete-constructs.py (UNIVERSAL_ALLOWED_INCLUDES): Remove stddef.h and stdarg.h. (HEADER_ALLOWED_INCLUDES): Update.
* Add caddr_t, daddr_t, and loff_t to the set of obsolete typedefs.Zack Weinberg2020-01-084-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | caddr_t is a BSD-derived alias for ‘char *’, obsoleted by the introduction of ‘void *’ in C89 (!) daddr_t is a “disk address,” but it’s always defined as ‘int’, making it too small for modern disks and tapes. loff_t is another name for off64_t, from early drafts of LFS. All three are already only exposed by sys/types.h under __USE_MISC. This patch adds them to the set of types that shall not be used in installed headers (enforced by check-obsolete-constructs.py) and expunges all remaining uses, internally as well as in installed headers. Since __DADDR_T_TYPE is always defined as __S32_TYPE, and daddr_t is obsolete so there’s no need to worry about future variation, the patch also removes __DADDR_T_TYPE from the set of macros that bits/typesizes.h is required to define. Instead bits/types.h always defines __daddr_t as __S32_TYPE, and the definition is moved to a more logical location within the file, next to __caddr_t. It’s always safe to change (__)loff_t to the matching (__)off64_t; in a few internal files, I removed an unnecessary __ prefix. daddr_t is only used for struct ustat, which is obsoleted by struct statvfs and we already don’t declare it in public headers, and for an ioctl parameter block in sys/mtio.h (which may or may not be obsolete, I can’t tell). In sys/mtio.h I replaced both uses with ‘int’ to match the use of bare ‘long int’ for most of the other fields of that structure. In misc/ustat.c, the definition of struct ustat is not actually necessary so I removed it entirely. In sysdeps/unix/sysv/linux/ustat.c a definition is necessary but only because INLINE_SYSCALL_CALL doesn’t work (on at least x86) when an argument is a pointer to an incomplete type, so I substituted a dummy definition. Most of the internal uses of caddr_t are in the sunrpc and nis directories, and since most of that code is obsolete, I mechanically replaced them with char * rather than consider whether void * might make more sense. Because “const caddr_t foo” is semantically different from “const char *foo” (in the first case ‘foo’ itself is const but the memory pointed to isn’t, in the second case the memory pointed to is const but ‘foo’ isn’t) this change exposed some const-correctness errors in sunrpc, which I fixed minimally. Outside of sunrpc and nis, I put a little more thought into whether uses of caddr_t should be void * instead. * scripts/check-obsolete-constructs.py: Add caddr_t, daddr_t, and loff_t to the set of obsolete types forbidden in public headers. * posix/bits/types.h: Unconditionally define __daddr_t as __S32_TYPE. Move definition of __daddr_t next to definition of __caddr_t. * bits/typesizes.h * sysdeps/mach/hurd/bits/typesizes.h * sysdeps/unix/sysv/linux/alpha/bits/typesizes.h * sysdeps/unix/sysv/linux/generic/bits/typesizes.h * sysdeps/unix/sysv/linux/mips/bits/typesizes.h * sysdeps/unix/sysv/linux/s390/bits/typesizes.h * sysdeps/unix/sysv/linux/sparc/bits/typesizes.h * sysdeps/unix/sysv/linux/x86/bits/typesizes.h: Don’t define __DADDR_T_TYPE. * sysdeps/gnu/sys/mtio.h (struct mtget): Change all uses of __daddr_t to int. * misc/ustat.c: Remove definition of struct ustat; only forward-declare it. * sysdeps/unix/sysv/linux/ustat.c: Replace fields of struct ustat with a size-preserving dummy field. * hurd/Makefile (migheaderpipe): Rewrite loff_t as __off64_t. * hurd/fd-read.c (_hurd_fd_read): Use off64_t instead of loff_t. * hurd/fd-write.c (hurd_fd_write): Use off64_t instead of loff_t. * hurd/hurd/fd.h (_hurd_fd_read, _hurd_fd_write): Declare using __off64_t instead of __loff_t. * support/xunistd.h (xcopy_file_range): Declare using off64_t instead of loff_t. * sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h * sysdeps/unix/sysv/linux/lseek.c * sysdeps/unix/sysv/linux/lseek64.c * sysdeps/unix/sysv/linux/splice.c Throughout, use off64_t instead of loff_t. * sysdeps/unix/sysv/linux/sys/quota.h (dqoff): Use __off64_t instead of __loff_t. (quotactl): Declare using char * instead of caddr_t. * sysdeps/unix/sysv/linux/test-errno-linux.c (do_test): Cast to char * instead of caddr_t when calling quotactl. * elf/dl-map-segments.h (_dl_map_segments): Cast to void * instead of caddr_t when calling __mprotect and __mmap. * elf/dl-minimal.c (malloc): Declare page as char *, not caddr_t. * elf/dl-reloc.c (_dl_relocate_object): Declare textrels.start as char *, not caddr_t. Cast to char *, not caddr_t, in pointer arithmetic. * intl/loadmsgcat.c: Remove two unnecessary casts to caddr_t when calling munmap. Change a third cast to target void * instead and add a comment explaining why this one is necessary. * locale/loadlocale.c (_nl_load_locale): Use NULL instead of `(caddr_t)0`, and remove an unnecessary cast to caddr_t when calling munmap. (_nl_unload_locale): Change casts when calling free and munmap to target char *, and add a comment explaining why they are necessary. * sysdeps/gnu/net/if.h (struct ifreq): Declare ifru_data as char *, not __caddr_t. (struct ifconf): Declare ifcu_buf as char *, not __caddr_t. * nis/nis_add.c * nis/nis_call.c * nis/nis_callback.c * nis/nis_checkpoint.c * nis/nis_findserv.c * nis/nis_intern.h * nis/nis_lookup.c * nis/nis_mkdir.c * nis/nis_modify.c * nis/nis_ping.c * nis/nis_remove.c * nis/nis_rmdir.c * nis/nis_server.c * nis/nis_table.c * nis/nis_util.c * nis/nss_nisplus/nisplus-grp.c * nis/nss_nisplus/nisplus-pwd.c * nis/rpcsvc/nis_callback.h * nis/rpcsvc/yp.h * nis/ypclnt.c * sunrpc/auth_des.c * sunrpc/auth_unix.c * sunrpc/authdes_prot.c * sunrpc/authuxprot.c * sunrpc/clnt_raw.c * sunrpc/clnt_tcp.c * sunrpc/clnt_udp.c * sunrpc/clnt_unix.c * sunrpc/key_call.c * sunrpc/pm_getmaps.c * sunrpc/pm_getport.c * sunrpc/pmap_clnt.c * sunrpc/pmap_prot2.c * sunrpc/pmap_rmt.c * sunrpc/proto.h * sunrpc/rpc/auth.h * sunrpc/rpc/clnt.h * sunrpc/rpc/pmap_clnt.h * sunrpc/rpc/pmap_rmt.h * sunrpc/rpc/rpc_msg.h * sunrpc/rpc/svc.h * sunrpc/rpc/xdr.h * sunrpc/rpc_clntout.c * sunrpc/rpc_cmsg.c * sunrpc/rpc_hout.c * sunrpc/rpc_prot.c * sunrpc/rpc_sample.c * sunrpc/rpc_svcout.c * sunrpc/svc.c * sunrpc/svc_authux.c * sunrpc/svc_raw.c * sunrpc/svc_tcp.c * sunrpc/svc_udp.c * sunrpc/svc_unix.c * sunrpc/xdr.c * sunrpc/xdr_array.c * sunrpc/xdr_mem.c * sunrpc/xdr_rec.c * sunrpc/xdr_ref.c * sunrpc/xdr_sizeof.c * sunrpc/xdr_stdio.c: Mechanically replace all uses of caddr_t with char *. * sunrpc/xdr_mem.c (xdrmem_create): Cast away const when setting xdrs->x_private and xdrs->x_base. * sunrpc/xdr_stdio.c (xdrstdio_getbytes): Correct argument types in definition to match prototype.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2020-01-0187-87/+87
|
* hurd: Global signal dispositionJeremie Koenig2019-12-297-108/+282
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds _hurd_sigstate_set_global_rcv used by libpthread to enable POSIX-confirming behavior of signals on a per-thread basis. This also provides a sigstate destructor _hurd_sigstate_delete, and a global process signal state, which needs to be locked and check when global disposition is enabled, thus the addition of _hurd_sigstate_lock _hurd_sigstate_actions _hurd_sigstate_pending _hurd_sigstate_unlock helpers. This also updates all the glibc code accordingly. This also drops support for get_int(INIT_SIGMASK), which did not make sense any more since we do not have a single signal thread any more. During fork/spawn, this also reinitializes the child global sigstate's lock. That cures an issue that would very rarely cause a deadlock in the child in fork, tries to unlock ss' critical section lock at the end of fork. This will typically (always?) be observed in /bin/sh, which is not surprising as that is the foremost caller of fork. To reproduce an intermediate state, add an endless loop if _hurd_global_sigstate is locked after __proc_dostop (cast through volatile); that is, while still being in the fork's parent process. When that triggers (use the libtool testsuite), the signal thread has already locked ss (which is _hurd_global_sigstate), and is stuck at hurdsig.c:685 in post_signal, trying to lock _hurd_siglock (which the main thread already has locked and keeps locked until after __task_create). This is the case that ss->thread == MACH_PORT_NULL, that is, a global signal. In the main thread, between __proc_dostop and __task_create is the __thread_abort call on the signal thread which would abort any current kernel operation (but leave ss locked). Later in fork, in the parent, when _hurd_siglock is unlocked in fork, the parent's signal thread can proceed and will unlock eventually the global sigstate. In the client, _hurd_siglock will likewise be unlocked, but the global sigstate never will be, as the client's signal thread has been configured to restart execution from _hurd_msgport_receive. Thus, when the child tries to unlock ss' critical section lock at the end of fork, it will first lock the global sigstate, will spin trying to lock it, which can never be successful, and we get our deadlock. Options seem to be: * Move the locking of _hurd_siglock earlier in post_signal -- but that may generally impact performance, if this locking isn't generally needed anyway? On the other hand, would it actually make sense to wait here until we are not any longer in a critical section (which is meant to disable signal delivery anyway (but not for preempted signals?))? * Clear the global sigstate in the fork's child with the rationale that we're anyway restarting the signal thread from a clean state. This has now been implemented. Why has this problem not been observed before Jérémie's patches? (Or has it? Perhaps even more rarely?) In _S_msg_sig_post, the signal is now posted to a *global receiver thread*, whereas previously it was posted to the *designated signal-receiving thread*. The latter one was in a critical section in fork, so didn't try to handle the signal until after leaving the critical section? (Not completely analyzed and verified.) Another question is what the signal is that is being received during/around the time __proc_dostop executes.
* hurd: Signal code refactoringJeremie Koenig2019-12-291-112/+160
| | | | | | | | | | | | | This should not change the current behavior, although this fixes a few minor bugs which were made apparent in the process of global signal disposition work: - Split into more functions - Scope variables more restrictively - Split out inner functions - refactor check_pending_signals - make sigsuspend POSIX-conformant. - fix uninitialized act value.
* hurd: Use __clock_gettime in _hurd_selectFlorian Weimer2019-11-071-7/+4
| | | | | | | | | The __gettimeofday references caused check-localplt failures after commit 5e46749c64d5. Fixes: 5e46749c64d51f50f8511ed99c1266d7c13e182b Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Change-Id: Ia6da4045157a5bbccc67d79e881d7592e6f8a890
* time: Introduce function to check correctness of nanoseconds valueLukasz Majewski2019-10-272-3/+3
| | | | | | | | | | | | | | | The valid_nanoseconds () static inline function has been introduced to check if nanoseconds value is in the correct range - greater or equal to zero and less than 1000000000. The explicit #include <time.h> has been added to files where it was missing. The __syscall_slong_t type for ns has been used to avoid issues on x32. Tested with: - scripts/build-many-glibcs.py - make PARALLELMFLAGS="-j12" && make PARALLELMFLAGS="-j12" xcheck on x86_64
* Prefer https to http for gnu.org and fsf.org URLsPaul Eggert2019-09-0786-86/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
* hurd: Fix poll and select POSIX compliancy details about errorsSamuel Thibault2019-08-301-41/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the following: - On error, poll must not return without polling, including EBADF, and instead report POLLHUP/POLLERR/POLLNVAL - Select must report EBADF if some set contains an invalid FD. The idea is to move error management to after all select calls, in the poll/select final treatment. The error is instead recorded in a new `error' field, and a new SELECT_ERROR bit set. Thanks Svante Signell for the initial version of the patch. * hurd/hurdselect.c (SELECT_ERROR): New macro. (_hurd_select): - Add `error' field to `d' structures array. - If a poll descriptor is bogus, set EBADF, but continue with a zero timeout. - Go through the whole fd_set, not only until _hurd_dtablesize. Return EBADF there is any bit set above _hurd_dtablesize. - Do not request io_select on bogus descriptors (SELECT_ERROR). - On io_select request error, record the error. - On io_select bogus reply, use EIO error code. - On io_select bogus or error reply, record the error. - Do not destroy reply port for bogus FDs. - On error, make poll set POLLHUP in the EPIPE case, POLLNVAL in the EBADF case, or else POLLERR. - On error, make select simulated readiness.
* hurd: Fix timeout handling in _hurd_selectRichard Braun2019-08-302-40/+79
| | | | | | | | | | | | | | | | | | | Rely on servers to implement timeouts, so that very short values (including 0) don't make mach_msg return before valid replies can be received. The purpose of this scheme is to guarantee a full client-server round-trip, whatever the timeout value. This change depends on the new io_select_timeout RPC being implemented by servers. * hurd/Makefile (user-interfaces): Add io_reply and io_request. * hurd/hurdselect.c: Include <sys/time.h>, <hurd/io_request.h> and <limits.h>. (_hurd_select): Replace the call to __io_select with either __io_select_request or __io_select_timeout_request, depending on the timeout. Count the number of ready descriptors (replies for which at least one type bit is set). Implement the timeout locally when there is no file descriptor.
* hurd: Fix _hurd_select for single fd setsRichard Braun2019-08-301-4/+1
| | | | | | | | | | | | The function attempts to optimize this case by performing one IPC system call with the timeout included among the parameters, but in the absence of a reply, it will call mach_msg again with the same timeout later, effectively doubling the total timeout of the select/poll call. Remove this optimization for the time being. * hurd/hurdselect.c (_hurd_select): Always call __io_select with no timeout.
* hurd: Fix comment styleSamuel Thibault2019-03-161-2/+1
|
* hurd: Document how EINTR should be handled in critical sectionsSamuel Thibault2019-03-161-1/+7
| | | | | * hurd/hurd/signal.h (_hurd_critical_section_lock): Document how EINTR should be handled.
* Fix -Wempty-body warnings in Hurd-specific code.Joseph Myers2019-02-271-4/+6
| | | | | | | | | | | | | | | | This patch fixes -Wempty-body warnings in Hurd-specific code that show up building glibc with -Wextra. Note: there also such warnings on many platforms arising from the default definition of HP_TIMING_NOW in sysdeps/generic/hp-timing.h, but no change there is proposed in this patch because of other changes under discussion in that area that would result in a nonempty definition. Tested with build-many-glibcs.py. * hurd/hurdinit.c (_hurd_init): Use braces around empty body of an if statement.
* Break more lines before not after operators.Joseph Myers2019-02-257-32/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes further coding style fixes where code was breaking lines after an operator, contrary to the GNU Coding Standards. As with the previous patch, it is limited to files following a reasonable approximation to GNU style already, and is not exhaustive; more such issues remain to be fixed. Tested for x86_64, and with build-many-glibcs.py. * dirent/dirent.h [!_DIRENT_HAVE_D_NAMLEN && _DIRENT_HAVE_D_RECLEN] (_D_ALLOC_NAMLEN): Break lines before rather than after operators. * elf/cache.c (print_cache): Likewise. * gshadow/fgetsgent_r.c (__fgetsgent_r): Likewise. * htl/pt-getattr.c (__pthread_getattr_np): Likewise. * hurd/hurdinit.c (_hurd_setproc): Likewise. * hurd/hurdkill.c (_hurd_sig_post): Likewise. * hurd/hurdlookup.c (__file_name_lookup_under): Likewise. * hurd/hurdsig.c (_hurd_internal_post_signal): Likewise. (reauth_proc): Likewise. * hurd/lookup-at.c (__file_name_lookup_at): Likewise. (__file_name_split_at): Likewise. (__directory_name_split_at): Likewise. * hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise. * hurd/port2fd.c (_hurd_port2fd): Likewise. * iconv/gconv_dl.c (do_print): Likewise. * inet/netinet/in.h (struct sockaddr_in): Likewise. * libio/wstrops.c (_IO_wstr_seekoff): Likewise. * locale/setlocale.c (new_composite_name): Likewise. * malloc/memusagestat.c (main): Likewise. * misc/fstab.c (fstab_convert): Likewise. * nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt): Likewise. * nss/nss_compat/compat-grp.c (getgrent_next_nss): Likewise. (getgrent_next_file): Likewise. (internal_getgrnam_r): Likewise. (internal_getgrgid_r): Likewise. * nss/nss_compat/compat-initgroups.c (getgrent_next_nss): Likewise. (internal_getgrent_r): Likewise. * nss/nss_compat/compat-pwd.c (getpwent_next_nss_netgr): Likewise. (getpwent_next_nss): Likewise. (getpwent_next_file): Likewise. (internal_getpwnam_r): Likewise. (internal_getpwuid_r): Likewise. * nss/nss_compat/compat-spwd.c (getspent_next_nss_netgr): Likewise. (getspent_next_nss): Likewise. (internal_getspnam_r): Likewise. * pwd/fgetpwent_r.c (__fgetpwent_r): Likewise. * shadow/fgetspent_r.c (__fgetspent_r): Likewise. * string/strchr.c (STRCHR): Likewise. * string/strchrnul.c (STRCHRNUL): Likewise. * sysdeps/aarch64/fpu/fpu_control.h (_FPU_FPCR_IEEE): Likewise. * sysdeps/aarch64/sfp-machine.h (_FP_CHOOSENAN): Likewise. * sysdeps/csky/dl-machine.h (elf_machine_rela): Likewise. * sysdeps/generic/memcopy.h (PAGE_COPY_FWD_MAYBE): Likewise. * sysdeps/generic/symbol-hacks.h (__stack_chk_fail_local): Likewise. * sysdeps/gnu/netinet/ip_icmp.h (ICMP_INFOTYPE): Likewise. * sysdeps/gnu/updwtmp.c (TRANSFORM_UTMP_FILE_NAME): Likewise. * sysdeps/gnu/utmp_file.c (TRANSFORM_UTMP_FILE_NAME): Likewise. * sysdeps/hppa/jmpbuf-unwind.h (_JMPBUF_UNWINDS): Likewise. * sysdeps/mach/hurd/bits/stat.h (S_ISPARE): Likewise. * sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start): Likewise. (open_file): Likewise. * sysdeps/mach/hurd/htl/pt-mutexattr-setprotocol.c (pthread_mutexattr_setprotocol): Likewise. * sysdeps/mach/hurd/ioctl.c (__ioctl): Likewise. * sysdeps/mach/hurd/mmap.c (__mmap): Likewise. * sysdeps/mach/hurd/ptrace.c (ptrace): Likewise. * sysdeps/mach/hurd/spawni.c (__spawni): Likewise. * sysdeps/microblaze/dl-machine.h (elf_machine_type_class): Likewise. (elf_machine_rela): Likewise. * sysdeps/mips/mips32/sfp-machine.h (_FP_CHOOSENAN): Likewise. * sysdeps/mips/mips64/sfp-machine.h (_FP_CHOOSENAN): Likewise. * sysdeps/mips/sys/asm.h (multiple #if conditionals): Likewise. * sysdeps/posix/rename.c (rename): Likewise. * sysdeps/powerpc/novmx-sigjmp.c (__novmx__sigjmp_save): Likewise. * sysdeps/powerpc/sigjmp.c (__vmx__sigjmp_save): Likewise. * sysdeps/s390/fpu/fenv_libc.h (FPC_VALID_MASK): Likewise. * sysdeps/s390/utf8-utf16-z9.c (gconv_end): Likewise. * sysdeps/unix/grantpt.c (grantpt): Likewise. * sysdeps/unix/sysv/linux/a.out.h (N_TXTOFF): Likewise. * sysdeps/unix/sysv/linux/updwtmp.c (TRANSFORM_UTMP_FILE_NAME): Likewise. * sysdeps/unix/sysv/linux/utmp_file.c (TRANSFORM_UTMP_FILE_NAME): Likewise. * sysdeps/x86/cpu-features.c (get_common_indices): Likewise. * time/tzfile.c (__tzfile_compute): Likewise.
* Break some lines before not after operators.Joseph Myers2019-02-2215-79/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The GNU Coding Standards specify that line breaks in expressions should go before an operator, not after one. This patch fixes various code to do this. It only changes code that appears to be mostly following GNU style anyway, not files and directories with substantially different formatting. It is not exhaustive even for files using GNU style (for example, changes to sysdeps files are deferred for subsequent cleanups). Some files changed are shared with gnulib, but most are specific to glibc. Changes were made manually, with places to change found by grep (so some cases, e.g. where the operator was followed by a comment at end of line, are particularly liable to have been missed by grep, but I did include cases where the operator was followed by backslash-newline). This patch generally does not attempt to address other coding style issues in the expressions changed (for example, missing spaces before '(', or lack of parentheses to ensure indentation of continuation lines properly reflects operator precedence). Tested for x86_64, and with build-many-glibcs.py. * benchtests/bench-memmem.c (simple_memmem): Break lines before rather than after operators. * benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise. * crypt/md5.c (md5_finish_ctx): Likewise. * crypt/sha256.c (__sha256_finish_ctx): Likewise. * crypt/sha512.c (__sha512_finish_ctx): Likewise. * elf/cache.c (load_aux_cache): Likewise. * elf/dl-load.c (open_verify): Likewise. * elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise. * elf/readelflib.c (process_elf_file): Likewise. * elf/rtld.c (dl_main): Likewise. * elf/sprof.c (generate_call_graph): Likewise. * hurd/ctty-input.c (_hurd_ctty_input): Likewise. * hurd/ctty-output.c (_hurd_ctty_output): Likewise. * hurd/dtable.c (reauth_dtable): Likewise. * hurd/getdport.c (__getdport): Likewise. * hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise. * hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise. * hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise): Likewise. * hurd/hurdioctl.c (fioctl): Likewise. * hurd/hurdselect.c (_hurd_select): Likewise. * hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise. (STOPSIGS): Likewise. * hurd/hurdstartup.c (_hurd_startup): Likewise. * hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise. * hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise. * hurd/msgportdemux.c (msgport_server): Likewise. * hurd/setauth.c (_hurd_setauth): Likewise. * include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise. * libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise. * locale/programs/ld-ctype.c (set_class_defaults): Likewise. * localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise. * login/tst-utmp.c (do_check): Likewise. (simulate_login): Likewise. * mach/lowlevellock.h (lll_lock): Likewise. (lll_trylock): Likewise. * math/test-fenv.c (ALL_EXC): Likewise. * math/test-fenvinline.c (ALL_EXC): Likewise. * misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise. * nis/nis_call.c (__do_niscall3): Likewise. * nis/nis_callback.c (cb_prog_1): Likewise. * nis/nis_defaults.c (searchaccess): Likewise. * nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise. * nis/nis_ismember.c (internal_ismember): Likewise. * nis/nis_local_names.c (nis_local_principal): Likewise. * nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise. * nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r): Likewise. * nis/ypclnt.c (yp_match): Likewise. (yp_first): Likewise. (yp_next): Likewise. (yp_master): Likewise. (yp_order): Likewise. * nscd/hstcache.c (cache_addhst): Likewise. * nscd/initgrcache.c (addinitgroupsX): Likewise. * nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise. (internal_getpwuid_r): Likewise. * nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise. * posix/glob.h (__GLOB_FLAGS): Likewise. * posix/regcomp.c (peek_token): Likewise. (peek_token_bracket): Likewise. (parse_expression): Likewise. * posix/regexec.c (sift_states_iter_mb): Likewise. (check_node_accept_bytes): Likewise. * posix/tst-spawn3.c (do_test): Likewise. * posix/wordexp-test.c (testit): Likewise. * posix/wordexp.c (parse_tilde): Likewise. (exec_comm): Likewise. * posix/wordexp.h (__WRDE_FLAGS): Likewise. * resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise. * setjmp/sigjmp.c (__sigjmp_save): Likewise. * stdio-common/printf_fp.c (__printf_fp_l): Likewise. * stdio-common/tst-fileno.c (do_test): Likewise. * stdio-common/vfprintf-internal.c (vfprintf): Likewise. * stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise. * stdlib/strtod_l.c (round_and_return): Likewise. (____STRTOF_INTERNAL): Likewise. * stdlib/tst-strfrom.h (TEST_STRFROM): Likewise. * string/strcspn.c (STRCSPN): Likewise. * string/test-memmem.c (simple_memmem): Likewise. * termios/tcsetattr.c (tcsetattr): Likewise. * time/alt_digit.c (_nl_parse_alt_digit): Likewise. * time/asctime.c (asctime_internal): Likewise. * time/strptime_l.c (__strptime_internal): Likewise. * time/sys/time.h (timercmp): Likewise. * time/tzfile.c (__tzfile_compute): Likewise.
* hurd: Fix initial sigaltstack stateSamuel Thibault2019-01-241-0/+1
| | | | | * hurd/hurdsig.c (_hurd_thread_sigstate): Set SS_DISABLE in sigaltstack.ss_flags.
* hurd: Support AT_EMPTY_PATHSamuel Thibault2019-01-221-0/+20
| | | | | | * hurd/lookup-at.c (__file_name_lookup_at): When at_flags contains AT_EMPTY_PATH, call __dir_lookup and __hurd_file_name_lookup_retry directly instead of __hurd_file_name_lookup.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2019-01-0187-87/+87
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* hurd: Handle "pid" magical lookup retryJustus Winter2018-12-281-13/+65
| | | | | | * hurd/lookup-retry: Include <unistd.h>. (__hurd_file_name_lookup_retry): Keep a ref on last result in `lastdir'. Release it on return. Handle "pid" magical lookup retry.
* Add __v*printf_internal with flags argumentsZack Weinberg2018-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a lot more printf variants than there are scanf variants, and the code for setting up and tearing down their custom FILE variants around the call to __vf(w)printf is more complicated and variable. Therefore, I have added _internal versions of all the v*printf variants, rather than introducing helper routines so that they can all directly call __vf(w)printf_internal, as was done with scanf. As with the scanf changes, in this patch the _internal functions still look at the environmental mode bits and all callers pass 0 for the flags parameter. Several of the affected public functions had _IO_ name aliases that were not exported (but, in one case, appeared in libio.h anyway); I was originally planning to leave them as aliases to avoid having to touch internal callers, but it turns out ldbl_*_alias only work for exported symbols, so they've all been removed instead. It also turns out there were hardly any internal callers. _IO_vsprintf and _IO_vfprintf *are* exported, so those two stick around. Summary for the changes to each of the affected symbols: _IO_vfprintf, _IO_vsprintf: All internal calls removed, thus the internal declarations, as well as uses of libc_hidden_proto and libc_hidden_def, were also removed. The external symbol is now exposed via uses of ldbl_strong_alias to __vfprintf_internal and __vsprintf_internal, respectively. _IO_vasprintf, _IO_vdprintf, _IO_vsnprintf, _IO_vfwprintf, _IO_vswprintf, _IO_obstack_vprintf, _IO_obstack_printf: All internal calls removed, thus declaration in internal headers were also removed. They were never exported, so there are no aliases tying them to the internal functions. I.e.: entirely gone. __vsnprintf: Internal calls were always preceded by macros such as #define __vsnprintf _IO_vsnprintf, and #define __vsnprintf vsnprintf The macros were removed and their uses replaced with calls to the new internal function __vsnprintf_internal. Since there were no internal calls, the internal declaration was also removed. The external symbol is preserved with ldbl_weak_alias to ___vsnprintf. __vfwprintf: All internal calls converted into calls to __vfwprintf_internal, thus the internal declaration was removed. The function is now a wrapper that calls __vfwprintf_internal. The external symbol is preserved. __vswprintf: Similarly, but no external symbol. __vasprintf, __vdprintf, __vfprintf, __vsprintf: New internal wrappers. Not exported. vasprintf, vdprintf, vfprintf, vsprintf, vsnprintf, vfwprintf, vswprintf, obstack_vprintf, obstack_printf: These functions used to be aliases to the respective _IO_* function, they are now aliases to their respective __* functions. Tested for powerpc and powerpc64le.
* hurd: Fix spawni's user_link reallocationSamuel Thibault2018-11-111-2/+2
| | | | | * hurd/hurd/userlink.h (_hurd_userlink_move): Make new_link's predecessor point to new_link instead of link.
* Hurd: export _hurd_port_moveSamuel Thibault2018-11-101-0/+4
| | | | | | * hurd/Versions (_hurd_port_move): Export function. * sysdeps/mach/hurd/i386/libc.abilist (_hurd_port_move): Expect symbol.
* Hurd: Fix ulinks in fd table reallocationSamuel Thibault2018-11-102-0/+49
| | | | | | | * hurd/hurd/userlink.h (_hurd_userlink_move): New function. * hurd/hurd/port.h (_hurd_port_move): New function. * sysdeps/mach/hurd/spawni.c (NEW_ULINK_TABLE): New macro. (EXPAND_DTABLE): Use NEW_ULINK_TABLE macro for ulink_dtable.
* hurd: Add pci RPC stubsSamuel Thibault2018-10-311-1/+1
| | | | * hurd/Makefile (user-interfaces): Add pci.
* hurd: return EIEIO instead of EIOSamuel Thibault2018-10-291-2/+2
| | | | | | | EIO would be understood as hardware failure, while this is software failure. * hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Return EIEIO instead of EIO
* hurd: Fix race between calling RPC and handling a signalSamuel Thibault2018-10-282-16/+5
| | | | | | | | | | * sysdeps/mach/hurd/i386/intr-msg.h (INTR_MSG_TRAP): Make _hurd_intr_rpc_msg_about_to global point to start of controlled assembly snippet. Make it check canceled flag. * hurd/hurdsig.c (_hurdsig_abort_rpcs): Only mutate thread if it passed the _hurd_intr_rpc_msg_about_to point. * hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Remove comment on mutation issue, remove cancel flag check.
* hurd: Return EIO on non-responding interrupted serversSamuel Thibault2018-10-281-5/+9
| | | | | | | | | since we do not actually know whether the RPC was completed or not, which makes a huge difference for e.g. write(), so better really error out than letting caller think that the RPC did not happen. * hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): When the server does not answer to interrupt_operation, return EIO instead of EINTR.
* hurd: set interrupt timeout to 1 minuteSamuel Thibault2018-10-281-1/+1
| | | | | | | | Seeing a server not able to get interrupted for 3s is not so surprising when e.g. a lot of writes are happening. 1 minute allows to actually notice the issue and be able to debug it. * hurd/hurdsig.c (_hurd_interrupted_rpc_timeout): Set to 60000.
* hurd: Fix exec usage of mach_setup_threadSamuel Thibault2018-08-011-0/+2
| | | | | | | | | | | | | | | | Exec needs that mach_setup_thread does *not* set up TLS since it works on another task, so we have to split this into mach_setup_tls. * mach/mach.h (__mach_setup_tls, mach_setup_tls): Add prototypes. * mach/setup-thread.c (__mach_setup_thread): Move TLS setup to... (__mach_setup_tls): ... new function. (mach_setup_tls): New alias. * hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls after __mach_setup_thread. * sysdeps/mach/hurd/profil.c (update_waiter): Likewise. * sysdeps/mach/hurd/setitimer.c (setitimer_locked): Likewise. * mach/Versions [libc] (mach_setup_tls): Add symbol. * sysdeps/mach/hurd/i386/libc.abilist (mach_setup_tls): Likewise.
* hurd: Silence warningSamuel Thibault2018-04-041-0/+8
| | | | | * hurd/hurdsig.c (interrupted_reply_port_location): Use DIAG_IGNORE_NEEDS_COMMENT to silence warning with GCC 6 and before.
* Revert parts of "hurd: Avoid more libc.so local PLTs"Samuel Thibault2018-04-032-3/+3
| | | | This reverts parts of commit 82dbf555a4d41690f63b94ccb4db4bf43d873aa0.
* hurd: Avoid more libc.so local PLTsSamuel Thibault2018-04-032-3/+3
| | | | | | | | | | | | | | | * hurd/catch-signal.c (__hurd_catch_signal): Call __libc_siglongjmp instead if siglongjmp. (hurd_safe_memmove): Call __libc_longjmp instead of longjmp. * hurd/hurdfault.c (faulted): Call __libc_longjmp instead of longjmp. * include/setjmp.h (__libc_siglongjmp, __libc_longjmp): New hidden prototypes. * libio/iolibio.h (_IO_puts): New hidden prototype. * libio/ioputs.c (_IO_puts): New hidden def. * setjmp/longjmp.c (__libc_longjmp, __libc_siglongjmp): New hidden defs. * sysdeps/mach/hurd/sigwait.c (__sigwait): Call __libc_longjmp instead of longjmp.
* hurd: Avoid more libc.so PLTsSamuel Thibault2018-04-022-0/+2
| | | | | | | | | | | | * sysdeps/hurd/include/hurd/signal.h (_hurd_raise_signal): Add hidden prototype. * hurd/hurd-raise.c (_hurd_raise_signal): Add hidden def. * hurd/Makefile ($(inlines:%=$(objpfx)%.c): Define _HEADER_H_HIDDEN_DEF macro. * sysdeps/hurd/include/hurd/fd.h (_hurd_fd_error, _hurd_fd_error_signal): Add hidden prototype. [_HURD_FD_H_HIDDEN_DEF] (_hurd_fd_error, _hurd_fd_error_signal): Add hidden def.
* hurd: Avoid some libc.so PLTsSamuel Thibault2018-04-028-27/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * hurd/catch-signal.c (hurd_catch_signal): Rename to __hurd_catch_signal. (hurd_catch_signal): New strong alias. (hurd_safe_memset, hurd_safe_copyout, hurd_safe_copyin): Call __hurd_catch_signal instead of hurd_catch_signal. * hurd/exc2signal.c (_hurd_exception2signal): Add hidden def. * hurd/hurdexec.c (_hurd_init): Add hidden def. * hurd/hurdinit.c (_hurd_init): Add hidden def. * hurd/hurdsig.c: Include <mach/mig_support.h>. (_hurd_thread_sigstate): Add hidden def. (_hurd_internal_post_signal): Use __mutex_unlock instead of mutex_unlock. * hurd/intern-fd.c (_hurd_intern_fd): Add hidden def. * hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Add hidden def. * hurd/path-lookup.c (hurd_file_name_path_lookup): Rename to __hurd_file_name_path_lookup. (hurd_file_name_path_lookup): New strong alias. (file_name_path_lookup): Call __hurd_file_name_path_lookup instead of hurd_file_name_path_lookup. * mach/errstring.c (mach_error_type): Add hidden def. * mach/msg-destroy.c (__mach_msg_destroy): Add hidden def. * mach/mutex-init.c (__mutex_init): Add hidden def. * mach/spin-lock.c (__spin_lock_locked, __spin_lock, __spin_unlock, __spin_try_lock, __mutex_lock, __mutex_trylock): Add hidden defs. * mach/spin-solid.c (__spin_lock_solid): Add hidden def. * sysdeps/mach/hurd/getcwd.c (_hurd_canonicalize_directory_name_internal): Rename to __hurd_canonicalize_directory_name_internal. (_hurd_canonicalize_directory_name_internal): New strong alias. (__canonicalize_directory_name_internal, __getcwd): Call __hurd_canonicalize_directory_name_internal instead of _hurd_canonicalize_directory_name_internal. * sysdeps/mach/hurd/mig-reply.c: Include <mach/mig_support.h>. (__mig_get_reply_port, __mig_dealloc_reply_port, __mig_init): Add hidden defs. * sysdeps/hurd/include/hurd.h: New file. * sysdeps/hurd/include/hurd/fd.h: New file. * sysdeps/hurd/include/hurd/signal.h: New file. * sysdeps/mach/include/lock-intern.h: New file. * sysdeps/mach/include/mach.h: New file. * sysdeps/mach/include/mach/mig_support.h: New file. * sysdeps/mach/include/mach_error.h: New file.
* hurd: Avoid some PLTs in libc and librtSamuel Thibault2018-04-026-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * hurd/hurdauth.c (_S_msg_add_auth): Call __vm_allocate and __vm_deallocate instead of vm_allocate and vm_deallocate. * hurd/hurdmsg.c (_S_msg_set_env_variable): Call __setenv instead of setenv. * hurd/hurdprio.c (_hurd_priority_which_map): Call __geteuid instead of geteuid. * hurd/path-lookup.c (file_name_path_scan): Call __strdup instead of strdup. * hurd/siginfo.c: Include <libioP.h>. (_hurd_siginfo_handler): Call _IO_puts instead of puts. * hurd/xattr.c (_hurd_xattr_get, _hurd_xattr_set): Call __munmap instead of munmap. * io/fts.c (fts_build): Call __dirfd instead of dirfd. * mach/devstream.c: Include <libioP.h>. (dealloc_ref): Call __mach_port_deallocate instead of mach_port_deallocate. (mach_open_devstream): Call _IO_fopencookie instead of fopencookie. Call __mach_port_deallocate instead of mach_port_deallocate. * stdlib/canonicalize.c (__realpath): Call __pathconf instead of pathconf. * sysdeps/mach/hurd/ifreq.c (__ifreq): Call __munmap instead of munmap. * sysdeps/mach/hurd/ifreq.h (__if_freereq): Likewise. * sysdeps/mach/hurd/ptrace.c (ptrace): Call __kill instead of kill. * sysdeps/mach/hurd/sendfile64.c (sendfile64): Call __munmap instead of munmap. * sysdeps/mach/hurd/socketpair.c (__socketpair): Call __close instead of close. * sysdeps/posix/clock_getres.c (realtime_getres): Call __sysconf instead of sysconf. * sysdeps/pthread/timer_gettime.c (timer_gettime): Call __clock_gettime instead of clock_gettime. * sysdeps/pthread/timer_routines.c (thread_func): Likewise. * sysdeps/pthread/timer_settime.c (timer_settime): Likewise. * sysdeps/unix/bsd/gtty.c (gtty): Call __ioctl instead of ioctl. * sysdeps/unix/bsd/stty.c (stty): Likewise. * sysdeps/unix/bsd/tcflow.c (tcflow): Call __tcgetattr instead of tcgetattr. * sysdeps/unix/clock_nanosleep.c (__clock_nanosleep): Call __clock_gettime and __nanosleep instead of clock_gettime and nanosleep.
* hurd: Code style fixesSamuel Thibault2018-03-201-37/+42
| | | | No code change.
* hurd: Fix build with latest htlSamuel Thibault2018-03-191-1/+1
| | | | * hurd/hurdsig.c: Include <pthreadP.h> instead of <pthread.h>.
* hurd: Fix O_DIRECTORY | O_NOFOLLOWSamuel Thibault2018-03-182-1/+3
| | | | | | | | | | | | | Appending / to the path to be looked up would make us always follow a final symlink, even with O_NOTRANS (since the final resolution is after the '/'). In the O_DIRECTORY | O_NOFOLLOW case, we thus have to really open the node and stat it, which we already do anyway, and check for directory type. * hurd/hurdlookup.c (__hurd_file_name_lookup): Do not append '/' to path when flags contains O_NOFOLLOW. * hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Return ENOTDIR if flags contains O_DIRECTORY and the result is a directory.
* hurd: Fix O_NOFOLLOWSamuel Thibault2018-03-181-16/+20
| | | | | | | | | | | The error code documented by POSIX for opening a symlink with O_NOFOLLOW is ELOOP. Also, if the translator does not expose symlink as a symlink translator but as a S_IFLNK file, O_NOFOLLOW needs to return ELOOP too. * hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Return ELOOP when opening a symlink with O_NOFOLLOW.
* hurd: Fix copyright yearsSamuel Thibault2018-03-182-2/+2
|
* hurd: Reimplement libc locks using mach's gsyncAgustina Arzille2018-03-187-6/+356
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * hurd/Makefile (routines): Add hurdlock. * hurd/Versions (GLIBC_PRIVATE): Added new entry to export the above interface. (HURD_CTHREADS_0.3): Remove __libc_getspecific. * hurd/hurdpid.c: Include <lowlevellock.h> (_S_msg_proc_newids): Use lll_wait to synchronize. * hurd/hurdsig.c: (reauth_proc): Use __mutex_lock and __mutex_unlock. * hurd/setauth.c: Include <hurdlock.h>, use integer for synchronization. * mach/Makefile (lock-headers): Remove machine-lock.h. * mach/lock-intern.h: Include <lowlevellock.h> instead of <machine-lock.h>. (__spin_lock_t): New type. (__SPIN_LOCK_INITIALIZER): New macro. (__spin_lock, __spin_unlock, __spin_try_lock, __spin_lock_locked, __mutex_init, __mutex_lock_solid, __mutex_unlock_solid, __mutex_lock, __mutex_unlock, __mutex_trylock): Use lll to implement locks. * mach/mutex-init.c: Include <lowlevellock.h> instead of <cthreads.h>. (__mutex_init): Initialize with lll. * manual/errno.texi (EOWNERDEAD, ENOTRECOVERABLE): New errno values. * sysdeps/mach/Makefile: Add libmachuser as dependencies for libs needing lll. * sysdeps/mach/hurd/bits/errno.h: Regenerate. * sysdeps/mach/hurd/cthreads.c (__libc_getspecific): Remove function. * sysdeps/mach/hurd/bits/libc-lock.h: Remove file. * sysdeps/mach/hurd/setpgid.c: Include <lowlevellock.h>. (__setpgid): Use lll for synchronization. * sysdeps/mach/hurd/setsid.c: Likewise with __setsid. * sysdeps/mach/bits/libc-lock.h: Include <tls.h> and <lowlevellock.h> instead of <cthreads.h>. (_IO_lock_inexpensive): New macro (__libc_lock_recursive_t, __rtld_lock_recursive_t): New structures. (__libc_lock_self0): New declaration. (__libc_lock_owner_self): New macro. (__libc_key_t): Remove type. (_LIBC_LOCK_INITIALIZER): New macro. (__libc_lock_define_initialized, __libc_lock_init, __libc_lock_fini, __libc_lock_fini_recursive, __rtld_lock_fini_recursive, __libc_lock_lock, __libc_lock_trylock, __libc_lock_unlock, __libc_lock_define_initialized_recursive, __rtld_lock_define_initialized_recursive, __libc_lock_init_recursive, __libc_lock_trylock_recursive, __libc_lock_lock_recursive, __libc_lock_unlock_recursive, __rtld_lock_initialize, __rtld_lock_trylock_recursive, __rtld_lock_lock_recursive, __rtld_lock_unlock_recursive __libc_once_define, __libc_mutex_unlock): Reimplement with lll. (__libc_lock_define_recursive, __rtld_lock_define_recursive, _LIBC_LOCK_RECURSIVE_INITIALIZER, _RTLD_LOCK_RECURSIVE_INITIALIZER): New macros. Include <libc-lockP.h> to reimplement libc_key* with pthread_key*. * hurd/hurdlock.c: New file. * hurd/hurdlock.h: New file. * mach/lowlevellock.h: New file
* hurd: Fix coding styleSamuel Thibault2018-03-182-2/+2
|
* hurd: Fix link cthread/pthread symbol exposition.Samuel Thibault2018-03-172-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | * hurd/Versions (HURD_CTHREADS_0.3): Rename weak refs cthread_fork, cthread_detach, pthread_getattr_np, pthread_attr_getstack, cthread_keycreate, cthread_getspecific, cthread_setspecific to __cthread_fork, __cthread_detach, __pthread_getattr_np, __pthread_attr_getstack, __cthread_keycreate, __cthread_getspecific, __cthread_setspecific. * hurd/hurdsig.c (_hurdsig_init): Use __cthread_fork, __cthread_detach, __pthread_getattr_np, __pthread_attr_getstack, __cthread_t instead of cthread_fork, cthread_detach, pthread_getattr_np, pthread_attr_getstack. * sysdeps/mach/hurd/cthreads.c (cthread_keycreate): Rename to __cthread_keycreate. (cthread_getspecific): Rename to __cthread_getspecific. (cthread_setspecific): Rename to __cthread_setspecific. (__libc_getspecific): Use __cthread_getspecific instead of cthread_getspecific. * sysdeps/mach/hurd/libc-lock.h (__libc_key_create): Use __cthread_keycreate instead of cthread_keycreate. (__libc_setspecific): Use __cthread_setspecific instead of cthread_setspecific. * sysdeps/mach/libc-lock.h (__libc_key_create, __libc_setspecific): Likewise.
* hurd: Replace threadvars with TLSSamuel Thibault2018-03-177-119/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This gets rid of a lot of kludge and gets closer to other ports. * hurd/Makefile (headers): Remove threadvar.h. (inline-headers): Remove threadvar.h. * hurd/Versions (GLIBC_2.0: Remove __hurd_sigthread_stack_base, __hurd_sigthread_stack_end, __hurd_sigthread_variables, __hurd_threadvar_max, __hurd_errno_location. (HURD_CTHREADS_0.3): Add pthread_getattr_np, pthread_attr_getstack. * hurd/hurd/signal.h: Do not include <hurd/threadvar.h>. (_hurd_self_sigstate): Use THREAD_SELF to get _hurd_sigstate. (_HURD_SIGNAL_H_EXTERN_INLINE): Use THREAD_SELF to get _hurd_sigstate, unless TLS is not initialized yet, in which case we do not need a critical section yet anyway. * hurd/hurd/threadvar.h: Include <tls.h>, do not include <machine-sp.h>. (__hurd_sigthread_variables, __hurd_threadvar_max): Remove variables declarations. (__hurd_threadvar_index): Remove enum. (_HURD_THREADVAR_H_EXTERN_INLINE): Remove macro. (__hurd_threadvar_location_from_sp,__hurd_threadvar_location): Remove inlines. (__hurd_reply_port0): New variable declaration. (__hurd_local_reply_port): New macro. * hurd/hurdsig.c (__hurd_sigthread_variables): Remove variable. (interrupted_reply_port_location): Add thread_t parameter. Use it with THREAD_TCB to access thread-local variables. (_hurdsig_abort_rpcs): Pass ss->thread to interrupted_reply_port_location. (_hurd_internal_post_signal): Likewise. (_hurdsig_init): Use presence of cthread_fork instead of __hurd_threadvar_stack_mask to start signal thread by hand. Remove signal thread threadvar initialization. * hurd/hurdstartup.c: Do not include <hurd/threadvar.h> * hurd/sigunwind.c: Include <hurd/threadvar.h> (_hurdsig_longjmp_from_handler): Use __hurd_local_reply_port instead of threadvar. * sysdeps/mach/hurd/Versions (libc.GLIBC_PRIVATE): Add __libc_lock_self0. (ld.GLIBC_2.0): Remove __hurd_sigthread_stack_base, __hurd_sigthread_stack_end, __hurd_sigthread_variables. (ld.GLIBC_PRIVATE): Add __libc_lock_self0. * sysdeps/mach/hurd/cthreads.c: Add __libc_lock_self0. * sysdeps/mach/hurd/dl-sysdep.c (errno, __hurd_sigthread_stack_base, __hurd_sigthread_stack_end, __hurd_sigthread_variables, threadvars, __hurd_threadvar_stack_offset, __hurd_threadvar_stack_mask): Do not define variables. * sysdeps/mach/hurd/errno-loc.c: Do not include <errno.h> and <hurd/threadvar.h>. [IS_IN(rtld)] (rtld_errno): New variable. [IS_IN(rtld)] (__errno_location): New weak function. [!IS_IN(rtld)]: Include "../../../csu/errno-loc.c". * sysdeps/mach/hurd/errno.c: Remove file. * sysdeps/mach/hurd/fork.c: Include <hurd/threadvar.h> (__fork): Remove THREADVAR_SPACE macro and its use. * sysdeps/mach/hurd/i386/init-first.c (__hurd_threadvar_max): Remove variable. (init): Do not initialize threadvar. * sysdeps/mach/hurd/i386/libc.abilist (__hurd_threadvar_max): Remove symbol. * sysdeps/mach/hurd/i386/sigreturn.c (__sigreturn): Use __hurd_local_reply_port instead of threadvar. * sysdeps/mach/hurd/i386/tls.h (tcbhead_t): Add reply_port and _hurd_sigstate fields. (HURD_DESC_TLS, __LIBC_NO_TLS, THREAD_TCB): New macro. * sysdeps/mach/hurd/i386/trampoline.c: Remove outdated comment. * sysdeps/mach/hurd/libc-lock.h: Do not include <hurd/threadvar.h>. (__libc_lock_owner_self): Use &__libc_lock_self0 and THREAD_SELF instead of threadvar. * sysdeps/mach/hurd/libc-tsd.h: Remove file. * sysdeps/mach/hurd/mig-reply.c (GETPORT, reply_port): Remove macros. (use_threadvar, global_reply_port): Remove variables. (__hurd_reply_port0): New variable. (__mig_get_reply_port): Use __hurd_local_reply_port and __hurd_reply_port0 instead of threadvar. (__mig_dealloc_reply_port): Likewise. (__mig_init): Do not initialize threadvar. * sysdeps/mach/hurd/profil.c: Fix comment.
* hurd: Fix getting signal thread stack layout for forkSamuel Thibault2018-03-171-1/+19
| | | | | | * hurd/hurdsig.c: Include <pthread.h>. (_hurdsig_init): Call pthread_getattr_np and pthread_attr_getstack to get the signal thread stack layout.
* hurd: add TLS supportSamuel Thibault2018-03-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * sysdeps/generic/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): Define macro. * sysdeps/mach/thread_state.h (MACHINE_THREAD_STATE_FIX_NEW): New macro. * sysdeps/mach/i386/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): New macro, defined to i386_THREAD_STATE. (MACHINE_THREAD_STATE_FLAVOR): Define to i386_REGS_SEGS_STATE instead of i386_THREAD_STATE. (MACHINE_THREAD_STATE_FIX_NEW): New macro, reads segments. * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Use i386_REGS_SEGS_STATE instead of i386_THREAD_STATE. * sysdeps/mach/hurd/i386/tls.h (TCB_ALIGNMENT, HURD_SEL_LDT): New macros. (_hurd_tls_fork): Add original thread parameter, Duplicate existing LDT descriptor instead of creating a new one. (_hurd_tls_new): New function, creates a new descriptor and updates tcb. * mach/setup-thread.c: Include <ldsodefs.h>. (__mach_setup_thread): Call _dl_allocate_tls, pass MACHINE_NEW_THREAD_STATE_FLAVOR to __thread_set_state instead of MACHINE_THREAD_STATE_FLAVOR, before getting MACHINE_THREAD_STATE_FLAVOR, calling _hurd_tls_new, and setting MACHINE_THREAD_STATE_FLAVOR with the result. * hurd/hurdfault.c (_hurdsig_fault_init): Call MACHINE_THREAD_STATE_FIX_NEW. * sysdeps/mach/hurd/fork.c (__fork): Call _hurd_tls_fork for sigthread too. Add original thread parameter.
* hurd: Fix includability of <hurd/signal.h> in all standardsSamuel Thibault2018-03-051-0/+1
| | | | | | | | | | | | | * bits/sigaction.h: Add include guard. * sysdeps/unix/sysv/linux/alpha/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/hppa/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/ia64/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/s390/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/tile/bits/sigaction.h: Likewise. * hurd/hurd/signal.h: Include <bits/sigaction.h>.
* Separate out error_t definitionSamuel Thibault2018-03-047-0/+9
| | | | | | | | | | | | | | | | | | so interfaces needing it can get it. * stdlib/errno.h (error_t): Move definition to... * bits/types/error_t.h: ... new header. * stdlib/Makefile (headers): Add bits/types/error_t.h. * sysdeps/mach/hurd/bits/errno.h (error_t): Move definition to... * sysdeps/mach/hurd/bits/types/error_t.h: ... new header. * sysdeps/mach/hurd/errnos.awk (error_t): Likewise. * hurd/hurd.h: Include <bits/types/error_t.h> * hurd/hurd/fd.h: Include <bits/types/error_t.h> * hurd/hurd/id.h: Include <errno.h> and <bits/types/error_t.h> * hurd/hurd/lookup.h: Include <errno.h> and <bits/types/error_t.h> * hurd/hurd/resource.h: Include <bits/types/error_t.h> * hurd/hurd/signal.h: Include <bits/types/error_t.h> * hurd/hurd/sigpreempt.h: Include <bits/types/error_t.h>
* hurd: Make almost all hurd headers includable in all standardsSamuel Thibault2018-03-044-14/+18
| | | | | | | | | | | | | | * hurd/hurd.h: Include <bits/types/sigset_t.h> * hurd/hurd/fd.h: Include <sys/select.h> and <bits/types/sigset_t.h> (_hurd_fd_read, _hurd_fd_write): Use __loff_t instead of loff_t. * hurd/hurd/signal.h: Include <bits/types/stack_t.h> and <bits/types/sigset_t.h>. [!defined __USE_GNU]: Do not #error out. (struct hurd_sigstate): Use _NSIG instead of NSIG. * hurd/hurd/sigpreempt.h (__need_size_t): Define. Include <stddef.h> and <bits/types/sigset_t.h> (struct hurd_signal_preemptor, hurd_catch_signal): Use __sighandler_t instead of sighandler_t.