* sysdeps/mach/hurd/fork.c (LOSE): Put `goto lose' in dead code
authorRoland McGrath <roland@gnu.org>
Thu, 14 Jun 2001 05:32:26 +0000 (05:32 +0000)
committerRoland McGrath <roland@gnu.org>
Thu, 14 Jun 2001 05:32:26 +0000 (05:32 +0000)
so the label is not considered unused.

* sysdeps/mach/hurd/pwrite64.c: New file.
* sysdeps/mach/hurd/pread64.c: New file.

* sysdeps/mach/hurd/pread.c
(__libc_pread): Define this name, with __pread as an alias.
* sysdeps/mach/hurd/pwrite.c
(__libc_pwrite): Define this name, with __pwrite as an alias.

Implement POSIX "shared memory objects" as regular
files residing in the /var/run/shm/ directory.
This works on any system that supports _POSIX_MAPPED_FILES,
to make it also support _POSIX_SHARED_MEMORY_OBJECTS.
* sysdeps/posix/shm_open.c: New file.
* sysdeps/posix/shm_unlink.c: New file.
* sysdeps/mach/hurd/bits/posix_opt.h
(_POSIX_SHARED_MEMORY_OBJECTS): Define it.

* rt/aio_notify.c (__aio_notify_only) [! _POSIX_REALTIME_SIGNALS]:
Use raise instead of __aio_sigqueue.

ChangeLog
rt/aio_notify.c
sysdeps/mach/hurd/bits/posix_opt.h
sysdeps/mach/hurd/fork.c
sysdeps/mach/hurd/pread.c
sysdeps/mach/hurd/pread64.c [new file with mode: 0644]
sysdeps/mach/hurd/pwrite.c
sysdeps/mach/hurd/pwrite64.c [new file with mode: 0644]
sysdeps/posix/shm_open.c [new file with mode: 0644]
sysdeps/posix/shm_unlink.c [new file with mode: 0644]

index 154cb795e9d6709fbe2df381f119384341d2d7f2..bc941ce0ccc7fce7c0cde4449698ebc8c9b29032 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
 2001-06-13  Roland McGrath  <roland@frob.com>
 
+       * sysdeps/mach/hurd/fork.c (LOSE): Put `goto lose' in dead code
+       so the label is not considered unused.
+
+       * sysdeps/mach/hurd/pwrite64.c: New file.
+       * sysdeps/mach/hurd/pread64.c: New file.
+
+       * sysdeps/mach/hurd/pread.c
+       (__libc_pread): Define this name, with __pread as an alias.
+       * sysdeps/mach/hurd/pwrite.c
+       (__libc_pwrite): Define this name, with __pwrite as an alias.
+
+       Implement POSIX "shared memory objects" as regular
+       files residing in the /var/run/shm/ directory.
+       This works on any system that supports _POSIX_MAPPED_FILES,
+       to make it also support _POSIX_SHARED_MEMORY_OBJECTS.
+       * sysdeps/posix/shm_open.c: New file.
+       * sysdeps/posix/shm_unlink.c: New file.
+       * sysdeps/mach/hurd/bits/posix_opt.h
+       (_POSIX_SHARED_MEMORY_OBJECTS): Define it.
+
+       * rt/aio_notify.c (__aio_notify_only) [! _POSIX_REALTIME_SIGNALS]:
+       Use raise instead of __aio_sigqueue.
+
        * sysdeps/mach/hurd/pread.c: Fail with EINVAL if OFFSET is negative.
        * sysdeps/mach/hurd/pwrite.c: Likewise.
 
index 558b2d2451421002b30224a0ff1ebc514744cbd6..04a9dd6db369a468e74ed25a295a8d7b84164764 100644 (file)
@@ -1,5 +1,5 @@
 /* Notify initiator of AIO request.
-   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1997,98,99,2000,01 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -58,10 +58,19 @@ __aio_notify_only (struct sigevent *sigev, pid_t caller_pid)
        result = -1;
     }
   else if (sigev->sigev_notify == SIGEV_SIGNAL)
-    /* We have to send a signal.  */
-    if (__aio_sigqueue (sigev->sigev_signo, sigev->sigev_value, caller_pid)
-       < 0)
-      result = -1;
+    {
+      /* We have to send a signal.  */
+#if _POSIX_REALTIME_SIGNALS
+      /* Note that the standard gives us the option of using a plain
+        non-queuing signal here when SA_SIGINFO is not set for the signal.  */
+      if (__aio_sigqueue (sigev->sigev_signo, sigev->sigev_value, caller_pid)
+         < 0)
+       result = -1;
+#else
+      /* There are no queued signals on this system at all.  */
+      result = raise (sigev->sigev_signo);
+#endif
+    }
 
   return result;
 }
index 02280002a2decc3fd56ad3d093e87a652d6ab5a7..6231248bc230f77592437e0220b29c3af4f44357 100644 (file)
 /* 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
 
@@ -46,6 +53,9 @@
 /* Setting of memory protections is supported.  */
 #define        _POSIX_MEMORY_PROTECTION        1
 
+/* POSIX.4 shared memory objects are supported (using regular files).  */
+#define _POSIX_SHARED_MEMORY_OBJECTS   _POSIX_MAPPED_FILES
+
 /* Implementation supports `poll' function.  */
 #define        _POSIX_POLL     1
 
index afc427045b911d931baf7e728fdc2722693cbb0c..aa3a040aacc5f599cf3aae4b60215a04f39aa1e8 100644 (file)
@@ -64,7 +64,7 @@ __fork (void)
   __spin_lock (&ss->critical_section_lock);
 
 #undef LOSE
-#define LOSE assert_perror (err) /* XXX */
+#define LOSE do { assert_perror (err); goto lose; } while (0) /* XXX */
 
   if (! setjmp (env))
     {
index dd69b10ac5994794141afd3c361275c567d87857..91b008f9f84a47a1f6591f40f560eea5a3da7f9b 100644 (file)
@@ -23,7 +23,7 @@
 #include <hurd/fd.h>
 
 ssize_t
-__pread (int fd, void *buf, size_t nbytes, off_t offset)
+__libc_pread (int fd, void *buf, size_t nbytes, off_t offset)
 {
   error_t err;
   if (offset < 0)
@@ -32,4 +32,8 @@ __pread (int fd, void *buf, size_t nbytes, off_t offset)
     err = HURD_FD_USE (fd, _hurd_fd_read (descriptor, buf, &nbytes, offset));
   return err ? __hurd_dfail (fd, err) : nbytes;
 }
-weak_alias (__pread, pread)
+
+#ifndef __libc_pread
+strong_alias (__libc_pread, __pread)
+weak_alias (__libc_pread, pread)
+#endif
diff --git a/sysdeps/mach/hurd/pread64.c b/sysdeps/mach/hurd/pread64.c
new file mode 100644 (file)
index 0000000..43841ee
--- /dev/null
@@ -0,0 +1,43 @@
+/* Read block from given position in file without changing file pointer.
+   Hurd 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 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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+ssize_t
+__libc_pread64 (int fd, void *buf, size_t nbyte, off64_t offset)
+{
+  /* XXX We don't really support large files on the Hurd.  So if
+     OFFSET doesn't fit in an `off_t', we'll return `-1' and set
+     errno.  EOVERFLOW probably isn't the right error value, but seems
+     appropriate here.  */
+  if ((off_t) offset != offset)
+    {
+      __set_errno (EOVERFLOW);
+      return -1;
+    }
+
+  return __libc_pread (fd, buf, nbyte, offset);
+}
+
+#ifndef __libc_pread64
+weak_alias (__libc_pread64, __pread64)
+weak_alias (__libc_pread64, pread64)
+#endif
index 42de3eb9f984c387821b06815a2e41235e6b623a..f734c4f5f2ffcc8a8cab0cb0300436dacf72637f 100644 (file)
@@ -25,7 +25,7 @@
 /* Write NBYTES of BUF to FD at given position OFFSET without changing
    the file position.  Return the number written, or -1.  */
 ssize_t
-__pwrite (int fd, const void *buf, size_t nbytes, off_t offset)
+__libc_pwrite (int fd, const void *buf, size_t nbytes, off_t offset)
 {
   error_t err;
   if (offset < 0)
@@ -34,4 +34,8 @@ __pwrite (int fd, const void *buf, size_t nbytes, off_t offset)
     err = HURD_FD_USE (fd, _hurd_fd_write (descriptor, buf, &nbytes, offset));
   return err ? __hurd_dfail (fd, err) : nbytes;
 }
-weak_alias (__pwrite, pwrite)
+
+#ifndef __libc_pwrite
+strong_alias (__libc_pwrite, __pwrite)
+weak_alias (__libc_pwrite, pwrite)
+#endif
diff --git a/sysdeps/mach/hurd/pwrite64.c b/sysdeps/mach/hurd/pwrite64.c
new file mode 100644 (file)
index 0000000..7cca3d8
--- /dev/null
@@ -0,0 +1,43 @@
+/* Write block to given position in file without changing file pointer.
+   Hurd 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 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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+ssize_t
+__libc_pwrite64 (int fd, const void *buf, size_t nbyte, off64_t offset)
+{
+  /* XXX We don't really support large files on the Hurd.  So if
+     OFFSET doesn't fit in an `off_t', we'll return `-1' and set
+     errno.  EOVERFLOW probably isn't the right error value, but seems
+     appropriate here.  */
+  if ((off_t) offset != offset)
+    {
+      __set_errno (EOVERFLOW);
+      return -1;
+    }
+
+  return __libc_pwrite (fd, buf, nbyte, offset);
+}
+
+#ifndef __libc_pwrite64
+weak_alias (__libc_pwrite64, __pwrite64)
+weak_alias (__libc_pwrite64, pwrite64)
+#endif
diff --git a/sysdeps/posix/shm_open.c b/sysdeps/posix/shm_open.c
new file mode 100644 (file)
index 0000000..8b8f875
--- /dev/null
@@ -0,0 +1,85 @@
+/* shm_open -- open a POSIX shared memory object.  Generic POSIX file 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 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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <unistd.h>
+
+#if ! _POSIX_MAPPED_FILES
+#include <sysdeps/generic/shm_open.c>
+
+#else
+
+#include <errno.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <paths.h>
+
+#define SHMDIR (_PATH_VARRUN "shm/")
+
+/* Open shared memory object.  */
+int
+shm_open (const char *name, int oflag, mode_t mode)
+{
+  size_t namelen;
+  char *fname;
+  int fd;
+
+  /* Construct the filename.  */
+  while (name[0] == '/')
+    ++name;
+
+  if (name[0] == '\0')
+    {
+      /* The name "/" is not supported.  */
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  namelen = strlen (name);
+  fname = (char *) __alloca (sizeof SHMDIR - 1 + namelen + 1);
+  __mempcpy (__mempcpy (fname, SHMDIR, sizeof SHMDIR - 1),
+            name, namelen + 1);
+
+  fd = open (name, oflag, mode);
+  if (fd != -1)
+    {
+      /* We got a descriptor.  Now set the FD_CLOEXEC bit.  */
+      int flags = fcntl (fd, F_GETFD, 0);
+
+      if (__builtin_expect (flags, 0) != -1)
+       {
+         flags |= FD_CLOEXEC;
+         flags = fcntl (fd, F_SETFD, flags);
+       }
+
+      if (flags == -1)
+       {
+         /* Something went wrong.  We cannot return the descriptor.  */
+         int save_errno = errno;
+         close (fd);
+         fd = -1;
+         __set_errno (save_errno);
+       }
+    }
+
+  return fd;
+}
+
+#endif
diff --git a/sysdeps/posix/shm_unlink.c b/sysdeps/posix/shm_unlink.c
new file mode 100644 (file)
index 0000000..aee2fcc
--- /dev/null
@@ -0,0 +1,62 @@
+/* shm_unlink -- remove a POSIX shared memory object.  Generic POSIX 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 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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <unistd.h>
+
+#if ! _POSIX_MAPPED_FILES
+#include <sysdeps/generic/shm_unlink.c>
+
+#else
+
+#include <errno.h>
+#include <sys/mman.h>
+#include <string.h>
+#include <stdlib.h>
+#include <paths.h>
+
+#define SHMDIR (_PATH_VARRUN "shm/")
+
+/* Remove shared memory object.  */
+int
+shm_unlink (const char *name)
+{
+  size_t namelen;
+  char *fname;
+
+  /* Construct the filename.  */
+  while (name[0] == '/')
+    ++name;
+
+  if (name[0] == '\0')
+    {
+      /* The name "/" is not supported.  */
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  namelen = strlen (name);
+  fname = (char *) __alloca (sizeof SHMDIR - 1 + namelen + 1);
+  __mempcpy (__mempcpy (fname, SHMDIR, sizeof SHMDIR - 1),
+            name, namelen + 1);
+
+
+  return __unlink (name);
+}
+
+#endif