sl@0: /* $FreeBSD: src/sys/sys/shm.h,v 1.23 2005/04/02 12:33:36 das Exp $ */ sl@0: /* $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $ */ sl@0: sl@0: /*- sl@0: * Copyright (c) 1994 Adam Glass sl@0: * All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * 4. The name of the author may not be used to endorse or promote products sl@0: * derived from this software without specific prior written permission sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR sl@0: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES sl@0: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. sl@0: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, sl@0: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT sl@0: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, sl@0: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY sl@0: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT sl@0: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF sl@0: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sl@0: * sl@0: * Portions Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). sl@0: */ sl@0: sl@0: /* sl@0: * As defined+described in "X/Open System Interfaces and Headers" sl@0: * Issue 4, p. XXX sl@0: */ sl@0: sl@0: #ifndef _SYS_SHM_H_ sl@0: #define _SYS_SHM_H_ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #define SHM_RDONLY 010000 /* Attach read-only (else read-write) */ sl@0: #define SHM_RND 020000 /* Round attach address to SHMLBA */ sl@0: #define SHMLBA PAGE_SIZE /* Segment low boundary address multiple */ sl@0: sl@0: /* "official" access mode definitions; somewhat braindead since you have sl@0: to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */ sl@0: #define SHM_R (IPC_R) sl@0: #define SHM_W (IPC_W) sl@0: sl@0: /* predefine tbd *LOCK shmctl commands */ sl@0: #define SHM_LOCK 11 sl@0: #define SHM_UNLOCK 12 sl@0: sl@0: /* ipcs shmctl commands */ sl@0: #define SHM_STAT 13 sl@0: #define SHM_INFO 14 sl@0: sl@0: #ifndef _PID_T_DECLARED sl@0: typedef __pid_t pid_t; sl@0: #define _PID_T_DECLARED sl@0: #endif sl@0: sl@0: #ifndef _TIME_T_DECLARED sl@0: typedef __time_t time_t; sl@0: #define _TIME_T_DECLARED sl@0: #endif sl@0: sl@0: #ifndef _SIZE_T_DECLARED sl@0: typedef __size_t size_t; sl@0: #define _SIZE_T_DECLARED sl@0: #endif sl@0: sl@0: struct shmid_ds { sl@0: struct ipc_perm shm_perm; /* operation permission structure */ sl@0: int shm_segsz; /* size of segment in bytes */ sl@0: pid_t shm_lpid; /* process ID of last shared memory op */ sl@0: pid_t shm_cpid; /* process ID of creator */ sl@0: short shm_nattch; /* number of current attaches */ sl@0: time_t shm_atime; /* time of last shmat() */ sl@0: time_t shm_dtime; /* time of last shmdt() */ sl@0: time_t shm_ctime; /* time of last change by shmctl() */ sl@0: void *shm_internal; /* sysv stupidity */ sl@0: }; sl@0: sl@0: #ifdef _KERNEL sl@0: sl@0: /* sl@0: * System 5 style catch-all structure for shared memory constants that sl@0: * might be of interest to user programs. Do we really want/need this? sl@0: */ sl@0: struct shminfo { sl@0: int shmmax, /* max shared memory segment size (bytes) */ sl@0: shmmin, /* min shared memory segment size (bytes) */ sl@0: shmmni, /* max number of shared memory identifiers */ sl@0: shmseg, /* max shared memory segments per process */ sl@0: shmall; /* max amount of shared memory (pages) */ sl@0: }; sl@0: sl@0: /* sl@0: * Add a kernel wrapper to the shmid_ds struct so that private info (like the sl@0: * MAC label) can be added to it, without changing the user interface. sl@0: */ sl@0: struct shmid_kernel { sl@0: struct shmid_ds u; sl@0: struct label *label; /* MAC label */ sl@0: }; sl@0: sl@0: extern struct shminfo shminfo; sl@0: sl@0: struct shm_info { sl@0: int used_ids; sl@0: unsigned long shm_tot; sl@0: unsigned long shm_rss; sl@0: unsigned long shm_swp; sl@0: unsigned long swap_attempts; sl@0: unsigned long swap_successes; sl@0: }; sl@0: sl@0: struct thread; sl@0: struct proc; sl@0: struct vmspace; sl@0: sl@0: #else /* !_KERNEL */ sl@0: sl@0: #include sl@0: sl@0: #ifndef _SIZE_T_DECLARED sl@0: typedef __size_t size_t; sl@0: #define _SIZE_T_DECLARED sl@0: #endif sl@0: sl@0: // FUNCTION PROTOTYPES sl@0: sl@0: sl@0: // FORWARD DECLARATIONS sl@0: sl@0: sl@0: // CLASS/STRUCT/FUNCTION DECLARATION sl@0: __BEGIN_DECLS sl@0: /* sl@0: * Get shared memory identifier using the IPC key generated by ftok. sl@0: */ sl@0: sl@0: IMPORT_C int shmget(key_t key, int size, int shmflg); sl@0: sl@0: sl@0: /* sl@0: * Attaches the shared memory segment associated with the shared memory identifier sl@0: * specified by shmid to the address space of the calling process. sl@0: */ sl@0: sl@0: IMPORT_C void* shmat(int shmid, const void *shmaddr, int shmflg); sl@0: sl@0: sl@0: /* sl@0: * Detaches the shared memory segment located at the address specified by shmaddr sl@0: * from the address space of the calling process. sl@0: */ sl@0: sl@0: IMPORT_C int shmdt(const void *shmaddr); sl@0: sl@0: sl@0: /* sl@0: * Provides a variety of shared memory control operations as specified by cmd. sl@0: */ sl@0: sl@0: IMPORT_C int shmctl(int shmid, int cmd, struct shmid_ds *buf); sl@0: sl@0: sl@0: __END_DECLS sl@0: sl@0: #endif /* !_KERNEL */ sl@0: sl@0: #endif // SHM_H sl@0: sl@0: // End of File