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