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 /*      $NetBSD: shm.h,v 1.35.2.1 2004/10/04 05:19:13 jmc Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
    9  * NASA Ames Research Center.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. All advertising materials mentioning features or use of this software
   20  *    must display the following acknowledgement:
   21  *      This product includes software developed by the NetBSD
   22  *      Foundation, Inc. and its contributors.
   23  * 4. Neither the name of The NetBSD Foundation nor the names of its
   24  *    contributors may be used to endorse or promote products derived
   25  *    from this software without specific prior written permission.
   26  *
   27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 /*
   41  * Copyright (c) 1994 Adam Glass
   42  * All rights reserved.
   43  *
   44  * Redistribution and use in source and binary forms, with or without
   45  * modification, are permitted provided that the following conditions
   46  * are met:
   47  * 1. Redistributions of source code must retain the above copyright
   48  *    notice, this list of conditions and the following disclaimer.
   49  * 2. Redistributions in binary form must reproduce the above copyright
   50  *    notice, this list of conditions and the following disclaimer in the
   51  *    documentation and/or other materials provided with the distribution.
   52  * 3. All advertising materials mentioning features or use of this software
   53  *    must display the following acknowledgement:
   54  *      This product includes software developed by Adam Glass.
   55  * 4. The name of the author may not be used to endorse or promote products
   56  *    derived from this software without specific prior written permission
   57  *
   58  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   59  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   60  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   61  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   62  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   63  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   64  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   65  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   66  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   67  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   68  */
   69 
   70 /*
   71  * As defined+described in "X/Open System Interfaces and Headers"
   72  *                         Issue 4, p. XXX
   73  */
   74 
   75 #ifndef _SYS_SHM_H_
   76 #define _SYS_SHM_H_
   77 
   78 #include <sys/cdefs.h>
   79 #include <sys/featuretest.h>
   80 
   81 #include <sys/ipc.h>
   82 
   83 #define SHM_RDONLY      010000  /* Attach read-only (else read-write) */
   84 #define SHM_RND         020000  /* Round attach address to SHMLBA */
   85 #ifdef _KERNEL
   86 #define _SHM_RMLINGER   040000  /* Attach even if segment removed */
   87 #endif
   88 
   89 /* Segment low boundry address multiple */
   90 #if defined(_KERNEL) || defined(_STANDALONE) || defined(_LKM)
   91 #define SHMLBA          PAGE_SIZE
   92 #else
   93 /*
   94  * SHMLBA uses libc's internal __sysconf() to retrieve the machine's
   95  * page size. The value of _SC_PAGESIZE is 28 -- we hard code it so we do not
   96  * need to include unistd.h
   97  */
   98 __BEGIN_DECLS
   99 long __sysconf __P((int));
  100 __END_DECLS
  101 #define SHMLBA          (__sysconf(28))
  102 #endif
  103 
  104 typedef unsigned int    shmatt_t;
  105 
  106 struct shmid_ds {
  107         struct ipc_perm shm_perm;       /* operation permission structure */
  108         size_t          shm_segsz;      /* size of segment in bytes */
  109         pid_t           shm_lpid;       /* process ID of last shm operation */
  110         pid_t           shm_cpid;       /* process ID of creator */
  111         shmatt_t        shm_nattch;     /* number of current attaches */
  112         time_t          shm_atime;      /* time of last shmat() */
  113         time_t          shm_dtime;      /* time of last shmdt() */
  114         time_t          shm_ctime;      /* time of last change by shmctl() */
  115 
  116         /*
  117          * These members are private and used only in the internal
  118          * implementation of this interface.
  119          */
  120         void            *_shm_internal;
  121 };
  122 
  123 #ifdef _KERNEL
  124 struct shmid_ds14 {
  125         struct ipc_perm14 shm_perm;     /* operation permission structure */
  126         int             shm_segsz;      /* size of segment in bytes */
  127         pid_t           shm_lpid;       /* process ID of last shm op */
  128         pid_t           shm_cpid;       /* process ID of creator */
  129         short           shm_nattch;     /* number of current attaches */
  130         time_t          shm_atime;      /* time of last shmat() */
  131         time_t          shm_dtime;      /* time of last shmdt() */
  132         time_t          shm_ctime;      /* time of last change by shmctl() */
  133         void            *shm_internal;  /* sysv stupidity */
  134 };
  135 #endif /* _KERNEL */
  136 
  137 #if defined(_NETBSD_SOURCE)
  138 /*
  139  * Some systems (e.g. HP-UX) take these as the second (cmd) arg to shmctl().
  140  * XXX Currently not implemented.
  141  */
  142 #define SHM_LOCK        3       /* Lock segment in memory. */
  143 #define SHM_UNLOCK      4       /* Unlock a segment locked by SHM_LOCK. */
  144 #endif /* _NETBSD_SOURCE */
  145 
  146 #if defined(_NETBSD_SOURCE)
  147 /*
  148  * Permission definitions used in shmflag arguments to shmat(2) and shmget(2).
  149  * Provided for source compatibility only; do not use in new code!
  150  */
  151 #define SHM_R           IPC_R   /* S_IRUSR, R for owner */
  152 #define SHM_W           IPC_W   /* S_IWUSR, W for owner */
  153 
  154 /*
  155  * System 5 style catch-all structure for shared memory constants that
  156  * might be of interest to user programs.  Do we really want/need this?
  157  */
  158 struct shminfo {
  159         int32_t shmmax;         /* max shared memory segment size (bytes) */
  160         int32_t shmmin;         /* min shared memory segment size (bytes) */
  161         int32_t shmmni;         /* max number of shared memory identifiers */
  162         int32_t shmseg;         /* max shared memory segments per process */
  163         int32_t shmall;         /* max amount of shared memory (pages) */
  164 };
  165 
  166 /* Warning: 64-bit structure padding is needed here */
  167 struct shmid_ds_sysctl {
  168         struct          ipc_perm_sysctl shm_perm;
  169         u_int64_t       shm_segsz;
  170         pid_t           shm_lpid;
  171         pid_t           shm_cpid;
  172         time_t          shm_atime;
  173         time_t          shm_dtime;
  174         time_t          shm_ctime;
  175         u_int32_t       shm_nattch;
  176 };
  177 struct shm_sysctl_info {
  178         struct  shminfo shminfo;
  179         int32_t pad;    /* shminfo not a multiple of 64 bits */
  180         struct  shmid_ds_sysctl shmids[1];
  181 };
  182 #endif /* _NETBSD_SOURCE */
  183 
  184 #ifdef _KERNEL
  185 extern struct shminfo shminfo;
  186 extern struct shmid_ds *shmsegs;
  187 
  188 struct vmspace;
  189 
  190 void    shminit __P((void));
  191 void    shmfork __P((struct vmspace *, struct vmspace *));
  192 void    shmexit __P((struct vmspace *));
  193 int     shmctl1 __P((struct proc *, int, int, struct shmid_ds *));
  194 #else /* !_KERNEL */
  195 
  196 __BEGIN_DECLS
  197 void    *shmat __P((int, const void *, int));
  198 int     shmctl __P((int, int, struct shmid_ds *)) __RENAME(__shmctl13);
  199 int     shmdt __P((const void *));
  200 int     shmget __P((key_t, size_t, int));
  201 __END_DECLS
  202 
  203 #endif /* !_KERNEL */
  204 
  205 #endif /* !_SYS_SHM_H_ */

Cache object: 1ccce98371b49640fff5b40e7bb08e8d


[ 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.