aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-02-08 13:36:53 +0000
committerCorinna Vinschen <corinna@vinschen.de>2007-02-08 13:36:53 +0000
commitce8bab5a923b07d34ea80dd2a508018aa34159ba (patch)
treed546e3254ed7b00561f02cded658bf44272c5bfc /winsup/cygwin/syscalls.cc
parentd7e4c7a807a5f1f633a184ea73be2599210499fb (diff)
downloadnewlib-ce8bab5a923b07d34ea80dd2a508018aa34159ba.zip
newlib-ce8bab5a923b07d34ea80dd2a508018aa34159ba.tar.gz
newlib-ce8bab5a923b07d34ea80dd2a508018aa34159ba.tar.bz2
* cygwin.din (shm_open): Export.
(shm_unlink): Export. * syscalls.cc (shm_open): New function. (shm_unlink): New function. * sysconf.cc (sca): Set value of _SC_SHARED_MEMORY_OBJECTS to _POSIX_SHARED_MEMORY_OBJECTS. * include/cygwin/version.h: Bump API minor number. * include/sys/mman.h (shm_open): Add prototype. (shm_unlink): Ditto.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 6a0e45f..998fe0e 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3346,3 +3346,49 @@ pclose (FILE *fp)
return status;
}
+
+#define SHM_STORAGE "/dev/shm"
+
+extern "C" int
+shm_open (const char *name, int oflag, mode_t mode)
+{
+ /* Name must start with a single slash. */
+ if (!name || name[0] != '/' || name[1] == '/'
+ || strlen (name) > CYG_MAX_PATH - sizeof (SHM_STORAGE))
+ {
+ debug_printf ("Invalid shared memory object name '%s'", name);
+ set_errno (EINVAL);
+ return -1;
+ }
+ /* Check for valid flags. */
+ if (((oflag & O_ACCMODE) != O_RDONLY && (oflag & O_ACCMODE) != O_RDWR)
+ || (oflag & ~(O_ACCMODE | O_CREAT | O_EXCL | O_TRUNC)))
+ {
+ debug_printf ("Invalid oflag 0%o", oflag);
+ set_errno (EINVAL);
+ return -1;
+ }
+ /* Note that we require the existance of /dev/shm here. We don't
+ create this directory from here. That's the task of the installer. */
+ char shmname[CYG_MAX_PATH];
+ strcpy (shmname, SHM_STORAGE);
+ strcat (shmname, name);
+ return open (shmname, oflag, mode & 0777);
+}
+
+extern "C" int
+shm_unlink (const char *name)
+{
+ /* Name must start with a single slash. */
+ if (!name || name[0] != '/' || name[1] == '/'
+ || strlen (name) > CYG_MAX_PATH - sizeof (SHM_STORAGE))
+ {
+ debug_printf ("Invalid shared memory object name '%s'", name);
+ set_errno (EINVAL);
+ return -1;
+ }
+ char shmname[CYG_MAX_PATH];
+ strcpy (shmname, SHM_STORAGE);
+ strcat (shmname, name);
+ return unlink (shmname);
+}