summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog23
-rw-r--r--rt/aio_notify.c19
-rw-r--r--sysdeps/mach/hurd/bits/posix_opt.h10
-rw-r--r--sysdeps/mach/hurd/fork.c2
-rw-r--r--sysdeps/mach/hurd/pread.c8
-rw-r--r--sysdeps/mach/hurd/pread64.c43
-rw-r--r--sysdeps/mach/hurd/pwrite.c8
-rw-r--r--sysdeps/mach/hurd/pwrite64.c43
-rw-r--r--sysdeps/posix/shm_open.c85
-rw-r--r--sysdeps/posix/shm_unlink.c62
10 files changed, 293 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 154cb795e9..bc941ce0cc 100644
--- 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.
diff --git a/rt/aio_notify.c b/rt/aio_notify.c
index 558b2d2451..04a9dd6db3 100644
--- a/rt/aio_notify.c
+++ b/rt/aio_notify.c
@@ -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;
}
diff --git a/sysdeps/mach/hurd/bits/posix_opt.h b/sysdeps/mach/hurd/bits/posix_opt.h
index 02280002a2..6231248bc2 100644
--- a/sysdeps/mach/hurd/bits/posix_opt.h
+++ b/sysdeps/mach/hurd/bits/posix_opt.h
@@ -31,6 +31,13 @@
/* 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
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c
index afc427045b..aa3a040aac 100644
--- a/sysdeps/mach/hurd/fork.c
+++ b/sysdeps/mach/hurd/fork.c
@@ -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))
{
diff --git a/sysdeps/mach/hurd/pread.c b/sysdeps/mach/hurd/pread.c
index dd69b10ac5..91b008f9f8 100644
--- a/sysdeps/mach/hurd/pread.c
+++ b/sysdeps/mach/hurd/pread.c
@@ -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
index 0000000000..43841eeb49
--- /dev/null
+++ b/sysdeps/mach/hurd/pread64.c
@@ -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
diff --git a/sysdeps/mach/hurd/pwrite.c b/sysdeps/mach/hurd/pwrite.c
index 42de3eb9f9..f734c4f5f2 100644
--- a/sysdeps/mach/hurd/pwrite.c
+++ b/sysdeps/mach/hurd/pwrite.c
@@ -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
index 0000000000..7cca3d8172
--- /dev/null
+++ b/sysdeps/mach/hurd/pwrite64.c
@@ -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
index 0000000000..8b8f87592d
--- /dev/null
+++ b/sysdeps/posix/shm_open.c
@@ -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
index 0000000000..aee2fcc34d
--- /dev/null
+++ b/sysdeps/posix/shm_unlink.c
@@ -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