summaryrefslogtreecommitdiff
path: root/hurd
diff options
context:
space:
mode:
Diffstat (limited to 'hurd')
-rw-r--r--hurd/Makefile10
-rw-r--r--hurd/Versions22
-rw-r--r--hurd/alloc-fd.c2
-rw-r--r--hurd/catch-exc.c2
-rw-r--r--hurd/catch-signal.c29
-rw-r--r--hurd/compat-20.c2
-rw-r--r--hurd/ctty-input.c2
-rw-r--r--hurd/ctty-output.c2
-rw-r--r--hurd/dtable.c2
-rw-r--r--hurd/exc2signal.c27
-rw-r--r--hurd/fchroot.c2
-rw-r--r--hurd/fcntl-internal.h62
-rw-r--r--hurd/fd-close.c2
-rw-r--r--hurd/fd-read.c2
-rw-r--r--hurd/fd-write.c2
-rw-r--r--hurd/fopenport.c4
-rw-r--r--hurd/get-host.c6
-rw-r--r--hurd/getdport.c2
-rw-r--r--hurd/geteuids.c2
-rw-r--r--hurd/getumask.c2
-rw-r--r--hurd/hurd-raise.c3
-rw-r--r--hurd/hurd.h26
-rw-r--r--hurd/hurd/fd.h19
-rw-r--r--hurd/hurd/id.h5
-rw-r--r--hurd/hurd/ioctl.h3
-rw-r--r--hurd/hurd/lookup.h24
-rw-r--r--hurd/hurd/port.h27
-rw-r--r--hurd/hurd/resource.h3
-rw-r--r--hurd/hurd/signal.h54
-rw-r--r--hurd/hurd/sigpreempt.h18
-rw-r--r--hurd/hurd/threadvar.h29
-rw-r--r--hurd/hurd/userlink.h20
-rw-r--r--hurd/hurd/xattr.h2
-rw-r--r--hurd/hurdauth.c18
-rw-r--r--hurd/hurdchdir.c2
-rw-r--r--hurd/hurdexec.c55
-rw-r--r--hurd/hurdfault.c3
-rw-r--r--hurd/hurdfault.h2
-rw-r--r--hurd/hurdfchdir.c2
-rw-r--r--hurd/hurdhost.h2
-rw-r--r--hurd/hurdid.c2
-rw-r--r--hurd/hurdinit.c3
-rw-r--r--hurd/hurdioctl.c2
-rw-r--r--hurd/hurdkill.c2
-rw-r--r--hurd/hurdlock.c220
-rw-r--r--hurd/hurdlock.h125
-rw-r--r--hurd/hurdlookup.c10
-rw-r--r--hurd/hurdmalloc.c15
-rw-r--r--hurd/hurdmalloc.h4
-rw-r--r--hurd/hurdmsg.c4
-rw-r--r--hurd/hurdpid.c5
-rw-r--r--hurd/hurdports.c2
-rw-r--r--hurd/hurdprio.c4
-rw-r--r--hurd/hurdrlimit.c2
-rw-r--r--hurd/hurdselect.c2
-rw-r--r--hurd/hurdsig.c45
-rw-r--r--hurd/hurdsock.c2
-rw-r--r--hurd/hurdsocket.h2
-rw-r--r--hurd/hurdstartup.c2
-rw-r--r--hurd/hurdstartup.h2
-rw-r--r--hurd/intern-fd.c3
-rw-r--r--hurd/intr-msg.c3
-rw-r--r--hurd/intr-rpc.defs2
-rw-r--r--hurd/intr-rpc.h2
-rw-r--r--hurd/longjmp-ts.c2
-rw-r--r--hurd/lookup-at.c2
-rw-r--r--hurd/lookup-retry.c42
-rw-r--r--hurd/msgportdemux.c2
-rw-r--r--hurd/new-fd.c2
-rw-r--r--hurd/openport.c2
-rw-r--r--hurd/path-lookup.c35
-rw-r--r--hurd/pid2task.c2
-rw-r--r--hurd/port-cleanup.c2
-rw-r--r--hurd/port2fd.c2
-rw-r--r--hurd/ports-get.c2
-rw-r--r--hurd/ports-set.c2
-rw-r--r--hurd/preempt-sig.c2
-rw-r--r--hurd/privports.c2
-rw-r--r--hurd/report-wait.c2
-rw-r--r--hurd/set-host.c2
-rw-r--r--hurd/setauth.c7
-rw-r--r--hurd/seteuids.c2
-rw-r--r--hurd/siginfo.c5
-rw-r--r--hurd/sigunwind.c2
-rw-r--r--hurd/stack_chk_fail_local.c1
-rw-r--r--hurd/task2pid.c2
-rw-r--r--hurd/thread-cancel.c2
-rw-r--r--hurd/thread-self.c2
-rw-r--r--hurd/trampoline.c4
-rw-r--r--hurd/vpprintf.c2
-rw-r--r--hurd/xattr.c8
91 files changed, 821 insertions, 289 deletions
diff --git a/hurd/Makefile b/hurd/Makefile
index 4c62d6a134..1bd6b85573 100644
--- a/hurd/Makefile
+++ b/hurd/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2016 Free Software Foundation, Inc.
+# Copyright (C) 1991-2018 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -55,6 +55,7 @@ routines = hurdstartup hurdinit \
ports-get ports-set hurdports hurdmsg \
errno-loc \
sysvshm \
+ hurdlock \
$(sig) $(dtable) $(inlines) port-cleanup report-wait xattr
sig = hurdsig hurdfault siginfo hurd-raise preempt-sig \
trampoline longjmp-ts catch-exc exc2signal hurdkill sigunwind \
@@ -79,10 +80,17 @@ shared-only-routines = compat-20
$(inlines:%=$(objpfx)%.c): $(objpfx)%-inlines.c: %.h
(h="`echo $(subst /,_,$*) | tr '[a-z]' '[A-Z]'`"; \
echo "#define _$${h}_H_EXTERN_INLINE /* Define real function. */"; \
+ echo "#define _$${h}_H_HIDDEN_DEF /* Declare hidden definition. */"; \
echo '#include "$<"') > $@-new
mv -f $@-new $@
generated += $(inlines:=.c)
+
+# Avoid ssp before TLS is initialized.
+CFLAGS-hurdstartup.o = $(no-stack-protector)
+CFLAGS-RPC_exec_startup_get_info.o = $(no-stack-protector)
+# Make generated headers compatible with all support standards
+migheaderpipe := | sed -e 's/\<ino64_t\>/__ino64_t/' -e 's/\<loff_t\>/__loff_t/'
include ../mach/Machrules
include ../Rules
diff --git a/hurd/Versions b/hurd/Versions
index b84ae791ed..af6a0e45de 100644
--- a/hurd/Versions
+++ b/hurd/Versions
@@ -4,7 +4,6 @@ libc {
_end;
# variables used in macros & inline functions
- __hurd_threadvar_max;
__hurd_threadvar_stack_mask; __hurd_threadvar_stack_offset;
# functions used in libmachuser and libhurduser
@@ -124,7 +123,11 @@ libc {
# functions used in macros & inline functions
__errno_location;
}
- GLIBC_2.19 {
+ GLIBC_2.26 {
+ # "quasi-internal" functions
+ _hurd_exec_paths;
+ }
+ GLIBC_2.27 {
# These always existed as inlines but the real functions were not exported.
_hurd_fd_error_signal; _hurd_fd_error;
__hurd_dfail; __hurd_sockfail;
@@ -136,14 +139,21 @@ libc {
HURD_CTHREADS_0.3 {
# weak refs to libthreads functions that libc calls iff libthreads in use
- cthread_fork; cthread_detach;
- pthread_getattr_np; pthread_attr_getstack;
+ __cthread_fork; __cthread_detach;
+ __pthread_getattr_np; __pthread_attr_getstack;
# variables used for detecting cthreads
_cthread_exit_routine; _cthread_init_routine;
# cthreads functions with stubs in libc
- cthread_keycreate; cthread_getspecific; cthread_setspecific;
- __libc_getspecific;
+ __cthread_keycreate; __cthread_getspecific; __cthread_setspecific;
+ }
+
+ GLIBC_PRIVATE {
+ # Used by other libs.
+ __lll_abstimed_wait; __lll_abstimed_xwait;
+ __lll_abstimed_lock; __lll_robust_lock;
+ __lll_robust_abstimed_lock; __lll_robust_trylock;
+ __lll_robust_unlock;
}
}
diff --git a/hurd/alloc-fd.c b/hurd/alloc-fd.c
index 8630b2eb47..19775bf964 100644
--- a/hurd/alloc-fd.c
+++ b/hurd/alloc-fd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/catch-exc.c b/hurd/catch-exc.c
index 98633fded3..8d3cb7d798 100644
--- a/hurd/catch-exc.c
+++ b/hurd/catch-exc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/catch-signal.c b/hurd/catch-signal.c
index bb9d8199a1..56ce86532d 100644
--- a/hurd/catch-signal.c
+++ b/hurd/catch-signal.c
@@ -1,5 +1,5 @@
/* Convenience function to catch expected signals during an operation.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,10 +22,10 @@
#include <assert.h>
error_t
-hurd_catch_signal (sigset_t sigset,
- unsigned long int first, unsigned long int last,
- error_t (*operate) (struct hurd_signal_preemptor *),
- sighandler_t handler)
+__hurd_catch_signal (sigset_t sigset,
+ unsigned long int first, unsigned long int last,
+ error_t (*operate) (struct hurd_signal_preemptor *),
+ sighandler_t handler)
{
/* We need to restore the signal mask, because otherwise the
signal-handling code will have blocked the caught signal and for
@@ -73,6 +73,7 @@ hurd_catch_signal (sigset_t sigset,
return error;
}
+strong_alias (__hurd_catch_signal, hurd_catch_signal)
error_t
@@ -83,9 +84,9 @@ hurd_safe_memset (void *dest, int byte, size_t nbytes)
memset (dest, byte, nbytes);
return 0;
}
- return hurd_catch_signal (sigmask (SIGBUS) | sigmask (SIGSEGV),
- (vm_address_t) dest, (vm_address_t) dest + nbytes,
- &operate, SIG_ERR);
+ return __hurd_catch_signal (sigmask (SIGBUS) | sigmask (SIGSEGV),
+ (vm_address_t) dest, (vm_address_t) dest + nbytes,
+ &operate, SIG_ERR);
}
@@ -97,9 +98,9 @@ hurd_safe_copyout (void *dest, const void *src, size_t nbytes)
memcpy (dest, src, nbytes);
return 0;
}
- return hurd_catch_signal (sigmask (SIGBUS) | sigmask (SIGSEGV),
- (vm_address_t) dest, (vm_address_t) dest + nbytes,
- &operate, SIG_ERR);
+ return __hurd_catch_signal (sigmask (SIGBUS) | sigmask (SIGSEGV),
+ (vm_address_t) dest, (vm_address_t) dest + nbytes,
+ &operate, SIG_ERR);
}
error_t
@@ -110,9 +111,9 @@ hurd_safe_copyin (void *dest, const void *src, size_t nbytes)
memcpy (dest, src, nbytes);
return 0;
}
- return hurd_catch_signal (sigmask (SIGBUS) | sigmask (SIGSEGV),
- (vm_address_t) src, (vm_address_t) src + nbytes,
- &operate, SIG_ERR);
+ return __hurd_catch_signal (sigmask (SIGBUS) | sigmask (SIGSEGV),
+ (vm_address_t) src, (vm_address_t) src + nbytes,
+ &operate, SIG_ERR);
}
error_t
diff --git a/hurd/compat-20.c b/hurd/compat-20.c
index bb5ca7e098..86401819d1 100644
--- a/hurd/compat-20.c
+++ b/hurd/compat-20.c
@@ -1,5 +1,5 @@
/* Old-versioned functions for binary compatibility with glibc-2.0.
- Copyright (C) 1998-2016 Free Software Foundation, Inc.
+ Copyright (C) 1998-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/ctty-input.c b/hurd/ctty-input.c
index 25463fd0b0..ec4092b855 100644
--- a/hurd/ctty-input.c
+++ b/hurd/ctty-input.c
@@ -1,5 +1,5 @@
/* _hurd_ctty_input -- Do an input RPC and generate SIGTTIN if necessary.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/ctty-output.c b/hurd/ctty-output.c
index 41286fb556..12fdf78159 100644
--- a/hurd/ctty-output.c
+++ b/hurd/ctty-output.c
@@ -1,5 +1,5 @@
/* _hurd_ctty_output -- Do an output RPC and generate SIGTTOU if necessary.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/dtable.c b/hurd/dtable.c
index 32ec49536a..5c204676f8 100644
--- a/hurd/dtable.c
+++ b/hurd/dtable.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/exc2signal.c b/hurd/exc2signal.c
index 3a2ec08124..10aa1ca4cf 100644
--- a/hurd/exc2signal.c
+++ b/hurd/exc2signal.c
@@ -1,5 +1,5 @@
/* Translate Mach exception codes into signal numbers. Stub version.
- Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include <hurd.h>
+#include <hurd/signal.h>
/* This file must be modified with machine-dependent details. */
#error "need to write sysdeps/mach/hurd/MACHINE/exc2signal.c"
@@ -25,46 +26,46 @@
into a signal number and signal subcode. */
void
-_hurd_exception2signal (int exception, int code, int subcode,
- int *signo, int *sigcode, int *error)
+_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
{
- *error = 0;
+ detail->error = 0;
- switch (exception)
+ switch (detail->exc)
{
default:
*signo = SIGIOT;
- *sigcode = exception;
+ detail->code = detail->exc;
break;
case EXC_BAD_ACCESS:
- if (code == KERN_PROTECTION_FAILURE)
+ if (detail->exc_code == KERN_PROTECTION_FAILURE)
*signo = SIGSEGV;
else
*signo = SIGBUS;
- *sigcode = subcode;
- *error = code;
+ detail->code = detail->exc_subcode;
+ detail->error = detail->exc_code;
break;
case EXC_BAD_INSTRUCTION:
*signo = SIGILL;
- *sigcode = 0;
+ detail->code = 0;
break;
case EXC_ARITHMETIC:
*signo = SIGFPE;
- *sigcode = 0;
+ detail->code = 0;
break;
case EXC_EMULATION:
case EXC_SOFTWARE:
*signo = SIGEMT;
- *sigcode = 0;
+ detail->code = 0;
break;
case EXC_BREAKPOINT:
*signo = SIGTRAP;
- *sigcode = 0;
+ detail->code = 0;
break;
}
}
+libc_hidden_def (_hurd_exception2signal)
diff --git a/hurd/fchroot.c b/hurd/fchroot.c
index 9027919e3f..ea97a1b388 100644
--- a/hurd/fchroot.c
+++ b/hurd/fchroot.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/fcntl-internal.h b/hurd/fcntl-internal.h
new file mode 100644
index 0000000000..d795e4089c
--- /dev/null
+++ b/hurd/fcntl-internal.h
@@ -0,0 +1,62 @@
+/* Helper functions for translating between O_* and SOCK_* flags.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+
+#include <fcntl.h>
+#include <sys/socket.h>
+
+/* Do some compile-time checks for the SOCK_* constants, which we rely on. */
+_Static_assert (SOCK_CLOEXEC == O_CLOEXEC,
+ "SOCK_CLOEXEC is assumed to be the same as O_CLOEXEC");
+_Static_assert (((SOCK_MAX - 1) | SOCK_TYPE_MASK) == SOCK_TYPE_MASK,
+ "SOCK_TYPE_MASK must contain SOCK_MAX - 1");
+_Static_assert ((SOCK_CLOEXEC & SOCK_TYPE_MASK) == 0,
+ "SOCK_TYPE_MASK must not contain SOCK_CLOEXEC");
+_Static_assert ((SOCK_NONBLOCK & SOCK_TYPE_MASK) == 0,
+ "SOCK_TYPE_MASK must not contain SOCK_NONBLOCK");
+
+
+/* Convert from SOCK_* flags to O_* flags. */
+__extern_always_inline
+int
+sock_to_o_flags (int in)
+{
+ int out = 0;
+
+ if (in & SOCK_NONBLOCK)
+ out |= O_NONBLOCK;
+ /* Others are passed through unfiltered. */
+ out |= in & ~(SOCK_NONBLOCK);
+
+ return out;
+}
+
+/* Convert from O_* flags to SOCK_* flags. */
+__extern_always_inline
+int
+o_to_sock_flags (int in)
+{
+ int out = 0;
+
+ if (in & O_NONBLOCK)
+ out |= SOCK_NONBLOCK;
+ /* Others are passed through unfiltered. */
+ out |= in & ~(O_NONBLOCK);
+
+ return out;
+}
diff --git a/hurd/fd-close.c b/hurd/fd-close.c
index f1e067f15a..d5bd0ffbc2 100644
--- a/hurd/fd-close.c
+++ b/hurd/fd-close.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/fd-read.c b/hurd/fd-read.c
index b4a6d983da..ba3fce818b 100644
--- a/hurd/fd-read.c
+++ b/hurd/fd-read.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/fd-write.c b/hurd/fd-write.c
index 45123d42f5..699f23d7e6 100644
--- a/hurd/fd-write.c
+++ b/hurd/fd-write.c
@@ -1,5 +1,5 @@
/* _hurd_fd_write -- write to a file descriptor; handles job control et al.
- Copyright (C) 1993-2016 Free Software Foundation, Inc.
+ Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/fopenport.c b/hurd/fopenport.c
index e0ab908dba..edb12b83f4 100644
--- a/hurd/fopenport.c
+++ b/hurd/fopenport.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -62,7 +62,7 @@ writeio (void *cookie, const char *buf, size_t n)
Returns zero if successful, nonzero if not. */
static int
seekio (void *cookie,
- _IO_off64_t *pos,
+ off64_t *pos,
int whence)
{
error_t err = __io_seek ((file_t) cookie, *pos, whence, pos);
diff --git a/hurd/get-host.c b/hurd/get-host.c
index a76ba5c095..2001fc5a86 100644
--- a/hurd/get-host.c
+++ b/hurd/get-host.c
@@ -1,5 +1,5 @@
/* Get a host configuration item kept as the whole contents of a file.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -65,7 +65,7 @@ _hurd_get_host_config (const char *item, char *buf, size_t buflen)
}
/* If the file is empty, give an empty value. */
- if (nread == 0)
+ if (nread == 0 && more == 0)
{
if (buflen != 0)
*buf = '\0';
@@ -80,7 +80,7 @@ _hurd_get_host_config (const char *item, char *buf, size_t buflen)
if (nread < buflen)
buf[nread] = '\0';
else
- if (buf[nread - 1] != '\0')
+ if (nread != 0 && buf[nread - 1] != '\0')
more = 1;
if (more)
diff --git a/hurd/getdport.c b/hurd/getdport.c
index 53e5a66502..337c6a47ba 100644
--- a/hurd/getdport.c
+++ b/hurd/getdport.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
diff --git a/hurd/geteuids.c b/hurd/geteuids.c
index 18cf7d2af1..bf8d576238 100644
--- a/hurd/geteuids.c
+++ b/hurd/geteuids.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/getumask.c b/hurd/getumask.c
index 2816115212..5d68662e51 100644
--- a/hurd/getumask.c
+++ b/hurd/getumask.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurd-raise.c b/hurd/hurd-raise.c
index 64909c03bd..9fe5541311 100644
--- a/hurd/hurd-raise.c
+++ b/hurd/hurd-raise.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -48,3 +48,4 @@ _hurd_raise_signal (struct hurd_sigstate *ss,
other thread. */
return __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
}
+libc_hidden_def (_hurd_raise_signal)
diff --git a/hurd/hurd.h b/hurd/hurd.h
index 4f889b57eb..d3c868928b 100644
--- a/hurd/hurd.h
+++ b/hurd/hurd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -41,6 +41,8 @@
#include <hurd/port.h>
#include <errno.h>
+#include <bits/types/error_t.h>
+#include <bits/types/sigset_t.h>
#ifndef _HURD_H_EXTERN_INLINE
#define _HURD_H_EXTERN_INLINE __extern_inline
@@ -57,15 +59,15 @@ __hurd_fail (error_t err)
case EMACH_SEND_INVALID_DEST:
case EMIG_SERVER_DIED:
/* The server has disappeared! */
- err = EIEIO;
+ err = (error_t) EIEIO;
break;
case KERN_NO_SPACE:
- err = ENOMEM;
+ err = (error_t) ENOMEM;
break;
case KERN_INVALID_ARGUMENT:
- err = EINVAL;
+ err = (error_t) EINVAL;
break;
case 0:
@@ -145,8 +147,7 @@ extern struct mutex _hurd_brk_lock;
extern int _hurd_set_brk (vm_address_t newbrk);
-#define __need_FILE
-#include <stdio.h>
+#include <bits/types/FILE.h>
/* Calls to get and set basic ports. */
@@ -245,12 +246,21 @@ extern FILE *fopenport (io_t port, const char *mode);
extern FILE *__fopenport (io_t port, const char *mode);
-/* Execute a file, replacing TASK's current program image. */
+/* Deprecated: use _hurd_exec_paths instead. */
extern error_t _hurd_exec (task_t task,
file_t file,
char *const argv[],
- char *const envp[]);
+ char *const envp[]) __attribute_deprecated__;
+
+/* Execute a file, replacing TASK's current program image. */
+
+extern error_t _hurd_exec_paths (task_t task,
+ file_t file,
+ const char *path,
+ const char *abspath,
+ char *const argv[],
+ char *const envp[]);
/* Inform the proc server we have exited with STATUS, and kill the
diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h
index bd6001b310..af5fdcf759 100644
--- a/hurd/hurd/fd.h
+++ b/hurd/hurd/fd.h
@@ -1,5 +1,5 @@
/* File descriptors.
- Copyright (C) 1993-2016 Free Software Foundation, Inc.
+ Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -26,7 +26,9 @@
#include <hurd/hurd_types.h>
#include <hurd/port.h>
#include <sys/socket.h>
+#include <sys/select.h>
#include <fcntl.h>
+#include <bits/types/sigset_t.h>
/* Structure representing a file descriptor. */
@@ -62,7 +64,7 @@ extern struct mutex _hurd_dtable_lock; /* Locks those two variables. */
extern struct hurd_fd *_hurd_fd_get (int fd);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_FD_H_EXTERN_INLINE struct hurd_fd *
_hurd_fd_get (int fd)
{
@@ -95,7 +97,7 @@ _hurd_fd_get (int fd)
return descriptor;
}
-# endif
+# endif
#endif
@@ -140,6 +142,7 @@ _hurd_fd_get (int fd)
__result; })
#include <errno.h>
+#include <bits/types/error_t.h>
/* Check if ERR should generate a signal.
Returns the signal to take, or zero if none. */
@@ -179,7 +182,7 @@ _hurd_fd_error (int fd, error_t err)
if (signo)
{
const struct hurd_signal_detail detail
- = { code: fd, error: err, exc: 0 };
+ = { exc: 0, exc_code: 0, exc_subcode: 0, code: fd, error: err };
_hurd_raise_signal (NULL, signo, &detail);
}
return err;
@@ -252,9 +255,9 @@ extern error_t _hurd_fd_close (struct hurd_fd *fd);
If successful, stores the amount actually read or written in *NBYTES. */
extern error_t _hurd_fd_read (struct hurd_fd *fd,
- void *buf, size_t *nbytes, loff_t offset);
+ void *buf, size_t *nbytes, __loff_t offset);
extern error_t _hurd_fd_write (struct hurd_fd *fd,
- const void *buf, size_t *nbytes, loff_t offset);
+ const void *buf, size_t *nbytes, __loff_t offset);
/* Call *RPC on PORT and/or CTTY; if a call on CTTY returns EBACKGROUND,
@@ -281,7 +284,7 @@ extern int _hurd_select (int nfds, struct pollfd *pollfds,
__hurd_file_name_lookup. */
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_FD_H_EXTERN_INLINE error_t
__hurd_at_flags (int *at_flags, int *flags)
{
@@ -298,7 +301,7 @@ __hurd_at_flags (int *at_flags, int *flags)
return 0;
}
-# endif
+# endif
#endif
/* Variant of file_name_lookup used in *at function implementations.
diff --git a/hurd/hurd/id.h b/hurd/hurd/id.h
index 4093c57ed0..38988bfe72 100644
--- a/hurd/hurd/id.h
+++ b/hurd/hurd/id.h
@@ -1,5 +1,5 @@
/* User and group IDs.
- Copyright (C) 1993-2016 Free Software Foundation, Inc.
+ Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,6 +20,9 @@
#define _HURD_ID_H 1
#include <features.h>
+#include <hurd/hurd_types.h>
+#include <errno.h>
+#include <bits/types/error_t.h>
#include <cthreads.h> /* For `struct mutex'. */
diff --git a/hurd/hurd/ioctl.h b/hurd/hurd/ioctl.h
index ae7fdf1257..ae74898255 100644
--- a/hurd/hurd/ioctl.h
+++ b/hurd/hurd/ioctl.h
@@ -1,5 +1,5 @@
/* User-registered handlers for specific `ioctl' requests.
- Copyright (C) 1993-2016 Free Software Foundation, Inc.
+ Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@
#define __need___va_list
#include <stdarg.h>
#include <bits/ioctls.h>
+#include <mach/port.h>
/* Type of handler function, called like ioctl to do its entire job. */
diff --git a/hurd/hurd/lookup.h b/hurd/hurd/lookup.h
index da7f48a6b6..d0fa87b3d6 100644
--- a/hurd/hurd/lookup.h
+++ b/hurd/hurd/lookup.h
@@ -1,5 +1,5 @@
/* Declarations of file name translation functions for the GNU Hurd.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -19,6 +19,10 @@
#ifndef _HURD_LOOKUP_H
#define _HURD_LOOKUP_H 1
+#include <errno.h>
+#include <bits/types/error_t.h>
+#include <hurd/hurd_types.h>
+
/* These functions all take two callback functions as the first two arguments.
The first callback function USE_INIT_PORT is called as follows:
@@ -48,7 +52,7 @@ error_t __hurd_file_name_lookup (error_t (*use_init_port)
error_t (*operate) (mach_port_t)),
file_t (*get_dtable_port) (int fd),
error_t (*lookup)
- (file_t dir, char *name, int flags, mode_t mode,
+ (file_t dir, const char *name, int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
const char *file_name,
@@ -59,7 +63,7 @@ error_t hurd_file_name_lookup (error_t (*use_init_port)
error_t (*operate) (mach_port_t)),
file_t (*get_dtable_port) (int fd),
error_t (*lookup)
- (file_t dir, char *name, int flags, mode_t mode,
+ (file_t dir, const char *name, int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
const char *file_name,
@@ -75,7 +79,7 @@ error_t __hurd_file_name_split (error_t (*use_init_port)
(int which,
error_t (*operate) (mach_port_t)),
file_t (*get_dtable_port) (int fd),
- error_t (*lookup) (file_t dir, char *name,
+ error_t (*lookup) (file_t dir, const char *name,
int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
@@ -85,7 +89,7 @@ error_t hurd_file_name_split (error_t (*use_init_port)
(int which,
error_t (*operate) (mach_port_t)),
file_t (*get_dtable_port) (int fd),
- error_t (*lookup) (file_t dir, char *name,
+ error_t (*lookup) (file_t dir, const char *name,
int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
@@ -99,7 +103,7 @@ error_t __hurd_directory_name_split (error_t (*use_init_port)
(int which,
error_t (*operate) (mach_port_t)),
file_t (*get_dtable_port) (int fd),
- error_t (*lookup) (file_t dir, char *name,
+ error_t (*lookup) (file_t dir, const char *name,
int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
@@ -109,7 +113,7 @@ error_t hurd_directory_name_split (error_t (*use_init_port)
(int which,
error_t (*operate) (mach_port_t)),
file_t (*get_dtable_port) (int fd),
- error_t (*lookup) (file_t dir, char *name,
+ error_t (*lookup) (file_t dir, const char *name,
int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
@@ -128,7 +132,7 @@ error_t __hurd_file_name_lookup_retry (error_t (*use_init_port)
error_t (*operate) (mach_port_t)),
file_t (*get_dtable_port) (int fd),
error_t (*lookup)
- (file_t dir, char *name,
+ (file_t dir, const char *name,
int flags, mode_t mode,
retry_type *do_retry,
string_t retry_name,
@@ -142,7 +146,7 @@ error_t hurd_file_name_lookup_retry (error_t (*use_init_port)
error_t (*operate) (mach_port_t)),
file_t (*get_dtable_port) (int fd),
error_t (*lookup)
- (file_t dir, char *name,
+ (file_t dir, const char *name,
int flags, mode_t mode,
retry_type *do_retry,
string_t retry_name,
@@ -178,7 +182,7 @@ error_t hurd_file_name_path_lookup (error_t (*use_init_port)
error_t (*operate) (mach_port_t)),
file_t (*get_dtable_port) (int fd),
error_t (*lookup)
- (file_t dir, char *name,
+ (file_t dir, const char *name,
int flags, mode_t mode,
retry_type *do_retry,
string_t retry_name,
diff --git a/hurd/hurd/port.h b/hurd/hurd/port.h
index c82fa4f04c..0779578d03 100644
--- a/hurd/hurd/port.h
+++ b/hurd/hurd/port.h
@@ -1,5 +1,5 @@
/* Lightweight user references for ports.
- Copyright (C) 1993-2016 Free Software Foundation, Inc.
+ Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,7 +24,6 @@
#include <mach.h>
#include <hurd/userlink.h>
#include <spin-lock.h>
-#include <hurd/signal.h>
/* Structure describing a cell containing a port. With the lock held, a
@@ -63,7 +62,7 @@ struct hurd_port
extern void _hurd_port_init (struct hurd_port *port, mach_port_t init);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE void
_hurd_port_init (struct hurd_port *port, mach_port_t init)
{
@@ -71,7 +70,7 @@ _hurd_port_init (struct hurd_port *port, mach_port_t init)
port->users = NULL;
port->port = init;
}
-# endif
+# endif
#endif
@@ -86,7 +85,7 @@ _hurd_port_locked_get (struct hurd_port *port,
struct hurd_userlink *link);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE mach_port_t
_hurd_port_locked_get (struct hurd_port *port,
struct hurd_userlink *link)
@@ -102,7 +101,7 @@ _hurd_port_locked_get (struct hurd_port *port,
__spin_unlock (&port->lock);
return result;
}
-# endif
+# endif
#endif
/* Same, but locks PORT first. */
@@ -112,7 +111,7 @@ _hurd_port_get (struct hurd_port *port,
struct hurd_userlink *link);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE mach_port_t
_hurd_port_get (struct hurd_port *port,
struct hurd_userlink *link)
@@ -124,7 +123,7 @@ _hurd_port_get (struct hurd_port *port,
HURD_CRITICAL_END;
return result;
}
-# endif
+# endif
#endif
@@ -136,7 +135,7 @@ _hurd_port_free (struct hurd_port *port,
mach_port_t used_port);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE void
_hurd_port_free (struct hurd_port *port,
struct hurd_userlink *link,
@@ -156,7 +155,7 @@ _hurd_port_free (struct hurd_port *port,
if (dealloc)
__mach_port_deallocate (__mach_task_self (), used_port);
}
-# endif
+# endif
#endif
@@ -166,7 +165,7 @@ _hurd_port_free (struct hurd_port *port,
extern void _hurd_port_locked_set (struct hurd_port *port, mach_port_t newport);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE void
_hurd_port_locked_set (struct hurd_port *port, mach_port_t newport)
{
@@ -177,7 +176,7 @@ _hurd_port_locked_set (struct hurd_port *port, mach_port_t newport)
if (old != MACH_PORT_NULL)
__mach_port_deallocate (__mach_task_self (), old);
}
-# endif
+# endif
#endif
/* Same, but locks PORT first. */
@@ -185,7 +184,7 @@ _hurd_port_locked_set (struct hurd_port *port, mach_port_t newport)
extern void _hurd_port_set (struct hurd_port *port, mach_port_t newport);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE void
_hurd_port_set (struct hurd_port *port, mach_port_t newport)
{
@@ -194,7 +193,7 @@ _hurd_port_set (struct hurd_port *port, mach_port_t newport)
_hurd_port_locked_set (port, newport);
HURD_CRITICAL_END;
}
-# endif
+# endif
#endif
diff --git a/hurd/hurd/resource.h b/hurd/hurd/resource.h
index c52ee36cd5..eb93110799 100644
--- a/hurd/hurd/resource.h
+++ b/hurd/hurd/resource.h
@@ -1,5 +1,5 @@
/* Resource limits for the Hurd.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@
#include <sys/types.h>
#include <sys/resource.h>
#include <errno.h>
+#include <bits/types/error_t.h>
#include <hurd/process.h>
/* This array contains the current resource limits for the process. */
diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h
index c589c59b4e..f84c4ef485 100644
--- a/hurd/hurd/signal.h
+++ b/hurd/hurd/signal.h
@@ -1,5 +1,5 @@
/* Implementing POSIX.1 signals under the Hurd.
- Copyright (C) 1993-2016 Free Software Foundation, Inc.
+ Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,10 +20,6 @@
#define _HURD_SIGNAL_H 1
#include <features.h>
-/* Make sure <signal.h> is going to define NSIG. */
-#ifndef __USE_GNU
-#error "Must have `_GNU_SOURCE' feature test macro to use this file"
-#endif
#define __need_size_t
#define __need_NULL
@@ -35,12 +31,21 @@
#include <hurd/hurd_types.h>
#include <signal.h>
#include <errno.h>
+#include <bits/types/error_t.h>
+#include <bits/types/stack_t.h>
+#include <bits/types/sigset_t.h>
+#include <bits/sigaction.h>
#include <hurd/msg.h>
#include <cthreads.h> /* For `struct mutex'. */
#include <setjmp.h> /* For `jmp_buf'. */
#include <spin-lock.h>
struct hurd_signal_preemptor; /* <hurd/sigpreempt.h> */
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc) || IS_IN (libpthread)
+# include <sigsetops.h>
+# endif
+#endif
/* Full details of a signal. */
@@ -68,8 +73,8 @@ struct hurd_sigstate
sigset_t blocked; /* What signals are blocked. */
sigset_t pending; /* Pending signals, possibly blocked. */
- struct sigaction actions[NSIG];
- struct sigaltstack sigaltstack;
+ struct sigaction actions[_NSIG];
+ stack_t sigaltstack;
/* Chain of thread-local signal preemptors; see <hurd/sigpreempt.h>.
Each element of this chain is in local stack storage, and the chain
@@ -78,7 +83,7 @@ struct hurd_sigstate
struct hurd_signal_preemptor *preemptors;
/* For each signal that may be pending, the details to deliver it with. */
- struct hurd_signal_detail pending_data[NSIG];
+ struct hurd_signal_detail pending_data[_NSIG];
/* If `suspended' is set when this thread gets a signal,
the signal thread sends an empty message to it. */
@@ -129,16 +134,15 @@ extern struct hurd_sigstate *_hurd_self_sigstate (void)
#endif
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate *
_hurd_self_sigstate (void)
{
- struct hurd_sigstate **location = &THREAD_SELF->_hurd_sigstate;
- if (*location == NULL)
- *location = _hurd_thread_sigstate (__mach_thread_self ());
- return *location;
+ if (THREAD_SELF->_hurd_sigstate == NULL)
+ THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ());
+ return THREAD_SELF->_hurd_sigstate;
}
-# endif
+# endif
#endif
/* Thread listening on our message port; also called the "signal thread". */
@@ -169,28 +173,26 @@ extern int _hurd_core_limit;
extern void *_hurd_critical_section_lock (void);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_SIGNAL_H_EXTERN_INLINE void *
_hurd_critical_section_lock (void)
{
- struct hurd_sigstate **location;
struct hurd_sigstate *ss;
#ifdef __LIBC_NO_TLS
- if (__LIBC_NO_TLS())
+ if (__LIBC_NO_TLS ())
/* TLS is currently initializing, no need to enter critical section. */
return NULL;
#endif
- location = &THREAD_SELF->_hurd_sigstate;
- ss = *location;
+ ss = THREAD_SELF->_hurd_sigstate;
if (ss == NULL)
{
/* The thread variable is unset; this must be the first time we've
asked for it. In this case, the critical section flag cannot
possible already be set. Look up our sigstate structure the slow
way. */
- ss = *location = _hurd_thread_sigstate (__mach_thread_self ());
+ ss = THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ());
}
if (! __spin_try_lock (&ss->critical_section_lock))
@@ -202,13 +204,13 @@ _hurd_critical_section_lock (void)
_hurd_critical_section_unlock to unlock it. */
return ss;
}
-# endif
+# endif
#endif
extern void _hurd_critical_section_unlock (void *our_lock);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_SIGNAL_H_EXTERN_INLINE void
_hurd_critical_section_unlock (void *our_lock)
{
@@ -231,7 +233,7 @@ _hurd_critical_section_unlock (void *our_lock)
__msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
}
}
-# endif
+# endif
#endif
/* Convenient macros for simple uses of critical sections.
@@ -362,18 +364,18 @@ extern mach_msg_timeout_t _hurd_interrupted_rpc_timeout;
do \
{ \
/* Get the message port. */ \
- __err = (fetch_msgport_expr); \
+ __err = (error_t) (fetch_msgport_expr); \
if (__err) \
break; \
/* Get the reference port. */ \
- __err = (fetch_refport_expr); \
+ __err = (error_t) (fetch_refport_expr); \
if (__err) \
{ \
/* Couldn't get it; deallocate MSGPORT and fail. */ \
__mach_port_deallocate (__mach_task_self (), msgport); \
break; \
} \
- __err = (rpc_expr); \
+ __err = (error_t) (rpc_expr); \
__mach_port_deallocate (__mach_task_self (), msgport); \
if ((dealloc_refport) && refport != MACH_PORT_NULL) \
__mach_port_deallocate (__mach_task_self (), refport); \
diff --git a/hurd/hurd/sigpreempt.h b/hurd/hurd/sigpreempt.h
index 3a1eaf2e9f..a1df82e2c6 100644
--- a/hurd/hurd/sigpreempt.h
+++ b/hurd/hurd/sigpreempt.h
@@ -1,5 +1,5 @@
/* Preemption of Hurd signals before POSIX.1 semantics take over.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -19,8 +19,12 @@
#ifndef _HURD_SIGPREEMPT_H
#define _HURD_SIGPREEMPT_H 1
+#define __need_size_t
+#include <stddef.h>
#include <errno.h>
-#include <signal.h> /* For sigset_t, sighandler_t, SIG_ERR. */
+#include <bits/types/error_t.h>
+#include <signal.h> /* For sighandler_t, SIG_ERR. */
+#include <bits/types/sigset_t.h>
struct hurd_sigstate; /* <hurd/signal.h> */
struct hurd_signal_detail; /* <hurd/signal.h> */
@@ -37,11 +41,11 @@ struct hurd_signal_preemptor
is tried, or the normal handling is done for the signal (which may
have been changed by the preemptor function). Otherwise, the signal
is processed as if the return value were its handler setting. */
- sighandler_t (*preemptor) (struct hurd_signal_preemptor *preemptor,
- struct hurd_sigstate *ss,
- int *signo, struct hurd_signal_detail *detail);
+ __sighandler_t (*preemptor) (struct hurd_signal_preemptor *preemptor,
+ struct hurd_sigstate *ss,
+ int *signo, struct hurd_signal_detail *detail);
/* If PREEMPTOR is null, act as if it returned HANDLER. */
- sighandler_t handler;
+ __sighandler_t handler;
struct hurd_signal_preemptor *next; /* List structure. */
};
@@ -78,7 +82,7 @@ void hurd_unpreempt_signals (struct hurd_signal_preemptor *preemptor);
error_t hurd_catch_signal (sigset_t sigset,
unsigned long int first, unsigned long int last,
error_t (*operate) (struct hurd_signal_preemptor *),
- sighandler_t handler);
+ __sighandler_t handler);
/* Convenience functions using `hurd_catch_signal'. */
diff --git a/hurd/hurd/threadvar.h b/hurd/hurd/threadvar.h
index ff43598d2c..414e452db5 100644
--- a/hurd/hurd/threadvar.h
+++ b/hurd/hurd/threadvar.h
@@ -1,5 +1,5 @@
/* Internal per-thread variables for the Hurd.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,6 +22,21 @@
#include <features.h>
#include <tls.h>
+/* The per-thread variables are found by ANDing this mask
+ with the value of the stack pointer and then adding this offset.
+
+ In the multi-threaded case, cthreads initialization sets
+ __hurd_threadvar_stack_mask to ~(cthread_stack_size - 1), a mask which
+ finds the base of the fixed-size cthreads stack; and
+ __hurd_threadvar_stack_offset to a small offset that skips the data
+ cthreads itself maintains at the base of each thread's stack.
+
+ In the single-threaded or libpthread case, __hurd_threadvar_stack_mask is
+ zero, so the stack pointer is ignored. */
+
+extern unsigned long int __hurd_threadvar_stack_mask;
+extern unsigned long int __hurd_threadvar_stack_offset;
+
/* The variables __hurd_sigthread_stack_base and
__hurd_sigthread_stack_end define the bounds of the stack used by the
signal thread, so that thread can always be specifically identified. */
@@ -29,13 +44,11 @@
extern unsigned long int __hurd_sigthread_stack_base;
extern unsigned long int __hurd_sigthread_stack_end;
-
-/* We do not use threadvars any more, this is kept as zero for compatibility with cthreads */
-extern unsigned long int __hurd_threadvar_stack_mask;
-extern unsigned long int __hurd_threadvar_stack_offset;
-extern unsigned int __hurd_threadvar_max;
-
+/* Store the MiG reply port reply port until we enable TLS. */
extern mach_port_t __hurd_reply_port0;
-#define __hurd_local_reply_port (*(__LIBC_NO_TLS() ? &__hurd_reply_port0 : &THREAD_SELF->reply_port))
+
+/* This returns either the TLS reply port variable, or a single-thread variable
+ when TLS is not initialized yet. */
+#define __hurd_local_reply_port (*(__LIBC_NO_TLS () ? &__hurd_reply_port0 : &THREAD_SELF->reply_port))
#endif /* hurd/threadvar.h */
diff --git a/hurd/hurd/userlink.h b/hurd/hurd/userlink.h
index 128ce59726..f9362557cb 100644
--- a/hurd/hurd/userlink.h
+++ b/hurd/hurd/userlink.h
@@ -1,5 +1,5 @@
/* Support for chains recording users of a resource; `struct hurd_userlink'.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,7 +24,11 @@
#define __need_NULL
#include <stddef.h>
-#include <hurd/signal.h>
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
+# include <hurd/signal.h>
+# endif
+#endif
#include <setjmp.h>
@@ -81,7 +85,7 @@ _hurd_userlink_link (struct hurd_userlink **chainp,
struct hurd_userlink *link);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_USERLINK_H_EXTERN_INLINE void
_hurd_userlink_link (struct hurd_userlink **chainp,
struct hurd_userlink *link)
@@ -102,7 +106,7 @@ _hurd_userlink_link (struct hurd_userlink **chainp,
link->thread.prevp = thread_chainp;
*thread_chainp = link;
}
-# endif
+# endif
#endif
@@ -112,7 +116,7 @@ _hurd_userlink_link (struct hurd_userlink **chainp,
extern int _hurd_userlink_unlink (struct hurd_userlink *link);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_USERLINK_H_EXTERN_INLINE int
_hurd_userlink_unlink (struct hurd_userlink *link)
{
@@ -135,7 +139,7 @@ _hurd_userlink_unlink (struct hurd_userlink *link)
return dealloc;
}
-# endif
+# endif
#endif
@@ -148,7 +152,7 @@ _hurd_userlink_unlink (struct hurd_userlink *link)
extern int _hurd_userlink_clear (struct hurd_userlink **chainp);
#if defined __USE_EXTERN_INLINES && defined _LIBC
-# if IS_IN (libc)
+# if IS_IN (libc)
_HURD_USERLINK_H_EXTERN_INLINE int
_hurd_userlink_clear (struct hurd_userlink **chainp)
{
@@ -161,7 +165,7 @@ _hurd_userlink_clear (struct hurd_userlink **chainp)
*chainp = NULL;
return 0;
}
-# endif
+# endif
#endif
#endif /* hurd/userlink.h */
diff --git a/hurd/hurd/xattr.h b/hurd/hurd/xattr.h
index 69640934dc..e9690831bb 100644
--- a/hurd/hurd/xattr.h
+++ b/hurd/hurd/xattr.h
@@ -1,5 +1,5 @@
/* Access to extended attributes on files for GNU/Hurd.
- Copyright (C) 2005-2016 Free Software Foundation, Inc.
+ Copyright (C) 2005-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdauth.c b/hurd/hurdauth.c
index 7ecba39c8d..1a7e67ea0e 100644
--- a/hurd/hurdauth.c
+++ b/hurd/hurdauth.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -52,8 +52,8 @@ _S_msg_add_auth (mach_port_t me,
int i, j, k;
vm_size_t offset;
- urp = vm_allocate (mach_task_self (), (vm_address_t *) newlistp,
- nexist + nnew * sizeof (uid_t), 1);
+ urp = __vm_allocate (mach_task_self (), (vm_address_t *) newlistp,
+ nexist + nnew * sizeof (uid_t), 1);
if (urp)
return urp;
@@ -75,10 +75,10 @@ _S_msg_add_auth (mach_port_t me,
offset = (round_page (nexist + nnew * sizeof (uid_t))
- round_page (j * sizeof (uid_t)));
if (offset)
- vm_deallocate (mach_task_self (),
- (vm_address_t) (*newlistp
- + (nexist + nnew * sizeof (uid_t))),
- offset);
+ __vm_deallocate (mach_task_self (),
+ (vm_address_t) (*newlistp
+ + (nexist + nnew * sizeof (uid_t))),
+ offset);
*newlistlen = j;
return 0;
}
@@ -136,8 +136,8 @@ _S_msg_add_auth (mach_port_t me,
#define freeup(array, len) \
if (array) \
- vm_deallocate (mach_task_self (), (vm_address_t) array, \
- len * sizeof (uid_t));
+ __vm_deallocate (mach_task_self (), (vm_address_t) array, \
+ len * sizeof (uid_t));
freeup (genuids, ngenuids);
freeup (auxuids, nauxuids);
diff --git a/hurd/hurdchdir.c b/hurd/hurdchdir.c
index 373df2745b..1adc9895e3 100644
--- a/hurd/hurdchdir.c
+++ b/hurd/hurdchdir.c
@@ -1,5 +1,5 @@
/* Change a port cell to a directory by looking up a name.
- Copyright (C) 1999-2016 Free Software Foundation, Inc.
+ Copyright (C) 1999-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c
index 9978607be6..732c9ec34b 100644
--- a/hurd/hurdexec.c
+++ b/hurd/hurdexec.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -30,11 +30,30 @@
/* Overlay TASK, executing FILE with arguments ARGV and environment ENVP.
If TASK == mach_task_self (), some ports are dealloc'd by the exec server.
- ARGV and ENVP are terminated by NULL pointers. */
+ ARGV and ENVP are terminated by NULL pointers.
+ Deprecated: use _hurd_exec_paths instead. */
error_t
_hurd_exec (task_t task, file_t file,
char *const argv[], char *const envp[])
{
+ return _hurd_exec_paths (task, file, NULL, NULL, argv, envp);
+}
+
+link_warning (_hurd_exec,
+ "_hurd_exec is deprecated, use _hurd_exec_paths instead");
+
+/* Overlay TASK, executing FILE with arguments ARGV and environment ENVP.
+ If TASK == mach_task_self (), some ports are dealloc'd by the exec server.
+ ARGV and ENVP are terminated by NULL pointers. PATH is the relative path to
+ FILE and ABSPATH is the absolute path to FILE. Passing NULL, though possible,
+ should be avoided, since then the exec server may not know the path to
+ FILE if FILE is a script, and will then pass /dev/fd/N to the
+ interpreter. */
+error_t
+_hurd_exec_paths (task_t task, file_t file,
+ const char *path, const char *abspath,
+ char *const argv[], char *const envp[])
+{
error_t err;
char *args, *env;
size_t argslen, envlen;
@@ -216,7 +235,7 @@ _hurd_exec (task_t task, file_t file,
/* We have euid != svuid or egid != svgid. POSIX.1 says that exec
sets svuid = euid and svgid = egid. So we must get a new auth
port and reauthenticate everything with it. We'll pass the new
- ports in file_exec instead of our own ports. */
+ ports in file_exec_paths instead of our own ports. */
auth_t newauth;
@@ -360,13 +379,28 @@ _hurd_exec (task_t task, file_t file,
if (__sigismember (&_hurdsig_traced, SIGKILL))
flags |= EXEC_SIGTRAP;
#endif
- err = __file_exec (file, task, flags,
- args, argslen, env, envlen,
- dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize,
- ports, MACH_MSG_TYPE_COPY_SEND, _hurd_nports,
- ints, INIT_INT_MAX,
- please_dealloc, pdp - please_dealloc,
- &_hurd_msgport, task == __mach_task_self () ? 1 : 0);
+ err = __file_exec_paths (file, task, flags,
+ path ? path : "",
+ abspath ? abspath : "",
+ args, argslen, env, envlen,
+ dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize,
+ ports, MACH_MSG_TYPE_COPY_SEND,
+ _hurd_nports,
+ ints, INIT_INT_MAX,
+ please_dealloc, pdp - please_dealloc,
+ &_hurd_msgport,
+ task == __mach_task_self () ? 1 : 0);
+ /* Fall back for backwards compatibility. This can just be removed
+ when __file_exec goes away. */
+ if (err == MIG_BAD_ID)
+ err = __file_exec (file, task, flags,
+ args, argslen, env, envlen,
+ dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize,
+ ports, MACH_MSG_TYPE_COPY_SEND, _hurd_nports,
+ ints, INIT_INT_MAX,
+ please_dealloc, pdp - please_dealloc,
+ &_hurd_msgport,
+ task == __mach_task_self () ? 1 : 0);
}
/* Release references to the standard ports. */
@@ -401,3 +435,4 @@ _hurd_exec (task_t task, file_t file,
free (env);
return err;
}
+libc_hidden_def (_hurd_exec_paths)
diff --git a/hurd/hurdfault.c b/hurd/hurdfault.c
index e3b3927110..39a4522811 100644
--- a/hurd/hurdfault.c
+++ b/hurd/hurdfault.c
@@ -1,5 +1,5 @@
/* Handle faults in the signal thread.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -204,7 +204,6 @@ _hurdsig_fault_init (void)
/* This state will be restored when we fault.
It runs the function above. */
memset (&state, 0, sizeof state);
-
MACHINE_THREAD_STATE_FIX_NEW (&state);
MACHINE_THREAD_STATE_SET_PC (&state, faulted);
MACHINE_THREAD_STATE_SET_SP (&state, faultstack, sizeof faultstack);
diff --git a/hurd/hurdfault.h b/hurd/hurdfault.h
index 075955bde0..04ae3903c3 100644
--- a/hurd/hurdfault.h
+++ b/hurd/hurdfault.h
@@ -1,5 +1,5 @@
/* Declarations for handling faults in the signal thread.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdfchdir.c b/hurd/hurdfchdir.c
index d771667345..cde753cc68 100644
--- a/hurd/hurdfchdir.c
+++ b/hurd/hurdfchdir.c
@@ -1,5 +1,5 @@
/* Change a port cell to a directory in an open file descriptor.
- Copyright (C) 1999-2016 Free Software Foundation, Inc.
+ Copyright (C) 1999-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdhost.h b/hurd/hurdhost.h
index 4e3ac33cbc..f2b3e68331 100644
--- a/hurd/hurdhost.h
+++ b/hurd/hurdhost.h
@@ -1,5 +1,5 @@
/* Host configuration items kept as the whole contents of a file.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdid.c b/hurd/hurdid.c
index 97c4d06f9b..71b50df1eb 100644
--- a/hurd/hurdid.c
+++ b/hurd/hurdid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c
index 02d0134519..6af1ddf610 100644
--- a/hurd/hurdinit.c
+++ b/hurd/hurdinit.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -110,6 +110,7 @@ _hurd_init (int flags, char **argv,
assume the availability of the POSIX.1 services we provide. */
RUN_HOOK (_hurd_subinit, ());
}
+libc_hidden_def (_hurd_init)
#include <hurd/signal.h>
diff --git a/hurd/hurdioctl.c b/hurd/hurdioctl.c
index 974787ed8b..5b05b3bfff 100644
--- a/hurd/hurdioctl.c
+++ b/hurd/hurdioctl.c
@@ -1,5 +1,5 @@
/* ioctl commands which must be done in the C library.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdkill.c b/hurd/hurdkill.c
index 2ae96312d0..d1e28df5aa 100644
--- a/hurd/hurdkill.c
+++ b/hurd/hurdkill.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdlock.c b/hurd/hurdlock.c
new file mode 100644
index 0000000000..382e9f2aa9
--- /dev/null
+++ b/hurd/hurdlock.c
@@ -0,0 +1,220 @@
+/* Hurd helpers for lowlevellocks.
+ Copyright (C) 1999-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "hurdlock.h"
+#include <hurd.h>
+#include <hurd/hurd.h>
+#include <time.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Convert an absolute timeout in nanoseconds to a relative
+ timeout in milliseconds. */
+static inline int __attribute__ ((gnu_inline))
+compute_reltime (const struct timespec *abstime, clockid_t clk)
+{
+ struct timespec ts;
+ __clock_gettime (clk, &ts);
+
+ ts.tv_sec = abstime->tv_sec - ts.tv_sec;
+ ts.tv_nsec = abstime->tv_nsec - ts.tv_nsec;
+
+ if (ts.tv_nsec < 0)
+ {
+ --ts.tv_sec;
+ ts.tv_nsec += 1000000000;
+ }
+
+ return ts.tv_sec < 0 ? -1 : (int)(ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
+}
+
+int
+__lll_abstimed_wait (void *ptr, int val,
+ const struct timespec *tsp, int flags, int clk)
+{
+ int mlsec = compute_reltime (tsp, clk);
+ return mlsec < 0 ? KERN_TIMEDOUT : lll_timed_wait (ptr, val, mlsec, flags);
+}
+
+int
+__lll_abstimed_xwait (void *ptr, int lo, int hi,
+ const struct timespec *tsp, int flags, int clk)
+{
+ int mlsec = compute_reltime (tsp, clk);
+ return mlsec < 0 ? KERN_TIMEDOUT : lll_timed_xwait (ptr, lo, hi, mlsec,
+ flags);
+}
+
+int
+__lll_abstimed_lock (void *ptr,
+ const struct timespec *tsp, int flags, int clk)
+{
+ if (lll_trylock (ptr) == 0)
+ return 0;
+
+ while (1)
+ {
+ if (atomic_exchange_acq ((int *)ptr, 2) == 0)
+ return 0;
+ else if (tsp->tv_nsec < 0 || tsp->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ int mlsec = compute_reltime (tsp, clk);
+ if (mlsec < 0 || lll_timed_wait (ptr, 2, mlsec, flags) == KERN_TIMEDOUT)
+ return ETIMEDOUT;
+ }
+}
+
+/* Robust locks. */
+
+/* Test if a given process id is still valid. */
+static inline int
+valid_pid (int pid)
+{
+ task_t task = __pid2task (pid);
+ if (task == MACH_PORT_NULL)
+ return 0;
+
+ __mach_port_deallocate (__mach_task_self (), task);
+ return 1;
+}
+
+/* Robust locks have currently no support from the kernel; they
+ are simply implemented with periodic polling. When sleeping, the
+ maximum blocking time is determined by this constant. */
+#define MAX_WAIT_TIME 1500
+
+int
+__lll_robust_lock (void *ptr, int flags)
+{
+ int *iptr = (int *)ptr;
+ int id = __getpid ();
+ int wait_time = 25;
+ unsigned int val;
+
+ /* Try to set the lock word to our PID if it's clear. Otherwise,
+ mark it as having waiters. */
+ while (1)
+ {
+ val = *iptr;
+ if (!val && atomic_compare_and_exchange_bool_acq (iptr, id, 0) == 0)
+ return 0;
+ else if (atomic_compare_and_exchange_bool_acq (iptr,
+ val | LLL_WAITERS, val) == 0)
+ break;
+ }
+
+ for (id |= LLL_WAITERS ; ; )
+ {
+ val = *iptr;
+ if (!val && atomic_compare_and_exchange_bool_acq (iptr, id, 0) == 0)
+ return 0;
+ else if (val && !valid_pid (val & LLL_OWNER_MASK))
+ {
+ if (atomic_compare_and_exchange_bool_acq (iptr, id, val) == 0)
+ return EOWNERDEAD;
+ }
+ else
+ {
+ lll_timed_wait (iptr, val, wait_time, flags);
+ if (wait_time < MAX_WAIT_TIME)
+ wait_time <<= 1;
+ }
+ }
+}
+
+int
+__lll_robust_abstimed_lock (void *ptr,
+ const struct timespec *tsp, int flags, int clk)
+{
+ int *iptr = (int *)ptr;
+ int id = __getpid ();
+ int wait_time = 25;
+ unsigned int val;
+
+ while (1)
+ {
+ val = *iptr;
+ if (!val && atomic_compare_and_exchange_bool_acq (iptr, id, 0) == 0)
+ return 0;
+ else if (atomic_compare_and_exchange_bool_acq (iptr,
+ val | LLL_WAITERS, val) == 0)
+ break;
+ }
+
+ for (id |= LLL_WAITERS ; ; )
+ {
+ val = *iptr;
+ if (!val && atomic_compare_and_exchange_bool_acq (iptr, id, 0) == 0)
+ return 0;
+ else if (val && !valid_pid (val & LLL_OWNER_MASK))
+ {
+ if (atomic_compare_and_exchange_bool_acq (iptr, id, val) == 0)
+ return EOWNERDEAD;
+ }
+ else
+ {
+ int mlsec = compute_reltime (tsp, clk);
+ if (mlsec < 0)
+ return ETIMEDOUT;
+ else if (mlsec > wait_time)
+ mlsec = wait_time;
+
+ int res = lll_timed_wait (iptr, val, mlsec, flags);
+ if (res == KERN_TIMEDOUT)
+ return ETIMEDOUT;
+ else if (wait_time < MAX_WAIT_TIME)
+ wait_time <<= 1;
+ }
+ }
+}
+
+int
+__lll_robust_trylock (void *ptr)
+{
+ int *iptr = (int *)ptr;
+ int id = __getpid ();
+ unsigned int val = *iptr;
+
+ if (!val)
+ {
+ if (atomic_compare_and_exchange_bool_acq (iptr, id, 0) == 0)
+ return 0;
+ }
+ else if (!valid_pid (val & LLL_OWNER_MASK)
+ && atomic_compare_and_exchange_bool_acq (iptr, id, val) == 0)
+ return EOWNERDEAD;
+
+ return EBUSY;
+}
+
+void
+__lll_robust_unlock (void *ptr, int flags)
+{
+ unsigned int val = atomic_load_relaxed ((unsigned int *)ptr);
+ while (1)
+ {
+ if (val & LLL_WAITERS)
+ {
+ lll_set_wake (ptr, 0, flags);
+ break;
+ }
+ else if (atomic_compare_exchange_weak_release ((unsigned int *)ptr, &val, 0))
+ break;
+ }
+}
diff --git a/hurd/hurdlock.h b/hurd/hurdlock.h
new file mode 100644
index 0000000000..4a8f416a1a
--- /dev/null
+++ b/hurd/hurdlock.h
@@ -0,0 +1,125 @@
+/* Low-level lock implementation. High-level Hurd helpers.
+ Copyright (C) 1999-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _HURD_LOCK_H
+#define _HURD_LOCK_H 1
+
+#include <mach/lowlevellock.h>
+
+struct timespec;
+
+/* Flags for robust locks. */
+#define LLL_WAITERS (1U << 31)
+#define LLL_DEAD_OWNER (1U << 30)
+
+#define LLL_OWNER_MASK ~(LLL_WAITERS | LLL_DEAD_OWNER)
+
+/* Wait on 64-bit address PTR, without blocking if its contents
+ are different from the pair <LO, HI>. */
+#define lll_xwait(ptr, lo, hi, flags) \
+ __gsync_wait (__mach_task_self (), \
+ (vm_offset_t)ptr, lo, hi, 0, flags | GSYNC_QUAD)
+
+/* Same as 'lll_wait', but only block for MLSEC milliseconds. */
+#define lll_timed_wait(ptr, val, mlsec, flags) \
+ __gsync_wait (__mach_task_self (), \
+ (vm_offset_t)ptr, val, 0, mlsec, flags | GSYNC_TIMED)
+
+/* Same as 'lll_xwait', but only block for MLSEC milliseconds. */
+#define lll_timed_xwait(ptr, lo, hi, mlsec, flags) \
+ __gsync_wait (__mach_task_self (), (vm_offset_t)ptr, \
+ lo, hi, mlsec, flags | GSYNC_TIMED | GSYNC_QUAD)
+
+/* Same as 'lll_wait', but only block until TSP elapses,
+ using clock CLK. */
+extern int __lll_abstimed_wait (void *__ptr, int __val,
+ const struct timespec *__tsp, int __flags, int __clk);
+
+/* Same as 'lll_xwait', but only block until TSP elapses,
+ using clock CLK. */
+extern int __lll_abstimed_xwait (void *__ptr, int __lo, int __hi,
+ const struct timespec *__tsp, int __flags, int __clk);
+
+/* Same as 'lll_lock', but return with an error if TSP elapses,
+ using clock CLK. */
+extern int __lll_abstimed_lock (void *__ptr,
+ const struct timespec *__tsp, int __flags, int __clk);
+
+/* Acquire the lock at PTR, but return with an error if
+ the process containing the owner thread dies. */
+extern int __lll_robust_lock (void *__ptr, int __flags);
+
+/* Same as '__lll_robust_lock', but only block until TSP
+ elapses, using clock CLK. */
+extern int __lll_robust_abstimed_lock (void *__ptr,
+ const struct timespec *__tsp, int __flags, int __clk);
+
+/* Same as '__lll_robust_lock', but return with an error
+ if the lock cannot be acquired without blocking. */
+extern int __lll_robust_trylock (void *__ptr);
+
+/* Wake one or more threads waiting on address PTR,
+ setting its value to VAL before doing so. */
+#define lll_set_wake(ptr, val, flags) \
+ __gsync_wake (__mach_task_self (), \
+ (vm_offset_t)ptr, val, flags | GSYNC_MUTATE)
+
+/* Release the robust lock at PTR. */
+extern void __lll_robust_unlock (void *__ptr, int __flags);
+
+/* Rearrange threads waiting on address SRC to instead wait on
+ DST, waking one of them if WAIT_ONE is non-zero. */
+#define lll_requeue(src, dst, wake_one, flags) \
+ __gsync_requeue (__mach_task_self (), (vm_offset_t)src, \
+ (vm_offset_t)dst, (boolean_t)wake_one, flags)
+
+/* The following are hacks that allow us to simulate optional
+ parameters in C, to avoid having to pass the clock id for
+ every one of these calls, defaulting to CLOCK_REALTIME if
+ no argument is passed. */
+
+#define lll_abstimed_wait(ptr, val, tsp, flags, ...) \
+ ({ \
+ const clockid_t __clk[] = { CLOCK_REALTIME, ##__VA_ARGS__ }; \
+ __lll_abstimed_wait ((ptr), (val), (tsp), (flags), \
+ __clk[sizeof (__clk) / sizeof (__clk[0]) - 1]); \
+ })
+
+#define lll_abstimed_xwait(ptr, lo, hi, tsp, flags, ...) \
+ ({ \
+ const clockid_t __clk[] = { CLOCK_REALTIME, ##__VA_ARGS__ }; \
+ __lll_abstimed_xwait ((ptr), (lo), (hi), (tsp), (flags), \
+ __clk[sizeof (__clk) / sizeof (__clk[0]) - 1]); \
+ })
+
+#define lll_abstimed_lock(ptr, tsp, flags, ...) \
+ ({ \
+ const clockid_t __clk[] = { CLOCK_REALTIME, ##__VA_ARGS__ }; \
+ __lll_abstimed_lock ((ptr), (tsp), (flags), \
+ __clk[sizeof (__clk) / sizeof (__clk[0]) - 1]); \
+ })
+
+#define lll_robust_abstimed_lock(ptr, tsp, flags, ...) \
+ ({ \
+ const clockid_t __clk[] = { CLOCK_REALTIME, ##__VA_ARGS__ }; \
+ __lll_robust_abstimed_lock ((ptr), (tsp), (flags), \
+ __clk[sizeof (__clk) / sizeof (__clk[0]) - 1]); \
+ })
+
+
+#endif
diff --git a/hurd/hurdlookup.c b/hurd/hurdlookup.c
index dbff009539..a642c49002 100644
--- a/hurd/hurdlookup.c
+++ b/hurd/hurdlookup.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -42,7 +42,7 @@ __hurd_file_name_lookup (error_t (*use_init_port)
(int which, error_t (*operate) (file_t)),
file_t (*get_dtable_port) (int fd),
error_t (*lookup)
- (file_t dir, char *name, int flags, mode_t mode,
+ (file_t dir, const char *name, int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
const char *file_name, int flags, mode_t mode,
@@ -72,7 +72,7 @@ __hurd_file_name_lookup (error_t (*use_init_port)
if (flags & O_NOFOLLOW) /* See lookup-retry.c about O_NOFOLLOW. */
flags |= O_NOTRANS;
- if (flags & O_DIRECTORY)
+ if (flags & O_DIRECTORY && (flags & O_NOFOLLOW) == 0)
{
/* The caller wants to require that the file we look up is a directory.
We can do this without an extra RPC by appending a trailing slash
@@ -105,7 +105,7 @@ __hurd_file_name_split (error_t (*use_init_port)
(int which, error_t (*operate) (file_t)),
file_t (*get_dtable_port) (int fd),
error_t (*lookup)
- (file_t dir, char *name, int flags, mode_t mode,
+ (file_t dir, const char *name, int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
const char *file_name,
@@ -158,7 +158,7 @@ __hurd_directory_name_split (error_t (*use_init_port)
(int which, error_t (*operate) (file_t)),
file_t (*get_dtable_port) (int fd),
error_t (*lookup)
- (file_t dir, char *name, int flags, mode_t mode,
+ (file_t dir, const char *name, int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
const char *file_name,
diff --git a/hurd/hurdmalloc.c b/hurd/hurdmalloc.c
index 58c29fa07d..65fb959d84 100644
--- a/hurd/hurdmalloc.c
+++ b/hurd/hurdmalloc.c
@@ -405,8 +405,8 @@ print_malloc_free_list (void)
}
#endif /* DEBUG */
-static void
-malloc_fork_prepare(void)
+void
+_hurd_malloc_fork_prepare(void)
/*
* Prepare the malloc module for a fork by insuring that no thread is in a
* malloc critical section.
@@ -419,8 +419,8 @@ malloc_fork_prepare(void)
}
}
-static void
-malloc_fork_parent(void)
+void
+_hurd_malloc_fork_parent(void)
/*
* Called in the parent process after a fork() to resume normal operation.
*/
@@ -432,8 +432,8 @@ malloc_fork_parent(void)
}
}
-static void
-malloc_fork_child(void)
+void
+_hurd_malloc_fork_child(void)
/*
* Called in the child process after a fork() to resume normal operation.
*/
@@ -446,7 +446,4 @@ malloc_fork_child(void)
}
-text_set_element (_hurd_fork_prepare_hook, malloc_fork_prepare);
-text_set_element (_hurd_fork_parent_hook, malloc_fork_parent);
-text_set_element (_hurd_fork_child_hook, malloc_fork_child);
text_set_element (_hurd_preinit_hook, malloc_init);
diff --git a/hurd/hurdmalloc.h b/hurd/hurdmalloc.h
index e11c208a8f..3520ffacd8 100644
--- a/hurd/hurdmalloc.h
+++ b/hurd/hurdmalloc.h
@@ -12,6 +12,10 @@ extern void *_hurd_malloc (size_t);
extern void *_hurd_realloc (void *, size_t);
extern void _hurd_free (void *);
+extern void _hurd_malloc_fork_prepare (void);
+extern void _hurd_malloc_fork_parent (void);
+extern void _hurd_malloc_fork_child (void);
+
#define malloc _hurd_malloc
#define realloc _hurd_realloc
#define free _hurd_free
diff --git a/hurd/hurdmsg.c b/hurd/hurdmsg.c
index 65f6edb1fa..63e5e81b87 100644
--- a/hurd/hurdmsg.c
+++ b/hurd/hurdmsg.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -344,7 +344,7 @@ _S_msg_set_env_variable (mach_port_t msgport, mach_port_t auth,
{
AUTHCHECK;
- if (setenv (variable, value, replace)) /* XXX name space */
+ if (__setenv (variable, value, replace)) /* XXX name space */
return errno;
return 0;
}
diff --git a/hurd/hurdpid.c b/hurd/hurdpid.c
index e5cda8c2f0..33659cc1ba 100644
--- a/hurd/hurdpid.c
+++ b/hurd/hurdpid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,6 +16,8 @@
<http://www.gnu.org/licenses/>. */
#include <hurd.h>
+#include <lowlevellock.h>
+
pid_t _hurd_pid, _hurd_ppid, _hurd_pgrp;
int _hurd_orphaned;
@@ -66,6 +68,7 @@ _S_msg_proc_newids (mach_port_t me,
/* Notify any waiting user threads that the id change as been completed. */
++_hurd_pids_changed_stamp;
+ lll_wake (&_hurd_pids_changed_stamp, GSYNC_BROADCAST);
return 0;
}
diff --git a/hurd/hurdports.c b/hurd/hurdports.c
index 287ccf63fe..410beab292 100644
--- a/hurd/hurdports.c
+++ b/hurd/hurdports.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdprio.c b/hurd/hurdprio.c
index ee98195f26..3783fe9397 100644
--- a/hurd/hurdprio.c
+++ b/hurd/hurdprio.c
@@ -1,5 +1,5 @@
/* Support code for dealing with priorities in the Hurd.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -50,7 +50,7 @@ _hurd_priority_which_map (enum __priority_which which, int who,
case PRIO_USER:
if (who == 0)
- who = geteuid ();
+ who = __geteuid ();
err = __USEPORT (PROC, __proc_getallpids (port, &pids, &npids));
for (i = 0; !err && i < npids; ++i)
{
diff --git a/hurd/hurdrlimit.c b/hurd/hurdrlimit.c
index ba24867ed7..231a9a4f51 100644
--- a/hurd/hurdrlimit.c
+++ b/hurd/hurdrlimit.c
@@ -1,5 +1,5 @@
/* Resource limits.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdselect.c b/hurd/hurdselect.c
index d5ba826d16..74f176d79d 100644
--- a/hurd/hurdselect.c
+++ b/hurd/hurdselect.c
@@ -1,5 +1,5 @@
/* Guts of both `select' and `poll' for Hurd.
- Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c
index b5c863438d..aa82f63413 100644
--- a/hurd/hurdsig.c
+++ b/hurd/hurdsig.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,9 +20,10 @@
#include <string.h>
#include <cthreads.h> /* For `struct mutex'. */
-#include <pthread.h>
+#include <pthreadP.h>
#include <mach.h>
#include <mach/thread_switch.h>
+#include <mach/mig_support.h>
#include <hurd.h>
#include <hurd/id.h>
@@ -32,6 +33,8 @@
#include "hurdmalloc.h" /* XXX */
#include "../locale/localeinfo.h"
+#include <libc-diag.h>
+
const char *_hurdsig_getenv (const char *);
struct mutex _hurd_siglock;
@@ -120,6 +123,7 @@ _hurd_thread_sigstate (thread_t thread)
__mutex_unlock (&_hurd_siglock);
return ss;
}
+libc_hidden_def (_hurd_thread_sigstate)
/* Signal delivery itself is on this page. */
@@ -244,8 +248,14 @@ interrupted_reply_port_location (thread_t thread,
/* Faulted trying to read the TCB. */
return NULL;
+ DIAG_PUSH_NEEDS_COMMENT;
+ /* GCC 6 and before seem to be confused by the setjmp call inside
+ _hurdsig_catch_memory_fault and think that we may be returning a second
+ time to here with portloc uninitialized (but we never do). */
+ DIAG_IGNORE_NEEDS_COMMENT (6, "-Wmaybe-uninitialized");
/* Fault now if this pointer is bogus. */
*(volatile mach_port_t *) portloc = *portloc;
+ DIAG_POP_NEEDS_COMMENT;
if (sigthread)
_hurdsig_end_catch_fault ();
@@ -1018,7 +1028,7 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss,
|| ss->actions[signo].sa_handler == SIG_IGN
|| ss->actions[signo].sa_handler == SIG_DFL))
{
- mutex_unlock (&_hurd_siglock);
+ __mutex_unlock (&_hurd_siglock);
goto deliver_pending;
}
__spin_unlock (&ss->lock);
@@ -1258,11 +1268,8 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
/* Start the signal thread listening on the message port. */
-#pragma weak cthread_fork
-#pragma weak cthread_detach
-#pragma weak pthread_getattr_np
-#pragma weak pthread_attr_getstack
- if (!cthread_fork)
+#pragma weak __cthread_fork
+ if (!__cthread_fork)
{
err = __thread_create (__mach_task_self (), &_hurd_msgport_thread);
assert_perror (err);
@@ -1287,7 +1294,6 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
}
else
{
- cthread_t thread;
/* When cthreads is being used, we need to make the signal thread a
proper cthread. Otherwise it cannot use mutex_lock et al, which
will be the cthreads versions. Various of the message port RPC
@@ -1297,17 +1303,22 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
we'll let the signal thread's per-thread variables be found as for
any normal cthread, and just leave the magic __hurd_sigthread_*
values all zero so they'll be ignored. */
- cthread_detach (thread = cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, 0));
-
- if (pthread_getattr_np)
+#pragma weak __cthread_detach
+#pragma weak __pthread_getattr_np
+#pragma weak __pthread_attr_getstack
+ __cthread_t thread = __cthread_fork (
+ (cthread_fn_t) &_hurd_msgport_receive, 0);
+ __cthread_detach (thread);
+
+ if (__pthread_getattr_np)
{
- /* Record stack layout for fork() */
+ /* Record signal thread stack layout for fork() */
pthread_attr_t attr;
void *addr;
size_t size;
- pthread_getattr_np ((pthread_t) thread, &attr);
- pthread_attr_getstack (&attr, &addr, &size);
+ __pthread_getattr_np ((pthread_t) thread, &attr);
+ __pthread_attr_getstack (&attr, &addr, &size);
__hurd_sigthread_stack_base = (uintptr_t) addr;
__hurd_sigthread_stack_end = __hurd_sigthread_stack_base + size;
}
@@ -1363,14 +1374,14 @@ reauth_proc (mach_port_t new)
__mach_port_destroy (__mach_task_self (), ref);
/* Set the owner of the process here too. */
- mutex_lock (&_hurd_id.lock);
+ __mutex_lock (&_hurd_id.lock);
if (!_hurd_check_ids ())
HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC],
__proc_setowner (port,
(_hurd_id.gen.nuids
? _hurd_id.gen.uids[0] : 0),
!_hurd_id.gen.nuids));
- mutex_unlock (&_hurd_id.lock);
+ __mutex_unlock (&_hurd_id.lock);
(void) &reauth_proc; /* Silence compiler warning. */
}
diff --git a/hurd/hurdsock.c b/hurd/hurdsock.c
index 1aaec27acd..bb98a6b745 100644
--- a/hurd/hurdsock.c
+++ b/hurd/hurdsock.c
@@ -1,5 +1,5 @@
/* _hurd_socket_server - Find the server for a socket domain.
- Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdsocket.h b/hurd/hurdsocket.h
index aef3faadda..dab74febce 100644
--- a/hurd/hurdsocket.h
+++ b/hurd/hurdsocket.h
@@ -1,5 +1,5 @@
/* Hurd-specific socket functions
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
+ Copyright (C) 2013-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdstartup.c b/hurd/hurdstartup.c
index edfd96fcbd..b148125c96 100644
--- a/hurd/hurdstartup.c
+++ b/hurd/hurdstartup.c
@@ -1,5 +1,5 @@
/* Initial program startup for running under the GNU Hurd.
- Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/hurdstartup.h b/hurd/hurdstartup.h
index cba69b6e93..64d12e19ba 100644
--- a/hurd/hurdstartup.h
+++ b/hurd/hurdstartup.h
@@ -1,5 +1,5 @@
/* Data from initial program startup for running under the GNU Hurd.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/intern-fd.c b/hurd/intern-fd.c
index 239bb8a874..3b00824cc1 100644
--- a/hurd/intern-fd.c
+++ b/hurd/intern-fd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -47,3 +47,4 @@ _hurd_intern_fd (io_t port, int flags, int dealloc)
return fd;
}
+libc_hidden_def (_hurd_intern_fd)
diff --git a/hurd/intr-msg.c b/hurd/intr-msg.c
index 95e5c5acfb..2f83ac6ce7 100644
--- a/hurd/intr-msg.c
+++ b/hurd/intr-msg.c
@@ -1,5 +1,5 @@
/* Replacement for mach_msg used in interruptible Hurd RPCs.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -422,3 +422,4 @@ _hurd_intr_rpc_mach_msg (mach_msg_header_t *msg,
return err;
}
+libc_hidden_def (_hurd_intr_rpc_mach_msg)
diff --git a/hurd/intr-rpc.defs b/hurd/intr-rpc.defs
index 7e61d799a9..c48443dd6f 100644
--- a/hurd/intr-rpc.defs
+++ b/hurd/intr-rpc.defs
@@ -1,5 +1,5 @@
/* Special MiG definitions for interruptible RPC stubs.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/intr-rpc.h b/hurd/intr-rpc.h
index f6a9783ad7..5e7937b7cb 100644
--- a/hurd/intr-rpc.h
+++ b/hurd/intr-rpc.h
@@ -1,5 +1,5 @@
/* Special MiG definitions for interruptible RPC stubs.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/longjmp-ts.c b/hurd/longjmp-ts.c
index 3252dcb25f..5a8bf6fe06 100644
--- a/hurd/longjmp-ts.c
+++ b/hurd/longjmp-ts.c
@@ -1,5 +1,5 @@
/* Perform a `longjmp' on a Mach thread_state. Stub version.
- Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/lookup-at.c b/hurd/lookup-at.c
index 5b03a4c9d0..deddc2264c 100644
--- a/hurd/lookup-at.c
+++ b/hurd/lookup-at.c
@@ -1,5 +1,5 @@
/* Lookup helper function for Hurd implementation of *at functions.
- Copyright (C) 2006-2016 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c
index aee2ba8f93..b596848624 100644
--- a/hurd/lookup-retry.c
+++ b/hurd/lookup-retry.c
@@ -1,5 +1,5 @@
/* hairy bits of Hurd file name lookup
- Copyright (C) 1992-2016 Free Software Foundation, Inc.
+ Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -47,7 +47,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
(int which, error_t (*operate) (file_t)),
file_t (*get_dtable_port) (int fd),
error_t (*lookup)
- (file_t dir, char *name,
+ (file_t dir, const char *name,
int flags, mode_t mode,
retry_type *do_retry, string_t retry_name,
mach_port_t *result),
@@ -127,7 +127,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
{
/* In Linux, O_NOFOLLOW means to reject symlinks. If we
did an O_NOLINK lookup above and io_stat here to check
- for S_IFLNK, a translator like firmlink could easily
+ for S_IFLNK only, a translator like firmlink could easily
spoof this check by not showing S_IFLNK, but in fact
redirecting the lookup to some other name
(i.e. opening the very same holes a symlink would).
@@ -145,23 +145,29 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
one exception to our general translator-based rule. */
struct stat64 st;
err = __io_stat (*result, &st);
- if (!err
- && (st.st_mode & (S_IPTRANS|S_IATRANS)))
+ if (!err)
{
- if (st.st_uid != 0)
- err = ENOENT;
- else if (st.st_mode & S_IPTRANS)
+ if (flags & O_DIRECTORY && !S_ISDIR (st.st_mode))
+ err = ENOTDIR;
+ if (S_ISLNK (st.st_mode))
+ err = ELOOP;
+ else if (st.st_mode & (S_IPTRANS|S_IATRANS))
{
- char buf[1024];
- char *trans = buf;
- size_t translen = sizeof buf;
- err = __file_get_translator (*result,
- &trans, &translen);
- if (!err
- && translen > sizeof _HURD_SYMLINK
- && !memcmp (trans,
- _HURD_SYMLINK, sizeof _HURD_SYMLINK))
- err = ENOENT;
+ if (st.st_uid != 0)
+ err = ELOOP;
+ else if (st.st_mode & S_IPTRANS)
+ {
+ char buf[1024];
+ char *trans = buf;
+ size_t translen = sizeof buf;
+ err = __file_get_translator (*result,
+ &trans, &translen);
+ if (!err
+ && translen > sizeof _HURD_SYMLINK
+ && !memcmp (trans,
+ _HURD_SYMLINK, sizeof _HURD_SYMLINK))
+ err = ELOOP;
+ }
}
}
}
diff --git a/hurd/msgportdemux.c b/hurd/msgportdemux.c
index c7ebf89c39..370cf4fb81 100644
--- a/hurd/msgportdemux.c
+++ b/hurd/msgportdemux.c
@@ -1,5 +1,5 @@
/* Demux messages sent on the signal port.
- Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/new-fd.c b/hurd/new-fd.c
index e5c9f9ea63..eab03471bf 100644
--- a/hurd/new-fd.c
+++ b/hurd/new-fd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/openport.c b/hurd/openport.c
index fbb59ceb03..308e19a4ad 100644
--- a/hurd/openport.c
+++ b/hurd/openport.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/path-lookup.c b/hurd/path-lookup.c
index 3186e8bf3d..5607d5809c 100644
--- a/hurd/path-lookup.c
+++ b/hurd/path-lookup.c
@@ -1,5 +1,5 @@
/* Filename lookup using a search path
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -33,7 +33,7 @@ file_name_path_scan (const char *file_name, const char *path,
error_t (*fun)(const char *name),
char **prefixed_name)
{
- if (path == NULL || index (file_name, '/'))
+ if (path == NULL || strchr (file_name, '/'))
{
if (prefixed_name)
*prefixed_name = 0;
@@ -47,7 +47,7 @@ file_name_path_scan (const char *file_name, const char *path,
for (;;)
{
error_t err;
- const char *next = index (path, ':') ?: path + strlen (path);
+ const char *next = strchr (path, ':') ?: path + strlen (path);
size_t pfx_len = next - path;
char pfxed_name[pfx_len + 2 + file_name_len + 1];
@@ -63,7 +63,7 @@ file_name_path_scan (const char *file_name, const char *path,
if (err == 0)
{
if (prefixed_name)
- *prefixed_name = strdup (pfxed_name);
+ *prefixed_name = __strdup (pfxed_name);
return 0;
}
if (!real_err && err != ENOENT)
@@ -87,16 +87,16 @@ file_name_path_scan (const char *file_name, const char *path,
if it is looked up using a prefix from PATH, *PREFIXED_NAME is set to
malloced storage containing the prefixed name. */
error_t
-hurd_file_name_path_lookup (error_t (*use_init_port)
- (int which, error_t (*operate) (mach_port_t)),
- file_t (*get_dtable_port) (int fd),
- error_t (*lookup)
- (file_t dir, char *name, int flags, mode_t mode,
- retry_type *do_retry, string_t retry_name,
- mach_port_t *result),
- const char *file_name, const char *path,
- int flags, mode_t mode,
- file_t *result, char **prefixed_name)
+__hurd_file_name_path_lookup (error_t (*use_init_port)
+ (int which, error_t (*operate) (mach_port_t)),
+ file_t (*get_dtable_port) (int fd),
+ error_t (*lookup)
+ (file_t dir, const char *name, int flags, mode_t mode,
+ retry_type *do_retry, string_t retry_name,
+ mach_port_t *result),
+ const char *file_name, const char *path,
+ int flags, mode_t mode,
+ file_t *result, char **prefixed_name)
{
error_t scan_lookup (const char *name)
{
@@ -106,6 +106,7 @@ hurd_file_name_path_lookup (error_t (*use_init_port)
}
return file_name_path_scan (file_name, path, scan_lookup, prefixed_name);
}
+strong_alias (__hurd_file_name_path_lookup, hurd_file_name_path_lookup)
file_t
file_name_path_lookup (const char *file_name, const char *path,
@@ -114,9 +115,9 @@ file_name_path_lookup (const char *file_name, const char *path,
error_t err;
file_t result;
- err = hurd_file_name_path_lookup (&_hurd_ports_use, &__getdport, 0,
- file_name, path, flags, mode,
- &result, prefixed_name);
+ err = __hurd_file_name_path_lookup (&_hurd_ports_use, &__getdport, 0,
+ file_name, path, flags, mode,
+ &result, prefixed_name);
return err ? (__hurd_fail (err), MACH_PORT_NULL) : result;
}
diff --git a/hurd/pid2task.c b/hurd/pid2task.c
index 80ee017a17..fd3ca02f3f 100644
--- a/hurd/pid2task.c
+++ b/hurd/pid2task.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/port-cleanup.c b/hurd/port-cleanup.c
index fe1c6ce4ca..fe22b458cc 100644
--- a/hurd/port-cleanup.c
+++ b/hurd/port-cleanup.c
@@ -1,5 +1,5 @@
/* Cleanup function for `struct hurd_port' users who longjmp.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/port2fd.c b/hurd/port2fd.c
index 9b52c74a2e..858a409f4a 100644
--- a/hurd/port2fd.c
+++ b/hurd/port2fd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/ports-get.c b/hurd/ports-get.c
index fb34fe64ba..648f029ed8 100644
--- a/hurd/ports-get.c
+++ b/hurd/ports-get.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/ports-set.c b/hurd/ports-set.c
index ce7456eb31..9ecd69cc39 100644
--- a/hurd/ports-set.c
+++ b/hurd/ports-set.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/preempt-sig.c b/hurd/preempt-sig.c
index bece0f26bf..c31e85e53d 100644
--- a/hurd/preempt-sig.c
+++ b/hurd/preempt-sig.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/privports.c b/hurd/privports.c
index 94d8156b5d..68121e77f0 100644
--- a/hurd/privports.c
+++ b/hurd/privports.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/report-wait.c b/hurd/report-wait.c
index f11a0902c3..db63fbe844 100644
--- a/hurd/report-wait.c
+++ b/hurd/report-wait.c
@@ -1,5 +1,5 @@
/* Report on what a thread in our task is waiting for.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/set-host.c b/hurd/set-host.c
index 252ce7be0d..6e20d15d4b 100644
--- a/hurd/set-host.c
+++ b/hurd/set-host.c
@@ -1,5 +1,5 @@
/* Set a host configuration item kept as the whole contents of a file.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/setauth.c b/hurd/setauth.c
index d38fdddd52..025be580e1 100644
--- a/hurd/setauth.c
+++ b/hurd/setauth.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,14 +18,13 @@
#include <hurd.h>
#include <hurd/port.h>
#include <hurd/id.h>
+#include <hurdlock.h>
#include "set-hooks.h"
/* Things in the library which want to be run when the auth port changes. */
DEFINE_HOOK (_hurd_reauth_hook, (auth_t new_auth));
-#include <cthreads.h>
-static struct mutex reauth_lock = MUTEX_INITIALIZER;
-
+static unsigned int reauth_lock = LLL_INITIALIZER;
/* Set the auth port to NEW, and reauthenticate
everything used by the library. */
diff --git a/hurd/seteuids.c b/hurd/seteuids.c
index 21e3431e2a..edfa4c2195 100644
--- a/hurd/seteuids.c
+++ b/hurd/seteuids.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/siginfo.c b/hurd/siginfo.c
index 743abed941..75e02d5282 100644
--- a/hurd/siginfo.c
+++ b/hurd/siginfo.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,10 +17,11 @@
#include <hurd/signal.h>
#include <stdio.h>
+#include <libioP.h>
void
_hurd_siginfo_handler (int signo)
{
/* XXX */
- puts ("got a SIGINFO");
+ _IO_puts ("got a SIGINFO");
}
diff --git a/hurd/sigunwind.c b/hurd/sigunwind.c
index a999173c50..40e0f679f7 100644
--- a/hurd/sigunwind.c
+++ b/hurd/sigunwind.c
@@ -1,5 +1,5 @@
/* longjmp cleanup function for unwinding past signal handlers.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/stack_chk_fail_local.c b/hurd/stack_chk_fail_local.c
new file mode 100644
index 0000000000..305871fbc0
--- /dev/null
+++ b/hurd/stack_chk_fail_local.c
@@ -0,0 +1 @@
+#include <debug/stack_chk_fail_local.c>
diff --git a/hurd/task2pid.c b/hurd/task2pid.c
index addbc39358..265cb88326 100644
--- a/hurd/task2pid.c
+++ b/hurd/task2pid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/thread-cancel.c b/hurd/thread-cancel.c
index 6cf5e752b7..c70b814dda 100644
--- a/hurd/thread-cancel.c
+++ b/hurd/thread-cancel.c
@@ -1,5 +1,5 @@
/* Thread cancellation support.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/thread-self.c b/hurd/thread-self.c
index d8785680ea..d6d96617f1 100644
--- a/hurd/thread-self.c
+++ b/hurd/thread-self.c
@@ -1,5 +1,5 @@
/* Cheap function to get current thread from sigstate without a syscall.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/trampoline.c b/hurd/trampoline.c
index b733b672e1..9bc278215a 100644
--- a/hurd/trampoline.c
+++ b/hurd/trampoline.c
@@ -1,5 +1,5 @@
/* Set thread_state for sighandler, and sigcontext to recover. Stub version.
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -28,7 +28,7 @@
struct sigcontext *
_hurd_setup_sighandler (int flags,
__sighandler_t handler,
- struct sigaltstack *sigaltstack,
+ stack_t *sigaltstack,
int signo, int sigcode,
void *state)
{
diff --git a/hurd/vpprintf.c b/hurd/vpprintf.c
index 9022604399..76cd31f922 100644
--- a/hurd/vpprintf.c
+++ b/hurd/vpprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/hurd/xattr.c b/hurd/xattr.c
index 5a694ab11f..23d9fcb691 100644
--- a/hurd/xattr.c
+++ b/hurd/xattr.c
@@ -1,5 +1,5 @@
/* Support for *xattr interfaces on GNU/Hurd.
- Copyright (C) 2006-2016 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -67,14 +67,14 @@ _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size)
if (value != NULL && *size < bufsz)
{
if (buf != value)
- munmap (buf, bufsz);
+ __munmap (buf, bufsz);
return -ERANGE;
}
if (buf != value && bufsz > 0)
{
if (value != NULL)
memcpy (value, buf, bufsz);
- munmap (buf, bufsz);
+ __munmap (buf, bufsz);
}
*size = bufsz;
return 0;
@@ -150,7 +150,7 @@ _hurd_xattr_set (io_t port, const char *name, const void *value, size_t size,
return err;
if (bufsz > 0)
{
- munmap (buf, bufsz);
+ __munmap (buf, bufsz);
return ENODATA;
}
}