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