Commit Graph

421 Commits

Author SHA1 Message Date
Samuel Thibault a0bb5abd09 hurd: Fix initial sigaltstack state
* hurd/hurdsig.c (_hurd_thread_sigstate): Set SS_DISABLE in
	sigaltstack.ss_flags.
2019-01-24 19:27:00 +01:00
Samuel Thibault ee4d79026d hurd: Support AT_EMPTY_PATH
* hurd/lookup-at.c (__file_name_lookup_at): When at_flags contains
	AT_EMPTY_PATH, call __dir_lookup and __hurd_file_name_lookup_retry
	directly instead of __hurd_file_name_lookup.
2019-01-22 23:41:13 +01:00
Joseph Myers 04277e02d7 Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2019-01-01 00:11:28 +00:00
Justus Winter 065957a370 hurd: Handle "pid" magical lookup retry
* hurd/lookup-retry: Include <unistd.h>.
	(__hurd_file_name_lookup_retry): Keep a ref on last result in `lastdir'.
	Release it on return.  Handle "pid" magical lookup retry.
2018-12-28 22:32:12 +01:00
Zack Weinberg 698fb75b9f Add __v*printf_internal with flags arguments
There are a lot more printf variants than there are scanf variants,
and the code for setting up and tearing down their custom FILE
variants around the call to __vf(w)printf is more complicated and
variable.  Therefore, I have added _internal versions of all the
v*printf variants, rather than introducing helper routines so that
they can all directly call __vf(w)printf_internal, as was done with
scanf.

As with the scanf changes, in this patch the _internal functions still
look at the environmental mode bits and all callers pass 0 for the
flags parameter.

Several of the affected public functions had _IO_ name aliases that
were not exported (but, in one case, appeared in libio.h anyway);
I was originally planning to leave them as aliases to avoid having
to touch internal callers, but it turns out ldbl_*_alias only work
for exported symbols, so they've all been removed instead.  It also
turns out there were hardly any internal callers.  _IO_vsprintf and
_IO_vfprintf *are* exported, so those two stick around.

Summary for the changes to each of the affected symbols:

  _IO_vfprintf, _IO_vsprintf:
    All internal calls removed, thus the internal declarations, as well
    as uses of libc_hidden_proto and libc_hidden_def, were also removed.
    The external symbol is now exposed via uses of ldbl_strong_alias
    to __vfprintf_internal and __vsprintf_internal, respectively.

  _IO_vasprintf, _IO_vdprintf, _IO_vsnprintf,
  _IO_vfwprintf, _IO_vswprintf,
  _IO_obstack_vprintf, _IO_obstack_printf:
    All internal calls removed, thus declaration in internal headers
    were also removed.  They were never exported, so there are no
    aliases tying them to the internal functions.  I.e.: entirely gone.

  __vsnprintf:
    Internal calls were always preceded by macros such as
      #define __vsnprintf _IO_vsnprintf, and
      #define __vsnprintf vsnprintf
    The macros were removed and their uses replaced with calls to the
    new internal function __vsnprintf_internal.  Since there were no
    internal calls, the internal declaration was also removed.  The
    external symbol is preserved with ldbl_weak_alias to ___vsnprintf.

  __vfwprintf:
    All internal calls converted into calls to __vfwprintf_internal,
    thus the internal declaration was removed.  The function is now a
    wrapper that calls __vfwprintf_internal.  The external symbol is
    preserved.

  __vswprintf:
    Similarly, but no external symbol.

  __vasprintf, __vdprintf, __vfprintf, __vsprintf:
    New internal wrappers.  Not exported.

  vasprintf, vdprintf, vfprintf, vsprintf, vsnprintf,
  vfwprintf, vswprintf,
  obstack_vprintf, obstack_printf:
    These functions used to be aliases to the respective _IO_* function,
    they are now aliases to their respective __* functions.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:42 -02:00
Samuel Thibault 278fdabd8c hurd: Fix spawni's user_link reallocation
* hurd/hurd/userlink.h (_hurd_userlink_move): Make new_link's
predecessor point to new_link instead of link.
2018-11-11 20:09:17 +01:00
Samuel Thibault 88b26b7e91 Hurd: export _hurd_port_move
* hurd/Versions (_hurd_port_move): Export function.
	* sysdeps/mach/hurd/i386/libc.abilist (_hurd_port_move): Expect
	symbol.
2018-11-10 13:13:12 +00:00
Samuel Thibault 7fa495cdf7 Hurd: Fix ulinks in fd table reallocation
* hurd/hurd/userlink.h (_hurd_userlink_move): New function.
	* hurd/hurd/port.h (_hurd_port_move): New function.
	* sysdeps/mach/hurd/spawni.c (NEW_ULINK_TABLE): New macro.
	(EXPAND_DTABLE): Use NEW_ULINK_TABLE macro for ulink_dtable.
2018-11-10 11:20:12 +00:00
Samuel Thibault fc783076ec hurd: Add pci RPC stubs
* hurd/Makefile (user-interfaces): Add pci.
2018-10-31 22:43:44 +01:00
Samuel Thibault b6e7c449f9 hurd: return EIEIO instead of EIO
EIO would be understood as hardware failure, while this is software
failure.

	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Return EIEIO instead of EIO
2018-10-29 18:57:13 +01:00
Samuel Thibault 5c81be5340 hurd: Fix race between calling RPC and handling a signal
* sysdeps/mach/hurd/i386/intr-msg.h (INTR_MSG_TRAP): Make
	_hurd_intr_rpc_msg_about_to global point to start of controlled
	assembly snippet. Make it check canceled flag.
	* hurd/hurdsig.c (_hurdsig_abort_rpcs): Only mutate thread if it passed
	the _hurd_intr_rpc_msg_about_to point.
	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Remove comment on mutation
	issue, remove cancel flag check.
2018-10-28 13:41:51 +01:00
Samuel Thibault 2d0d1d3876 hurd: Return EIO on non-responding interrupted servers
since we do not actually know whether the RPC was completed or not,
which makes a huge difference for e.g. write(), so better really error
out than letting caller think that the RPC did not happen.

	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): When the server does not
	answer to interrupt_operation, return EIO instead of EINTR.
2018-10-28 10:25:44 +01:00
Samuel Thibault 46a7f24c84 hurd: set interrupt timeout to 1 minute
Seeing a server not able to get interrupted for 3s is not so surprising when
e.g. a lot of writes are happening. 1 minute allows to actually notice the
issue and be able to debug it.

	* hurd/hurdsig.c (_hurd_interrupted_rpc_timeout): Set to 60000.
2018-10-28 10:23:22 +01:00
Samuel Thibault 42fc12ef73 hurd: Fix exec usage of mach_setup_thread
Exec needs that mach_setup_thread does *not* set up TLS since it works on
another task, so we have to split this into mach_setup_tls.

	* mach/mach.h (__mach_setup_tls, mach_setup_tls): Add prototypes.
	* mach/setup-thread.c (__mach_setup_thread): Move TLS setup to...
	(__mach_setup_tls): ... new function.
	(mach_setup_tls): New alias.
	* hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls after
	__mach_setup_thread.
	* sysdeps/mach/hurd/profil.c (update_waiter): Likewise.
	* sysdeps/mach/hurd/setitimer.c (setitimer_locked): Likewise.
	* mach/Versions [libc] (mach_setup_tls): Add symbol.
	* sysdeps/mach/hurd/i386/libc.abilist (mach_setup_tls): Likewise.
2018-08-01 00:10:03 +02:00
Samuel Thibault e8ef51b171 hurd: Silence warning
* hurd/hurdsig.c (interrupted_reply_port_location): Use
	DIAG_IGNORE_NEEDS_COMMENT to silence warning with GCC 6 and before.
2018-04-04 02:06:16 +02:00
Samuel Thibault 5e17a480f8 Revert parts of "hurd: Avoid more libc.so local PLTs"
This reverts parts of commit 82dbf555a4.
2018-04-03 23:06:00 +02:00
Samuel Thibault 82dbf555a4 hurd: Avoid more libc.so local PLTs
* hurd/catch-signal.c (__hurd_catch_signal): Call __libc_siglongjmp
	instead if siglongjmp.
	(hurd_safe_memmove): Call __libc_longjmp instead of longjmp.
	* hurd/hurdfault.c (faulted): Call __libc_longjmp instead of longjmp.
	* include/setjmp.h (__libc_siglongjmp, __libc_longjmp): New hidden
	prototypes.
	* libio/iolibio.h (_IO_puts): New hidden prototype.
	* libio/ioputs.c (_IO_puts): New hidden def.
	* setjmp/longjmp.c (__libc_longjmp, __libc_siglongjmp): New hidden
	defs.
	* sysdeps/mach/hurd/sigwait.c (__sigwait): Call __libc_longjmp instead
	of longjmp.
2018-04-03 00:36:33 +00:00
Samuel Thibault a758c29399 hurd: Avoid more libc.so PLTs
* sysdeps/hurd/include/hurd/signal.h (_hurd_raise_signal): Add hidden
	prototype.
	* hurd/hurd-raise.c (_hurd_raise_signal): Add hidden def.
	* hurd/Makefile ($(inlines:%=$(objpfx)%.c): Define
	_HEADER_H_HIDDEN_DEF macro.
	* sysdeps/hurd/include/hurd/fd.h (_hurd_fd_error,
	_hurd_fd_error_signal): Add hidden prototype.
	[_HURD_FD_H_HIDDEN_DEF] (_hurd_fd_error, _hurd_fd_error_signal): Add
	hidden def.
2018-04-02 23:40:26 +00:00
Samuel Thibault 7a8f45e302 hurd: Avoid some libc.so PLTs
* hurd/catch-signal.c (hurd_catch_signal): Rename to
	__hurd_catch_signal.
	(hurd_catch_signal): New strong alias.
	(hurd_safe_memset, hurd_safe_copyout, hurd_safe_copyin): Call
	__hurd_catch_signal instead of hurd_catch_signal.
	* hurd/exc2signal.c (_hurd_exception2signal): Add hidden def.
	* hurd/hurdexec.c (_hurd_init): Add hidden def.
	* hurd/hurdinit.c (_hurd_init): Add hidden def.
	* hurd/hurdsig.c: Include <mach/mig_support.h>.
	(_hurd_thread_sigstate): Add hidden def.
	(_hurd_internal_post_signal): Use __mutex_unlock instead of
	mutex_unlock.
	* hurd/intern-fd.c (_hurd_intern_fd): Add hidden def.
	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Add hidden def.
	* hurd/path-lookup.c (hurd_file_name_path_lookup): Rename to
	__hurd_file_name_path_lookup.
	(hurd_file_name_path_lookup): New strong alias.
	(file_name_path_lookup): Call __hurd_file_name_path_lookup instead of
	hurd_file_name_path_lookup.
	* mach/errstring.c (mach_error_type): Add hidden def.
	* mach/msg-destroy.c (__mach_msg_destroy): Add hidden def.
	* mach/mutex-init.c (__mutex_init): Add hidden def.
	* mach/spin-lock.c (__spin_lock_locked, __spin_lock, __spin_unlock,
	__spin_try_lock, __mutex_lock, __mutex_trylock): Add hidden defs.
	* mach/spin-solid.c (__spin_lock_solid): Add hidden def.
	* sysdeps/mach/hurd/getcwd.c
	(_hurd_canonicalize_directory_name_internal): Rename to
	__hurd_canonicalize_directory_name_internal.
	(_hurd_canonicalize_directory_name_internal): New strong alias.
	(__canonicalize_directory_name_internal, __getcwd): Call
	__hurd_canonicalize_directory_name_internal instead of
	_hurd_canonicalize_directory_name_internal.
	* sysdeps/mach/hurd/mig-reply.c: Include <mach/mig_support.h>.
	(__mig_get_reply_port, __mig_dealloc_reply_port, __mig_init): Add
	hidden defs.
	* sysdeps/hurd/include/hurd.h: New file.
	* sysdeps/hurd/include/hurd/fd.h: New file.
	* sysdeps/hurd/include/hurd/signal.h: New file.
	* sysdeps/mach/include/lock-intern.h: New file.
	* sysdeps/mach/include/mach.h: New file.
	* sysdeps/mach/include/mach/mig_support.h: New file.
	* sysdeps/mach/include/mach_error.h: New file.
2018-04-02 22:08:55 +00:00
Samuel Thibault dba2bdbe75 hurd: Avoid some PLTs in libc and librt
* hurd/hurdauth.c (_S_msg_add_auth): Call __vm_allocate and
	__vm_deallocate instead of vm_allocate and vm_deallocate.
	* hurd/hurdmsg.c (_S_msg_set_env_variable): Call __setenv instead of
	setenv.
	* hurd/hurdprio.c (_hurd_priority_which_map): Call __geteuid instead
	of geteuid.
	* hurd/path-lookup.c (file_name_path_scan): Call __strdup instead of
	strdup.
	* hurd/siginfo.c: Include <libioP.h>.
	(_hurd_siginfo_handler): Call _IO_puts instead of puts.
	* hurd/xattr.c (_hurd_xattr_get, _hurd_xattr_set): Call __munmap instead of
	munmap.
	* io/fts.c (fts_build): Call __dirfd instead of dirfd.
	* mach/devstream.c: Include <libioP.h>.
	(dealloc_ref): Call __mach_port_deallocate instead of
	mach_port_deallocate.
	(mach_open_devstream): Call _IO_fopencookie instead of fopencookie.
	Call __mach_port_deallocate instead of mach_port_deallocate.
	* stdlib/canonicalize.c (__realpath): Call __pathconf instead of
	pathconf.
	* sysdeps/mach/hurd/ifreq.c (__ifreq): Call __munmap instead of
	munmap.
	* sysdeps/mach/hurd/ifreq.h (__if_freereq): Likewise.
	* sysdeps/mach/hurd/ptrace.c (ptrace): Call __kill instead of kill.
	* sysdeps/mach/hurd/sendfile64.c (sendfile64): Call __munmap instead
	of munmap.
	* sysdeps/mach/hurd/socketpair.c (__socketpair): Call __close instead
	of close.
	* sysdeps/posix/clock_getres.c (realtime_getres): Call __sysconf
	instead of sysconf.
	* sysdeps/pthread/timer_gettime.c (timer_gettime): Call
	__clock_gettime instead of clock_gettime.
	* sysdeps/pthread/timer_routines.c (thread_func): Likewise.
	* sysdeps/pthread/timer_settime.c (timer_settime): Likewise.
	* sysdeps/unix/bsd/gtty.c (gtty): Call __ioctl instead of ioctl.
	* sysdeps/unix/bsd/stty.c (stty): Likewise.
	* sysdeps/unix/bsd/tcflow.c (tcflow): Call __tcgetattr instead of
	tcgetattr.
	* sysdeps/unix/clock_nanosleep.c (__clock_nanosleep): Call
	__clock_gettime and __nanosleep instead of clock_gettime and
	nanosleep.
2018-04-02 19:07:52 +00:00
Samuel Thibault 79962d89a9 hurd: Code style fixes
No code change.
2018-03-20 03:00:39 +01:00
Samuel Thibault 0f652f053e hurd: Fix build with latest htl
* hurd/hurdsig.c: Include <pthreadP.h> instead of <pthread.h>.
2018-03-19 01:32:39 +01:00
Samuel Thibault 72103e73c9 hurd: Fix O_DIRECTORY | O_NOFOLLOW
Appending / to the path to be looked up would make us always follow a final
symlink, even with O_NOTRANS (since the final resolution is after the
'/').  In the O_DIRECTORY | O_NOFOLLOW case, we thus have to really open
the node and stat it, which we already do anyway, and check for
directory type.

	* hurd/hurdlookup.c (__hurd_file_name_lookup): Do not append '/' to
	path when flags contains O_NOFOLLOW.
	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Return ENOTDIR
	if flags contains O_DIRECTORY and the result is a directory.
2018-03-18 19:43:04 +01:00
Samuel Thibault 489999cc9c hurd: Fix O_NOFOLLOW
The error code documented by POSIX for opening a symlink with O_NOFOLLOW
is ELOOP.

Also, if the translator does not expose symlink as a symlink translator but
as a S_IFLNK file, O_NOFOLLOW needs to return ELOOP too.

	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Return ELOOP
	when opening a symlink with O_NOFOLLOW.
2018-03-18 19:42:17 +01:00
Samuel Thibault 55325314bf hurd: Fix copyright years 2018-03-18 18:33:37 +01:00
Agustina Arzille fb4cc8a0c2 hurd: Reimplement libc locks using mach's gsync
* hurd/Makefile (routines): Add hurdlock.
	* hurd/Versions (GLIBC_PRIVATE): Added new entry to export the above
	interface.
	(HURD_CTHREADS_0.3): Remove __libc_getspecific.
	* hurd/hurdpid.c: Include <lowlevellock.h>
	(_S_msg_proc_newids): Use lll_wait to synchronize.
	* hurd/hurdsig.c: (reauth_proc): Use __mutex_lock and __mutex_unlock.
	* hurd/setauth.c: Include <hurdlock.h>, use integer for synchronization.
	* mach/Makefile (lock-headers): Remove machine-lock.h.
	* mach/lock-intern.h: Include <lowlevellock.h> instead of
	<machine-lock.h>.
	(__spin_lock_t): New type.
	(__SPIN_LOCK_INITIALIZER): New macro.
	(__spin_lock, __spin_unlock, __spin_try_lock, __spin_lock_locked,
	__mutex_init, __mutex_lock_solid, __mutex_unlock_solid, __mutex_lock,
	__mutex_unlock, __mutex_trylock): Use lll to implement locks.
	* mach/mutex-init.c: Include <lowlevellock.h> instead of <cthreads.h>.
	(__mutex_init): Initialize with lll.
	* manual/errno.texi (EOWNERDEAD, ENOTRECOVERABLE): New errno values.
	* sysdeps/mach/Makefile: Add libmachuser as dependencies for libs
	needing lll.
	* sysdeps/mach/hurd/bits/errno.h: Regenerate.
	* sysdeps/mach/hurd/cthreads.c (__libc_getspecific): Remove function.
	* sysdeps/mach/hurd/bits/libc-lock.h: Remove file.
	* sysdeps/mach/hurd/setpgid.c: Include <lowlevellock.h>.
	(__setpgid): Use lll for synchronization.
	* sysdeps/mach/hurd/setsid.c: Likewise with __setsid.
	* sysdeps/mach/bits/libc-lock.h: Include <tls.h> and <lowlevellock.h>
	instead of <cthreads.h>.
	(_IO_lock_inexpensive): New macro
	(__libc_lock_recursive_t, __rtld_lock_recursive_t): New structures.
	(__libc_lock_self0): New declaration.
	(__libc_lock_owner_self): New macro.
	(__libc_key_t): Remove type.
	(_LIBC_LOCK_INITIALIZER): New macro.
	(__libc_lock_define_initialized, __libc_lock_init, __libc_lock_fini,
	__libc_lock_fini_recursive, __rtld_lock_fini_recursive,
	__libc_lock_lock, __libc_lock_trylock, __libc_lock_unlock,
	__libc_lock_define_initialized_recursive,
	__rtld_lock_define_initialized_recursive,
	__libc_lock_init_recursive, __libc_lock_trylock_recursive,
	__libc_lock_lock_recursive, __libc_lock_unlock_recursive,
	__rtld_lock_initialize, __rtld_lock_trylock_recursive,
	__rtld_lock_lock_recursive, __rtld_lock_unlock_recursive
	__libc_once_define, __libc_mutex_unlock): Reimplement with lll.
	(__libc_lock_define_recursive, __rtld_lock_define_recursive,
	_LIBC_LOCK_RECURSIVE_INITIALIZER, _RTLD_LOCK_RECURSIVE_INITIALIZER):
	New macros.
	Include <libc-lockP.h> to reimplement libc_key* with pthread_key*.
	* hurd/hurdlock.c: New file.
	* hurd/hurdlock.h: New file.
	* mach/lowlevellock.h: New file
2018-03-18 18:23:45 +01:00
Samuel Thibault 6dbe9dcae5 hurd: Fix coding style 2018-03-18 00:06:19 +01:00
Samuel Thibault c2fb08c78a hurd: Fix link cthread/pthread symbol exposition.
* hurd/Versions (HURD_CTHREADS_0.3): Rename weak refs cthread_fork,
	cthread_detach, pthread_getattr_np, pthread_attr_getstack,
	cthread_keycreate, cthread_getspecific, cthread_setspecific to
	__cthread_fork, __cthread_detach, __pthread_getattr_np,
	__pthread_attr_getstack, __cthread_keycreate, __cthread_getspecific,
	__cthread_setspecific.
	* hurd/hurdsig.c (_hurdsig_init): Use __cthread_fork,
	__cthread_detach, __pthread_getattr_np, __pthread_attr_getstack,
	__cthread_t instead of cthread_fork, cthread_detach,
	pthread_getattr_np, pthread_attr_getstack.
	* sysdeps/mach/hurd/cthreads.c (cthread_keycreate): Rename to
	__cthread_keycreate.
	(cthread_getspecific): Rename to __cthread_getspecific.
	(cthread_setspecific): Rename to __cthread_setspecific.
	(__libc_getspecific): Use __cthread_getspecific instead of
	cthread_getspecific.
	* sysdeps/mach/hurd/libc-lock.h (__libc_key_create): Use
	__cthread_keycreate instead of cthread_keycreate.
	(__libc_setspecific): Use __cthread_setspecific instead of
	cthread_setspecific.
	* sysdeps/mach/libc-lock.h (__libc_key_create, __libc_setspecific):
	Likewise.
2018-03-17 23:53:39 +01:00
Samuel Thibault dc33bef307 hurd: Replace threadvars with TLS
This gets rid of a lot of kludge and gets closer to other ports.

	* hurd/Makefile (headers): Remove threadvar.h.
	(inline-headers): Remove threadvar.h.
	* hurd/Versions (GLIBC_2.0: Remove __hurd_sigthread_stack_base,
	__hurd_sigthread_stack_end, __hurd_sigthread_variables,
	__hurd_threadvar_max, __hurd_errno_location.
	(HURD_CTHREADS_0.3): Add pthread_getattr_np, pthread_attr_getstack.
	* hurd/hurd/signal.h: Do not include <hurd/threadvar.h>.
	(_hurd_self_sigstate): Use THREAD_SELF to get _hurd_sigstate.
	(_HURD_SIGNAL_H_EXTERN_INLINE): Use THREAD_SELF to get _hurd_sigstate,
	unless TLS is not initialized yet, in which case we do not need a
	critical section yet anyway.
	* hurd/hurd/threadvar.h: Include <tls.h>, do not include
	<machine-sp.h>.
	(__hurd_sigthread_variables, __hurd_threadvar_max): Remove variables
	declarations.
	(__hurd_threadvar_index): Remove enum.
	(_HURD_THREADVAR_H_EXTERN_INLINE): Remove macro.
	(__hurd_threadvar_location_from_sp,__hurd_threadvar_location): Remove
	inlines.
	(__hurd_reply_port0): New variable declaration.
	(__hurd_local_reply_port): New macro.
	* hurd/hurdsig.c (__hurd_sigthread_variables): Remove variable.
	(interrupted_reply_port_location): Add thread_t parameter.  Use it
	with THREAD_TCB to access thread-local variables.
	(_hurdsig_abort_rpcs): Pass ss->thread to
	interrupted_reply_port_location.
	(_hurd_internal_post_signal): Likewise.
	(_hurdsig_init): Use presence of cthread_fork instead of
	__hurd_threadvar_stack_mask to start signal thread by hand.
	Remove signal thread threadvar initialization.
	* hurd/hurdstartup.c: Do not include <hurd/threadvar.h>
	* hurd/sigunwind.c: Include <hurd/threadvar.h>
	(_hurdsig_longjmp_from_handler): Use __hurd_local_reply_port instead
	of threadvar.
	* sysdeps/mach/hurd/Versions (libc.GLIBC_PRIVATE): Add
	__libc_lock_self0.
	(ld.GLIBC_2.0): Remove __hurd_sigthread_stack_base,
	__hurd_sigthread_stack_end, __hurd_sigthread_variables.
	(ld.GLIBC_PRIVATE): Add __libc_lock_self0.
	* sysdeps/mach/hurd/cthreads.c: Add __libc_lock_self0.
	* sysdeps/mach/hurd/dl-sysdep.c (errno, __hurd_sigthread_stack_base,
	__hurd_sigthread_stack_end, __hurd_sigthread_variables, threadvars,
	__hurd_threadvar_stack_offset, __hurd_threadvar_stack_mask): Do not
	define variables.
	* sysdeps/mach/hurd/errno-loc.c: Do not include <errno.h> and
	<hurd/threadvar.h>.
	[IS_IN(rtld)] (rtld_errno): New variable.
	[IS_IN(rtld)] (__errno_location): New weak function.
	[!IS_IN(rtld)]: Include "../../../csu/errno-loc.c".
	* sysdeps/mach/hurd/errno.c: Remove file.
	* sysdeps/mach/hurd/fork.c: Include <hurd/threadvar.h>
	(__fork): Remove THREADVAR_SPACE macro and its use.
	* sysdeps/mach/hurd/i386/init-first.c (__hurd_threadvar_max): Remove
	variable.
	(init): Do not initialize threadvar.
	* sysdeps/mach/hurd/i386/libc.abilist (__hurd_threadvar_max): Remove
	symbol.
	* sysdeps/mach/hurd/i386/sigreturn.c (__sigreturn): Use
	__hurd_local_reply_port instead of threadvar.
	* sysdeps/mach/hurd/i386/tls.h (tcbhead_t): Add reply_port and
	_hurd_sigstate fields.
	(HURD_DESC_TLS, __LIBC_NO_TLS, THREAD_TCB): New macro.
	* sysdeps/mach/hurd/i386/trampoline.c: Remove outdated comment.
	* sysdeps/mach/hurd/libc-lock.h: Do not include <hurd/threadvar.h>.
	(__libc_lock_owner_self): Use &__libc_lock_self0 and THREAD_SELF
	instead of threadvar.
	* sysdeps/mach/hurd/libc-tsd.h: Remove file.
	* sysdeps/mach/hurd/mig-reply.c (GETPORT, reply_port): Remove macros.
	(use_threadvar, global_reply_port): Remove variables.
	(__hurd_reply_port0): New variable.
	(__mig_get_reply_port): Use __hurd_local_reply_port and
	__hurd_reply_port0 instead of threadvar.
	(__mig_dealloc_reply_port): Likewise.
	(__mig_init): Do not initialize threadvar.
	* sysdeps/mach/hurd/profil.c: Fix comment.
2018-03-17 23:29:57 +01:00
Samuel Thibault 34e6a8694d hurd: Fix getting signal thread stack layout for fork
* hurd/hurdsig.c: Include <pthread.h>.
(_hurdsig_init): Call pthread_getattr_np and pthread_attr_getstack to
get the signal thread stack layout.
2018-03-17 22:53:01 +01:00
Samuel Thibault f8baf2a224 hurd: add TLS support
* sysdeps/generic/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR):
	Define macro.
	* sysdeps/mach/thread_state.h (MACHINE_THREAD_STATE_FIX_NEW): New macro.
	* sysdeps/mach/i386/thread_state.h
	(MACHINE_NEW_THREAD_STATE_FLAVOR): New macro, defined to
	i386_THREAD_STATE.
	(MACHINE_THREAD_STATE_FLAVOR): Define to i386_REGS_SEGS_STATE instead of
	i386_THREAD_STATE.
	(MACHINE_THREAD_STATE_FIX_NEW): New macro, reads segments.

	* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Use
	i386_REGS_SEGS_STATE instead of i386_THREAD_STATE.

	* sysdeps/mach/hurd/i386/tls.h (TCB_ALIGNMENT, HURD_SEL_LDT): New
	macros.
	(_hurd_tls_fork): Add original thread parameter, Duplicate existing LDT
	descriptor instead of creating a new one.
	(_hurd_tls_new): New function, creates a new descriptor and updates tcb.

	* mach/setup-thread.c: Include <ldsodefs.h>.
	(__mach_setup_thread): Call _dl_allocate_tls, pass
	MACHINE_NEW_THREAD_STATE_FLAVOR to __thread_set_state instead of
	MACHINE_THREAD_STATE_FLAVOR, before getting
	MACHINE_THREAD_STATE_FLAVOR, calling _hurd_tls_new, and setting
	MACHINE_THREAD_STATE_FLAVOR with the result.
	* hurd/hurdfault.c (_hurdsig_fault_init): Call
	MACHINE_THREAD_STATE_FIX_NEW.
	* sysdeps/mach/hurd/fork.c (__fork): Call _hurd_tls_fork for sigthread
	too.  Add original thread parameter.
2018-03-17 03:17:36 +01:00
Samuel Thibault a1ede3a402 hurd: Fix includability of <hurd/signal.h> in all standards
* bits/sigaction.h: Add include guard.
* sysdeps/unix/sysv/linux/alpha/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/sigaction.h: Likewise.
* sysdeps/unix/sysv/linux/tile/bits/sigaction.h: Likewise.
* hurd/hurd/signal.h: Include <bits/sigaction.h>.
2018-03-05 22:50:29 +01:00
Samuel Thibault 974393ea43 Separate out error_t definition
so interfaces needing it can get it.

	* stdlib/errno.h (error_t): Move definition to...
	* bits/types/error_t.h: ... new header.
	* stdlib/Makefile (headers): Add bits/types/error_t.h.
	* sysdeps/mach/hurd/bits/errno.h (error_t): Move definition to...
	* sysdeps/mach/hurd/bits/types/error_t.h: ... new header.
	* sysdeps/mach/hurd/errnos.awk (error_t): Likewise.
	* hurd/hurd.h: Include <bits/types/error_t.h>
	* hurd/hurd/fd.h: Include <bits/types/error_t.h>
	* hurd/hurd/id.h: Include <errno.h> and <bits/types/error_t.h>
	* hurd/hurd/lookup.h: Include <errno.h> and <bits/types/error_t.h>
	* hurd/hurd/resource.h: Include <bits/types/error_t.h>
	* hurd/hurd/signal.h: Include <bits/types/error_t.h>
	* hurd/hurd/sigpreempt.h: Include <bits/types/error_t.h>
2018-03-04 17:27:58 +01:00
Samuel Thibault ba89615dab hurd: Make almost all hurd headers includable in all standards
* hurd/hurd.h: Include <bits/types/sigset_t.h>
	* hurd/hurd/fd.h: Include <sys/select.h> and <bits/types/sigset_t.h>
	(_hurd_fd_read, _hurd_fd_write): Use __loff_t instead of loff_t.
	* hurd/hurd/signal.h: Include <bits/types/stack_t.h> and
	<bits/types/sigset_t.h>.
	[!defined __USE_GNU]: Do not #error out.
	(struct hurd_sigstate): Use _NSIG instead of NSIG.
	* hurd/hurd/sigpreempt.h (__need_size_t): Define.
	Include <stddef.h> and <bits/types/sigset_t.h>
	(struct hurd_signal_preemptor, hurd_catch_signal): Use __sighandler_t
	instead of sighandler_t.
2018-03-04 04:03:13 +01:00
Samuel Thibault 95dfdbd28c hurd: Avoid using ino64_t and loff_t in headers
* mach/Machrules ($(patsubst %,$(objpfx)%.h,$(user-interfaces)):
	Process mig output through $(migheaderpipe).
	* hurd/Makefile (migheaderpipe): Define variable.
2018-03-04 02:13:56 +01:00
Samuel Thibault 48d34cbc23 hurd: fix header conformity
* hurd/hurd/fd.h (_hurd_fd_error): Fix struct initializer to be
	trivial, for C++ conformity.
2018-03-04 01:35:38 +01:00
Samuel Thibault 3403cb7dd4 hurd: avoid including hurd/signal.h when not needed
thus making <hurd/port.h> and <hurd/userlink.h> includable without
_GNU_SOURCE.

	* hurd/hurd/port.h: Do not include <hurd/signal.h>.
	* hurd/hurd/userlink.h [!defined __USE_EXTERN_INLINES ||
	!defined _LIBC || !IS_IN (libc)]: Do not include <hurd/signal.h>.
2018-03-04 01:28:55 +01:00
Samuel Thibault e30c291a6d hurd: Add missing includes
* hurd/hurd/id.h: Include <hurd/hurd_types.h>
	* hurd/hurd/ioctl.h: Include <mach/port.h>
	* hurd/hurd/lookup.h: Include <hurd/hurd_types.h>
2018-03-03 23:58:51 +01:00
Zack Weinberg 9964a14579 Mechanically remove _IO_ name aliases for types and constants.
This patch mechanically removes all remaining uses, and the
definitions, of the following libio name aliases:

 name                         replaced with
 ----                         -------------
 _IO_FILE                     FILE
 _IO_fpos_t                   __fpos_t
 _IO_fpos64_t                 __fpos64_t
 _IO_size_t                   size_t
 _IO_ssize_t                  ssize_t or __ssize_t
 _IO_off_t                    off_t
 _IO_off64_t                  off64_t
 _IO_pid_t                    pid_t
 _IO_uid_t                    uid_t
 _IO_wint_t                   wint_t
 _IO_va_list                  va_list or __gnuc_va_list
 _IO_BUFSIZ                   BUFSIZ
 _IO_cookie_io_functions_t    cookie_io_functions_t
 __io_read_fn                 cookie_read_function_t
 __io_write_fn                cookie_write_function_t
 __io_seek_fn                 cookie_seek_function_t
 __io_close_fn                cookie_close_function_t

I used __fpos_t and __fpos64_t instead of fpos_t and fpos64_t because
the definitions of fpos_t and fpos64_t depend on the largefile mode.
I used __ssize_t and __gnuc_va_list in a handful of headers where
namespace cleanliness might be relevant even though they're
internal-use-only.  In all other cases, I used the public-namespace
name.

There are a tiny handful of places where I left a use of 'struct _IO_FILE'
alone, because it was being used together with 'struct _IO_FILE_plus'
or 'struct _IO_FILE_complete' in the same arithmetic expression.

Because this patch was almost entirely done with search and replace, I
may have introduced indentation botches.  I did proofread the diff,
but I may have missed something.

The ChangeLog below calls out all of the places where this was not a
pure search-and-replace change.

Installed stripped libraries and executables are unchanged by this patch,
except that some assertions in vfscanf.c change line numbers.

	* libio/libio.h (_IO_FILE): Delete; all uses changed to FILE.
	(_IO_fpos_t): Delete; all uses changed to __fpos_t.
	(_IO_fpos64_t): Delete; all uses changed to __fpos64_t.
	(_IO_size_t): Delete; all uses changed to size_t.
	(_IO_ssize_t): Delete; all uses changed to ssize_t or __ssize_t.
	(_IO_off_t): Delete; all uses changed to off_t.
	(_IO_off64_t): Delete; all uses changed to off64_t.
	(_IO_pid_t): Delete; all uses changed to pid_t.
	(_IO_uid_t): Delete; all uses changed to uid_t.
	(_IO_wint_t): Delete; all uses changed to wint_t.
	(_IO_va_list): Delete; all uses changed to va_list or __gnuc_va_list.
	(_IO_BUFSIZ): Delete; all uses changed to BUFSIZ.
	(_IO_cookie_io_functions_t): Delete; all uses changed to
	cookie_io_functions_t.
	(__io_read_fn): Delete; all uses changed to cookie_read_function_t.
	(__io_write_fn): Delete; all uses changed to cookie_write_function_t.
	(__io_seek_fn): Delete; all uses changed to cookie_seek_function_t.
	(__io_close_fn): Delete: all uses changed to cookie_close_function_t.

	* libio/iofopncook.c: Remove unnecessary forward declarations.
	* libio/iolibio.h: Correct outdated commentary.
	* malloc/malloc.c (__malloc_stats): Remove unnecessary casts.
	* stdio-common/fxprintf.c (__fxprintf_nocancel):
	Remove unnecessary casts.
	* stdio-common/getline.c: Use _IO_getdelim directly.
	Don't redefine ssize_t.
	* stdio-common/printf_fp.c, stdio_common/printf_fphex.c
	* stdio-common/printf_size.c: Don't redefine size_t or FILE.
	Remove outdated comments.
	* stdio-common/vfscanf.c: Don't redefine va_list.
2018-02-21 14:11:05 -05:00
Samuel Thibault 2f8902cc7a hurd: Fix preprocessor indentation 2018-01-29 23:00:17 +01:00
Samuel Thibault e01e0ddc42 hurd: Add expected ABI lists
* hurd/Versions: Fix version when _hurd_exec_paths was added.
* mach/Versions: Fix version when __mach_host_self_ was added.
* sysdeps/mach/hurd/i386/ld.abilist: New file.
* sysdeps/mach/hurd/i386/libBrokenLocale.abilist: New file.
* sysdeps/mach/hurd/i386/libanl.abilist: New file.
* sysdeps/mach/hurd/i386/libc.abilist: New file.
* sysdeps/mach/hurd/i386/libcrypt.abilist: New file.
* sysdeps/mach/hurd/i386/libdl.abilist: New file.
* sysdeps/mach/hurd/i386/libm.abilist: New file.
* sysdeps/mach/hurd/i386/libnsl.abilist: New file.
* sysdeps/mach/hurd/i386/libresolv.abilist: New file.
* sysdeps/mach/hurd/i386/librt.abilist: New file.
* sysdeps/mach/hurd/i386/libutil.abilist: New file.
2018-01-29 22:07:44 +01:00
Samuel Thibault 625ba81ef5 hurd: Include <sigsetops.h> from hurd/hurd/signal.h
* hurd/hurd/signal.h [__USE_EXTERN_INLINES][_LIBC][IS_IN(libc) ||
IS_IN(libpthread)]: Include <sigsetops.h>.
2018-01-28 19:36:49 +01:00
Samuel Thibault e925416840 hurd: fix typo 2018-01-28 19:27:19 +01:00
Samuel Thibault 28f6186f3e hurd: take __USE_EXTERN_INLINES into account and restrict inlines
* hurd/hurd.h (__hurd_fail): Always declare function, and provide inline
version only if __USE_EXTERN_INLINES is defined.
* hurd/hurd/fd.h (_hurd_fd_error_signal, _hurd_fd_error, __hurd_dfail,
__hurd_sockfail): Likewise.
(_hurd_fd_get): Always declare functions, and provide inline versions
only if __USE_EXTERN_INLINES and _LIBC are defined and IS_IN(libc).
* hurd/hurd/port.h (_hurd_port_init, _hurd_port_locked_get,
_hurd_port_get, _hurd_port_free, _hurd_port_locked_set,
_hurd_port_set): Always declare functions, and provide inline versions
only if __USE_EXTERN_INLINES and _LIBC are defined and
IS_IN(libc).
* hurd/hurd/signal.h (_hurd_self_sigstate, _hurd_critical_section_lock,
_hurd_critical_section_unlock): Likewise.
* hurd/hurd/threadvar.h (__hurd_threadvar_location_from_sp,
* __hurd_threadvar_location): Likewise.
* hurd/hurd/userlink.h (_hurd_userlink_link, _hurd_userlink_unlink,
_hurd_userlink_clear): Likewise.
* mach/lock-intern.h (__spin_lock_init, __spin_lock, __mutex_lock,
__mutex_unlock, __mutex_trylock): Always declare functions, and provide
inline versions only if __USE_EXTERN_INLINES and _LIBC are defined.
* mach/mach/mig_support.h (__mig_strncpy): Likewise.
* sysdeps/generic/machine-lock.h (__spin_unlock, __spin_try_lock,
__spin_lock_locked): Likewise.
* sysdeps/mach/i386/machine-lock.h (__spin_unlock, __spin_try_lock,
__spin_lock_locked): Likewise.
* mach/spin-lock.c (__USE_EXTERN_INLINES): Define to 1.
* hurd/Versions (libc: GLIBC_2.27): Add _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.
2018-01-28 18:46:23 +01:00
Thomas Schwinge 84814e2a40 hurd: Add missing fcntl-internal.h
* hurd/fcntl-internal.h: New file.
2018-01-28 17:05:40 +01:00
Samuel Thibault f8bee46cc2 hurd: Fix warnings
* hurd/hurd/lookup.h (__hurd_file_name_lookup, hurd_file_name_lookup,
	__hurd_file_name_split, hurd_file_name_split,
	__hurd_directory_name_split, hurd_directory_name_split,
	__hurd_file_name_lookup_retry, hurd_file_name_lookup_retry,
	hurd_file_name_path_lookup): Make lookup function parameter take a
	const char *name instead of char *name.
	* hurd/hurdlookup.c (__hurd_file_name_lookup, __hurd_file_name_split,
	__hurd_directory_name_split): Likewise.
	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
	* hurd/path-lookup.c (hurd_file_name_path_lookup): Likewise.
2018-01-28 16:23:59 +01:00
Samuel Thibault 09085ede12 hurd: Implement faccessat without AT_EACCESS flag
* hurd/hurd/fd.h: Include <fcntl.h>
(__hurd_at_flags): New function.
* hurd/lookup-at.c (__file_name_lookup_at): Replace flag computation
with call to __hurd_at_flags.
* include/unistd.h (__faccessat, __faccessat_noerrno): Add declaration.
* sysdeps/mach/hurd/access.c (access_common): Move implementation to
__faccessat
(hurd_fail_seterrno, hurd_fail_noerrno): Move to sysdeps/mach/hurd/faccessat.c.
(__access_noerrno): Use __faccessat_common instead of access_common.
(__access): Likewise.
* sysdeps/mach/hurd/euidaccess.c (__euidaccess): Replace implementation
with a call to __faccessat.
* sysdeps/mach/hurd/faccessat.c (faccessat): Rename into...
(__faccessat_common): ... this. Move implementation of __access into it when
AT_FLAGS does not contain AT_EACCESS. Make it call __hurd_at_flags, add
reauthenticate_cwdir_at helper to implement AT mechanism.
(__faccessat_noerrno): New function, just calls __faccessat_common.
(__faccessat): New function, just calls __faccessat_common.
(faccessat): Define weak alias.
2018-01-10 02:03:28 +01:00
Samuel Thibault 311ba8dc44 hurd: Use the new file_exec_paths RPC
From: Emilio Pozuelo Monfort <pochu27@gmail.com>
From: Svante Signell <svante.signell@gmail.com>

Pass the file paths of executable to the exec server, both relative and
absolute, which exec needs to properly execute and avertise #!-scripts.
Previously, the exec server tried to guess the name from argv[0] but argv[0]
only contains the executable name by convention.

	* hurd/hurdexec.c (_hurd_exec): Deprecate function.
	(_hurd_exec_paths): New function.
	* hurd/hurd.h (_hurd_exec): Deprecate function.
	(_hurd_exec_paths): Declare function.
	* hurd/Versions: Export _hurd_exec_paths.
	* sysdeps/mach/hurd/execve.c: Include <stdlib.h> and <stdio.h>
	(__execve): Use __getcwd to build absolute path, and use
	_hurd_exec_paths instead of _hurd_exec.
	* sysdeps/mach/hurd/spawni.c: Likewise.
	* sysdeps/mach/hurd/fexecve.c: Use _hurd_exec_paths instead of
	_hurd_exec.
2018-01-09 01:37:34 +01:00
Joseph Myers 688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Samuel Thibault 507fe02799 hurd: fix gethostname(NULL, 0)
* hurd/get-host.c (_hurd_get_host_config): Also check that more == 0
	before assuming that the file is empty.  Avoid testing buffer content
	when nread == 0.
2017-09-07 00:51:17 +02:00