summaryrefslogtreecommitdiff
path: root/winsup/cygwin/cygserver_shm.h
blob: a8b7dd2a6bccfc35449362b7c3310f2de1b48c9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* cygserver_shm.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. */

#include <sys/types.h>
#include <sys/shm.h>

#include "threaded_queue.h"
#include "cygwin/cygserver_process.h"
#include "cygwin/cygserver_transport.h"
#include "cygwin/cygserver.h"

/* Values for the client_request_shm::parameters.in.type field. */
#define SHM_CREATE   0
#define SHM_REATTACH 1
#define SHM_ATTACH   2
#define SHM_DETACH   3
#define SHM_DEL      4

struct _shmattach
{
  void *data;
  int shmflg;
  struct _shmattach *next;
};

struct int_shmid_ds
{
  struct shmid_ds ds;
  void *mapptr;
};

struct shmnode
{
  struct int_shmid_ds *shmds;
  int shm_id;
  struct shmnode *next;
  key_t key;
  HANDLE filemap;
  HANDLE attachmap;
  struct _shmattach *attachhead;
};

class client_request_shm : public client_request
{
public:
#ifdef __INSIDE_CYGWIN__
  client_request_shm (key_t ntype, size_t nsize, int shmflg);
  client_request_shm (int ntype, int nshmid);
#else
  client_request_shm ();
#endif

  union
  {
    struct
    {
      int type;
      pid_t cygpid;
      DWORD winpid;
      int shm_id;
      key_t key;
      size_t size;
      int shmflg;
      char sd_buf[4096];	// Must be the last item (variable length).
    } in;
    struct
    {
      int shm_id;
      HANDLE filemap;
      HANDLE attachmap;
      key_t key;
    } out;
  } parameters;

private:
#ifndef __INSIDE_CYGWIN__
  virtual void serve (transport_layer_base *, process_cache *);
#endif
};