1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/include/sys/shm.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,180 @@
1.4 +/* $FreeBSD: src/sys/sys/shm.h,v 1.23 2005/04/02 12:33:36 das Exp $ */
1.5 +/* $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $ */
1.6 +
1.7 +/*-
1.8 + * Copyright (c) 1994 Adam Glass
1.9 + * All rights reserved.
1.10 + *
1.11 + * Redistribution and use in source and binary forms, with or without
1.12 + * modification, are permitted provided that the following conditions
1.13 + * are met:
1.14 + * 1. Redistributions of source code must retain the above copyright
1.15 + * notice, this list of conditions and the following disclaimer.
1.16 + * 2. Redistributions in binary form must reproduce the above copyright
1.17 + * notice, this list of conditions and the following disclaimer in the
1.18 + * documentation and/or other materials provided with the distribution.
1.19 + * 4. The name of the author may not be used to endorse or promote products
1.20 + * derived from this software without specific prior written permission
1.21 + *
1.22 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1.23 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1.24 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1.25 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1.26 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1.27 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1.28 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1.29 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1.30 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1.31 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.32 + *
1.33 + * Portions Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
1.34 + */
1.35 +
1.36 +/*
1.37 + * As defined+described in "X/Open System Interfaces and Headers"
1.38 + * Issue 4, p. XXX
1.39 + */
1.40 +
1.41 +#ifndef _SYS_SHM_H_
1.42 +#define _SYS_SHM_H_
1.43 +
1.44 +#include <sys/cdefs.h>
1.45 +#include <sys/ipc.h>
1.46 +#include <sys/_types.h>
1.47 +
1.48 +#define SHM_RDONLY 010000 /* Attach read-only (else read-write) */
1.49 +#define SHM_RND 020000 /* Round attach address to SHMLBA */
1.50 +#define SHMLBA PAGE_SIZE /* Segment low boundary address multiple */
1.51 +
1.52 +/* "official" access mode definitions; somewhat braindead since you have
1.53 + to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */
1.54 +#define SHM_R (IPC_R)
1.55 +#define SHM_W (IPC_W)
1.56 +
1.57 +/* predefine tbd *LOCK shmctl commands */
1.58 +#define SHM_LOCK 11
1.59 +#define SHM_UNLOCK 12
1.60 +
1.61 +/* ipcs shmctl commands */
1.62 +#define SHM_STAT 13
1.63 +#define SHM_INFO 14
1.64 +
1.65 +#ifndef _PID_T_DECLARED
1.66 +typedef __pid_t pid_t;
1.67 +#define _PID_T_DECLARED
1.68 +#endif
1.69 +
1.70 +#ifndef _TIME_T_DECLARED
1.71 +typedef __time_t time_t;
1.72 +#define _TIME_T_DECLARED
1.73 +#endif
1.74 +
1.75 +#ifndef _SIZE_T_DECLARED
1.76 +typedef __size_t size_t;
1.77 +#define _SIZE_T_DECLARED
1.78 +#endif
1.79 +
1.80 +struct shmid_ds {
1.81 + struct ipc_perm shm_perm; /* operation permission structure */
1.82 + int shm_segsz; /* size of segment in bytes */
1.83 + pid_t shm_lpid; /* process ID of last shared memory op */
1.84 + pid_t shm_cpid; /* process ID of creator */
1.85 + short shm_nattch; /* number of current attaches */
1.86 + time_t shm_atime; /* time of last shmat() */
1.87 + time_t shm_dtime; /* time of last shmdt() */
1.88 + time_t shm_ctime; /* time of last change by shmctl() */
1.89 + void *shm_internal; /* sysv stupidity */
1.90 +};
1.91 +
1.92 +#ifdef _KERNEL
1.93 +
1.94 +/*
1.95 + * System 5 style catch-all structure for shared memory constants that
1.96 + * might be of interest to user programs. Do we really want/need this?
1.97 + */
1.98 +struct shminfo {
1.99 + int shmmax, /* max shared memory segment size (bytes) */
1.100 + shmmin, /* min shared memory segment size (bytes) */
1.101 + shmmni, /* max number of shared memory identifiers */
1.102 + shmseg, /* max shared memory segments per process */
1.103 + shmall; /* max amount of shared memory (pages) */
1.104 +};
1.105 +
1.106 +/*
1.107 + * Add a kernel wrapper to the shmid_ds struct so that private info (like the
1.108 + * MAC label) can be added to it, without changing the user interface.
1.109 + */
1.110 +struct shmid_kernel {
1.111 + struct shmid_ds u;
1.112 + struct label *label; /* MAC label */
1.113 +};
1.114 +
1.115 +extern struct shminfo shminfo;
1.116 +
1.117 +struct shm_info {
1.118 + int used_ids;
1.119 + unsigned long shm_tot;
1.120 + unsigned long shm_rss;
1.121 + unsigned long shm_swp;
1.122 + unsigned long swap_attempts;
1.123 + unsigned long swap_successes;
1.124 +};
1.125 +
1.126 +struct thread;
1.127 +struct proc;
1.128 +struct vmspace;
1.129 +
1.130 +#else /* !_KERNEL */
1.131 +
1.132 +#include <sys/cdefs.h>
1.133 +
1.134 +#ifndef _SIZE_T_DECLARED
1.135 +typedef __size_t size_t;
1.136 +#define _SIZE_T_DECLARED
1.137 +#endif
1.138 +
1.139 +// FUNCTION PROTOTYPES
1.140 +
1.141 +
1.142 +// FORWARD DECLARATIONS
1.143 +
1.144 +
1.145 +// CLASS/STRUCT/FUNCTION DECLARATION
1.146 +__BEGIN_DECLS
1.147 +/*
1.148 +* Get shared memory identifier using the IPC key generated by ftok.
1.149 +*/
1.150 +
1.151 +IMPORT_C int shmget(key_t key, int size, int shmflg);
1.152 +
1.153 +
1.154 +/*
1.155 +* Attaches the shared memory segment associated with the shared memory identifier
1.156 +* specified by shmid to the address space of the calling process.
1.157 +*/
1.158 +
1.159 +IMPORT_C void* shmat(int shmid, const void *shmaddr, int shmflg);
1.160 +
1.161 +
1.162 +/*
1.163 +* Detaches the shared memory segment located at the address specified by shmaddr
1.164 +* from the address space of the calling process.
1.165 +*/
1.166 +
1.167 +IMPORT_C int shmdt(const void *shmaddr);
1.168 +
1.169 +
1.170 +/*
1.171 +* Provides a variety of shared memory control operations as specified by cmd.
1.172 +*/
1.173 +
1.174 +IMPORT_C int shmctl(int shmid, int cmd, struct shmid_ds *buf);
1.175 +
1.176 +
1.177 +__END_DECLS
1.178 +
1.179 +#endif /* !_KERNEL */
1.180 +
1.181 +#endif // SHM_H
1.182 +
1.183 +// End of File