summaryrefslogtreecommitdiff
path: root/hurd
diff options
context:
space:
mode:
Diffstat (limited to 'hurd')
-rw-r--r--hurd/Makefile14
-rw-r--r--hurd/Versions33
-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.h30
-rw-r--r--hurd/hurd/fd.h58
-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.h46
-rw-r--r--hurd/hurd/resource.h3
-rw-r--r--hurd/hurd/signal.h66
-rw-r--r--hurd/hurd/sigpreempt.h18
-rw-r--r--hurd/hurd/threadvar.h82
-rw-r--r--hurd/hurd/userlink.h28
-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.c71
-rw-r--r--hurd/hurdsock.c2
-rw-r--r--hurd/hurdsocket.h2
-rw-r--r--hurd/hurdstartup.c3
-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.c15
-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.c6
-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, 954 insertions, 350 deletions
diff --git a/hurd/Makefile b/hurd/Makefile
index 1e7d808ea8..a41737f497 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
@@ -21,10 +21,10 @@ include ../Makeconfig
headers = hurd.h $(interface-headers) \
$(addprefix hurd/,fd.h id.h port.h signal.h sigpreempt.h ioctl.h\
- userlink.h resource.h threadvar.h lookup.h)
+ userlink.h resource.h lookup.h)
inline-headers = hurd.h $(addprefix hurd/,fd.h signal.h \
- userlink.h threadvar.h port.h)
+ userlink.h port.h)
# The RPC interfaces go in a separate library.
interface-library := libhurduser
@@ -54,6 +54,7 @@ routines = hurdstartup hurdinit \
vpprintf \
ports-get ports-set hurdports hurdmsg \
errno-loc \
+ 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 \
@@ -78,10 +79,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 77f5b4271e..af6a0e45de 100644
--- a/hurd/Versions
+++ b/hurd/Versions
@@ -4,14 +4,8 @@ libc {
_end;
# variables used in macros & inline functions
- __hurd_sigthread_stack_base; __hurd_sigthread_stack_end;
- __hurd_sigthread_variables;
- __hurd_threadvar_max;
__hurd_threadvar_stack_mask; __hurd_threadvar_stack_offset;
- # functions used in macros & inline functions
- __hurd_errno_location;
-
# functions used in libmachuser and libhurduser
_S_catch_exception_raise;
_S_catch_exception_raise_state;
@@ -129,16 +123,37 @@ libc {
# functions used in macros & inline functions
__errno_location;
}
+ 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;
+ _hurd_port_locked_set;
+ __hurd_threadvar_location_from_sp;
+ __hurd_threadvar_location;
+ _hurd_userlink_link; _hurd_userlink_unlink; _hurd_userlink_clear;
+ }
HURD_CTHREADS_0.3 {
# weak refs to libthreads functions that libc calls iff libthreads in use
- cthread_fork; cthread_detach;
+ __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 b17e43750f..de4cb950e8 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 0cbe2e09ef..dc9bba8af1 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 ec0782797d..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,11 +41,16 @@
#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
#endif
+extern int __hurd_fail (error_t err);
+
+#ifdef __USE_EXTERN_INLINES
_HURD_H_EXTERN_INLINE int
__hurd_fail (error_t err)
{
@@ -54,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:
@@ -75,6 +80,7 @@ __hurd_fail (error_t err)
errno = err;
return -1;
}
+#endif
/* Basic ports and info, initialized by startup. */
@@ -141,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. */
@@ -241,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 54951024a4..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,6 +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. */
@@ -58,6 +61,10 @@ extern struct mutex _hurd_dtable_lock; /* Locks those two variables. */
NULL. The cell is unlocked; when ready to use it, lock it and check for
it being unused. */
+extern struct hurd_fd *_hurd_fd_get (int fd);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_FD_H_EXTERN_INLINE struct hurd_fd *
_hurd_fd_get (int fd)
{
@@ -90,6 +97,8 @@ _hurd_fd_get (int fd)
return descriptor;
}
+# endif
+#endif
/* Evaluate EXPR with the variable `descriptor' bound to a pointer to the
@@ -133,10 +142,14 @@ _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. */
+extern int _hurd_fd_error_signal (error_t err);
+
+#ifdef __USE_EXTERN_INLINES
_HURD_FD_H_EXTERN_INLINE int
_hurd_fd_error_signal (error_t err)
{
@@ -153,11 +166,15 @@ _hurd_fd_error_signal (error_t err)
return 0;
}
}
+#endif
/* Handle an error from an RPC on a file descriptor's port. You should
always use this function to handle errors from RPCs made on file
descriptor ports. Some errors are translated into signals. */
+extern error_t _hurd_fd_error (int fd, error_t err);
+
+#ifdef __USE_EXTERN_INLINES
_HURD_FD_H_EXTERN_INLINE error_t
_hurd_fd_error (int fd, error_t err)
{
@@ -165,25 +182,33 @@ _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;
}
+#endif
/* Handle error code ERR from an RPC on file descriptor FD's port.
Set `errno' to the appropriate error code, and always return -1. */
+extern int __hurd_dfail (int fd, error_t err);
+
+#ifdef __USE_EXTERN_INLINES
_HURD_FD_H_EXTERN_INLINE int
__hurd_dfail (int fd, error_t err)
{
errno = _hurd_fd_error (fd, err);
return -1;
}
+#endif
/* Likewise, but do not raise SIGPIPE on EPIPE if flags contain
MSG_NOSIGNAL. */
+extern int __hurd_sockfail (int fd, int flags, error_t err);
+
+#ifdef __USE_EXTERN_INLINES
_HURD_FD_H_EXTERN_INLINE int
__hurd_sockfail (int fd, int flags, error_t err)
{
@@ -192,6 +217,7 @@ __hurd_sockfail (int fd, int flags, error_t err)
errno = err;
return -1;
}
+#endif
/* Set up *FD to have PORT its server port, doing appropriate ctty magic.
Does no locking or unlocking. */
@@ -229,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,
@@ -254,6 +280,30 @@ extern int _hurd_select (int nfds, struct pollfd *pollfds,
const struct timespec *timeout,
const sigset_t *sigmask);
+/* Apply AT_FLAGS on FLAGS, in preparation for calling
+ __hurd_file_name_lookup. */
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
+_HURD_FD_H_EXTERN_INLINE error_t
+__hurd_at_flags (int *at_flags, int *flags)
+{
+ if ((*at_flags & AT_SYMLINK_FOLLOW) && (*at_flags & AT_SYMLINK_NOFOLLOW))
+ return EINVAL;
+
+ *flags |= (*at_flags & AT_SYMLINK_NOFOLLOW) ? O_NOLINK : 0;
+ *at_flags &= ~AT_SYMLINK_NOFOLLOW;
+ if (*at_flags & AT_SYMLINK_FOLLOW)
+ *flags &= ~O_NOLINK;
+ *at_flags &= ~AT_SYMLINK_FOLLOW;
+ if (*at_flags != 0)
+ return EINVAL;
+
+ return 0;
+}
+# endif
+#endif
+
/* Variant of file_name_lookup used in *at function implementations.
AT_FLAGS may only contain AT_SYMLINK_FOLLOW or AT_SYMLINK_NOFOLLOW,
which will remove and add O_NOLINK from FLAGS respectively.
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 4fea1aa4d2..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
@@ -60,6 +59,10 @@ struct hurd_port
/* Initialize *PORT to INIT. */
+extern void _hurd_port_init (struct hurd_port *port, mach_port_t init);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE void
_hurd_port_init (struct hurd_port *port, mach_port_t init)
{
@@ -67,6 +70,8 @@ _hurd_port_init (struct hurd_port *port, mach_port_t init)
port->users = NULL;
port->port = init;
}
+# endif
+#endif
/* Cleanup function for non-local exits. */
@@ -75,6 +80,12 @@ extern void _hurd_port_cleanup (void *, jmp_buf, int);
/* Get a reference to *PORT, which is locked.
Pass return value and LINK to _hurd_port_free when done. */
+extern mach_port_t
+_hurd_port_locked_get (struct hurd_port *port,
+ struct hurd_userlink *link);
+
+#if defined __USE_EXTERN_INLINES && defined _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)
@@ -90,9 +101,17 @@ _hurd_port_locked_get (struct hurd_port *port,
__spin_unlock (&port->lock);
return result;
}
+# endif
+#endif
/* Same, but locks PORT first. */
+extern mach_port_t
+_hurd_port_get (struct hurd_port *port,
+ struct hurd_userlink *link);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE mach_port_t
_hurd_port_get (struct hurd_port *port,
struct hurd_userlink *link)
@@ -104,10 +123,19 @@ _hurd_port_get (struct hurd_port *port,
HURD_CRITICAL_END;
return result;
}
+# endif
+#endif
/* Free a reference gotten with `USED_PORT = _hurd_port_get (PORT, LINK);' */
+extern void
+_hurd_port_free (struct hurd_port *port,
+ struct hurd_userlink *link,
+ mach_port_t used_port);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE void
_hurd_port_free (struct hurd_port *port,
struct hurd_userlink *link,
@@ -127,11 +155,17 @@ _hurd_port_free (struct hurd_port *port,
if (dealloc)
__mach_port_deallocate (__mach_task_self (), used_port);
}
+# endif
+#endif
/* Set *PORT's port to NEWPORT. NEWPORT's reference is consumed by PORT->port.
PORT->lock is locked. */
+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)
_HURD_PORT_H_EXTERN_INLINE void
_hurd_port_locked_set (struct hurd_port *port, mach_port_t newport)
{
@@ -142,9 +176,15 @@ _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
/* Same, but locks PORT first. */
+extern void _hurd_port_set (struct hurd_port *port, mach_port_t newport);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_PORT_H_EXTERN_INLINE void
_hurd_port_set (struct hurd_port *port, mach_port_t newport)
{
@@ -153,6 +193,8 @@ _hurd_port_set (struct hurd_port *port, mach_port_t newport)
_hurd_port_locked_set (port, newport);
HURD_CRITICAL_END;
}
+# endif
+#endif
#endif /* hurd/port.h */
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 14955c4242..335ead910e 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,13 +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>
-#include <hurd/threadvar.h> /* We cache sigstate in a threadvar. */
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. */
@@ -74,9 +78,9 @@ struct hurd_sigstate
semantics: if sa_handler is SIG_IGN instead of SIG_DFL, this thread
will receive global signals and use the process-wide action vector
instead of this one. */
- struct sigaction actions[NSIG];
+ struct sigaction actions[_NSIG];
- struct sigaltstack sigaltstack;
+ 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
@@ -85,7 +89,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. */
@@ -155,15 +159,17 @@ extern void _hurd_sigstate_delete (thread_t thread);
#define _HURD_SIGNAL_H_EXTERN_INLINE __extern_inline
#endif
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate *
_hurd_self_sigstate (void)
{
- struct hurd_sigstate **location = (struct hurd_sigstate **)
- (void *) __hurd_threadvar_location (_HURD_THREADVAR_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
/* Thread listening on our message port; also called the "signal thread". */
@@ -184,19 +190,29 @@ extern int _hurd_core_limit;
interrupted lest the signal handler try to take the same lock and
deadlock result. */
+extern void *_hurd_critical_section_lock (void);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_SIGNAL_H_EXTERN_INLINE void *
_hurd_critical_section_lock (void)
{
- struct hurd_sigstate **location = (struct hurd_sigstate **)
- (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE);
- struct hurd_sigstate *ss = *location;
+ struct hurd_sigstate *ss;
+
+#ifdef __LIBC_NO_TLS
+ if (__LIBC_NO_TLS ())
+ /* TLS is currently initializing, no need to enter critical section. */
+ return NULL;
+#endif
+
+ 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))
@@ -208,7 +224,13 @@ _hurd_critical_section_lock (void)
_hurd_critical_section_unlock to unlock it. */
return ss;
}
+# endif
+#endif
+extern void _hurd_critical_section_unlock (void *our_lock);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_SIGNAL_H_EXTERN_INLINE void
_hurd_critical_section_unlock (void *our_lock)
{
@@ -231,6 +253,8 @@ _hurd_critical_section_unlock (void *our_lock)
__msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
}
}
+# endif
+#endif
/* Convenient macros for simple uses of critical sections.
These two must be used as a pair at the same C scoping level. */
@@ -360,18 +384,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 b7b2a041ef..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
@@ -20,6 +20,7 @@
#define _HURD_THREADVAR_H
#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.
@@ -30,87 +31,24 @@
__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 case, __hurd_threadvar_stack_mask is zero, so the
- stack pointer is ignored; and __hurd_threadvar_stack_offset gives the
- address of a small allocated region which contains the variables for the
- single thread. */
+ 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;
-/* A special case must always be made for the signal thread. Even when there
- is only one user thread and an allocated region can be used for the user
- thread's variables, the signal thread needs to have its own location for
- per-thread variables. The variables __hurd_sigthread_stack_base and
+/* 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. */
extern unsigned long int __hurd_sigthread_stack_base;
extern unsigned long int __hurd_sigthread_stack_end;
-extern unsigned long int *__hurd_sigthread_variables;
+/* Store the MiG reply port reply port until we enable TLS. */
+extern mach_port_t __hurd_reply_port0;
-/* At the location described by the two variables above,
- there are __hurd_threadvar_max `unsigned long int's of per-thread data. */
-extern unsigned int __hurd_threadvar_max;
-
-/* These values are the indices for the standard per-thread variables. */
-enum __hurd_threadvar_index
- {
- _HURD_THREADVAR_MIG_REPLY, /* Reply port for MiG user stub functions. */
- _HURD_THREADVAR_ERRNO, /* `errno' value for this thread. */
- _HURD_THREADVAR_SIGSTATE, /* This thread's `struct hurd_sigstate'. */
- _HURD_THREADVAR_DYNAMIC_USER, /* Dynamically-assigned user variables. */
- _HURD_THREADVAR_MALLOC, /* For use of malloc. */
- _HURD_THREADVAR_DL_ERROR, /* For use of -ldl and dynamic linker. */
- _HURD_THREADVAR_RPC_VARS, /* For state of RPC functions. */
- _HURD_THREADVAR_LOCALE, /* For thread-local locale setting. */
- _HURD_THREADVAR_CTYPE_B, /* Cache of thread-local locale data. */
- _HURD_THREADVAR_CTYPE_TOLOWER, /* Cache of thread-local locale data. */
- _HURD_THREADVAR_CTYPE_TOUPPER, /* Cache of thread-local locale data. */
- _HURD_THREADVAR_MAX /* Default value for __hurd_threadvar_max. */
- };
-
-
-#ifndef _HURD_THREADVAR_H_EXTERN_INLINE
-#define _HURD_THREADVAR_H_EXTERN_INLINE __extern_inline
-#endif
-
-/* Return the location of the value for the per-thread variable with index
- INDEX used by the thread whose stack pointer is SP. */
-
-extern unsigned long int *__hurd_threadvar_location_from_sp
- (enum __hurd_threadvar_index __index, void *__sp);
-_HURD_THREADVAR_H_EXTERN_INLINE unsigned long int *
-__hurd_threadvar_location_from_sp (enum __hurd_threadvar_index __index,
- void *__sp)
-{
- unsigned long int __stack = (unsigned long int) __sp;
- return &((__stack >= __hurd_sigthread_stack_base &&
- __stack < __hurd_sigthread_stack_end)
- ? __hurd_sigthread_variables
- : (unsigned long int *) ((__stack & __hurd_threadvar_stack_mask) +
- __hurd_threadvar_stack_offset))[__index];
-}
-
-#include <machine-sp.h> /* Define __thread_stack_pointer. */
-
-/* Return the location of the current thread's value for the
- per-thread variable with index INDEX. */
-
-extern unsigned long int *
-__hurd_threadvar_location (enum __hurd_threadvar_index __index) __THROW
- /* This declaration tells the compiler that the value is constant
- given the same argument. We assume this won't be called twice from
- the same stack frame by different threads. */
- __attribute__ ((__const__));
-
-_HURD_THREADVAR_H_EXTERN_INLINE unsigned long int *
-__hurd_threadvar_location (enum __hurd_threadvar_index __index)
-{
- return __hurd_threadvar_location_from_sp (__index,
- __thread_stack_pointer ());
-}
-
+/* 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 275ce0cdd8..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>
@@ -76,6 +80,12 @@ struct hurd_userlink
/* Attach LINK to the chain of users at *CHAINP. */
+extern void
+_hurd_userlink_link (struct hurd_userlink **chainp,
+ struct hurd_userlink *link);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_USERLINK_H_EXTERN_INLINE void
_hurd_userlink_link (struct hurd_userlink **chainp,
struct hurd_userlink *link)
@@ -96,11 +106,17 @@ _hurd_userlink_link (struct hurd_userlink **chainp,
link->thread.prevp = thread_chainp;
*thread_chainp = link;
}
+# endif
+#endif
/* Detach LINK from its chain. Returns nonzero iff this was the
last user of the resource and it should be deallocated. */
+extern int _hurd_userlink_unlink (struct hurd_userlink *link);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_USERLINK_H_EXTERN_INLINE int
_hurd_userlink_unlink (struct hurd_userlink *link)
{
@@ -123,6 +139,8 @@ _hurd_userlink_unlink (struct hurd_userlink *link)
return dealloc;
}
+# endif
+#endif
/* Clear all users from *CHAINP. Call this when the resource *CHAINP
@@ -131,6 +149,10 @@ _hurd_userlink_unlink (struct hurd_userlink *link)
value is zero, someone is still using the resource and they will
deallocate it when they are finished. */
+extern int _hurd_userlink_clear (struct hurd_userlink **chainp);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# if IS_IN (libc)
_HURD_USERLINK_H_EXTERN_INLINE int
_hurd_userlink_clear (struct hurd_userlink **chainp)
{
@@ -143,5 +165,7 @@ _hurd_userlink_clear (struct hurd_userlink **chainp)
*chainp = NULL;
return 0;
}
+# 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 c68034f98b..12ba819259 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;
@@ -217,7 +236,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;
@@ -361,13 +380,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. */
@@ -402,3 +436,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 9016227fc9..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,6 +204,7 @@ _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 5204a82c2a..0a73b54574 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
@@ -328,7 +328,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 5c6425a057..88158d920c 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,8 +20,10 @@
#include <string.h>
#include <cthreads.h> /* For `struct mutex'. */
+#include <pthreadP.h>
#include <mach.h>
#include <mach/thread_switch.h>
+#include <mach/mig_support.h>
#include <hurd.h>
#include <hurd/id.h>
@@ -31,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;
@@ -45,7 +49,6 @@ thread_t _hurd_msgport_thread;
/* These are set up by _hurdsig_init. */
unsigned long int __hurd_sigthread_stack_base;
unsigned long int __hurd_sigthread_stack_end;
-unsigned long int *__hurd_sigthread_variables;
/* Linked-list of per-thread signal state. */
struct hurd_sigstate *_hurd_sigstates;
@@ -123,6 +126,7 @@ _hurd_thread_sigstate (thread_t thread)
__mutex_unlock (&_hurd_siglock);
return ss;
}
+libc_hidden_def (_hurd_thread_sigstate)
/* Destroy a sigstate structure. Called by libpthread just before the
* corresponding thread is terminated (the kernel thread port must remain valid
@@ -217,7 +221,6 @@ _hurd_sigstate_actions (struct hurd_sigstate *ss)
else
return ss->actions;
}
-
/* Signal delivery itself is on this page. */
@@ -334,18 +337,24 @@ abort_thread (struct hurd_sigstate *ss, struct machine_thread_all_state *state,
that this location can be set without faulting, or else return NULL. */
static mach_port_t *
-interrupted_reply_port_location (struct machine_thread_all_state *thread_state,
+interrupted_reply_port_location (thread_t thread,
+ struct machine_thread_all_state *thread_state,
int sigthread)
{
- mach_port_t *portloc = (mach_port_t *) __hurd_threadvar_location_from_sp
- (_HURD_THREADVAR_MIG_REPLY, (void *) thread_state->basic.SP);
+ mach_port_t *portloc = &THREAD_TCB(thread, thread_state)->reply_port;
if (sigthread && _hurdsig_catch_memory_fault (portloc))
- /* Faulted trying to read the stack. */
+ /* 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 ();
@@ -423,7 +432,8 @@ _hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread,
our nonzero return tells the trampoline code to finish the message
receive operation before running the handler. */
- mach_port_t *reply = interrupted_reply_port_location (state,
+ mach_port_t *reply = interrupted_reply_port_location (ss->thread,
+ state,
sigthread);
error_t err = __interrupt_operation (intr_port, _hurdsig_interrupt_timeout);
@@ -982,7 +992,8 @@ post_signal (struct hurd_sigstate *ss,
if (! machine_get_basic_state (ss->thread, &thread_state))
goto sigbomb;
- loc = interrupted_reply_port_location (&thread_state, 1);
+ loc = interrupted_reply_port_location (ss->thread,
+ &thread_state, 1);
if (loc && *loc != MACH_PORT_NULL)
/* This is the reply port for the context which called
sigreturn. Since we are abandoning that context entirely
@@ -1048,7 +1059,8 @@ post_signal (struct hurd_sigstate *ss,
{
/* Fetch the thread variable for the MiG reply port,
and set it to MACH_PORT_NULL. */
- mach_port_t *loc = interrupted_reply_port_location (&thread_state,
+ mach_port_t *loc = interrupted_reply_port_location (ss->thread,
+ &thread_state,
1);
if (loc)
{
@@ -1454,7 +1466,8 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
/* Start the signal thread listening on the message port. */
- if (__hurd_threadvar_stack_mask == 0)
+#pragma weak __cthread_fork
+ if (!__cthread_fork)
{
err = __thread_create (__mach_task_self (), &_hurd_msgport_thread);
assert_perror (err);
@@ -1465,16 +1478,10 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
(vm_address_t *) &__hurd_sigthread_stack_base,
&stacksize);
assert_perror (err);
+ err = __mach_setup_tls (_hurd_msgport_thread);
+ assert_perror (err);
__hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize;
- __hurd_sigthread_variables =
- malloc (__hurd_threadvar_max * sizeof (unsigned long int));
- if (__hurd_sigthread_variables == NULL)
- __libc_fatal ("hurd: Can't allocate threadvars for signal thread\n");
- memset (__hurd_sigthread_variables, 0,
- __hurd_threadvar_max * sizeof (unsigned long int));
- __hurd_sigthread_variables[_HURD_THREADVAR_LOCALE]
- = (unsigned long int) &_nl_global_locale;
/* Reinitialize the MiG support routines so they will use a per-thread
variable for the cached reply port. */
@@ -1494,9 +1501,25 @@ _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. */
-#pragma weak cthread_fork
-#pragma weak cthread_detach
- cthread_detach (cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, 0));
+#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 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);
+ __hurd_sigthread_stack_base = (uintptr_t) addr;
+ __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + size;
+ }
/* XXX We need the thread port for the signal thread further on
in this thread (see hurdfault.c:_hurdsigfault_init).
@@ -1549,14 +1572,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 9de8f2a898..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
@@ -23,7 +23,6 @@
#include <hurd.h>
#include <hurd/exec_startup.h>
#include <sysdep.h>
-#include <hurd/threadvar.h>
#include <unistd.h>
#include <elf.h>
#include <set-hooks.h>
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 3528ba8ac3..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
@@ -29,16 +29,9 @@ __file_name_lookup_at (int fd, int at_flags,
error_t err;
file_t result;
- if ((at_flags & AT_SYMLINK_FOLLOW) && (at_flags & AT_SYMLINK_NOFOLLOW))
- return (__hurd_fail (EINVAL), MACH_PORT_NULL);
-
- flags |= (at_flags & AT_SYMLINK_NOFOLLOW) ? O_NOLINK : 0;
- at_flags &= ~AT_SYMLINK_NOFOLLOW;
- if (at_flags & AT_SYMLINK_FOLLOW)
- flags &= ~O_NOLINK;
- at_flags &= ~AT_SYMLINK_FOLLOW;
- if (at_flags != 0)
- return (__hurd_fail (EINVAL), MACH_PORT_NULL);
+ err = __hurd_at_flags (&at_flags, &flags);
+ if (err)
+ return (__hurd_fail (err), MACH_PORT_NULL);
if (fd == AT_FDCWD || file_name[0] == '/')
return __file_name_lookup (file_name, flags, mode);
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 1f224621bb..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
@@ -18,6 +18,7 @@
#include <hurd.h>
#include <thread_state.h>
+#include <hurd/threadvar.h>
#include <jmpbuf-unwind.h>
#include <assert.h>
#include <stdint.h>
@@ -38,8 +39,7 @@ _hurdsig_longjmp_from_handler (void *data, jmp_buf env, int val)
{
/* Destroy the MiG reply port used by the signal handler, and restore
the reply port in use by the thread when interrupted. */
- mach_port_t *reply_port =
- (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY);
+ mach_port_t *reply_port = &__hurd_local_reply_port;
if (*reply_port)
{
mach_port_t port = *reply_port;
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;
}
}