summaryrefslogtreecommitdiff
path: root/mach
diff options
context:
space:
mode:
Diffstat (limited to 'mach')
-rw-r--r--mach/Machrules9
-rw-r--r--mach/Makefile31
-rw-r--r--mach/Versions3
-rw-r--r--mach/devstream.c15
-rw-r--r--mach/errstring.c7
-rw-r--r--mach/lock-intern.h91
-rw-r--r--mach/lowlevellock.h81
-rw-r--r--mach/mach.h11
-rw-r--r--mach/mach/mach_traps.h19
-rw-r--r--mach/mach/mig_support.h18
-rw-r--r--mach/mach_error.c4
-rw-r--r--mach/mach_init.c2
-rw-r--r--mach/mach_init.h2
-rw-r--r--mach/mig-alloc.c2
-rw-r--r--mach/mig-dealloc.c2
-rw-r--r--mach/mig-reply.c2
-rw-r--r--mach/msg-destroy.c1
-rw-r--r--mach/msg.c2
-rw-r--r--mach/msgserver.c2
-rw-r--r--mach/mutex-init.c10
-rw-r--r--mach/mutex-solid.c2
-rw-r--r--mach/setup-thread.c32
-rw-r--r--mach/shortcut.awk2
-rw-r--r--mach/spin-lock.c8
-rw-r--r--mach/spin-lock.h2
-rw-r--r--mach/spin-solid.c3
-rw-r--r--mach/stack_chk_fail_local.c1
27 files changed, 262 insertions, 102 deletions
diff --git a/mach/Machrules b/mach/Machrules
index acea1289b2..65411f493a 100644
--- a/mach/Machrules
+++ b/mach/Machrules
@@ -1,5 +1,5 @@
# Rules for MiG interfaces that want to go into the C library.
-# 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
@@ -29,6 +29,7 @@
# _S_rpcname.
# Includers can also add to or modify `migdefines' to set MiG flags.
+# They can also set `migheaderpipe' to mangle the MiG header output.
all:
@@ -51,7 +52,7 @@ $(objpfx)dummy.mk:
$(make-target-directory)
echo '# Empty' > $@
-MIGFLAGS = -DMACH_IPC_COMPAT=0 -DSTANDALONE -DTypeCheck=0 \
+MIGFLAGS = -DSTANDALONE -DTypeCheck=0 \
$(+includes) $(migdefines) -subrprefix __
# Putting CC in the enivronment makes the mig wrapper script
# use the same compiler setup we are using to run cpp.
@@ -176,7 +177,7 @@ $(patsubst %,$(objpfx)%.h,$(user-interfaces)): $(objpfx)%.h: $(objpfx)%.__h \
$(objpfx)%.uh
# The last line of foo.__h is "#endif _foo_user_".
# The first two lines of foo.uh are "#ifndef _foo_user_"/"#define _foo_user_".
- (sed -e '$$d' $<; sed -e '1,2d' $(word 2,$^)) > $@-new
+ (sed -e '$$d' $<; sed -e '1,2d' $(word 2,$^)) $(migheaderpipe) > $@-new
mv -f $@-new $@
interface-routines := $(foreach if,$(user-interfaces), \
@@ -221,7 +222,7 @@ endif
ifdef interface-library
-$(interface-library)-routines = $(interface-routines)
+$(interface-library)-routines = $(interface-routines) stack_chk_fail_local
extra-libs += $(interface-library)
extra-libs-others += $(interface-library)
diff --git a/mach/Makefile b/mach/Makefile
index 2a695a5f3a..435ae6882d 100644
--- a/mach/Makefile
+++ b/mach/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,9 +21,9 @@ include ../Makeconfig
headers = mach_init.h mach.h mach_error.h mach-shortcuts.h mach/mach_traps.h \
$(interface-headers) mach/mach.h mach/mig_support.h mach/error.h \
- $(lock-headers) machine-sp.h
+ $(lock-headers) machine-sp.h bits/mach/param.h
lock = spin-solid spin-lock mutex-init mutex-solid
-lock-headers = lock-intern.h machine-lock.h spin-lock.h
+lock-headers = lock-intern.h spin-lock.h
routines = $(mach-syscalls) $(mach-shortcuts) \
mach_init mig_strncpy msg \
mig-alloc mig-dealloc mig-reply \
@@ -53,6 +53,15 @@ server-interfaces := mach/exc
# Clear any environment value.
generated =
+
+# Avoid ssp before TLS is initialized.
+CFLAGS-mach_init.o = $(no-stack-protector)
+CFLAGS-RPC_vm_statistics.o = $(no-stack-protector)
+CFLAGS-RPC_vm_map.o = $(no-stack-protector)
+CFLAGS-RPC_vm_protect.o = $(no-stack-protector)
+CFLAGS-RPC_i386_set_gdt.o = $(no-stack-protector)
+CFLAGS-RPC_i386_set_ldt.o = $(no-stack-protector)
+CFLAGS-RPC_task_get_special_port.o = $(no-stack-protector)
# Translate GNU names for CPUs into the names used in Mach header files.
mach-machine = $(patsubst powerpc,ppc,$(base-machine))
@@ -61,7 +70,7 @@ mach-machine = $(patsubst powerpc,ppc,$(base-machine))
ifndef inhibit_mach_syscalls
-include $(objpfx)mach-syscalls.mk
endif
-$(objpfx)mach-syscalls.mk: syscalls.awk Makefile
+$(objpfx)mach-syscalls.mk: syscalls.awk Makefile libc-modules.h
# Go kludges!!!
$(make-target-directory)
# We must use $(CFLAGS) to get -O flags that affect #if's in header files.
@@ -88,7 +97,8 @@ else
$(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
(echo '#include <sysdep.h>'; \
echo 'kernel_trap (__$*,$(sysno-$*),$(nargs-$*))'; \
- echo 'weak_alias (__$*, $*)') > $@-new
+ echo 'weak_alias (__$*, $*)'; \
+ echo 'libc_hidden_def (__$*)') > $@-new
mv -f $@-new $@
generated += $(mach-syscalls:=.S)
endif # mach-syscalls
@@ -107,7 +117,7 @@ ifndef mach-shortcuts
# $(mach-shortcuts) will be set, and that will change how
# mach_interface.defs is processed: it will get the -D flags below.
user-interfaces := $(filter-out $(mach-interface-list:%=mach/%) \
- mach/mach_port mach/mach_host mach/mach4 \
+ mach/mach_port mach/mach_host mach/mach4 mach/gnumach \
device/device_request,\
$(user-interfaces))
endif
@@ -137,9 +147,12 @@ $(objpfx)mach-shortcuts.h: $(mach-interface-list:%=$(objpfx)mach/%.h) \
# The first line gets us one paragraph per line, with @s separating real lines.
# The second line selects paragraphs for the shortcutted functions.
# The third line removes `_rpc' from the names and reconstitutes the lines.
- cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
- | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
- | sed 's/_rpc//g' | tr @ \\012 > $@-new
+ ( echo "#include <mach/mach_types.h>" ; \
+ echo "#include <mach/message.h>" ; \
+ echo ; \
+ cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
+ | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
+ | sed 's/_rpc//g' | tr @ \\012 ) > $@-new
mv -f $@-new $@
generated += mach-shortcuts.h
diff --git a/mach/Versions b/mach/Versions
index 0097aad59b..c7a3d60bae 100644
--- a/mach/Versions
+++ b/mach/Versions
@@ -32,6 +32,7 @@ libc {
mach_port_allocate; mach_port_allocate_name; mach_port_deallocate;
mach_port_insert_right; mach_reply_port;
mach_setup_thread;
+ mach_setup_tls;
mach_task_self;
mach_thread_self;
mig_allocate; mig_dealloc_reply_port; mig_deallocate;
@@ -54,7 +55,7 @@ libc {
# This was always there, but not exported as it should have been.
mig_strncpy;
}
- GLIBC_2.23 {
+ GLIBC_2.21 {
__mach_host_self_;
}
diff --git a/mach/devstream.c b/mach/devstream.c
index ba1c01b4e0..505b6573ae 100644
--- a/mach/devstream.c
+++ b/mach/devstream.c
@@ -1,6 +1,6 @@
/* stdio on a Mach device port.
Translates \n to \r\n on output, echos and translates \r to \n on input.
- 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
@@ -22,6 +22,7 @@
#include <device/device.h>
#include <errno.h>
#include <string.h>
+#include <libioP.h>
static ssize_t
@@ -111,7 +112,7 @@ devstream_read (void *cookie, char *buffer, size_t to_read)
static int
dealloc_ref (void *cookie)
{
- if (mach_port_deallocate (mach_task_self (), (mach_port_t) cookie))
+ if (__mach_port_deallocate (mach_task_self (), (mach_port_t) cookie))
{
errno = EINVAL;
return -1;
@@ -130,13 +131,13 @@ mach_open_devstream (mach_port_t dev, const char *mode)
return NULL;
}
- stream = fopencookie ((void *) dev, mode,
- (cookie_io_functions_t) { write: devstream_write,
- read: devstream_read,
- close: dealloc_ref });
+ stream = _IO_fopencookie ((void *) dev, mode,
+ (cookie_io_functions_t) { write: devstream_write,
+ read: devstream_read,
+ close: dealloc_ref });
if (stream == NULL)
{
- mach_port_deallocate (mach_task_self (), dev);
+ __mach_port_deallocate (mach_task_self (), dev);
return NULL;
}
diff --git a/mach/errstring.c b/mach/errstring.c
index 52cf1eb46e..3e665e6f7a 100644
--- a/mach/errstring.c
+++ b/mach/errstring.c
@@ -46,8 +46,7 @@
extern void __mach_error_map_compat (mach_error_t *);
const char *
-mach_error_type( err )
- mach_error_t err;
+mach_error_type(mach_error_t err)
{
int sub, system;
@@ -60,6 +59,7 @@ mach_error_type( err )
|| sub >= errors[system].max_sub ) return( "(?/?)" );
return( errors[system].subsystem[sub].subsys_name );
}
+libc_hidden_def (mach_error_type)
boolean_t mach_error_full_diag = FALSE;
@@ -86,8 +86,7 @@ mach_error_string_int(mach_error_t err,
}
const char *
-mach_error_string( err )
- mach_error_t err;
+mach_error_string(mach_error_t err)
{
boolean_t diag;
diff --git a/mach/lock-intern.h b/mach/lock-intern.h
index 426628b9c2..ed8acb6aec 100644
--- a/mach/lock-intern.h
+++ b/mach/lock-intern.h
@@ -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
@@ -19,20 +19,31 @@
#define _LOCK_INTERN_H
#include <sys/cdefs.h>
-#include <machine-lock.h>
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+# include <lowlevellock.h>
+#endif
#ifndef _EXTERN_INLINE
#define _EXTERN_INLINE __extern_inline
#endif
+/* The type of a spin lock variable. */
+typedef unsigned int __spin_lock_t;
+
+/* Static initializer for spinlocks. */
+#define __SPIN_LOCK_INITIALIZER LLL_INITIALIZER
/* Initialize LOCK. */
+extern void __spin_lock_init (__spin_lock_t *__lock);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
_EXTERN_INLINE void
__spin_lock_init (__spin_lock_t *__lock)
{
*__lock = __SPIN_LOCK_INITIALIZER;
}
+#endif
/* Lock LOCK, blocking if we can't get it. */
@@ -40,57 +51,87 @@ extern void __spin_lock_solid (__spin_lock_t *__lock);
/* Lock the spin lock LOCK. */
+extern void __spin_lock (__spin_lock_t *__lock);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
_EXTERN_INLINE void
__spin_lock (__spin_lock_t *__lock)
{
- if (! __spin_try_lock (__lock))
- __spin_lock_solid (__lock);
+ lll_lock (__lock, 0);
}
-
-/* Name space-clean internal interface to mutex locks.
+#endif
- Code internal to the C library uses these functions to lock and unlock
- mutex locks. These locks are of type `struct mutex', defined in
- <cthreads.h>. The functions here are name space-clean. If the program
- is linked with the cthreads library, `__mutex_lock_solid' and
- `__mutex_unlock_solid' will invoke the corresponding cthreads functions
- to implement real mutex locks. If not, simple stub versions just use
- spin locks. */
+/* Unlock LOCK. */
+extern void __spin_unlock (__spin_lock_t *__lock);
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+ lll_unlock (__lock, 0);
+}
+#endif
-/* Initialize the newly allocated mutex lock LOCK for further use. */
-extern void __mutex_init (void *__lock);
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
+extern int __spin_try_lock (__spin_lock_t *__lock);
-/* Lock LOCK, blocking if we can't get it. */
-extern void __mutex_lock_solid (void *__lock);
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+_EXTERN_INLINE int
+__spin_try_lock (__spin_lock_t *__lock)
+{
+ return (lll_trylock (__lock) == 0);
+}
+#endif
+
+/* Return nonzero if LOCK is locked. */
+extern int __spin_lock_locked (__spin_lock_t *__lock);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ return (*(volatile __spin_lock_t *)__lock != 0);
+}
+#endif
+
+/* Name space-clean internal interface to mutex locks. */
-/* Finish unlocking LOCK, after the spin lock LOCK->held has already been
- unlocked. This function will wake up any thread waiting on LOCK. */
-extern void __mutex_unlock_solid (void *__lock);
+/* Initialize the newly allocated mutex lock LOCK for further use. */
+extern void __mutex_init (void *__lock);
/* Lock the mutex lock LOCK. */
+extern void __mutex_lock (void *__lock);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
_EXTERN_INLINE void
__mutex_lock (void *__lock)
{
- if (! __spin_try_lock ((__spin_lock_t *) __lock))
- __mutex_lock_solid (__lock);
+ __spin_lock ((__spin_lock_t *)__lock);
}
+#endif
/* Unlock the mutex lock LOCK. */
+extern void __mutex_unlock (void *__lock);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
_EXTERN_INLINE void
__mutex_unlock (void *__lock)
{
- __spin_unlock ((__spin_lock_t *) __lock);
- __mutex_unlock_solid (__lock);
+ __spin_unlock ((__spin_lock_t *)__lock);
}
+#endif
+extern int __mutex_trylock (void *__lock);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
_EXTERN_INLINE int
__mutex_trylock (void *__lock)
{
- return __spin_try_lock ((__spin_lock_t *) __lock);
+ return (__spin_try_lock ((__spin_lock_t *)__lock));
}
+#endif
#endif /* lock-intern.h */
diff --git a/mach/lowlevellock.h b/mach/lowlevellock.h
new file mode 100644
index 0000000000..8635b9db53
--- /dev/null
+++ b/mach/lowlevellock.h
@@ -0,0 +1,81 @@
+/* Low-level lock implementation. Mach gsync-based version.
+ 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
+ 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 _MACH_LOWLEVELLOCK_H
+#define _MACH_LOWLEVELLOCK_H 1
+
+#include <mach/gnumach.h>
+#include <atomic.h>
+
+/* Gsync flags. */
+#ifndef GSYNC_SHARED
+# define GSYNC_SHARED 0x01
+# define GSYNC_QUAD 0x02
+# define GSYNC_TIMED 0x04
+# define GSYNC_BROADCAST 0x08
+# define GSYNC_MUTATE 0x10
+#endif
+
+/* Static initializer for low-level locks. */
+#define LLL_INITIALIZER 0
+
+/* Wait on address PTR, without blocking if its contents
+ * are different from VAL. */
+#define lll_wait(ptr, val, flags) \
+ __gsync_wait (__mach_task_self (), \
+ (vm_offset_t)(ptr), (val), 0, 0, (flags))
+
+/* Wake one or more threads waiting on address PTR. */
+#define lll_wake(ptr, flags) \
+ __gsync_wake (__mach_task_self (), (vm_offset_t)(ptr), 0, (flags))
+
+/* Acquire the lock at PTR. */
+#define lll_lock(ptr, flags) \
+ ({ \
+ int *__iptr = (int *)(ptr); \
+ int __flags = (flags); \
+ if (*__iptr != 0 || \
+ atomic_compare_and_exchange_bool_acq (__iptr, 1, 0) != 0) \
+ while (1) \
+ { \
+ if (atomic_exchange_acq (__iptr, 2) == 0) \
+ break; \
+ lll_wait (__iptr, 2, __flags); \
+ } \
+ (void)0; \
+ })
+
+/* Try to acquire the lock at PTR, without blocking.
+ Evaluates to zero on success. */
+#define lll_trylock(ptr) \
+ ({ \
+ int *__iptr = (int *)(ptr); \
+ *__iptr == 0 && \
+ atomic_compare_and_exchange_bool_acq (__iptr, 1, 0) == 0 ? 0 : -1; \
+ })
+
+/* Release the lock at PTR. */
+#define lll_unlock(ptr, flags) \
+ ({ \
+ int *__iptr = (int *)(ptr); \
+ if (atomic_exchange_rel (__iptr, 0) == 2) \
+ lll_wake (__iptr, (flags)); \
+ (void)0; \
+ })
+
+#endif
diff --git a/mach/mach.h b/mach/mach.h
index c7e7c8ca9b..93398b0da5 100644
--- a/mach/mach.h
+++ b/mach/mach.h
@@ -1,5 +1,5 @@
/* Standard header for all Mach programs.
- 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,8 @@
#define _MACH_H 1
-/* We must include this before using __need_FILE with <stdio.h> below. */
#include <features.h>
-
/* Get the basic types used by Mach. */
#include <mach/mach_types.h>
@@ -79,9 +77,7 @@ extern void
__mach_msg_destroy (mach_msg_header_t *msg),
mach_msg_destroy (mach_msg_header_t *msg);
-
-#define __need_FILE
-#include <stdio.h>
+#include <bits/types/FILE.h>
/* Open a stream on a Mach device. */
extern FILE *mach_open_devstream (mach_port_t device_port, const char *mode);
@@ -100,5 +96,8 @@ kern_return_t mach_setup_thread (task_t task, thread_t thread, void *pc,
vm_address_t *stack_base,
vm_size_t *stack_size);
+/* Give THREAD a TLS area. */
+kern_return_t __mach_setup_tls (thread_t thread);
+kern_return_t mach_setup_tls (thread_t thread);
#endif /* mach.h */
diff --git a/mach/mach/mach_traps.h b/mach/mach/mach_traps.h
index 10dd3703f2..b87ea9e745 100644
--- a/mach/mach/mach_traps.h
+++ b/mach/mach/mach_traps.h
@@ -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,8 +17,7 @@
/* Declare the few Mach system calls (except mach_msg, in <mach/message.h>).
This does not include the kernel RPC shortcut calls (in <mach-shortcuts.h>).
-
- This file omits the MACH_IPC_COMPAT functions. */
+ */
#ifndef _MACH_MACH_TRAPS_H
@@ -30,33 +29,27 @@
/* Create and return a new receive right. */
extern mach_port_t mach_reply_port (void);
-extern mach_port_t __mach_reply_port (void);
/* Return the thread control port for the calling thread. */
extern mach_port_t mach_thread_self (void);
-extern mach_port_t __mach_thread_self (void);
/* Return the task control port for the calling task.
The parens are needed to protect against the macro in <mach_init.h>. */
extern mach_port_t (mach_task_self) (void);
-extern mach_port_t (__mach_task_self) (void);
/* Return the host information port for the host of the calling task.
The parens are needed to protect against the macro in <mach_init.h>. */
extern mach_port_t (mach_host_self) (void);
-extern mach_port_t (__mach_host_self) (void);
/* Attempt to context switch the current thread off the processor. Returns
true if there are other threads that can be run and false if not. */
extern boolean_t swtch (void);
-extern boolean_t __swtch (void);
/* Attempt to context switch the current thread off the processor. Lower
the thread's priority as much as possible. The thread's priority will
be restored when it runs again. PRIORITY is currently unused. Return
true if there are other threads that can be run and false if not. */
extern boolean_t swtch_pri (int priority);
-extern boolean_t __swtch_pri (int priority);
/* Attempt to context switch the current thread off the processor. Try
to run NEW_THREAD next, ignoring normal scheduling policies. The
@@ -67,13 +60,15 @@ extern boolean_t __swtch_pri (int priority);
swtch_pri. If OPTION is SWITCH_OPTION_NONE, ignore TIME. */
kern_return_t thread_switch (mach_port_t new_thread,
int option, mach_msg_timeout_t option_time);
-kern_return_t __thread_switch (mach_port_t new_thread,
- int option, mach_msg_timeout_t option_time);
/* Block the current thread until the kernel (or device) event
identified by EVENT occurs. */
kern_return_t evc_wait (unsigned int event);
-kern_return_t __evc_wait (unsigned int event);
+/* Display a null-terminated character string on the Mach console. This
+ system call is meant as a debugging tool useful to circumvent messaging
+ altogether. */
+
+extern void mach_print(const char *s);
#endif /* mach/mach_traps.h */
diff --git a/mach/mach/mig_support.h b/mach/mach/mig_support.h
index b83b1d0b5c..fc17062b6a 100644
--- a/mach/mach/mig_support.h
+++ b/mach/mach/mig_support.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
@@ -26,19 +26,6 @@
#include <sys/types.h>
#include <string.h>
-#ifndef __USE_GNU
-/* The only problem that has come up so far is __stpncpy being undeclared
- below because <string.h> doesn't declare it without __USE_GNU. We could
- work around that problem by just adding the declaration there, or by
- eliding the inline functions in the absence of __USE_GNU. But either of
- these would result in unoptimized calls (because no inline version of
- __stpncpy will have been defined), and there may be other niggling
- problems lurking. Instead we simply insist on _GNU_SOURCE for
- compiling mig output; anyway, that better reflects the fact that mig
- output requires nonstandard special support code not found elsewhere. */
-# error mig stubs must be compiled with -D_GNU_SOURCE
-#endif
-
/* MiG initialization. */
extern void __mig_init (void *__first);
extern void mig_init (void *__first);
@@ -66,6 +53,8 @@ extern void mig_reply_setup (const mach_msg_header_t *__request,
/* Idiocy support function. */
extern vm_size_t mig_strncpy (char *__dst, const char *__src, vm_size_t __len);
extern vm_size_t __mig_strncpy (char *__dst, const char *__src, vm_size_t);
+
+#if defined __USE_EXTERN_INLINES && defined _LIBC
__extern_inline vm_size_t
__mig_strncpy (char *__dst, const char *__src, vm_size_t __len)
{
@@ -76,6 +65,7 @@ mig_strncpy (char *__dst, const char *__src, vm_size_t __len)
{
return __mig_strncpy (__dst, __src, __len);
}
+#endif
diff --git a/mach/mach_error.c b/mach/mach_error.c
index 8bbb2ec74e..0d3082d021 100644
--- a/mach/mach_error.c
+++ b/mach/mach_error.c
@@ -63,9 +63,7 @@
extern char * mach_error_string_int(mach_error_t, boolean_t *);
void
-mach_error( str, err )
- char *str;
- mach_error_t err;
+mach_error(char *str, mach_error_t err)
{
char * err_str;
char buf[1024];
diff --git a/mach/mach_init.c b/mach/mach_init.c
index 941cb8670a..7a5ed9b829 100644
--- a/mach/mach_init.c
+++ b/mach/mach_init.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/mach/mach_init.h b/mach/mach_init.h
index 3cced775b4..160ea21600 100644
--- a/mach/mach_init.h
+++ b/mach/mach_init.h
@@ -1,5 +1,5 @@
/* Declarations and macros for the basic Mach things set at startup.
- 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/mach/mig-alloc.c b/mach/mig-alloc.c
index cd76b40879..d8eef70a96 100644
--- a/mach/mig-alloc.c
+++ b/mach/mig-alloc.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/mach/mig-dealloc.c b/mach/mig-dealloc.c
index b75480ae26..0b2138210e 100644
--- a/mach/mig-dealloc.c
+++ b/mach/mig-dealloc.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/mach/mig-reply.c b/mach/mig-reply.c
index b817bc4745..145d0e9cac 100644
--- a/mach/mig-reply.c
+++ b/mach/mig-reply.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/mach/msg-destroy.c b/mach/msg-destroy.c
index bc7dd558e9..7429ecbc2d 100644
--- a/mach/msg-destroy.c
+++ b/mach/msg-destroy.c
@@ -189,6 +189,7 @@ __mach_msg_destroy (mach_msg_header_t *msg)
}
weak_alias (__mach_msg_destroy, mach_msg_destroy)
+libc_hidden_def (__mach_msg_destroy)
static void
mach_msg_destroy_port (mach_port_t port, mach_msg_type_name_t type)
diff --git a/mach/msg.c b/mach/msg.c
index bccad7fd26..8eb252a16e 100644
--- a/mach/msg.c
+++ b/mach/msg.c
@@ -25,6 +25,7 @@
*/
#include <mach/port.h>
#include <mach/message.h>
+#include <mach.h>
#ifdef MACH_MSG_OVERWRITE
/* In variants with this feature, the actual system call is
@@ -125,6 +126,7 @@ __mach_msg (mach_msg_header_t *msg,
return ret;
}
weak_alias (__mach_msg, mach_msg)
+libc_hidden_def (__mach_msg)
mach_msg_return_t
__mach_msg_send (mach_msg_header_t *msg)
diff --git a/mach/msgserver.c b/mach/msgserver.c
index 87c3c06d37..58da00722f 100644
--- a/mach/msgserver.c
+++ b/mach/msgserver.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/mach/mutex-init.c b/mach/mutex-init.c
index 16bf34f67c..a8f238c722 100644
--- a/mach/mutex-init.c
+++ b/mach/mutex-init.c
@@ -1,5 +1,5 @@
/* Initialize a cthreads mutex structure.
- 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
@@ -17,13 +17,11 @@
<http://www.gnu.org/licenses/>. */
#include <lock-intern.h>
-#include <cthreads.h>
+#include <lowlevellock.h>
void
__mutex_init (void *lock)
{
- /* This happens to be name space-safe because it is a macro.
- It invokes only spin_lock_init, which is a macro for __spin_lock_init;
- and cthread_queue_init, which is a macro for some simple code. */
- mutex_init ((struct mutex *) lock);
+ *(int *)lock = LLL_INITIALIZER;
}
+libc_hidden_def (__mutex_init)
diff --git a/mach/mutex-solid.c b/mach/mutex-solid.c
index 5107c4cc3e..1493ad7d8b 100644
--- a/mach/mutex-solid.c
+++ b/mach/mutex-solid.c
@@ -1,5 +1,5 @@
/* Stub versions of mutex_lock_solid/mutex_unlock_solid for no -lthreads.
- 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/mach/setup-thread.c b/mach/setup-thread.c
index 6100a20493..ce60a7302a 100644
--- a/mach/setup-thread.c
+++ b/mach/setup-thread.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
@@ -19,6 +19,7 @@
#include <thread_state.h>
#include <string.h>
#include <mach/machine/vm_param.h>
+#include <ldsodefs.h>
#include "sysdep.h" /* Defines stack direction. */
#define STACK_SIZE (16 * 1024 * 1024) /* 16MB, arbitrary. */
@@ -72,8 +73,35 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc,
if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE))
return error;
- return __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+ return __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR,
(natural_t *) &ts, tssize);
}
weak_alias (__mach_setup_thread, mach_setup_thread)
+
+/* Give THREAD a TLS area. */
+kern_return_t
+__mach_setup_tls (thread_t thread)
+{
+ kern_return_t error;
+ struct machine_thread_state ts;
+ mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT;
+ tcbhead_t *tcb;
+
+ tcb = _dl_allocate_tls (NULL);
+ if (tcb == NULL)
+ return KERN_RESOURCE_SHORTAGE;
+
+ if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &ts, &tssize))
+ return error;
+ assert (tssize == MACHINE_THREAD_STATE_COUNT);
+
+ _hurd_tls_new (thread, &ts, tcb);
+
+ error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &ts, tssize);
+ return error;
+}
+
+weak_alias (__mach_setup_tls, mach_setup_tls)
diff --git a/mach/shortcut.awk b/mach/shortcut.awk
index ea283d49ba..090da82b6a 100644
--- a/mach/shortcut.awk
+++ b/mach/shortcut.awk
@@ -1,6 +1,7 @@
# Icky intimate knowledge of MiG output.
BEGIN { print "/* This file is generated by shortcut.awk. */";
+ print "#include <mach-shortcuts-hidden.h>";
echo=1;
inproto=0; proto=""; arglist="";
}
@@ -44,6 +45,7 @@ echo == 1 { print $0; }
print " return err;"
print "}";
print "weak_alias (" call ", " alias ")";
+ print "libc_hidden_def (" call ")";
# Declare RPC so the weak_alias that follows will work.
print "extern __typeof (" call ") " rpc ";";
echo = 1;
diff --git a/mach/spin-lock.c b/mach/spin-lock.c
index aaebc55cf4..e5c730d7fb 100644
--- a/mach/spin-lock.c
+++ b/mach/spin-lock.c
@@ -1,8 +1,16 @@
+#define __USE_EXTERN_INLINES 1
#define _EXTERN_INLINE /* Empty to define the real functions. */
#include "spin-lock.h"
weak_alias (__spin_lock_init, spin_lock_init);
+libc_hidden_def (__spin_lock_locked);
weak_alias (__spin_lock_locked, spin_lock_locked);
+libc_hidden_def (__spin_lock);
weak_alias (__spin_lock, spin_lock);
+libc_hidden_def (__spin_unlock);
weak_alias (__spin_unlock, spin_unlock);
+libc_hidden_def (__spin_try_lock);
weak_alias (__spin_try_lock, spin_try_lock);
+libc_hidden_def (__mutex_lock);
+libc_hidden_def (__mutex_unlock);
+libc_hidden_def (__mutex_trylock);
diff --git a/mach/spin-lock.h b/mach/spin-lock.h
index 535191a5ec..5b4db0ba47 100644
--- a/mach/spin-lock.h
+++ b/mach/spin-lock.h
@@ -1,5 +1,5 @@
/* Definitions of user-visible names for spin locks.
- 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/mach/spin-solid.c b/mach/spin-solid.c
index a81816afa7..db1bcd0750 100644
--- a/mach/spin-solid.c
+++ b/mach/spin-solid.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
@@ -26,3 +26,4 @@ __spin_lock_solid (spin_lock_t *lock)
__swtch_pri (0);
}
weak_alias (__spin_lock_solid, spin_lock_solid);
+libc_hidden_def (__spin_lock_solid)
diff --git a/mach/stack_chk_fail_local.c b/mach/stack_chk_fail_local.c
new file mode 100644
index 0000000000..305871fbc0
--- /dev/null
+++ b/mach/stack_chk_fail_local.c
@@ -0,0 +1 @@
+#include <debug/stack_chk_fail_local.c>