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/cygwin/include')
-rwxr-xr-xwinsup/cygwin/include/cygwin/cygserver.h211
-rwxr-xr-xwinsup/cygwin/include/cygwin/cygserver_process.h166
-rwxr-xr-xwinsup/cygwin/include/cygwin/cygserver_transport.h41
-rwxr-xr-xwinsup/cygwin/include/cygwin/cygserver_transport_pipes.h64
-rwxr-xr-xwinsup/cygwin/include/cygwin/cygserver_transport_sockets.h53
-rw-r--r--winsup/cygwin/include/cygwin/ipc.h58
-rw-r--r--winsup/cygwin/include/cygwin/msg.h92
-rw-r--r--winsup/cygwin/include/cygwin/sem.h95
-rw-r--r--winsup/cygwin/include/cygwin/shm.h119
9 files changed, 627 insertions, 272 deletions
diff --git a/winsup/cygwin/include/cygwin/cygserver.h b/winsup/cygwin/include/cygwin/cygserver.h
index c7a04929f..d4ea70fbb 100755
--- a/winsup/cygwin/include/cygwin/cygserver.h
+++ b/winsup/cygwin/include/cygwin/cygserver.h
@@ -13,123 +13,172 @@ details. */
#ifndef _CYGSERVER_H_
#define _CYGSERVER_H_
-#define MAX_REQUEST_SIZE 128
+#ifdef __GNUC__
+#define CYGSERVER_PACKED __attribute__ ((packed))
+#else
+#define CYGSERVER_PACKED
+#endif
#define CYGWIN_SERVER_VERSION_MAJOR 1
#define CYGWIN_SERVER_VERSION_API 1
#define CYGWIN_SERVER_VERSION_MINOR 0
#define CYGWIN_SERVER_VERSION_PATCH 0
-
typedef enum {
- CYGSERVER_UNKNOWN=0,
- CYGSERVER_OK=1,
- CYGSERVER_DEAD=2
+ CYGSERVER_UNKNOWN = 0,
+ CYGSERVER_OK,
+ CYGSERVER_UNAVAIL
} cygserver_states;
-typedef enum {
- CYGSERVER_REQUEST_INVALID = 0,
- CYGSERVER_REQUEST_GET_VERSION,
- CYGSERVER_REQUEST_ATTACH_TTY,
- CYGSERVER_REQUEST_SHUTDOWN,
- CYGSERVER_REQUEST_SHM_GET,
- CYGSERVER_REQUEST_LAST
-} cygserver_request_code;
-
-class request_header
-{
- public:
- ssize_t cb;
- cygserver_request_code req_id;
- ssize_t error_code;
- request_header (cygserver_request_code id, ssize_t ncb) : cb (ncb), req_id (id), error_code (0) {} ;
-}
-#ifdef __GNUC__
- __attribute__ ((packed))
-#endif
-;
+/*---------------------------------------------------------------------------*
+ * class client_request
+ *---------------------------------------------------------------------------*/
-extern void cygserver_init ();
-
-#define INIT_REQUEST(req,id) \
- (req).header.cb = sizeof (req); \
- (req).header.req_id = id;
+class transport_layer_base;
-struct request_get_version
-{
- DWORD major, api, minor, patch;
-}
-#ifdef __GNUC__
- __attribute__ ((packed))
+#ifndef __INSIDE_CYGWIN__
+class process_cache;
#endif
-;
-struct request_shutdown
+class client_request
{
- int foo;
-}
-#ifdef __GNUC__
- __attribute__ ((packed))
+protected:
+ typedef enum {
+ CYGSERVER_REQUEST_INVALID,
+ CYGSERVER_REQUEST_GET_VERSION,
+ CYGSERVER_REQUEST_SHUTDOWN,
+ CYGSERVER_REQUEST_ATTACH_TTY,
+ CYGSERVER_REQUEST_SHM,
+ CYGSERVER_REQUEST_LAST
+ } request_code_t;
+
+ struct header_t
+ {
+ size_t msglen;
+ union
+ {
+ request_code_t request_code;
+ ssize_t error_code;
+ };
+
+ header_t () {};
+ header_t (request_code_t, size_t);
+ } CYGSERVER_PACKED;
+
+public:
+#ifndef __INSIDE_CYGWIN__
+ static void handle_request (transport_layer_base *, process_cache *);
#endif
-;
-struct request_attach_tty
-{
- DWORD pid, master_pid;
- HANDLE from_master, to_master;
-}
-#ifdef __GNUC__
- __attribute__ ((packed))
-#endif
-;
+ client_request (request_code_t request_code,
+ void *buf = NULL,
+ size_t bufsiz = 0);
+ virtual ~client_request ();
+
+ request_code_t request_code () const { return _header.request_code; }
+
+ ssize_t error_code () const { return _header.error_code; };
+ void error_code (ssize_t error_code) { _header.error_code = error_code; };
+
+ size_t msglen () const { return _header.msglen; };
+ void msglen (size_t len) { _header.msglen = len; };
+
+ int make_request ();
+
+protected:
+ virtual void send (transport_layer_base *);
+
+private:
+ header_t _header;
+ void * const _buf;
+ const size_t _buflen;
-class client_request
-{
- public:
- client_request (cygserver_request_code id, ssize_t data_size);
- virtual void send (transport_layer_base *conn);
#ifndef __INSIDE_CYGWIN__
- virtual void serve (transport_layer_base *conn, class process_cache *cache);
+ void handle (transport_layer_base *, process_cache *);
+ virtual void serve (transport_layer_base *, process_cache *) = 0;
#endif
- virtual operator struct request_header ();
- cygserver_request_code req_id () {return header.req_id;};
- virtual ~client_request();
- request_header header;
- char *buffer;
};
+/*---------------------------------------------------------------------------*
+ * class client_request_get_version
+ *---------------------------------------------------------------------------*/
+
class client_request_get_version : public client_request
{
- public:
+private:
+ struct request_get_version
+ {
+ DWORD major, api, minor, patch;
+ } CYGSERVER_PACKED;
+
+public:
+ client_request_get_version ();
+ bool check_version () const;
+
+private:
+ struct request_get_version version;
+
#ifndef __INSIDE_CYGWIN__
- virtual void serve (transport_layer_base *conn, class process_cache *cache);
+ virtual void serve (transport_layer_base *, process_cache *);
#endif
- client_request_get_version::client_request_get_version();
- struct request_get_version version;
};
+/*---------------------------------------------------------------------------*
+ * class client_request_shutdown
+ *
+ * Nb. This whole class is only !__INSIDE_CYGWIN__ since it is used
+ * solely by cygserver itself.
+ *---------------------------------------------------------------------------*/
+
+#ifndef __INSIDE_CYGWIN__
+
class client_request_shutdown : public client_request
{
- public:
-#ifndef __INSIDE_CYGWIN__
- virtual void serve (transport_layer_base *conn, class process_cache *cache);
-#endif
+public:
client_request_shutdown ();
+
+private:
+ virtual void serve (transport_layer_base *, process_cache *);
};
+#endif /* !__INSIDE_CYGWIN__ */
+
+/*---------------------------------------------------------------------------*
+ * class client_request_attach_tty
+ *---------------------------------------------------------------------------*/
+
class client_request_attach_tty : public client_request
{
- public:
-#ifndef __INSIDE_CYGWIN__
- virtual void serve (transport_layer_base *conn, class process_cache *cache);
-#endif
+private:
+ struct request_attach_tty
+ {
+ DWORD pid, master_pid;
+ HANDLE from_master, to_master;
+ } CYGSERVER_PACKED;
+
+public:
+#ifdef __INSIDE_CYGWIN__
+ client_request_attach_tty (DWORD nmaster_pid,
+ HANDLE nfrom_master, HANDLE nto_master);
+#else
client_request_attach_tty ();
- client_request_attach_tty (DWORD npid, DWORD nmaster_pid, HANDLE nfrom_master, HANDLE nto_master);
- HANDLE from_master () {return req.from_master;};
- HANDLE to_master () {return req.to_master;};
+#endif
+
+ HANDLE from_master () const { return req.from_master; };
+ HANDLE to_master () const { return req.to_master; };
+
+protected:
+ virtual void send (transport_layer_base *);
+
+private:
struct request_attach_tty req;
+
+#ifndef __INSIDE_CYGWIN__
+ virtual void serve (transport_layer_base *, process_cache *);
+#endif
};
-extern int cygserver_request (client_request *);
+extern bool check_cygserver_available ();
+extern void cygserver_init ();
-#endif /* _CYGSERVER+H+ */
+#endif /* _CYGSERVER_H_ */
diff --git a/winsup/cygwin/include/cygwin/cygserver_process.h b/winsup/cygwin/include/cygwin/cygserver_process.h
index c8ff40b09..25c634e9e 100755
--- a/winsup/cygwin/include/cygwin/cygserver_process.h
+++ b/winsup/cygwin/include/cygwin/cygserver_process.h
@@ -4,81 +4,161 @@
Written by Robert Collins <rbtcollins@hotmail.com>
- This file is part of Cygwin.
+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. */
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
#ifndef _CYGSERVER_PROCESS_
#define _CYGSERVER_PROCESS_
-/* needs threaded_queue.h */
+#include <assert.h>
-class process_cleanup:public queue_request
+#include "threaded_queue.h"
+
+class process_cleanup : public queue_request
{
public:
+ process_cleanup (class process *const theprocess)
+ : _process (theprocess)
+ {
+ assert (_process);
+ }
+
+ virtual ~process_cleanup ();
+
virtual void process ();
- process_cleanup (class process *nprocess) : theprocess (nprocess) {};
+
private:
- class process * theprocess;
+ class process *const _process;
};
-class process_process_param:public queue_process_param
-{
- class process_cache *cache;
-public:
- DWORD request_loop ();
- process_process_param ():queue_process_param (true) {};
-};
+class process;
class cleanup_routine
{
+ friend class process;
+
public:
- cleanup_routine () : next (NULL) {};
- class cleanup_routine * next;
+ cleanup_routine (void *const key)
+ : _key (key),
+ _next (NULL)
+ {}
+
+ virtual ~cleanup_routine ();
+
+ bool operator== (const cleanup_routine &rhs) const
+ {
+ return _key == rhs._key;
+ }
+
+ void *key () const { return _key; }
+
/* MUST BE SYNCHRONOUS */
- virtual void cleanup (long winpid);
+ virtual void cleanup (class process *) = 0;
+
+private:
+ void *const _key;
+ cleanup_routine *_next;
};
+class process_cache;
+
class process
{
+ friend class process_cache;
+ friend class process_cleanup;
+
public:
- HANDLE handle ();
- long winpid;
- process (long);
+ process (pid_t cygpid, DWORD winpid);
~process ();
- DWORD exit_code ();
- class process * next;
- long refcount;
- bool add_cleanup_routine (class cleanup_routine *);
- void cleanup ();
+
+ pid_t cygpid () const { return _cygpid; }
+ DWORD winpid () const { return _winpid; }
+ HANDLE handle () const { return _hProcess; }
+
+ bool is_active () const { return _exit_status == STILL_ACTIVE; }
+
+ void hold () { EnterCriticalSection (&_access); }
+ void release () { LeaveCriticalSection (&_access); }
+
+ bool add (cleanup_routine *);
+ bool remove (const cleanup_routine *);
+
private:
+ const pid_t _cygpid;
+ const DWORD _winpid;
+ HANDLE _hProcess;
+ long _cleaning_up;
+ DWORD _exit_status; // Set in the constructor and in exit_code ().
+ cleanup_routine *_routines_head;
/* used to prevent races-on-delete */
- CRITICAL_SECTION access;
- volatile long cleaning_up;
- class cleanup_routine *head;
- HANDLE thehandle;
- DWORD _exit_status;
+ CRITICAL_SECTION _access;
+ class process *_next;
+
+ DWORD check_exit_code ();
+ void cleanup ();
};
-class process_cache:public threaded_queue
+class process_cache
{
+ // Number of special (i.e., non-process) handles in _wait_array.
+ // See wait_for_processes () and sync_wait_array () for details.
+ enum {
+ SPECIALS_COUNT = 2
+ };
+
+ class submission_loop : public queue_submission_loop
+ {
+ public:
+ submission_loop (process_cache *const cache, threaded_queue *const queue)
+ : queue_submission_loop (queue, true),
+ _cache (cache)
+ {
+ assert (_cache);
+ }
+
+ private:
+ process_cache *const _cache;
+
+ virtual void request_loop ();
+ };
+
+ friend class submission_loop;
+
public:
process_cache (unsigned int initial_workers);
- virtual ~ process_cache ();
- class process *process (long);
- /* remove a process from the cache */
- int handle_snapshot (HANDLE *, class process **, ssize_t, int);
- void remove_process (class process *);
- /* threaded_queue methods */
- void process_requests ();
- HANDLE cache_add_trigger;
+ ~process_cache ();
+
+ class process *process (pid_t cygpid, DWORD winpid);
+
+ bool running () const { return _queue.running (); }
+
+ bool start () { return _queue.start (); }
+ bool stop () { return _queue.stop (); }
private:
- virtual void add_task (class process *);
- class process *head;
- CRITICAL_SECTION cache_write_access;
+ threaded_queue _queue;
+ submission_loop _submitter;
+
+ size_t _processes_count;
+ class process *_processes_head; // A list sorted by winpid.
+
+ // Access to the _wait_array and related fields is not thread-safe,
+ // since they are used solely by wait_for_processes () and its callees.
+
+ HANDLE _wait_array[MAXIMUM_WAIT_OBJECTS];
+ class process *_process_array[MAXIMUM_WAIT_OBJECTS];
+
+ HANDLE _cache_add_trigger; // Actually both add and remove.
+ CRITICAL_SECTION _cache_write_access; // Actually both read and write access.
+
+ void wait_for_processes (HANDLE interrupt);
+ size_t sync_wait_array (HANDLE interrupt);
+ void check_and_remove_process (const size_t index);
+
+ class process *find (DWORD winpid, class process **previous = NULL);
};
#endif /* _CYGSERVER_PROCESS_ */
diff --git a/winsup/cygwin/include/cygwin/cygserver_transport.h b/winsup/cygwin/include/cygwin/cygserver_transport.h
index 493c9b530..915f35e66 100755
--- a/winsup/cygwin/include/cygwin/cygserver_transport.h
+++ b/winsup/cygwin/include/cygwin/cygserver_transport.h
@@ -1,32 +1,39 @@
-/* cygserver.cc
+/* cygserver_transport.h
Copyright 2001, 2002 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com>
- This file is part of Cygwin.
+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. */
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
#ifndef _CYGSERVER_TRANSPORT_
#define _CYGSERVER_TRANSPORT_
-class transport_layer_base *create_server_transport();
-/* the base class does nothing. */
+class transport_layer_base *create_server_transport ();
+
class transport_layer_base
{
- public:
- virtual void listen ();
- virtual class transport_layer_base * accept ();
- virtual void close ();
- virtual ssize_t read (char *buf, size_t len);
- virtual ssize_t write (char *buf, size_t len);
- virtual bool connect();
- virtual void impersonate_client ();
- virtual void revert_to_self ();
- transport_layer_base ();
+public:
+#ifndef __INSIDE_CYGWIN__
+ virtual int listen () = 0;
+ virtual class transport_layer_base *accept (bool *recoverable) = 0;
+#endif
+
+ virtual void close () = 0;
+ virtual ssize_t read (void *buf, size_t len) = 0;
+ virtual ssize_t write (void *buf, size_t len) = 0;
+ virtual int connect () = 0;
+
+#ifndef __INSIDE_CYGWIN__
+ virtual void impersonate_client ();
+ virtual void revert_to_self ();
+#endif
+
+ virtual ~transport_layer_base ();
};
#endif /* _CYGSERVER_TRANSPORT_ */
diff --git a/winsup/cygwin/include/cygwin/cygserver_transport_pipes.h b/winsup/cygwin/include/cygwin/cygserver_transport_pipes.h
index 9ebeee2a4..4bea2eb13 100755
--- a/winsup/cygwin/include/cygwin/cygserver_transport_pipes.h
+++ b/winsup/cygwin/include/cygwin/cygserver_transport_pipes.h
@@ -1,39 +1,53 @@
-/* cygserver.cc
+/* cygserver_transport_pipes.h
Copyright 2001, 2002 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com>
- This file is part of Cygwin.
+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. */
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
#ifndef _CYGSERVER_TRANSPORT_PIPES_
#define _CYGSERVER_TRANSPORT_PIPES_
+
/* Named pipes based transport, for security on NT */
class transport_layer_pipes : public transport_layer_base
{
- public:
- virtual void listen ();
- virtual class transport_layer_pipes * accept ();
- virtual void close ();
- virtual ssize_t read (char *buf, size_t len);
- virtual ssize_t write (char *buf, size_t len);
- virtual bool connect();
- virtual void impersonate_client ();
- virtual void revert_to_self ();
- transport_layer_pipes ();
-
- private:
- /* for pipe based communications */
- void init_security ();
- SECURITY_DESCRIPTOR sd;
- SECURITY_ATTRIBUTES sec_none_nih, sec_all_nih;
- char pipe_name [MAX_PATH];
- HANDLE pipe;
- bool inited;
- transport_layer_pipes (HANDLE new_pipe);
+public:
+#ifndef __INSIDE_CYGWIN__
+ virtual int listen ();
+ virtual class transport_layer_pipes *accept (bool *recoverable);
+#endif
+
+ virtual void close ();
+ virtual ssize_t read (void *buf, size_t len);
+ virtual ssize_t write (void *buf, size_t len);
+ virtual int connect ();
+
+#ifndef __INSIDE_CYGWIN__
+ virtual void impersonate_client ();
+ virtual void revert_to_self ();
+#endif
+
+ transport_layer_pipes ();
+ virtual ~transport_layer_pipes ();
+
+private:
+ /* for pipe based communications */
+ void init_security ();
+
+ //FIXME: allow inited, sd, all_nih_.. to be static members
+ SECURITY_DESCRIPTOR _sd;
+ SECURITY_ATTRIBUTES _sec_all_nih;
+ const char *const _pipe_name;
+ HANDLE _hPipe;
+ const bool _is_accepted_endpoint;
+ bool _is_listening_endpoint;
+
+ transport_layer_pipes (HANDLE hPipe);
};
+
#endif /* _CYGSERVER_TRANSPORT_PIPES_ */
diff --git a/winsup/cygwin/include/cygwin/cygserver_transport_sockets.h b/winsup/cygwin/include/cygwin/cygserver_transport_sockets.h
index 9881ca2bb..d960f9c2c 100755
--- a/winsup/cygwin/include/cygwin/cygserver_transport_sockets.h
+++ b/winsup/cygwin/include/cygwin/cygserver_transport_sockets.h
@@ -1,33 +1,46 @@
-/* cygserver.cc
+/* cygserver_transport_sockets.h
Copyright 2001, 2002 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com>
- This file is part of Cygwin.
+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. */
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
#ifndef _CYGSERVER_TRANSPORT_SOCKETS_
#define _CYGSERVER_TRANSPORT_SOCKETS_
+
+#include <sys/socket.h>
+#include <sys/un.h>
+
class transport_layer_sockets : public transport_layer_base
{
- public:
- virtual void listen ();
- virtual class transport_layer_sockets * accept ();
- virtual void close ();
- virtual ssize_t read (char *buf, size_t len);
- virtual ssize_t write (char *buf, size_t len);
- virtual bool connect();
- transport_layer_sockets ();
-
- private:
- /* for socket based communications */
- int fd;
- struct sockaddr sockdetails;
- int sdlen;
- transport_layer_sockets (int newfd);
+public:
+#ifndef __INSIDE_CYGWIN__
+ virtual int listen ();
+ virtual class transport_layer_sockets *accept (bool *recoverable);
+#endif
+
+ virtual void close ();
+ virtual ssize_t read (void *buf, size_t len);
+ virtual ssize_t write (void *buf, size_t len);
+ virtual int connect ();
+
+ transport_layer_sockets ();
+ virtual ~transport_layer_sockets ();
+
+private:
+ /* for socket based communications */
+ int _fd;
+ struct sockaddr_un _addr;
+ socklen_t _addr_len;
+ const bool _is_accepted_endpoint;
+ bool _is_listening_endpoint;
+
+ transport_layer_sockets (int fd);
};
+
#endif /* _CYGSERVER_TRANSPORT_SOCKETS_ */
diff --git a/winsup/cygwin/include/cygwin/ipc.h b/winsup/cygwin/include/cygwin/ipc.h
index c718a173a..8a88a1085 100644
--- a/winsup/cygwin/include/cygwin/ipc.h
+++ b/winsup/cygwin/include/cygwin/ipc.h
@@ -1,6 +1,6 @@
/* sys/ipc.h
- Copyright 2001 Red Hat Inc.
+ Copyright 2001, 2002 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com>
This file is part of Cygwin.
@@ -9,45 +9,45 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#ifndef _SYS_IPC_H
+#define _SYS_IPC_H
+
#ifdef __cplusplus
extern "C"
{
#endif
-#ifndef _SYS_IPC_H
-#define _SYS_IPC_H
-
-/* sys/types must be included before sys/ipc.h. We aren't meant to automatically
- * include it however
+struct ipc_perm
+{
+ uid_t uid; /* Owner's user ID. */
+ gid_t gid; /* Owner's group ID. */
+ uid_t cuid; /* Creator's user ID. */
+ gid_t cgid; /* Creator's group ID. */
+ mode_t mode; /* Read/write permission. */
+ key_t key;
+};
+
+/* Mode bits:
*/
+#define IPC_CREAT 0x0200 /* Create entry if key does not exist. */
+#define IPC_EXCL 0x0400 /* Fail if key exists. */
+#define IPC_NOWAIT 0x0800 /* Error if request must wait. */
-struct ipc_perm {
- uid_t uid;
- gid_t gid;
- uid_t cuid;
- gid_t cgid;
- mode_t mode;
-};
-
-/* the mode flags used with the _get functions use the low order 9 bits for a mode
- * request
+/* Keys:
*/
-#define IPC_CREAT 0x0200
-#define IPC_EXCL 0x0400
-#define IPC_NOWAIT 0x0800
-
-/* this is a value that will _never_ be a valid key from ftok */
-#define IPC_PRIVATE -2
+#define IPC_PRIVATE ((key_t) 0) /* Private key. */
-/* ctl commands 1000-1fff is ipc reserved */
-#define IPC_RMID 0x1003
-#define IPC_SET 0x1002
-#define IPC_STAT 0x1001
+/* Control commands:
+ */
+#define IPC_RMID 0x1000 /* Remove identifier. */
+#define IPC_SET 0x1001 /* Set options. */
+#define IPC_STAT 0x1002 /* Get options. */
+#define IPC_INFO 0x1003 /* For ipcs(8). */
-key_t ftok(const char *, int);
-
-#endif /* _SYS_IPC_H */
+key_t ftok (const char *path, int id);
#ifdef __cplusplus
}
#endif
+
+#endif /* _SYS_IPC_H */
diff --git a/winsup/cygwin/include/cygwin/msg.h b/winsup/cygwin/include/cygwin/msg.h
new file mode 100644
index 000000000..14e89f556
--- /dev/null
+++ b/winsup/cygwin/include/cygwin/msg.h
@@ -0,0 +1,92 @@
+/* sys/msg.h
+
+ 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. */
+
+#ifndef _SYS_MSG_H
+#define _SYS_MSG_H
+
+#include <cygwin/ipc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* Message operation flags:
+ */
+#define MSG_NOERROR 0x01 /* No error if big message. */
+
+/* Command definitions for the semctl () function:
+ */
+#define MSG_STAT 0x2000 /* For ipcs(8) */
+#define MSG_INFO 0x2001 /* For ipcs(8) */
+
+/* Used for the number of messages in the message queue.
+ */
+typedef long int msgqnum_t;
+
+/* Used for the number of bytes allowed in a message queue.
+ */
+typedef long int msglen_t;
+
+struct msqid_ds
+{
+ struct ipc_perm msg_perm; /* Operation permission structure. */
+ msglen_t msg_cbytes; /* Number of bytes currently on queue. */
+ msgqnum_t msg_qnum; /* Number of messages currently on queue. */
+ msglen_t msg_qbytes; /* Maximum number of bytes allowed on queue. */
+ pid_t msg_lspid; /* Process ID of last msgsnd (). */
+ pid_t msg_lrpid; /* Process ID of last msgrcv (). */
+ timestruc_t msg_stim; /* Time of last msgsnd (). */
+ timestruc_t msg_rtim; /* Time of last msgrcv (). */
+ timestruc_t msg_ctim; /* Time of last change. */
+ long msg_spare4[2];
+};
+
+#define msg_stime msg_stim.tv_sec
+#define msg_rtime msg_rtim.tv_sec
+#define msg_ctime msg_ctim.tv_sec
+
+/* Buffer type for msgctl (IPC_INFO, ...) as used by ipcs(8).
+ */
+struct msginfo
+{
+ unsigned long msgpool; /* Maximum number of message bytes,
+ system wide. */
+ unsigned long msgmax; /* Maximum number of bytes per
+ message. */
+ unsigned long msgmnb; /* Maximum number of bytes on any one
+ message queue. */
+ unsigned long msgmni; /* Maximum number of message queues,
+ system wide. */
+ unsigned long msgtql; /* Maximum number of messages, system
+ wide. */
+ unsigned long msg_spare[4];
+};
+
+/* Buffer type for msgctl (MSG_INFO, ...) as used by ipcs(8).
+ */
+struct msg_info
+{
+ unsigned long msg_ids; /* Number of allocated queues. */
+ unsigned long msg_num; /* Number of messages, system wide. */
+ unsigned long msg_tot; /* Size in bytes of messages, system wide. */
+};
+
+int msgctl (int msqid, int cmd, struct msqid_ds *buf);
+int msgget (key_t key, int msgflg);
+ssize_t msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
+int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_MSG_H */
diff --git a/winsup/cygwin/include/cygwin/sem.h b/winsup/cygwin/include/cygwin/sem.h
new file mode 100644
index 000000000..a3ece9f8a
--- /dev/null
+++ b/winsup/cygwin/include/cygwin/sem.h
@@ -0,0 +1,95 @@
+/* sys/sem.h
+
+ 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. */
+
+#ifndef _SYS_SEM_H
+#define _SYS_SEM_H
+
+#include <cygwin/ipc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* Semaphore operation flags:
+ */
+#define SEM_UNDO /* Set up adjust on exit entry. */
+
+/* Command definitions for the semctl () function:
+ */
+#define GETNCNT 0x3000 /* Get semncnt. */
+#define GETPID 0x3001 /* Get sempid. */
+#define GETVAL 0x3002 /* Get semval. */
+#define GETALL 0x3003 /* Get all cases of semval. */
+#define GETZCNT 0x3004 /* Get semzcnt. */
+#define SETVAL 0x3005 /* Set semval. */
+#define SETALL 0x3006 /* Set all cases of semval. */
+
+#define SEM_STAT 0x3010 /* For ipcs(8). */
+#define SEM_INFO 0x3011 /* For ipcs(8). */
+
+struct semid_ds
+{
+ struct ipc_perm sem_perm; /* Operation permission structure. */
+ unsigned short sem_nsems; /* Number of semaphores in set. */
+ timestruc_t sem_otim; /* Last semop () time. */
+ timestruc_t sem_ctim; /* Last time changed by semctl (). */
+ long sem_spare4[2];
+};
+
+#define sem_otime sem_otim.tv_sec
+#define sem_ctime sem_ctim.tv_sec
+
+struct sembuf
+{
+ unsigned short sem_num; /* Semaphore number. */
+ short sem_op; /* Semaphore operation. */
+ short sem_flg; /* Operation flags. */
+};
+
+/* Buffer type for semctl (IPC_INFO, ...) as used by ipcs(8).
+ */
+struct seminfo
+{
+ unsigned long semmni; /* Maximum number of unique semaphore
+ sets, system wide. */
+ unsigned long semmns; /* Maximum number of semaphores,
+ system wide. */
+ unsigned long semmsl; /* Maximum number of semaphores per
+ semaphore set. */
+ unsigned long semopm; /* Maximum number of operations per
+ semop call. */
+ unsigned long semmnu; /* Maximum number of undo structures,
+ system wide. */
+ unsigned long semume; /* Maximum number of undo entries per
+ undo structure. */
+ unsigned long semvmx; /* Maximum semaphore value. */
+ unsigned long semaem; /* Maximum adjust-on-exit value. */
+ unsigned long sem_spare[4];
+};
+
+/* Buffer type for semctl (SEM_INFO, ...) as used by ipcs(8).
+ */
+struct sem_info
+{
+ unsigned long sem_ids; /* Number of allocated semaphore sets. */
+ unsigned long sem_num; /* Number of allocated semaphores. */
+};
+
+int semctl (int semid, int semnum, int cmd, ...);
+int semget (key_t key, int nsems, int semflg);
+int semop (int semid, struct sembuf *sops, size_t nsops);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_SEM_H */
diff --git a/winsup/cygwin/include/cygwin/shm.h b/winsup/cygwin/include/cygwin/shm.h
index eb037ba19..b6b2d447c 100644
--- a/winsup/cygwin/include/cygwin/shm.h
+++ b/winsup/cygwin/include/cygwin/shm.h
@@ -1,6 +1,6 @@
/* sys/shm.h
- Copyright 2001 Red Hat Inc.
+ Copyright 2001, 2002 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com>
This file is part of Cygwin.
@@ -9,81 +9,86 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#ifndef _SYS_SHM_H
+#define _SYS_SHM_H
+
+#include <cygwin/ipc.h>
+
#ifdef __cplusplus
extern "C"
{
#endif
-#ifndef _SYS_SHM_H
-#define _SYS_SHM_H
-
-#include <cygwin/ipc.h>
+/* 64 Kb was hardcoded for x86. MS states this may change, but we need
+ * it in the header file.
+ */
+#define SHMLBA 65536 /* Segment low boundary address multiple. */
-#define SHM_RDONLY 1
-/* 64 Kb was hardcoded for x86. MS states this may change, but we need it in the header
- * file.
+/* Shared memory operation flags:
*/
-#define SHMLBA 65536
-#define SHM_RND 1
+#define SHM_RDONLY 0x01 /* Attach read-only (else read-write). */
+#define SHM_RND 0x02 /* Round attach address to SHMLBA. */
-typedef long int shmatt_t;
+/* Command definitions for the semctl () function:
+ */
+#define SHM_STAT 0x4000 /* For ipcs(8) */
+#define SHM_INFO 0x4001 /* For ipcs(8) */
-#if defined(__INSIDE_CYGWIN__) && defined(__cplusplus)
+/* Unsigned integer used for the number of current attaches.
+ */
+typedef unsigned int shmatt_t;
-class _shmattach {
-public:
- void *data;
- int shmflg;
- class _shmattach *next;
+struct shmid_ds
+{
+ struct ipc_perm shm_perm; /* Operation permission structure. */
+ size_t shm_segsz; /* Size of segment in bytes. */
+ pid_t shm_lpid; /* Process ID of last operation. */
+ pid_t shm_cpid; /* Process ID of creator. */
+ shmatt_t shm_nattch; /* Number of current attaches. */
+ timestruc_t shm_atim; /* Time of last shmat (). */
+ timestruc_t shm_dtim; /* Time of last shmdt (). */
+ timestruc_t shm_ctim; /* Time of last change by shmctl (). */
+ long shm_spare4[2];
};
-class shmid_ds {
-public:
- struct ipc_perm shm_perm;
- size_t shm_segsz;
- pid_t shm_lpid;
- pid_t shm_cpid;
- shmatt_t shm_nattch;
- time_t shm_atime;
- time_t shm_dtime;
- time_t shm_ctime;
- void *mapptr;
-};
+#define shm_atime shm_atim.tv_sec
+#define shm_dtime shm_dtim.tv_sec
+#define shm_ctime shm_ctim.tv_sec
-class shmnode {
-public:
- class shmid_ds * shmds;
- int shm_id;
- class shmnode *next;
- key_t key;
- HANDLE filemap;
- HANDLE attachmap;
- class _shmattach *attachhead;
+/* Buffer type for shmctl (IPC_INFO, ...) as used by ipcs(8).
+ */
+struct shminfo
+{
+ unsigned long shmmax; /* Maximum size in bytes of a shared
+ memory segment. */
+ unsigned long shmmin; /* Minimum size in bytes of a shared
+ memory segment. */
+ unsigned long shmmni; /* Maximum number of shared memory
+ segments, system wide. */
+ unsigned long shmseg; /* Maximum number of shared memory
+ segments attached per process. */
+ unsigned long shmall; /* Maximum number of bytes of shared
+ memory, system wide. */
+ unsigned long shm_spare[4];
};
-#else
-/* this is what we return when queried. It has no bitwise correspondence
- * the internal structures
+/* Buffer type for shmctl (SHM_INFO, ...) as used by ipcs(8).
*/
-struct shmid_ds {
- struct ipc_perm shm_perm;
- size_t shm_segsz;
- pid_t shm_lpid;
- pid_t shm_cpid;
- shmatt_t shm_nattch;
- time_t shm_atime;
- time_t shm_dtime;
- time_t shm_ctime;
+struct shm_info
+{
+ unsigned long shm_ids; /* Number of allocated segments. */
+ unsigned long shm_tot; /* Size in bytes of allocated segments. */
+ unsigned long shm_atts; /* Number of attached segments, system
+ wide. */
};
-#endif /* __INSIDE_CYGWIN__ */
-
-void *shmat(int, const void *, int);
-int shmctl(int, int, struct shmid_ds *);
-int shmdt(const void *);
-int shmget(key_t, size_t, int);
-#endif /* _SYS_SHM_H */
+void *shmat (int shmid, const void *shmaddr, int shmflg);
+int shmctl (int shmid, int cmd, struct shmid_ds *buf);
+int shmdt (const void *shmaddr);
+int shmget (key_t key, size_t size, int shmflg);
#ifdef __cplusplus
}
#endif
+
+#endif /* _SYS_SHM_H */