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.42 2006/11/25 21:40:06 christos 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(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 #if defined(_NETBSD_SOURCE)
  124 /*
  125  * Some systems (e.g. HP-UX) take these as the second (cmd) arg to shmctl().
  126  */
  127 #define SHM_LOCK        3       /* Lock segment in memory. */
  128 #define SHM_UNLOCK      4       /* Unlock a segment locked by SHM_LOCK. */
  129 #endif /* _NETBSD_SOURCE */
  130 
  131 #if defined(_NETBSD_SOURCE)
  132 /*
  133  * Permission definitions used in shmflag arguments to shmat(2) and shmget(2).
  134  * Provided for source compatibility only; do not use in new code!
  135  */
  136 #define SHM_R           IPC_R   /* S_IRUSR, R for owner */
  137 #define SHM_W           IPC_W   /* S_IWUSR, W for owner */
  138 
  139 /*
  140  * System 5 style catch-all structure for shared memory constants that
  141  * might be of interest to user programs.  Do we really want/need this?
  142  */
  143 struct shminfo {
  144         int32_t shmmax;         /* max shared memory segment size (bytes) */
  145         int32_t shmmin;         /* min shared memory segment size (bytes) */
  146         int32_t shmmni;         /* max number of shared memory identifiers */
  147         int32_t shmseg;         /* max shared memory segments per process */
  148         int32_t shmall;         /* max amount of shared memory (pages) */
  149 };
  150 
  151 /* Warning: 64-bit structure padding is needed here */
  152 struct shmid_ds_sysctl {
  153         struct          ipc_perm_sysctl shm_perm;
  154         uint64_t        shm_segsz;
  155         pid_t           shm_lpid;
  156         pid_t           shm_cpid;
  157         time_t          shm_atime;
  158         time_t          shm_dtime;
  159         time_t          shm_ctime;
  160         uint32_t        shm_nattch;
  161 };
  162 struct shm_sysctl_info {
  163         struct  shminfo shminfo;
  164         int32_t pad;    /* shminfo not a multiple of 64 bits */
  165         struct  shmid_ds_sysctl shmids[1];
  166 };
  167 #endif /* _NETBSD_SOURCE */
  168 
  169 #ifdef _KERNEL
  170 extern struct shminfo shminfo;
  171 extern struct shmid_ds *shmsegs;
  172 extern int shm_nused;
  173 
  174 #define SHMSEG_FREE             0x0200
  175 #define SHMSEG_REMOVED          0x0400
  176 #define SHMSEG_ALLOCATED        0x0800
  177 #define SHMSEG_WANTED           0x1000
  178 #define SHMSEG_RMLINGER         0x2000
  179 #define SHMSEG_WIRED            0x4000
  180 
  181 struct vmspace;
  182 
  183 void    shminit(void);
  184 void    shmfork(struct vmspace *, struct vmspace *);
  185 void    shmexit(struct vmspace *);
  186 int     shmctl1(struct lwp *, int, int, struct shmid_ds *);
  187 #else /* !_KERNEL */
  188 
  189 __BEGIN_DECLS
  190 void    *shmat(int, const void *, int);
  191 int     shmctl(int, int, struct shmid_ds *) __RENAME(__shmctl13);
  192 int     shmdt(const void *);
  193 int     shmget(key_t, size_t, int);
  194 __END_DECLS
  195 
  196 #endif /* !_KERNEL */
  197 
  198 #endif /* !_SYS_SHM_H_ */

Cache object: 8943aad2150e5cf2dc12dd28451b4626


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