summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/cygserver_shm.h
blob: 80bbf84f05a8e57e99616129e541c19369bf083e (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
88
89
90
91
92
93
94
95
96
/* cygserver_shm.h: Single unix specification IPC interface for 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. */

#ifndef __CYGSERVER_SHM_H__
#define __CYGSERVER_SHM_H__

#include <sys/types.h>
#include <sys/sysproto.h>
#ifndef _KERNEL
#define _KERNEL 1
#endif
#include <cygwin/shm.h>

#include "cygserver.h"
#include "cygserver_ipc.h"

#ifndef __INSIDE_CYGWIN__
class transport_layer_base;
class process_cache;
#endif

class client_request_shm : public client_request
{
  friend class client_request;

public:
  enum shmop_t
    {
      SHMOP_shmat,
      SHMOP_shmctl,
      SHMOP_shmdt,
      SHMOP_shmget,
      SHMOP_shmfork	/* Called on fixup_after_fork */
    };

private:
  union
  {
    struct
    {
      shmop_t shmop;
      proc ipcblk;
      struct shmat_args  atargs;
      struct shmctl_args ctlargs;
      struct shmdt_args  dtargs;
      struct shmget_args getargs;
      struct proc        forkargs;
    } in;

    struct {
      union {
	int ret;
	vm_offset_t ptr;
      };
      vm_object_t obj;
    } out;
  } _parameters;

#ifndef __INSIDE_CYGWIN__
  client_request_shm ();
  virtual void serve (transport_layer_base *, process_cache *);
#endif

public:

#ifdef __INSIDE_CYGWIN__
  client_request_shm (int, const void *, int);		// shmat
  client_request_shm (int, int, struct shmid_ds *);	// shmctl
  client_request_shm (const void *);			// shmdt
  client_request_shm (key_t, size_t, int);		// shmget
  client_request_shm (proc *);				// shmfork
#endif

  int retval () const { return msglen () ? _parameters.out.ret : -1; }
  void *ptrval () const { return (void *)_parameters.out.ptr; }
  vm_object_t objval () const { return _parameters.out.obj; }
};

#ifndef __INSIDE_CYGWIN__
void shminit ();
int shmunload ();
void shmexit_myhook (struct vmspace *vm);
int cygwin_shmfork_myhook (struct thread *, struct proc *);

int shmat (struct thread *, struct shmat_args *);
int shmctl (struct thread *, struct shmctl_args *);
int shmdt (struct thread *, struct shmdt_args *);
int shmget (struct thread *, struct shmget_args *);
#endif

#endif /* __CYGSERVER_SHM_H__ */