Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygserver')
-rw-r--r--winsup/cygserver/ChangeLog9
-rw-r--r--winsup/cygserver/Makefile.in4
-rw-r--r--winsup/cygserver/msg.cc47
-rw-r--r--winsup/cygserver/sem.cc40
-rw-r--r--winsup/cygserver/threaded_queue.h127
5 files changed, 225 insertions, 2 deletions
diff --git a/winsup/cygserver/ChangeLog b/winsup/cygserver/ChangeLog
index fcc3b28a5..813192a49 100644
--- a/winsup/cygserver/ChangeLog
+++ b/winsup/cygserver/ChangeLog
@@ -1,3 +1,12 @@
+2003-08-30 Christopher Faylor <cgf@redhat.com>
+
+ * msg.cc: New file.
+ * sem.cc: Ditto.
+
+2003-08-30 Christopher Faylor <cgf@redhat.com>
+
+ * threaded_queue.h: New file.
+
2003-08-25 Christopher Faylor <cgf@redhat.com>
* Makefile.in: Build libcygserver.a.
diff --git a/winsup/cygserver/Makefile.in b/winsup/cygserver/Makefile.in
index b0396340a..5780dab99 100644
--- a/winsup/cygserver/Makefile.in
+++ b/winsup/cygserver/Makefile.in
@@ -37,8 +37,8 @@ override CXXFLAGS+=-fno-exceptions -fno-rtti -DHAVE_DECL_GETOPT=0 -D__OUTSIDE_CY
include $(srcdir)/../Makefile.common
-OBJS:= cygserver.o client.o process.o shm.o threaded_queue.o transport.o \
- transport_pipes.o transport_sockets.o
+OBJS:= cygserver.o client.o process.o msg.o sem.o shm.o threaded_queue.o \
+ transport.o transport_pipes.o transport_sockets.o
LIBOBJS:=${patsubst %.o,lib%.o,$(OBJS)}
CYGWIN_OBJS:=$(cygwin_build)/smallprint.o $(cygwin_build)/version.o \
diff --git a/winsup/cygserver/msg.cc b/winsup/cygserver/msg.cc
new file mode 100644
index 000000000..fecaa068a
--- /dev/null
+++ b/winsup/cygserver/msg.cc
@@ -0,0 +1,47 @@
+/* msg.cc: Single unix specification IPC interface for Cygwin.
+
+ Copyright 2002 Red Hat, Inc.
+
+ Written by Conrad Scott <conrad.scott@dsl.pipex.com>.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#include "winsup.h"
+
+#include <sys/types.h>
+#include <cygwin/msg.h>
+
+
+#include "cygerrno.h"
+
+extern "C" int
+msgctl (int msqid, int cmd, struct msqid_ds *buf)
+{
+ set_errno (ENOSYS);
+ return -1;
+}
+
+extern "C" int
+msgget (key_t key, int msgflg)
+{
+ set_errno (ENOSYS);
+ return -1;
+}
+
+extern "C" ssize_t
+msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
+{
+ set_errno (ENOSYS);
+ return -1;
+}
+
+extern "C" int
+msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
+{
+ set_errno (ENOSYS);
+ return -1;
+}
diff --git a/winsup/cygserver/sem.cc b/winsup/cygserver/sem.cc
new file mode 100644
index 000000000..97d91a354
--- /dev/null
+++ b/winsup/cygserver/sem.cc
@@ -0,0 +1,40 @@
+/* sem.cc: Single unix specification IPC interface for Cygwin.
+
+ Copyright 2002 Red Hat, Inc.
+
+ Written by Conrad Scott <conrad.scott@dsl.pipex.com>.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#include "winsup.h"
+
+#include <sys/types.h>
+#include <cygwin/sem.h>
+
+
+#include "cygerrno.h"
+
+extern "C" int
+semctl (int semid, int semnum, int cmd, ...)
+{
+ set_errno (ENOSYS);
+ return -1;
+}
+
+extern "C" int
+semget (key_t key, int nsems, int semflg)
+{
+ set_errno (ENOSYS);
+ return -1;
+}
+
+extern "C" int
+semop (int semid, struct sembuf *sops, size_t nsops)
+{
+ set_errno (ENOSYS);
+ return -1;
+}
diff --git a/winsup/cygserver/threaded_queue.h b/winsup/cygserver/threaded_queue.h
new file mode 100644
index 000000000..5b6fddc42
--- /dev/null
+++ b/winsup/cygserver/threaded_queue.h
@@ -0,0 +1,127 @@
+/* threaded_queue.h
+
+ Copyright 2001, 2002 Red Hat Inc.
+
+ Written by Robert Collins <rbtcollins@hotmail.com>
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _THREADED_QUEUE_
+#define _THREADED_QUEUE_
+
+/*****************************************************************************/
+
+/* a specific request */
+
+class queue_request
+{
+public:
+ queue_request *_next;
+
+ queue_request () : _next (NULL) {}
+ virtual ~queue_request ();
+
+ virtual void process () = 0;
+};
+
+/*****************************************************************************/
+
+/* a queue to allocate requests from n submission loops to x worker threads */
+
+class queue_submission_loop;
+
+class threaded_queue
+{
+public:
+ threaded_queue (size_t initial_workers = 1);
+ ~threaded_queue ();
+
+ void add_submission_loop (queue_submission_loop *);
+
+ bool running () const { return _running; }
+
+ bool start ();
+ bool stop ();
+
+ void add (queue_request *);
+
+private:
+ long _workers_count;
+ bool _running;
+
+ queue_submission_loop *_submitters_head;
+
+ long _requests_count; // Informational only.
+ queue_request *_requests_head;
+
+ CRITICAL_SECTION _queue_lock;
+ HANDLE _requests_sem; // == _requests_count
+
+ static DWORD WINAPI start_routine (LPVOID /* this */);
+
+ void create_workers (size_t initial_workers);
+ void worker_loop ();
+};
+
+/*****************************************************************************/
+
+/* parameters for a request finding and submitting loop */
+
+class queue_submission_loop
+{
+ friend class threaded_queue;
+
+public:
+ queue_submission_loop (threaded_queue *, bool ninterruptible);
+ virtual ~queue_submission_loop ();
+
+ bool start ();
+ bool stop ();
+
+ threaded_queue *queue () { return _queue; };
+
+protected:
+ bool _running;
+ HANDLE _interrupt_event;
+ threaded_queue *const _queue;
+
+private:
+ bool _interruptible;
+ HANDLE _hThread;
+ DWORD _tid;
+ queue_submission_loop *_next;
+
+ static DWORD WINAPI start_routine (LPVOID /* this */);
+ virtual void request_loop () = 0;
+};
+
+#ifdef __cplusplus
+
+/*---------------------------------------------------------------------------*
+ * Some type-safe versions of the various interlocked functions.
+ *---------------------------------------------------------------------------*/
+
+template <typename T> T *
+TInterlockedExchangePointer (T **lvalue, T *rvalue)
+{
+ return reinterpret_cast<T *>
+ (InterlockedExchangePointer (reinterpret_cast<void **> (lvalue),
+ reinterpret_cast<void *> (rvalue)));
+}
+
+template <typename T> T *
+TInterlockedCompareExchangePointer (T **lvalue, T *rvalue1, T *rvalue2)
+{
+ return reinterpret_cast<T *>
+ (InterlockedCompareExchangePointer (reinterpret_cast<void **> (lvalue),
+ reinterpret_cast<void *> (rvalue1),
+ reinterpret_cast<void *> (rvalue2)));
+}
+
+#endif /* __cplusplus */
+
+#endif /* _THREADED_QUEUE_ */