summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/pthread.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-02-20 15:48:04 +0000
committerCorinna Vinschen <corinna@vinschen.de>2007-02-20 15:48:04 +0000
commit8fbd574ef065d5d71c933bbb76d8817300fbb487 (patch)
tree70c319ca4151050cbaef9f4f0095246665dc5573 /winsup/cygwin/pthread.cc
parentd0cf179299952b716333e437a8264610e5b4740f (diff)
downloadcygnal-8fbd574ef065d5d71c933bbb76d8817300fbb487.tar.gz
cygnal-8fbd574ef065d5d71c933bbb76d8817300fbb487.tar.bz2
cygnal-8fbd574ef065d5d71c933bbb76d8817300fbb487.zip
* cygwin.din (sem_unlink): Export.
* posix_ipc.cc: Include thread.h and semaphore.h. Remove TODO comment. (ipc_names): Add max_len member. Set to maximum length of the path before tacking on the prefix path. Set prefix path for named semaphors to /dev/shm, as on Linux. (enum ipc_type_t): Change sem to semaphore to avoid name conflicts. (check_path): Detect empty paths. Use ipc_names's max_len member. Use __small_sprintf to create full object path name. Special case semaphores. (ipc_cond_init): Drop superfluous strcpy. (class ipc_flock): New class to simplify file locking in subsequent code. (struct mq_hdr): Raise size of mqh_uname to allow adding a unique LUID to the name. (mq_open): Fix formatting. Create unique synchronization object names using AllocateLocallyUniqueId. (struct sem_finfo): New structure defining named semaphore file content. (sem_open): Move here. Rework implementation to allow kernel persistent implementation of POSIX named semaphores. (_sem_close): Implement sem_close. (sem_close): Move here. Just call _sem_close with do_close parameter set to true. (sem_unlink): New function. * pthread.cc (mangle_sem_name): Remove. (sem_open): Move to posix_ipc.cc. (sem_close): Ditto. * syscalls.cc (close_all_files): Call semaphore::terminate here. * thread.cc: Fix formatting. Rearrange semaphore functions so that they are close together. (semaphore::semaphore): Rework to play nicely with new named semaphore implementation. (semaphore::_terminate): Call _sem_close if semaphore is a named semaphore. (semaphore::destroy): Don't destroy named semaphores. Return EINVAL instead. (semaphore::close): Only destroy named semaphores. Return EINVAL otherwise. (semaphore::open): Rework to play nicely with new named semaphore implementation. Loop through existing semaphores to be able to return same sem_t pointer as a former call on the same named semaphore. (semaphore::getinternal): New function called from _sem_close. * thread.h (class List): Make mx and head public. (class semaphore): Fix formatting. Align method declarations with implementation in thread.cc. Add members used for named semaphores. (semaphore::terminate): New static method. * include/semaphore.h: Redefine SEM_FAILED. Fix formatting. (sem_unlink): Add declaration. * include/cygwin/version.h: Bump API minor number.
Diffstat (limited to 'winsup/cygwin/pthread.cc')
-rw-r--r--winsup/cygwin/pthread.cc56
1 files changed, 1 insertions, 55 deletions
diff --git a/winsup/cygwin/pthread.cc b/winsup/cygwin/pthread.cc
index 949bc0970..310c5d76b 100644
--- a/winsup/cygwin/pthread.cc
+++ b/winsup/cygwin/pthread.cc
@@ -1,6 +1,6 @@
/* pthread.cc: posix pthread interface for Cygwin
- Copyright 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+ Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007 Red Hat, Inc.
Originally written by Marco Fuykschot <marco@ddi.nl>
@@ -164,60 +164,6 @@ sem_destroy (sem_t * sem)
return semaphore::destroy (sem);
}
-/* Mangle semaphore name to follow windows naming rules. Prepend "Global\"
- if running on terminal service aware machine. Substitute invalid backslash
- by forward slash characters, hoping not to collide. */
-static bool
-mangle_sem_name (char *mangled, const char *name)
-{
- myfault efault;
- if (efault.faulted (EFAULT))
- return false;
- if (!*name)
- {
- set_errno (ENOENT);
- return false;
- }
- size_t len = strlen (cygheap->shared_prefix);
- if (strlen (name) >= CYG_MAX_PATH - len)
- {
- set_errno (EINVAL);
- return false;
- }
- strcpy (mangled, cygheap->shared_prefix);
- char *d = mangled + len;
- const char *s = name;
- while (*s)
- *d++ = (*s == '\\') ? '/' : *s++;
- *d = '\0';
- return true;
-}
-
-sem_t *
-sem_open (const char *name, int oflag, ...)
-{
- mode_t mode = 0;
- unsigned int value = 0;
- if (oflag & O_CREAT)
- {
- va_list ap;
- va_start (ap, oflag);
- mode = va_arg (ap, mode_t);
- value = va_arg (ap, unsigned int);
- va_end (ap);
- }
- char mangled_name[CYG_MAX_PATH];
- if (!mangle_sem_name (mangled_name, name))
- return NULL;
- return semaphore::open (mangled_name, oflag, mode, value);
-}
-
-int
-sem_close (sem_t * sem)
-{
- return semaphore::destroy (sem);
-}
-
int
sem_wait (sem_t * sem)
{