The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/shm.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $OpenBSD: shm.h,v 1.30 2021/03/10 10:21:47 jsg 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 #ifndef _SYS_IPC_H_
   43 #include <sys/ipc.h>
   44 #endif
   45 
   46 #if __BSD_VISIBLE
   47 
   48 /* shm-specific sysctl variables corresponding to members of struct shminfo */
   49 #define KERN_SHMINFO_SHMMAX     1       /* int: max shm segment size (bytes) */
   50 #define KERN_SHMINFO_SHMMIN     2       /* int: min shm segment size (bytes) */
   51 #define KERN_SHMINFO_SHMMNI     3       /* int: max number of shm identifiers */
   52 #define KERN_SHMINFO_SHMSEG     4       /* int: max shm segments per process */
   53 #define KERN_SHMINFO_SHMALL     5       /* int: max amount of shm (pages) */
   54 #define KERN_SHMINFO_MAXID      6       /* number of valid shared memory ids */
   55 
   56 #define CTL_KERN_SHMINFO_NAMES { \
   57         { 0, 0 }, \
   58         { "shmmax", CTLTYPE_INT }, \
   59         { "shmmin", CTLTYPE_INT }, \
   60         { "shmmni", CTLTYPE_INT }, \
   61         { "shmseg", CTLTYPE_INT }, \
   62         { "shmall", CTLTYPE_INT }, \
   63 }
   64 
   65 /*
   66  * Old (deprecated) access mode definitions--do not use.
   67  * Provided for compatibility with old code only.
   68  */
   69 #define SHM_R           IPC_R
   70 #define SHM_W           IPC_W
   71 
   72 #endif /* __BSD_VISIBLE */
   73 
   74 /*
   75  * Shared memory operation flags for shmat(2).
   76  */
   77 #define SHM_RDONLY      010000  /* Attach read-only (else read-write) */
   78 #define SHM_RND         020000  /* Round attach address to SHMLBA */
   79 
   80 /*
   81  * Shared memory specific control commands for shmctl().
   82  * We accept but ignore these (XXX).
   83  */
   84 #define SHM_LOCK        3       /* Lock segment in memory. */
   85 #define SHM_UNLOCK      4       /* Unlock a segment locked by SHM_LOCK. */
   86 
   87 /*
   88  * Segment low boundary address multiple
   89  */
   90 #define SHMLBA          (1U << _MAX_PAGE_SHIFT)
   91 
   92 typedef short           shmatt_t;
   93 
   94 struct shmid_ds {
   95         struct ipc_perm shm_perm;       /* operation permission structure */
   96         int             shm_segsz;      /* size of segment in bytes */
   97         pid_t           shm_lpid;       /* process ID of last shm op */
   98         pid_t           shm_cpid;       /* process ID of creator */
   99         shmatt_t        shm_nattch;     /* number of current attaches */
  100         time_t          shm_atime;      /* time of last shmat() */
  101         long            __shm_atimensec;
  102         time_t          shm_dtime;      /* time of last shmdt() */
  103         long            __shm_dtimensec;
  104         time_t          shm_ctime;      /* time of last change by shmctl() */
  105         long            __shm_ctimensec;
  106         void            *shm_internal;  /* implementation specific data */
  107 };
  108 
  109 #if __BSD_VISIBLE
  110 /*
  111  * System V style catch-all structure for shared memory constants that
  112  * might be of interest to user programs.  Do we really want/need this?
  113  */
  114 struct shminfo {
  115         int     shmmax;         /* max shared memory segment size (bytes) */
  116         int     shmmin;         /* min shared memory segment size (bytes) */
  117         int     shmmni;         /* max number of shared memory identifiers */
  118         int     shmseg;         /* max shared memory segments per process */
  119         int     shmall;         /* max amount of shared memory (pages) */
  120 };
  121 
  122 struct shm_sysctl_info {
  123         struct  shminfo shminfo;
  124         struct  shmid_ds shmids[1];
  125 };
  126 #endif /* __BSD_VISIBLE */
  127 
  128 #ifdef _KERNEL
  129 extern struct shminfo shminfo;
  130 extern struct shmid_ds **shmsegs;
  131 
  132 struct proc;
  133 struct vmspace;
  134 
  135 void    shminit(void);
  136 void    shmfork(struct vmspace *, struct vmspace *);
  137 void    shmexit(struct vmspace *);
  138 int     sysctl_sysvshm(int *, u_int, void *, size_t *, void *, size_t);
  139 
  140 #else /* !_KERNEL */
  141 
  142 __BEGIN_DECLS
  143 void *shmat(int, const void *, int);
  144 int shmctl(int, int, struct shmid_ds *);
  145 int shmdt(const void *);
  146 int shmget(key_t, size_t, int);
  147 __END_DECLS
  148 
  149 #endif /* !_KERNEL */
  150 
  151 #endif /* !_SYS_SHM_H_ */

Cache object: f1918e9793f1853921335db21301d00e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.