<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel rdf:about="http://blog.gmane.org/gmane.os.hurd.bugs">
    <title>gmane.os.hurd.bugs</title>
    <link>http://blog.gmane.org/gmane.os.hurd.bugs</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21864"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21859"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21857"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21855"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21854"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21848"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21847"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21840"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21839"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21828"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21820"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21806"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21798"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21794"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21793"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21790"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21789"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21780"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21779"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.hurd.bugs/21778"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21864">
    <title>»No more PTYs« message</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21864</link>
    <description>&lt;pre&gt;Hi!

We've been seeing this on darnassus several times: try to allocate a PTY
(log in via SSH, or start screen, etc.), and get a »No more PTYs«
message.  Now the same happend on flubber: I could log in via SSH, but
starting screen failed.  I did a »ls -l /dev/tty* /dev/pty*« (which will
start all translators due to »stat«ing the nodes) -- and then I was able
to start screen.  Strange?


Grüße,
 Thomas
&lt;/pre&gt;</description>
    <dc:creator>Thomas Schwinge</dc:creator>
    <dc:date>2012-05-25T09:34:45</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21859">
    <title>[PATCH,HURD] sendto: do not crash when addr is NULL</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21859</link>
    <description>&lt;pre&gt;Hi,

currently, sendto() crashes when the specified addr is NULL; the 
attached patch fixes it making sendto() with NULL addr behave as it 
would be a plain send().

Thanks,
&lt;/pre&gt;</description>
    <dc:creator>Pino Toscano</dc:creator>
    <dc:date>2012-05-20T20:58:24</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21857">
    <title>grub-pc makes hurd crash</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21857</link>
    <description>&lt;pre&gt;Hi,

while configuring/installing grub-pc from debian, the kernel panics in 
the way attached in the screenshot.

Riccardo
&lt;/pre&gt;</description>
    <dc:creator>Riccardo Mottola</dc:creator>
    <dc:date>2012-05-19T14:15:19</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21855">
    <title>grub-pc makes hurd crash</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21855</link>
    <description>&lt;pre&gt;Hi,

while configuring/installing grub-pc from debian, the kernel panics in 
the way attached in the screenshot.

Riccardo
&lt;/pre&gt;</description>
    <dc:creator>Riccardo Mottola</dc:creator>
    <dc:date>2012-05-19T14:13:19</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21854">
    <title>restartable netdde</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21854</link>
    <description>&lt;pre&gt;Hello,

One nifty feature of userland drivers is that you can easily restart
them by just making the translator away. However, that makes pfinet
away, as well as all current network connexions and listening servers.

But pfinet doesn't really need to exit: it could just reopen the network
device after e.g. 1s delay, reconfigure it, and continue as if nothing
happened.

Could somebody have a look?

Samuel


&lt;/pre&gt;</description>
    <dc:creator>Samuel Thibault</dc:creator>
    <dc:date>2012-05-19T12:45:58</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21848">
    <title>kernel panic on network activity</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21848</link>
    <description>&lt;pre&gt;Hi,

I attach a screenshot on how my kernel panics when I just "ping" 
localhost. I provide a "screenshot" since I had to uninstall any ssh, 
telnet or login daemon to be able to boot.
This happens after the last debian update I was doing.

dpkg -l | grep hurd
reports: 20120408-3

Any hints?

Riccardo
&lt;/pre&gt;</description>
    <dc:creator>Riccardo Mottola</dc:creator>
    <dc:date>2012-05-15T22:35:02</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21847">
    <title>cthreads to pthreads conversion</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21847</link>
    <description>&lt;pre&gt;So, I have gotten this patch back to where Barry had it in 2008:
It needs testing. Specific changes that I have made are to remove the need for
condition_implies from console-client, pfinet, term, and trans. I, mostly,
followed the pattern set by Vicente in libpipe. (Which was in a strange state
in Barry's patch.) I also audited uses of trylock due to the return values
changing from cthreads to pthreads. The only questionable piece of code is
marked "BDD - Is this sane?" in ufs/sizes.c. I think Barry's replacement is
correct.

Compiling notes:
The patch should apply cleanly to HEAD as of May 14, 2012.

You need an implementation of hurd_condition_wait in libpthread: I will attach
Vicente's, which he put in sysdeps/hurd.

I had to comment out the declaration of hurd_condition_wait in
/usr/include/cthreads.h for the new one to compile.

I had to give the absolute path to libpthread2.a in libpthread.a to get the
linker to link to it. Without doing so, the linker would use the
libpthread2.a somewhere in /lib/, and I would get undefined references to
hurd_condition_wait.

Finally, I had to apply the have_kernel_resources branch to libpthreads. A
broken patch is better than no patch. It is personally frustrating to me to be
changing the source from a working threading library to one which does not
work. At all. Given the code, programs should always fail at the first
pthread_create.


Anyway... this is for testing. Most of the code changes were done by Barry
deFreese and Vicente Ara. I got the code back up to HEAD, and made some minor
changes/corrections.

Thomas DiModica

PS. When I typed in "make install", the system tries to boot with a read-only
file system. I can get to a shell, but alot of things don't start right. How
do I fix this?/* Modified condition_wait that checks for cancellation.
Copyright (C) 1995, 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 Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB.  If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.  */

#include &amp;lt;hurd/signal.h&amp;gt;
#include &amp;lt;pthread.h&amp;gt;
#include &amp;lt;pt-internal.h&amp;gt;
#include &amp;lt;assert.h&amp;gt; 

/* Just like condition_wait, but cancellable.  Returns true if cancelled.  */
int
hurd_condition_wait (pthread_cond_t *c, pthread_mutex_t *m)
{
  /* This function will be called by hurd_thread_cancel while we are blocked
     in the condition_wait.  We wake up all threads blocked on C,
     so our thread will wake up and notice the cancellation flag.  */
  struct __pthread *self = _pthread_self ();

  void cancel_me (void)
    {
      __pthread_spin_lock (&amp;amp;c-&amp;gt;__lock);

      /* If self has been dequeued, self-&amp;gt;prevp == 0 */
      if (self-&amp;gt;prevp)
{
  __pthread_dequeue (self);
  __pthread_spin_unlock (&amp;amp;c-&amp;gt;__lock);
  __pthread_wakeup (self);
}
      else
{
  /* There is no thread to wakeup */
  __pthread_spin_unlock (&amp;amp;c-&amp;gt;__lock);
}
    }
  
  struct hurd_sigstate *ss = _hurd_self_sigstate ();

  int cancel;

  assert (ss-&amp;gt;intr_port == MACH_PORT_NULL); /* Sanity check for signal bugs. */


  /* Atomically enqueue our cproc on the condition variable's queue of
     waiters, and mark our sigstate to indicate that `cancel_me' must be
     called to wake us up.  We must hold the sigstate lock while acquiring
     the condition variable's lock and tweaking it, so that
     hurd_thread_cancel can never suspend us and then deadlock in
     condition_broadcast waiting for the condition variable's lock.  */

  __pthread_spin_lock (&amp;amp;ss-&amp;gt;lock);
  __pthread_spin_lock (&amp;amp;c-&amp;gt;__lock);
  cancel = ss-&amp;gt;cancel;
  if (cancel)
    /* We were cancelled before doing anything.  Don't block at all.  */
    ss-&amp;gt;cancel = 0;
  else
    {
      /* Put us on the queue so that condition_broadcast will know to wake
         us up.  */
      __pthread_enqueue (&amp;amp;c-&amp;gt;__queue, self);
      /* Tell hurd_thread_cancel how to unblock us.  */
      ss-&amp;gt;cancel_hook = &amp;amp;cancel_me;
    }
  __pthread_spin_unlock (&amp;amp;c-&amp;gt;__lock);
  __pthread_spin_unlock (&amp;amp;ss-&amp;gt;lock);

  if (cancel)
    {
      /* Cancelled on entry.  Just leave the mutex locked.  */
      m = NULL;
    }
  else
    {
      /* Now unlock the mutex and block until woken.  */
      pthread_mutex_unlock (m);
      __pthread_block (self);
    }

  __pthread_spin_lock (&amp;amp;ss-&amp;gt;lock);
  /* Clear the hook, now that we are done blocking.  */
  ss-&amp;gt;cancel_hook = NULL;
  /* Check the cancellation flag; we might have unblocked due to
     cancellation rather than a normal condition_signal or
     condition_broadcast (or we might have just happened to get cancelled
     right after waking up).  */
  cancel |= ss-&amp;gt;cancel;
  ss-&amp;gt;cancel = 0;
  __pthread_spin_unlock (&amp;amp;ss-&amp;gt;lock);

  if (m)
    /* Reacquire the mutex and return.  */
    __pthread_mutex_lock (m);

  return cancel;
}
&lt;/pre&gt;</description>
    <dc:creator>Thomas Thomas</dc:creator>
    <dc:date>2012-05-15T22:53:40</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21840">
    <title>[PATCH,HURD] Add SysV SHM support</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21840</link>
    <description>&lt;pre&gt;2005-07-11  Marcus Brinkmann  &amp;lt;marcus&amp;lt; at &amp;gt;gnu.org&amp;gt;

        * hurd/Makefile (routines): Add sysvshm.
        (distribute): Add sysvshm.h.
        * hurd/sysvshm.h: New file.
        * hurd/sysvshm.c: New file.
        * sysdeps/mach/hurd/bits/stat.h (S_IMMAP0): New macro.
        (S_ISPARE): Unset the S_IMMAP0 flag.
        * sysdeps/mach/hurd/ftok.c: New file.
        * sysdeps/mach/hurd/shmat.c: New file.
        * sysdeps/mach/hurd/shmctl.c: New file.
        * sysdeps/mach/hurd/shmdt.c: New file.
        * sysdeps/mach/hurd/bits/posix_opt.h: Define _XOPEN_SHM to 1.

---
 hurd/Makefile                      |    3 +-
 hurd/sysvshm.c                     |   96 ++++++++++++++
 hurd/sysvshm.h                     |   47 +++++++
 sysdeps/mach/hurd/bits/posix_opt.h |    2 +
 sysdeps/mach/hurd/ftok.c           |   43 +++++++
 sysdeps/mach/hurd/shmat.c          |   78 ++++++++++++
 sysdeps/mach/hurd/shmctl.c         |  132 ++++++++++++++++++++
 sysdeps/mach/hurd/shmdt.c          |   51 ++++++++
 sysdeps/mach/hurd/shmget.c         |  242 ++++++++++++++++++++++++++++++++++++
 9 files changed, 693 insertions(+), 1 deletion(-)

diff --git a/hurd/Makefile b/hurd/Makefile
index bdad4ff..4f74ccc 100644
--- a/hurd/Makefile
+++ b/hurd/Makefile
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -59,6 +59,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; routines = hurdstartup hurdinit \
    vpprintf \
    ports-get ports-set hurdports hurdmsg \
    errno-loc \
+   sysvshm \
    $(sig) $(dtable) $(inlines) port-cleanup report-wait xattr
 sig= hurdsig hurdfault siginfo hurd-raise preempt-sig \
   trampoline longjmp-ts catch-exc exc2signal hurdkill sigunwind \
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -67,7 +68,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; 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 \
+distribute = hurdstartup.h hurdfault.h hurdhost.h sysvshm.h \
      faultexc.defs intr-rpc.defs intr-rpc.h intr-msg.h Notes
 
 # XXX this is a temporary hack; see hurdmalloc.h
diff --git a/hurd/sysvshm.c b/hurd/sysvshm.c
new file mode 100644
index 0000000..292cc01
--- /dev/null
+++ b/hurd/sysvshm.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -0,0 +1,96 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
+/* Copyright (C) 2005 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 &amp;lt;string.h&amp;gt;
+#include &amp;lt;stdlib.h&amp;gt;
+#include &amp;lt;stdio.h&amp;gt;
+#include &amp;lt;stddef.h&amp;gt;
+#include &amp;lt;errno.h&amp;gt;
+#include &amp;lt;unistd.h&amp;gt;
+#include &amp;lt;fcntl.h&amp;gt;
+#include &amp;lt;dirent.h&amp;gt;
+#include &amp;lt;sys/stat.h&amp;gt;
+#include &amp;lt;sys/shm.h&amp;gt;
+
+
+/* Description of an shm attachment.  */
+struct sysvshm_attach
+{
+  /* Linked list.  */
+  struct sysvshm_attach *next;
+
+  /* Map address.  */
+  void *addr;
+
+  /* Map size.  */
+  size_t size;
+};
+
+/* List of attachments.  */
+static struct sysvshm_attach *attach_list;
+
+/* A lock to protect the linked list of shared memory attachments.  */
+static struct mutex sysvshm_lock = MUTEX_INITIALIZER;
+
+
+/* Adds a segment attachment.  */
+error_t
+__sysvshm_add (void *addr, size_t size)
+{
+  struct sysvshm_attach *shm;
+
+  shm = malloc (sizeof (*shm));
+  if (!shm)
+    return errno;
+
+  __mutex_lock (&amp;amp;sysvshm_lock);
+  shm-&amp;gt;addr = addr;
+  shm-&amp;gt;size = size;
+  shm-&amp;gt;next = attach_list;
+  attach_list = shm;
+  __mutex_unlock (&amp;amp;sysvshm_lock);
+
+  return 0;
+}
+
+/* Removes a segment attachment.  Returns its size if found, or EINVAL
+   otherwise.  */
+error_t
+__sysvshm_remove (void *addr, size_t *size)
+{
+  struct sysvshm_attach *shm;
+  struct sysvshm_attach **pshm = &amp;amp;attach_list;
+
+  __mutex_lock (&amp;amp;sysvshm_lock);
+  shm = attach_list;
+  while (shm)
+    {
+      shm = *pshm;
+      if (shm-&amp;gt;addr == addr)
+{
+  *pshm = shm-&amp;gt;next;
+  *size = shm-&amp;gt;size;
+  __mutex_unlock (&amp;amp;sysvshm_lock);
+  return 0;
+}
+      pshm = &amp;amp;shm-&amp;gt;next;
+      shm = shm-&amp;gt;next;
+    }
+  __mutex_unlock (&amp;amp;sysvshm_lock);
+  return EINVAL;
+}
diff --git a/hurd/sysvshm.h b/hurd/sysvshm.h
new file mode 100644
index 0000000..0c561c8
--- /dev/null
+++ b/hurd/sysvshm.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -0,0 +1,47 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
+/* Copyright (C) 2005 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 &amp;lt;paths.h&amp;gt;
+#include &amp;lt;hurd.h&amp;gt;
+
+/* The area (from top to bottom) that is used for private keys.  These
+   are all keys that have the second highest bit set.  */
+#define SHM_PRIV_KEY_START INT_MAX
+#define SHM_PRIV_KEY_END ((INT_MAX / 2) + 1)
+
+#define SHM_PREFIX "shm-"
+#define SHM_DIR _PATH_DEV "shm/"
+
+/* The maximum number of characters in a shared memory segment file name.
+   32 is the max number of characters in a 128 bit number in hex.  */
+#if __WORDSIZE &amp;gt; 128
+#error Need to increase SHM_NAMEMAX.
+#else
+#define SHM_NAMEMAX (sizeof (SHM_PREFIX) - 1 + 32 + 1)
+#endif
+
+/* Use this with printf and its variants.  */
+#define SHM_NAMEPRI SHM_PREFIX "%0x"
+
+
+/* Adds a segment attachment.  */
+error_t __sysvshm_add (void *addr, size_t size);
+
+/* Removes a segment attachment.  Returns its size if found, or EINVAL
+   otherwise.  */
+error_t __sysvshm_remove (void *addr, size_t *size);
diff --git a/sysdeps/mach/hurd/bits/posix_opt.h b/sysdeps/mach/hurd/bits/posix_opt.h
index 23d32ce..bd65cfa 100644
--- a/sysdeps/mach/hurd/bits/posix_opt.h
+++ b/sysdeps/mach/hurd/bits/posix_opt.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -59,6 +59,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 #undef _POSIX_NO_TRUNC/* Overlong file names get error?  */
 #undef _POSIX_SYNC_IO/* File supports O_SYNC et al?  */
 
+/* XPG4.2 shared memory is supported.  */
+#define _XOPEN_SHM      1
 
 /* We do not have the POSIX threads interface.  */
 #define _POSIX_THREADS-1
diff --git a/sysdeps/mach/hurd/ftok.c b/sysdeps/mach/hurd/ftok.c
new file mode 100644
index 0000000..8d8b5cb
--- /dev/null
+++ b/sysdeps/mach/hurd/ftok.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -0,0 +1,43 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
+/* Copyright (C) 1995, 1996, 2000, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper &amp;lt;drepper&amp;lt; at &amp;gt;gnu.ai.mit.edu&amp;gt;, August 1995.
+
+   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 &amp;lt;sys/ipc.h&amp;gt;
+#include &amp;lt;sys/stat.h&amp;gt;
+
+
+/* In the Hurd, we use the second-to-most-significant bit as flag for
+   private keys.  We use a different order of the components so that
+   the biggest one---the inode number---is affected by this.  */
+
+key_t
+ftok (pathname, proj_id)
+     const char *pathname;
+     int proj_id;
+{
+  struct stat64 st;
+  key_t key;
+
+  if (__xstat64 (_STAT_VER, pathname, &amp;amp;st) &amp;lt; 0)
+    return (key_t) -1;
+
+  key = ((st.st_dev &amp;amp; 0xff) | ((proj_id &amp;amp; 0xff) &amp;lt;&amp;lt; 8)
+ | ((st.st_ino &amp;amp; 0x3fff) &amp;lt;&amp;lt; 16));
+
+  return key;
+}
diff --git a/sysdeps/mach/hurd/shmat.c b/sysdeps/mach/hurd/shmat.c
new file mode 100644
index 0000000..148a60c
--- /dev/null
+++ b/sysdeps/mach/hurd/shmat.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -0,0 +1,78 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
+/* Copyright (C) 2005 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 &amp;lt;errno.h&amp;gt;
+#include &amp;lt;utime.h&amp;gt;
+#include &amp;lt;stdio.h&amp;gt;
+#include &amp;lt;assert.h&amp;gt;
+#include &amp;lt;sys/mman.h&amp;gt;
+#include &amp;lt;sys/ipc.h&amp;gt;
+#include &amp;lt;sys/shm.h&amp;gt;
+#include &amp;lt;sys/time.h&amp;gt;
+#include &amp;lt;sys/stat.h&amp;gt;
+#include &amp;lt;fcntl.h&amp;gt;
+
+#include "sysvshm.h"
+
+/* Attach the shared memory segment associated with SHMID to the data
+   segment of the calling process.  SHMADDR and SHMFLG determine how
+   and where the segment is attached.  */
+void *
+__shmat (int shmid, const void *shmaddr, int shmflg)
+{
+  error_t err;
+  char filename[sizeof (SHM_DIR) - 1 + SHM_NAMEMAX];
+  int fd;
+  void *addr;
+  struct stat statbuf;
+  int res;
+
+  sprintf (filename, SHM_DIR SHM_NAMEPRI, shmid);
+  fd = __open (filename, (shmflg &amp;amp; SHM_RDONLY) ? O_RDONLY : O_RDWR);
+  if (fd &amp;lt; 0)
+    {
+      if (errno == ENOENT)
+errno = EINVAL;
+      return (void *) -1;
+    }
+
+  res = __fstat (fd, &amp;amp;statbuf);
+  if (res &amp;lt; 0)
+    {
+      __close (fd);
+      return (void *) -1;
+    }
+
+  addr = __mmap ((void *) shmaddr, statbuf.st_size,
+ PROT_READ | ((shmflg &amp;amp; SHM_RDONLY) ? 0 : PROT_WRITE),
+ MAP_SHARED, fd, 0);
+  __close (fd);
+  if (addr == MAP_FAILED)
+    return (void *) -1;
+
+  err = __sysvshm_add (addr, statbuf.st_size);
+  if (err)
+    {
+      munmap (addr, statbuf.st_size);
+      return (void *) -1;
+    }
+
+  return addr;
+}
+
+weak_alias(__shmat, shmat)
diff --git a/sysdeps/mach/hurd/shmctl.c b/sysdeps/mach/hurd/shmctl.c
new file mode 100644
index 0000000..0d8eea6
--- /dev/null
+++ b/sysdeps/mach/hurd/shmctl.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -0,0 +1,132 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
+/* Copyright (C) 2005 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 &amp;lt;errno.h&amp;gt;
+#include &amp;lt;stdio.h&amp;gt;
+#include &amp;lt;unistd.h&amp;gt;
+#include &amp;lt;sys/mman.h&amp;gt;
+#include &amp;lt;sys/ipc.h&amp;gt;
+#include &amp;lt;sys/shm.h&amp;gt;
+#include &amp;lt;sys/stat.h&amp;gt;
+#include &amp;lt;fcntl.h&amp;gt;
+
+#include "sysvshm.h"
+
+/* Provide operations to control over shared memory segments.  */
+int
+__shmctl (int id, int cmd, struct shmid_ds *buf)
+{
+  error_t err = 0;
+  int fd;
+  int res;
+  char filename[sizeof (SHM_DIR) - 1 + SHM_NAMEMAX];
+  struct stat statbuf;
+
+  sprintf (filename, SHM_DIR SHM_NAMEPRI, id);
+  /* SysV requires read access for IPC_STAT.  */
+  fd = __open (filename, O_NORW);
+  if (fd &amp;lt; 0)
+    {
+      if (errno == ENOENT)
+errno = EINVAL;
+      return -1;
+    }
+
+  res = __fstat (fd, &amp;amp;statbuf);
+  if (res &amp;lt; 0)
+    {
+      err = errno;
+      __close (fd);
+      errno = err;
+      return -1;
+    }
+  
+  switch (cmd)
+    {
+    case IPC_STAT:
+
+      buf-&amp;gt;shm_perm.__key = id;
+      buf-&amp;gt;shm_perm.uid = statbuf.st_uid;
+      buf-&amp;gt;shm_perm.gid = statbuf.st_gid;
+
+      /* We do not support the creator.  */
+      buf-&amp;gt;shm_perm.cuid = statbuf.st_uid;
+      buf-&amp;gt;shm_perm.cgid = statbuf.st_gid;
+
+      /* We just want the protection bits.  */
+      buf-&amp;gt;shm_perm.mode = statbuf.st_mode &amp;amp; 0777;
+      /* Hopeless.  We do not support a sequence number.  */
+      buf-&amp;gt;shm_perm.__seq = statbuf.st_ino;
+      buf-&amp;gt;shm_segsz = statbuf.st_size;
+
+      /* Hopeless.  We do not support any of these.  */
+      buf-&amp;gt;shm_atime = statbuf.st_atime;
+      buf-&amp;gt;shm_dtime = statbuf.st_mtime;
+      /* Well, this comes at least close.  */
+      buf-&amp;gt;shm_ctime = statbuf.st_ctime;
+
+      /* We do not support the PID.  */
+      buf-&amp;gt;shm_cpid = 0;
+      buf-&amp;gt;shm_lpid = 0;
+
+      if (statbuf.st_mode &amp;amp; S_IMMAP0)
+        buf-&amp;gt;shm_nattch = 0;
+      else
+        /* 42 is the answer.  Of course this is bogus, but for most
+   applications, this should be fine.  */
+        buf-&amp;gt;shm_nattch = 42;
+
+      break;
+
+    case IPC_SET:
+      if (statbuf.st_uid != buf-&amp;gt;shm_perm.uid
+  || statbuf.st_gid != buf-&amp;gt;shm_perm.gid)
+{
+  res = __fchown (fd,
+  (statbuf.st_uid != buf-&amp;gt;shm_perm.uid)
+  ? buf-&amp;gt;shm_perm.uid : -1,
+  (statbuf.st_gid != buf-&amp;gt;shm_perm.gid)
+  ? buf-&amp;gt;shm_perm.gid : -1);
+  if (res &amp;lt; 0)
+    err = errno;
+}
+
+      if (!err &amp;amp;&amp;amp; statbuf.st_mode &amp;amp; 0777 != buf-&amp;gt;shm_perm.mode &amp;amp; 0777)
+{
+  res = __fchmod (fd, (statbuf.st_mode &amp;amp; ~0777)
+  | (buf-&amp;gt;shm_perm.mode &amp;amp; 0777));
+  if (res &amp;lt; 0)
+    err = errno;
+}
+      break;
+
+    case IPC_RMID:
+      res = __unlink (filename);
+      /* FIXME: Check error (mapping ENOENT to EINVAL).  */
+      break;
+
+    default:
+      err = EINVAL;
+    }
+
+  __close (fd);
+  errno = err;
+  return err ? -1 : 0;
+}
+
+weak_alias(__shmctl, shmctl)
diff --git a/sysdeps/mach/hurd/shmdt.c b/sysdeps/mach/hurd/shmdt.c
new file mode 100644
index 0000000..cdafef0
--- /dev/null
+++ b/sysdeps/mach/hurd/shmdt.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -0,0 +1,51 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
+/* Copyright (C) 2005 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 &amp;lt;stdio.h&amp;gt;
+#include &amp;lt;errno.h&amp;gt;
+#include &amp;lt;fcntl.h&amp;gt;
+#include &amp;lt;unistd.h&amp;gt;
+#include &amp;lt;assert.h&amp;gt;
+#include &amp;lt;sys/mman.h&amp;gt;
+#include &amp;lt;sys/ipc.h&amp;gt;
+#include &amp;lt;sys/shm.h&amp;gt;
+#include &amp;lt;sys/time.h&amp;gt;
+#include &amp;lt;sys/stat.h&amp;gt;
+
+#include "sysvshm.h"
+
+/* Detach shared memory segment starting at address specified by
+   SHMADDR from the caller's data segment.  */
+int
+__shmdt (const void *shmaddr)
+{
+  error_t err;
+  size_t size;
+
+  err = __sysvshm_remove ((void *) shmaddr, &amp;amp;size);
+  if (err)
+    {
+      errno = err;
+      return -1;
+    }
+
+  __munmap ((void *) shmaddr, size);
+  return 0;
+}
+
+weak_alias(__shmdt, shmdt)
diff --git a/sysdeps/mach/hurd/shmget.c b/sysdeps/mach/hurd/shmget.c
new file mode 100644
index 0000000..6620472
--- /dev/null
+++ b/sysdeps/mach/hurd/shmget.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -0,0 +1,242 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
+/* Copyright (C) 2005 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 &amp;lt;stdbool.h&amp;gt;
+#include &amp;lt;stdlib.h&amp;gt;
+#include &amp;lt;errno.h&amp;gt;
+#include &amp;lt;sys/shm.h&amp;gt;
+#include &amp;lt;sys/types.h&amp;gt;
+#include &amp;lt;sys/stat.h&amp;gt;
+#include &amp;lt;limits.h&amp;gt;
+#include &amp;lt;stdio.h&amp;gt;
+#include &amp;lt;fcntl.h&amp;gt;
+#include &amp;lt;unistd.h&amp;gt;
+
+#include &amp;lt;hurd/fd.h&amp;gt;
+
+#include "sysvshm.h"
+
+/* Create a new shared memory segment file without linking it into the
+   filesystem.  Return the directory and file ports in R_DIR and R_FILE.  */
+static error_t
+create_shm_file (size_t size, int flags, file_t *r_dir, file_t *r_file)
+{
+  error_t err;
+  file_t dir;
+  file_t file;
+
+  flags &amp;amp;= 0777;
+
+  /* Get a port to the directory that will contain the file.  */
+  dir = __file_name_lookup (SHM_DIR, 0, 0);
+  if (dir == MACH_PORT_NULL)
+    return errno;
+
+  /* Create an unnamed file in the directory.  */
+  err = __dir_mkfile (dir, O_RDWR, flags, &amp;amp;file);
+  if (err)
+    {
+      __mach_port_deallocate (__mach_task_self (), dir);
+      return err;
+    }
+
+  err = __file_set_size (file, size);
+  if (err)
+    {
+      __mach_port_deallocate (__mach_task_self (), file);
+      __mach_port_deallocate (__mach_task_self (), dir);
+
+      return err;
+    }
+
+  *r_dir = dir;
+  *r_file = file;
+
+  return 0;
+}
+  
+
+/* Open the shared memory segment *R_KEY and return a file descriptor
+   to it in R_FD.  If KEY is IPC_PRIVATE, use a private key and return
+   it in R_KEY.  */
+static error_t
+get_exclusive (int shmflags, size_t size, key_t *r_key, int *r_fd)
+{
+  error_t err;
+  file_t dir;
+  file_t file;
+  char filename[SHM_NAMEMAX];
+  key_t key = *r_key;
+  bool is_private;
+
+  /* Create the shared memory segment.  */
+  err = create_shm_file (size, shmflags, &amp;amp;dir, &amp;amp;file);
+  if (err)
+    return err;
+
+  if (key == IPC_PRIVATE)
+    {
+      is_private = true;
+      key = SHM_PRIV_KEY_START;
+
+      /* Try to link the shared memory segment into the filesystem
+ (exclusively).  Private segments have negative keys.  */
+      do
+{
+  sprintf (filename, SHM_NAMEPRI, key);
+  err = __dir_link (dir, file, filename, 1);
+  if (!err)
+    {
+      /* We are done.  */
+      *r_key = key;
+      break;
+    }
+  else if (err == EEXIST)
+    {
+      /* Check if we ran out of keys.  If not, try again with new
+ key.  */
+      if (key == SHM_PRIV_KEY_END)
+err = ENOSPC;
+      else
+err = 0;
+
+      key--;
+    }
+}
+      while (!err);
+    }
+  else
+    {
+      /* Try to link the shared memory segment into the filesystem
+ (exclusively) under the given key.  */
+      sprintf (filename, SHM_NAMEPRI, key);
+      err = __dir_link (dir, file, filename, 1);
+    }
+
+  __mach_port_deallocate (__mach_task_self (), dir);
+
+  if (!err)
+    {
+      int fd;
+
+      /* Get a file descriptor for that port.  */
+      fd = _hurd_intern_fd (file, O_RDWR, 1); /* dealloc on error */
+      if (fd &amp;lt; 0)
+err = errno;
+      else
+*r_fd = fd;
+    }
+
+  return err;
+}
+
+
+/* Open the shared memory segment KEY (creating it if it doesn't yet
+   exist) and return a file descriptor to it in R_FD.  */
+static error_t
+get_shared (int shmflags, size_t size, key_t key, int *r_fd)
+{
+  error_t err = 0;
+  char filename[sizeof (SHM_DIR) - 1 + SHM_NAMEMAX];
+  int fd = -1;
+  sprintf (filename, SHM_DIR SHM_NAMEPRI, key);
+
+  do
+    {
+      fd = __open (filename, O_NORW, shmflags &amp;amp; 0777);
+
+      if (fd &amp;lt; 0 &amp;amp;&amp;amp; errno != ENOENT)
+/* We give up.  */
+return errno;
+      else if (fd &amp;gt;= 0)
+{
+  int res;
+  struct stat statbuf;
+
+  /* Check the size (we only need to do this if we did not
+     create the shared memory segment file ourselves).  */
+  res = __fstat (fd, &amp;amp;statbuf);
+  if (res &amp;lt; 0)
+    {
+      err = errno;
+      __close (fd);
+      return err;
+    }
+
+  if (statbuf.st_size &amp;lt; size)
+    {
+      __close (fd);
+      return EINVAL;
+    }
+}  
+      else
+{
+  /* The memory segment doesn't exist.  */
+  if (shmflags &amp;amp; IPC_CREAT)
+    {
+      /* Try to create it exclusively.  */
+      err = get_exclusive (shmflags, size, &amp;amp;key, &amp;amp;fd);
+      if (err == EEXIST)
+/* If somebody created it in the meanwhile, just try again.  */
+err = 0;
+    }
+  else
+    err = ENOENT;
+}
+    }
+  while (fd &amp;lt; 0 &amp;amp;&amp;amp; !err);
+
+  if (!err)
+    *r_fd = fd;
+  else
+    *r_fd = -1;
+
+  return err;
+}
+
+/* Return an identifier for an shared memory segment of at least size
+   SIZE which is associated with KEY.  */
+int
+__shmget (key_t key, size_t size, int shmflags)
+{
+  error_t err;
+  int fd;
+
+  if (key == IPC_PRIVATE || shmflags &amp;amp; IPC_EXCL)
+    /* An exclusive shared memory segment must be created.  */
+    err = get_exclusive (shmflags, size, &amp;amp;key, &amp;amp;fd);
+  else
+    err = get_shared (shmflags, size, key, &amp;amp;fd);
+
+  if (err)
+    {
+      errno = err;
+      return -1;
+    }
+
+  /* From here, we can't fail.  That's important, as otherwise we
+     would need to unlink the file if we created it (in that case, the
+     code above would have to be changed to pass a "created" flag down
+     to the caller).  */
+
+  __close (fd);
+
+  return key;
+}
+
+weak_alias(__shmget, shmget)


&lt;/pre&gt;</description>
    <dc:creator>Samuel Thibault</dc:creator>
    <dc:date>2012-05-12T18:01:00</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21839">
    <title>[PATCH,HURD] Add TLS support</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21839</link>
    <description>&lt;pre&gt;This adds TLS support to GNU/HURD. Using it to replace threadvar will be
part of another patch.  I had to separate the thread state with segments
from the thread state without segments: each thread has its own gs
segment, which needs to be inherited across fork, etc.  I also had to
fix some initialization order.

2009-07-30  Samuel Thibault  &amp;lt;samuel.thibault&amp;lt; at &amp;gt;gnu.org&amp;gt;

* sysdeps/mach/hurd/bits/libc-lock.h [_LIBC - 0]: Include &amp;lt;tls.h&amp;gt;
* sysdeps/mach/hurd/tls.h: Include &amp;lt;stdint.h&amp;gt; and &amp;lt;sysdep.h&amp;gt;
* include/errno.h (__GNU__): Do not define TLS errno for now.

* sysdeps/generic/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): New
macro.
* sysdeps/mach/thread_state.h (MACHINE_THREAD_STATE_FIX_NEW): New macro.
* sysdeps/mach/i386/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR):
New macro, defined to i386_THREAD_STATE.
(MACHINE_THREAD_STATE_FLAVOR): Define to i386_REGS_SEGS_STATE instead
of i386_THREAD_STATE.
(MACHINE_THREAD_STATE_FIX_NEW): New macro, reads segments.
* sysdeps/mach/powerpc/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR):
New macro, defined to PPC_THREAD_STATE.

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

* sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Use kern_return_t
error type. Use first GDT slot, 0x48.
(_hurd_tls_fork): Use kern_return_t error type.  Duplicate existing LDT
descriptor instead of creating a new one.
(_hurd_tls_new): New function, creates a new descriptor and updates tcb.

* mach/mach.h (__mach_setup_tls,mach_setup_tls): Add declarations.
* mach/setup-thread.c: Include &amp;lt;ldsodefs.h&amp;gt;.
(__mach_setup_thread): Use MACHINE_NEW_THREAD_STATE_FLAVOR instead of
MACHINE_THREAD_STATE_FLAVOR.
(__mach_setup_tls): New function.
* hurd/hurdfault.c (_hurdsig_fault_init): Call
MACHINE_THREAD_STATE_FIX_NEW.

* sysdeps/mach/hurd/profil.c (update_waiter): Call __mach_setup_tls.
* sysdeps/mach/hurd/setitimer.c (setitimer_locked): Call
__mach_setup_tls.
* hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls.
* sysdeps/mach/hurd/fork.c (__fork): Call _hurd_tls_fork for
sigthread.  Pass kernel thread to _hurd_tls_fork.
* sysdeps/mach/hurd/i386/init-first.c (init): Move ELF header parsing
after getting up the environment pointer.  Call
__pthread_initialize_minimal.
* csu/libc-start.c (LIBC_START_MAIN) [__GNU__]: Do not call
__pthread_initialize_minimal.

---
 csu/libc-start.c                    |    2 ++
 hurd/hurdfault.c                    |    2 ++
 hurd/hurdsig.c                      |    2 ++
 include/errno.h                     |   14 +++++----
 mach/mach.h                         |    3 ++
 mach/setup-thread.c                 |   30 +++++++++++++++++-
 sysdeps/generic/thread_state.h      |    1 +
 sysdeps/mach/hurd/bits/libc-lock.h  |    3 ++
 sysdeps/mach/hurd/fork.c            |    7 ++++-
 sysdeps/mach/hurd/i386/init-first.c |   59 ++++++++++++++++++++++-------------
 sysdeps/mach/hurd/i386/tls.h        |   53 +++++++++++++++++++++++++------
 sysdeps/mach/hurd/i386/trampoline.c |    2 +-
 sysdeps/mach/hurd/profil.c          |    2 ++
 sysdeps/mach/hurd/setitimer.c       |    3 +-
 sysdeps/mach/hurd/tls.h             |    6 +++-
 sysdeps/mach/i386/thread_state.h    |   11 ++++++-
 sysdeps/mach/powerpc/thread_state.h |    1 +
 sysdeps/mach/thread_state.h         |    3 ++
 18 files changed, 160 insertions(+), 44 deletions(-)

diff --git a/csu/libc-start.c b/csu/libc-start.c
index 0f9bfd7..dcf2bac 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -139,10 +139,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
   /* Performe IREL{,A} relocations.  */
   __libc_csu_irel ();
 
+#ifndef __GNU__
   /* Initialize the thread library at least a bit since the libgcc
      functions are using thread functions if these are available and
      we need to setup errno.  */
   __pthread_initialize_minimal ();
+#endif
 
   /* Set up the stack checker's canary.  */
   uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random);
diff --git a/hurd/hurdfault.c b/hurd/hurdfault.c
index e2891d1..3990f90 100644
--- a/hurd/hurdfault.c
+++ b/hurd/hurdfault.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -205,6 +205,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; _hurdsig_fault_init (void)
   /* This state will be restored when we fault.
      It runs the function above.  */
   memset (&amp;amp;state, 0, sizeof state);
+
+  MACHINE_THREAD_STATE_FIX_NEW (&amp;amp;state);
   MACHINE_THREAD_STATE_SET_PC (&amp;amp;state, faulted);
   MACHINE_THREAD_STATE_SET_SP (&amp;amp;state, faultstack, sizeof faultstack);
 
diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c
index e1e0919..9e8485a 100644
--- a/hurd/hurdsig.c
+++ b/hurd/hurdsig.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1267,6 +1267,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; _hurdsig_init (const int *intarray, size_t intarraysize)
  (vm_address_t *) &amp;amp;__hurd_sigthread_stack_base,
  &amp;amp;stacksize);
       assert_perror (err);
+      err = __mach_setup_tls (_hurd_msgport_thread);
+      assert_perror (err);
 
       __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize;
       __hurd_sigthread_variables =
diff --git a/include/errno.h b/include/errno.h
index 98c6080..8acab90 100644
--- a/include/errno.h
+++ b/include/errno.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -21,13 +21,15 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; extern int rtld_errno attribute_hidden;
 
 #  include &amp;lt;tls.h&amp;gt;
 
-#  undef  errno
-#  ifndef NOT_IN_libc
-#   define errno __libc_errno
-#  else
-#   define errno errno/* For #ifndef errno tests.  */
-#  endif
+#  if !defined(__GNU__)
+#   undef  errno
+#   ifndef NOT_IN_libc
+#    define errno __libc_errno
+#   else
+#    define errno errno/* For #ifndef errno tests.  */
+#   endif
 extern __thread int errno attribute_tls_model_ie;
+#  endif
 
 # endif/* RTLD_PRIVATE_ERRNO */
 
diff --git a/mach/mach.h b/mach/mach.h
index 622db97..61a8c1f 100644
--- a/mach/mach.h
+++ b/mach/mach.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -100,5 +100,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; kern_return_t mach_setup_thread (task_t task, thread_t thread, void *pc,
  vm_address_t *stack_base,
  vm_size_t *stack_size);
 
+/* Give THREAD a TLS area.  */
+kern_return_t __mach_setup_tls (thread_t thread);
+kern_return_t mach_setup_tls (thread_t thread);
 
 #endif/* mach.h */
diff --git a/mach/setup-thread.c b/mach/setup-thread.c
index 7d104ab..4422f7c 100644
--- a/mach/setup-thread.c
+++ b/mach/setup-thread.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -19,6 +19,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 #include &amp;lt;thread_state.h&amp;gt;
 #include &amp;lt;string.h&amp;gt;
 #include &amp;lt;mach/machine/vm_param.h&amp;gt;
+#include &amp;lt;ldsodefs.h&amp;gt;
 #include "sysdep.h"/* Defines stack direction.  */
 
 #defineSTACK_SIZE(16 * 1024 * 1024) /* 16MB, arbitrary.  */
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -72,8 +73,35 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __mach_setup_thread (task_t task, thread_t thread, void *pc,
   if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE))
     return error;
 
-  return __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+  return __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR,
      (natural_t *) &amp;amp;ts, tssize);
 }
 
 weak_alias (__mach_setup_thread, mach_setup_thread)
+
+/* Give THREAD a TLS area.  */
+kern_return_t
+__mach_setup_tls (thread_t thread)
+{
+  kern_return_t error;
+  struct machine_thread_state ts;
+  mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT;
+  tcbhead_t *tcb;
+
+  if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+     (natural_t *) &amp;amp;ts, &amp;amp;tssize))
+    return error;
+  assert (tssize == MACHINE_THREAD_STATE_COUNT);
+
+  tcb = _dl_allocate_tls(NULL);
+  if (!tcb)
+    return KERN_RESOURCE_SHORTAGE;
+
+  _hurd_tls_new(thread, &amp;amp;ts, tcb);
+
+  error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+     (natural_t *) &amp;amp;ts, tssize);
+  return error;
+}
+
+weak_alias (__mach_setup_tls, mach_setup_tls)
diff --git a/sysdeps/generic/thread_state.h b/sysdeps/generic/thread_state.h
index e93d40d..0781061 100644
--- a/sysdeps/generic/thread_state.h
+++ b/sysdeps/generic/thread_state.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -22,6 +22,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 
 /* Replace &amp;lt;machine&amp;gt; with "i386" or "mips" or whatever.  */
 
+#define MACHINE_NEW_THREAD_STATE_FLAVOR&amp;lt;machine&amp;gt;_NEW_THREAD_STATE
 #define MACHINE_THREAD_STATE_FLAVOR&amp;lt;machine&amp;gt;_THREAD_STATE
 #define MACHINE_THREAD_STATE_COUNT&amp;lt;machine&amp;gt;_THREAD_STATE_COUNT
 
diff --git a/sysdeps/mach/hurd/bits/libc-lock.h b/sysdeps/mach/hurd/bits/libc-lock.h
index af531da..a89844e 100644
--- a/sysdeps/mach/hurd/bits/libc-lock.h
+++ b/sysdeps/mach/hurd/bits/libc-lock.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -20,6 +20,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 #define _BITS_LIBC_LOCK_H 1
 
 #if (_LIBC - 0) || (_CTHREADS_ - 0)
+#if (_LIBC - 0)
+#include &amp;lt;tls.h&amp;gt;
+#endif
 #include &amp;lt;cthreads.h&amp;gt;
 #include &amp;lt;hurd/threadvar.h&amp;gt;
 
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c
index 644838c..8bea456 100644
--- a/sysdeps/mach/hurd/fork.c
+++ b/sysdeps/mach/hurd/fork.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -522,6 +522,11 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __fork (void)
 #endif
       MACHINE_THREAD_STATE_SET_PC (&amp;amp;state,
    (unsigned long int) _hurd_msgport_receive);
+
+      /* Do special thread setup for TLS if needed.  */
+      if (err = _hurd_tls_fork (sigthread, _hurd_msgport_thread, &amp;amp;state))
+LOSE;
+
       if (err = __thread_set_state (sigthread, MACHINE_THREAD_STATE_FLAVOR,
     (natural_t *) &amp;amp;state, statecount))
 LOSE;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -532,7 +537,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __fork (void)
       _hurd_longjmp_thread_state (&amp;amp;state, env, 1);
 
       /* Do special thread setup for TLS if needed.  */
-      if (err = _hurd_tls_fork (thread, &amp;amp;state))
+      if (err = _hurd_tls_fork (thread, __mach_thread_self (), &amp;amp;state))
 LOSE;
 
       if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index 7a10e78..92ca337 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -103,10 +103,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; init1 (int argc, char *arg0, ...)
   char **argv = &amp;amp;arg0;
   char **envp = &amp;amp;argv[argc + 1];
   struct hurd_startup_data *d;
-#ifndef SHARED
-  extern ElfW(Phdr) *_dl_phdr;
-  extern size_t _dl_phnum;
-#endif
 
   while (*envp)
     ++envp;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -117,27 +113,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; init1 (int argc, char *arg0, ...)
      data block; the argument strings start there.  */
   if ((void *) d == argv[0])
     {
-#ifndef SHARED
-      /* We may need to see our own phdrs, e.g. for TLS setup.
-         Try the usual kludge to find the headers without help from
- the exec server.  */
-      extern const void _start;
-      const ElfW(Ehdr) *const ehdr = &amp;amp;_start;
-      _dl_phdr = (ElfW(Phdr) *) ((const void *) ehdr + ehdr-&amp;gt;e_phoff);
-      _dl_phnum = ehdr-&amp;gt;e_phnum;
-      assert (ehdr-&amp;gt;e_phentsize == sizeof (ElfW(Phdr)));
-#endif
       return;
     }
 
-#ifndef SHARED
-  __libc_enable_secure = d-&amp;gt;flags &amp;amp; EXEC_SECURE;
-
-  _dl_phdr = (ElfW(Phdr) *) d-&amp;gt;phdr;
-  _dl_phnum = d-&amp;gt;phdrsz / sizeof (ElfW(Phdr));
-  assert (d-&amp;gt;phdrsz % sizeof (ElfW(Phdr)) == 0);
-#endif
-
   _hurd_init_dtable = d-&amp;gt;dtable;
   _hurd_init_dtablesize = d-&amp;gt;dtablesize;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -171,6 +149,10 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; init (int *data)
   char **envp = &amp;amp;argv[argc + 1];
   struct hurd_startup_data *d;
   unsigned long int threadvars[_HURD_THREADVAR_MAX];
+#ifndef SHARED
+  extern ElfW(Phdr) *_dl_phdr;
+  extern size_t _dl_phnum;
+#endif
 
   /* Provide temporary storage for thread-specific variables on the
      startup stack so the cthreads initialization code can use them
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -191,6 +173,39 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; init (int *data)
     ++envp;
   d = (void *) ++envp;
 
+  /* 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])
+    {
+#ifndef SHARED
+      /* We may need to see our own phdrs, e.g. for TLS setup.
+         Try the usual kludge to find the headers without help from
+ the exec server.  */
+      extern const void __executable_start;
+      const ElfW(Ehdr) *const ehdr = &amp;amp;__executable_start;
+      _dl_phdr = (ElfW(Phdr) *) ((const void *) ehdr + ehdr-&amp;gt;e_phoff);
+      _dl_phnum = ehdr-&amp;gt;e_phnum;
+      assert (ehdr-&amp;gt;e_phentsize == sizeof (ElfW(Phdr)));
+#endif
+    }
+  else
+    {
+#ifndef SHARED
+      __libc_enable_secure = d-&amp;gt;flags &amp;amp; EXEC_SECURE;
+
+      _dl_phdr = (ElfW(Phdr) *) d-&amp;gt;phdr;
+      _dl_phnum = d-&amp;gt;phdrsz / sizeof (ElfW(Phdr));
+      assert (d-&amp;gt;phdrsz % sizeof (ElfW(Phdr)) == 0);
+#endif
+    }
+
+#ifndef SHARED
+  /* We need to setup TLS before starting sigthread */
+  extern void __pthread_initialize_minimal(void);
+  __pthread_initialize_minimal();
+#endif
+
   /* 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
diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h
index d0a72f0..40306dd 100644
--- a/sysdeps/mach/hurd/i386/tls.h
+++ b/sysdeps/mach/hurd/i386/tls.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -70,7 +70,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; _hurd_tls_init (tcbhead_t *tcb, int secondcall)
 
       /* Get the first available selector.  */
       int sel = -1;
-      error_t err = __i386_set_gdt (tcb-&amp;gt;self, &amp;amp;sel, desc);
+      kern_return_t err = __i386_set_gdt (tcb-&amp;gt;self, &amp;amp;sel, desc);
       if (err == MIG_BAD_ID)
 {
   /* Old kernel, use a per-thread LDT.  */
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -94,16 +94,16 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; _hurd_tls_init (tcbhead_t *tcb, int secondcall)
       /* Fetch the selector set by the first call.  */
       int sel;
       asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0));
-      if (__builtin_expect (sel, 0x50) &amp;amp; 4) /* LDT selector */
+      if (__builtin_expect (sel, 0x48) &amp;amp; 4) /* LDT selector */
 {
-  error_t err = __i386_set_ldt (tcb-&amp;gt;self, sel, &amp;amp;desc, 1);
+  kern_return_t err = __i386_set_ldt (tcb-&amp;gt;self, sel, &amp;amp;desc, 1);
   assert_perror (err);
   if (err)
     return "i386_set_ldt failed";
 }
       else
 {
-  error_t err = __i386_set_gdt (tcb-&amp;gt;self, &amp;amp;sel, desc);
+  kern_return_t err = __i386_set_gdt (tcb-&amp;gt;self, &amp;amp;sel, desc);
   assert_perror (err);
   if (err)
     return "i386_set_gdt failed";
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -140,9 +140,40 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; _hurd_tls_init (tcbhead_t *tcb, int secondcall)
 
 # include &amp;lt;mach/machine/thread_status.h&amp;gt;
 
-/* Set up TLS in the new thread of a fork child, copying from our own.  */
-static inline error_t __attribute__ ((unused))
-_hurd_tls_fork (thread_t child, struct i386_thread_state *state)
+/* Set up TLS in the new thread of a fork child, copying from the original.  */
+static inline kern_return_t __attribute__ ((unused))
+_hurd_tls_fork (thread_t child, thread_t orig, struct i386_thread_state *state)
+{
+  /* Fetch the selector set by _hurd_tls_init.  */
+  int sel;
+  asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0));
+  if (sel == state-&amp;gt;ds)/* _hurd_tls_init was never called.  */
+    return 0;
+
+  struct descriptor desc, *_desc = &amp;amp;desc;
+  kern_return_t err;
+  unsigned int count;
+
+  if (__builtin_expect (sel, 0x48) &amp;amp; 4) /* LDT selector */
+    err = __i386_get_ldt (orig, sel, 1, &amp;amp;_desc, &amp;amp;count);
+  else
+    err = __i386_get_gdt (orig, sel, &amp;amp;desc);
+
+  assert_perror (err);
+  if (err)
+    return err;
+
+  if (__builtin_expect (sel, 0x48) &amp;amp; 4) /* LDT selector */
+    err = __i386_set_ldt (child, sel, &amp;amp;desc, 1);
+  else
+    err = __i386_set_gdt (child, &amp;amp;sel, desc);
+
+  state-&amp;gt;gs = sel;
+  return err;
+}
+
+static inline kern_return_t __attribute__ ((unused))
+_hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb)
 {
   /* Fetch the selector set by _hurd_tls_init.  */
   int sel;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -150,11 +181,13 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; _hurd_tls_fork (thread_t child, struct i386_thread_state *state)
   if (sel == state-&amp;gt;ds)/* _hurd_tls_init was never called.  */
     return 0;
 
-  tcbhead_t *const tcb = THREAD_SELF;
   HURD_TLS_DESC_DECL (desc, tcb);
-  error_t err;
+  kern_return_t err;
+
+  tcb-&amp;gt;tcb = tcb;
+  tcb-&amp;gt;self = child;
 
-  if (__builtin_expect (sel, 0x50) &amp;amp; 4) /* LDT selector */
+  if (__builtin_expect (sel, 0x48) &amp;amp; 4) /* LDT selector */
     err = __i386_set_ldt (child, sel, &amp;amp;desc, 1);
   else
     err = __i386_set_gdt (child, &amp;amp;sel, desc);
diff --git a/sysdeps/mach/hurd/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c
index 5e109f8..793dab8 100644
--- a/sysdeps/mach/hurd/i386/trampoline.c
+++ b/sysdeps/mach/hurd/i386/trampoline.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -64,7 +64,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
   sizeof (state-&amp;gt;basic));
   memcpy (&amp;amp;state-&amp;gt;fpu, &amp;amp;ss-&amp;gt;context-&amp;gt;sc_i386_float_state,
   sizeof (state-&amp;gt;fpu));
-  state-&amp;gt;set |= (1 &amp;lt;&amp;lt; i386_THREAD_STATE) | (1 &amp;lt;&amp;lt; i386_FLOAT_STATE);
+  state-&amp;gt;set |= (1 &amp;lt;&amp;lt; i386_REGS_SEGS_STATE) | (1 &amp;lt;&amp;lt; i386_FLOAT_STATE);
 }
     }
 
diff --git a/sysdeps/mach/hurd/profil.c b/sysdeps/mach/hurd/profil.c
index c68c95a..c6cb1f8 100644
--- a/sysdeps/mach/hurd/profil.c
+++ b/sysdeps/mach/hurd/profil.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -68,6 +68,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; update_waiter (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
       if (! err)
 err = __mach_setup_thread (__mach_task_self (), profile_thread,
    &amp;amp;profile_waiter, NULL, NULL);
+      if (! err)
+err = __mach_setup_tls(profile_thread);
     }
   else
     err = 0;
diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
index a7b2e29..84fa6fd 100644
--- a/sysdeps/mach/hurd/setitimer.c
+++ b/sysdeps/mach/hurd/setitimer.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -222,11 +222,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; setitimer_locked (const struct itimerval *new, struct itimerval *old,
     return __hurd_fail (err);
   _hurd_itimer_thread_stack_base = 0; /* Anywhere.  */
   _hurd_itimer_thread_stack_size = __vm_page_size; /* Small stack.  */
-  if (err = __mach_setup_thread (__mach_task_self (),
+  if ((err = __mach_setup_thread (__mach_task_self (),
  _hurd_itimer_thread,
  &amp;amp;timer_thread,
  &amp;amp;_hurd_itimer_thread_stack_base,
  &amp;amp;_hurd_itimer_thread_stack_size))
+      || (err = __mach_setup_tls(_hurd_itimer_thread)))
     {
       __thread_terminate (_hurd_itimer_thread);
       _hurd_itimer_thread = MACH_PORT_NULL;
diff --git a/sysdeps/mach/hurd/tls.h b/sysdeps/mach/hurd/tls.h
index 2a91aa9..f18aa51 100644
--- a/sysdeps/mach/hurd/tls.h
+++ b/sysdeps/mach/hurd/tls.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1,5 +1,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 /* Definitions for thread-local data handling.  Hurd version.
-   Copyright (C) 2003, 2005, 2007, 2011 Free Software Foundation, Inc.
+
+   Copyright (C) 2003, 2005, 2007, 2009, 2011 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
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -22,7 +24,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 #ifndef __ASSEMBLER__
 
 # include &amp;lt;stddef.h&amp;gt;
+# include &amp;lt;stdint.h&amp;gt;
 # include &amp;lt;stdbool.h&amp;gt;
+# include &amp;lt;sysdep.h&amp;gt;
 # include &amp;lt;mach/mig_errors.h&amp;gt;
 # include &amp;lt;mach.h&amp;gt;
 
diff --git a/sysdeps/mach/i386/thread_state.h b/sysdeps/mach/i386/thread_state.h
index b1d1285..3a700df 100644
--- a/sysdeps/mach/i386/thread_state.h
+++ b/sysdeps/mach/i386/thread_state.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -21,7 +21,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 
 #include &amp;lt;mach/machine/thread_status.h&amp;gt;
 
-#define MACHINE_THREAD_STATE_FLAVORi386_THREAD_STATE
+#define MACHINE_NEW_THREAD_STATE_FLAVORi386_THREAD_STATE
+#define MACHINE_THREAD_STATE_FLAVORi386_REGS_SEGS_STATE
 #define MACHINE_THREAD_STATE_COUNTi386_THREAD_STATE_COUNT
 
 #define machine_thread_state i386_thread_state
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -30,6 +31,14 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 #define SP uesp
 #define SYSRETURN eax
 
+#define MACHINE_THREAD_STATE_FIX_NEW(ts) do { \
+asm ("mov %%cs, %w0" : "=q" ((ts)-&amp;gt;cs)); \
+asm ("mov %%ds, %w0" : "=q" ((ts)-&amp;gt;ds)); \
+asm ("mov %%es, %w0" : "=q" ((ts)-&amp;gt;es)); \
+asm ("mov %%fs, %w0" : "=q" ((ts)-&amp;gt;fs)); \
+asm ("mov %%gs, %w0" : "=q" ((ts)-&amp;gt;gs)); \
+} while(0)
+
 struct machine_thread_all_state
   {
     int set;/* Mask of bits (1 &amp;lt;&amp;lt; FLAVOR).  */
diff --git a/sysdeps/mach/powerpc/thread_state.h b/sysdeps/mach/powerpc/thread_state.h
index d11a5ab..42a3c42 100644
--- a/sysdeps/mach/powerpc/thread_state.h
+++ b/sysdeps/mach/powerpc/thread_state.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -18,6 +18,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 
 #include &amp;lt;mach/machine/thread_status.h&amp;gt;
 
+#define MACHINE_NEW_THREAD_STATE_FLAVORPPC_THREAD_STATE
 #define MACHINE_THREAD_STATE_FLAVORPPC_THREAD_STATE
 #define MACHINE_THREAD_STATE_COUNTPPC_THREAD_STATE_COUNT
 
diff --git a/sysdeps/mach/thread_state.h b/sysdeps/mach/thread_state.h
index ac6cabb..234b873 100644
--- a/sysdeps/mach/thread_state.h
+++ b/sysdeps/mach/thread_state.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -37,6 +37,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
   ((ts)-&amp;gt;SP = (unsigned long int) (stack) + (size))
 #endif
 #endif
+#ifndef MACHINE_THREAD_STATE_FIX_NEW
+#define MACHINE_THREAD_STATE_FIX_NEW(ts)
+#endif
 
 /* These functions are of use in machine-dependent signal trampoline
    implementations.  */
&lt;/pre&gt;</description>
    <dc:creator>Samuel Thibault</dc:creator>
    <dc:date>2012-05-12T17:27:52</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21828">
    <title>bug in libpthreads</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21828</link>
    <description>&lt;pre&gt;In function initialize_pthread in file pthread/pt-alloc.c, you need to
initialize the value of have_kernel_resources to zero if the thread
structure is not recycled. Following the logic of
__pthread_create_internal: we go from __pthread_alloc to
__pthread_thread_alloc without touching have_kernel_resources.

Then, __pthread_thread_alloc exits immediately if
have_kernel_resources is non-zero: not good if we haven't
actually allocated these resources.

Sorry this isn't a patch, but it is only a one line fix,
Thomas D



&lt;/pre&gt;</description>
    <dc:creator>Thomas Thomas</dc:creator>
    <dc:date>2012-05-11T00:38:26</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21820">
    <title>iconx and execve problems</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21820</link>
    <description>&lt;pre&gt;Hello,

As discussed on IRC recently and on the bug-hurd mailing list
http://lists.gnu.org/archive/html/bug-hurd/2012-01/msg00004.html
and the debian-hurd mailing list
http://lists.debian.org/debian-hurd/2012/01/msg00001.html
(bug 654381, tests run under fakeroot and . not in PATH)
http://lists.debian.org/debian-hurd/2012/01/msg00002.html
the icon package FTBFS due to a missing . in PATH. Other architectures
does not have this problem. According to Samuel the problem is missing
info from glibc to the exec server about $0.

In May-June 2010 Emilio Pozuelo monfort proposed a set of patches to
glibc and the exec server by adding two new RPCs
http://lists.gnu.org/archive/html/bug-hurd/2010-05/msg00108.html
http://lists.gnu.org/archive/html/bug-hurd/2010-06/msg00002.html

However, that patch was considered not worth the effort
http://lists.gnu.org/archive/html/bug-hurd/2010-06/msg00010.html

Now when glibc Hurd patches are being considered upstream maybe the set
of patches by Emilio can be revised again. In one way or another, this
problem has to be solved, the icon package has to be moved from
debian-ports to the main archive in the aim of GNU/Hurd to enter testing
for wheezy.

Thanks,
Svante



&lt;/pre&gt;</description>
    <dc:creator>Svante Signell</dc:creator>
    <dc:date>2012-05-10T09:30:52</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21806">
    <title>hurd/glibc.git and merging</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21806</link>
    <description>&lt;pre&gt;There is some agitation in libc circles about the state of Hurd
support.  I'd like to get a lot of the low-hanging-fruit Hurd
changes merged into libc ASAP.

I've been looking at git://git.sv.gnu.org/hurd/glibc.git and read
enough about topgit to have a general sense of how the branches are
meant to be used.  I've looked at a small handful of the branches
and some seem quite trivial to merge.  But they are not really
merge-ready.  Some are completely lacking ChangeLog entries, and I'd
rather have these written by the person who made the change than do
it myself.  Some have incomplete ChangeLog entries (not mentioning
every file touched).  Probably all are missing proper copyright year
updates for the current protocol (which is to collapse down to a
single year range ending in 2012).

Unless I've been even more remiss than I thought I'd been, some of
these changes were never posted for my review at all.  I guess I was
sufficiently remiss for a long time that people could reasonably
have given up, and I'm sorry for that.  I'd like to remedy the
situation now.

Certainly the easiest thing for me is if each change is turned into
a git branch that is suitable for direct merging into the libc
trunk, or a git-am-friendly posting.  But since everybody's time is
limited, I'm willing to help out with the tedium to some degree.

I think we could get through the vast majority, which are simple
cases, with no more than a day of focused work.  Who wants to help?


Thanks,
Roland



&lt;/pre&gt;</description>
    <dc:creator>Roland McGrath</dc:creator>
    <dc:date>2012-05-09T20:57:38</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21798">
    <title>Please disable test cp/parent-perm-race on hurd-i386</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21798</link>
    <description>&lt;pre&gt;Hello,

(From http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=670478 )

cp/parent-perm-race tries to copy a fifo with the --copy-contents
option.  The problem is that cp still uses O_NOFOLLOW in that case,
strace shows:

open("mode/fifo", O_RDONLY|O_NOFOLLOW)

O_NOFOLLOW is actually normally meant for security, to avoid attacks
through symlink redirection.  In that case, the Hurd thus disables
translators too, to avoid any rogue translator that would achieve the
same kind attack as symlink redirection.  But then --copy-contents can
not work, since the fifo thus can not work (it's a translator that
implements it).  I don't think either the Hurd or coreutils will want to
change their behavior, so could the test be disabled on GNU/Hurd?

Samuel


&lt;/pre&gt;</description>
    <dc:creator>Samuel Thibault</dc:creator>
    <dc:date>2012-05-08T18:38:16</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21794">
    <title>extending devprobe for netdde</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21794</link>
    <description>&lt;pre&gt;Hello,

There's currently no way to know whether netdde found a network device,
because devprobe only works with mach devices.  It should however not be
hard to extend it to work with netdde: it should be a matter of doing in
devprobe something like commit d3ad9490749fe330bea91c0027a0c8319476cac0
in pfinet, see below.

Could someone have a look?

Samuel

commit d3ad9490749fe330bea91c0027a0c8319476cac0
Author: Samuel Thibault &amp;lt;samuel.thibault&amp;lt; at &amp;gt;ens-lyon.org&amp;gt;
Date:   Sun Feb 19 05:32:36 2012 +0100

    Make pfinet try both a filepath and kernel device
    
    pfinet/ethernet.c (ethernet_open): Try to file_name_lookup() the device as
    filepath before opening the Mach device.

diff --git a/pfinet/ethernet.c b/pfinet/ethernet.c
index dab5c56..f366919 100644
--- a/pfinet/ethernet.c
+++ b/pfinet/ethernet.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -166,14 +166,33 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; ethernet_open (struct device *dev)
 
   mach_port_set_qlimit (mach_task_self (), edev-&amp;gt;readptname, MACH_PORT_QLIMIT_MAX);
 
-  err = get_privileged_ports (0, &amp;amp;master_device);
-  if (err)
-    error (2, err, "cannot get device master port");
-
-  err = device_open (master_device, D_WRITE | D_READ, dev-&amp;gt;name, &amp;amp;edev-&amp;gt;ether_port);
-  mach_port_deallocate (mach_task_self (), master_device);
-  if (err)
-    error (2, err, "%s", dev-&amp;gt;name);
+  master_device = file_name_lookup (dev-&amp;gt;name, O_READ | O_WRITE, 0);
+  if (master_device != MACH_PORT_NULL)
+    {
+      /* The device name here is the path of a device file.  */
+      err = device_open (master_device, D_WRITE | D_READ, "eth", &amp;amp;edev-&amp;gt;ether_port);
+      mach_port_deallocate (mach_task_self (), master_device);
+      if (err)
+error (2, err, "%s", dev-&amp;gt;name);
+    }
+  else
+    {
+      /* No, perhaps a Mach device?  */
+      int file_errno = errno;
+      err = get_privileged_ports (0, &amp;amp;master_device);
+      if (err)
+{
+  error (0, errno, "file_name_lookup %s", dev-&amp;gt;name);
+  error (2, err, "and cannot get device master port");
+}
+      err = device_open (master_device, D_WRITE | D_READ, dev-&amp;gt;name, &amp;amp;edev-&amp;gt;ether_port);
+      mach_port_deallocate (mach_task_self (), master_device);
+      if (err)
+{
+  error (0, errno, "file_name_lookup %s", dev-&amp;gt;name);
+  error (2, err, "%s", dev-&amp;gt;name);
+}
+    }
 
   err = device_set_filter (edev-&amp;gt;ether_port, ports_get_right (edev-&amp;gt;readpt),
    MACH_MSG_TYPE_MAKE_SEND, 0,


&lt;/pre&gt;</description>
    <dc:creator>Samuel Thibault</dc:creator>
    <dc:date>2012-05-05T12:27:09</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21793">
    <title>Compiling ext2fs.static with pthreads</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21793</link>
    <description>&lt;pre&gt;I've applied Barry's patch, and removed all cthreads references that I can find
(in the code that gets compiled). I compiled everything in the source tree,
so I clobbered the linker script version of libpthread.a. In attempting to run
ext2fs.static, I get an assertion failure in pthread (somewhere). I renamed the
library and unclobbered the linker script, and am now trying to just recompile
ext2fs.static. However, when I do I get errors about undefined references to
hurd_condition_wait. That function is in libpthread2.a, so why can it not be
found now that we're going through the linker script?

Thomas D



&lt;/pre&gt;</description>
    <dc:creator>Thomas Thomas</dc:creator>
    <dc:date>2012-05-03T19:27:52</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21790">
    <title>Many questions, mostly about mach-defpager</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21790</link>
    <description>&lt;pre&gt;So, mach-defpager "wires" all of its threads. What exactly does that mean?
I think the headers are kind-of sketchy. They do say that in GNU all threads
are wired, will this apply to pthread threads, too?

Nextly, it uses cthread_data to store a pointer to a thread-specific buffer
that it uses in paging. As I see it: all threads are created when the pager
starts up, and no threads are created afterward. Thus, I could achieve the
same result by using a hash to map between the thread handles and the
buffer pointers. Would this be a good idea/efficient? Mainly, I just want
your thoughts.


I'll leave it at this...

Thomas D



&lt;/pre&gt;</description>
    <dc:creator>Thomas Thomas</dc:creator>
    <dc:date>2012-04-30T23:30:00</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21789">
    <title>[PATCH,HURD] mach: compliance fixes for nanosleep</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21789</link>
    <description>&lt;pre&gt;Hi,

attached there is a patch to make Mach's nanosleep() (used by Hurd) a 
bit more POSIX compliant:
* check for validity of the `requested_time' parameter
* return EINTR when interrupted
* modify correctly the `remaining' parameter only when interrupted

Thanks,
&lt;/pre&gt;</description>
    <dc:creator>Pino Toscano</dc:creator>
    <dc:date>2012-04-28T15:29:00</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21780">
    <title>[PATCH,HURD] hurd: compliance fixes for ptsname_r</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21780</link>
    <description>&lt;pre&gt;Hi,

attached there is a patch to fix few issues in Hurd's ptsname_r(), 
mostly checking for more error conditions and making sure to set as 
errno and return the proper values on error conditions.

Thanks,
&lt;/pre&gt;</description>
    <dc:creator>Pino Toscano</dc:creator>
    <dc:date>2012-04-27T10:44:10</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21779">
    <title>[PATCH,HURD] hurd: compliance fixes for getlogin_r</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21779</link>
    <description>&lt;pre&gt;Hi,

attached there is a patch to fix few issues in Hurd's getlogin_r(): 
avoid a static buffer, and check for buffer shorter than necessary.

Thanks,
&lt;/pre&gt;</description>
    <dc:creator>Pino Toscano</dc:creator>
    <dc:date>2012-04-27T10:44:03</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21778">
    <title>[PATCH,HURD] hurd: compliance fixes for getgroups</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21778</link>
    <description>&lt;pre&gt;Hi,

attached there is a patch to fix a couple of issues with Hurd's 
getgroups(), namely when the requested number is &amp;lt; 0 or when it is &amp;gt; 0 
but less than the actual number of groups that would be returned (this 
case is handled by simply returning the first n groups, instead of 
failing).

Thanks,
&lt;/pre&gt;</description>
    <dc:creator>Pino Toscano</dc:creator>
    <dc:date>2012-04-27T10:43:43</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.hurd.bugs/21775">
    <title>Next weeks</title>
    <link>http://comments.gmane.org/gmane.os.hurd.bugs/21775</link>
    <description>&lt;pre&gt;Hi!

I won't be available for one week starting today (completely, without
Internet access, huh) :-) and the two weeks after won't be much better.
After that, my focus will be GSoC and glibc.


Grüße,
 Thomas
&lt;/pre&gt;</description>
    <dc:creator>Thomas Schwinge</dc:creator>
    <dc:date>2012-04-27T06:26:03</dc:date>
  </item>
  <textinput rdf:about="http://search.gmane.org/?group=$group=gmane.os.hurd.bugs">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.os.hurd.bugs</link>
  </textinput>
</rdf:RDF>

