[BACK]Return to shm.h CVS log [TXT][DIR] Up to [local] / sys / sys

Annotation of sys/sys/shm.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: shm.h,v 1.21 2007/05/29 10:44:28 sturm Exp $  */
                      2: /*     $NetBSD: shm.h,v 1.20 1996/04/09 20:55:35 cgd Exp $     */
                      3:
                      4: /*
                      5:  * Copyright (c) 1994 Adam Glass
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *      This product includes software developed by Adam Glass.
                     19:  * 4. The name of the author may not be used to endorse or promote products
                     20:  *    derived from this software without specific prior written permission
                     21:  *
                     22:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     23:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     24:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     25:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     26:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     27:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     28:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     29:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     30:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     31:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     32:  */
                     33:
                     34: /*
                     35:  * As defined+described in "X/Open System Interfaces and Headers"
                     36:  *                         Issue 4, p. XXX
                     37:  */
                     38:
                     39: #ifndef _SYS_SHM_H_
                     40: #define _SYS_SHM_H_
                     41:
                     42: #include <sys/cdefs.h>
                     43: #ifndef _SYS_IPC_H_
                     44: #include <sys/ipc.h>
                     45: #endif
                     46:
                     47: #if __BSD_VISIBLE
                     48:
                     49: /* shm-specific sysctl variables corresponding to members of struct shminfo */
                     50: #define KERN_SHMINFO_SHMMAX    1       /* int: max shm segment size (bytes) */
                     51: #define KERN_SHMINFO_SHMMIN    2       /* int: min shm segment size (bytes) */
                     52: #define KERN_SHMINFO_SHMMNI    3       /* int: max number of shm identifiers */
                     53: #define KERN_SHMINFO_SHMSEG    4       /* int: max shm segments per process */
                     54: #define KERN_SHMINFO_SHMALL    5       /* int: max amount of shm (pages) */
                     55: #define KERN_SHMINFO_MAXID     6       /* number of valid shared memory ids */
                     56:
                     57: #define CTL_KERN_SHMINFO_NAMES { \
                     58:        { 0, 0 }, \
                     59:        { "shmmax", CTLTYPE_INT }, \
                     60:        { "shmmin", CTLTYPE_INT }, \
                     61:        { "shmmni", CTLTYPE_INT }, \
                     62:        { "shmseg", CTLTYPE_INT }, \
                     63:        { "shmall", CTLTYPE_INT }, \
                     64: }
                     65:
                     66: /*
                     67:  * Old (deprecated) access mode definitions--do not use.
                     68:  * Provided for compatibility with old code only.
                     69:  */
                     70: #define SHM_R          IPC_R
                     71: #define SHM_W          IPC_W
                     72:
                     73: #endif /* __BSD_VISIBLE */
                     74:
                     75: /*
                     76:  * Shared memory operation flags for shmat(2).
                     77:  */
                     78: #define        SHM_RDONLY      010000  /* Attach read-only (else read-write) */
                     79: #define        SHM_RND         020000  /* Round attach address to SHMLBA */
                     80: #ifdef _KERNEL
                     81: #define        _SHM_RMLINGER   040000  /* Attach even if segment removed */
                     82: #endif
                     83:
                     84: /*
                     85:  * Shared memory specific control commands for shmctl().
                     86:  * We accept but ignore these (XXX).
                     87:  */
                     88: #define        SHM_LOCK        3       /* Lock segment in memory. */
                     89: #define        SHM_UNLOCK      4       /* Unlock a segment locked by SHM_LOCK. */
                     90:
                     91: /*
                     92:  * Segment low boundry address multiple
                     93:  * Use PAGE_SIZE for kernel but for userland query the kernel for the value.
                     94:  */
                     95: #if defined(_KERNEL) || defined(_STANDALONE) || defined(_LKM)
                     96: #define        SHMLBA          PAGE_SIZE
                     97: #else
                     98: #define        SHMLBA          (getpagesize())
                     99: #endif /* _KERNEL || _STANDALONE || _LKM */
                    100:
                    101: typedef short          shmatt_t;
                    102:
                    103: struct shmid_ds {
                    104:        struct ipc_perm shm_perm;       /* operation permission structure */
                    105:        int             shm_segsz;      /* size of segment in bytes */
                    106:        pid_t           shm_lpid;       /* process ID of last shm op */
                    107:        pid_t           shm_cpid;       /* process ID of creator */
                    108:        shmatt_t        shm_nattch;     /* number of current attaches */
                    109:        time_t          shm_atime;      /* time of last shmat() */
                    110:        time_t          shm_dtime;      /* time of last shmdt() */
                    111:        time_t          shm_ctime;      /* time of last change by shmctl() */
                    112:        void            *shm_internal;  /* implementation specific data */
                    113: };
                    114:
                    115: #ifdef _KERNEL
                    116: struct shmid_ds23 {
                    117:        struct ipc_perm23 shm_perm;     /* operation permission structure */
                    118:        int             shm_segsz;      /* size of segment in bytes */
                    119:        pid_t           shm_lpid;       /* process ID of last shm op */
                    120:        pid_t           shm_cpid;       /* process ID of creator */
                    121:        shmatt_t        shm_nattch;     /* number of current attaches */
                    122:        time_t          shm_atime;      /* time of last shmat() */
                    123:        time_t          shm_dtime;      /* time of last shmdt() */
                    124:        time_t          shm_ctime;      /* time of last change by shmctl() */
                    125:        void            *shm_internal;  /* implementation specific data */
                    126: };
                    127:
                    128: struct shmid_ds35 {
                    129:        struct ipc_perm35 shm_perm;     /* operation permission structure */
                    130:        int               shm_segsz;    /* size of segment in bytes */
                    131:        pid_t             shm_lpid;     /* process ID of last shm op */
                    132:        pid_t             shm_cpid;     /* process ID of creator */
                    133:        shmatt_t          shm_nattch;   /* number of current attaches */
                    134:        time_t            shm_atime;    /* time of last shmat() */
                    135:        time_t            shm_dtime;    /* time of last shmdt() */
                    136:        time_t            shm_ctime;    /* time of last change by shmctl() */
                    137:        void              *shm_internal;/* implementation specific data */
                    138: };
                    139: #endif
                    140:
                    141: #if __BSD_VISIBLE
                    142: /*
                    143:  * System V style catch-all structure for shared memory constants that
                    144:  * might be of interest to user programs.  Do we really want/need this?
                    145:  */
                    146: struct shminfo {
                    147:        int     shmmax;         /* max shared memory segment size (bytes) */
                    148:        int     shmmin;         /* min shared memory segment size (bytes) */
                    149:        int     shmmni;         /* max number of shared memory identifiers */
                    150:        int     shmseg;         /* max shared memory segments per process */
                    151:        int     shmall;         /* max amount of shared memory (pages) */
                    152: };
                    153:
                    154: struct shm_sysctl_info {
                    155:        struct  shminfo shminfo;
                    156:        struct  shmid_ds shmids[1];
                    157: };
                    158: #endif /* __BSD_VISIBLE */
                    159:
                    160: #ifdef _KERNEL
                    161: extern struct shminfo shminfo;
                    162: extern struct shmid_ds **shmsegs;
                    163:
                    164: /* initial values for machdep.c */
                    165: extern int shmseg;
                    166: extern int shmmaxpgs;
                    167:
                    168: struct proc;
                    169: struct vmspace;
                    170:
                    171: void   shminit(void);
                    172: void   shmfork(struct vmspace *, struct vmspace *);
                    173: void   shmexit(struct vmspace *);
                    174: int    sysctl_sysvshm(int *, u_int, void *, size_t *, void *, size_t);
                    175: int    shmctl1(struct proc *, int, int, caddr_t,
                    176:            int (*)(const void *, void *, size_t),
                    177:            int (*)(const void *, void *, size_t));
                    178:
                    179: #else /* !_KERNEL */
                    180:
                    181: __BEGIN_DECLS
                    182: void *shmat(int, const void *, int);
                    183: int shmctl(int, int, struct shmid_ds *);
                    184: int shmdt(const void *);
                    185: int shmget(key_t, size_t, int);
                    186: __END_DECLS
                    187:
                    188: #endif /* !_KERNEL */
                    189:
                    190: #endif /* !_SYS_SHM_H_ */

CVSweb