diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/configure real-libc/configure
--- /mnt/marcus/gnu/cvs/libc/configure	2003-05-06 16:04:22.000000000 +0200
+++ real-libc/configure	2003-05-19 03:49:23.000000000 +0200
@@ -1910,7 +1910,7 @@ os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\
 
 case "$os" in
 gnu*)
-  base_os=mach/hurd ;;
+  base_os=l4/hurd ;;
 netbsd* | 386bsd* | freebsd* | bsdi*)
   base_os=unix/bsd/bsd4.4 ;;
 osf* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/configure.in real-libc/configure.in
--- /mnt/marcus/gnu/cvs/libc/configure.in	2003-05-06 16:04:22.000000000 +0200
+++ real-libc/configure.in	2003-05-19 03:43:21.000000000 +0200
@@ -452,7 +452,7 @@ os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\
 
 case "$os" in
 gnu*)
-  base_os=mach/hurd ;;
+  base_os=l4/hurd ;;
 netbsd* | 386bsd* | freebsd* | bsdi*)
   base_os=unix/bsd/bsd4.4 ;;
 osf* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/getumask.c real-libc/hurd-l4/getumask.c
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/getumask.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/getumask.c	2003-05-19 16:00:19.000000000 +0200
@@ -0,0 +1,26 @@
+/* Copyright (C) 1992, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/stat.h>
+#include <hurd.h>
+
+mode_t
+getumask (void)
+{
+  return _hurd_umask;
+}
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd/resource.h real-libc/hurd-l4/hurd/resource.h
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd/resource.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/hurd/resource.h	2003-05-19 14:42:53.000000000 +0200
@@ -0,0 +1,52 @@
+/* Resource limits for the Hurd.
+   Copyright (C) 1994, 1995, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _HURD_RESOURCE_H
+#define _HURD_RESOURCE_H
+
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <errno.h>
+#include <hurd/process.h>
+
+/* This array contains the current resource limits for the process.  */
+extern struct rlimit _hurd_rlimits[RLIM_NLIMITS];
+extern struct mutex _hurd_rlimit_lock; /* Locks _hurd_rlimits.  */
+
+
+/* Helper function for getpriority and setpriority.  Maps FN over all the
+   processes specified by WHICH and WHO.  PI is non-null if a
+   proc_getprocinfo was already done; FN may use *PI arbitrarily, it is
+   reset on the next call; PI_FLAGS is passed to proc_getprocinfo.  Returns
+   FN's result the first time it returns nonzero.  If FN never returns
+   nonzero, this returns zero.  */
+extern error_t _hurd_priority_which_map (enum __priority_which which, int who,
+					 error_t (*fn) (pid_t pid,
+							struct procinfo *pi),
+					 int pi_flags);
+
+/* Convert between Mach priority values and the priority
+   values used by getpriority, setpriority, and nice.  */
+#define MACH_PRIORITY_TO_NICE(prio) (2 * ((prio) - 12))
+#define NICE_TO_MACH_PRIORITY(nice) (12 + ((nice) / 2))
+
+
+
+
+#endif
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd/sigpreempt.h real-libc/hurd-l4/hurd/sigpreempt.h
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd/sigpreempt.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/hurd/sigpreempt.h	2003-05-19 14:43:02.000000000 +0200
@@ -0,0 +1,103 @@
+/* Preemption of Hurd signals before POSIX.1 semantics take over.
+   Copyright (C) 1996 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef	_HURD_SIGPREEMPT_H
+
+#define	_HURD_SIGPREEMPT_H	1
+#include <errno.h>
+#include <signal.h>		/* For sigset_t, sighandler_t, SIG_ERR.  */
+struct hurd_sigstate;		/* <hurd/signal.h> */
+struct hurd_signal_detail;	/* <hurd/signal.h> */
+
+struct hurd_signal_preemptor
+  {
+    /* These members select which signals this structure will apply to.
+       The rest of the structure is only consulted if these match.  */
+    sigset_t signals;		/* Signals preempted.  */
+    unsigned long int first, last; /* Range of sigcode values preempted.  */
+
+    /* This function will be called (with SS->lock held) to decide what to
+       do with the signal described.  It may modify the codes of the signal
+       passed.  If the return value is SIG_ERR, the next matching 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);
+    /* If PREEMPTOR is null, act as if it returned HANDLER.  */
+    sighandler_t handler;
+
+    struct hurd_signal_preemptor *next;	/* List structure.  */
+  };
+
+#define HURD_PREEMPT_SIGNAL_P(preemptor, signo, sigcode) \
+  (((preemptor)->signals & sigmask (signo)) && \
+   (sigcode) >= (preemptor)->first && (sigcode) <= (preemptor)->last)
+
+
+/* Signal preemptors applying to all threads; locked by _hurd_siglock.  */
+extern struct hurd_signal_preemptor *_hurdsig_preemptors;
+extern sigset_t _hurdsig_preempted_set;
+
+
+/* The caller must initialize all members of *PREEMPTOR except `next'.
+   The preemptor is registered on the global list.  */
+void hurd_preempt_signals (struct hurd_signal_preemptor *preemptor);
+
+/* Remove a preemptor registered with hurd_preempt_signals.  */
+void hurd_unpreempt_signals (struct hurd_signal_preemptor *preemptor);
+
+
+/* Call *OPERATE and return its value.  If a signal in SIGSET with a sigcode
+   in the range [FIRST,LAST] arrives during the call, catch it.  If HANDLER
+   is a function, it handles the signal in the normal way (i.e. it should
+   longjmp unless it can restart the insn on return).  If it is SIG_ERR,
+   hurd_catch_signal returns the sc_error value from the signal (or
+   EGRATUITOUS if that is zero).
+
+   The preemptor structure is passed to *OPERATE, which may modify its
+   sigcode range or functions at any time during which it is guaranteed no
+   signal in SIGSET will arrive.  */
+
+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);
+
+
+/* Convenience functions using `hurd_catch_signal'.  */
+
+
+/* Like `memset', but catch faults in DEST.  */
+error_t hurd_safe_memset (void *dest, int byte, size_t nbytes);
+
+/* Like `memcpy', but catch faults in SRC.  */
+error_t hurd_safe_copyin (void *dest, const void *src, size_t nbytes);
+
+/* Like `memcpy', but catch faults in DEST.  */
+error_t hurd_safe_copyout (void *dest, const void *src, size_t nbytes);
+
+/* Like `memmove', but catch faults in SRC or DEST.
+   If only one region is expected to fault, it is more efficient
+   to use `hurd_safe_copyin' or `hurd_safe_copyout' as appropriate.  */
+error_t hurd_safe_memmove (void *dest, const void *src, size_t nbytes);
+
+
+#endif	/* hurd/sigpreempt.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd/threadvar.h real-libc/hurd-l4/hurd/threadvar.h
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd/threadvar.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/hurd/threadvar.h	2003-05-19 14:43:05.000000000 +0200
@@ -0,0 +1,117 @@
+/* Internal per-thread variables for the Hurd.
+   Copyright (C) 1994,95,97,98,99,2001,02 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _HURD_THREADVAR_H
+#define	_HURD_THREADVAR_H
+
+#include <features.h>
+
+/* The per-thread variables are found by ANDing this mask
+   with the value of the stack pointer and then adding this offset.
+
+   In the multi-threaded case, cthreads initialization sets
+   __hurd_threadvar_stack_mask to ~(cthread_stack_size - 1), a mask which
+   finds the base of the fixed-size cthreads stack; and
+   __hurd_threadvar_stack_offset to a small offset that skips the data
+   cthreads itself maintains at the base of each thread's stack.
+
+   In the single-threaded 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.  */
+
+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
+   __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;
+
+
+/* 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 ());
+}
+
+
+#endif	/* hurd/threadvar.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd/userlink.h real-libc/hurd-l4/hurd/userlink.h
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd/userlink.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/hurd/userlink.h	2003-05-19 14:43:10.000000000 +0200
@@ -0,0 +1,148 @@
+/* Support for chains recording users of a resource; `struct hurd_userlink'.
+   Copyright (C) 1994, 1995, 1997, 1999 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef	_HURD_USERLINK_H
+
+#define	_HURD_USERLINK_H	1
+#include <features.h>
+
+#define __need_NULL
+#include <stddef.h>
+
+#include <hurd/signal.h>
+#include <setjmp.h>
+
+
+/* This structure records a link in two doubly-linked lists.
+   We call these the per-resource user list and the per-thread
+   active-resource list.
+
+   Users of a given resource are recorded by their presence in a list
+   associated with that resource.  A user attaches his own link (in local
+   storage on his stack) to a shared chain at the time he begins using some
+   resource.  When finished with that resource, the user removes his link
+   from the chain.  If his link is the last (there are no other users of
+   the resource), and his chain has been detached from the shared cell (the
+   resource in the cell has been replaced), then the user deallocates the
+   resource that he used.
+
+   All uses of shared resources by a single thread are linked together by
+   its `active-resource' list; the head of this list is stored in the
+   per-thread sigstate structure.  When the thread makes a non-local exit
+   (i.e. longjmp), it will examine its active-resource list, and each link
+   residing in a stack frame being jumped out of will be unlinked from both
+   the resource's user list and the thread's active-resource list, and
+   deallocate the resource if that was the last user link for that resource.
+
+   NOTE: Access to a thread's active-resource list must always be done
+   inside a signal-proof critical section; the functions in this file
+   assume they are called inside a critical section, and do no locking of
+   their own.  Also important: the longjmp cleanup relies on all userlink
+   structures residing on the stack of the using thread.  */
+
+struct hurd_userlink
+  {
+    struct
+      {
+	struct hurd_userlink *next, **prevp;
+      } resource, thread;
+
+    /* This function is called when a non-local exit
+       unwinds the frame containing this link.  */
+    void (*cleanup) (void *cleanup_data, jmp_buf env, int val);
+    void *cleanup_data;
+  };
+
+
+#ifndef _HURD_USERLINK_H_EXTERN_INLINE
+#define _HURD_USERLINK_H_EXTERN_INLINE extern __inline
+#endif
+
+
+/* Attach LINK to the chain of users at *CHAINP.  */
+
+_HURD_USERLINK_H_EXTERN_INLINE void
+_hurd_userlink_link (struct hurd_userlink **chainp,
+		     struct hurd_userlink *link)
+{
+  struct hurd_userlink **thread_chainp;
+
+  link->resource.next = *chainp;
+  if (link->resource.next)
+    link->resource.next->resource.prevp = &link->resource.next;
+  link->resource.prevp = chainp;
+  *chainp = link;
+
+  /* Also chain it on the current thread's list of active resources.  */
+  thread_chainp = &_hurd_self_sigstate ()->active_resources;
+  link->thread.next = *thread_chainp;
+  if (link->thread.next)
+    link->thread.next->thread.prevp = &link->thread.next;
+  link->thread.prevp = thread_chainp;
+  *thread_chainp = link;
+}
+
+
+/* Detach LINK from its chain.  Returns nonzero iff this was the
+   last user of the resource and it should be deallocated.  */
+
+_HURD_USERLINK_H_EXTERN_INLINE int
+_hurd_userlink_unlink (struct hurd_userlink *link)
+{
+  /* We should deallocate the resource used if this chain has been detached
+     from the cell (and thus has a nil `prevp'), and there is no next link
+     representing another user reference to the same resource. */
+  int dealloc = ! link->resource.next && ! link->resource.prevp;
+
+  /* Remove our link from the chain of current users.  */
+  if (link->resource.prevp)
+    *link->resource.prevp = link->resource.next;
+  if (link->resource.next)
+    link->resource.next->resource.prevp = link->resource.prevp;
+
+  /* Remove our link from the chain of currently active resources
+     for this thread.  */
+  *link->thread.prevp = link->thread.next;
+  if (link->thread.next)
+    link->thread.next->thread.prevp = link->thread.prevp;
+
+  return dealloc;
+}
+
+
+/* Clear all users from *CHAINP.  Call this when the resource *CHAINP
+   protects is changing.  If the return value is nonzero, no users are on
+   the chain and the caller should deallocate the resource.  If the return
+   value is zero, someone is still using the resource and they will
+   deallocate it when they are finished.  */
+
+_HURD_USERLINK_H_EXTERN_INLINE int
+_hurd_userlink_clear (struct hurd_userlink **chainp)
+{
+  if (*chainp == NULL)
+    return 1;
+
+  /* Detach the chain of current users from the cell.  The last user to
+     remove his link from that chain will deallocate the old resource.  */
+  (*chainp)->resource.prevp = NULL;
+  *chainp = NULL;
+  return 0;
+}
+
+#endif	/* hurd/userlink.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd.h real-libc/hurd-l4/hurd.h
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/hurd.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/hurd.h	2003-05-19 16:16:11.000000000 +0200
@@ -0,0 +1,352 @@
+/* Copyright (C) 1993,94,95,96,97,98,99,2001,02 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef	_HURD_H
+
+#define	_HURD_H	1
+#include <features.h>
+
+
+/* Get types, macros, constants and function declarations for all
+   microkernel interaction.  */
+#include <l4.h>
+#include <sys/stat.h>
+
+#if 0
+/* Get types and constants necessary for Hurd interfaces.  */
+#include <hurd/hurd_types.h>
+
+/* Get MiG stub declarations for commonly used Hurd interfaces.  */
+#include <hurd/auth.h>
+#include <hurd/process.h>
+#include <hurd/fs.h>
+#include <hurd/io.h>
+
+/* Get `struct hurd_port' and related definitions implementing lightweight
+   user references for ports.  These are used pervasively throughout the C
+   library; this is here to avoid putting it in nearly every source file.  */
+#include <hurd/port.h>
+#endif
+
+#include <errno.h>
+
+#ifndef _HURD_H_EXTERN_INLINE
+#define _HURD_H_EXTERN_INLINE extern __inline
+#endif
+
+#if 0
+_HURD_H_EXTERN_INLINE int
+__hurd_fail (error_t err)
+{
+  switch (err)
+    {
+    case EMACH_SEND_INVALID_DEST:
+    case EMIG_SERVER_DIED:
+      /* The server has disappeared!  */
+      err = EIEIO;
+      break;
+
+    case KERN_NO_SPACE:
+      err = ENOMEM;
+      break;
+
+    case KERN_INVALID_ARGUMENT:
+      err = EINVAL;
+      break;
+
+    case 0:
+      return 0;
+
+    default:
+      break;
+    }
+
+  errno = err;
+  return -1;
+}
+
+/* Basic ports and info, initialized by startup.  */
+
+extern int _hurd_exec_flags;	/* Flags word passed in exec_startup.  */
+extern struct hurd_port *_hurd_ports;
+extern unsigned int _hurd_nports;
+#endif
+extern mode_t _hurd_umask;
+#if 0
+extern sigset_t _hurdsig_traced;
+
+/* Shorthand macro for internal library code referencing _hurd_ports (see
+   <hurd/port.h>).  */
+
+#define	__USEPORT(which, expr) \
+  HURD_PORT_USE (&_hurd_ports[INIT_PORT_##which], (expr))
+
+/* Function version of __USEPORT: calls OPERATE with a send right.  */
+
+extern error_t _hurd_ports_use (int which, error_t (*operate) (mach_port_t));
+
+
+/* Base address and size of the initial stack set up by the exec server.
+   If using cthreads, this stack is deallocated in startup.
+   Not locked.  */
+
+extern vm_address_t _hurd_stack_base;
+extern vm_size_t _hurd_stack_size;
+
+/* Initial file descriptor table we were passed at startup.  If we are
+   using a real dtable, these are turned into that and then cleared at
+   startup.  If not, these are never changed after startup.  Not locked.  */
+
+extern mach_port_t *_hurd_init_dtable;
+extern mach_msg_type_number_t _hurd_init_dtablesize;
+
+/* Current process IDs.  */
+
+extern pid_t _hurd_pid, _hurd_ppid, _hurd_pgrp;
+extern int _hurd_orphaned;
+
+/* This variable is incremented every time the process IDs change.  */
+extern unsigned int _hurd_pids_changed_stamp;
+
+/* This condition is broadcast every time the process IDs change.  */
+extern struct condition _hurd_pids_changed_sync;
+
+/* Unix `data break', for brk and sbrk.
+   If brk and sbrk are not used, this info will not be initialized or used.  */
+
+
+/* Data break.  This is what `sbrk (0)' returns.  */
+
+extern vm_address_t _hurd_brk;
+
+/* End of allocated space.  This is generally `round_page (_hurd_brk)'.  */
+
+extern vm_address_t _hurd_data_end;
+
+/* This mutex locks _hurd_brk and _hurd_data_end.  */
+
+extern struct mutex _hurd_brk_lock;
+
+/* Set the data break to NEWBRK; _hurd_brk_lock must
+   be held, and is released on return.  */
+
+extern int _hurd_set_brk (vm_address_t newbrk);
+
+#define __need_FILE
+#include <stdio.h>
+
+/* Calls to get and set basic ports.  */
+
+extern error_t _hurd_ports_get (unsigned int which, mach_port_t *result);
+extern error_t _hurd_ports_set (unsigned int which, mach_port_t newport);
+
+extern process_t getproc (void);
+extern file_t getcwdir (void), getcrdir (void);
+extern auth_t getauth (void);
+extern mach_port_t getcttyid (void);
+extern int setproc (process_t);
+extern int setcwdir (file_t), setcrdir (file_t);
+extern int setcttyid (mach_port_t);
+
+/* Does reauth with the proc server and fd io servers.  */
+extern int __setauth (auth_t), setauth (auth_t);
+
+
+/* Modify a port cell by looking up a directory name.
+   This verifies that it is a directory and that we have search permission.  */
+extern int _hurd_change_directory_port_from_name (struct hurd_port *portcell,
+						  const char *name);
+/* Same thing, but using an open file descriptor.
+   Also verifies that it is a directory and that we have search permission.  */
+extern int _hurd_change_directory_port_from_fd (struct hurd_port *portcell,
+						int fd);
+
+
+
+/* Get and set the effective UID set.  */
+extern int geteuids (int __n, uid_t *__uidset);
+extern int seteuids (int __n, const uid_t *__uidset);
+
+
+/* Split FILE into a directory and a name within the directory.  The
+   directory lookup uses the current root and working directory.  If
+   successful, stores in *NAME a pointer into FILE where the name
+   within directory begins and returns a port to the directory;
+   otherwise sets `errno' and returns MACH_PORT_NULL.  */
+
+extern file_t __file_name_split (const char *file, char **name);
+extern file_t file_name_split (const char *file, char **name);
+
+/* Split DIRECTORY into a parent directory and a name within the directory.
+   This is the same as file_name_split, but ignores trailing slashes.  */
+
+extern file_t __directory_name_split (const char *file, char **name);
+extern file_t directory_name_split (const char *file, char **name);
+
+/* Open a port to FILE with the given FLAGS and MODE (see <fcntl.h>).
+   The file lookup uses the current root and working directory.
+   Returns a port to the file if successful; otherwise sets `errno'
+   and returns MACH_PORT_NULL.  */
+
+extern file_t __file_name_lookup (const char *file, int flags, mode_t mode);
+extern file_t file_name_lookup (const char *file, int flags, mode_t mode);
+
+/* Open a port to FILE with the given FLAGS and MODE (see <fcntl.h>).  The
+   file lookup uses the current root directory, but uses STARTDIR as the
+   "working directory" for file relative names.  Returns a port to the file
+   if successful; otherwise sets `errno' and returns MACH_PORT_NULL.  */
+
+extern file_t __file_name_lookup_under (file_t startdir, const char *file,
+					int flags, mode_t mode);
+extern file_t file_name_lookup_under (file_t startdir, const char *file,
+				      int flags, mode_t mode);
+
+
+/* Lookup FILE_NAME and return the node opened with FLAGS & MODE
+   (see hurd_file_name_lookup for details), but a simple file name (without
+   any directory prefixes) will be consecutively prefixed with the pathnames
+   in the `:' separated list PATH until one succeeds in a successful lookup.
+   If none succeed, then the first error that wasn't ENOENT is returned, or
+   ENOENT if no other errors were returned.  If PREFIXED_NAME is non-NULL,
+   then if the result is looked up directly, *PREFIXED_NAME is set to NULL, and
+   if it is looked up using a prefix from PATH, *PREFIXED_NAME is set to
+   malloc'd storage containing the prefixed name.  */
+extern file_t file_name_path_lookup (const char *file_name, const char *path,
+				     int flags, mode_t mode,
+				     char **prefixed_name);
+
+
+
+/* Open a file descriptor on a port.  FLAGS are as for `open'; flags
+   affected by io_set_openmodes are not changed by this.  If successful,
+   this consumes a user reference for PORT (which will be deallocated on
+   close).  */
+
+extern int openport (io_t port, int flags);
+
+/* Open a stream on a port.  MODE is as for `fopen'.
+   If successful, this consumes a user reference for PORT
+   (which will be deallocated on fclose).  */
+
+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.  */
+
+extern error_t _hurd_exec (task_t task,
+			   file_t file,
+			   char *const argv[],
+			   char *const envp[]);
+
+
+/* Inform the proc server we have exited with STATUS, and kill the
+   task thoroughly.  This function never returns, no matter what.  */
+
+extern void _hurd_exit (int status) __attribute__ ((noreturn));
+
+
+/* Initialize the library data structures from the
+   ints and ports passed to us by the exec server.
+   Then vm_deallocate PORTARRAY and INTARRAY.  */
+
+extern void _hurd_init (int flags, char **argv,
+			mach_port_t *portarray, size_t portarraysize,
+			int *intarray, size_t intarraysize);
+
+/* Do startup handshaking with the proc server, and initialize library data
+   structures that require proc server interaction.  This includes
+   initializing signals; see _hurdsig_init in <hurd/signal.h>.  */
+
+extern void _hurd_proc_init (char **argv,
+			     const int *intarray, size_t intarraysize);
+
+
+/* Return the socket server for sockaddr domain DOMAIN.  If DEAD is
+   nonzero, remove the old cached port and always do a fresh lookup.
+
+   It is assumed that a socket server will stay alive during a complex socket
+   operation involving several RPCs.  But a socket server may die during
+   long idle periods between socket operations.  Callers should first pass
+   zero for DEAD; if the first socket RPC tried on the returned port fails
+   with MACH_SEND_INVALID_DEST or MIG_SERVER_DIED (indicating the server
+   went away), the caller should call _hurd_socket_server again with DEAD
+   nonzero and retry the RPC on the new socket server port.  */
+
+extern socket_t _hurd_socket_server (int domain, int dead);
+
+/* Send a `sig_post' RPC to process number PID.  If PID is zero,
+   send the message to all processes in the current process's process group.
+   If PID is < -1, send SIG to all processes in process group - PID.
+   SIG and REFPORT are passed along in the request message.  */
+
+extern error_t _hurd_sig_post (pid_t pid, int sig, mach_port_t refport);
+extern error_t hurd_sig_post (pid_t pid, int sig, mach_port_t refport);
+
+/* Fetch the host privileged port and device master port from the proc
+   server.  They are fetched only once and then cached in the
+   variables below.  A special program that gets them from somewhere
+   other than the proc server (such as a bootstrap filesystem) can set
+   these variables to install the ports.  */
+
+extern kern_return_t __get_privileged_ports (mach_port_t *host_priv_ptr,
+					     device_t *device_master_ptr);
+extern kern_return_t get_privileged_ports (mach_port_t *host_priv_ptr,
+					   device_t *device_master_ptr);
+extern mach_port_t _hurd_host_priv, _hurd_device_master;
+
+/* Return the PID of the task whose control port is TASK.
+   On error, sets `errno' and returns -1.  */
+
+extern pid_t __task2pid (task_t task), task2pid (task_t task);
+
+/* Return the task control port of process PID.
+   On error, sets `errno' and returns MACH_PORT_NULL.  */
+
+extern task_t __pid2task (pid_t pid), pid2task (pid_t pid);
+
+/* Return the current thread's thread port.  This is a cheap operation (no
+   system call), but it relies on Hurd signal state being set up.  */
+extern thread_t hurd_thread_self (void);
+
+
+/* Cancel pending operations on THREAD.  If it is doing an interruptible RPC,
+   that RPC will now return EINTR; otherwise, the "cancelled" flag will be
+   set, causing the next `hurd_check_cancel' call to return nonzero or the
+   next interruptible RPC to return EINTR (whichever is called first).  */
+extern error_t hurd_thread_cancel (thread_t thread);
+
+/* Test and clear the calling thread's "cancelled" flag.  */
+extern int hurd_check_cancel (void);
+
+
+/* Return the io server port for file descriptor FD.
+   This adds a Mach user reference to the returned port.
+   On error, sets `errno' and returns MACH_PORT_NULL.  */
+
+extern io_t __getdport (int fd), getdport (int fd);
+
+
+#include <stdarg.h>
+
+/* Write formatted output to PORT, a Mach port supporting the i/o protocol,
+   according to the format string FORMAT, using the argument list in ARG.  */
+int vpprintf (io_t port, const char *format, va_list arg);
+
+#endif
+#endif	/* hurd.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/hurdinit.c real-libc/hurd-l4/hurdinit.c
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/hurdinit.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/hurdinit.c	2003-05-19 15:55:39.000000000 +0200
@@ -0,0 +1,234 @@
+/* Copyright (C) 1992,93,94,95,96,97,98,99,2000,01
+   	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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#if 0
+#include <hurd.h>
+#include <hurd/port.h>
+#include "set-hooks.h"
+#include "hurdmalloc.h"		/* XXX */
+
+
+int _hurd_exec_flags;
+struct hurd_port *_hurd_ports;
+unsigned int _hurd_nports;
+#endif
+mode_t _hurd_umask;
+#if 0
+sigset_t _hurdsig_traced;
+#endif
+char **__libc_argv;
+int __libc_argc;
+
+
+#if 0
+error_t
+_hurd_ports_use (int which, error_t (*operate) (mach_port_t))
+{
+  if (__builtin_expect (_hurd_ports == NULL, 0))
+    /* This means that _hurd_init has not been called yet, which is
+       normally only the case in the bootstrap filesystem, and there
+       only in the early phases of booting.  */
+    return EGRATUITOUS;
+
+  return HURD_PORT_USE (&_hurd_ports[which], (*operate) (port));
+}
+
+DEFINE_HOOK (_hurd_subinit, (void));
+
+__typeof (_hurd_proc_init) _hurd_new_proc_init;	/* below */
+
+/* Initialize the library data structures from the
+   ints and ports passed to us by the exec server.
+
+   PORTARRAY and INTARRAY are vm_deallocate'd.  */
+
+void
+_hurd_init (int flags, char **argv,
+	    mach_port_t *portarray, size_t portarraysize,
+	    int *intarray, size_t intarraysize)
+{
+  size_t i;
+
+  _hurd_exec_flags = flags;
+
+  _hurd_ports = malloc (portarraysize * sizeof (*_hurd_ports));
+  if (_hurd_ports == NULL)
+    __libc_fatal ("Can't allocate _hurd_ports\n");
+  _hurd_nports = portarraysize;
+
+  /* See what ports we were passed.  */
+  for (i = 0; i < portarraysize; ++i)
+    _hurd_port_init (&_hurd_ports[i], portarray[i]);
+
+  /* When the user asks for the bootstrap port,
+     he will get the one the exec server passed us.  */
+  __task_set_special_port (__mach_task_self (), TASK_BOOTSTRAP_PORT,
+			   portarray[INIT_PORT_BOOTSTRAP]);
+
+  if (intarraysize > INIT_UMASK)
+    _hurd_umask = intarray[INIT_UMASK] & 0777;
+  else
+    _hurd_umask = CMASK;
+
+  if (intarraysize > INIT_TRACEMASK)
+    _hurdsig_traced = intarray[INIT_TRACEMASK];
+
+  /* Tell the proc server we exist, if it does.  */
+  if (portarray[INIT_PORT_PROC] != MACH_PORT_NULL)
+    _hurd_new_proc_init (argv, intarray, intarraysize);
+
+  /* All done with init ints and ports.  */
+  __vm_deallocate (__mach_task_self (),
+		   (vm_address_t) intarray,
+		   intarraysize * sizeof (int));
+  __vm_deallocate (__mach_task_self (),
+		   (vm_address_t) portarray,
+		   portarraysize * sizeof (mach_port_t));
+
+  if (flags & EXEC_SECURE)
+    /* XXX if secure exec, elide environment variables
+       which the library uses and could be security holes.
+       CORESERVER, COREFILE
+       */ ;
+
+  /* Call other things which want to do some initialization.  These are not
+     on the __libc_subinit hook because things there like to be able to
+     assume the availability of the POSIX.1 services we provide.  */
+  RUN_HOOK (_hurd_subinit, ());
+}
+
+#include <hurd/signal.h>
+
+/* The user can do "int _hide_arguments = 1;" to make
+   sure the arguments are never visible with `ps'.  */
+int _hide_arguments, _hide_environment;
+
+/* Hook for things which should be initialized as soon as the proc
+   server is available.  */
+DEFINE_HOOK (_hurd_proc_subinit, (void));
+
+/* Do startup handshaking with the proc server just installed in _hurd_ports.
+   Call _hurdsig_init to set up signal processing.  */
+
+void
+_hurd_new_proc_init (char **argv,
+		     const int *intarray, size_t intarraysize)
+{
+  mach_port_t oldmsg;
+  struct hurd_userlink ulink;
+  process_t procserver;
+
+  /* Initialize the signal code; Mach exceptions will become signals.  */
+  _hurdsig_init (intarray, intarraysize);
+
+  /* The signal thread is now prepared to receive messages.
+     It is safe to give the port to the proc server.  */
+
+  procserver = _hurd_port_get (&_hurd_ports[INIT_PORT_PROC], &ulink);
+
+  /* Give the proc server our message port.  */
+  __proc_setmsgport (procserver, _hurd_msgport, &oldmsg);
+  if (oldmsg != MACH_PORT_NULL)
+    /* Deallocate the old msg port we replaced.  */
+    __mach_port_deallocate (__mach_task_self (), oldmsg);
+
+  /* Tell the proc server where our args and environment are.  */
+  __proc_set_arg_locations (procserver,
+			    _hide_arguments ? 0 : (vm_address_t) argv,
+			    _hide_environment ? 0 : (vm_address_t) __environ);
+
+  _hurd_port_free (&_hurd_ports[INIT_PORT_PROC], &ulink, procserver);
+
+  /* Initialize proc server-assisted fault recovery for the signal thread.  */
+  _hurdsig_fault_init ();
+
+  /* Call other things which want to do some initialization.  These are not
+     on the _hurd_subinit hook because things there assume that things done
+     here, like _hurd_pid, are already initialized.  */
+  RUN_HOOK (_hurd_proc_subinit, ());
+
+  /* XXX This code should probably be removed entirely at some point.  This
+     conditional should make it reasonably usable with old gdb's for a
+     while.  Eventually it probably makes most sense for the exec server to
+     mask out EXEC_SIGTRAP so the debugged program is closer to not being
+     able to tell it's being debugged.  */
+  if (!__sigisemptyset (&_hurdsig_traced)
+#ifdef EXEC_SIGTRAP
+      && !(_hurd_exec_flags & EXEC_SIGTRAP)
+#endif
+      )
+    /* This process is "traced", meaning it should stop on signals or exec.
+       We are all set up now to handle signals.  Stop ourselves, to inform
+       our parent (presumably a debugger) that the exec has completed.  */
+    __msg_sig_post (_hurd_msgport, SIGTRAP, 0, __mach_task_self ());
+}
+
+#include <shlib-compat.h>
+versioned_symbol (libc, _hurd_new_proc_init, _hurd_proc_init, GLIBC_2_1);
+
+/* Called when we get a message telling us to change our proc server port.  */
+
+error_t
+_hurd_setproc (process_t procserver)
+{
+  error_t err;
+  mach_port_t oldmsg;
+
+  /* Give the proc server our message port.  */
+  if (err = __proc_setmsgport (procserver, _hurd_msgport, &oldmsg))
+    return err;
+  if (oldmsg != MACH_PORT_NULL)
+    /* Deallocate the old msg port we replaced.  */
+    __mach_port_deallocate (__mach_task_self (), oldmsg);
+
+  /* Tell the proc server where our args and environment are.  */
+  if (err = __proc_set_arg_locations (procserver,
+				      _hide_arguments ? 0 :
+				      (vm_address_t) __libc_argv,
+				      _hide_environment ? 0 :
+				      (vm_address_t) __environ))
+    return err;
+
+  /* Those calls worked, so the port looks good.  */
+  _hurd_port_set (&_hurd_ports[INIT_PORT_PROC], procserver);
+
+  {
+    pid_t oldpgrp = _hurd_pgrp;
+
+    /* Call these functions again so they can fetch the
+       new information from the new proc server.  */
+    RUN_HOOK (_hurd_proc_subinit, ());
+
+    if (_hurd_pgrp != oldpgrp)
+      {
+	/* Run things that want notification of a pgrp change.  */
+	DECLARE_HOOK (_hurd_pgrp_changed_hook, (pid_t));
+	RUN_HOOK (_hurd_pgrp_changed_hook, (_hurd_pgrp));
+      }
+  }
+
+  return 0;
+}
+#endif
+
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/hurdsig.c real-libc/hurd-l4/hurdsig.c
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/hurdsig.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/hurdsig.c	2003-05-19 15:46:59.000000000 +0200
@@ -0,0 +1,1404 @@
+/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000,01,2002
+   	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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#if 0
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <cthreads.h>		/* For `struct mutex'.  */
+#include <mach.h>
+#include <mach/thread_switch.h>
+
+#include <hurd.h>
+#include <hurd/id.h>
+#include <hurd/signal.h>
+
+#include "hurdfault.h"
+#include "hurdmalloc.h"		/* XXX */
+#include "../locale/localeinfo.h"
+
+const char *_hurdsig_getenv (const char *);
+
+struct mutex _hurd_siglock;
+int _hurd_stopped;
+
+/* Port that receives signals and other miscellaneous messages.  */
+mach_port_t _hurd_msgport;
+
+/* Thread listening on it.  */
+thread_t _hurd_msgport_thread;
+
+/* Thread which receives task-global signals.  */
+thread_t _hurd_sigthread;
+
+#endif
+
+/* 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;
+
+#if 0
+/* Linked-list of per-thread signal state.  */
+struct hurd_sigstate *_hurd_sigstates;
+
+/* Timeout for RPC's after interrupt_operation. */
+mach_msg_timeout_t _hurd_interrupted_rpc_timeout = 3000;
+
+static void
+default_sigaction (struct sigaction actions[NSIG])
+{
+  int signo;
+
+  __sigemptyset (&actions[0].sa_mask);
+  actions[0].sa_flags = SA_RESTART;
+  actions[0].sa_handler = SIG_DFL;
+
+  for (signo = 1; signo < NSIG; ++signo)
+    actions[signo] = actions[0];
+}
+
+struct hurd_sigstate *
+_hurd_thread_sigstate (thread_t thread)
+{
+  struct hurd_sigstate *ss;
+  __mutex_lock (&_hurd_siglock);
+  for (ss = _hurd_sigstates; ss != NULL; ss = ss->next)
+    if (ss->thread == thread)
+       break;
+  if (ss == NULL)
+    {
+      ss = malloc (sizeof (*ss));
+      if (ss == NULL)
+	__libc_fatal ("hurd: Can't allocate thread sigstate\n");
+      ss->thread = thread;
+      __spin_lock_init (&ss->lock);
+
+      /* Initialize default state.  */
+      __sigemptyset (&ss->blocked);
+      __sigemptyset (&ss->pending);
+      memset (&ss->sigaltstack, 0, sizeof (ss->sigaltstack));
+      ss->preemptors = NULL;
+      ss->suspended = MACH_PORT_NULL;
+      ss->intr_port = MACH_PORT_NULL;
+      ss->context = NULL;
+
+      /* Initialize the sigaction vector from the default signal receiving
+	 thread's state, and its from the system defaults.  */
+      if (thread == _hurd_sigthread)
+	default_sigaction (ss->actions);
+      else
+	{
+	  struct hurd_sigstate *s;
+	  for (s = _hurd_sigstates; s != NULL; s = s->next)
+	    if (s->thread == _hurd_sigthread)
+	      break;
+	  if (s)
+	    {
+	      __spin_lock (&s->lock);
+	      memcpy (ss->actions, s->actions, sizeof (s->actions));
+	      __spin_unlock (&s->lock);
+	    }
+	  else
+	    default_sigaction (ss->actions);
+	}
+
+      ss->next = _hurd_sigstates;
+      _hurd_sigstates = ss;
+    }
+  __mutex_unlock (&_hurd_siglock);
+  return ss;
+}
+
+/* Signal delivery itself is on this page.  */
+
+#include <hurd/fd.h>
+#include <hurd/crash.h>
+#include <hurd/resource.h>
+#include <hurd/paths.h>
+#include <setjmp.h>
+#include <fcntl.h>
+#include <sys/wait.h>
+#include "thread_state.h"
+#include <hurd/msg_server.h>
+#include <hurd/msg_reply.h>	/* For __msg_sig_post_reply.  */
+#include <hurd/interrupt.h>
+#include <assert.h>
+#include <unistd.h>
+
+
+/* Call the crash dump server to mummify us before we die.
+   Returns nonzero if a core file was written.  */
+static int
+write_corefile (int signo, const struct hurd_signal_detail *detail)
+{
+  error_t err;
+  mach_port_t coreserver;
+  file_t file, coredir;
+  const char *name;
+
+  /* Don't bother locking since we just read the one word.  */
+  rlim_t corelimit = _hurd_rlimits[RLIMIT_CORE].rlim_cur;
+
+  if (corelimit == 0)
+    /* No core dumping, thank you very much.  Note that this makes
+       `ulimit -c 0' prevent crash-suspension too, which is probably
+       what the user wanted.  */
+    return 0;
+
+  /* XXX RLIMIT_CORE:
+     When we have a protocol to make the server return an error
+     for RLIMIT_FSIZE, then tell the corefile fs server the RLIMIT_CORE
+     value in place of the RLIMIT_FSIZE value.  */
+
+  /* First get a port to the core dumping server.  */
+  coreserver = MACH_PORT_NULL;
+  name = _hurdsig_getenv ("CRASHSERVER");
+  if (name != NULL)
+    coreserver = __file_name_lookup (name, 0, 0);
+  if (coreserver == MACH_PORT_NULL)
+    coreserver = __file_name_lookup (_SERVERS_CRASH, 0, 0);
+  if (coreserver == MACH_PORT_NULL)
+    return 0;
+
+  /* Get a port to the directory where the new core file will reside.  */
+  file = MACH_PORT_NULL;
+  name = _hurdsig_getenv ("COREFILE");
+  if (name == NULL)
+    name = "core";
+  coredir = __file_name_split (name, (char **) &name);
+  if (coredir != MACH_PORT_NULL)
+    /* Create the new file, but don't link it into the directory yet.  */
+    __dir_mkfile (coredir, O_WRONLY|O_CREAT,
+		  0600 & ~_hurd_umask, /* XXX ? */
+		  &file);
+
+  /* Call the core dumping server to write the core file.  */
+  err = __crash_dump_task (coreserver,
+			   __mach_task_self (),
+			   file,
+			   signo, detail->code, detail->error,
+			   detail->exc, detail->exc_code, detail->exc_subcode,
+			   _hurd_ports[INIT_PORT_CTTYID].port,
+			   MACH_MSG_TYPE_COPY_SEND);
+  __mach_port_deallocate (__mach_task_self (), coreserver);
+
+  if (! err && file != MACH_PORT_NULL)
+    /* The core dump into FILE succeeded, so now link it into the
+       directory.  */
+    err = __dir_link (coredir, file, name, 1);
+  __mach_port_deallocate (__mach_task_self (), file);
+  __mach_port_deallocate (__mach_task_self (), coredir);
+  return !err && file != MACH_PORT_NULL;
+}
+
+
+/* The lowest-numbered thread state flavor value is 1,
+   so we use bit 0 in machine_thread_all_state.set to
+   record whether we have done thread_abort.  */
+#define THREAD_ABORTED 1
+
+/* SS->thread is suspended.  Abort the thread and get its basic state.  */
+static void
+abort_thread (struct hurd_sigstate *ss, struct machine_thread_all_state *state,
+	      void (*reply) (void))
+{
+  if (!(state->set & THREAD_ABORTED))
+    {
+      error_t err = __thread_abort (ss->thread);
+      assert_perror (err);
+      /* Clear all thread state flavor set bits, because thread_abort may
+	 have changed the state.  */
+      state->set = THREAD_ABORTED;
+    }
+
+  if (reply)
+    (*reply) ();
+
+  machine_get_basic_state (ss->thread, state);
+}
+
+/* Find the location of the MiG reply port cell in use by the thread whose
+   state is described by THREAD_STATE.  If SIGTHREAD is nonzero, make sure
+   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,
+				 int sigthread)
+{
+  mach_port_t *portloc = (mach_port_t *) __hurd_threadvar_location_from_sp
+    (_HURD_THREADVAR_MIG_REPLY, (void *) thread_state->basic.SP);
+
+  if (sigthread && _hurdsig_catch_memory_fault (portloc))
+    /* Faulted trying to read the stack.  */
+    return NULL;
+
+  /* Fault now if this pointer is bogus.  */
+  *(volatile mach_port_t *) portloc = *portloc;
+
+  if (sigthread)
+    _hurdsig_end_catch_fault ();
+
+  return portloc;
+}
+
+#include <hurd/sigpreempt.h>
+#include "intr-msg.h"
+
+/* Timeout on interrupt_operation calls.  */
+mach_msg_timeout_t _hurdsig_interrupt_timeout = 1000;
+
+/* SS->thread is suspended.
+
+   Abort any interruptible RPC operation the thread is doing.
+
+   This uses only the constant member SS->thread and the unlocked, atomically
+   set member SS->intr_port, so no locking is needed.
+
+   If successfully sent an interrupt_operation and therefore the thread should
+   wait for its pending RPC to return (possibly EINTR) before taking the
+   incoming signal, returns the reply port to be received on.  Otherwise
+   returns MACH_PORT_NULL.
+
+   SIGNO is used to find the applicable SA_RESTART bit.  If SIGNO is zero,
+   the RPC fails with EINTR instead of restarting (thread_cancel).
+
+   *STATE_CHANGE is set nonzero if STATE->basic was modified and should
+   be applied back to the thread if it might ever run again, else zero.  */
+
+mach_port_t
+_hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread,
+		     struct machine_thread_all_state *state, int *state_change,
+		     void (*reply) (void))
+{
+  extern const void _hurd_intr_rpc_msg_in_trap;
+  mach_port_t rcv_port = MACH_PORT_NULL;
+  mach_port_t intr_port;
+
+  *state_change = 0;
+
+  intr_port = ss->intr_port;
+  if (intr_port == MACH_PORT_NULL)
+    /* No interruption needs done.  */
+    return MACH_PORT_NULL;
+
+  /* Abort the thread's kernel context, so any pending message send or
+     receive completes immediately or aborts.  */
+  abort_thread (ss, state, reply);
+
+  if (state->basic.PC < (natural_t) &_hurd_intr_rpc_msg_in_trap)
+    {
+      /* The thread is about to do the RPC, but hasn't yet entered
+	 mach_msg.  Mutate the thread's state so it knows not to try
+	 the RPC.  */
+      INTR_MSG_BACK_OUT (&state->basic);
+      MACHINE_THREAD_STATE_SET_PC (&state->basic,
+				   &_hurd_intr_rpc_msg_in_trap);
+      state->basic.SYSRETURN = MACH_SEND_INTERRUPTED;
+      *state_change = 1;
+    }
+  else if (state->basic.PC == (natural_t) &_hurd_intr_rpc_msg_in_trap &&
+	   /* The thread was blocked in the system call.  After thread_abort,
+	      the return value register indicates what state the RPC was in
+	      when interrupted.  */
+	   state->basic.SYSRETURN == MACH_RCV_INTERRUPTED)
+      {
+	/* The RPC request message was sent and the thread was waiting for
+	   the reply message; now the message receive has been aborted, so
+	   the mach_msg call will return MACH_RCV_INTERRUPTED.  We must tell
+	   the server to interrupt the pending operation.  The thread must
+	   wait for the reply message before running the signal handler (to
+	   guarantee that the operation has finished being interrupted), so
+	   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,
+							      sigthread);
+	error_t err = __interrupt_operation (intr_port, _hurdsig_interrupt_timeout);
+
+	if (err)
+	  {
+	    if (reply)
+	      {
+		/* The interrupt didn't work.
+		   Destroy the receive right the thread is blocked on.  */
+		__mach_port_destroy (__mach_task_self (), *reply);
+		*reply = MACH_PORT_NULL;
+	      }
+
+	    /* The system call return value register now contains
+	       MACH_RCV_INTERRUPTED; when mach_msg resumes, it will retry the
+	       call.  Since we have just destroyed the receive right, the
+	       retry will fail with MACH_RCV_INVALID_NAME.  Instead, just
+	       change the return value here to EINTR so mach_msg will not
+	       retry and the EINTR error code will propagate up.  */
+	    state->basic.SYSRETURN = EINTR;
+	    *state_change = 1;
+	  }
+	else if (reply)
+	  rcv_port = *reply;
+
+	/* All threads whose RPCs were interrupted by the interrupt_operation
+	   call above will retry their RPCs unless we clear SS->intr_port.
+	   So we clear it for the thread taking a signal when SA_RESTART is
+	   clear, so that its call returns EINTR.  */
+	if (! signo || !(ss->actions[signo].sa_flags & SA_RESTART))
+	  ss->intr_port = MACH_PORT_NULL;
+      }
+
+  return rcv_port;
+}
+
+
+/* Abort the RPCs being run by all threads but this one;
+   all other threads should be suspended.  If LIVE is nonzero, those
+   threads may run again, so they should be adjusted as necessary to be
+   happy when resumed.  STATE is clobbered as a scratch area; its initial
+   contents are ignored, and its contents on return are not useful.  */
+
+static void
+abort_all_rpcs (int signo, struct machine_thread_all_state *state, int live)
+{
+  /* We can just loop over the sigstates.  Any thread doing something
+     interruptible must have one.  We needn't bother locking because all
+     other threads are stopped.  */
+
+  struct hurd_sigstate *ss;
+  size_t nthreads;
+  mach_port_t *reply_ports;
+
+  /* First loop over the sigstates to count them.
+     We need to know how big a vector we will need for REPLY_PORTS.  */
+  nthreads = 0;
+  for (ss = _hurd_sigstates; ss != NULL; ss = ss->next)
+    ++nthreads;
+
+  reply_ports = alloca (nthreads * sizeof *reply_ports);
+
+  nthreads = 0;
+  for (ss = _hurd_sigstates; ss != NULL; ss = ss->next, ++nthreads)
+    if (ss->thread == _hurd_msgport_thread)
+      reply_ports[nthreads] = MACH_PORT_NULL;
+    else
+      {
+	int state_changed;
+	state->set = 0;		/* Reset scratch area.  */
+
+	/* Abort any operation in progress with interrupt_operation.
+	   Record the reply port the thread is waiting on.
+	   We will wait for all the replies below.  */
+	reply_ports[nthreads] = _hurdsig_abort_rpcs (ss, signo, 1,
+						     state, &state_changed,
+						     NULL);
+	if (live)
+	  {
+	    if (reply_ports[nthreads] != MACH_PORT_NULL)
+	      {
+		/* We will wait for the reply to this RPC below, so the
+		   thread must issue a new RPC rather than waiting for the
+		   reply to the one it sent.  */
+		state->basic.SYSRETURN = EINTR;
+		state_changed = 1;
+	      }
+	    if (state_changed)
+	      /* Aborting the RPC needed to change this thread's state,
+		 and it might ever run again.  So write back its state.  */
+	      __thread_set_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR,
+				  (natural_t *) &state->basic,
+				  MACHINE_THREAD_STATE_COUNT);
+	  }
+      }
+
+  /* Wait for replies from all the successfully interrupted RPCs.  */
+  while (nthreads-- > 0)
+    if (reply_ports[nthreads] != MACH_PORT_NULL)
+      {
+	error_t err;
+	mach_msg_header_t head;
+	err = __mach_msg (&head, MACH_RCV_MSG|MACH_RCV_TIMEOUT, 0, sizeof head,
+			  reply_ports[nthreads],
+			  _hurd_interrupted_rpc_timeout, MACH_PORT_NULL);
+	switch (err)
+	  {
+	  case MACH_RCV_TIMED_OUT:
+	  case MACH_RCV_TOO_LARGE:
+	    break;
+
+	  default:
+	    assert_perror (err);
+	  }
+      }
+}
+
+struct hurd_signal_preemptor *_hurdsig_preemptors = 0;
+sigset_t _hurdsig_preempted_set;
+
+/* XXX temporary to deal with spelling fix */
+weak_alias (_hurdsig_preemptors, _hurdsig_preempters)
+
+/* Mask of stop signals.  */
+#define STOPSIGS (sigmask (SIGTTIN) | sigmask (SIGTTOU) | \
+		  sigmask (SIGSTOP) | sigmask (SIGTSTP))
+
+/* Deliver a signal.  SS is not locked.  */
+void
+_hurd_internal_post_signal (struct hurd_sigstate *ss,
+			    int signo, struct hurd_signal_detail *detail,
+			    mach_port_t reply_port,
+			    mach_msg_type_name_t reply_port_type,
+			    int untraced)
+{
+  error_t err;
+  struct machine_thread_all_state thread_state;
+  enum { stop, ignore, core, term, handle } act;
+  sighandler_t handler;
+  sigset_t pending;
+  int ss_suspended;
+
+  /* Reply to this sig_post message.  */
+  __typeof (__msg_sig_post_reply) *reply_rpc
+    = (untraced ? __msg_sig_post_untraced_reply : __msg_sig_post_reply);
+  void reply (void)
+    {
+      error_t err;
+      if (reply_port == MACH_PORT_NULL)
+	return;
+      err = (*reply_rpc) (reply_port, reply_port_type, 0);
+      reply_port = MACH_PORT_NULL;
+      if (err != MACH_SEND_INVALID_DEST) /* Ignore dead reply port.  */
+	assert_perror (err);
+    }
+
+  /* Mark the signal as pending.  */
+  void mark_pending (void)
+    {
+      __sigaddset (&ss->pending, signo);
+      /* Save the details to be given to the handler when SIGNO is
+	 unblocked.  */
+      ss->pending_data[signo] = *detail;
+    }
+
+  /* Suspend the process with SIGNO.  */
+  void suspend (void)
+    {
+      /* Stop all other threads and mark ourselves stopped.  */
+      __USEPORT (PROC,
+		 ({
+		   /* Hold the siglock while stopping other threads to be
+		      sure it is not held by another thread afterwards.  */
+		   __mutex_lock (&_hurd_siglock);
+		   __proc_dostop (port, _hurd_msgport_thread);
+		   __mutex_unlock (&_hurd_siglock);
+		   abort_all_rpcs (signo, &thread_state, 1);
+		   reply ();
+		   __proc_mark_stop (port, signo, detail->code);
+		 }));
+      _hurd_stopped = 1;
+    }
+  /* Resume the process after a suspension.  */
+  void resume (void)
+    {
+      /* Resume the process from being stopped.  */
+      thread_t *threads;
+      mach_msg_type_number_t nthreads, i;
+      error_t err;
+
+      if (! _hurd_stopped)
+	return;
+
+      /* Tell the proc server we are continuing.  */
+      __USEPORT (PROC, __proc_mark_cont (port));
+      /* Fetch ports to all our threads and resume them.  */
+      err = __task_threads (__mach_task_self (), &threads, &nthreads);
+      assert_perror (err);
+      for (i = 0; i < nthreads; ++i)
+	{
+	  if (threads[i] != _hurd_msgport_thread &&
+	      (act != handle || threads[i] != ss->thread))
+	    {
+	      err = __thread_resume (threads[i]);
+	      assert_perror (err);
+	    }
+	  err = __mach_port_deallocate (__mach_task_self (),
+					threads[i]);
+	  assert_perror (err);
+	}
+      __vm_deallocate (__mach_task_self (),
+		       (vm_address_t) threads,
+		       nthreads * sizeof *threads);
+      _hurd_stopped = 0;
+      if (act == handle)
+	/* The thread that will run the handler is already suspended.  */
+	ss_suspended = 1;
+    }
+
+  if (signo == 0)
+    {
+      if (untraced)
+	/* This is PTRACE_CONTINUE.  */
+	resume ();
+
+      /* This call is just to check for pending signals.  */
+      __spin_lock (&ss->lock);
+      goto check_pending_signals;
+    }
+
+ post_signal:
+
+  thread_state.set = 0;		/* We know nothing.  */
+
+  __spin_lock (&ss->lock);
+
+  /* Check for a preempted signal.  Preempted signals can arrive during
+     critical sections.  */
+  {
+    inline sighandler_t try_preemptor (struct hurd_signal_preemptor *pe)
+      {				/* PE cannot be null.  */
+	do
+	  {
+	    if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->code))
+	      {
+		if (pe->preemptor)
+		  {
+		    sighandler_t handler = (*pe->preemptor) (pe, ss,
+							     &signo, detail);
+		    if (handler != SIG_ERR)
+		      return handler;
+		  }
+		else
+		  return pe->handler;
+	      }
+	    pe = pe->next;
+	  } while (pe != 0);
+	return SIG_ERR;
+      }
+
+    handler = ss->preemptors ? try_preemptor (ss->preemptors) : SIG_ERR;
+
+    /* If no thread-specific preemptor, check for a global one.  */
+    if (handler == SIG_ERR && __sigismember (&_hurdsig_preempted_set, signo))
+      {
+	__mutex_lock (&_hurd_siglock);
+	handler = try_preemptor (_hurdsig_preemptors);
+	__mutex_unlock (&_hurd_siglock);
+      }
+  }
+
+  ss_suspended = 0;
+
+  if (handler == SIG_IGN)
+    /* Ignore the signal altogether.  */
+    act = ignore;
+  else if (handler != SIG_ERR)
+    /* Run the preemption-provided handler.  */
+    act = handle;
+  else
+    {
+      /* No preemption.  Do normal handling.  */
+
+      if (!untraced && __sigismember (&_hurdsig_traced, signo))
+	{
+	  /* We are being traced.  Stop to tell the debugger of the signal.  */
+	  if (_hurd_stopped)
+	    /* Already stopped.  Mark the signal as pending;
+	       when resumed, we will notice it and stop again.  */
+	    mark_pending ();
+	  else
+	    suspend ();
+	  __spin_unlock (&ss->lock);
+	  reply ();
+	  return;
+	}
+
+      handler = ss->actions[signo].sa_handler;
+
+      if (handler == SIG_DFL)
+	/* Figure out the default action for this signal.  */
+	switch (signo)
+	  {
+	  case 0:
+	    /* A sig_post msg with SIGNO==0 is sent to
+	       tell us to check for pending signals.  */
+	    act = ignore;
+	    break;
+
+	  case SIGTTIN:
+	  case SIGTTOU:
+	  case SIGSTOP:
+	  case SIGTSTP:
+	    act = stop;
+	    break;
+
+	  case SIGCONT:
+	  case SIGIO:
+	  case SIGURG:
+	  case SIGCHLD:
+	  case SIGWINCH:
+	    act = ignore;
+	    break;
+
+	  case SIGQUIT:
+	  case SIGILL:
+	  case SIGTRAP:
+	  case SIGIOT:
+	  case SIGEMT:
+	  case SIGFPE:
+	  case SIGBUS:
+	  case SIGSEGV:
+	  case SIGSYS:
+	    act = core;
+	    break;
+
+	  case SIGINFO:
+	    if (_hurd_pgrp == _hurd_pid)
+	      {
+		/* We are the process group leader.  Since there is no
+		   user-specified handler for SIGINFO, we use a default one
+		   which prints something interesting.  We use the normal
+		   handler mechanism instead of just doing it here to avoid
+		   the signal thread faulting or blocking in this
+		   potentially hairy operation.  */
+		act = handle;
+		handler = _hurd_siginfo_handler;
+	      }
+	    else
+	      act = ignore;
+	    break;
+
+	  default:
+	    act = term;
+	    break;
+	  }
+      else if (handler == SIG_IGN)
+	act = ignore;
+      else
+	act = handle;
+
+      if (__sigmask (signo) & STOPSIGS)
+	/* Stop signals clear a pending SIGCONT even if they
+	   are handled or ignored (but not if preempted).  */
+	__sigdelset (&ss->pending, SIGCONT);
+      else
+	{
+	  if (signo == SIGCONT)
+	    /* Even if handled or ignored (but not preempted), SIGCONT clears
+	       stop signals and resumes the process.  */
+	    ss->pending &= ~STOPSIGS;
+
+	  if (_hurd_stopped && act != stop && (untraced || signo == SIGCONT))
+	    resume ();
+	}
+    }
+
+  if (_hurd_orphaned && act == stop &&
+      (__sigmask (signo) & (__sigmask (SIGTTIN) | __sigmask (SIGTTOU) |
+			    __sigmask (SIGTSTP))))
+    {
+      /* If we would ordinarily stop for a job control signal, but we are
+	 orphaned so noone would ever notice and continue us again, we just
+	 quietly die, alone and in the dark.  */
+      detail->code = signo;
+      signo = SIGKILL;
+      act = term;
+    }
+
+  /* Handle receipt of a blocked signal, or any signal while stopped.  */
+  if (act != ignore &&		/* Signals ignored now are forgotten now.  */
+      __sigismember (&ss->blocked, signo) ||
+      (signo != SIGKILL && _hurd_stopped))
+    {
+      mark_pending ();
+      act = ignore;
+    }
+
+  /* Perform the chosen action for the signal.  */
+  switch (act)
+    {
+    case stop:
+      if (_hurd_stopped)
+	{
+	  /* We are already stopped, but receiving an untraced stop
+	     signal.  Instead of resuming and suspending again, just
+	     notify the proc server of the new stop signal.  */
+	  error_t err = __USEPORT (PROC, __proc_mark_stop
+				   (port, signo, detail->code));
+	  assert_perror (err);
+	}
+      else
+	/* Suspend the process.  */
+	suspend ();
+      break;
+
+    case ignore:
+      /* Nobody cares about this signal.  If there was a call to resume
+	 above in SIGCONT processing and we've left a thread suspended,
+	 now's the time to set it going. */
+      if (ss_suspended)
+	{
+	  err = __thread_resume (ss->thread);
+	  assert_perror (err);
+	  ss_suspended = 0;
+	}
+      break;
+
+    sigbomb:
+      /* We got a fault setting up the stack frame for the handler.
+	 Nothing to do but die; BSD gets SIGILL in this case.  */
+      detail->code = signo;	/* XXX ? */
+      signo = SIGILL;
+      act = core;
+      /* FALLTHROUGH */
+
+    case term:			/* Time to die.  */
+    case core:			/* And leave a rotting corpse.  */
+      /* Have the proc server stop all other threads in our task.  */
+      err = __USEPORT (PROC, __proc_dostop (port, _hurd_msgport_thread));
+      assert_perror (err);
+      /* No more user instructions will be executed.
+	 The signal can now be considered delivered.  */
+      reply ();
+      /* Abort all server operations now in progress.  */
+      abort_all_rpcs (signo, &thread_state, 0);
+
+      {
+	int status = W_EXITCODE (0, signo);
+	/* Do a core dump if desired.  Only set the wait status bit saying we
+	   in fact dumped core if the operation was actually successful.  */
+	if (act == core && write_corefile (signo, detail))
+	  status |= WCOREFLAG;
+	/* Tell proc how we died and then stick the saber in the gut.  */
+	_hurd_exit (status);
+	/* NOTREACHED */
+      }
+
+    case handle:
+      /* Call a handler for this signal.  */
+      {
+	struct sigcontext *scp, ocontext;
+	int wait_for_reply, state_changed;
+
+	/* Stop the thread and abort its pending RPC operations.  */
+	if (! ss_suspended)
+	  {
+	    err = __thread_suspend (ss->thread);
+	    assert_perror (err);
+	  }
+
+	/* Abort the thread's kernel context, so any pending message send
+	   or receive completes immediately or aborts.  If an interruptible
+	   RPC is in progress, abort_rpcs will do this.  But we must always
+	   do it before fetching the thread's state, because
+	   thread_get_state is never kosher before thread_abort.  */
+	abort_thread (ss, &thread_state, NULL);
+
+	if (ss->context)
+	  {
+	    /* We have a previous sigcontext that sigreturn was about
+	       to restore when another signal arrived.  */
+
+	    mach_port_t *loc;
+
+	    if (_hurdsig_catch_memory_fault (ss->context))
+	      {
+		/* We faulted reading the thread's stack.  Forget that
+		   context and pretend it wasn't there.  It almost
+		   certainly crash if this handler returns, but that's it's
+		   problem.  */
+		ss->context = NULL;
+	      }
+	    else
+	      {
+		/* Copy the context from the thread's stack before
+		   we start diddling the stack to set up the handler.  */
+		ocontext = *ss->context;
+		ss->context = &ocontext;
+	      }
+	    _hurdsig_end_catch_fault ();
+
+	    if (! machine_get_basic_state (ss->thread, &thread_state))
+	      goto sigbomb;
+	    loc = interrupted_reply_port_location (&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
+		 and restoring SS->context instead, destroy this port.  */
+	      __mach_port_destroy (__mach_task_self (), *loc);
+
+	    /* The thread was in sigreturn, not in any interruptible RPC.  */
+	    wait_for_reply = 0;
+
+	    assert (! __spin_lock_locked (&ss->critical_section_lock));
+	  }
+	else
+	  {
+	    int crit = __spin_lock_locked (&ss->critical_section_lock);
+
+	    wait_for_reply
+	      = (_hurdsig_abort_rpcs (ss,
+				      /* In a critical section, any RPC
+					 should be cancelled instead of
+					 restarted, regardless of
+					 SA_RESTART, so the entire
+					 "atomic" operation can be aborted
+					 as a unit.  */
+				      crit ? 0 : signo, 1,
+				      &thread_state, &state_changed,
+				      &reply)
+		 != MACH_PORT_NULL);
+
+	    if (crit)
+	      {
+		/* The thread is in a critical section.  Mark the signal as
+		   pending.  When it finishes the critical section, it will
+		   check for pending signals.  */
+		mark_pending ();
+		if (state_changed)
+		  /* Some cases of interrupting an RPC must change the
+		     thread state to back out the call.  Normally this
+		     change is rolled into the warping to the handler and
+		     sigreturn, but we are not running the handler now
+		     because the thread is in a critical section.  Instead,
+		     mutate the thread right away for the RPC interruption
+		     and resume it; the RPC will return early so the
+		     critical section can end soon.  */
+		  __thread_set_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR,
+				      (natural_t *) &thread_state.basic,
+				      MACHINE_THREAD_STATE_COUNT);
+		/* */
+		ss->intr_port = MACH_PORT_NULL;
+		__thread_resume (ss->thread);
+		break;
+	      }
+	  }
+
+	/* Call the machine-dependent function to set the thread up
+	   to run the signal handler, and preserve its old context.  */
+	scp = _hurd_setup_sighandler (ss, handler, signo, detail,
+				      wait_for_reply, &thread_state);
+	if (scp == NULL)
+	  goto sigbomb;
+
+	/* Set the machine-independent parts of the signal context.  */
+
+	{
+	  /* 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,
+							      1);
+	  if (loc)
+	    {
+	      scp->sc_reply_port = *loc;
+	      *loc = MACH_PORT_NULL;
+	    }
+	  else
+	    scp->sc_reply_port = MACH_PORT_NULL;
+
+	  /* Save the intr_port in use by the interrupted code,
+	     and clear the cell before running the trampoline.  */
+	  scp->sc_intr_port = ss->intr_port;
+	  ss->intr_port = MACH_PORT_NULL;
+
+	  if (ss->context)
+	    {
+	      /* After the handler runs we will restore to the state in
+		 SS->context, not the state of the thread now.  So restore
+		 that context's reply port and intr port.  */
+
+	      scp->sc_reply_port = ss->context->sc_reply_port;
+	      scp->sc_intr_port = ss->context->sc_intr_port;
+
+	      ss->context = NULL;
+	    }
+	}
+
+	/* Backdoor extra argument to signal handler.  */
+	scp->sc_error = detail->error;
+
+	/* Block requested signals while running the handler.  */
+	scp->sc_mask = ss->blocked;
+	__sigorset (&ss->blocked, &ss->blocked, &ss->actions[signo].sa_mask);
+
+	/* Also block SIGNO unless we're asked not to.  */
+	if (! (ss->actions[signo].sa_flags & (SA_RESETHAND | SA_NODEFER)))
+	  __sigaddset (&ss->blocked, signo);
+
+	/* Reset to SIG_DFL if requested.  SIGILL and SIGTRAP cannot
+           be automatically reset when delivered; the system silently
+           enforces this restriction.  */
+	if (ss->actions[signo].sa_flags & SA_RESETHAND
+	    && signo != SIGILL && signo != SIGTRAP)
+	  ss->actions[signo].sa_handler = SIG_DFL;
+
+	/* Start the thread running the handler (or possibly waiting for an
+	   RPC reply before running the handler).  */
+	err = __thread_set_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR,
+				  (natural_t *) &thread_state.basic,
+				  MACHINE_THREAD_STATE_COUNT);
+	assert_perror (err);
+	err = __thread_resume (ss->thread);
+	assert_perror (err);
+	thread_state.set = 0;	/* Everything we know is now wrong.  */
+	break;
+      }
+    }
+
+  /* The signal has either been ignored or is now being handled.  We can
+     consider it delivered and reply to the killer.  */
+  reply ();
+
+  /* We get here unless the signal was fatal.  We still hold SS->lock.
+     Check for pending signals, and loop to post them.  */
+  {
+    /* Return nonzero if SS has any signals pending we should worry about.
+       We don't worry about any pending signals if we are stopped, nor if
+       SS is in a critical section.  We are guaranteed to get a sig_post
+       message before any of them become deliverable: either the SIGCONT
+       signal, or a sig_post with SIGNO==0 as an explicit poll when the
+       thread finishes its critical section.  */
+    inline int signals_pending (void)
+      {
+	if (_hurd_stopped || __spin_lock_locked (&ss->critical_section_lock))
+	  return 0;
+	return pending = ss->pending & ~ss->blocked;
+      }
+
+  check_pending_signals:
+    untraced = 0;
+
+    if (signals_pending ())
+      {
+	for (signo = 1; signo < NSIG; ++signo)
+	  if (__sigismember (&pending, signo))
+	    {
+	    deliver_pending:
+	      __sigdelset (&ss->pending, signo);
+	      *detail = ss->pending_data[signo];
+	      __spin_unlock (&ss->lock);
+	      goto post_signal;
+	    }
+      }
+
+    /* No pending signals left undelivered for this thread.
+       If we were sent signal 0, we need to check for pending
+       signals for all threads.  */
+    if (signo == 0)
+      {
+	__spin_unlock (&ss->lock);
+	__mutex_lock (&_hurd_siglock);
+	for (ss = _hurd_sigstates; ss != NULL; ss = ss->next)
+	  {
+	    __spin_lock (&ss->lock);
+	    for (signo = 1; signo < NSIG; ++signo)
+	      if (__sigismember (&ss->pending, signo)
+		  && (!__sigismember (&ss->blocked, signo)
+		      /* We "deliver" immediately pending blocked signals whose
+			 action might be to ignore, so that if ignored they are
+			 dropped right away.  */
+		      || ss->actions[signo].sa_handler == SIG_IGN
+		      || ss->actions[signo].sa_handler == SIG_DFL))
+		{
+		  mutex_unlock (&_hurd_siglock);
+		  goto deliver_pending;
+		}
+	    __spin_unlock (&ss->lock);
+	  }
+	__mutex_unlock (&_hurd_siglock);
+      }
+    else
+      {
+	/* No more signals pending; SS->lock is still locked.
+	   Wake up any sigsuspend call that is blocking SS->thread.  */
+	if (ss->suspended != MACH_PORT_NULL)
+	  {
+	    /* There is a sigsuspend waiting.  Tell it to wake up.  */
+	    error_t err;
+	    mach_msg_header_t msg;
+	    msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
+	    msg.msgh_remote_port = ss->suspended;
+	    msg.msgh_local_port = MACH_PORT_NULL;
+	    /* These values do not matter.  */
+	    msg.msgh_id = 8675309; /* Jenny, Jenny.  */
+	    ss->suspended = MACH_PORT_NULL;
+	    err = __mach_msg (&msg, MACH_SEND_MSG, sizeof msg, 0,
+			      MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE,
+			      MACH_PORT_NULL);
+	    assert_perror (err);
+	  }
+	__spin_unlock (&ss->lock);
+      }
+  }
+
+  /* All pending signals delivered to all threads.
+     Now we can send the reply message even for signal 0.  */
+  reply ();
+}
+
+/* Decide whether REFPORT enables the sender to send us a SIGNO signal.
+   Returns zero if so, otherwise the error code to return to the sender.  */
+
+static error_t
+signal_allowed (int signo, mach_port_t refport)
+{
+  if (signo < 0 || signo >= NSIG)
+    return EINVAL;
+
+  if (refport == __mach_task_self ())
+    /* Can send any signal.  */
+    goto win;
+
+  /* Avoid needing to check for this below.  */
+  if (refport == MACH_PORT_NULL)
+    return EPERM;
+
+  switch (signo)
+    {
+    case SIGINT:
+    case SIGQUIT:
+    case SIGTSTP:
+    case SIGHUP:
+    case SIGINFO:
+    case SIGTTIN:
+    case SIGTTOU:
+    case SIGWINCH:
+      /* Job control signals can be sent by the controlling terminal.  */
+      if (__USEPORT (CTTYID, port == refport))
+	goto win;
+      break;
+
+    case SIGCONT:
+      {
+	/* A continue signal can be sent by anyone in the session.  */
+	mach_port_t sessport;
+	if (! __USEPORT (PROC, __proc_getsidport (port, &sessport)))
+	  {
+	    __mach_port_deallocate (__mach_task_self (), sessport);
+	    if (refport == sessport)
+	      goto win;
+	  }
+      }
+      break;
+
+    case SIGIO:
+    case SIGURG:
+      {
+	/* Any io object a file descriptor refers to might send us
+	   one of these signals using its async ID port for REFPORT.
+
+	   This is pretty wide open; it is not unlikely that some random
+	   process can at least open for reading something we have open,
+	   get its async ID port, and send us a spurious SIGIO or SIGURG
+	   signal.  But BSD is actually wider open than that!--you can set
+	   the owner of an io object to any process or process group
+	   whatsoever and send them gratuitous signals.
+
+	   Someday we could implement some reasonable scheme for
+	   authorizing SIGIO and SIGURG signals properly.  */
+
+	int d;
+	int lucky = 0;		/* True if we find a match for REFPORT.  */
+	__mutex_lock (&_hurd_dtable_lock);
+	for (d = 0; !lucky && (unsigned) d < (unsigned) _hurd_dtablesize; ++d)
+	  {
+	    struct hurd_userlink ulink;
+	    io_t port;
+	    mach_port_t asyncid;
+	    if (_hurd_dtable[d] == NULL)
+	      continue;
+	    port = _hurd_port_get (&_hurd_dtable[d]->port, &ulink);
+	    if (! __io_get_icky_async_id (port, &asyncid))
+	      {
+		if (refport == asyncid)
+		  /* Break out of the loop on the next iteration.  */
+		  lucky = 1;
+		__mach_port_deallocate (__mach_task_self (), asyncid);
+	      }
+	    _hurd_port_free (&_hurd_dtable[d]->port, &ulink, port);
+	  }
+	/* If we found a lucky winner, we've set D to -1 in the loop.  */
+	if (lucky)
+	  goto win;
+      }
+    }
+
+  /* If this signal is legit, we have done `goto win' by now.
+     When we return the error, mig deallocates REFPORT.  */
+  return EPERM;
+
+ win:
+  /* Deallocate the REFPORT send right; we are done with it.  */
+  __mach_port_deallocate (__mach_task_self (), refport);
+
+  return 0;
+}
+
+/* Implement the sig_post RPC from <hurd/msg.defs>;
+   sent when someone wants us to get a signal.  */
+kern_return_t
+_S_msg_sig_post (mach_port_t me,
+		 mach_port_t reply_port, mach_msg_type_name_t reply_port_type,
+		 int signo, natural_t sigcode,
+		 mach_port_t refport)
+{
+  error_t err;
+  struct hurd_signal_detail d;
+
+  if (err = signal_allowed (signo, refport))
+    return err;
+
+  d.code = sigcode;
+  d.exc = 0;
+
+  /* Post the signal to the designated signal-receiving thread.  This will
+     reply when the signal can be considered delivered.  */
+  _hurd_internal_post_signal (_hurd_thread_sigstate (_hurd_sigthread),
+			      signo, &d, reply_port, reply_port_type,
+			      0); /* Stop if traced.  */
+
+  return MIG_NO_REPLY;		/* Already replied.  */
+}
+
+/* Implement the sig_post_untraced RPC from <hurd/msg.defs>;
+   sent when the debugger wants us to really get a signal
+   even if we are traced.  */
+kern_return_t
+_S_msg_sig_post_untraced (mach_port_t me,
+			  mach_port_t reply_port,
+			  mach_msg_type_name_t reply_port_type,
+			  int signo, natural_t sigcode,
+			  mach_port_t refport)
+{
+  error_t err;
+  struct hurd_signal_detail d;
+
+  if (err = signal_allowed (signo, refport))
+    return err;
+
+  d.code = sigcode;
+  d.exc = 0;
+
+  /* Post the signal to the designated signal-receiving thread.  This will
+     reply when the signal can be considered delivered.  */
+  _hurd_internal_post_signal (_hurd_thread_sigstate (_hurd_sigthread),
+			      signo, &d, reply_port, reply_port_type,
+			      1); /* Untraced flag. */
+
+  return MIG_NO_REPLY;		/* Already replied.  */
+}
+
+extern void __mig_init (void *);
+
+#include <mach/task_special_ports.h>
+
+/* Initialize the message port and _hurd_sigthread and start the signal
+   thread.  */
+
+void
+_hurdsig_init (const int *intarray, size_t intarraysize)
+{
+  error_t err;
+  vm_size_t stacksize;
+  struct hurd_sigstate *ss;
+
+  __mutex_init (&_hurd_siglock);
+
+  err = __mach_port_allocate (__mach_task_self (),
+			      MACH_PORT_RIGHT_RECEIVE,
+			      &_hurd_msgport);
+  assert_perror (err);
+
+  /* Make a send right to the signal port.  */
+  err = __mach_port_insert_right (__mach_task_self (),
+				  _hurd_msgport,
+				  _hurd_msgport,
+				  MACH_MSG_TYPE_MAKE_SEND);
+  assert_perror (err);
+
+  /* Initialize the main thread's signal state.  */
+  ss = _hurd_self_sigstate ();
+
+  /* Copy inherited values from our parent (or pre-exec process state)
+     into the signal settings of the main thread.  */
+  if (intarraysize > INIT_SIGMASK)
+    ss->blocked = intarray[INIT_SIGMASK];
+  if (intarraysize > INIT_SIGPENDING)
+    ss->pending = intarray[INIT_SIGPENDING];
+  if (intarraysize > INIT_SIGIGN && intarray[INIT_SIGIGN] != 0)
+    {
+      int signo;
+      for (signo = 1; signo < NSIG; ++signo)
+	if (intarray[INIT_SIGIGN] & __sigmask(signo))
+	  ss->actions[signo].sa_handler = SIG_IGN;
+    }
+
+  /* Set the default thread to receive task-global signals
+     to this one, the main (first) user thread.  */
+  _hurd_sigthread = ss->thread;
+
+  /* Start the signal thread listening on the message port.  */
+
+  if (__hurd_threadvar_stack_mask == 0)
+    {
+      err = __thread_create (__mach_task_self (), &_hurd_msgport_thread);
+      assert_perror (err);
+
+      stacksize = __vm_page_size * 8; /* Small stack for signal thread.  */
+      err = __mach_setup_thread (__mach_task_self (), _hurd_msgport_thread,
+				 _hurd_msgport_receive,
+				 (vm_address_t *) &__hurd_sigthread_stack_base,
+				 &stacksize);
+      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.  */
+      __mig_init ((void *) __hurd_sigthread_stack_base);
+
+      err = __thread_resume (_hurd_msgport_thread);
+      assert_perror (err);
+    }
+  else
+    {
+      /* When cthreads is being used, we need to make the signal thread a
+         proper cthread.  Otherwise it cannot use mutex_lock et al, which
+         will be the cthreads versions.  Various of the message port RPC
+         handlers need to take locks, so we need to be able to call into
+         cthreads code and meet its assumptions about how our thread and
+         its stack are arranged.  Since cthreads puts it there anyway,
+         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));
+
+      /* XXX We need the thread port for the signal thread further on
+         in this thread (see hurdfault.c:_hurdsigfault_init).
+         Therefore we block until _hurd_msgport_thread is initialized
+         by the newly created thread.  This really shouldn't be
+         necessary; we should be able to fetch the thread port for a
+         cthread from here.  */
+      while (_hurd_msgport_thread == 0)
+	__swtch_pri (0);
+    }
+
+  /* Receive exceptions on the signal port.  */
+#ifdef TASK_EXCEPTION_PORT
+  __task_set_special_port (__mach_task_self (),
+			   TASK_EXCEPTION_PORT, _hurd_msgport);
+#elif defined (EXC_MASK_ALL)
+  __task_set_exception_ports (__mach_task_self (),
+			      EXC_MASK_ALL & ~(EXC_MASK_SYSCALL
+					       | EXC_MASK_MACH_SYSCALL
+					       | EXC_MASK_RPC_ALERT),
+			      _hurd_msgport,
+			      EXCEPTION_DEFAULT, MACHINE_THREAD_STATE);
+#else
+# error task_set_exception_port?
+#endif
+
+  /* Sanity check.  Any pending, unblocked signals should have been
+     taken by our predecessor incarnation (i.e. parent or pre-exec state)
+     before packing up our init ints.  This assert is last (not above)
+     so that signal handling is all set up to handle the abort.  */
+  assert ((ss->pending &~ ss->blocked) == 0);
+}
+				/* XXXX */
+/* Reauthenticate with the proc server.  */
+
+static void
+reauth_proc (mach_port_t new)
+{
+  mach_port_t ref, ignore;
+
+  ref = __mach_reply_port ();
+  if (! HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC],
+		       __proc_reauthenticate (port, ref,
+					      MACH_MSG_TYPE_MAKE_SEND) ||
+		       __auth_user_authenticate (new, ref,
+						 MACH_MSG_TYPE_MAKE_SEND,
+						 &ignore))
+      && ignore != MACH_PORT_NULL)
+    __mach_port_deallocate (__mach_task_self (), ignore);
+  __mach_port_destroy (__mach_task_self (), ref);
+
+  /* Set the owner of the process here too. */
+  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);
+
+  (void) &reauth_proc;		/* Silence compiler warning.  */
+}
+text_set_element (_hurd_reauth_hook, reauth_proc);
+
+/* Like `getenv', but safe for the signal thread to run.
+   If the environment is trashed, this will just return NULL.  */
+
+const char *
+_hurdsig_getenv (const char *variable)
+{
+  if (__libc_enable_secure)
+    return NULL;
+
+  if (_hurdsig_catch_memory_fault (__environ))
+    /* We bombed in getenv.  */
+    return NULL;
+  else
+    {
+      const size_t len = strlen (variable);
+      char *value = NULL;
+      char *volatile *ep = __environ;
+      while (*ep)
+	{
+	  const char *p = *ep;
+	  _hurdsig_fault_preemptor.first = (long int) p;
+	  _hurdsig_fault_preemptor.last = VM_MAX_ADDRESS;
+	  if (! strncmp (p, variable, len) && p[len] == '=')
+	    {
+	      size_t valuelen;
+	      p += len + 1;
+	      valuelen = strlen (p);
+	      _hurdsig_fault_preemptor.last = (long int) (p + valuelen);
+	      value = malloc (++valuelen);
+	      if (value)
+		memcpy (value, p, valuelen);
+	      break;
+	    }
+	  _hurdsig_fault_preemptor.first = (long int) ++ep;
+	  _hurdsig_fault_preemptor.last = (long int) (ep + 1);
+	}
+      _hurdsig_end_catch_fault ();
+      return value;
+    }
+}
+#endif
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/hurdstartup.c real-libc/hurd-l4/hurdstartup.c
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/hurdstartup.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/hurdstartup.c	2003-05-19 18:06:37.000000000 +0200
@@ -0,0 +1,203 @@
+/* Initial program startup for running under the GNU Hurd.
+   Copyright (C) 1991,92,93,94,95,96,97,98,2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <hurd.h>
+#if 0
+#include <hurd/exec_startup.h>
+#endif
+#include <sysdep.h>
+#include <hurd/threadvar.h>
+#include <unistd.h>
+#include <elf.h>
+#include <set-hooks.h>
+#include "hurdstartup.h"
+#include <argz.h>
+
+#if 0
+mach_port_t *_hurd_init_dtable;
+mach_msg_type_number_t _hurd_init_dtablesize;
+#endif
+
+/* Entry point.  This is the first thing in the text segment.
+
+   The exec server started the initial thread in our task with this spot the
+   PC, and a stack that is presumably big enough.  We do basic Mach
+   initialization so mig-generated stubs work, and then do an exec_startup
+   RPC on our bootstrap port, to which the exec server responds with the
+   information passed in the exec call, as well as our original bootstrap
+   port, and the base address and size of the preallocated stack.
+
+   If using cthreads, we are given a new stack by cthreads initialization and
+   deallocate the stack set up by the exec server.  On the new stack we call
+   `start1' (above) to do the rest of the startup work.  Since the stack may
+   disappear out from under us in a machine-dependent way, we use a pile of
+   static variables to communicate the information from exec_startup to start1.
+   This is unfortunate but preferable to machine-dependent frobnication to copy
+   the state from the old stack to the new one.  */
+
+
+void
+_hurd_startup (void **argptr, void (*main) (intptr_t *data))
+{
+  error_t err;
+#if 0
+  mach_port_t in_bootstrap;
+  char *args, *env;
+  mach_msg_type_number_t argslen, envlen;
+#endif
+  struct hurd_startup_data data;
+  char **argv, **envp;
+  int argc, envc;
+  int **argcptr;
+#if 0
+  vm_address_t addr;
+
+  /* Attempt to map page zero redzoned before we receive any RPC
+     data that might get allocated there.  We can ignore errors.  */
+  addr = 0;
+  __vm_map (__mach_task_self (),
+	    &addr, __vm_page_size, 0, 0, MACH_PORT_NULL, 0, 1,
+	    VM_PROT_NONE, VM_PROT_NONE, VM_INHERIT_COPY);
+
+  if (err = __task_get_special_port (__mach_task_self (), TASK_BOOTSTRAP_PORT,
+				     &in_bootstrap))
+    LOSE;
+
+  if (in_bootstrap != MACH_PORT_NULL)
+    {
+      /* Call the exec server on our bootstrap port and
+	 get all our standard information from it.  */
+
+      argslen = envlen = 0;
+      data.dtablesize = data.portarraysize = data.intarraysize = 0;
+
+      err = __exec_startup_get_info (in_bootstrap,
+				     &data.user_entry,
+				     &data.phdr, &data.phdrsz,
+				     &data.stack_base, &data.stack_size,
+				     &data.flags,
+				     &args, &argslen,
+				     &env, &envlen,
+				     &data.dtable, &data.dtablesize,
+				     &data.portarray, &data.portarraysize,
+				     &data.intarray, &data.intarraysize);
+      __mach_port_deallocate (__mach_task_self (), in_bootstrap);
+    }
+
+  if (err || in_bootstrap == MACH_PORT_NULL || (data.flags & EXEC_STACK_ARGS))
+    {
+      /* Either we have no bootstrap port, or the RPC to the exec server
+	 failed, or whoever started us up passed the flag saying args are
+	 on the stack.  Try to snarf the args in the canonical Mach way.
+	 Hopefully either they will be on the stack as expected, or the
+	 stack will be zeros so we don't crash.  */
+
+      argcptr = argptr;
+      argc = argcptr[0];
+      argv = (char **) &argcptr[1];
+      envp = &argv[argc + 1];
+      envc = 0;
+      while (envp[envc])
+	++envc;
+    }
+  else
+    {
+      /* Turn the block of null-separated strings we were passed for the
+	 arguments and environment into vectors of pointers to strings.  */
+
+      /* Count up the arguments so we can allocate ARGV.  */
+      argc = __argz_count (args, argslen);
+      /* Count up the environment variables so we can allocate ENVP.  */
+      envc = __argz_count (env, envlen);
+
+      /* There were some arguments.  Allocate space for the vectors of
+	 pointers and fill them in.  We allocate the space for the
+	 environment pointers immediately after the argv pointers because
+	 the ELF ABI will expect it.  */
+      argcptr = __alloca (sizeof (intptr_t) +
+			  (argc + 1 + envc + 1) * sizeof (char *) +
+			  sizeof (struct hurd_startup_data));
+      *argcptr = argc;
+      argv = (void *) (argcptr + 1);
+      __argz_extract (args, argslen, argv);
+
+      /* There was some environment.  */
+      envp = &argv[argc + 1];
+      __argz_extract (env, envlen, envp);
+    }
+
+  if (err || in_bootstrap == MACH_PORT_NULL)
+    {
+      /* Either we have no bootstrap port, or the RPC to the exec server
+	 failed.  Set all our other variables to have empty information.  */
+
+      data.flags = 0;
+      args = env = NULL;
+      argslen = envlen = 0;
+      data.dtable = NULL;
+      data.dtablesize = 0;
+      data.portarray = NULL;
+      data.portarraysize = 0;
+      data.intarray = NULL;
+      data.intarraysize = 0;
+    }
+  else if ((void *) &envp[envc + 1] == argv[0])
+    {
+      /* The arguments arrived on the stack from the kernel, but our
+	 protocol requires some space after them for a `struct
+	 hurd_startup_data'.  Move them.  */
+      struct
+	{
+	  intptr_t count;
+	  char *argv[argc + 1];
+	  char *envp[envc + 1];
+	  struct hurd_startup_data data;
+	} *args = alloca (sizeof *args);
+      if ((void *) &args[1] == (void *) argcptr)
+	args = alloca (-((char *) &args->data - (char *) args));
+      memmove (args, argcptr, (char *) &args->data - (char *) args);
+      argcptr = (void *) args;
+      argv = args->argv;
+      envp = args->envp;
+    }
+#endif
+
+  {
+    struct hurd_startup_data *d = (void *) &envp[envc + 1];
+
+    if ((void *) d != argv[0])
+      {
+	*d = data;
+#if 0
+	_hurd_init_dtable = d->dtable;
+	_hurd_init_dtablesize = d->dtablesize;
+#endif
+      }
+
+    (*main) (argcptr);
+  }
+
+  /* Should never get here.  */
+  LOSE;
+  abort ();
+}
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/hurdstartup.h real-libc/hurd-l4/hurdstartup.h
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/hurdstartup.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/hurdstartup.h	2003-05-19 17:54:11.000000000 +0200
@@ -0,0 +1,66 @@
+/* Data from initial program startup for running under the GNU Hurd.
+   Copyright (C) 1995,97,2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _HURDSTARTUP_H
+#define _HURDSTARTUP_H 1
+
+# include <stdint.h>
+
+/* Interesting data saved from the exec_startup reply.
+   The DATA argument to *MAIN (see below) points to:
+
+    int argc;
+    char *argv[argc];
+    char *argv_terminator = NULL;
+    char *envp[?];
+    char *envp_terminator = NULL;
+    struct hurd_startup_data data;
+
+*/
+
+struct hurd_startup_data
+  {
+    int flags;
+#if 0
+    mach_port_t *dtable;
+    mach_msg_type_number_t dtablesize;
+    mach_port_t *portarray;
+    mach_msg_type_number_t portarraysize;
+    int *intarray;
+    mach_msg_type_number_t intarraysize;
+    vm_address_t stack_base;
+    vm_size_t stack_size;
+    vm_address_t phdr;
+    vm_size_t phdrsz;
+    vm_address_t user_entry;
+#endif
+  };
+
+
+/* Initialize Mach RPCs; do initial handshake with the exec server (or
+   extract the arguments from the stack in the case of the bootstrap task);
+   finally, call *MAIN with the information gleaned.  That function is not
+   expected to return.  ARGPTR should be the address of the first argument
+   of the entry point function that is called with the stack exactly as the
+   exec server or kernel sets it.  */
+
+extern void _hurd_startup (void **argptr, void (*main) (intptr_t *data));
+
+
+#endif	/* hurdstartup.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/hurd-l4/Makefile real-libc/hurd-l4/Makefile
--- /mnt/marcus/gnu/cvs/libc/hurd-l4/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/hurd-l4/Makefile	2003-05-19 19:18:57.000000000 +0200
@@ -0,0 +1,112 @@
+# Copyright (C) 1991,92,93,94,95,96,97,98,99,2001,2002
+#	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, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+subdir := hurd-l4
+
+all:
+
+# Some things below (but before including Rules) use configuration variables.
+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)
+headers = hurd.h $(addprefix hurd/,sigpreempt.h \
+			    userlink.h resource.h threadvar.h)
+
+inline-headers = $(addprefix hurd/, \
+				          userlink.h threadvar.h port.h)
+
+# The RPC interfaces go in a separate library.
+#interface-library := libhurduser
+#user-interfaces		:= $(addprefix hurd/,\
+#				       auth startup \
+#				       process process_request \
+#				       msg msg_reply msg_request \
+#				       exec exec_startup crash interrupt \
+#				       fs fsys io term tioctl socket ifsock \
+#				       login password pfinet \
+#				       )
+#server-interfaces	:= hurd/msg faultexc
+
+#routines = hurdstartup hurdinit \
+#	   hurdid hurdpid hurdrlimit hurdprio hurdexec hurdselect \
+#	   hurdlookup lookup-retry \
+#	   get-host set-host \
+#	   path-lookup \
+#	   setauth \
+#	   pid2task task2pid \
+#	   geteuids seteuids getumask fchroot \
+#	   hurdsock hurdauth \
+#	   hurdchdir hurdfchdir \
+#	   privports \
+#	   msgportdemux \
+#	   fopenport \
+#	   vpprintf \
+#	   ports-get ports-set hurdports hurdmsg \
+#	   errno-loc \
+#	   $(sig) $(dtable) $(inlines) port-cleanup report-wait
+routines = hurdstartup hurdinit getumask errno-loc hurdsig
+
+sig	= hurdsig hurdfault siginfo hurd-raise preempt-sig \
+	  trampoline longjmp-ts catch-exc exc2signal hurdkill sigunwind \
+	  thread-self thread-cancel intr-msg catch-signal
+dtable	= dtable port2fd new-fd alloc-fd intern-fd \
+	  getdport openport \
+	  fd-close fd-read fd-write hurdioctl ctty-input ctty-output
+#inlines = $(inline-headers:%.h=%-inlines)
+#distribute = hurdstartup.h hurdfault.h hurdhost.h \
+#	     faultexc.defs intr-rpc.defs intr-rpc.h intr-msg.h Notes
+
+
+# XXX this is a temporary hack; see hurdmalloc.h
+#routines += hurdmalloc
+#distribute += hurdmalloc.h
+
+# Binary compatibility for libc.so.0.2[GLIBC_2.0].
+#ifeq ($(versioning),yes)
+#routines += compat-20
+#endif
+
+#shared-only-routines = compat-20
+
+# For each of the $(inline-headers), generate a trivial source
+# file that will #include it to define its inline functions as real functions.
+#$(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 '#include "$<"') > $@-new
+#	mv -f $@-new $@
+#generated += $(inlines:=.c)
+
+#include ../mach/Machrules
+include ../Rules
+#
+# intr-rpc.defs defines the INTR_INTERFACE macro to make the generated RPC
+# stubs import <hurd/signal.h> and #define __mach_msg to
+# _hurd_intr_rpc_mach_msg.
+#user-MIGFLAGS += -imacros intr-rpc.defs
+
+# The special exc server for sigthread faults uses a special prefix.
+#MIGFLAGS-faultexc = -prefix _hurdsig_fault_
+
+# We need this static dependency to get faultexc.h generated the first time.
+#$(objpfx)hurdfault.o $(objpfx)hurdfault.d: \
+#	$(objpfx)faultexc_server.h $(objpfx)faultexc_server.c
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/generic/getpeername.c real-libc/sysdeps/generic/getpeername.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/generic/getpeername.c	2001-07-10 10:55:58.000000000 +0200
+++ real-libc/sysdeps/generic/getpeername.c	2003-05-19 18:40:02.000000000 +0200
@@ -22,7 +22,7 @@
 /* Put the address of the peer connected to socket FD into *ADDR
    (which is *LEN bytes long), and its actual length into *LEN.  */
 int
-getpeername (fd, addr, len)
+__getpeername (fd, addr, len)
      int fd;
      __SOCKADDR_ARG addr;
      socklen_t *len;
@@ -34,3 +34,4 @@ getpeername (fd, addr, len)
 
 stub_warning (getpeername)
 #include <stub-tag.h>
+weak_alias (__getpeername, getpeername)
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/generic/tempname.c real-libc/sysdeps/generic/tempname.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/generic/tempname.c	2001-07-10 10:56:53.000000000 +0200
+++ real-libc/sysdeps/generic/tempname.c	2003-05-19 04:07:36.000000000 +0200
@@ -25,7 +25,7 @@
    template suitable for use in __gen_tempname into TMPL, bounded
    by TMPL_LEN. */
 int
-__path_search (tmpl, tmpl_len, dir, pfx)
+__path_search (tmpl, tmpl_len, dir, pfx, try_tmpdir)
      char *tmpl;
      size_t tmpl_len;
      const char *dir;
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/fedisblxcpt.c real-libc/sysdeps/i386/fpu/fedisblxcpt.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/fedisblxcpt.c	2003-05-06 16:04:39.000000000 +0200
+++ real-libc/sysdeps/i386/fpu/fedisblxcpt.c	2003-05-19 18:55:50.000000000 +0200
@@ -38,6 +38,7 @@ fedisableexcept (int excepts)
   new_exc |= excepts;
   __asm__ ("fldcw %0" : : "m" (*&new_exc));
 
+#if 0
   /* If the CPU supports SSE we set the MXCSR as well.  */
   if ((GL(dl_hwcap_mask) & HWCAP_I386_XMM) != 0)
     {
@@ -50,6 +51,7 @@ fedisableexcept (int excepts)
 
       __asm__ ("ldmxcsr %0" : : "m" (*&xnew_exc));
     }
+#endif
 
   return old_exc;
 }
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/feenablxcpt.c real-libc/sysdeps/i386/fpu/feenablxcpt.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/feenablxcpt.c	2003-05-06 16:04:39.000000000 +0200
+++ real-libc/sysdeps/i386/fpu/feenablxcpt.c	2003-05-19 18:56:03.000000000 +0200
@@ -38,6 +38,7 @@ feenableexcept (int excepts)
   new_exc &= ~excepts;
   __asm__ ("fldcw %0" : : "m" (*&new_exc));
 
+#if 0
   /* If the CPU supports SSE we set the MXCSR as well.  */
   if ((GL(dl_hwcap_mask) & HWCAP_I386_XMM) != 0)
     {
@@ -50,6 +51,7 @@ feenableexcept (int excepts)
 
       __asm__ ("stmxcsr %0" : : "m" (*&xnew_exc));
     }
+#endif
 
   return old_exc;
 }
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/feholdexcpt.c real-libc/sysdeps/i386/fpu/feholdexcpt.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/feholdexcpt.c	2003-05-06 16:04:39.000000000 +0200
+++ real-libc/sysdeps/i386/fpu/feholdexcpt.c	2003-05-19 18:55:37.000000000 +0200
@@ -35,6 +35,7 @@ feholdexcept (fenv_t *envp)
   work = envp->__control_word | 0x3f;
   __asm__ ("fldcw %0" : : "m" (*&work));
 
+#if 0
   /* If the CPU supports SSE we set the MXCSR as well.  */
   if ((GL(dl_hwcap_mask) & HWCAP_I386_XMM) != 0)
     {
@@ -48,6 +49,7 @@ feholdexcept (fenv_t *envp)
 
       __asm__ ("ldmxcsr %0" : : "m" (*&xwork));
     }
+#endif
 
   return 0;
 }
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/fesetround.c real-libc/sysdeps/i386/fpu/fesetround.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/fesetround.c	2003-05-06 16:04:39.000000000 +0200
+++ real-libc/sysdeps/i386/fpu/fesetround.c	2003-05-19 18:55:23.000000000 +0200
@@ -37,6 +37,7 @@ fesetround (int round)
   cw |= round;
   __asm__ ("fldcw %0" : : "m" (*&cw));
 
+#if 0
   /* If the CPU supports SSE we set the MXCSR as well.  */
   if ((GL(dl_hwcap_mask) & HWCAP_I386_XMM) != 0)
     {
@@ -47,6 +48,7 @@ fesetround (int round)
       xcw |= round << 3;
       __asm__ ("ldmxcsr %0" : : "m" (*&xcw));
     }
+#endif
 
   return 0;
 }
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/ftestexcept.c real-libc/sysdeps/i386/fpu/ftestexcept.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/i386/fpu/ftestexcept.c	2003-05-06 16:04:39.000000000 +0200
+++ real-libc/sysdeps/i386/fpu/ftestexcept.c	2003-05-19 18:55:06.000000000 +0200
@@ -32,9 +32,11 @@ fetestexcept (int excepts)
   /* Get current exceptions.  */
   __asm__ ("fnstsw %0" : "=a" (temp));
 
+#if 0
   /* If the CPU supports SSE we test the MXCSR as well.  */
   if ((GL(dl_hwcap_mask) & HWCAP_I386_XMM) != 0)
     __asm__ ("stmxcsr %0" : "=m" (*&xtemp));
+#endif
 
   return (temp | xtemp) & excepts & FE_ALL_EXCEPT;
 }
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/getpagesize.c real-libc/sysdeps/l4/getpagesize.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/getpagesize.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/getpagesize.c	2003-05-19 05:06:58.000000000 +0200
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1995, 1996, 2002, 2003 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <unistd.h>
+#include <l4.h>
+
+/* Return the system page size.  */
+int
+__getpagesize ()
+{
+  /* An Fpage is at least 1 Kb large.  */
+  l4_word_t page_size = 1024;
+
+  /* Find smallest page size supported by the hardware and the kernel.
+     There is always at least one bit set.  */
+  while (page_size && !(page_size & l4_page_size_mask ()))
+    page_size <<= 1;
+
+  return page_size;
+}
+libc_hidden_def (__getpagesize)
+weak_alias (__getpagesize, getpagesize)
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/aio_fsync.c real-libc/sysdeps/l4/hurd/aio_fsync.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/aio_fsync.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/aio_fsync.c	2003-05-19 18:31:32.000000000 +0200
@@ -0,0 +1,51 @@
+/* Synchronize I/O in given file descriptor.  Stub version.
+   Copyright (C) 2001 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+
+/* We use an UGLY hack to prevent gcc from finding us cheating.  The
+   implementation of aio_fsync and aio_fsync64 are identical and so
+   we want to avoid code duplication by using aliases.  But gcc sees
+   the different parameter lists and prints a warning.  We define here
+   a function so that aio_fsync64 has no prototype.  */
+#define aio_fsync64 XXX
+#include <aio.h>
+/* And undo the hack.  */
+#undef aio_fsync64
+
+#include <errno.h>
+#include <fcntl.h>
+
+int
+aio_fsync (int op, struct aiocb *aiocbp)
+{
+  if (op != O_SYNC)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+weak_alias (aio_fsync, aio_fsync64)
+
+stub_warning (aio_fsync)
+stub_warning (aio_fsync64)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/errno.h real-libc/sysdeps/l4/hurd/bits/errno.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/errno.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/bits/errno.h	2003-05-19 04:41:13.000000000 +0200
@@ -0,0 +1,314 @@
+#ifdef _ERRNO_H
+
+enum __error_t_codes
+{
+#undef EDOM
+#undef ERANGE
+	EPERM           = 1,
+#define	EPERM           1 /* Operation not permitted */
+	ENOENT          = 2,
+#define	ENOENT          2 /* No such file or directory */
+	ESRCH           = 3,
+#define	ESRCH           3 /* No such process */
+	EINTR           = 4,
+#define	EINTR           4 /* Interrupted system call */
+	EIO             = 5,
+#define	EIO             5 /* Input/output error */
+	ENXIO           = 6,
+#define	ENXIO           6 /* No such device or address */
+	E2BIG           = 7,
+#define	E2BIG           7 /* Argument list too long */
+	ENOEXEC         = 8,
+#define	ENOEXEC         8 /* Exec format error */
+	EBADF           = 9,
+#define	EBADF           9 /* Bad file descriptor */
+	ECHILD          = 10,
+#define	ECHILD          10/* No child processes */
+	EDEADLK         = 11,
+#define	EDEADLK         11/* Resource deadlock avoided */
+	ENOMEM          = 12,
+#define	ENOMEM          12/* Cannot allocate memory */
+	EACCES          = 13,
+#define	EACCES          13/* Permission denied */
+	EFAULT          = 14,
+#define	EFAULT          14/* Bad address */
+	ENOTBLK         = 15,
+#define	ENOTBLK         15/* Block device required */
+	EBUSY           = 16,
+#define	EBUSY           16/* Device or resource busy */
+	EEXIST          = 17,
+#define	EEXIST          17/* File exists */
+	EXDEV           = 18,
+#define	EXDEV           18/* Invalid cross-device link */
+	ENODEV          = 19,
+#define	ENODEV          19/* No such device */
+	ENOTDIR         = 20,
+#define	ENOTDIR         20/* Not a directory */
+	EISDIR          = 21,
+#define	EISDIR          21/* Is a directory */
+	EINVAL          = 22,
+#define	EINVAL          22/* Invalid argument */
+	EMFILE          = 24,
+#define	EMFILE          24/* Too many open files */
+	ENFILE          = 23,
+#define	ENFILE          23/* Too many open files in system */
+	ENOTTY          = 25,
+#define	ENOTTY          25/* Inappropriate ioctl for device */
+	ETXTBSY         = 26,
+#define	ETXTBSY         26/* Text file busy */
+	EFBIG           = 27,
+#define	EFBIG           27/* File too large */
+	ENOSPC          = 28,
+#define	ENOSPC          28/* No space left on device */
+	ESPIPE          = 29,
+#define	ESPIPE          29/* Illegal seek */
+	EROFS           = 30,
+#define	EROFS           30/* Read-only file system */
+	EMLINK          = 31,
+#define	EMLINK          31/* Too many links */
+	EPIPE           = 32,
+#define	EPIPE           32/* Broken pipe */
+	EDOM            = 33,
+#define	EDOM            33/* Numerical argument out of domain */
+	ERANGE          = 34,
+#define	ERANGE          34/* Numerical result out of range */
+	EAGAIN          = 35,
+#define	EAGAIN          35/* Resource temporarily unavailable */
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+	EINPROGRESS     = 36,
+#define	EINPROGRESS     36/* Operation now in progress */
+	EALREADY        = 37,
+#define	EALREADY        37/* Operation already in progress */
+	ENOTSOCK        = 38,
+#define	ENOTSOCK        38/* Socket operation on non-socket */
+	EMSGSIZE        = 40,
+#define	EMSGSIZE        40/* Message too long */
+	EPROTOTYPE      = 41,
+#define	EPROTOTYPE      41/* Protocol wrong type for socket */
+	ENOPROTOOPT     = 42,
+#define	ENOPROTOOPT     42/* Protocol not available */
+	EPROTONOSUPPORT = 43,
+#define	EPROTONOSUPPORT 43/* Protocol not supported */
+	ESOCKTNOSUPPORT = 44,
+#define	ESOCKTNOSUPPORT 44/* Socket type not supported */
+	EOPNOTSUPP      = 45,
+#define	EOPNOTSUPP      45/* Operation not supported */
+	EPFNOSUPPORT    = 46,
+#define	EPFNOSUPPORT    46/* Protocol family not supported */
+	EAFNOSUPPORT    = 47,
+#define	EAFNOSUPPORT    47/* Address family not supported by protocol */
+	EADDRINUSE      = 48,
+#define	EADDRINUSE      48/* Address already in use */
+	EADDRNOTAVAIL   = 49,
+#define	EADDRNOTAVAIL   49/* Cannot assign requested address */
+	ENETDOWN        = 50,
+#define	ENETDOWN        50/* Network is down */
+	ENETUNREACH     = 51,
+#define	ENETUNREACH     51/* Network is unreachable */
+	ENETRESET       = 52,
+#define	ENETRESET       52/* Network dropped connection on reset */
+	ECONNABORTED    = 53,
+#define	ECONNABORTED    53/* Software caused connection abort */
+	ECONNRESET      = 54,
+#define	ECONNRESET      54/* Connection reset by peer */
+	ENOBUFS         = 55,
+#define	ENOBUFS         55/* No buffer space available */
+	EISCONN         = 56,
+#define	EISCONN         56/* Transport endpoint is already connected */
+	ENOTCONN        = 57,
+#define	ENOTCONN        57/* Transport endpoint is not connected */
+	EDESTADDRREQ    = 39,
+#define	EDESTADDRREQ    39/* Destination address required */
+	ESHUTDOWN       = 58,
+#define	ESHUTDOWN       58/* Cannot send after transport endpoint shutdown */
+	ETOOMANYREFS    = 59,
+#define	ETOOMANYREFS    59/* Too many references: cannot splice */
+	ETIMEDOUT       = 60,
+#define	ETIMEDOUT       60/* Connection timed out */
+	ECONNREFUSED    = 61,
+#define	ECONNREFUSED    61/* Connection refused */
+	ELOOP           = 62,
+#define	ELOOP           62/* Too many levels of symbolic links */
+	ENAMETOOLONG    = 63,
+#define	ENAMETOOLONG    63/* File name too long */
+	EHOSTDOWN       = 64,
+#define	EHOSTDOWN       64/* Host is down */
+	EHOSTUNREACH    = 65,
+#define	EHOSTUNREACH    65/* No route to host */
+	ENOTEMPTY       = 66,
+#define	ENOTEMPTY       66/* Directory not empty */
+	EPROCLIM        = 67,
+#define	EPROCLIM        67/* Too many processes */
+	EUSERS          = 68,
+#define	EUSERS          68/* Too many users */
+	EDQUOT          = 69,
+#define	EDQUOT          69/* Disk quota exceeded */
+	ESTALE          = 70,
+#define	ESTALE          70/* Stale NFS file handle */
+	EREMOTE         = 71,
+#define	EREMOTE         71/* Object is remote */
+	EBADRPC         = 72,
+#define	EBADRPC         72/* RPC struct is bad */
+	ERPCMISMATCH    = 73,
+#define	ERPCMISMATCH    73/* RPC version wrong */
+	EPROGUNAVAIL    = 74,
+#define	EPROGUNAVAIL    74/* RPC program not available */
+	EPROGMISMATCH   = 75,
+#define	EPROGMISMATCH   75/* RPC program version wrong */
+	EPROCUNAVAIL    = 76,
+#define	EPROCUNAVAIL    76/* RPC bad procedure for program */
+	ENOLCK          = 77,
+#define	ENOLCK          77/* No locks available */
+	EFTYPE          = 79,
+#define	EFTYPE          79/* Inappropriate file type or format */
+	EAUTH           = 80,
+#define	EAUTH           80/* Authentication error */
+	ENEEDAUTH       = 81,
+#define	ENEEDAUTH       81/* Need authenticator */
+	ENOSYS          = 78,
+#define	ENOSYS          78/* Function not implemented */
+	ENOTSUP         = 118,
+#define	ENOTSUP         118/* Not supported */
+	EILSEQ          = 106,
+#define	EILSEQ          106/* Invalid or incomplete multibyte or wide character */
+	EBACKGROUND     = 100,
+#define	EBACKGROUND     100/* Inappropriate operation for background process */
+	EDIED           = 101,
+#define	EDIED           101/* Translator died */
+	ED              = 102,
+#define	ED              102/* ? */
+	EGREGIOUS       = 103,
+#define	EGREGIOUS       103/* You really blew it this time */
+	EIEIO           = 104,
+#define	EIEIO           104/* Computer bought the farm */
+	EGRATUITOUS     = 105,
+#define	EGRATUITOUS     105/* Gratuitous error */
+	EBADMSG         = 107,
+#define	EBADMSG         107/* Bad message */
+	EIDRM           = 108,
+#define	EIDRM           108/* Identifier removed */
+	EMULTIHOP       = 109,
+#define	EMULTIHOP       109/* Multihop attempted */
+	ENODATA         = 110,
+#define	ENODATA         110/* No data available */
+	ENOLINK         = 111,
+#define	ENOLINK         111/* Link has been severed */
+	ENOMSG          = 112,
+#define	ENOMSG          112/* No message of desired type */
+	ENOSR           = 113,
+#define	ENOSR           113/* Out of streams resources */
+	ENOSTR          = 114,
+#define	ENOSTR          114/* Device not a stream */
+	EOVERFLOW       = 115,
+#define	EOVERFLOW       115/* Value too large for defined data type */
+	EPROTO          = 116,
+#define	EPROTO          116/* Protocol error */
+	ETIME           = 117,
+#define	ETIME           117/* Timer expired */
+	ECANCELED       = 118,
+#define	ECANCELED       118/* Operation canceled */
+
+	/* Errors from <mach/message.h>.  */
+	EMACH_SEND_IN_PROGRESS          = 0x10000001,
+	EMACH_SEND_INVALID_DATA         = 0x10000002,
+	EMACH_SEND_INVALID_DEST         = 0x10000003,
+	EMACH_SEND_TIMED_OUT            = 0x10000004,
+	EMACH_SEND_WILL_NOTIFY          = 0x10000005,
+	EMACH_SEND_NOTIFY_IN_PROGRESS   = 0x10000006,
+	EMACH_SEND_INTERRUPTED          = 0x10000007,
+	EMACH_SEND_MSG_TOO_SMALL        = 0x10000008,
+	EMACH_SEND_INVALID_REPLY        = 0x10000009,
+	EMACH_SEND_INVALID_RIGHT        = 0x1000000a,
+	EMACH_SEND_INVALID_NOTIFY       = 0x1000000b,
+	EMACH_SEND_INVALID_MEMORY       = 0x1000000c,
+	EMACH_SEND_NO_BUFFER            = 0x1000000d,
+	EMACH_SEND_NO_NOTIFY            = 0x1000000e,
+	EMACH_SEND_INVALID_TYPE         = 0x1000000f,
+	EMACH_SEND_INVALID_HEADER       = 0x10000010,
+	EMACH_RCV_IN_PROGRESS           = 0x10004001,
+	EMACH_RCV_INVALID_NAME          = 0x10004002,
+	EMACH_RCV_TIMED_OUT             = 0x10004003,
+	EMACH_RCV_TOO_LARGE             = 0x10004004,
+	EMACH_RCV_INTERRUPTED           = 0x10004005,
+	EMACH_RCV_PORT_CHANGED          = 0x10004006,
+	EMACH_RCV_INVALID_NOTIFY        = 0x10004007,
+	EMACH_RCV_INVALID_DATA          = 0x10004008,
+	EMACH_RCV_PORT_DIED             = 0x10004009,
+	EMACH_RCV_IN_SET                = 0x1000400a,
+	EMACH_RCV_HEADER_ERROR          = 0x1000400b,
+	EMACH_RCV_BODY_ERROR            = 0x1000400c,
+
+	/* Errors from <mach/kern_return.h>.  */
+	EKERN_INVALID_ADDRESS           = 1,
+	EKERN_PROTECTION_FAILURE        = 2,
+	EKERN_NO_SPACE                  = 3,
+	EKERN_INVALID_ARGUMENT          = 4,
+	EKERN_FAILURE                   = 5,
+	EKERN_RESOURCE_SHORTAGE         = 6,
+	EKERN_NOT_RECEIVER              = 7,
+	EKERN_NO_ACCESS                 = 8,
+	EKERN_MEMORY_FAILURE            = 9,
+	EKERN_MEMORY_ERROR              = 10,
+	EKERN_NOT_IN_SET                = 12,
+	EKERN_NAME_EXISTS               = 13,
+	EKERN_ABORTED                   = 14,
+	EKERN_INVALID_NAME              = 15,
+	EKERN_INVALID_TASK              = 16,
+	EKERN_INVALID_RIGHT             = 17,
+	EKERN_INVALID_VALUE             = 18,
+	EKERN_UREFS_OVERFLOW            = 19,
+	EKERN_INVALID_CAPABILITY        = 20,
+	EKERN_RIGHT_EXISTS              = 21,
+	EKERN_INVALID_HOST              = 22,
+	EKERN_MEMORY_PRESENT            = 23,
+	EKERN_WRITE_PROTECTION_FAILURE  = 24,
+	EKERN_TERMINATED                = 26,
+
+	/* Errors from <mach/mig_errors.h>.  */
+	EMIG_TYPE_ERROR         = -300  /* client type check failure */,
+	EMIG_REPLY_MISMATCH     = -301  /* wrong reply message ID */,
+	EMIG_REMOTE_ERROR       = -302  /* server detected error */,
+	EMIG_BAD_ID             = -303  /* bad request message ID */,
+	EMIG_BAD_ARGUMENTS      = -304  /* server type check failure */,
+	EMIG_NO_REPLY           = -305  /* no reply should be sent */,
+	EMIG_EXCEPTION          = -306  /* server raised exception */,
+	EMIG_ARRAY_TOO_LARGE    = -307  /* array not large enough */,
+	EMIG_SERVER_DIED        = -308  /* server died */,
+	EMIG_DESTROY_REQUEST    = -309  /* destroy request with no reply */,
+
+	/* Errors from <device/device_types.h>.  */
+	ED_IO_ERROR             = 2500  /* hardware IO error */,
+	ED_WOULD_BLOCK          = 2501  /* would block, but D_NOWAIT set */,
+	ED_NO_SUCH_DEVICE       = 2502  /* no such device */,
+	ED_ALREADY_OPEN         = 2503  /* exclusive-use device already open */,
+	ED_DEVICE_DOWN          = 2504  /* device has been shut down */,
+	ED_INVALID_OPERATION    = 2505  /* bad operation for device */,
+	ED_INVALID_RECNUM       = 2506  /* invalid record (block) number */,
+	ED_INVALID_SIZE         = 2507  /* invalid IO size */,
+	ED_NO_MEMORY            = 2508  /* memory allocation failure */,
+	ED_READ_ONLY            = 2509  /* device cannot be written to */
+
+};
+
+#define	_HURD_ERRNOS	119
+
+/* User-visible type of error codes.  It is ok to use `int' or
+   `kern_return_t' for these, but with `error_t' the debugger prints
+   symbolic values.  */
+#ifdef __USE_GNU
+typedef enum __error_t_codes error_t;
+#define __error_t_defined	1
+#endif
+
+/* Return the current thread's location for `errno'.
+   The syntax of this function allows redeclarations like `int errno'.  */
+extern int *__errno_location (void) __THROW __attribute__ ((__const__));
+
+#define errno			(*__errno_location ())
+
+#endif /* <errno.h> included.  */
+
+#if !defined (_ERRNO_H) && defined (__need_Emath)
+#define	EDOM            33	/* Numerical argument out of domain */
+#define	ERANGE          34	/* Numerical result out of range */
+#endif /* <errno.h> not included and need math error codes.  */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/libc-tsd.h real-libc/sysdeps/l4/hurd/bits/libc-tsd.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/libc-tsd.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/bits/libc-tsd.h	2003-05-19 04:41:13.000000000 +0200
@@ -0,0 +1,34 @@
+/* libc-internal interface for thread-specific data.  Hurd version.
+   Copyright (C) 1998,2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _BITS_LIBC_TSD_H
+#define _BITS_LIBC_TSD_H 1
+
+#include <hurd/threadvar.h>
+
+#define __libc_tsd_define(CLASS, KEY) /* nothing, always have threadvars */
+
+#define __libc_tsd_address(KEY) \
+  ((void **) __hurd_threadvar_location (_HURD_THREADVAR_##KEY))
+
+#define __libc_tsd_get(KEY)		(*__libc_tsd_address (KEY))
+#define __libc_tsd_set(KEY, VALUE)	(*__libc_tsd_address (KEY) = (VALUE))
+
+
+#endif	/* bits/libc-tsd.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/local_lim.h real-libc/sysdeps/l4/hurd/bits/local_lim.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/local_lim.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/bits/local_lim.h	2003-05-19 04:41:13.000000000 +0200
@@ -0,0 +1,46 @@
+/* Minimum guaranteed maximum values for system limits.  Hurd version.
+   Copyright (C) 1993,94,96,98,2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* GNU has no arbitrary fixed limits on most of these things, so we
+   don't define the macros.  Some things are unlimited.  Some are in
+   fact limited but the limit is run-time dependent and fetched with
+   `sysconf' or `pathconf'.  */
+
+/* This one value is actually constrained by the `struct dirent'
+   layout, in which the `d_namlen' member is only 8 bits wide.  */
+
+#define NAME_MAX	255
+
+/* POSIX.1 requires that we define NGROUPS_MAX (though none of the others
+   is required).  GNU allows any number of supplementary groups,
+   dynamically allocated.  So we pick a number which seems vaguely
+   suitable, and `sysconf' will return a number at least as large.  */
+
+#define NGROUPS_MAX	256
+
+/* The maximum number of symbolic links that are allowed in a single file
+   name resolution.  When a further link is encountered, the call returns
+   ELOOP.  This name is a GNU extension; POSIX.1 has no such limit, and BSD
+   calls it MAXSYMLINKS in <sys/param.h>.  (We define the name under
+   _BSD_SOURCE even without _GNU_SOURCE because our <sys/param.h> uses it
+   to define MAXSYMLINKS.)  */
+
+#if defined __USE_GNU || defined __USE_BSD /* 1003.1a defines this */
+#define	SYMLOOP_MAX	8
+#endif
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/posix_opt.h real-libc/sysdeps/l4/hurd/bits/posix_opt.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/posix_opt.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/bits/posix_opt.h	2003-05-19 04:41:13.000000000 +0200
@@ -0,0 +1,79 @@
+/* Define POSIX options for GNU/Hurd.
+   Copyright (C) 1998,2000,2001,2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _UNISTD_H
+#error "Never include this file directly; use <unistd.h> instead."
+#endif
+
+#ifndef	_BITS_POSIX_OPT_H
+#define	_BITS_POSIX_OPT_H	1
+
+
+/* Job control is supported.  */
+#define	_POSIX_JOB_CONTROL	1
+
+/* Processes have a saved set-user-ID and a saved set-group-ID.  */
+#define	_POSIX_SAVED_IDS	1
+
+#if 0				/* XXX implement aio_* */
+/* Asynchronous I/O is supported.  */
+#define _POSIX_ASYNCHRONOUS_IO	1
+/* Alternative name for Unix98.  */
+#define _LFS_ASYNCHRONOUS_IO	_POSIX_ASYNCHRONOUS_IO
+#endif
+
+/* Synchronizing file data is supported, but msync is missing.  */
+#undef _POSIX_SYNCHRONIZED_IO
+
+/* The fsync function is present.  */
+#define	_POSIX_FSYNC	200112L
+
+/* Mapping of files to memory is supported.  */
+#define	_POSIX_MAPPED_FILES	200112L
+
+/* Locking of ranges of memory is supported.  */
+#define	_POSIX_MEMLOCK_RANGE	200112L
+
+/* Setting of memory protections is supported.  */
+#define	_POSIX_MEMORY_PROTECTION	200112L
+
+/* POSIX.4 shared memory objects are supported (using regular files).  */
+#define _POSIX_SHARED_MEMORY_OBJECTS	_POSIX_MAPPED_FILES
+
+/* Elements of the `c_cc' member of `struct termios' structure
+   can be disabled by using the value _POSIX_VDISABLE.  */
+#define _POSIX_VDISABLE			((unsigned char) -1)
+
+
+/* Different Hurd filesystems might do these differently.
+   You must query the particular file with `pathconf' or `fpathconf'.  */
+#undef _POSIX_CHOWN_RESTRICTED	/* Only root can change owner of file?  */
+#undef _POSIX_NO_TRUNC		/* Overlong file names get error?  */
+#undef _POSIX_SYNC_IO		/* File supports O_SYNC et al?  */
+
+/* GNU libc provides regular expression handling.  */
+#define _POSIX_REGEXP	1
+
+/* We have a POSIX shell.  */
+#define _POSIX_SHELL	1
+
+/* The `spawn' function family is supported.  */
+#define _POSIX_SPAWN	200112L
+
+#endif /* bits/posix_opt.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/stat.h real-libc/sysdeps/l4/hurd/bits/stat.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/stat.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/bits/stat.h	2003-05-19 04:15:38.000000000 +0200
@@ -0,0 +1,193 @@
+/* Copyright (C) 1992, 93, 94, 96, 97, 99, 2000 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* NOTE: The size of this structure (32 ints) is known in
+   <hurd/hurd_types.defs>, since it is used in the `io_stat' RPC.  MiG
+   does not cope at all well with the passed C structure not being of
+   the expected size.  There are some filler words at the end to allow
+   for future expansion.  To increase the size of the structure used
+   in the RPC and retain binary compatibility, we would need to assign
+   a new message number.  */
+
+struct stat
+  {
+    int st_fstype;		/* File system type.  */
+    __fsid_t st_fsid;		/* File system ID.  */
+#define	st_dev	st_fsid
+
+#ifndef __USE_FILE_OFFSET64
+    __ino_t st_ino;		/* File number.  */
+#else
+    __ino64_t st_ino;		/* File number.  */
+#endif
+    unsigned int st_gen;	/* To detect reuse of file numbers.  */
+    __dev_t st_rdev;		/* Device if special file.  */
+    __mode_t st_mode;		/* File mode.  */
+    __nlink_t st_nlink;		/* Number of links.  */
+
+    __uid_t st_uid;		/* Owner.  */
+    __gid_t st_gid;		/* Owning group.  */
+
+#ifndef __USE_FILE_OFFSET64
+    __off_t st_size;		/* Size in bytes.  */
+#else
+    __off64_t st_size;		/* Size in bytes.  */
+#endif
+
+    __time_t st_atime;		/* Access time, seconds */
+    unsigned long int st_atime_usec; /* and microseconds.  */
+    __time_t st_mtime;		/* Modification time, seconds */
+    unsigned long int st_mtime_usec; /* and microseconds.  */
+    __time_t st_ctime;		/* Status change time, seconds */
+    unsigned long int st_ctime_usec; /* and microseconds.  */
+
+    __blksize_t st_blksize;	/* Optimal size for I/O.  */
+
+#ifndef __USE_FILE_OFFSET64
+    __blkcnt_t st_blocks;	/* Number of 512-byte blocks allocated.
+				   Not related to `st_blksize'.  */
+#else
+    __blkcnt64_t st_blocks;	/* Number of 512-byte blocks allocated.
+				   Not related to `st_blksize'.  */
+#endif
+
+    __uid_t st_author;		/* File author.  */
+
+    unsigned int st_flags;	/* User-defined flags.
+				   High 16 bits can be set only by root.  */
+
+#ifndef __USE_FILE_OFFSET64
+# define _SPARE_SIZE	((sizeof (__fsid_t) == sizeof (int)) ? 12 : 11)
+#else
+# define _SPARE_SIZE	((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
+#endif
+    int st_spare[_SPARE_SIZE];	/* Room for future expansion.  */
+#undef _SPARE_SIZE
+  };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+  {
+    int st_fstype;		/* File system type.  */
+    __fsid_t st_fsid;		/* File system ID.  */
+# define st_dev	st_fsid
+
+    __ino64_t st_ino;		/* File number.  */
+    unsigned int st_gen;	/* To detect reuse of file numbers.  */
+    __dev_t st_rdev;		/* Device if special file.  */
+    __mode_t st_mode;		/* File mode.  */
+    __nlink_t st_nlink;		/* Number of links.  */
+
+    __uid_t st_uid;		/* Owner.  */
+    __gid_t st_gid;		/* Owning group.  */
+
+    __off64_t st_size;		/* Size in bytes.  */
+
+    __time_t st_atime;		/* Access time, seconds */
+    unsigned long int st_atime_usec; /* and microseconds.  */
+    __time_t st_mtime;		/* Modification time, seconds */
+    unsigned long int st_mtime_usec; /* and microseconds.  */
+    __time_t st_ctime;		/* Status change time, seconds */
+    unsigned long int st_ctime_usec; /* and microseconds.  */
+
+    __blksize_t st_blksize;	/* Optimal size for I/O.  */
+
+    __blkcnt64_t st_blocks;	/* Number of 512-byte blocks allocated.
+				   Not related to `st_blksize'.  */
+
+    __uid_t st_author;		/* File author.  */
+
+    unsigned int st_flags;	/* User-defined flags.
+				   High 16 bits can be set only by root.  */
+
+#define _SPARE_SIZE	((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
+    int st_spare[_SPARE_SIZE];	/* Room for future expansion.  */
+#undef _SPARE_SIZE
+  };
+#endif
+
+#define	_STATBUF_ST_BLKSIZE	/* Tell code we have this member.  */
+
+/* Encoding of the file mode.  */
+
+#define	__S_IFMT	0170000	/* These bits determine file type.  */
+
+/* File types.  */
+#define	__S_IFDIR	0040000	/* Directory.  */
+#define	__S_IFCHR	0020000	/* Character device.  */
+#define	__S_IFBLK	0060000	/* Block device.  */
+#define	__S_IFREG	0100000	/* Regular file.  */
+#define	__S_IFLNK	0120000	/* Symbolic link.  */
+#define	__S_IFSOCK	0140000	/* Socket.  */
+#define	__S_IFIFO	0010000	/* FIFO.  */
+
+/* POSIX.1b objects.  */
+#define __S_TYPEISMQ(buf) (0)
+#define __S_TYPEISSEM(buf) (0)
+#define __S_TYPEISSHM(buf) (0)
+
+/* Protection bits.  */
+
+#define	__S_ISUID	04000	/* Set user ID on execution.  */
+#define	__S_ISGID	02000	/* Set group ID on execution.  */
+#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
+#define	__S_IREAD	00400	/* Read by owner.  */
+#define	__S_IWRITE	00200	/* Write by owner.  */
+#define	__S_IEXEC	00100	/* Execute by owner.  */
+
+
+#ifdef	__USE_GNU
+/* If set, there is no benefit in caching the contents of this file.  */
+#define S_INOCACHE	000000200000
+
+/* If the S_IUSEUNK bit is set, then the S_IUNKNOWN bits (see below)
+   control access for unknown users.  If S_IUSEUNK is clear, then unknown
+   users are treated as "others" for purposes of access control.  */
+#define S_IUSEUNK	000000400000
+/* Mask of protection bits for unknown users (no effective IDs at all).  */
+#define S_IUNKNOWN      000007000000
+/* Shift S_IREAD, S_IWRITE, S_IEXEC left this many bits to produce the
+   protection bits for unknown users.  */
+#define S_IUNKSHIFT	12
+
+/* Read only bits: */
+
+/* There is a passive translator set for this file */
+#define S_IPTRANS	000010000000
+/* There is an active translator running on this file */
+#define S_IATRANS	000020000000
+/* This is the root of a filesystem (or single node translator) */
+#define S_IROOT		000040000000
+/* All the bits relevant to translators */
+#define S_ITRANS	000070000000
+
+/* ALL the unused bits.  */
+#define	S_ISPARE	(~(S_IFMT|S_ITRANS|S_INOCACHE|    \
+			   S_IUSEUNK|S_IUNKNOWN|07777))
+#endif
+
+/* Default file creation mask (umask).  */
+#ifdef	__USE_BSD
+#define	CMASK		0022
+#endif
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/typesizes.h real-libc/sysdeps/l4/hurd/bits/typesizes.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/bits/typesizes.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/bits/typesizes.h	2003-05-19 04:41:13.000000000 +0200
@@ -0,0 +1,65 @@
+/* bits/typesizes.h -- underlying types for *_t.  Hurd version.
+   Copyright (C) 2002,2003 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _BITS_TYPES_H
+# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef	_BITS_TYPESIZES_H
+#define	_BITS_TYPESIZES_H	1
+
+/* See <bits/types.h> for the meaning of these macros.  This file exists so
+   that <bits/types.h> need not vary across different GNU platforms.  */
+
+#define __DEV_T_TYPE		__U32_TYPE
+#define __UID_T_TYPE		__U32_TYPE
+#define __GID_T_TYPE		__U32_TYPE
+#define __INO_T_TYPE		__ULONGWORD_TYPE
+#define __INO64_T_TYPE		__UQUAD_TYPE
+#define __MODE_T_TYPE		__U32_TYPE
+#define __NLINK_T_TYPE		__UWORD_TYPE
+#define __OFF_T_TYPE		__SLONGWORD_TYPE
+#define __OFF64_T_TYPE		__SQUAD_TYPE
+#define __PID_T_TYPE		__S32_TYPE
+#define __RLIM_T_TYPE		__ULONGWORD_TYPE
+#define __RLIM64_T_TYPE		__UQUAD_TYPE
+#define	__BLKCNT_T_TYPE		__SLONGWORD_TYPE
+#define	__BLKCNT64_T_TYPE	__SQUAD_TYPE
+#define	__FSBLKCNT_T_TYPE	__ULONGWORD_TYPE
+#define	__FSBLKCNT64_T_TYPE	__UQUAD_TYPE
+#define	__FSFILCNT_T_TYPE	__ULONGWORD_TYPE
+#define	__FSFILCNT64_T_TYPE	__UQUAD_TYPE
+#define	__ID_T_TYPE		__U32_TYPE
+#define __CLOCK_T_TYPE		__SLONGWORD_TYPE
+#define __TIME_T_TYPE		__SLONGWORD_TYPE
+#define __USECONDS_T_TYPE	__U32_TYPE
+#define __SUSECONDS_T_TYPE	__SLONGWORD_TYPE
+#define __DADDR_T_TYPE		__S32_TYPE
+#define __SWBLK_T_TYPE		__SLONGWORD_TYPE
+#define __KEY_T_TYPE		__S32_TYPE
+#define __CLOCKID_T_TYPE	__S32_TYPE
+#define __TIMER_T_TYPE		__S32_TYPE
+#define __BLKSIZE_T_TYPE	__SLONGWORD_TYPE
+#define __FSID_T_TYPE		__UQUAD_TYPE
+
+/* Number of descriptors that can fit in an `fd_set'.  */
+#define	__FD_SETSIZE		256
+
+
+#endif /* bits/typesizes.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/check_fds.c real-libc/sysdeps/l4/hurd/check_fds.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/check_fds.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/check_fds.c	2003-05-19 16:09:06.000000000 +0200
@@ -0,0 +1,112 @@
+/* Copyright (C) 2000 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <fcntl.h>
+#include <paths.h>
+#include <unistd.h>
+
+#include <hurd.h>
+#if 0
+#include <hurd/fd.h>
+#endif
+
+#include <set-hooks.h>
+
+/* Try to get a machine dependent instruction which will make the
+   program crash.  This is used in case everything else fails.  */
+#include <abort-instr.h>
+#ifndef ABORT_INSTRUCTION
+/* No such instruction is available.  */
+# define ABORT_INSTRUCTION
+#endif
+
+static void
+check_one_fd (int fd, int mode)
+{
+#if 0
+  struct hurd_fd *d;
+
+  d = _hurd_fd_get (fd);
+  if (d == NULL)
+    {
+      /* This descriptor hasn't been opened.  We try to allocate the
+         descriptor and open /dev/null on it so that the SUID program
+         we are about to start does not accidently use this
+         descriptor.  */
+      d = _hurd_alloc_fd (NULL, fd);
+      if (d != NULL)
+	{
+	  mach_port_t port;
+
+	  port = __file_name_lookup (_PATH_DEVNULL, mode, 0);
+	  if (port)
+	    {
+	      /* Since /dev/null isn't supposed to be a terminal, we
+		 avoid any ctty magic.  */
+	      d->port.port = port;
+	      d->flags = 0;
+
+	      __spin_unlock (&d->port.lock);
+	      return;
+	    }
+	}
+      
+      /* We cannot even give an error message here since it would run
+	 into the same problems.  */
+      while (1)
+	/* Try for ever and ever.  */
+	ABORT_INSTRUCTION;
+    }
+#endif
+}
+
+static void
+check_standard_fds (void)
+{
+  /* Check all three standard file descriptors.  */
+  check_one_fd (STDIN_FILENO, O_RDONLY);
+  check_one_fd (STDOUT_FILENO, O_RDWR);
+  check_one_fd (STDERR_FILENO, O_RDWR);
+}
+
+static void
+init_standard_fds (void)
+{
+  /* Now that we have FDs, make sure that, if this is a SUID program,
+     FDs 0, 1 and 2 are allocated.  If necessary we'll set them up
+     ourselves.  If that's not possible we stop the program.  */
+  if (__builtin_expect (__libc_enable_secure, 0))
+    check_standard_fds ();
+
+  (void) &init_standard_fds;	/* Avoid "defined but not used" warning.  */
+}
+text_set_element (_hurd_fd_subinit, init_standard_fds);
+
+
+#ifndef SHARED
+void
+__libc_check_standard_fds (void)
+{
+  /* We don't check the standard file descriptors here.  They will be
+     checked when we initialize the file descriptor table, as part of
+     the _hurd_fd_subinit hook.
+     
+     This function is only present to make sure that this module gets
+     linked in when part of the static libc.  */
+}
+#endif
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/config-name.h real-libc/sysdeps/l4/hurd/config-name.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/config-name.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/config-name.h	2003-05-19 05:00:14.000000000 +0200
@@ -0,0 +1,4 @@
+#define UNAME_SYSNAME "GNU/Hurd"
+#define UNAME_RELEASE "0"
+#define UNAME_VERSION "0.0"
+#define UNAME_MACHINE "i386"
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/errno-loc.c real-libc/sysdeps/l4/hurd/errno-loc.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/errno-loc.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/errno-loc.c	2003-05-19 05:33:13.000000000 +0200
@@ -0,0 +1,29 @@
+/* __errno_location -- helper function for locating per-thread errno value
+   Copyright (C) 2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <hurd/threadvar.h>
+
+int *
+__errno_location (void)
+{
+  return (int *) __hurd_threadvar_location (_HURD_THREADVAR_ERRNO);
+}
+strong_alias (__errno_location, __hurd_errno_location)
+libc_hidden_def (__errno_location)
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/execve.c real-libc/sysdeps/l4/hurd/execve.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/execve.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/execve.c	2003-05-19 04:25:01.000000000 +0200
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Replace the current process, executing PATH with arguments ARGV and
+   environment ENVP.  ARGV and ENVP are terminated by NULL pointers.  */
+int
+__execve (path, argv, envp)
+     const char *path;
+     char *const argv[];
+     char *const envp[];
+{
+  if (path == NULL || argv == NULL || envp == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (execve)
+
+weak_alias (__execve, execve)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/_exit.c real-libc/sysdeps/l4/hurd/_exit.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/_exit.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/_exit.c	2003-05-19 04:24:00.000000000 +0200
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991,94,95,96,97,99,2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <unistd.h>
+#include <stdlib.h>
+
+/* The function `_exit' should take a status argument and simply
+   terminate program execution, using the low-order 8 bits of the
+   given integer as status.  */
+void
+_exit (status)
+     int status;
+{
+  status &= 0xff;
+  abort ();
+}
+libc_hidden_def (_exit)
+weak_alias (_exit, _Exit)
+
+stub_warning (_exit)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/fork.c real-libc/sysdeps/l4/hurd/fork.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/fork.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/fork.c	2003-05-19 04:21:51.000000000 +0200
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+
+/* Clone the calling process, creating an exact copy.
+   Return -1 for errors, 0 to the new process,
+   and the process ID of the new process to the old process.  */
+int
+__fork ()
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+libc_hidden_def (__fork)
+stub_warning (fork)
+
+weak_alias (__fork, fork)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/fxstat.c real-libc/sysdeps/l4/hurd/fxstat.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/fxstat.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/fxstat.c	2003-05-19 16:26:37.000000000 +0200
@@ -0,0 +1,50 @@
+/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+/* Get information about the file descriptor FD in BUF.  */
+int
+__fxstat (int vers, int fd, struct stat *buf)
+{
+  if (vers != _STAT_VER)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  if (fd < 0)
+    {
+      __set_errno (EBADF);
+      return -1;
+    }
+  else if (buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (fstat)
+hidden_def (__fxstat)
+weak_alias (__fxstat, _fxstat)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getcwd.c real-libc/sysdeps/l4/hurd/getcwd.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getcwd.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/getcwd.c	2003-05-19 04:30:53.000000000 +0200
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 1992, 1995, 1996, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+#include <stddef.h>
+
+/* Get the pathname of the current working directory,
+   and put it in SIZE bytes of BUF.  Returns NULL if the
+   directory couldn't be determined or SIZE was too small.
+   If successful, returns BUF.  In GNU, if BUF is NULL,
+   an array is allocated with `malloc'; the array is SIZE
+   bytes long, unless SIZE <= 0, in which case it is as
+   big as necessary.  */
+char *
+__getcwd (char *buf, size_t size)
+{
+  __set_errno (ENOSYS);
+  return NULL;
+}
+weak_alias (__getcwd, getcwd)
+
+stub_warning (__getcwd)
+stub_warning (getcwd)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getdents.c real-libc/sysdeps/l4/hurd/getdents.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getdents.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/getdents.c	2003-05-19 16:31:46.000000000 +0200
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stddef.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+ssize_t
+__getdirentries (fd, buf, nbytes, basep)
+     int fd;
+     char *buf;
+     size_t nbytes;
+     off_t *basep;
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+weak_alias (__getdirentries, getdirentries)
+
+stub_warning (getdirentries)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getdtsz.c real-libc/sysdeps/l4/hurd/getdtsz.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getdtsz.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/getdtsz.c	2003-05-19 05:18:23.000000000 +0200
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+/* Return the maximum number of file descriptors
+   the current process could possibly have.  */
+int
+__getdtablesize ()
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (getdtablesize)
+
+weak_alias (__getdtablesize, getdtablesize)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getegid.c real-libc/sysdeps/l4/hurd/getegid.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getegid.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/getegid.c	2003-05-19 04:27:10.000000000 +0200
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1992, 1995, 1996, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+/* Get the effective group ID of the calling process.  */
+__gid_t
+__getegid ()
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (getegid)
+
+weak_alias (__getegid, getegid)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/geteuid.c real-libc/sysdeps/l4/hurd/geteuid.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/geteuid.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/geteuid.c	2003-05-19 04:26:38.000000000 +0200
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1992, 1995, 1996, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+
+/* Get the effective user ID of the calling process.  */
+__uid_t
+__geteuid ()
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (geteuid)
+
+weak_alias (__geteuid, geteuid)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getlogin.c real-libc/sysdeps/l4/hurd/getlogin.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getlogin.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/getlogin.c	2003-05-19 04:28:17.000000000 +0200
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1995, 1996 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Return the login name of the user, or NULL if it can't be determined.
+   The returned pointer, if not NULL, is good only until the next call.  */
+char *
+getlogin (void)
+{
+  __set_errno (ENOSYS);
+  return NULL;
+}
+
+stub_warning (getlogin)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getlogin_r.c real-libc/sysdeps/l4/hurd/getlogin_r.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getlogin_r.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/getlogin_r.c	2003-05-19 04:28:50.000000000 +0200
@@ -0,0 +1,37 @@
+/* Reentrant function to return the current login name.  Stub version.
+   Copyright (C) 1996, 2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+/* Return at most NAME_LEN characters of the login name of the user in NAME.
+   If it cannot be determined or some other error occurred, return the error
+   code.  Otherwise return 0.  */
+int
+getlogin_r (name, name_len)
+     char *name;
+     size_t name_len;
+{
+  __set_errno (ENOSYS);
+  return errno;
+}
+libc_hidden_def (getlogin_r)
+
+stub_warning (getlogin_r)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getpid.c real-libc/sysdeps/l4/hurd/getpid.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getpid.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/getpid.c	2003-05-19 05:33:22.000000000 +0200
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991, 1993, 1995, 1997, 2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <unistd.h>
+#include <l4.h>
+
+/* Get the process ID of the calling process.  */
+pid_t
+__getpid ()
+{
+  return (pid_t) l4_version (l4_myself ());
+}
+libc_hidden_def (__getpid)
+weak_alias (__getpid, getpid)
+libc_hidden_weak (getpid)
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getppid.c real-libc/sysdeps/l4/hurd/getppid.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/getppid.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/getppid.c	2003-05-19 04:26:02.000000000 +0200
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+
+/* Get the parent process ID of the calling process.  */
+int
+__getppid ()
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (getppid)
+
+weak_alias (__getppid, getppid)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/bits/sigcontext.h real-libc/sysdeps/l4/hurd/i386/bits/sigcontext.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/bits/sigcontext.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/i386/bits/sigcontext.h	2003-05-13 23:32:07.000000000 +0200
@@ -0,0 +1,123 @@
+/* Machine-dependent signal context structure for GNU Hurd.  i386 version.
+   Copyright (C) 1991, 92, 94, 97, 2001, 2003 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+#ifndef sc_pc
+
+/* Signal handlers are actually called:
+   void handler (int sig, int code, struct sigcontext *scp);  */
+
+#if MACH_NOT_L4
+#include <mach/machine/fp_reg.h>
+#endif
+
+/* State of this thread when the signal was taken.  */
+struct sigcontext
+  {
+    /* These first members are machine-independent.  */
+
+    int sc_onstack;		/* Nonzero if running on sigstack.  */
+    __sigset_t sc_mask;		/* Blocked signals to restore.  */
+
+    /* Port this thread is doing an interruptible RPC on.  */
+    unsigned int sc_intr_port;
+
+    /* Error code associated with this signal (interpreted as `error_t').  */
+    int sc_error;
+
+    /* All following members are machine-dependent.  The rest of this
+       structure is written to be laid out identically to:
+       {
+#if MACH_NOT_L4
+	 struct i386_thread_state basic;
+	 struct i386_float_state fpu;
+#endif
+       }
+       trampoline.c knows this, so it must be changed if this changes.  */
+
+#define sc_i386_thread_state sc_gs /* Beginning of correspondence.  */
+    /* Segment registers.  */
+    int sc_gs;
+    int sc_fs;
+    int sc_es;
+    int sc_ds;
+
+    /* "General" registers.  These members are in the order that the i386
+       `pusha' and `popa' instructions use (`popa' ignores %esp).  */
+    int sc_edi;
+    int sc_esi;
+    int sc_ebp;
+    int sc_esp;			/* Not used; sc_uesp is used instead.  */
+    int sc_ebx;
+    int sc_edx;
+    int sc_ecx;
+    int sc_eax;
+
+    int sc_eip;			/* Instruction pointer.  */
+    int sc_cs;			/* Code segment register.  */
+
+    int sc_efl;			/* Processor flags.  */
+
+    int sc_uesp;		/* This stack pointer is used.  */
+    int sc_ss;			/* Stack segment register.  */
+
+    /* Following mimics struct i386_float_state.  Structures and symbolic
+       values can be found in <mach/i386/fp_reg.h>.  */
+#define sc_i386_float_state sc_fpkind
+    int sc_fpkind;		/* FP_NO, FP_387, etc.  */
+    int sc_fpused;		/* If zero, ignore rest of float state.  */
+#if MACH_NOT_L4
+        struct i386_fp_save sc_fpsave;
+        struct i386_fp_regs sc_fpregs;
+#endif
+    int sc_fpexcsr;		/* FPSR including exception bits.  */
+  };
+
+/* Traditional BSD names for some members.  */
+#define sc_sp	sc_uesp		/* Stack pointer.  */
+#define sc_fp	sc_ebp		/* Frame pointer.  */
+#define sc_pc	sc_eip		/* Process counter.  */
+#define sc_ps	sc_efl
+
+
+/* Codes for SIGFPE.  */
+#define FPE_INTOVF_TRAP		0x1 /* integer overflow */
+#define FPE_INTDIV_FAULT	0x2 /* integer divide by zero */
+#define FPE_FLTOVF_FAULT	0x3 /* floating overflow */
+#define FPE_FLTDIV_FAULT	0x4 /* floating divide by zero */
+#define FPE_FLTUND_FAULT	0x5 /* floating underflow */
+#define FPE_SUBRNG_FAULT	0x7 /* BOUNDS instruction failed */
+#define FPE_FLTDNR_FAULT	0x8 /* denormalized operand */
+#define FPE_FLTINX_FAULT	0x9 /* floating loss of precision */
+#define FPE_EMERR_FAULT		0xa /* mysterious emulation error 33 */
+#define FPE_EMBND_FAULT		0xb /* emulation BOUNDS instruction failed */
+
+/* Codes for SIGILL.  */
+#define ILL_INVOPR_FAULT	0x1 /* invalid operation */
+#define ILL_STACK_FAULT		0x2 /* fault on microkernel stack access */
+#define ILL_FPEOPR_FAULT	0x3 /* invalid floating operation */
+
+/* Codes for SIGTRAP.  */
+#define DBG_SINGLE_TRAP		0x1 /* single step */
+#define DBG_BRKPNT_FAULT	0x2 /* breakpoint instruction */
+
+#endif /* sc_pc */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/crt0.S real-libc/sysdeps/l4/hurd/i386/crt0.S
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/crt0.S	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/i386/crt0.S	2003-05-19 03:54:53.000000000 +0200
@@ -0,0 +1,62 @@
+/* Startup code for statically linked root server.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU Hurd.
+
+   The GNU Hurd 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 Hurd 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+	/* Beginning of the text segment, which must start with _start.  */
+	.text
+	.globl _start
+_start:
+	/* Clear the frame pointer.  The ABI suggests this be done, to mark
+	   the outermost frame obviously.  */
+	xorl %ebp, %ebp
+
+	/* Load the ESP register with the small stack below.  */
+	leal __stack, %esp
+
+	/* Call the start function.  */
+	call start
+
+	/* Shutdown.  */
+	pushl %eax
+	pushl $halt_message
+	call printf
+
+loop:	jmp loop
+
+halt_message:
+	.asciz "Exit code: 0x%x.  System halted."
+
+
+	/* The multiboot header follows.  It must be within the first
+	8192 bytes of the binary image, and longword aligned.  */
+	.align 4
+__mb_header:
+	/* The magic.  */
+	.long 0x1BADB002;
+	/* The flags.  */
+	.long 0x00000000;
+	/* The checksum (must add to zero with the magic and flags.  */
+	.long -0x1BADB002;
+	
+
+	/* Beginning of the bss segment.  */
+	.bss
+
+	/* The stack space.  */
+	.space	0x1000
+__stack:
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/init-first.c real-libc/sysdeps/l4/hurd/i386/init-first.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/init-first.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/i386/init-first.c	2003-05-19 18:20:00.000000000 +0200
@@ -0,0 +1,386 @@
+/* Initialization code run first thing by the ELF startup code.  For i386/Hurd.
+   Copyright (C) 1995,96,97,98,99,2000,2001,02 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <assert.h>
+#include <hurd.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sysdep.h>
+#include <set-hooks.h>
+#include <hurd/threadvar.h>
+#include "hurdstartup.h"
+#if 0
+#include "hurdmalloc.h"		/* XXX */
+#endif
+#include "../locale/localeinfo.h"
+
+#include <ldsodefs.h>
+#include <fpu_control.h>
+
+#include <l4.h>
+#include <l4/globals.h>
+#include <l4/stubs-init.h>
+
+extern void __libc_init (int, char **, char **);
+extern void __init_misc (int, char **, char **);
+#ifdef USE_NONOPTION_FLAGS
+extern void __getopt_clean_environment (char **);
+#endif
+#ifndef SHARED
+extern void _dl_non_dynamic_init (void) internal_function;
+#endif
+extern void __libc_global_ctors (void);
+
+unsigned int __hurd_threadvar_max;
+unsigned long int __hurd_threadvar_stack_offset;
+unsigned long int __hurd_threadvar_stack_mask;
+
+#ifndef SHARED
+int __libc_enable_secure;
+#endif
+int __libc_multiple_libcs attribute_hidden = 1;
+
+extern int __libc_argc attribute_hidden;
+extern char **__libc_argv attribute_hidden;
+extern char **_dl_argv;
+
+
+void *(*_cthread_init_routine) (void); /* Returns new SP to use.  */
+void (*_cthread_exit_routine) (int status) __attribute__ ((__noreturn__));
+
+/* Things that want to be run before _hurd_init or much anything else.
+   Importantly, these are called before anything tries to use malloc.  */
+DEFINE_HOOK (_hurd_preinit_hook, (void));
+
+
+/* We call this once the Hurd magic is all set up and we are ready to be a
+   Posixoid program.  This does the same things the generic version does.  */
+static void
+posixland_init (int argc, char **argv, char **envp)
+{
+  __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
+
+  /* Make sure we don't initialize twice.  */
+  if (!__libc_multiple_libcs)
+    {
+      /* Set the FPU control word to the proper default value.  */
+      __setfpucw (__fpu_control);
+    }
+
+  /* Save the command-line arguments.  */
+  __libc_argc = argc;
+  __libc_argv = argv;
+  __environ = envp;
+
+#ifndef SHARED
+  _dl_non_dynamic_init ();
+#endif
+  __init_misc (argc, argv, envp);
+  __libc_init (argc, argv, envp);
+
+#ifdef USE_NONOPTION_FLAGS
+  /* This is a hack to make the special getopt in GNU libc working.  */
+  __getopt_clean_environment (envp);
+#endif
+
+#ifdef SHARED
+  __libc_global_ctors ();
+#endif
+}
+
+
+static void
+init1 (int argc, char *arg0, ...)
+{
+  char **argv = &arg0;
+  char **envp = &argv[argc + 1];
+  struct hurd_startup_data *d;
+
+  while (*envp)
+    ++envp;
+  d = (void *) ++envp;
+
+#if 0
+  /* If we are the bootstrap task started by the kernel,
+     then after the environment pointers there is no Hurd
+     data block; the argument strings start there.  */
+  if ((void *) d != argv[0])
+    {
+      _hurd_init_dtable = d->dtable;
+      _hurd_init_dtablesize = d->dtablesize;
+
+      {
+	/* Check if the stack we are now on is different from
+	   the one described by _hurd_stack_{base,size}.  */
+
+	char dummy;
+	const vm_address_t newsp = (vm_address_t) &dummy;
+
+	if (d->stack_size != 0 && (newsp < d->stack_base ||
+				   newsp - d->stack_base > d->stack_size))
+	  /* The new stack pointer does not intersect with the
+	     stack the exec server set up for us, so free that stack.  */
+	  __vm_deallocate (__mach_task_self (), d->stack_base, d->stack_size);
+      }
+    }
+
+  if ((void *) d != argv[0] && (d->portarray || d->intarray))
+    /* Initialize library data structures, start signal processing, etc.  */
+    _hurd_init (d->flags, argv,
+		d->portarray, d->portarraysize,
+		d->intarray, d->intarraysize);
+#endif
+
+#if 0
+#ifndef SHARED
+  __libc_enable_secure = d->flags & EXEC_SECURE;
+#endif
+#endif
+}
+
+
+static inline void
+init (int *data)
+{
+  int argc = *data;
+  char **argv = (void *) (data + 1);
+  char **envp = &argv[argc + 1];
+  struct hurd_startup_data *d;
+  unsigned long int threadvars[_HURD_THREADVAR_MAX];
+
+  /* Provide temporary storage for thread-specific variables on the
+     startup stack so the cthreads initialization code can use them
+     for malloc et al, or so we can use malloc below for the real
+     threadvars array.  */
+  memset (threadvars, 0, sizeof threadvars);
+  threadvars[_HURD_THREADVAR_LOCALE] = (unsigned long int) &_nl_global_locale;
+  __hurd_threadvar_stack_offset = (unsigned long int) threadvars;
+
+  /* Since the cthreads initialization code uses malloc, and the
+     malloc initialization code needs to get at the environment, make
+     sure we can find it.  We'll need to do this again later on since
+     switching stacks changes the location where the environment is
+     stored.  */
+  __environ = envp;
+
+  while (*envp)
+    ++envp;
+  d = (void *) ++envp;
+
+  /* The user might have defined a value for this, to get more variables.
+     Otherwise it will be zero on startup.  We must make sure it is set
+     properly before before cthreads initialization, so cthreads can know
+     how much space to leave for thread variables.  */
+  if (__hurd_threadvar_max < _HURD_THREADVAR_MAX)
+    __hurd_threadvar_max = _HURD_THREADVAR_MAX;
+
+
+  /* After possibly switching stacks, call `init1' (above) with the user
+     code as the return address, and the argument data immediately above
+     that on the stack.  */
+
+  if (_cthread_init_routine)
+    {
+      /* Initialize cthreads, which will allocate us a new stack to run on.  */
+      void *newsp = (*_cthread_init_routine) ();
+      struct hurd_startup_data *od;
+
+      void switch_stacks (void);
+
+      /* Copy per-thread variables from that temporary
+	 area onto the new cthread stack.  */
+      memcpy (__hurd_threadvar_location_from_sp (0, newsp),
+	      threadvars, sizeof threadvars);
+
+      /* Copy the argdata from the old stack to the new one.  */
+      newsp = memcpy (newsp - ((char *) &d[1] - (char *) data), data,
+		      (char *) d - (char *) data);
+
+#ifdef SHARED
+      /* And readjust the dynamic linker's idea of where the argument
+         vector lives.  */
+      assert (_dl_argv == argv);
+      _dl_argv = (void *) ((int *) newsp + 1);
+#endif
+
+      /* Set up the Hurd startup data block immediately following
+	 the argument and environment pointers on the new stack.  */
+      od = (newsp + ((char *) d - (char *) data));
+      if ((void *) argv[0] == d)
+	/* We were started up by the kernel with arguments on the stack.
+	   There is no Hurd startup data, so zero the block.  */
+	memset (od, 0, sizeof *od);
+      else
+	/* Copy the Hurd startup data block to the new stack.  */
+	*od = *d;
+
+      /* Push the user code address on the top of the new stack.  It will
+	 be the return address for `init1'; we will jump there with NEWSP
+	 as the stack pointer.  */
+      *--(int *) newsp = data[-1];
+      ((void **) data)[-1] = switch_stacks;
+      /* Force NEWSP into %ecx and &init1 into %eax, which are not restored
+	 by function return.  */
+      asm volatile ("# a %0 c %1" : : "a" (newsp), "c" (&init1));
+    }
+  else
+    {
+      /* We are not using cthreads, so we will have just a single allocated
+	 area for the per-thread variables of the main user thread.  */
+      unsigned long int *array;
+      unsigned int i;
+      int usercode;
+
+      void call_init1 (void);
+
+      array = malloc (__hurd_threadvar_max * sizeof (unsigned long int));
+      if (array == NULL)
+	__libc_fatal ("Can't allocate single-threaded thread variables.");
+
+      /* Copy per-thread variables from the temporary array into the
+	 newly malloc'd space.  */
+      memcpy (array, threadvars, sizeof threadvars);
+      __hurd_threadvar_stack_offset = (unsigned long int) array;
+      for (i = _HURD_THREADVAR_MAX; i < __hurd_threadvar_max; ++i)
+	array[i] = 0;
+
+      /* The argument data is just above the stack frame we will unwind by
+	 returning.  Mutate our own return address to run the code below.  */
+      usercode = data[-1];
+      ((void **) data)[-1] = call_init1;
+      /* Force USERCODE into %eax and &init1 into %ecx, which are not
+	 restored by function return.  */
+      asm volatile ("# a %0 c %1" : : "a" (usercode), "c" (&init1));
+    }
+}
+
+/* These bits of inline assembler used to be located inside `init'.
+   However they were optimized away by gcc 2.95.  */
+
+/* The return address of `init' above, was redirected to here, so at
+   this point our stack is unwound and callers' registers restored.
+   Only %ecx and %eax are call-clobbered and thus still have the
+   values we set just above.  Fetch from there the new stack pointer
+   we will run on, and jmp to the run-time address of `init1'; when it
+   returns, it will run the user code with the argument data at the
+   top of the stack.  */
+asm ("switch_stacks:\n"
+     "	movl %eax, %esp\n"
+     "	jmp *%ecx");
+
+/* As in the stack-switching case, at this point our stack is unwound
+   and callers' registers restored, and only %ecx and %eax communicate
+   values from the lines above.  In this case we have stashed in %eax
+   the user code return address.  Push it on the top of the stack so
+   it acts as init1's return address, and then jump there.  */
+asm ("call_init1:\n"
+     "	push %eax\n"
+     "	jmp *%ecx\n");
+
+
+/* Do the first essential initializations that must precede all else.  */
+static inline void
+first_init (void)
+{
+  /* Initialize system call stubs and global variables.  */
+  l4_init ();
+
+  /* Initialize data structures so we can do RPCs.  */
+  
+  RUN_HOOK (_hurd_preinit_hook, ());
+}
+
+#ifdef SHARED
+/* This function is called specially by the dynamic linker to do early
+   initialization of the shared C library before normal initializers
+   expecting a Posixoid environment can run.  It gets called with the
+   stack set up just as the user will see it, so it can switch stacks.  */
+
+void
+_dl_init_first (int argc, ...)
+{
+  first_init ();
+
+  init (&argc);
+}
+#endif
+
+
+#ifdef SHARED
+/* The regular posixland initialization is what goes into libc's
+   normal initializer.  */
+/* NOTE!  The linker notices the magical name `_init' and sets the DT_INIT
+   pointer in the dynamic section based solely on that.  It is convention
+   for this function to be in the `.init' section, but the symbol name is
+   the only thing that really matters!!  */
+strong_alias (posixland_init, _init);
+
+void
+__libc_init_first (int argc, char **argv, char **envp)
+{
+  /* Everything was done in the shared library initializer, _init.  */
+}
+#else
+strong_alias (posixland_init, __libc_init_first);
+
+
+/* XXX This is all a crock and I am not happy with it.
+   This poorly-named function is called by static-start.S,
+   which should not exist at all.  */
+void
+_hurd_stack_setup (volatile int argc, ...)
+{
+  void doinit (intptr_t *data)
+    {
+      /* This function gets called with the argument data at TOS.  */
+      void doinit1 (volatile int argc, ...)
+	{
+	  init ((int *) &argc);
+	}
+
+      /* Push the user return address after the argument data, and then
+         jump to `doinit1' (above), so it is as if __libc_init_first's
+         caller had called `doinit1' with the argument data already on the
+         stack.  */
+      *--data = (&argc)[-1];
+      asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack.  */
+		    "movl $0, %%ebp\n" /* Clear outermost frame pointer.  */
+		    "jmp *%1" : : "r" (data), "r" (&doinit1) : "sp", "bp");
+      /* NOTREACHED */
+    }
+
+  first_init ();
+
+  _hurd_startup ((void **) &argc, &doinit);
+}
+
+
+/* This function is defined here so that if this file ever gets into
+   ld.so we will get a link error.  Having this file silently included
+   in ld.so causes disaster, because the _init definition above will
+   cause ld.so to gain an init function, which is not a cool thing. */
+
+void
+_dl_start (void)
+{
+  abort ();
+}
+
+#endif
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/static-start.S real-libc/sysdeps/l4/hurd/i386/static-start.S
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/static-start.S	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/i386/static-start.S	2003-05-19 04:02:15.000000000 +0200
@@ -0,0 +1,28 @@
+/* Startup code for statically linked Hurd/i386 binaries.
+   Copyright (C) 1998 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+	.text
+	.globl _start
+_start:
+	call _hurd_stack_setup
+	xorl %edx, %edx
+	jmp _start1
+
+#define _start _start1
+#include <sysdeps/i386/elf/start.S>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/sys/io.h real-libc/sysdeps/l4/hurd/i386/sys/io.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/i386/sys/io.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/i386/sys/io.h	2003-05-19 01:49:26.000000000 +0200
@@ -0,0 +1,178 @@
+/* Access to hardware i/o ports.  GNU/x86 version.
+   Copyright (C) 2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef	_SYS_IO_H
+#define	_SYS_IO_H	1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* If TURN_ON is TRUE, request for permission to do direct i/o on the
+   port numbers in the range [FROM,FROM+NUM-1].  Otherwise, turn I/O
+   permission off for that range.  This call requires root privileges.  */
+extern int ioperm (unsigned long int __from, unsigned long int __num,
+                   int __turn_on) __THROW;
+
+/* Set the I/O privilege level to LEVEL.  If LEVEL>3, permission to
+   access any I/O port is granted.  This call requires root
+   privileges. */
+extern int iopl (int __level) __THROW;
+
+#if defined __GNUC__ && __GNUC__ >= 2
+
+static __inline unsigned char
+inb (unsigned short int port)
+{
+  unsigned char _v;
+
+  __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port));
+  return _v;
+}
+
+static __inline unsigned char
+inb_p (unsigned short int port)
+{
+  unsigned char _v;
+
+  __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port));
+  return _v;
+}
+
+static __inline unsigned short int
+inw (unsigned short int port)
+{
+  unsigned short _v;
+
+  __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port));
+  return _v;
+}
+
+static __inline unsigned short int
+inw_p (unsigned short int port)
+{
+  unsigned short int _v;
+
+  __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port));
+  return _v;
+}
+
+static __inline unsigned int
+inl (unsigned short int port)
+{
+  unsigned int _v;
+
+  __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port));
+  return _v;
+}
+
+static __inline unsigned int
+inl_p (unsigned short int port)
+{
+  unsigned int _v;
+  __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port));
+  return _v;
+}
+
+static __inline void
+outb (unsigned char value, unsigned short int port)
+{
+  __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port));
+}
+
+static __inline void
+outb_p (unsigned char value, unsigned short int port)
+{
+  __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (value),
+			"Nd" (port));
+}
+
+static __inline void
+outw (unsigned short int value, unsigned short int port)
+{
+  __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port));
+
+}
+
+static __inline void
+outw_p (unsigned short int value, unsigned short int port)
+{
+  __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (value),
+			"Nd" (port));
+}
+
+static __inline void
+outl (unsigned int value, unsigned short int port)
+{
+  __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port));
+}
+
+static __inline void
+outl_p (unsigned int value, unsigned short int port)
+{
+  __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (value),
+			"Nd" (port));
+}
+
+static __inline void
+insb (unsigned short int port, void *addr, unsigned long int count)
+{
+  __asm__ __volatile__ ("cld ; rep ; insb":"=D" (addr),
+			"=c" (count):"d" (port), "0" (addr), "1" (count));
+}
+
+static __inline void
+insw (unsigned short int port, void *addr, unsigned long int count)
+{
+  __asm__ __volatile__ ("cld ; rep ; insw":"=D" (addr),
+			"=c" (count):"d" (port), "0" (addr), "1" (count));
+}
+
+static __inline void
+insl (unsigned short int port, void *addr, unsigned long int count)
+{
+  __asm__ __volatile__ ("cld ; rep ; insl":"=D" (addr),
+			"=c" (count):"d" (port), "0" (addr), "1" (count));
+}
+
+static __inline void
+outsb (unsigned short int port, const void *addr, unsigned long int count)
+{
+  __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (addr),
+			"=c" (count):"d" (port), "0" (addr), "1" (count));
+}
+
+static __inline void
+outsw (unsigned short int port, const void *addr, unsigned long int count)
+{
+  __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (addr),
+			"=c" (count):"d" (port), "0" (addr), "1" (count));
+}
+
+static __inline void
+outsl (unsigned short int port, const void *addr, unsigned long int count)
+{
+  __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (addr),
+			"=c" (count):"d" (port), "0" (addr), "1" (count));
+}
+
+#endif	/* GNU C */
+
+__END_DECLS
+#endif /* _SYS_IO_H */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/ifreq.h real-libc/sysdeps/l4/hurd/ifreq.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/ifreq.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/ifreq.h	2003-05-19 05:26:59.000000000 +0200
@@ -0,0 +1,43 @@
+/* Fetch the host's network interface list.  Hurd version.
+   Copyright (C) 2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <net/if.h>
+#include <sys/socket.h>
+#include <sys/mman.h>
+
+
+static inline void
+__ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd)
+{
+  *num_ifs = 0;
+  *ifreqs = NULL;
+}
+
+
+static inline struct ifreq *
+__if_nextreq (struct ifreq *ifr)
+{
+  return ifr + 1;
+}
+
+
+static inline void
+__if_freereq (struct ifreq *ifreqs, int num_ifs)
+{
+}
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/Implies real-libc/sysdeps/l4/hurd/Implies
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/Implies	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/Implies	2003-05-19 04:14:22.000000000 +0200
@@ -0,0 +1,5 @@
+# The gnu subdirectory exists for things common to both Linux-based and
+# Hurd-based GNU systems.
+gnu
+# The Hurd provides a rough superset of the functionality of 4.4 BSD.
+unix/bsd/bsd4.4
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/lxstat.c real-libc/sysdeps/l4/hurd/lxstat.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/lxstat.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/lxstat.c	2003-05-19 16:28:43.000000000 +0200
@@ -0,0 +1,27 @@
+/* Copyright (C) 1991,1992,1995,1996,1997,2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/stat.h>
+
+int
+__lxstat (int version, const char *file, struct stat *buf)
+{
+  return __xstat (version, file, buf);
+}
+hidden_def (__lxstat)
+weak_alias (__lxstat, _lxstat)
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/Makeconfig real-libc/sysdeps/l4/hurd/Makeconfig
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/Makeconfig	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/Makeconfig	2003-05-19 03:53:41.000000000 +0200
@@ -0,0 +1,4 @@
+# We need special startup code for statically linked binaries.
+# See Makefile in this directory for the rule that builds this.
+# We must define this variable earlier than sysdeps Makefiles are included.
+static-start-installed-name = crt0.o
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/Makefile real-libc/sysdeps/l4/hurd/Makefile
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/Makefile	2003-05-19 16:09:20.000000000 +0200
@@ -0,0 +1,58 @@
+# Copyright (C) 1993,94,95,96,97,98,99,2000,2001,2002, 2003
+#	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, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifdef in-Makerules
+
+# Look for header files in hurd-l4/ under the top-level library source
+# directory.  Look for generated header files where they get created.
+includes += -I$(..)hurd-l4
+
+# We use the style `if (err = call(...))' a lot in the Hurd code,
+# where we have a lot of functions that return zero or an errno code.
++cflags += -Wno-parentheses
+
+# Do not use any assembly code from sysdeps/unix (and subdirectories).
+# This bypasses all the system call stubs and uses any existing posix or
+# generic C files instead.
+inhibit-sysdep-asm += unix*
+inhibit-unix-syscalls = yes
+
+# Don't try to generate anything from the installed Unix system and its
+# libraries.  That is only of use when building for a Unix system, so as to
+# be compatible with some existing binaries for that system.
+inhibit-glue = yes
+
+
+ifeq ($(subdir),csu)
+
+sysdep_routines += set-init
+extra-objs += static-start.o
+
+# We need special startup code for statically linked binaries.
+$(objpfx)crt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o
+	$(link-relocatable)
+
+endif
+
+
+ifeq ($(subdir),sunrpc)
+sysdep_headers += nfs/nfs.h
+endif
+
+endif	# in-Makerules
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/mknod.c real-libc/sysdeps/l4/hurd/mknod.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/mknod.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/mknod.c	2003-05-19 16:30:28.000000000 +0200
@@ -0,0 +1,45 @@
+/* Copyright (C) 1995, 1996, 2001 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/* This definition is only used if inlining fails for this function; see
+   the last page of <sys/stat.h>.  The real work is done by the `x'
+   function which is passed a version number argument.  We arrange in the
+   makefile that when not inlined this function is always statically
+   linked; that way a dynamically-linked executable always encodes the
+   version number corresponding to the data structures it uses, so the `x'
+   functions in the shared library can adapt without needing to recompile
+   all callers.  */
+
+int
+__mknod (const char *path, mode_t mode, dev_t dev)
+{
+  return __xmknod (_MKNOD_VER, path, mode, &dev);
+}
+
+weak_alias (__mknod, mknod)
+
+/* Hide the symbol so that no definition but the one locally in the
+   executable or DSO is used.  */
+#ifdef HAVE_DOT_HIDDEN
+asm (".hidden\tmknod");
+asm (".hidden\t__mknod");
+#endif
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/nfs/nfs.h real-libc/sysdeps/l4/hurd/nfs/nfs.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/nfs/nfs.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/nfs/nfs.h	2003-05-19 19:22:35.000000000 +0200
@@ -0,0 +1,32 @@
+/* <nfs/nfs.h> -- ill-specified NFS-related definitions
+   Copyright (C) 1999 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _NFS_NFS_H
+#define _NFS_NFS_H 1
+
+/* This file is empty for now.  Its contents do not seem to be
+   standardized in any way.  It exists solely for the sake of
+   <rpcsvc/bootparam_prot.h> which insists on including <nfs/nfs.h>.
+
+   For the time being, we just provide this file here to smooth building
+   the libc distribution (i.e. librpcsvc).  We do not install this file for
+   users, since we haven't really figured out what the right thing to go
+   here is.  */
+
+#endif /* nfs/nfs.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/open64.c real-libc/sysdeps/l4/hurd/open64.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/open64.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/open64.c	2003-05-19 04:30:08.000000000 +0200
@@ -0,0 +1,57 @@
+/* Copyright (C) 1991, 1995, 1996, 1997, 1999, 2000, 2002
+   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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <bp-sym.h>
+
+/* Open FILE with access OFLAG.  If OFLAG includes O_CREAT,
+   a third argument is the file protection.  */
+int
+__libc_open64 (file, oflag)
+     const char *file;
+     int oflag;
+{
+  int mode;
+
+  if (file == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  if (oflag & O_CREAT)
+    {
+      va_list arg;
+      va_start (arg, oflag);
+      mode = va_arg (arg, int);
+      va_end (arg);
+    }
+
+  __set_errno (ENOSYS);
+  return -1;
+}
+strong_alias (__libc_open64, __open64)
+libc_hidden_def (__open64)
+weak_alias (__libc_open64, BP_SYM (open64))
+
+stub_warning (open64)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/open.c real-libc/sysdeps/l4/hurd/open.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/open.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/open.c	2003-05-19 16:20:48.000000000 +0200
@@ -0,0 +1,60 @@
+/* Copyright (C) 1992,93,94,95,97,2000,2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <hurd.h>
+#if 0
+#include <hurd/fd.h>
+#endif
+
+/* Open FILE with access OFLAG.  If OFLAG includes O_CREAT,
+   a third argument is the file protection.  */
+int
+__libc_open (const char *file, int oflag, ...)
+{
+  mode_t mode;
+#if 0
+  io_t port;
+#endif
+
+  if (oflag & O_CREAT)
+    {
+      va_list arg;
+      va_start (arg, oflag);
+      mode = va_arg (arg, mode_t);
+      va_end (arg);
+    }
+  else
+    mode = 0;
+
+#if 0
+  port = __file_name_lookup (file, oflag, mode);
+  if (port == MACH_PORT_NULL)
+#endif
+    return -1;
+#if 0
+  return _hurd_intern_fd (port, oflag, 1);
+#endif
+}
+
+libc_hidden_def (__libc_open)
+weak_alias (__libc_open, __open)
+libc_hidden_weak (__open)
+weak_alias (__libc_open, open)
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/readdir.c real-libc/sysdeps/l4/hurd/readdir.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/readdir.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/readdir.c	2003-05-19 16:33:30.000000000 +0200
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+
+/* Read a directory entry from DIRP.  */
+struct dirent *
+__readdir (DIR *dirp)
+{
+  __set_errno (ENOSYS);
+  return NULL;
+}
+weak_alias (__readdir, readdir)
+
+stub_warning (readdir)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/set-init.c real-libc/sysdeps/l4/hurd/set-init.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/set-init.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/set-init.c	2003-05-19 04:00:24.000000000 +0200
@@ -0,0 +1,23 @@
+/* Copyright (C) 1991, 1992, 1994, 1995, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+#include <set-hooks.h>
+
+DEFINE_HOOK_RUNNER (__libc_subinit, __libc_init,
+		    (int argc, char **argv, char **envp), (argc, argv, envp))
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/siglist.h real-libc/sysdeps/l4/hurd/siglist.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/siglist.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/siglist.h	2003-05-19 04:10:04.000000000 +0200
@@ -0,0 +1,23 @@
+/* Copyright (C) 1999, 2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This file is included multiple times.  */
+
+#include_next <siglist.h>	/* Get the canonical list.  */
+
+#define	OLD_SIGLIST_SIZE	33 /* For GLIBC_2.0 binary compatibility.  */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/Subdirs real-libc/sysdeps/l4/hurd/Subdirs
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/Subdirs	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/Subdirs	2003-05-19 14:39:17.000000000 +0200
@@ -0,0 +1 @@
+hurd-l4
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/sys/param.h real-libc/sysdeps/l4/hurd/sys/param.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/sys/param.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/sys/param.h	2003-05-19 04:49:36.000000000 +0200
@@ -0,0 +1,132 @@
+/* Copyright (C) 1993, 1994, 1995, 1997, 1999 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This file is deprecated and is provided only for compatibility with
+   Unix systems.  It is unwise to include this file on programs which
+   are intended only for GNU systems.
+
+   Parts from:
+
+ * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)param.h	7.23 (Berkeley) 5/6/91
+ */
+
+
+#ifndef	_SYS_PARAM_H
+
+#define	_SYS_PARAM_H	1
+#include <features.h>
+
+#define __need_NULL
+#include <stddef.h>
+
+#include <sys/types.h>
+#include <errno.h>
+#include <signal.h>
+#include <endian.h>
+#include <limits.h>
+#ifdef notyet
+# include <ufs/param.h>
+#endif
+
+
+/* What versions of BSD we are compatible with.  */
+#define	BSD	199306		/* System version (year & month). */
+#define BSD4_3	1
+#define BSD4_4	1
+
+#define	GNU	1994100		/* GNU version (year, month, and release).  */
+
+
+/* BSD names for some <limits.h> values.  We do not define the BSD names
+   for the values which are not statically limited, such as NOFILE.  */
+
+#define	NBBY		CHAR_BIT
+#define	NGROUPS		NGROUPS_MAX
+#define	MAXSYMLINKS	SYMLOOP_MAX
+#define	CANBSIZ		MAX_CANON /* XXX ? */
+
+/* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to
+   compare against some fixed limit.  */
+#define	NCARGS		INT_MAX
+
+/* There is nothing quite equivalent in GNU to Unix "mounts", but there is
+   no limit on the number of simultaneously attached filesystems.  */
+#define NMOUNT		INT_MAX
+
+
+/* Magical constants.  */
+#define	NOGROUP	65535		/* Marker for empty group set member.  */
+#define	NODEV	((dev_t) -1)	/* Non-existent device.  */
+
+
+/* Bit map related macros.  */
+#define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+#define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+#define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+#define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+
+/* Macros for counting and rounding.  */
+#ifndef howmany
+# define howmany(x, y)	(((x)+((y)-1))/(y))
+#endif
+#define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
+#define powerof2(x)	((((x)-1)&(x))==0)
+
+/* Macros for min/max.  */
+#define	MIN(a,b) (((a)<(b))?(a):(b))
+#define	MAX(a,b) (((a)>(b))?(a):(b))
+
+
+/* Scale factor for scaled integers used to count %cpu time and load avgs.
+
+   The number of CPU `tick's that map to a unique `%age' can be expressed
+   by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
+   can be calculated (assuming 32 bits) can be closely approximated using
+   the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).  */
+
+#define	FSHIFT	11		/* Bits to right of fixed binary point.  */
+#define FSCALE	(1<<FSHIFT)
+
+#endif	 /* sys/param.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/xstat.c real-libc/sysdeps/l4/hurd/xstat.c
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/hurd/xstat.c	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/hurd/xstat.c	2003-05-19 16:04:06.000000000 +0200
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <stddef.h>
+
+/* Get file information about FILE in BUF.  */
+int
+__xstat (int vers, const char *file, struct stat *buf)
+{
+  if (vers != _STAT_VER || file == NULL || buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  __set_errno (ENOSYS);
+  return -1;
+}
+hidden_def (__xstat)
+stub_warning (stat)
+weak_alias (__xstat, _xstat)
+#include <stub-tag.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/ipc.h real-libc/sysdeps/l4/i386/l4/bits/ipc.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/ipc.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/ipc.h	2003-05-12 17:28:21.000000000 +0200
@@ -0,0 +1,7 @@
+#ifndef _L4_IPC_H
+# error "Never use <l4/bits/ipc.h> directly; include <l4/ipc.h> instead."
+#endif
+
+#define l4_allocate_new_cache_lines		1
+#define l4_do_not_allocate_new_cache_lines	2
+#define l4_allocate_only_new_cache_lines	3
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/kip.h real-libc/sysdeps/l4/i386/l4/bits/kip.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/kip.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/kip.h	2003-05-12 16:34:40.000000000 +0200
@@ -0,0 +1,6 @@
+#ifndef _L4_KIP_H
+# error "Never use <l4/bits/kip.h> directly; include <l4/kip.h> instead."
+#endif
+
+/* Kernel features.  */
+#define L4_FEATURE_SMALLSPACES "smallspaces"
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/math.h real-libc/sysdeps/l4/i386/l4/bits/math.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/math.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/math.h	2003-05-10 04:50:49.000000000 +0200
@@ -0,0 +1,24 @@
+#ifndef _L4_MATH_H
+# error "Never use <l4/bits/math.h> directly; include <l4/math.h> instead."
+#endif
+
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+_L4_EXTERN_INLINE l4_word_t
+__l4_msb_ (l4_word_t data) __attribute__((__const__));
+
+_L4_EXTERN_INLINE l4_word_t
+__l4_msb_ (l4_word_t data)
+{
+  l4_word_t msb;
+
+  __asm__ ("bsr %[data], %[msb]"
+	   : [msb] "=r" (msb)
+	   : [data] "rm" (data));
+
+  return msb;
+}
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/misc.h real-libc/sysdeps/l4/i386/l4/bits/misc.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/misc.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/misc.h	2003-05-12 17:29:51.000000000 +0200
@@ -0,0 +1,9 @@
+#ifndef _L4_MISC_H
+# error "Never use <l4/bits/misc.h> directly; include <l4/misc.h> instead."
+#endif
+
+#define l4_uncacheable_memory		1
+#define l4_write_combining_memory	2
+#define l4_write_through_memory		5
+#define l4_write_protected_memory	6
+#define l4_write_back_memory		7
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/space.h real-libc/sysdeps/l4/i386/l4/bits/space.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/space.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/space.h	2003-05-13 14:47:16.000000000 +0200
@@ -0,0 +1,69 @@
+#ifndef _L4_SPACE_H
+# error "Never use <l4/bits/space.h> directly; include <l4/space.h> instead."
+#endif
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+/* IO Fpages.  */
+
+typedef _L4_RAW
+(l4_word_t, _L4_STRUCT1
+ ({
+   _L4_BITFIELD4
+     (l4_word_t,
+      _L4_BITFIELD (rights, 4),
+      _L4_BITFIELD (_two, 2),
+      _L4_BITFIELD (log2_size, 6),
+      _L4_BITFIELD_32_64 (base, 16, 48));
+ })) l4_io_fpage_t;
+  
+_L4_EXTERN_INLINE l4_fpage_t
+l4_io_fpage (l4_word_t base_address, int size)
+{
+  l4_fpage_t fpage;
+  l4_io_fpage_t io_fpage;
+  l4_word_t msb = __l4_msb (size);
+
+  io_fpage.rights = 0;
+  io_fpage._two = 2;
+  io_fpage.log2_size = (1 << msb) == size ? msb : msb + 1;
+  io_fpage.base = base_address;
+  fpage.raw = io_fpage.raw;
+  return fpage;
+}
+
+
+_L4_EXTERN_INLINE l4_fpage_t
+l4_io_fpage_log2 (l4_word_t base_address, int log2_size)
+{
+  l4_fpage_t fpage;
+  l4_io_fpage_t io_fpage;
+
+  io_fpage.rights = 0;
+  io_fpage._two = 2;
+  io_fpage.log2_size = log2_size;
+  io_fpage.base = base_address;
+  fpage.raw = io_fpage.raw;
+  return fpage;  
+}
+
+
+/* l4_space_control control argument.  */
+
+#define L4_LARGE_SPACE		0
+#define L4_SMALL_SPACE		(1 << 31)
+
+/* LOC and SIZE are in MB.  */
+_L4_EXTERN_INLINE l4_word_t
+l4_small_space (l4_word_t loc, l4_word_t size)
+{
+  l4_word_t small_space = loc >> 1;	/* Divide by 2 (MB).  */
+  l4_word_t two_pow_p = size >> 2;	/* Divide by 4 (MB).  */
+
+  /* Make P the LSB of small_space.  */
+  small_space = (small_space & ~(two_pow_p - 1)) | two_pow_p;
+  return small_space & 0xff;
+}
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/stubs.h real-libc/sysdeps/l4/i386/l4/bits/stubs.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/stubs.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/stubs.h	2003-05-10 00:46:29.000000000 +0200
@@ -0,0 +1,17 @@
+#ifndef _L4_STUBS_H
+# error "Never use <l4/bits/stubs.h> directly; include <l4/stubs.h> instead."
+#endif
+
+typedef void (*__l4_syscall_stub_t) (void);
+
+__l4_syscall_stub_t __l4_exchange_registers;
+__l4_syscall_stub_t __l4_thread_control;
+__l4_syscall_stub_t __l4_system_clock;
+__l4_syscall_stub_t __l4_thread_switch;
+__l4_syscall_stub_t __l4_schedule;
+__l4_syscall_stub_t __l4_ipc;
+__l4_syscall_stub_t __l4_lipc;
+__l4_syscall_stub_t __l4_unmap;
+__l4_syscall_stub_t __l4_space_control;
+__l4_syscall_stub_t __l4_processor_control;
+__l4_syscall_stub_t __l4_memory_control;
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/stubs-init.h real-libc/sysdeps/l4/i386/l4/bits/stubs-init.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/stubs-init.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/stubs-init.h	2003-05-10 00:45:50.000000000 +0200
@@ -0,0 +1,26 @@
+#ifndef _L4_STUBS_INIT_H
+# error "Never use <l4/bits/stubs-init.h> directly; include <l4/stubs-init.h> instead."
+#endif
+
+#define __L4_SETUP_SYSCALL(name)					\
+extern void (*__l4_ ## name) (void);					\
+  __l4_ ## name = (void (*) (void))					\
+    (((l4_word_t) l4_get_kernel_interface ())				\
+     + l4_get_kernel_interface ()->name)
+
+/* Initialize the syscall stubs.  */
+_L4_EXTERN_INLINE void
+l4_init_stubs (void)
+{
+  __L4_SETUP_SYSCALL (exchange_registers);
+  __L4_SETUP_SYSCALL (thread_control);
+  __L4_SETUP_SYSCALL (system_clock);
+  __L4_SETUP_SYSCALL (thread_switch);
+  __L4_SETUP_SYSCALL (schedule);
+  __L4_SETUP_SYSCALL (ipc);
+  __L4_SETUP_SYSCALL (lipc);
+  __L4_SETUP_SYSCALL (unmap);
+  __L4_SETUP_SYSCALL (space_control);
+  __L4_SETUP_SYSCALL (processor_control);
+  __L4_SETUP_SYSCALL (memory_control);
+};
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/syscall.h real-libc/sysdeps/l4/i386/l4/bits/syscall.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/syscall.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/syscall.h	2003-05-19 00:17:05.000000000 +0200
@@ -0,0 +1,288 @@
+#ifndef _L4_SYSCALL_H
+# error "Never use <l4/bits/syscall.h> directly; include <l4/syscall.h> instead."
+#endif
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+/* Return the pointer to the kernel interface page, the API version,
+   the API flags, and the kernel ID.  */
+_L4_EXTERN_INLINE l4_kip_t
+l4_kernel_interface (l4_api_version_t *api_version, l4_api_flags_t *api_flags,
+		     l4_kernel_id_t *kernel_id) __attribute__ ((__pure__));
+
+_L4_EXTERN_INLINE l4_kip_t
+l4_kernel_interface (l4_api_version_t *api_version, l4_api_flags_t *api_flags,
+		     l4_kernel_id_t *kernel_id)
+{
+  void *kip;
+
+  /* The KernelInterface system call is invoked by "lock; nop" and
+     returns a pointer to the kernel interface page in %eax, the API
+     version in %ecx, the API flags in %edx, and the kernel ID in
+     %esi.  */
+  __asm__ ("  lock; nop\n"
+	   : "=a" (kip), "=c" (api_version->raw),
+	   "=d" (api_flags->raw), "=S" (kernel_id->raw));
+
+  return kip;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_exchange_registers (l4_thread_id_t *dest, l4_word_t *control,
+		       l4_word_t *sp, l4_word_t *ip, l4_word_t *flags,
+		       l4_word_t *user_defined_handle, l4_thread_id_t *pager)
+{
+  /* We can not invoke the system call directly using GCC inline
+     assembler, as the system call requires the PAGER argument to be
+     in %ebp, and that is used by GCC to locate the function arguments
+     on the stack, and there is no other free register we can use to
+     hold the PAGER argument temporarily.  So we must pass a pointer
+     to an array of two function arguments in one register, one of
+     them being the PAGER, the other being the one to be stored in the
+     register used to hold the array pointer.  */
+  struct
+  {
+    l4_word_t ebp;
+    l4_word_t esi;
+  } regs = { pager->raw, *ip };
+ 
+  __asm__ __volatile__ ("pushl %%ebp\n"
+			"pushl %%esi\n"
+			/* After saving %ebp and &regs on the stack,
+			   set up the remaining system call
+			   arguments.  */
+			"movl (%%esi), %%ebp\n"
+			"movl 4(%%esi), %%esi\n"
+			"call *__l4_exchange_registers\n"
+
+			/* Temporarily exchange %esi with &regs on the
+			   stack and store %ebp.  */
+			"xchgl %%esi, (%%esp)\n"
+			"movl %%ebp, (%%esi)\n"
+			/* Pop %esi that was returned from the syscall.  */
+			"popl %%esi\n"
+			"popl %%ebp\n"
+			: "=a" (dest->raw), "=c" (*control), "=d" (*sp),
+			"=S" (*ip), "=D" (*flags), "=b" (*user_defined_handle)
+			: "a" (dest->raw), "c" (*control), "d" (*sp),
+			"S" (&regs), "D" (*flags), "b" (*user_defined_handle)
+			: "memory");
+
+  pager->raw = regs.ebp;
+  return;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_thread_control (l4_thread_id_t dest, l4_thread_id_t space,
+		   l4_thread_id_t scheduler, l4_thread_id_t pager,
+		   void *utcb_loc)
+{
+  l4_word_t result;
+  l4_word_t dummy;
+
+  __asm__ __volatile__ ("push %%ebp\n"
+			"call *__l4_thread_control\n"
+			"pop %%ebp\n"
+			: "=a" (result), "=c" (dummy),
+			"=d" (dummy), "=S" (dummy), "=D" (dummy)
+			: "a" (dest.raw), "c" (pager.raw),
+			"d" (scheduler.raw), "S" (space.raw),
+			"D" (utcb_loc)
+			: "ebx");
+  return result;
+}
+
+
+_L4_EXTERN_INLINE l4_clock_t
+l4_system_clock (void)
+{
+  l4_clock_t time;
+
+  __asm__ __volatile__ ("call *__l4_system_clock"
+			: "=A" (time)
+			:
+			: "ecx", "esi");
+
+  return time;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_thread_switch (l4_thread_id_t dest)
+{
+  __asm__ __volatile__ ("call *__l4_thread_switch"
+			:
+			: "a" (dest.raw));
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_schedule (l4_thread_id_t dest, l4_word_t time_control,
+	     l4_word_t proc_control, l4_word_t prio,
+	     l4_word_t preempt_control, l4_word_t *old_time_control)
+{
+  l4_word_t result;
+  l4_word_t dummy;
+
+  __asm__ __volatile__ ("push %%ebp\n"
+			"call *__l4_schedule\n"
+			"pop %%ebp\n"
+			: "=a" (result), "=d" (*old_time_control),
+			"=c" (dummy), "=S" (dummy), "=D" (dummy)
+			: "a" (dest), "c" (prio), "d" (time_control),
+			"S" (proc_control), "D" (preempt_control)
+			: "ebx");
+
+  return result;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_unmap (l4_word_t control)
+{
+  l4_word_t mr0;
+  l4_word_t utcb;
+  l4_word_t dummy;
+
+  l4_store_mr (0, &mr0);
+  utcb = (l4_word_t) __l4_utcb ();
+
+  __asm__ __volatile__ ("push %%ebp\n"
+			"call *__l4_unmap\n"
+			"pop %%ebp\n"
+			: "=a" (mr0), "=c" (dummy), "=d" (dummy)
+			: "a" (mr0), "c" (utcb), "d" (control)
+			: "esi", "edi", "ebx");
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_space_control (l4_thread_id_t space, l4_word_t control,
+		  l4_fpage_t kip_area, l4_fpage_t utcb_area,
+		  l4_thread_id_t redirector, l4_word_t *old_control)
+{
+  l4_word_t result;
+  l4_word_t dummy;
+
+  __asm__ __volatile__ ("push %%ebp\n"
+			"call *__l4_space_control\n"
+			"pop %%ebp\n"
+			: "=a" (result), "=c" (*old_control),
+			"=d" (dummy), "=S" (dummy), "=D" (dummy)
+			: "a" (space.raw), "c" (control),
+			"d" (kip_area.raw), "S" (utcb_area.raw),
+			"D" (redirector.raw)
+			: "ebx");
+  return result;
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_ipc (l4_thread_id_t to, l4_thread_id_t from_spec,
+	l4_word_t timeouts, l4_thread_id_t *from)
+{
+  l4_word_t mr[2];
+  l4_word_t utcb;
+  l4_msg_tag_t tag;
+  l4_thread_id_t result;
+  l4_word_t dummy;
+
+  utcb = (l4_word_t) __l4_utcb ();
+  l4_store_mr (0, &tag.raw);
+  l4_store_mr (1, &mr[0]);
+  l4_store_mr (2, &mr[1]);
+
+  __asm__ __volatile__ ("push %%ebp\n"
+			"call *__l4_ipc\n"
+			"movl %%ebp, %%ecx\n"
+			"pop %%ebp\n"
+			: "=a" (result.raw), "=c" (mr[1]), "=d" (dummy),
+			"=S" (tag.raw), "=b" (mr[0])
+			: "a" (to.raw), "c" (timeouts), "d" (from_spec.raw),
+			"S" (tag.raw), "D" (utcb));
+  /* FIXME: Make it so that we can use l4_is_nilthread?  */
+  if (from_spec.raw)
+    {
+      *from = result;
+      l4_load_mr (1, mr[0]);
+      l4_load_mr (2, mr[1]);
+    }
+  return tag;
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_lipc (l4_thread_id_t to, l4_thread_id_t from_spec,
+	 l4_word_t timeouts, l4_thread_id_t *from)
+{
+  l4_word_t mr[2];
+  l4_word_t utcb;
+  l4_msg_tag_t tag;
+  l4_thread_id_t result;
+  l4_word_t dummy;
+
+  utcb = (l4_word_t) __l4_utcb ();
+  l4_store_mr (0, &tag.raw);
+  l4_store_mr (1, &mr[0]);
+  l4_store_mr (2, &mr[1]);
+
+  __asm__ __volatile__ ("push %%ebp\n"
+			"call *__l4_lipc\n"
+			"movl %%ebp, %%ecx\n"
+			"pop %%ebp\n"
+			: "=a" (result.raw), "=c" (mr[1]), "=d" (dummy),
+			"=S" (tag.raw), "=b" (mr[0])
+			: "a" (to.raw), "c" (timeouts), "d" (from_spec.raw),
+			"S" (tag.raw), "D" (utcb));
+  /* FIXME: Make it so that we can use l4_is_nilthread?  */
+  if (from_spec.raw)
+    {
+      *from = result;
+      l4_load_mr (1, mr[0]);
+      l4_load_mr (2, mr[1]);
+    }
+  return tag;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_processor_control (l4_word_t proc, l4_word_t control, l4_word_t int_freq,
+		      l4_word_t ext_freq, l4_word_t voltage)
+{
+  l4_word_t result;
+  l4_word_t dummy;
+
+  __asm__ __volatile__ ("push %%ebp\n"
+			"call *__l4_processor_control\n"
+			"pop %%ebp\n"
+			: "=a" (result), "=c" (dummy),
+			"=d" (dummy), "=S" (dummy), "=D" (dummy)
+			: "a" (proc), "c" (control), "d" (int_freq),
+			"S" (ext_freq), "D" (voltage)
+			: "ebx");
+  return result;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_memory_control (l4_word_t control, l4_word_t *attributes)
+{
+  l4_word_t tag;
+  l4_word_t dummy;
+
+  l4_store_mr (0, &tag);
+
+  __asm__ __volatile__ ("push %%ebp\n"
+			"call *__l4_memory_control\n"
+			"pop %%ebp\n"
+			: "=a" (dummy), "=c" (dummy), "=d" (dummy),
+			"=S" (dummy), "=D" (dummy), "=b" (dummy)
+			: "a" (tag), "c" (control), "d" (attributes[0]),
+			"S" (attributes[1]), "D" (attributes[2]),
+			"b" (attributes[3]));
+}
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/types.h real-libc/sysdeps/l4/i386/l4/bits/types.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/types.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/types.h	2003-05-12 16:33:50.000000000 +0200
@@ -0,0 +1,9 @@
+#ifndef _L4_TYPES_H
+# error "Never use <l4/bits/types.h> directly; include <l4/types.h> instead."
+#endif
+
+/* ia32 has 32 bits per word.  */
+#define L4_WORDSIZE	L4_WORDSIZE_32
+
+/* ia32 is little-endian.  */
+#define L4_BYTE_ORDER	L4_LITTLE_ENDIAN
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/vregs.h real-libc/sysdeps/l4/i386/l4/bits/vregs.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/l4/bits/vregs.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/l4/bits/vregs.h	2003-05-12 17:30:28.000000000 +0200
@@ -0,0 +1,394 @@
+#ifndef _L4_VREGS_H
+# error "Never use <l4/bits/vregs.h> directly; include <l4/vregs.h> instead."
+#endif
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+/* Retrieve the UTCB address.  */
+static inline l4_word_t *
+__l4_utcb (void)
+{
+  l4_word_t *utcb;
+
+  __asm__ ("movl %%gs:0, %[utcb]"
+	   : [utcb] "=r" (utcb));
+
+  return utcb;
+}
+
+/* Offsets of various elements in the UTCB, relativ to the UTCB
+   address.  */
+#define __L4_UTCB_MR0		0
+#define __L4_UTCB_THREAD_WORD0	-4
+#define __L4_UTCB_THREAD_WORD1	-5
+#define __L4_UTCB_SENDER	-6
+#define __L4_UTCB_RECEIVER	-7
+#define __L4_UTCB_TIMEOUT	-8
+#define __L4_UTCB_ERROR_CODE	-9
+#define __L4_UTCB_FLAGS		-10
+#define __L4_UTCB_EXC_HANDLER	-11
+#define __L4_UTCB_PAGER		-12
+#define __L4_UTCB_USER_HANDLE	-13
+#define __L4_UTCB_PROCESSOR_NO	-14
+#define __L4_UTCB_MY_GLOBAL_ID	-15
+#define __L4_UTCB_BR0		-16
+
+
+/* Get the local thread ID.  */
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_my_local_id (void)
+{
+  l4_thread_id_t id;
+
+  /* Local thread ID is equal to the UTCB address.  */
+  id.raw = (l4_word_t) __l4_utcb ();
+
+  return id;
+}
+
+
+/* Get the global thread ID.  */
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_my_global_id (void)
+{
+  l4_thread_id_t id;
+  l4_word_t *utcb = __l4_utcb ();
+
+  id.raw = utcb[__L4_UTCB_MY_GLOBAL_ID];
+  return id;
+}
+
+
+_L4_EXTERN_INLINE int
+l4_processor_no (void)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  return utcb[__L4_UTCB_PROCESSOR_NO];
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_user_defined_handle (void)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  return utcb[__L4_UTCB_USER_HANDLE];
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_user_defined_handle (l4_word_t data)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  utcb[__L4_UTCB_USER_HANDLE] = data;
+}
+
+
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_pager (void)
+{
+  l4_thread_id_t thread;
+  l4_word_t *utcb = __l4_utcb ();
+
+  thread.raw = utcb[__L4_UTCB_PAGER];
+  return thread;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_pager (l4_thread_id_t thread)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  utcb[__L4_UTCB_PAGER] = thread.raw;
+}
+
+
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_exception_handler (void)
+{
+  l4_thread_id_t thread;
+  l4_word_t *utcb = __l4_utcb ();
+
+  thread.raw = utcb[__L4_UTCB_EXC_HANDLER];
+  return thread;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_exception_handler (l4_thread_id_t thread)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  utcb[__L4_UTCB_EXC_HANDLER] = thread.raw;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_clr_cop_flag (l4_word_t n)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  /* The second byte in the flags field contains the coprocessor
+     flags.  */
+  __asm__ ("andl %[mask], %[where]"
+	   :
+	   : [mask] "ir" (~(1 << (8 + n))),
+	   [where] "m" (utcb[__L4_UTCB_FLAGS]));
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_cop_flag (l4_word_t n)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  /* The second byte in the flags field contains the coprocessor
+     flags.  */
+  __asm__ ("orl %[mask], %[where]"
+	   :
+	   : [mask] "ir" (1 << (8 + n)),
+	   [where] "m" (utcb[__L4_UTCB_FLAGS]));
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_disable_preemption_fault_exception (void)
+{
+  l4_word_t *utcb = __l4_utcb ();
+  l4_uint8_t result;
+
+  /* The first byte in the flags field contains the preemption
+     flags.  The sixth bit is the signal bit*/
+  __asm__ ("btr %[offset], %[base]\n"
+	   "setc %[result]"
+	   : [result] "=r" (result)
+	   : [offset] "i" (5), [base] "m" (utcb[__L4_UTCB_FLAGS]));
+
+  return result;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_enable_preemption_fault_exception (void)
+{
+  l4_word_t *utcb = __l4_utcb ();
+  l4_uint8_t result;
+
+  /* The first byte in the flags field contains the preemption
+     flags.  The sixth bit is the signal flag.  */
+  __asm__ ("bts %[offset], %[base]\n"
+	   "setc %[result]"
+	   : [result] "=r" (result)
+	   : [offset] "i" (5), [base] "m" (utcb[__L4_UTCB_FLAGS]));
+
+  return result;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_disable_preemption (void)
+{
+  l4_word_t *utcb = __l4_utcb ();
+  l4_uint8_t result;
+
+  /* The first byte in the flags field contains the preemption
+     flags.  The seventh bit is the delay flag.  */
+  __asm__ ("btr %[offset], %[base]\n"
+	   "setc %[result]"
+	   : [result] "=r" (result)
+	   : [offset] "i" (6), [base] "m" (utcb[__L4_UTCB_FLAGS]));
+
+  return result;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_enable_preemption (void)
+{
+  l4_word_t *utcb = __l4_utcb ();
+  l4_uint8_t result;
+
+  /* The first byte in the flags field contains the preemption
+     flags.  The seventh bit is the delay flag.  */
+  __asm__ ("bts %[offset], %[base]\n"
+	   "setc %[result]"
+	   : [result] "=r" (result)
+	   : [offset] "i" (6), [base] "m" (utcb[__L4_UTCB_FLAGS]));
+
+  return result;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_preemption_pending (void)
+{
+  l4_word_t *utcb = __l4_utcb ();
+  l4_uint8_t result;
+
+  /* The first byte in the flags field contains the preemption
+     flags.  The eighth bit is the pending flag.  */
+  __asm__ ("btr %[offset], %[base]\n"
+	   "setc %[result]"
+	   : [result] "=r" (result)
+	   : [offset] "i" (7), [base] "m" (utcb[__L4_UTCB_FLAGS]));
+
+  return result;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_error_code (void)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  return utcb[__L4_UTCB_ERROR_CODE];
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_xfer_timeout (void)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  return utcb[__L4_UTCB_TIMEOUT];
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_xfer_timeout (l4_word_t time)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  utcb[__L4_UTCB_TIMEOUT] = time;
+}
+
+
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_intended_receiver (void)
+{
+  l4_thread_id_t thread;
+  l4_word_t *utcb = __l4_utcb ();
+
+  thread.raw = utcb[__L4_UTCB_RECEIVER];
+  return thread;
+}
+
+
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_actual_sender (void)
+{
+  l4_thread_id_t thread;
+  l4_word_t *utcb = __l4_utcb ();
+
+  thread.raw = utcb[__L4_UTCB_SENDER];
+  return thread;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_virtual_sender (l4_thread_id_t thread)
+{
+  l4_word_t *utcb = __l4_utcb ();
+
+  utcb[__L4_UTCB_SENDER] = thread.raw;
+}
+
+
+/* Message registers (MR0 to MR63) start at offset __L4_UTCB_MR0 and
+   go upward.  The spec doesn't say this, but we can use __L4_UTCB_MR0
+   to store the first message register MR0 until we do an actual
+   system call, although only MR1 to MR63 are actually memory
+   mapped.  */
+
+/* Set message register NR to DATA.  */
+_L4_EXTERN_INLINE void
+l4_load_mr (int nr, l4_word_t data)
+{
+  l4_word_t *mr = __l4_utcb () + __L4_UTCB_MR0;
+
+  mr[nr] = data;
+}
+
+
+/* Set COUNT message registers beginning from START to the values in
+   DATA.  */
+_L4_EXTERN_INLINE void
+l4_load_mrs (int start, int count, l4_word_t *data)
+{
+  l4_word_t *mr = __l4_utcb () + __L4_UTCB_MR0 + start;
+
+  while (count--)
+    *(mr++) = *(data++);
+}
+
+
+/* Store message register NR in DATA.  */
+_L4_EXTERN_INLINE void
+l4_store_mr (int nr, l4_word_t *data)
+{
+  l4_word_t *mr = __l4_utcb () + __L4_UTCB_MR0;
+
+  *data = mr[nr];
+}
+
+
+/* Store COUNT message registers beginning from START in DATA.  */
+_L4_EXTERN_INLINE void
+l4_store_mrs (int start, int count, l4_word_t *data)
+{
+  l4_word_t *mr = __l4_utcb () + __L4_UTCB_MR0 + start;
+
+  while (count--)
+    *(data++) = *(mr++);
+}
+
+
+/* Buffer registers (BR0 to BR31) start at offset __L4_UTCB_BR0 and go
+   downward.  */
+
+/* Set message register NR to DATA.  */
+_L4_EXTERN_INLINE void
+l4_load_br (int nr, l4_word_t data)
+{
+  l4_word_t *br = __l4_utcb () + __L4_UTCB_BR0;
+
+  br[nr] = data;
+}
+
+
+/* Set COUNT message registers beginning from START to the values in
+   DATA.  */
+_L4_EXTERN_INLINE void
+l4_load_brs (int start, int count, l4_word_t *data)
+{
+  l4_word_t *br = __l4_utcb () + __L4_UTCB_BR0 - start;
+
+  while (count--)
+    *(br--) = *(data--);
+}
+
+
+/* Store message register NR in DATA.  */
+_L4_EXTERN_INLINE void
+l4_store_br (int nr, l4_word_t *data)
+{
+  l4_word_t *br = __l4_utcb () + __L4_UTCB_BR0;
+
+  *data = br[nr];
+}
+
+
+/* Store COUNT message registers beginning from START in DATA.  */
+_L4_EXTERN_INLINE void
+l4_store_brs (int start, int count, l4_word_t *data)
+{
+  l4_word_t *br = __l4_utcb () + __L4_UTCB_BR0 - start;
+
+  while (count--)
+    *(data--) = *(br--);
+}
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/machine-lock.h real-libc/sysdeps/l4/i386/machine-lock.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/machine-lock.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/machine-lock.h	2003-05-14 14:31:09.000000000 +0200
@@ -0,0 +1,66 @@
+/* Machine-specific definition for spin locks.  i386 version.
+   Copyright (C) 1994, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _MACHINE_LOCK_H
+#define	_MACHINE_LOCK_H
+
+/* The type of a spin lock variable.  */
+
+typedef __volatile int __spin_lock_t;
+
+/* Value to initialize `__spin_lock_t' variables to.  */
+
+#define	__SPIN_LOCK_INITIALIZER	0
+
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+/* Unlock LOCK.  */
+
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+   register int __unlocked;
+   __asm__ __volatile ("xchgl %0, %1"
+		       : "=&r" (__unlocked), "=m" (*__lock) : "0" (0));
+}
+
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has.  */
+
+_EXTERN_INLINE int
+__spin_try_lock (__spin_lock_t *__lock)
+{
+  register int __locked;
+  __asm__ __volatile ("xchgl %0, %1"
+		      : "=&r" (__locked), "=m" (*__lock) : "0" (1));
+  return !__locked;
+}
+
+/* Return nonzero if LOCK is locked.  */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+  return *__lock != 0;
+}
+
+
+#endif /* machine-lock.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/machine-sp.h real-libc/sysdeps/l4/i386/machine-sp.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/machine-sp.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/machine-sp.h	2003-05-14 02:15:28.000000000 +0200
@@ -0,0 +1,31 @@
+/* Machine-specific function to return the stack pointer.  i386 version.
+   Copyright (C) 1994,97,2001 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* Return the current stack pointer.  */
+
+#define __thread_stack_pointer() ({					      \
+  void *__sp__;								      \
+  __asm__ ("movl %%esp, %0" : "=r" (__sp__));				      \
+  __sp__;								      \
+})
+
+#endif	/* machine-sp.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/sysdep.h real-libc/sysdeps/l4/i386/sysdep.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/i386/sysdep.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/i386/sysdep.h	2003-05-19 03:29:21.000000000 +0200
@@ -0,0 +1,71 @@
+/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifdef i486
+#define TEXT_ALIGN      4
+#else
+#define TEXT_ALIGN      2
+#endif
+#define DATA_ALIGN      2
+#define ALIGN           TEXT_ALIGN
+
+#define ENTRY(x)  .globl C_SYMBOL_NAME(x); .p2align TEXT_ALIGN; C_SYMBOL_NAME(x##:)
+
+
+#define LOSE asm volatile ("hlt")
+
+#define SNARF_ARGS(entry_sp, argc, argv, envp)				      \
+  do									      \
+    {									      \
+      register char **p;						      \
+      argc = (int) *entry_sp;						      \
+      argv = (char **) (entry_sp + 1);					      \
+      p = argv;								      \
+      while (*p++ != NULL)						      \
+	;								      \
+      if (p >= (char **) argv[0])					      \
+	--p;								      \
+      envp = p;							      \
+    } while (0)
+
+#define CALL_WITH_SP(fn, info, sp) \
+  do {									      \
+	void **ptr = (void **) sp;					      \
+	*--(__typeof (info) *) ptr = info;				      \
+	ptr[-1] = ptr;							      \
+	--ptr;								      \
+    asm volatile ("movl %0, %%esp; call %1" : : 			      \
+		  "g" (ptr), "m" (*(long int *) (fn)) : "%esp"); 	      \
+  } while (0)
+
+#define RETURN_TO(sp, pc, retval) \
+  asm volatile ("movl %0, %%esp; jmp %*%1 # %2" \
+		: : "g" (sp), "r" (pc), "a" (retval))
+
+
+#define STACK_GROWTH_DOWN
+
+/* Get the machine-independent Mach definitions.  */
+#include <sysdeps/l4/sysdep.h>
+
+
+/* This should be rearranged, but at the moment this file provides
+   the most useful definitions for assembler syntax details.  */
+#undef ENTRY
+#undef ALIGN
+#include <sysdeps/unix/i386/sysdep.h>
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/compat/types.h real-libc/sysdeps/l4/l4/compat/types.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/compat/types.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/compat/types.h	2003-05-14 21:44:33.000000000 +0200
@@ -0,0 +1,86 @@
+/*********************************************************************
+ *                
+ * Copyright (C) 2001, 2002, 2003,  Karlsruhe University
+ *                
+ * File path:     l4/types.h
+ * Description:   Commonly used L4 types
+ *                
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *                
+ * $Id: types.h,v 1.1.1.1 2003/05/02 11:37:58 l4hq Exp $
+ *                
+ ********************************************************************/
+
+#if defined(__cplusplus)
+static inline L4_Clock_t operator + (const L4_Clock_t &l, const int r)
+{
+  return (L4_Clock_t) { raw : l.raw + r };
+}
+
+static inline L4_Clock_t operator + (const L4_Clock_t & l, const L4_Uint64 t)
+{
+    return (L4_Clock_t) { raw : l.raw + t };
+}
+
+static inline L4_Clock_t operator - (const L4_Clock_t & c, const int r)
+{
+    return (L4_Clock_t) { raw : c.raw - r };
+}
+
+static inline L4_Clock_t operator - (const L4_Clock_t & c, const L4_Uint64 r)
+{
+    return (L4_Clock_t) { raw : c.raw - r };
+}
+#endif /* __cplusplus */
+
+
+#if defined(__cplusplus)
+static inline L4_Bool_t operator < (const L4_Clock_t &l, const L4_Clock_t &r)
+{
+    return l.raw < r.raw;
+}
+
+static inline L4_Bool_t operator > (const L4_Clock_t &l, const L4_Clock_t &r)
+{
+    return l.raw > r.raw;
+}
+
+static inline L4_Bool_t operator <= (const L4_Clock_t &l, const L4_Clock_t &r)
+{
+    return l.raw <= r.raw;
+}
+
+static inline L4_Bool_t operator >= (const L4_Clock_t &l, const L4_Clock_t &r)
+{
+    return l.raw >= r.raw;
+}
+
+static inline L4_Bool_t operator == (const L4_Clock_t &l, const L4_Clock_t &r)
+{
+    return l.raw == r.raw;
+}
+
+static inline L4_Bool_t operator != (const L4_Clock_t &l, const L4_Clock_t &r)
+{
+    return l.raw != r.raw;
+}
+#endif /* __cplusplus */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/globals.h real-libc/sysdeps/l4/l4/globals.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/globals.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/globals.h	2003-05-10 00:47:12.000000000 +0200
@@ -0,0 +1,7 @@
+/* Only include this file once in your application to prevent the need
+   to link with this library.  */
+
+#include <l4/kip.h>
+
+/* The global kernel interface page.  */
+l4_kip_t __l4_kip;
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/ipc.h real-libc/sysdeps/l4/l4/ipc.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/ipc.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/ipc.h	2003-05-12 17:51:33.000000000 +0200
@@ -0,0 +1,974 @@
+#ifndef _L4_IPC_H
+#define _L4_IPC_H	1
+
+#include <l4/types.h>
+#include <l4/bits/ipc.h>
+#include <l4/vregs.h>
+#include <l4/syscall.h>
+#include <l4/schedule.h>
+
+/* Message tags.  */
+
+#define l4_niltag	((l4_msg_tag_t) { .raw = 0 })
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_msg_tag_equal (l4_msg_tag_t tag1, l4_msg_tag_t tag2)
+{
+  return tag1.raw == tag2.raw;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_msg_tag_not_equal (l4_msg_tag_t tag1, l4_msg_tag_t tag2)
+{
+  return tag1.raw != tag2.raw;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_label (l4_msg_tag_t tag)
+{
+  return tag.label;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_untyped_words (l4_msg_tag_t tag)
+{
+  return tag.untyped;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_typed_words (l4_msg_tag_t tag)
+{
+  return tag.typed;
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_msg_tag_add_label (l4_msg_tag_t tag, l4_word_t label)
+{
+  l4_msg_tag_t new_tag = tag;
+  new_tag.label = label;
+  return new_tag;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_tag_add_label_to (l4_msg_tag_t *tag, l4_word_t label)
+{
+  tag->label = label;
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_msg_tag (void)
+{
+  l4_msg_tag_t tag;
+  l4_store_mr (0, &tag.raw);
+  return tag;
+}
+
+_L4_EXTERN_INLINE void
+l4_set_msg_tag (l4_msg_tag_t tag)
+{
+  l4_load_mr (0, tag.raw);
+}
+
+
+/* Map items.  */
+
+typedef union
+{
+  l4_word_t raw[2];
+  struct
+  {
+    _L4_BITFIELD4
+    (l4_word_t,
+     _L4_BITFIELD (not_last, 1),
+     _L4_BITFIELD (_four, 3),
+     _L4_BITFIELD (_zero, 6),
+     _L4_BITFIELD_32_64 (send_base, 22, 54));
+
+    l4_fpage_t send_fpage;
+  };
+} l4_map_item_t;
+
+
+_L4_EXTERN_INLINE l4_map_item_t
+l4_map_item (l4_fpage_t fpage, l4_word_t send_base)
+{
+  l4_map_item_t map_item;
+  map_item.not_last = 0;
+  map_item._four = 4;
+  map_item._zero = 0;
+  map_item.send_base = send_base / 1024;
+  map_item.send_fpage = fpage;
+  return map_item;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_map_item (l4_map_item_t map_item)
+{
+  return map_item._four == 4;
+}
+
+
+/* Grant items.  */
+
+typedef union
+{
+  l4_word_t raw[2];
+  struct
+  {
+    _L4_BITFIELD4
+    (l4_word_t,
+     _L4_BITFIELD (not_last, 1),
+     _L4_BITFIELD (_five, 3),
+     _L4_BITFIELD (_zero, 6),
+     _L4_BITFIELD_32_64 (send_base, 22, 54));
+
+    l4_fpage_t send_fpage;
+  };
+} l4_grant_item_t;
+
+
+_L4_EXTERN_INLINE l4_grant_item_t
+l4_grant_item (l4_fpage_t fpage, l4_word_t send_base)
+{
+  l4_grant_item_t grant_item;
+  grant_item.not_last = 0;
+  grant_item._five = 5;
+  grant_item._zero = 0;
+  grant_item.send_base = send_base / 1024;
+  grant_item.send_fpage = fpage;
+  return grant_item;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_grant_item (l4_grant_item_t grant_item)
+{
+  return grant_item._five == 5;
+}
+
+
+/* String items.  */
+
+typedef union
+{
+  l4_word_t raw[2];
+  struct
+  {
+    _L4_BITFIELD6
+    (l4_word_t,
+     _L4_BITFIELD (not_last, 1),
+     _L4_BITFIELD (cache_hint, 2),
+     _L4_BITFIELD (_zero, 1),
+     _L4_BITFIELD (nr_substrings, 5),
+     _L4_BITFIELD (cont, 1),
+     _L4_BITFIELD_32_64 (length, 22, 54));
+
+    l4_word_t string[1];
+  };
+} l4_string_item_t;
+
+
+typedef struct
+{
+  l4_word_t cache_hint;
+} l4_cache_allocation_hint_t;
+
+#define l4_use_default_cache_line_allocation \
+  ((l4_cache_allocation_hint_t) { .cache_hint = 0 })
+
+
+_L4_EXTERN_INLINE l4_string_item_t
+l4_string_item (int length, void *address)
+{
+  l4_string_item_t string_item;
+  string_item.not_last = 0;
+  string_item.cache_hint = l4_use_default_cache_line_allocation.cache_hint;
+  string_item._zero = 0;
+  string_item.nr_substrings = 0;
+  string_item.cont = 0;
+  string_item.length = length;
+  string_item.string[0] = (l4_word_t) address;
+  return string_item;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_string_item (l4_string_item_t *string_item)
+{
+  return string_item->_zero == 0;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_compound_string (l4_string_item_t *string_item)
+{
+  return string_item->cont;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_substrings (l4_string_item_t *string_item)
+{
+  return string_item->nr_substrings + 1;
+}
+
+
+_L4_EXTERN_INLINE void *
+l4_substring (l4_string_item_t *string_item, l4_word_t nr)
+{
+  return (void *) string_item->string[nr];
+}
+
+
+/* Append the string described by string item SOURCE to the string
+   described by string item STRING_ITEM.  */
+_L4_EXTERN_INLINE l4_string_item_t *
+l4_add_substring_address_to (l4_string_item_t *string_item,
+			     l4_string_item_t *source)
+{
+  l4_string_item_t *target = string_item;
+  int cont;
+
+  /* First search for end of target string item.  */
+  do
+    {
+      cont = target->cont;
+      if (!cont)
+	target->cont = 1;
+      target = (l4_string_item_t *)
+	(((void *) target) + 1 + target->nr_substrings + 1);
+    }
+  while (cont);
+
+  /* Now copy the source string item.  */
+  do
+    {
+      int nr = 1 + source->nr_substrings + 1;
+      cont = source->cont;
+      while (nr--)
+	*(target++) = *(source++);
+    }
+  while (cont);
+
+  return string_item;
+}
+
+
+/* Append the string described by string item SOURCE as a substring
+   (of the same length) to the string item STRING_ITEM.  */
+_L4_EXTERN_INLINE l4_string_item_t *
+l4_add_substring_to (l4_string_item_t *string_item, void *source)
+{
+  l4_string_item_t *target = string_item;
+
+  /* First search for end of target string item.  */
+  while (target->cont)
+    target = (l4_string_item_t *)
+      (((void *) target) + 1 + target->nr_substrings + 1);
+
+  /* Now add the source substring.  */
+  target->nr_substrings++;
+  target->string[target->nr_substrings + 1] = (l4_word_t) source;
+
+  return string_item;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_cache_allocation_hint_equal (l4_cache_allocation_hint_t hint1,
+				   l4_cache_allocation_hint_t hint2)
+{
+  return hint1.cache_hint == hint2.cache_hint;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_cache_allocation_hint_not_equal (l4_cache_allocation_hint_t hint1,
+				       l4_cache_allocation_hint_t hint2)
+{
+  return hint1.cache_hint != hint2.cache_hint;
+}
+
+
+_L4_EXTERN_INLINE l4_cache_allocation_hint_t
+l4_cache_allocation_hint (l4_string_item_t *string_item)
+{
+  l4_cache_allocation_hint_t hint;
+  hint.cache_hint = string_item->cache_hint;
+  return hint;
+}
+
+
+_L4_EXTERN_INLINE l4_string_item_t
+l4_add_cache_allocation_hint (l4_string_item_t string_item,
+			      l4_cache_allocation_hint_t hint)
+{
+  string_item.cache_hint = hint.cache_hint;
+  return string_item;
+}
+
+
+_L4_EXTERN_INLINE l4_string_item_t *
+l4_add_cache_allocation_hint_to (l4_string_item_t *string_item,
+				 l4_cache_allocation_hint_t hint)
+{
+  string_item->cache_hint = hint.cache_hint;
+  return string_item;
+}
+
+
+/* Acceptors and message buffers.  */
+typedef _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+  _L4_BITFIELD3
+    (l4_word_t,
+     _L4_BITFIELD (string_items, 1),
+     _L4_BITFIELD (_zero, 3),
+     _L4_BITFIELD_32_64 (rcv_window, 28, 60));
+})) l4_acceptor_t;
+
+#define l4_untyped_words_acceptor \
+  ((l4_acceptor_t) { .string_items = 0, ._zero = 0, .rcv_window = 0 })
+#define l4_string_items_acceptor \
+  ((l4_acceptor_t) { .string_items = 1, ._zero = 0, .rcv_window = 0 })
+
+
+typedef union
+{
+  l4_word_t br[33];
+  l4_string_item_t string_item[33];
+} l4_msg_buffer_t;
+
+
+_L4_EXTERN_INLINE l4_acceptor_t
+l4_map_grant_items (l4_fpage_t rcv_window)
+{
+  l4_acceptor_t acceptor;
+  acceptor.raw = rcv_window.raw;
+  acceptor.string_items = 1;
+  acceptor._zero = 0;
+  return acceptor;
+}
+
+
+_L4_EXTERN_INLINE l4_acceptor_t
+l4_add_acceptor (l4_acceptor_t acceptor1, l4_acceptor_t acceptor2)
+{
+  acceptor1.string_items |= acceptor2.string_items;
+  if (acceptor2.rcv_window)
+    acceptor1.rcv_window = acceptor2.rcv_window;
+  return acceptor1;
+}
+
+
+_L4_EXTERN_INLINE l4_acceptor_t *
+l4_add_acceptor_to (l4_acceptor_t *acceptor1, l4_acceptor_t acceptor2)
+{
+  acceptor1->string_items |= acceptor2.string_items;
+  if (acceptor2.rcv_window)
+    acceptor1->rcv_window = acceptor2.rcv_window;
+  return acceptor1;
+}
+
+
+_L4_EXTERN_INLINE l4_acceptor_t
+l4_remove_acceptor (l4_acceptor_t acceptor1, l4_acceptor_t acceptor2)
+{
+  acceptor1.string_items &= ~acceptor2.string_items;
+  if (acceptor2.rcv_window)
+    acceptor1.rcv_window = 0;
+  return acceptor1;
+}
+
+
+_L4_EXTERN_INLINE l4_acceptor_t *
+l4_remove_acceptor_from (l4_acceptor_t *acceptor1, l4_acceptor_t acceptor2)
+{
+  acceptor1->string_items &= ~acceptor2.string_items;
+  if (acceptor2.rcv_window)
+    acceptor1->rcv_window = 0;
+  return acceptor1;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_has_string_items (l4_acceptor_t acceptor)
+{
+  return acceptor.string_items;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_has_map_grant_items (l4_acceptor_t acceptor)
+{
+  return acceptor.rcv_window;
+}
+
+
+_L4_EXTERN_INLINE l4_fpage_t
+l4_rcv_window (l4_acceptor_t acceptor)
+{
+  l4_fpage_t fpage;
+  acceptor.string_items = 0;
+  fpage.raw = acceptor.raw;
+  return fpage;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_accept (l4_acceptor_t acceptor)
+{
+  l4_load_br (0, acceptor.raw);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_accept_strings (l4_acceptor_t acceptor, l4_msg_buffer_t *msg_buffer)
+{
+  l4_string_item_t *string_item = msg_buffer->string_item;
+  int br = 1;
+  int cont;
+
+  l4_load_br (0, acceptor.raw);
+  do
+    {
+      int nr = 1 + string_item->nr_substrings + 1;
+      cont = string_item->cont || string_item->not_last;
+      l4_load_brs (br, nr, (l4_word_t *) string_item);
+      br += nr;
+      string_item = (l4_string_item_t *) (((void *) string_item) + nr);
+    }
+  while (cont);
+}
+
+
+_L4_EXTERN_INLINE l4_acceptor_t
+l4_accepted (void)
+{
+  l4_acceptor_t acceptor;
+  l4_store_br (0, &acceptor.raw);
+  return acceptor;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_buffer_clear (l4_msg_buffer_t *msg_buffer)
+{
+  msg_buffer->br[0] = 0;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_buffer_append_simple_rcv_string (l4_msg_buffer_t *msg_buffer,
+					l4_string_item_t string_item)
+{
+  l4_string_item_t *target = msg_buffer->string_item;
+  int cont;
+
+  do
+    {
+      int nr = 1 + target->nr_substrings + 1;
+      cont = target->cont | target->not_last;
+      if (!cont)
+	target->not_last = 1;
+      target = (l4_string_item_t *) (((void *) target) + nr);
+    }
+  while (cont);
+
+  string_item.not_last = 0;
+  string_item.nr_substrings = 0;
+  *target = string_item;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_buffer_append_rcv_string (l4_msg_buffer_t *msg_buffer,
+				 l4_string_item_t *string_item)
+{
+  l4_string_item_t *target = msg_buffer->string_item;
+  l4_word_t *brp;
+  int cont;
+
+  /* Find the end of the message buffer.  */
+  do
+    {
+      int nr = 1 + target->nr_substrings + 1;
+      cont = target->cont | target->not_last;
+      if (!cont)
+	target->not_last = 1;
+      target = (l4_string_item_t *) (((void *) target) + nr);
+    }
+  while (cont);
+
+  brp = (l4_word_t *) target;
+
+  /* Copy the source string.  */
+  do
+    {
+      int nr = string_item->nr_substrings + 1;
+      l4_word_t *substrings = string_item->string;
+
+      cont = string_item->cont;
+      *(brp++) = string_item->raw[0];
+      while (nr-- > 0)
+	*(brp++) = *(substrings++);
+      string_item = (l4_string_item_t *) substrings;
+    }
+  while (cont);
+}
+
+
+/* Message composition.  */
+
+typedef union
+{
+  l4_msg_tag_t tag;
+  l4_word_t mr[64];
+} l4_msg_t;
+
+
+_L4_EXTERN_INLINE void
+l4_msg_put (l4_msg_t *msg, l4_word_t label, int untyped_nr, l4_word_t *untyped,
+	    int typed_nr, l4_word_t *typed)
+{
+  l4_word_t *mrs = msg->mr;
+
+  msg->tag.untyped = untyped_nr;
+  msg->tag.typed = typed_nr;
+  msg->tag.propagated = 0;
+  msg->tag.redirected = 0;
+  msg->tag.cross_cpu = 0;
+  msg->tag.error = 0;
+  msg->tag.label = label;
+
+  while (untyped_nr--)
+    *(mrs++) = *(untyped++);
+
+  while (typed_nr--)
+    *(mrs++) = *(typed++);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_get (l4_msg_t *msg, l4_word_t *untyped, l4_word_t *typed)
+{
+  l4_word_t *mr = msg->mr;
+  int untyped_nr = msg->tag.untyped;
+  int typed_nr = msg->tag.typed;
+
+  while (untyped_nr)
+    *(untyped++) = *(mr++);
+
+  while (typed_nr)
+    *(typed++) = *(mr++);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_msg_msg_tag (l4_msg_t *msg)
+{
+  return msg->tag;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_msg_msg_tag (l4_msg_t *msg, l4_msg_tag_t tag)
+{
+  msg->tag = tag;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_msg_label (l4_msg_t *msg)
+{
+  return msg->tag.label;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_msg_label (l4_msg_t *msg, l4_word_t label)
+{
+  msg->tag.label = label;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_load (l4_msg_t *msg)
+{
+  l4_load_mrs (0, 1 + msg->tag.untyped + msg->tag.typed, msg->mr);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_store (l4_msg_tag_t tag, l4_msg_t *msg)
+{
+  msg->tag = tag;
+  l4_store_mrs (1, msg->tag.untyped + msg->tag.typed, &msg->mr[1]);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_clear (l4_msg_t *msg)
+{
+  msg->tag = l4_niltag;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_append_word (l4_msg_t *msg, l4_word_t data)
+{
+  l4_word_t new_untyped_nr = ++msg->tag.untyped;
+  l4_word_t typed_nr = msg->tag.typed;
+
+  if (typed_nr)
+    {
+      l4_word_t *mrs = &msg->mr[new_untyped_nr + typed_nr];
+      while (typed_nr--)
+	{
+	  *(mrs) = *(mrs - 1);
+	  mrs--;
+	}
+      *mrs = data;
+    }
+  else
+    msg->mr[new_untyped_nr] = data;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_append_map_item (l4_msg_t *msg, l4_map_item_t map_item)
+{
+  /* The "not last" bit is ignored for sending.  */
+  int pos = 1 + msg->tag.untyped + msg->tag.typed;
+  msg->mr[pos++] = map_item.raw[0];
+  msg->mr[pos] = map_item.raw[1];
+  msg->tag.typed += 2;
+}
+    
+  
+_L4_EXTERN_INLINE void
+l4_msg_append_grant_item (l4_msg_t *msg, l4_grant_item_t grant_item)
+{
+  /* The "not last" bit is ignored for sending.  */
+  int pos = 1 + msg->tag.untyped + msg->tag.typed;
+  msg->mr[pos++] = grant_item.raw[0];
+  msg->mr[pos] = grant_item.raw[1];
+  msg->tag.typed += 2;
+}
+    
+  
+_L4_EXTERN_INLINE void
+l4_msg_append_simple_string_item (l4_msg_t *msg, l4_string_item_t string_item)
+{
+  /* The "not last" bit is ignored for sending.  */
+  int pos = 1 + msg->tag.untyped + msg->tag.typed;
+  string_item.cont = 0;
+  string_item.nr_substrings = 0;
+  msg->mr[pos++] = string_item.raw[0];
+  msg->mr[pos] = string_item.raw[1];
+  msg->tag.typed += 2;
+}
+    
+  
+_L4_EXTERN_INLINE void
+l4_msg_append_string_item (l4_msg_t *msg, l4_string_item_t *string_item)
+{
+  /* The "not last" bit is ignored for sending.  */
+  int pos = 1 + msg->tag.untyped + msg->tag.typed;
+  int cont;
+
+  do
+    {
+      int nr = string_item->nr_substrings + 1;
+      l4_word_t *substrings = string_item->string;
+
+      cont = string_item->cont;
+      msg->mr[pos++] = string_item->raw[0];
+      while (nr-- > 0)
+	msg->mr[pos++] = *(substrings++);
+      string_item = (l4_string_item_t *) substrings;
+    }
+  while (cont);
+
+  msg->tag.typed += pos - 1 - msg->tag.untyped;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_put_word (l4_msg_t *msg, l4_word_t nr, l4_word_t data)
+{
+  msg->mr[1 + nr] = data;
+}
+
+_L4_EXTERN_INLINE void
+l4_msg_put_map_item (l4_msg_t *msg, l4_word_t nr, l4_map_item_t map_item)
+{
+  l4_word_t pos = 1 + msg->tag.untyped + nr;
+  msg->mr[pos++] = map_item.raw[0];
+  msg->mr[pos] = map_item.raw[1];
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_put_grant_item (l4_msg_t *msg, l4_word_t nr, l4_grant_item_t grant_item)
+{
+  l4_word_t pos = 1 + msg->tag.untyped + nr;
+  msg->mr[pos++] = grant_item.raw[0];
+  msg->mr[pos] = grant_item.raw[1];
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_put_simple_string_item (l4_msg_t *msg, l4_word_t nr,
+			       l4_string_item_t string_item)
+{
+  l4_word_t pos = 1 + msg->tag.untyped + nr;
+  string_item.cont = 0;
+  string_item.nr_substrings = 0;
+  msg->mr[pos++] = string_item.raw[0];
+  msg->mr[pos] = string_item.raw[1];
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_put_string_item (l4_msg_t *msg, l4_word_t nr,
+			l4_string_item_t *string_item)
+{
+  l4_word_t pos = 1 + msg->tag.untyped + nr;
+  int cont;
+
+  do
+    {
+      int nr = string_item->nr_substrings + 1;
+      l4_word_t *substrings = string_item->string;
+
+      cont = string_item->cont;
+      msg->mr[pos++] = string_item->raw[0];
+      while (nr-- > 0)
+	msg->mr[pos++] = *(substrings++);
+      string_item = (l4_string_item_t *) substrings;
+    }
+  while (cont);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_get_word (l4_msg_t *msg, l4_word_t nr, l4_word_t *data)
+{
+  *data = msg->mr[1 + nr];
+}
+
+_L4_EXTERN_INLINE void
+l4_msg_get_map_item (l4_msg_t *msg, l4_word_t nr, l4_map_item_t *map_item)
+{
+  l4_word_t pos = 1 + msg->tag.untyped + nr;
+  map_item->raw[0] = msg->mr[pos++];
+  map_item->raw[1] = msg->mr[pos];
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_get_grant_item (l4_msg_t *msg, l4_word_t nr,
+		       l4_grant_item_t *grant_item)
+{
+  l4_word_t pos = 1 + msg->tag.untyped + nr;
+  grant_item->raw[0] = msg->mr[pos++];
+  grant_item->raw[1] = msg->mr[pos];
+}
+
+
+_L4_EXTERN_INLINE void
+l4_msg_get_string_item (l4_msg_t *msg, l4_word_t nr,
+			l4_string_item_t *string_item)
+{
+  l4_word_t pos = 1 + msg->tag.untyped + nr;
+  int cont;
+
+  do
+    {
+      int nr = string_item->nr_substrings + 1;
+      l4_word_t *substrings = string_item->string;
+
+      cont = string_item->cont;
+      msg->mr[pos++] = string_item->raw[0];
+      while (nr-- > 0)
+	*(substrings++) = msg->mr[pos++];
+      string_item = (l4_string_item_t *) substrings;
+    }
+  while (cont);
+}
+
+
+/* l4_ipc convenience interface.  */
+
+_L4_EXTERN_INLINE l4_word_t
+l4_timeouts (l4_time_t send_timeout, l4_time_t receive_timeout)
+{
+  return (send_timeout.raw << 16) | receive_timeout.raw;
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_call_timeouts (l4_thread_id_t dest, l4_time_t send_timeout,
+		  l4_time_t receive_timeout)
+{
+  l4_thread_id_t from;
+  return l4_ipc (dest, dest, l4_timeouts (send_timeout, receive_timeout),
+		 &from);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_call (l4_thread_id_t dest)
+{
+  return l4_call_timeouts (dest, l4_never, l4_never);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_send_timeout (l4_thread_id_t dest, l4_time_t send_timeout)
+{
+  l4_thread_id_t dummy;
+  return l4_ipc (dest, l4_nilthread, l4_timeouts (send_timeout, l4_zero_time),
+		 &dummy);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_send (l4_thread_id_t dest)
+{
+  return l4_send_timeout (dest, l4_never);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_reply (l4_thread_id_t dest)
+{
+  return l4_send_timeout (dest, l4_zero_time);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_receive_timeout (l4_thread_id_t from, l4_time_t receive_timeout)
+{
+  l4_thread_id_t dummy;
+  return l4_ipc (l4_nilthread, from,
+		 l4_timeouts (l4_zero_time, receive_timeout), &dummy);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_receive (l4_thread_id_t from)
+{
+  return l4_receive_timeout (from, l4_never);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_wait_timeout (l4_time_t receive_timeout, l4_thread_id_t *from)
+{
+  return l4_ipc (l4_nilthread, l4_anythread,
+		 l4_timeouts (l4_zero_time, receive_timeout), from);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_wait (l4_thread_id_t *from)
+{
+  return l4_wait_timeout (l4_never, from);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_reply_wait_timeout (l4_thread_id_t dest, l4_time_t receive_timeout,
+		       l4_thread_id_t *from)
+{
+  return l4_ipc (dest, l4_anythread,
+		 l4_timeouts (l4_time_period (0), receive_timeout), from);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_reply_wait (l4_thread_id_t dest, l4_thread_id_t *from)
+{
+  return l4_reply_wait_timeout (dest, l4_never, from);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_sleep (l4_time_t time)
+{
+  l4_set_msg_tag (l4_receive_timeout (l4_my_local_id (), time));
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_lcall (l4_thread_id_t dest)
+{
+  l4_thread_id_t dummy;
+  return l4_lipc (dest, dest, l4_timeouts (l4_never, l4_never), &dummy);
+}
+
+
+_L4_EXTERN_INLINE l4_msg_tag_t
+l4_lreply_wait (l4_thread_id_t dest, l4_thread_id_t *from)
+{
+  return l4_lipc (dest, dest, l4_timeouts (l4_time_period (0), l4_never),
+		  from);
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_ipc_succeeded (l4_msg_tag_t tag)
+{
+  return tag.error;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_ipc_failed (l4_msg_tag_t tag)
+{
+  return !tag.error;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_ipc_propagated (l4_msg_tag_t tag)
+{
+  return tag.propagated;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_ipc_redirected (l4_msg_tag_t tag)
+{
+  return tag.redirected;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_ipc_xcpu (l4_msg_tag_t tag)
+{
+  return tag.cross_cpu;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_propagation (l4_msg_tag_t *tag)
+{
+  tag->propagated = 1;
+}
+
+#endif	/* l4/ipc.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/kip.h real-libc/sysdeps/l4/l4/kip.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/kip.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/kip.h	2003-05-12 16:34:30.000000000 +0200
@@ -0,0 +1,571 @@
+#ifndef _L4_KIP_H
+#define _L4_KIP_H	1
+
+#include <l4/types.h>
+#include <l4/bits/kip.h>
+
+
+typedef _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+  _L4_BITFIELD4
+    (l4_word_t,
+     _L4_BITFIELD (__pad1, 16),
+
+     /* The subversion or revision.  */
+     _L4_BITFIELD (subversion, 8),
+
+     /* The interface version.  */
+     _L4_BITFIELD (version, 8),
+		  
+     _L4_BITFIELD_64 (__pad2, 32));
+})) l4_api_version_t;
+
+
+#define L4_API_FLAGS_LITTLE_ENDIAN	0x0
+#define L4_API_FLAGS_BIG_ENDIAN		0x1
+#define L4_API_FLAGS_WORDSIZE_32	0x0
+#define L4_API_FLAGS_WORDSIZE_64	0x1
+
+typedef _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+  _L4_BITFIELD3
+    (l4_word_t,
+     /* The endianess.  */
+     _L4_BITFIELD (endian, 2),
+
+     /* The word size.  */
+     _L4_BITFIELD (wordsize, 2),
+
+     _L4_BITFIELD_32_64 (__pad, 28, 60));
+})) l4_api_flags_t;
+ 
+
+typedef _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+  _L4_BITFIELD4
+    (l4_word_t,
+     _L4_BITFIELD (__pad, 16),
+
+     /* The kernel sub ID.  */
+     _L4_BITFIELD (subid, 8),
+
+     /* The kernel ID.  */
+     _L4_BITFIELD (id, 8),
+
+     _L4_BITFIELD_64 (__pad, 32));
+})) l4_kernel_id_t;
+
+
+typedef _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+  _L4_BITFIELD5
+    (l4_word_t,
+     /* Execute access right can be independently set.  */
+     _L4_BITFIELD (execute, 1),
+
+     /* Write access right can be independently set.  */
+     _L4_BITFIELD (write, 1),
+
+     /* Read access right can be independently set.  */
+     _L4_BITFIELD (read, 1),
+
+     _L4_BITFIELD (__pad, 7),
+
+     /* Page size of 2^(k + 10) is supported by hardware and kernel if
+	bit k is set.  */
+     _L4_BITFIELD_32_64 (page_size_mask, 22, 54));
+})) l4_page_info_t;
+
+
+typedef struct
+{
+  char magic[4];
+#if L4_WORDSIZE == L4_WORDSIZE_64
+  char __pad1[4];
+#endif
+
+  l4_api_version_t api_version;
+  l4_api_flags_t api_flags;
+
+  l4_word_t kern_desc_ptr;
+
+  l4_word_t __pad2[17];
+
+  _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+    _L4_BITFIELD2
+      (l4_word_t,
+       /* Number of memory descriptors.  */
+       _L4_BITFIELD_32_64 (nr, 16, 32),
+
+       /* Offset (in bytes) of memory descriptors in KIP.  */
+       _L4_BITFIELD_32_64 (mem_desc_ptr, 16, 32));
+  })) memory_info;
+
+  l4_word_t __pad3[20];
+
+  _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+    _L4_BITFIELD4
+      (l4_word_t,
+       /* UTCB size multiplier.  Size of one UTCB block is m *
+	  2^log2_align.  */
+       _L4_BITFIELD (size_mul, 10),
+
+       /* UTCB alignment requirement (must be aligned to 2^log2_align).  */
+       _L4_BITFIELD (log2_align, 6),
+
+       /* Minimal size for UTCB area is 2^log2_min_size.  */
+       _L4_BITFIELD (log2_min_size, 6),
+
+       _L4_BITFIELD_32_64 (__pad, 10, 42));
+  })) utcb_info;
+
+  _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+    _L4_BITFIELD2
+      (l4_word_t,
+       /* The size of the KIP area is 2^log2_size.  */
+       _L4_BITFIELD (log2_size, 6),
+
+       _L4_BITFIELD_32_64 (__pad, 26, 58));
+  })) kip_area_info;
+
+  l4_word_t __pad4[2];
+
+  l4_word_t boot_info;
+
+  /* Offset (in bytes) of processor descriptors in KIP.  */
+  l4_word_t proc_desc_ptr;
+
+  _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+    _L4_BITFIELD3
+      (l4_word_t,
+       /* Minimal time difference that can be read with the system
+	  clock syscall.  */
+       _L4_BITFIELD (read_precision, 16),
+
+       /* Maximal jitter for a scheduled thread activation.  */
+       _L4_BITFIELD (schedule_precision, 16),
+
+       _L4_BITFIELD_64 (__pad, 32));
+  })) clock_info;
+
+  _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+    _L4_BITFIELD4
+      (l4_word_t,
+       /* Number of valid thread number bits.  */
+       _L4_BITFIELD (log2_max_thread, 8),
+
+       /* Lowest thread number used for system threads.  */
+       _L4_BITFIELD (system_base, 12),
+
+       /* Lowest thread number available for user threads.  */
+       _L4_BITFIELD (user_base, 12),
+
+       _L4_BITFIELD_64 (__pad, 32));
+  })) thread_info;
+
+  l4_page_info_t page_info;
+
+  _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+    _L4_BITFIELD3
+      (l4_word_t,
+       /* The number of processors minus 1.  */
+       _L4_BITFIELD (processors, 16),
+
+       _L4_BITFIELD_32_64 (__pad, 12, 44),
+
+       /* The size of one processor description is 2^log2_size.  */
+       _L4_BITFIELD (log2_size, 4));
+  })) processor_info;
+
+  /* Privileged system call links.  */
+  l4_word_t space_control;
+  l4_word_t thread_control;
+  l4_word_t processor_control;
+  l4_word_t memory_control;
+
+  /* Normal system call links.  */
+  l4_word_t ipc;
+  l4_word_t lipc;
+  l4_word_t unmap;
+  l4_word_t exchange_registers;
+  l4_word_t system_clock;
+  l4_word_t thread_switch;
+  l4_word_t schedule;
+} *l4_kip_t;
+
+
+typedef struct
+{
+  _L4_BITFIELD5
+  (l4_word_t,
+   /* The type of the memory descriptor.  */
+   _L4_BITFIELD (type, 4),
+
+   /* The subtype of the memory descriptor if type is
+     L4_MEMDESC_BOOTLOADER or L4_MEMDESC_ARCH, otherwise
+     undefined.  */
+   _L4_BITFIELD (subtype, 4),
+
+   _L4_BITFIELD (__pad1, 1),
+
+   /* 1 if memory is virtual, 0 if it is physical.  */
+   _L4_BITFIELD (virtual, 1),
+
+   _L4_BITFIELD_32_64 (low, 22, 54));
+
+  _L4_BITFIELD2
+  (l4_word_t,
+   _L4_BITFIELD (__pad2, 10),
+
+   _L4_BITFIELD_32_64 (high, 22, 54));
+} *l4_memory_desc_t;
+
+#define L4_MEMDESC_MASK		0xf
+#define L4_MEMDESC_UNDEFINED	0x0
+#define L4_MEMDESC_CONVENTIONAL	0x1
+#define L4_MEMDESC_RESERVED	0x2
+#define L4_MEMDESC_DEDICATED	0x3
+#define L4_MEMDESC_SHARED	0x4
+#define L4_MEMDESC_BOOTLOADER	0xe
+#define L4_MEMDESC_ARCH		0xf
+
+
+typedef struct
+{
+  /* External frequency in kHz.  */
+  l4_word_t external_freq;
+
+  /* Internal frequency in kHz.  */
+  l4_word_t internal_freq;
+
+  l4_word_t __pad[2];
+} *l4_proc_desc_t;
+
+
+typedef struct
+{
+  /* Kernel ID.  */
+  l4_kernel_id_t id;
+
+  /* The kernel generation date.  */
+  _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+    _L4_BITFIELD4
+      (l4_word_t,
+       _L4_BITFIELD (day, 5),
+       _L4_BITFIELD (month, 4),
+       /* The year from 2000 on.  */
+       _L4_BITFIELD (year, 7),
+       _L4_BITFIELD_32_64 (__pad, 16, 48));
+  })) gen_date;
+
+  /* The kernel version.  */
+  _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+    _L4_BITFIELD4
+      (l4_word_t,
+       _L4_BITFIELD (subsubver, 16),
+       _L4_BITFIELD (subver, 8),
+       _L4_BITFIELD (ver, 8),
+
+       _L4_BITFIELD_64 (__pad, 32));
+  })) version;
+
+  char supplier[4];
+#if L4_WORDSIZE == L4_WORDSIZE_64
+  char __pad[4];
+#endif
+
+  /* The kernel version string followed by architecture specific
+     feature strings.  */
+  char version_parts[0];
+} *l4_kern_desc_t;
+
+
+extern l4_kip_t __l4_kip;
+#define l4_get_kernel_interface()  (__l4_kip + 0)  /* Not an lvalue.  */
+
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+_L4_EXTERN_INLINE l4_api_version_t
+l4_api_version (void)
+{
+  return l4_get_kernel_interface ()->api_version;
+}
+
+
+_L4_EXTERN_INLINE l4_api_flags_t
+l4_api_flags (void)
+{
+  return l4_get_kernel_interface ()->api_flags;
+}
+
+
+_L4_EXTERN_INLINE l4_kernel_id_t
+l4_kernel_id (void)
+{
+  l4_kern_desc_t kern;
+
+  kern = (l4_kern_desc_t) ((l4_word_t) l4_get_kernel_interface ()
+			   + l4_get_kernel_interface ()->kern_desc_ptr);
+  return kern->id;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_kernel_gen_date (l4_word_t *year, l4_word_t *month, l4_word_t *day)
+{
+  l4_kern_desc_t kern;
+
+  kern = (l4_kern_desc_t) ((l4_word_t) l4_get_kernel_interface ()
+			   + l4_get_kernel_interface ()->kern_desc_ptr);
+
+  if (year)
+    *year = kern->gen_date.year + 2000;
+  if (month)
+    *month = kern->gen_date.month;
+  if (day)
+    *day = kern->gen_date.day;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_kernel_version (l4_word_t *ver, l4_word_t *subver, l4_word_t *subsubver)
+{
+  l4_kern_desc_t kern;
+
+  kern = (l4_kern_desc_t) ((l4_word_t) l4_get_kernel_interface ()
+			   + l4_get_kernel_interface ()->kern_desc_ptr);
+
+  if (ver)
+    *ver = kern->version.ver;
+  if (subver)
+    *subver = kern->version.subver;
+  if (subsubver)
+    *subsubver = kern->version.subsubver;
+}
+
+
+_L4_EXTERN_INLINE char *
+l4_kernel_supplier (void)
+{
+  l4_kern_desc_t kern;
+
+  kern = (l4_kern_desc_t) ((l4_word_t) l4_get_kernel_interface ()
+			   + l4_get_kernel_interface ()->kern_desc_ptr);
+
+  return kern->supplier;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_num_processors (void)
+{
+  return l4_get_kernel_interface ()->processor_info.processors + 1;
+}
+
+
+_L4_EXTERN_INLINE l4_proc_desc_t
+l4_proc_desc (l4_word_t num)
+{
+  if (num >= l4_num_processors ())
+    return (l4_proc_desc_t) 0;
+
+  return (l4_proc_desc_t) ((l4_word_t) l4_get_kernel_interface ()
+			   + l4_get_kernel_interface ()->proc_desc_ptr)
+    + num * (1 << l4_get_kernel_interface ()->processor_info.log2_size);
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_proc_internal_freq (l4_proc_desc_t proc)
+{
+  return proc->internal_freq;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_proc_external_freq (l4_proc_desc_t proc)
+{
+  return proc->external_freq;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_page_size_mask (void)
+{
+  return l4_get_kernel_interface ()->page_info.page_size_mask << 10;
+}
+
+
+_L4_EXTERN_INLINE l4_page_info_t
+l4_page_rights (void)
+{
+  return l4_get_kernel_interface ()->page_info;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_thread_id_bits (void)
+{
+  return l4_get_kernel_interface ()->thread_info.log2_max_thread;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_thread_user_base (void)
+{
+  return l4_get_kernel_interface ()->thread_info.user_base;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_thread_system_base (void)
+{
+  return l4_get_kernel_interface ()->thread_info.system_base;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_read_precision (void)
+{
+  return l4_get_kernel_interface ()->clock_info.read_precision;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_schedule_precision (void)
+{
+  return l4_get_kernel_interface ()->clock_info.schedule_precision;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_utcb_area_size_log2 (void)
+{
+  return l4_get_kernel_interface ()->utcb_info.log2_min_size;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_utcb_area_size (void)
+{
+  return 1 << l4_get_kernel_interface ()->utcb_info.log2_min_size;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_utcb_alignment_log2 (void)
+{
+  return l4_get_kernel_interface ()->utcb_info.log2_align;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_utcb_size (void)
+{
+  return l4_get_kernel_interface ()->utcb_info.size_mul
+    * (1 << l4_utcb_alignment_log2 ());
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_kip_area_size_log2 (void)
+{
+  return l4_get_kernel_interface ()->kip_area_info.log2_size;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_kip_area_size (void)
+{
+  return 1 << l4_get_kernel_interface ()->kip_area_info.log2_size;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_boot_info (void)
+{
+  return l4_get_kernel_interface ()->boot_info;
+}
+
+
+_L4_EXTERN_INLINE char *
+l4_kernel_version_string (void)
+{
+  l4_kern_desc_t kern;
+
+  kern = (l4_kern_desc_t) ((l4_word_t) l4_get_kernel_interface ()
+			   + l4_get_kernel_interface ()->kern_desc_ptr);
+
+  return kern->version_parts;
+}
+
+
+_L4_EXTERN_INLINE char *
+l4_feature (l4_word_t num)
+{
+  char *feature = l4_kernel_version_string ();
+
+  do
+    {
+      while (*feature)
+	feature++;
+      feature++;
+      if (!*feature)
+	return (char *) 0;
+    }
+  while (num--);
+
+  return feature;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_num_memory_desc (void)
+{
+  return l4_get_kernel_interface ()->memory_info.nr;
+}
+
+
+_L4_EXTERN_INLINE l4_memory_desc_t
+l4_memory_desc (l4_word_t num)
+{
+  l4_memory_desc_t mem;
+
+  if (num >= l4_num_memory_desc ())
+    return (l4_memory_desc_t) 0;
+
+  mem = (l4_memory_desc_t)
+    ((l4_word_t) l4_get_kernel_interface ()
+     + l4_get_kernel_interface ()->memory_info.mem_desc_ptr);
+  return mem + num;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_memory_desc_virtual (l4_memory_desc_t mem)
+{
+  return mem->virtual;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_memory_desc_type (l4_memory_desc_t mem)
+{
+  return (mem->subtype << 4) + mem->type;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_memory_desc_low (l4_memory_desc_t mem)
+{
+  return mem->low << 10;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_memory_desc_high (l4_memory_desc_t mem)
+{
+  return mem->high << 10;
+}
+
+#endif	/* l4/kip.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/math.h real-libc/sysdeps/l4/l4/math.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/math.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/math.h	2003-05-10 04:51:46.000000000 +0200
@@ -0,0 +1,54 @@
+#ifndef _L4_MATH_H
+#define _L4_MATH_H	1
+
+#include <l4/types.h>
+
+/* <l4/bits/math.h> defines __l4_msb_().  */
+#include <l4/bits/math.h>
+
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+_L4_EXTERN_INLINE l4_word_t
+__l4_msb (l4_word_t data) __attribute__((__const__));
+
+_L4_EXTERN_INLINE l4_word_t
+__l4_msb (l4_word_t data)
+{
+  if (__builtin_constant_p (data))
+    {
+#define __L4_MSB_TRY(b) else if (data < (1 << (b + 1))) return (b)
+#define __L4_MSB_IS(b) else return (b)
+
+      if (!data)
+	/* Undefined.  */
+	return 0;
+      __L4_MSB_TRY(0); __L4_MSB_TRY(1); __L4_MSB_TRY(2); __L4_MSB_TRY(3);
+      __L4_MSB_TRY(4); __L4_MSB_TRY(5); __L4_MSB_TRY(6); __L4_MSB_TRY(7);
+      __L4_MSB_TRY(8); __L4_MSB_TRY(9); __L4_MSB_TRY(10); __L4_MSB_TRY(11);
+      __L4_MSB_TRY(12); __L4_MSB_TRY(13); __L4_MSB_TRY(14); __L4_MSB_TRY(15);
+      __L4_MSB_TRY(16); __L4_MSB_TRY(17); __L4_MSB_TRY(18); __L4_MSB_TRY(19);
+      __L4_MSB_TRY(20); __L4_MSB_TRY(21); __L4_MSB_TRY(22); __L4_MSB_TRY(23);
+      __L4_MSB_TRY(24); __L4_MSB_TRY(25); __L4_MSB_TRY(26); __L4_MSB_TRY(27);
+      __L4_MSB_TRY(28); __L4_MSB_TRY(29); __L4_MSB_TRY(30);
+#if L4_WORDSIZE == L4_WORDSIZE_32
+      __L4_MSB_IS(31);
+#else
+      __L4_MSB_TRY(31); __L4_MSB_TRY(32); __L4_MSB_TRY(33); __L4_MSB_TRY(34);
+      __L4_MSB_TRY(35); __L4_MSB_TRY(36); __L4_MSB_TRY(37); __L4_MSB_TRY(38);
+      __L4_MSB_TRY(39); __L4_MSB_TRY(40); __L4_MSB_TRY(41); __L4_MSB_TRY(42);
+      __L4_MSB_TRY(43); __L4_MSB_TRY(44); __L4_MSB_TRY(45); __L4_MSB_TRY(46);
+      __L4_MSB_TRY(47); __L4_MSB_TRY(48); __L4_MSB_TRY(49); __L4_MSB_TRY(50);
+      __L4_MSB_TRY(51); __L4_MSB_TRY(52); __L4_MSB_TRY(53); __L4_MSB_TRY(54);
+      __L4_MSB_TRY(55); __L4_MSB_TRY(56); __L4_MSB_TRY(57); __L4_MSB_TRY(58);
+      __L4_MSB_TRY(59); __L4_MSB_TRY(60); __L4_MSB_TRY(61); __L4_MSB_TRY(62);
+      __L4_MSB_IS(63);
+#endif
+    }
+  return __l4_msb_ (data);
+}
+
+#endif	/* l4/math.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/misc.h real-libc/sysdeps/l4/l4/misc.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/misc.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/misc.h	2003-05-18 23:50:58.000000000 +0200
@@ -0,0 +1,35 @@
+#ifndef _L4_MISC_H
+#define _L4_MISC_H	1
+
+#include <l4/types.h>
+#include <l4/bits/misc.h>
+#include <l4/vregs.h>
+#include <l4/syscall.h>
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+/* l4_memory_control convenience interface.  */
+
+#define L4_DEFAULT_MEMORY	0x0
+
+_L4_EXTERN_INLINE void
+l4_set_page_attribute (l4_fpage_t fpage, l4_word_t attribute)
+{
+  l4_set_rights (&fpage, 0);
+  l4_load_mr (0, fpage.raw);
+  l4_memory_control (0, &attribute); 
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_pages_attributes (l4_word_t nr, l4_fpage_t *fpages,
+			 l4_word_t *attributes)
+{
+  l4_load_mrs (0, nr, (l4_word_t *) fpages);
+  l4_memory_control (nr - 1, attributes);
+}
+
+#endif	/* misc.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/schedule.h real-libc/sysdeps/l4/l4/schedule.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/schedule.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/schedule.h	2003-05-14 21:34:30.000000000 +0200
@@ -0,0 +1,105 @@
+#ifndef _L4_SCHEDULE_H
+#define _L4_SCHEDULE_H	1
+
+#include <l4/types.h>
+#include <l4/vregs.h>
+#include <l4/syscall.h>
+#include <l4/thread.h>
+
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+/* FIXME: These are compound statements and can not be used for
+   initialization of global variables in C99.  */
+#define l4_never	((l4_time_t) { .raw = 0 })
+#define l4_zero_time \
+	((l4_time_t) { .period.m = 0, .period.e = 5, .period._zero = 0 })
+
+_L4_EXTERN_INLINE l4_time_t
+l4_time_period (l4_uint64_t usec)
+{
+  /* FIXME: If usec is a built-in constant, optimize.  Optimize the
+     loop for the run-time case.  Probably just use optimized version
+     from Karlsruhe.  */
+  l4_time_t time = { .raw = 0 };
+
+  while (usec & ~((1 << 10) - 1))
+    {
+      if (time.period.e == 31)
+	return l4_never;
+
+      time.period.e++;
+      usec = usec >> 1;
+    }
+  time.period.m = usec;
+
+  return time;
+}
+
+
+/* Convenience interface for l4_thread_switch.  */
+
+_L4_EXTERN_INLINE void
+l4_yield (void)
+{
+  l4_thread_switch (l4_nilthread);
+}
+
+
+/* Convenience interface for l4_schedule.  */
+
+_L4_EXTERN_INLINE l4_word_t
+l4_set_priority (l4_thread_id_t dest, l4_word_t priority)
+{
+  l4_word_t prio = priority & ((1 << 16) - 1);
+  l4_word_t dummy;
+  return l4_schedule (dest, -1, -1, prio, -1, &dummy);
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_set_processor_no (l4_thread_id_t dest, l4_word_t proc_num)
+{
+  l4_word_t proc = proc_num & ((1 << 8) - 1);
+  l4_word_t dummy;
+  return l4_schedule (dest, -1, proc, -1, -1, &dummy);
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_time_slice (l4_thread_id_t dest, l4_time_t *ts, l4_time_t *tq)
+{
+  l4_word_t time_control;
+  return l4_schedule (dest, -1, -1, -1, -1, &time_control);
+  ts->raw = time_control >> 16;
+  tq->raw = time_control & ((1 << 16) - 1);
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_set_time_slice (l4_thread_id_t dest, l4_time_t ts, l4_time_t tq)
+{
+  l4_word_t time_control = (ts.raw << 16) | tq.raw;
+  l4_word_t dummy;
+  return l4_schedule (dest, time_control, -1, -1, -1, &dummy);
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_preemption_delay (l4_thread_id_t dest, l4_word_t sensitive_prio,
+		     l4_word_t max_delay)
+{
+  l4_word_t preempt_control = (sensitive_prio << 16)
+    | (max_delay & ((1 << 16) - 1));
+  return l4_schedule (dest, -1, -1, -1, -1, &preempt_control);
+}
+
+
+
+#ifndef _L4_NOT_COMPAT
+#endif	/* !_L4_NOT_COMPAT */
+
+#endif	/* l4/schedule.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/space.h real-libc/sysdeps/l4/l4/space.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/space.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/space.h	2003-05-14 14:50:10.000000000 +0200
@@ -0,0 +1,193 @@
+#ifndef _L4_SPACE_H
+#define _L4_SPACE_H	1
+
+#include <l4/types.h>
+#include <l4/math.h>
+#include <l4/bits/space.h>
+#include <l4/syscall.h>
+
+/* fpage support.  */
+#define l4_no_access		0x00
+#define l4_executable		0x01
+#define l4_writable		0x02
+#define l4_readable		0x04
+#define l4_fully_accessible	(l4_readable | l4_writable | l4_executable)
+#define l4_read_exec_only	(l4_readable | l4_executable)
+
+#define l4_nilpage ((l4_fpage_t) { .raw = 0 })
+/* FIXME: When gcc supports unnamed fields in initializer.  */
+#define l4_complete_address_space \
+  ((l4_fpage_t) { page.rights = 0, page.log2_size = 1, page.base = 0 })
+
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+_L4_EXTERN_INLINE l4_fpage_t
+l4_fpage (l4_word_t base, int size)
+{
+  l4_fpage_t fpage;
+  l4_word_t msb = __l4_msb (size);
+
+  fpage.base = base >> 10;
+  fpage.log2_size = (1 << msb) == size ? msb : msb + 1;
+  fpage.rights = l4_no_access;
+
+  return fpage;
+}
+
+
+_L4_EXTERN_INLINE l4_fpage_t
+l4_fpage_log2 (l4_word_t base, int log2_size)
+{
+  l4_fpage_t fpage;
+
+  fpage.base = base >> 10;
+  fpage.log2_size = log2_size;
+  fpage.rights = l4_no_access;
+  return fpage;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_address (l4_fpage_t fpage)
+{
+  return fpage.base << 10;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_size (l4_fpage_t fpage)
+{
+  return 1 << fpage.log2_size;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_size_log2 (l4_fpage_t fpage)
+{
+  return fpage.log2_size;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_rights (l4_fpage_t fpage)
+{
+  return fpage.rights;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_rights (l4_fpage_t *fpage, l4_word_t rights)
+{
+  fpage->rights = rights;
+}
+
+
+_L4_EXTERN_INLINE l4_fpage_t
+l4_fpage_add_rights (l4_fpage_t fpage, l4_word_t rights)
+{
+  l4_fpage_t new_fpage = fpage;
+  new_fpage.rights |= rights;
+  return new_fpage;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_fpage_add_rights_to (l4_fpage_t *fpage, l4_word_t rights)
+{
+  fpage->rights |= rights;
+}
+
+
+_L4_EXTERN_INLINE l4_fpage_t
+l4_fpage_remove_rights (l4_fpage_t fpage, l4_word_t rights)
+{
+  l4_fpage_t new_fpage = fpage;
+  new_fpage.rights &= ~rights;
+  return new_fpage;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_fpage_remove_rights_from (l4_fpage_t *fpage, l4_word_t rights)
+{
+  fpage->rights &= ~rights;
+}
+
+
+/* l4_unmap convenience interface.  */
+
+_L4_EXTERN_INLINE void
+l4_unmap_fpage (l4_fpage_t fpage)
+{
+  l4_load_mr (0, fpage.raw);
+  l4_unmap (0);
+  l4_store_mr (0, &fpage.raw);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_unmap_fpages (l4_word_t nr, l4_fpage_t *fpages)
+{
+  l4_load_mrs (0, nr, (l4_word_t *) fpages);
+  l4_unmap ((nr - 1) & L4_UNMAP_COUNT_MASK);
+  l4_store_mrs (0, nr, (l4_word_t *) fpages);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_flush (l4_fpage_t fpage)
+{
+  l4_load_mr (0, fpage.raw);
+  l4_unmap (L4_UNMAP_FLUSH);
+  l4_store_mr (0, &fpage.raw);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_flush_fpages (l4_word_t nr, l4_fpage_t *fpages)
+{
+  l4_load_mrs (0, nr, (l4_word_t *) fpages);
+  l4_unmap (L4_UNMAP_FLUSH | ((nr - 1) & L4_UNMAP_COUNT_MASK));
+  l4_store_mrs (0, nr, (l4_word_t *) fpages);
+}
+
+
+_L4_EXTERN_INLINE l4_fpage_t
+l4_get_status (l4_fpage_t fpage)
+{
+  l4_fpage_t save_fpage;
+  l4_fpage_t status;
+  
+  save_fpage = l4_fpage_remove_rights (fpage, l4_fully_accessible);
+  l4_load_mr (0, save_fpage.raw);
+  l4_unmap (0);
+  l4_store_mr (0, &status.raw);
+  return status;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_was_referenced (l4_fpage_t fpage)
+{
+  return fpage.referenced;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_was_written (l4_fpage_t fpage)
+{
+  return fpage.written;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_was_executed (l4_fpage_t fpage)
+{
+  return fpage.executed;
+}
+
+#endif	/* l4/syscall.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/stubs.h real-libc/sysdeps/l4/l4/stubs.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/stubs.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/stubs.h	2003-05-08 22:19:22.000000000 +0200
@@ -0,0 +1,9 @@
+/* Only include this file once in your application to prevent the need
+   to link with this library.  */
+
+#ifndef _L4_STUBS_H
+#define _L4_STUBS_H	1
+
+#include <l4/bits/stubs.h>
+
+#endif	/* l4/stubs.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/stubs-init.h real-libc/sysdeps/l4/l4/stubs-init.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/stubs-init.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/stubs-init.h	2003-05-10 04:36:11.000000000 +0200
@@ -0,0 +1,9 @@
+#ifndef _L4_STUBS_INIT_H
+#define _L4_STUBS_INIT_H	1
+
+#include <l4/types.h>
+#include <l4/kip.h>
+
+#include <l4/bits/stubs-init.h>
+
+#endif	/* l4/stubs-init.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/syscall.h real-libc/sysdeps/l4/l4/syscall.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/syscall.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/syscall.h	2003-05-18 23:57:32.000000000 +0200
@@ -0,0 +1,63 @@
+#ifndef _L4_SYSCALL_H
+#define _L4_SYSCALL_H	1
+
+#include <l4/types.h>
+#include <l4/vregs.h>
+#include <l4/kip.h>
+
+/* <l4/bits/syscall.h> defines extern inlines for all system calls.  */
+#include <l4/bits/syscall.h>
+
+/* l4_exchange_registers control argument.  */
+
+/* Input.  */
+#define L4_XCHG_REGS_HALT		0x0001
+#define L4_XCHG_REGS_CANCEL_RECV	0x0002
+#define L4_XCHG_REGS_CANCEL_SEND	0x0004
+#define L4_XCHG_REGS_CANCEL_IPC		(L4_XCHG_REGS_CANCEL_RECV	\
+					 | L4_XCHG_REGS_CANCEL_SEND)
+#define L4_XCHG_REGS_SET_SP		0x0008
+#define L4_XCHG_REGS_SET_IP		0x0010
+#define L4_XCHG_REGS_SET_FLAGS		0x0020
+#define L4_XCHG_REGS_SET_USER_HANDLE	0x0040
+#define L4_XCHG_REGS_SET_PAGER		0x0080
+#define L4_XCHG_REGS_SET_HALT		0x0100
+
+/* Output.  */
+#define L4_XCHG_REGS_HALTED		0x01
+#define L4_XCHG_REGS_RECEIVING		0x02
+#define L4_XCHG_REGS_SENDING		0x04
+#define L4_XCHG_REGS_IPCING		(L4_XCHG_REGS_RECEIVING		\
+					 | L4_XCHG_REGS_SENDING)
+
+/* l4_schedule return codes.  */
+#define L4_SCHEDULE_ERROR		0
+#define L4_SCHEDULE_DEAD		1
+#define L4_SCHEDULE_INACTIVE		2
+#define L4_SCHEDULE_RUNNING		3
+#define L4_SCHEDULE_PENDING_SEND	4
+#define L4_SCHEDULE_SENDING		5
+#define L4_SCHEDULE_WAITING		6
+#define L4_SCHEDULE_RECEIVING		7
+
+
+/* l4_unmap flags.  */
+#define L4_UNMAP_FLUSH		0x40
+#define L4_UNMAP_COUNT_MASK	0x3f
+
+#ifndef _L4_NOT_COMPAT
+#define L4_ExchangeRegisters	l4_exchange_registers
+#define L4_ThreadControl	l4_thread_control
+#define L4_SystemClock() \
+ ({ return ((L4_Clock_t) { .clock = l4_system_clock () })
+#define L4_ThreadSwitch		l4_thread_switch
+#define L4_Schedule		l4_schedule
+#define L4_Ipc			l4_ipc
+#define L4_Lipc			l4_lipc
+#define L4_Unmap		l4_unmap
+#define L4_SpaceControl		l4_space_control
+#define L4_ProcessorControl	l4_processor_control
+#define L4_MemoryControl	l4_memory_control
+#endif	/* !_L4_NOT_COMPAT */
+
+#endif	/* l4/syscall.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/thread.h real-libc/sysdeps/l4/l4/thread.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/thread.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/thread.h	2003-05-18 23:59:37.000000000 +0200
@@ -0,0 +1,293 @@
+#ifndef _L4_THREAD_H
+#define _L4_THREAD_H	1
+
+#include <l4/types.h>
+#include <l4/vregs.h>
+#include <l4/syscall.h>
+
+/* FIXME: These are compound statements and can not be used for
+   initialization of global variables in C99.  */
+#define l4_nilthread	((l4_thread_id_t) { .raw = 0 })
+#define l4_anythread	((l4_thread_id_t) { .raw = (l4_word_t) -1 })
+/* FIXME: When gcc supports unnamed fields as initializers, use them.  */
+#define l4_anylocalthread \
+	((l4_thread_id_t) { .local.local = -1, .local._all_zero = 0 })
+
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_global_id (l4_word_t thread_no, l4_word_t version)
+{
+  l4_thread_id_t thread;
+
+  thread.thread_no = thread_no;
+  thread.version = version;
+
+  return thread;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_version (l4_thread_id_t thread)
+{
+  return thread.version;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_thread_no (l4_thread_id_t thread)
+{
+  return thread.thread_no;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_thread_equal (l4_thread_id_t thread1, l4_thread_id_t thread2)
+{
+  return thread1.raw == thread2.raw;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_thread_not_equal (l4_thread_id_t thread1, l4_thread_id_t thread2)
+{
+  return thread1.raw != thread2.raw;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_nil_thread (l4_thread_id_t thread)
+{
+  return thread.raw == 0;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_local_id (l4_thread_id_t thread)
+{
+  return thread._all_zero == 0;
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_is_global_id (l4_thread_id_t thread)
+{
+  return thread._all_zero != 0;
+}
+
+
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_myself (void)
+{
+  return l4_my_global_id ();
+}
+
+
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_global_id_of (l4_thread_id_t thread)
+{
+  if (l4_is_global_id (thread))
+    return thread;
+  else
+    {
+      l4_thread_id_t dest = thread;
+      l4_word_t control = 0;
+      l4_word_t dummy = 0;
+      l4_thread_id_t pager = l4_nilthread;
+
+      l4_exchange_registers (&dest, &control, &dummy, &dummy, &dummy,
+			     &dummy, &pager);
+      return dest;
+    }
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_same_threads (l4_thread_id_t thread1, l4_thread_id_t thread2)
+{
+  l4_thread_id_t global1 = l4_global_id_of (thread1);
+  l4_thread_id_t global2 = l4_global_id_of (thread2);
+
+  return global1.raw == global2.raw;
+}
+
+
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_local_id_of (l4_thread_id_t thread)
+{
+  if (l4_is_local_id (thread))
+    return thread;
+  else
+    {
+      l4_thread_id_t dest = thread;
+      l4_word_t control = 0;
+      l4_word_t dummy = 0;
+      l4_thread_id_t pager = l4_nilthread;
+
+      l4_exchange_registers (&dest, &control, &dummy, &dummy, &dummy,
+			     &dummy, &pager);
+      return dest;
+    }
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_user_defined_handle_of (l4_thread_id_t thread)
+{
+  l4_thread_id_t dest = thread;
+  l4_word_t control = 0;
+  l4_word_t user_handle = 0;
+  l4_word_t dummy = 0;
+  l4_thread_id_t pager = l4_nilthread;
+
+  l4_exchange_registers (&dest, &control, &dummy, &dummy, &dummy,
+			 &user_handle, &pager);
+  return user_handle;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_user_defined_handle_of (l4_thread_id_t thread, l4_word_t handle)
+{
+  l4_thread_id_t dest = thread;
+  l4_word_t control = L4_XCHG_REGS_SET_USER_HANDLE;
+  l4_word_t user_handle = handle;
+  l4_word_t dummy = 0;
+  l4_thread_id_t pager = l4_nilthread;
+
+  l4_exchange_registers (&dest, &control, &dummy, &dummy, &dummy,
+			 &user_handle, &pager);
+}
+
+
+_L4_EXTERN_INLINE l4_thread_id_t
+l4_pager_of (l4_thread_id_t thread)
+{
+  l4_thread_id_t dest = thread;
+  l4_word_t control = 0;
+  l4_thread_id_t pager = l4_nilthread;
+  l4_word_t dummy = 0;
+
+  l4_exchange_registers (&dest, &control, &dummy, &dummy, &dummy,
+			 &dummy, &pager);
+  return pager;
+}
+
+
+_L4_EXTERN_INLINE void
+l4_set_pager_of (l4_thread_id_t thread, l4_thread_id_t pager_thread)
+{
+  l4_thread_id_t dest = thread;
+  l4_word_t control = L4_XCHG_REGS_SET_PAGER;
+  l4_thread_id_t pager = pager_thread;
+  l4_word_t dummy = 0;
+
+  l4_exchange_registers (&dest, &control, &dummy, &dummy, &dummy,
+			 &dummy, &pager);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_start (l4_thread_id_t thread)
+{
+  l4_thread_id_t dest = thread;
+  l4_word_t control = L4_XCHG_REGS_SET_HALT;
+  l4_word_t dummy = 0;
+  l4_thread_id_t pager = l4_nilthread;
+
+  l4_exchange_registers (&dest, &control, &dummy, &dummy, &dummy,
+			 &dummy, &pager);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_start_sp_ip (l4_thread_id_t thread, l4_word_t sp_data, l4_word_t ip_data)
+{
+  l4_thread_id_t dest = thread;
+  l4_word_t control = L4_XCHG_REGS_SET_HALT | L4_XCHG_REGS_SET_SP
+    | L4_XCHG_REGS_SET_IP;
+  l4_word_t sp = sp_data;
+  l4_word_t ip = ip_data;
+  l4_word_t dummy = 0;
+  l4_thread_id_t pager = l4_nilthread;
+
+  l4_exchange_registers (&dest, &control, &sp, &ip, &dummy, &dummy, &pager);
+}
+
+
+_L4_EXTERN_INLINE void
+l4_start_sp_ip_flags (l4_thread_id_t thread, l4_word_t sp_data,
+		      l4_word_t ip_data, l4_word_t flags_data)
+{
+  l4_thread_id_t dest = thread;
+  l4_word_t control = L4_XCHG_REGS_SET_HALT | L4_XCHG_REGS_SET_SP
+    | L4_XCHG_REGS_SET_IP | L4_XCHG_REGS_SET_FLAGS;
+  l4_word_t sp = sp_data;
+  l4_word_t ip = ip_data;
+  l4_word_t flags = flags_data;
+  l4_word_t dummy = 0;
+  l4_thread_id_t pager = l4_nilthread;
+
+  l4_exchange_registers (&dest, &control, &sp, &ip, &flags, &dummy, &pager);
+}
+
+
+#define __L4_STOP(name, extra_control)				\
+_L4_EXTERN_INLINE l4_word_t					\
+name (l4_thread_id_t thread)					\
+{								\
+  l4_thread_id_t dest = thread;					\
+  l4_word_t control = L4_XCHG_REGS_SET_HALT | L4_XCHG_REGS_HALT	\
+    | (extra_control);						\
+  l4_word_t dummy = 0;						\
+  l4_thread_id_t pager = l4_nilthread;				\
+								\
+  l4_exchange_registers (&dest, &control, &dummy, &dummy,	\
+			 &dummy, &dummy, &pager);		\
+  return control;						\
+}								\
+								\
+								\
+_L4_EXTERN_INLINE l4_word_t					\
+name ## _sp_ip_flags (l4_thread_id_t thread, l4_word_t *sp,	\
+                      l4_word_t *ip, l4_word_t *flags)		\
+{								\
+  l4_thread_id_t dest = thread;					\
+  l4_word_t control = L4_XCHG_REGS_SET_HALT | L4_XCHG_REGS_HALT	\
+    | L4_XCHG_REGS_SET_SP | L4_XCHG_REGS_SET_IP			\
+    | (extra_control);						\
+  l4_word_t dummy = 0;						\
+  l4_thread_id_t pager = l4_nilthread;				\
+								\
+  l4_exchange_registers (&dest, &control, sp, ip, flags,	\
+			 &dummy, &pager);			\
+  return control;						\
+}
+
+__L4_STOP (l4_stop, 0)
+__L4_STOP (l4_abort_receive_and_stop, L4_XCHG_REGS_CANCEL_RECV)
+__L4_STOP (l4_abort_send_and_stop, L4_XCHG_REGS_CANCEL_SEND)
+__L4_STOP (l4_abort_ipc_and_stop, L4_XCHG_REGS_CANCEL_IPC)
+
+
+/* Convenience interface for l4_thread_control.  */ 
+
+_L4_EXTERN_INLINE l4_word_t
+l4_associate_interrupt (l4_thread_id_t irq, l4_thread_id_t handler)
+{
+  return l4_thread_control (irq, irq, l4_nilthread, handler, (void *) -1);
+}
+
+
+_L4_EXTERN_INLINE l4_word_t
+l4_deassociate_interrupt (l4_thread_id_t irq)
+{
+  return l4_thread_control (irq, irq, l4_nilthread, irq, (void *) -1);
+}
+
+
+#endif	/* l4/thread.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/types.h real-libc/sysdeps/l4/l4/types.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/types.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/types.h	2003-05-14 21:46:10.000000000 +0200
@@ -0,0 +1,253 @@
+#ifndef _L4_TYPES_H
+#define _L4_TYPES_H	1
+
+#define L4_LITTLE_ENDIAN	0
+#define L4_BIG_ENDIAN		1
+
+#define L4_WORDSIZE_32		0
+#define L4_WORDSIZE_64		1
+
+/* <l4/bits/types.h> defines L4_BYTE_ORDER and L4_WORDSIZE.  It also
+   defines the basic type l4_word_t.  */
+#include <l4/bits/types.h>
+
+# define __l4_intN_t(N, MODE) \
+  typedef int l4_int##N##_t __attribute__ ((__mode__ (MODE)))
+# define __l4_uintN_t(N, MODE) \
+  typedef unsigned int l4_uint##N##_t __attribute__ ((__mode__ (MODE)))
+
+__l4_intN_t (8, __QI__);
+__l4_intN_t (16, __HI__);
+__l4_intN_t (32, __SI__);
+__l4_intN_t (64, __DI__);
+
+__l4_uintN_t (8, __QI__);
+__l4_uintN_t (16, __HI__);
+__l4_uintN_t (32, __SI__);
+__l4_uintN_t (64, __DI__);
+
+#if L4_WORDSIZE == L4_WORDSIZE_32
+typedef l4_uint32_t l4_word_t;
+#else
+#if L4_WORDSIZE == L4_WORDSIZE_64
+typedef l4_uint64_t l4_word_t;
+#else
+#error "Unsupported word size."
+#endif
+#endif
+
+
+/* Utility macros for structure definitions.  */
+
+/* A bit-field element.  */
+#define _L4_BITFIELD(name, nr) name : nr
+#define _L4_BITFIELD1(type, bf1) type bf1
+
+/* Sometimes the bit-field has different sizes depending on the word
+   size, and sometimes it only exists on systems with a specific word
+   size.  */
+#if L4_WORDSIZE == L4_WORDSIZE_32
+#define _L4_BITFIELD_64(name, nr) : 0
+#define _L4_BITFIELD_32_64(name, nr32, nr64) name : nr32
+#else
+#if L4_WORDSIZE == L4_WORDSIZE_64
+#define _L4_BITFIELD_64(name, nr) name : nr
+#define _L4_BITFIELD_32_64(name, nr32, nr64) name : nr64
+#endif
+#endif
+
+/* The representation of a bit-field is system and/or compiler
+   specific.  We require that GCC uses a specific representation that
+   only depends on the endianess of the system.  */
+#if L4_BYTE_ORDER == L4_LITTLE_ENDIAN
+#define _L4_BITFIELD2(type, bf1, bf2) type bf1; type bf2
+#define _L4_BITFIELD3(type, bf1, bf2, bf3) type bf1; type bf2; type bf3
+#define _L4_BITFIELD4(type, bf1, bf2, bf3, bf4) \
+  type bf1; type bf2; type bf3; type bf4
+#define _L4_BITFIELD5(type, bf1, bf2, bf3, bf4, bf5) \
+  type bf1; type bf2; type bf3; type bf4; type bf5
+#define _L4_BITFIELD6(type, bf1, bf2, bf3, bf4, bf5, bf6) \
+  type bf1; type bf2; type bf3; type bf4; type bf5; type bf6
+#define _L4_BITFIELD7(type, bf1, bf2, bf3, bf4, bf5, bf6, bf7) \
+  type bf1; type bf2; type bf3; type bf4; type bf5; type bf6; type bf7
+#else
+#if L4_BYTE_ORDER == L4_BIG_ENDIAN
+#define _L4_BITFIELD2(type, bf1, bf2) type bf2; type bf1
+#define _L4_BITFIELD3(type, bf1, bf2, bf3) type bf3; type bf2; type bf1
+#define _L4_BITFIELD4(type, bf1, bf2, bf3, bf4) \
+  type bf4; type bf3; type bf2 type; type bf1
+#define _L4_BITFIELD5(type, bf1, bf2, bf3, bf4, bf5) \
+  type bf5; type bf4; type bf3; type bf2 type; type bf1
+#define _L4_BITFIELD6(type, bf1, bf2, bf3, bf4, bf5, bf6) \
+  type bf6; type bf5; type bf4; type bf3; type bf2; type bf1
+#define _L4_BITFIELD6(type, bf1, bf2, bf3, bf4, bf5, bf6, bf7) \
+  type bf7; type bf6; type bf5; type bf4; type bf3; type bf2; type bf1
+#else
+#error "Unsupported endianess."
+#endif
+#endif
+
+
+/* Use _L4_RAW to define a union of a raw accessor of type TYPE and a
+   bit-field with one or more interpretations.  */
+#define _L4_RAW(type, x)	\
+  union				\
+  {				\
+    type raw;			\
+    x;				\
+  }
+
+#define _L4_STRUCT1(s1)		struct s1;
+#define _L4_STRUCT2(s1, s2)	struct s1; struct s2;
+#define _L4_STRUCT3(s1, s2, s3)	struct s1; struct s2; struct s3;
+#define _L4_STRUCT4(s1, s2, s3, s4) \
+  struct s1; struct s2; struct s3; struct s4
+
+
+/* The Thread ID type is here to avoid vregs.h requiring thread.h.  */
+/* FIXME: Remove named structs when gcc supports initializers for
+   unnamed fields, and change the initializers in <l4/thread.h>.  */
+typedef _L4_RAW
+(l4_word_t, _L4_STRUCT4
+ ({
+   _L4_BITFIELD2
+     (l4_word_t,
+      _L4_BITFIELD_32_64 (version, 14, 32),
+      _L4_BITFIELD_32_64 (thread_no, 18, 32));
+ },
+ {
+   _L4_BITFIELD2
+     (l4_word_t,
+      _L4_BITFIELD (_all_zero, 6),
+      _L4_BITFIELD_32_64 (local, 26, 58));
+ },
+ {
+   _L4_BITFIELD2
+     (l4_word_t,
+      _L4_BITFIELD_32_64 (version, 14, 32),
+      _L4_BITFIELD_32_64 (thread_no, 18, 32));
+ } global,
+ {
+   _L4_BITFIELD2
+     (l4_word_t,
+      _L4_BITFIELD (_all_zero, 6),
+      _L4_BITFIELD_32_64 (local, 26, 58));
+ } local)) l4_thread_id_t;
+
+
+/* The clock is 64 bits on all architectures.  The clock base is
+   undefined.  The base unit is 1 microsecond.  */
+typedef l4_uint64_t l4_clock_t;
+
+
+typedef _L4_RAW
+(l4_uint16_t, _L4_STRUCT2
+ ({
+   /* This is a time period.  It is 2^e * m usec long.  */
+   _L4_BITFIELD3
+     (l4_uint16_t,
+      _L4_BITFIELD (m, 10),
+      _L4_BITFIELD (e, 5),
+      _L4_BITFIELD (_zero, 1));
+ } period,
+ {
+   /* This is a time point with validity (2^10 - 1) * 2^e.  */
+   _L4_BITFIELD4
+     (l4_uint16_t,
+      _L4_BITFIELD (m, 10),
+      _L4_BITFIELD (c, 1),
+      _L4_BITFIELD (e, 4),
+      _L4_BITFIELD (_one, 1));
+ } point)) l4_time_t;
+
+
+/* FIXME: Remove named structs when gcc supports initializers for
+   unnamed fields, and change the initializers in <l4/space.h>.  */
+typedef _L4_RAW
+(l4_word_t, _L4_STRUCT4
+ ({
+   _L4_BITFIELD3
+     (l4_word_t,
+      _L4_BITFIELD (rights, 4),
+      _L4_BITFIELD (log2_size, 6),
+      _L4_BITFIELD_32_64 (base, 22, 54));
+ },
+ {
+   /* Alias names for RIGHTS.  */
+   _L4_BITFIELD3
+     (l4_word_t,
+      _L4_BITFIELD (executable, 1),
+      _L4_BITFIELD (writable, 1),
+      _L4_BITFIELD (readable, 1));
+ },
+ {
+   /* Names for status bits as returned from l4_unmap.  */
+   _L4_BITFIELD3
+     (l4_word_t,
+      _L4_BITFIELD (executed, 1),
+      _L4_BITFIELD (written, 1),
+      _L4_BITFIELD (referenced, 1));
+ },
+ {
+   _L4_BITFIELD3
+     (l4_word_t,
+      _L4_BITFIELD (rights, 4),
+      _L4_BITFIELD (log2_size, 6),
+      _L4_BITFIELD_32_64 (base, 22, 54));
+ } page)) l4_fpage_t;
+
+
+/* Message tags.  */
+typedef _L4_RAW (l4_word_t, _L4_STRUCT1 ({
+  _L4_BITFIELD7
+    (l4_word_t,
+     _L4_BITFIELD (untyped, 6),
+     _L4_BITFIELD (typed, 6),
+     _L4_BITFIELD (propagated, 1),
+     _L4_BITFIELD (redirected, 1),
+     _L4_BITFIELD (cross_cpu, 1),
+     _L4_BITFIELD (error, 4),
+     _L4_BITFIELD_32_64 (label, 16, 48));
+})) l4_msg_tag_t;
+
+
+#ifndef _L4_NO_COMPAT
+/* Compatibility interfaces.  */
+
+typedef l4_word_t L4_Word_t;
+typedef l4_uint64_t L4_Word64_t;
+typedef l4_word_t L4_Bool_t;
+
+
+/* Clock interface.  */
+
+typedef _L4_RAW
+(L4_Word64_t, _L4_STRUCT1
+ ({
+   l4_clock_t clock;
+ })) L4_Clock_t;
+
+#define L4_ClockAddUsec(clock, usec) \
+ ({ return ((L4_Clock_t) { .clock = (clock).clock + (usec) }); })
+
+#define L4_ClockSubUsec(clock, usec) \
+ ({ return ((L4_Clock_t) { .clock = clock - usec }); })
+
+#define L4_IsClockEarlier(clock1, clock2) \
+ ({ return (clock1).clock < (clock2).clock; })
+
+#define L4_IsClockLater(clock1, clock2) \
+ ({ return (clock1).clock > (clock2).clock; })
+
+#define L4_IsClockEqual(clock1, clock2) \
+ ({ return (clock1).clock == (clock2).clock; })
+
+#define L4_IsClockNotEqual(clock1, clock2) \
+ ({ return (clock1).clock != (clock2).clock; })
+
+
+#include <l4/compat/types.h>
+
+#endif	/* !_L4_NO_COMPAT */
+
+#endif	/* l4/types.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/vregs.h real-libc/sysdeps/l4/l4/vregs.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4/vregs.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4/vregs.h	2003-05-07 21:02:20.000000000 +0200
@@ -0,0 +1,10 @@
+#ifndef _L4_VREGS_H
+#define _L4_VREGS_H	1
+
+#include <l4/types.h>
+
+/* <l4/bits/vregs.h> defines extern inlines for virtual register
+   access.  */
+#include <l4/bits/vregs.h>
+
+#endif	/* l4/vregs.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4.h real-libc/sysdeps/l4/l4.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/l4.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/l4.h	2003-05-19 05:09:46.000000000 +0200
@@ -0,0 +1,28 @@
+#ifndef _L4_H
+#define _L4_H	1
+
+#include <l4/types.h>
+#include <l4/syscall.h>
+#include <l4/thread.h>
+#include <l4/schedule.h>
+#include <l4/space.h>
+#include <l4/ipc.h>
+#include <l4/misc.h>
+#include <l4/kip.h>
+
+#ifndef _L4_EXTERN_INLINE
+#define _L4_EXTERN_INLINE extern __inline
+#endif
+
+/* Initialize the global data.  */
+_L4_EXTERN_INLINE void
+l4_init (void)
+{
+  l4_api_version_t version;
+  l4_api_flags_t flags;
+  l4_kernel_id_t id;
+
+  __l4_kip = l4_kernel_interface (&version, &flags, &id);
+};
+
+#endif	/* l4.h */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/Makefile real-libc/sysdeps/l4/Makefile
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/Makefile	2003-05-19 03:54:05.000000000 +0200
@@ -0,0 +1,24 @@
+# Copyright (C) 1993,1994,1996,1997,2002,2003 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, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifdef in-Makerules
+
+# Look for header files in mach/ under the top-level library source directory.
+includes += -I$(..)l4
+
+endif	# in-Makerules
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/sys/syscall.h real-libc/sysdeps/l4/sys/syscall.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/sys/syscall.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/sys/syscall.h	2003-05-19 03:18:43.000000000 +0200
@@ -0,0 +1 @@
+/* The L4 syscalls are in <l4/syscall.h>.  */
diff -x CVS -rupN /mnt/marcus/gnu/cvs/libc/sysdeps/l4/sysdep.h real-libc/sysdeps/l4/sysdep.h
--- /mnt/marcus/gnu/cvs/libc/sysdeps/l4/sysdep.h	1970-01-01 01:00:00.000000000 +0100
+++ real-libc/sysdeps/l4/sysdep.h	2003-05-19 04:46:52.000000000 +0200
@@ -0,0 +1,86 @@
+/* Copyright (C) 1994, 1995, 1997 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifdef __ASSEMBLER__
+
+#ifdef HAVE_ELF
+/* For ELF we need to add the `.type' directive to make shared libraries
+   work right.  */
+#undef ENTRY
+#define ENTRY(name) \
+  ASM_GLOBAL_DIRECTIVE name; \
+  .align ALIGN; \
+  .type name,@function; \
+  name:
+#endif
+
+#endif
+
+/* This is invoked by things run when there is random lossage, before they
+   try to do anything else.  Just to be safe, deallocate the reply port so
+   bogons arriving on it don't foul up future RPCs.  */
+
+/* FIXME */
+#if 0
+#ifndef __ASSEMBLER__
+#define FATAL_PREPARE_INCLUDE
+#define FATAL_PREPARE
+#endif
+#endif
+
+/* sysdeps/l4/MACHINE/sysdep.h should define the following macros.  */
+
+/* Produce a text assembler label for the C global symbol NAME.  */
+#ifndef ENTRY
+#define ENTRY(name) .error ENTRY not defined by sysdeps/mach/MACHINE/sysdep.h
+/* This is not used on all machines.  */
+#endif
+
+/* Set variables ARGC, ARGV, and ENVP for the arguments
+   left on the stack by the microkernel.  */
+#ifndef SNARF_ARGS
+#define SNARF_ARGS(argc, argv, envp)
+#error SNARF_ARGS not defined by sysdeps/mach/MACHINE/sysdep.h
+#endif
+
+/* Call the C function FN with no arguments,
+   on a stack starting at SP (as returned by *_cthread_init_routine).
+   You don't need to deal with FN returning; it shouldn't.  */
+#ifndef	CALL_WITH_SP
+#define CALL_WITH_SP(fn, sp)
+#error CALL_WITH_SP not defined by sysdeps/mach/MACHINE/sysdep.h
+#endif
+
+/* LOSE can be defined as the `halt' instruction or something
+   similar which will cause the process to die in a characteristic
+   way suggesting a bug.  */
+#ifndef LOSE
+#define	LOSE	({ volatile int zero = 0; zero / zero; })
+#endif
+
+/* One of these should be defined to specify the stack direction.  */
+#if !defined (STACK_GROWTH_UP) && !defined (STACK_GROWTH_DOWN)
+#error stack direction unspecified
+#endif
+
+/* Used by some assembly code.  */
+#ifdef NO_UNDERSCORES
+#define C_SYMBOL_NAME(name)	name
+#else
+#define C_SYMBOL_NAME(name)	_##name
+#endif
