From ce8bab5a923b07d34ea80dd2a508018aa34159ba Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 8 Feb 2007 13:36:53 +0000 Subject: * 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. --- winsup/cygwin/syscalls.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'winsup/cygwin/syscalls.cc') diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 6a0e45fb5..998fe0ed4 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); +} -- cgit v1.2.3