epoc32/include/stdapis/sys/shm.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/* $FreeBSD: src/sys/sys/shm.h,v 1.23 2005/04/02 12:33:36 das Exp $ */
williamr@2
     2
/*	$NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $	*/
williamr@2
     3
williamr@2
     4
/*-
williamr@2
     5
 * Copyright (c) 1994 Adam Glass
williamr@2
     6
 *© Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
williamr@2
     7
 *© Portions copyright (c) 2006 Symbian Software Ltd. All rights reserved.
williamr@2
     8
 * All rights reserved.
williamr@2
     9
 *
williamr@2
    10
 * Redistribution and use in source and binary forms, with or without
williamr@2
    11
 * modification, are permitted provided that the following conditions
williamr@2
    12
 * are met:
williamr@2
    13
 * 1. Redistributions of source code must retain the above copyright
williamr@2
    14
 *    notice, this list of conditions and the following disclaimer.
williamr@2
    15
 * 2. Redistributions in binary form must reproduce the above copyright
williamr@2
    16
 *    notice, this list of conditions and the following disclaimer in the
williamr@2
    17
 *    documentation and/or other materials provided with the distribution.
williamr@2
    18
 * 4. The name of the author may not be used to endorse or promote products
williamr@2
    19
 *    derived from this software without specific prior written permission
williamr@2
    20
 *
williamr@2
    21
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
williamr@2
    22
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
williamr@2
    23
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
williamr@2
    24
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
williamr@2
    25
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
williamr@2
    26
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
williamr@2
    27
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
williamr@2
    28
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
williamr@2
    29
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
williamr@2
    30
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
williamr@2
    31
 */
williamr@2
    32
williamr@2
    33
/*
williamr@2
    34
 * As defined+described in "X/Open System Interfaces and Headers"
williamr@2
    35
 *                         Issue 4, p. XXX
williamr@2
    36
 */
williamr@2
    37
williamr@2
    38
#ifndef _SYS_SHM_H_
williamr@2
    39
#define _SYS_SHM_H_
williamr@2
    40
williamr@2
    41
#include <sys/cdefs.h>
williamr@2
    42
#include <sys/ipc.h>
williamr@2
    43
#include <sys/_types.h>
williamr@2
    44
williamr@2
    45
#define SHM_RDONLY  010000  /* Attach read-only (else read-write) */
williamr@2
    46
#define SHM_RND     020000  /* Round attach address to SHMLBA */
williamr@2
    47
#define SHMLBA      PAGE_SIZE /* Segment low boundary address multiple */
williamr@2
    48
williamr@2
    49
/* "official" access mode definitions; somewhat braindead since you have
williamr@2
    50
   to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */
williamr@2
    51
#define SHM_R       (IPC_R)
williamr@2
    52
#define SHM_W       (IPC_W)
williamr@2
    53
williamr@2
    54
/* predefine tbd *LOCK shmctl commands */
williamr@2
    55
#define	SHM_LOCK	11
williamr@2
    56
#define	SHM_UNLOCK	12
williamr@2
    57
williamr@2
    58
/* ipcs shmctl commands */
williamr@2
    59
#define	SHM_STAT	13
williamr@2
    60
#define	SHM_INFO	14
williamr@2
    61
williamr@2
    62
#ifndef _PID_T_DECLARED
williamr@2
    63
typedef	__pid_t		pid_t;
williamr@2
    64
#define	_PID_T_DECLARED
williamr@2
    65
#endif
williamr@2
    66
williamr@2
    67
#ifndef _TIME_T_DECLARED
williamr@2
    68
typedef	__time_t	time_t;
williamr@2
    69
#define	_TIME_T_DECLARED
williamr@2
    70
#endif
williamr@2
    71
williamr@2
    72
#ifndef _SIZE_T_DECLARED
williamr@2
    73
typedef	__size_t	size_t;
williamr@2
    74
#define	_SIZE_T_DECLARED
williamr@2
    75
#endif
williamr@2
    76
williamr@2
    77
struct shmid_ds {
williamr@2
    78
	struct ipc_perm shm_perm;	/* operation permission structure */
williamr@2
    79
	int             shm_segsz;	/* size of segment in bytes */
williamr@2
    80
	pid_t           shm_lpid;   /* process ID of last shared memory op */
williamr@2
    81
	pid_t           shm_cpid;	/* process ID of creator */
williamr@2
    82
	short		shm_nattch;	/* number of current attaches */
williamr@2
    83
	time_t          shm_atime;	/* time of last shmat() */
williamr@2
    84
	time_t          shm_dtime;	/* time of last shmdt() */
williamr@2
    85
	time_t          shm_ctime;	/* time of last change by shmctl() */
williamr@2
    86
	void           *shm_internal;   /* sysv stupidity */
williamr@2
    87
};
williamr@2
    88
williamr@2
    89
#ifdef _KERNEL
williamr@2
    90
williamr@2
    91
/*
williamr@2
    92
 * System 5 style catch-all structure for shared memory constants that
williamr@2
    93
 * might be of interest to user programs.  Do we really want/need this?
williamr@2
    94
 */
williamr@2
    95
struct shminfo {
williamr@2
    96
	int	shmmax,		/* max shared memory segment size (bytes) */
williamr@2
    97
		shmmin,		/* min shared memory segment size (bytes) */
williamr@2
    98
		shmmni,		/* max number of shared memory identifiers */
williamr@2
    99
		shmseg,		/* max shared memory segments per process */
williamr@2
   100
		shmall;		/* max amount of shared memory (pages) */
williamr@2
   101
};
williamr@2
   102
williamr@2
   103
/* 
williamr@2
   104
 * Add a kernel wrapper to the shmid_ds struct so that private info (like the
williamr@2
   105
 * MAC label) can be added to it, without changing the user interface.
williamr@2
   106
 */
williamr@2
   107
struct shmid_kernel {
williamr@2
   108
	struct shmid_ds u;
williamr@2
   109
	struct label *label;	/* MAC label */
williamr@2
   110
};
williamr@2
   111
williamr@2
   112
extern struct shminfo	shminfo;
williamr@2
   113
williamr@2
   114
struct shm_info {
williamr@2
   115
	int used_ids;
williamr@2
   116
	unsigned long shm_tot;
williamr@2
   117
	unsigned long shm_rss;
williamr@2
   118
	unsigned long shm_swp;
williamr@2
   119
	unsigned long swap_attempts;
williamr@2
   120
	unsigned long swap_successes;
williamr@2
   121
};
williamr@2
   122
williamr@2
   123
struct thread;
williamr@2
   124
struct proc;
williamr@2
   125
struct vmspace;
williamr@2
   126
williamr@2
   127
#else /* !_KERNEL */
williamr@2
   128
williamr@2
   129
#include <sys/cdefs.h>
williamr@2
   130
williamr@2
   131
#ifndef _SIZE_T_DECLARED
williamr@2
   132
typedef __size_t        size_t;
williamr@2
   133
#define _SIZE_T_DECLARED
williamr@2
   134
#endif
williamr@2
   135
williamr@2
   136
// FUNCTION PROTOTYPES
williamr@2
   137
williamr@2
   138
williamr@2
   139
// FORWARD DECLARATIONS
williamr@2
   140
williamr@2
   141
williamr@2
   142
// CLASS/STRUCT/FUNCTION DECLARATION
williamr@2
   143
__BEGIN_DECLS
williamr@2
   144
/*
williamr@2
   145
* Get shared memory identifier using the IPC key generated by ftok.
williamr@2
   146
*/
williamr@2
   147
williamr@2
   148
IMPORT_C int shmget(key_t key, int size, int shmflg);
williamr@2
   149
williamr@2
   150
williamr@2
   151
/*
williamr@2
   152
* Attaches the shared memory segment associated with the shared memory identifier 
williamr@2
   153
* specified by shmid to the address space of the calling process.
williamr@2
   154
*/
williamr@2
   155
williamr@2
   156
IMPORT_C void* shmat(int shmid, const void *shmaddr, int shmflg);
williamr@2
   157
williamr@2
   158
williamr@2
   159
/*
williamr@2
   160
* Detaches the shared memory segment located at the address specified by shmaddr 
williamr@2
   161
* from the address space of the calling process.
williamr@2
   162
*/
williamr@2
   163
williamr@2
   164
IMPORT_C int shmdt(const void *shmaddr);
williamr@2
   165
williamr@2
   166
williamr@2
   167
/*
williamr@2
   168
* Provides a variety of shared memory control operations as specified by cmd.
williamr@2
   169
*/
williamr@2
   170
williamr@2
   171
IMPORT_C int shmctl(int shmid, int cmd, struct shmid_ds *buf);
williamr@2
   172
williamr@2
   173
williamr@2
   174
__END_DECLS
williamr@2
   175
williamr@2
   176
#endif /* !_KERNEL */
williamr@2
   177
williamr@2
   178
#endif // SHM_H
williamr@2
   179
williamr@2
   180
//  End of File