File: spec_shm.h

package info (click to toggle)
pymca 5.1.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 40,004 kB
  • ctags: 17,800
  • sloc: python: 132,302; ansic: 20,016; cpp: 827; makefile: 48; sh: 30; xml: 24
file content (146 lines) | stat: -rw-r--r-- 5,250 bytes parent folder | download | duplicates (6)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/****************************************************************************
*   @(#)spec_shm.h	6.7  11/20/13 CSS
*
*   "spec" Release 6
*
*   Copyright (c) 1995-2010 Certified Scientific Software
*
*   The software contained in this file "spec_shm.h" describes the
*   shared-data structures used and defined by the CSS "spec" package.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
****************************************************************************/

#define SHM_MAGIC       0xCEBEC000

/*
*  Difference between SHM_VERSION 3 and 4 is the increase in
*  header size from 1024 to 4096 to put the data portion
*  on a memory page boundary.
*
*  Difference between SHM_VERSION 4 and 5 is the addition of
*  the SHM_IS_FRAMES tag and the frame_size and latest_frames
*  elements of the shm_head structure.
*
*  Difference between SHM_VERSION 5 and 6 is the addition of
*  metadata tail to data and info array to shm_head structure.
*/
#define SHM_VERSION     6

/* structure flags */
#define SHM_IS_STATUS   0x0001
#define SHM_IS_ARRAY    0x0002
#define SHM_IS_MASK     0x000F  /* User can't change these bits */
#define SHM_IS_MCA      0x0010
#define SHM_IS_IMAGE    0x0020
#define SHM_IS_SCAN     0x0040
#define SHM_IS_INFO     0x0080
#define SHM_IS_FRAMES   0x0100

/* array data types */
#define SHM_DOUBLE      0
#define SHM_FLOAT       1
#define SHM_LONG        2
#define SHM_ULONG       3
#define SHM_SHORT       4
#define SHM_USHORT      5
#define SHM_CHAR        6
#define SHM_UCHAR       7
#define SHM_STRING      8
#define SHM_LONG64      9
#define SHM_ULONG64     10

#define NAME_LENGTH     32
#define INFO_LENGTH     512

/*
*  The meta_length field is not defined by the standard.
*  However, spec will use the following size for the
*  shared arrays it creates.  Applications that use
*  the meta data should always check the meta_length
*  field and not rely on SHM_META_SIZE.
*/
#define SHM_META_SIZE   8192    /* size of metadata region added to tail of array */

#define SHM_OHEAD_SIZE  1024    /* Old header size */
#define SHM_HEAD_SIZE   4096    /* Header size puts data on page boundary */

#ifndef SPEC_TYPE_DEFS
typedef int     s32_t;
typedef unsigned int    u32_t;
typedef long long       s64_t;
typedef unsigned long long      u64_t;
#endif

struct  shm_head {
	u32_t   magic;                  /* magic number (SHM_MAGIC) */
	u32_t   type;                   /* one of the array data types */
	u32_t   version;                /* version number of this struct */
	u32_t   rows;                   /* number of rows of array data */
	u32_t   cols;                   /* number of cols of array data */
	u32_t   utime;                  /* last-updated counter */
	char    name[NAME_LENGTH];      /* name of spec variable */
	char    spec_version[NAME_LENGTH];      /* name of spec process */
	s32_t   shmid;                  /* shared mem ID */
	u32_t   flags;                  /* more type info */
	u32_t   pid;                    /* process id of spec process */
	/*
	*  A frame can be a single MCA acquisition or a single image.
	*  A 2D array can be considered a succession of MCA frames or
	*  a succession of images.  Since data is stored row-wise,
	*  frames are defined by a number of rows.
	*/
	u32_t   frame_size;             /* number of rows per frame */
	u32_t   latest_frame;           /* most recently updated frame */
	/*
	*  The metadata region added in SHM_VERSION 6 is located after
	*  the array data.  The meta_start element is the offset
	*  from the start of the shared segment.
	*/
	u32_t   meta_start;             /* byte offset to metadata tail */
	u32_t   meta_length;            /* byte length of metadata tail */
	char    pad[256];               /* space to expand */
	char    info[INFO_LENGTH];      /* arbitrary info */
};

#define SHM_MAX_IDS     256

struct  shm_status {
	u32_t    spec_state;
	u32_t    utime;                 /* updated when ids[] changes */
	s32_t    ids[SHM_MAX_IDS];      /* shm ids for shared arrays */
	/* more later */
};

struct shm_oheader {
	union {
		struct  shm_head head;
		char    pad[SHM_OHEAD_SIZE];
	} head;
	void    *data;
};

struct shm_header {
	union {
		struct  shm_head head;
		char    pad[SHM_HEAD_SIZE];
	} head;
	void    *data;
};