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 /* $FreeBSD$ */
    2 /*      $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $     */
    3 
    4 /*-
    5  * SPDX-License-Identifier: BSD-4-Clause
    6  *
    7  * Copyright (c) 1994 Adam Glass
    8  * All rights reserved.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *      This product includes software developed by Adam Glass.
   21  * 4. The name of the author may not be used to endorse or promote products
   22  *    derived from this software without specific prior written permission
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   25  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   26  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   27  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   29  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   33  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   34  */
   35 
   36 /*
   37  * As defined+described in "X/Open System Interfaces and Headers"
   38  *                         Issue 4, p. XXX
   39  */
   40 
   41 #ifndef _SYS_SHM_H_
   42 #define _SYS_SHM_H_
   43 
   44 #include <sys/cdefs.h>
   45 #ifdef _WANT_SYSVSHM_INTERNALS
   46 #define _WANT_SYSVIPC_INTERNALS
   47 #endif
   48 #include <sys/ipc.h>
   49 #include <sys/_types.h>
   50 
   51 #include <machine/param.h>
   52 
   53 #define SHM_RDONLY  010000  /* Attach read-only (else read-write) */
   54 #define SHM_RND     020000  /* Round attach address to SHMLBA */
   55 #define SHM_REMAP   030000  /* Unmap before mapping */
   56 #define SHMLBA      PAGE_SIZE /* Segment low boundary address multiple */
   57 
   58 /* "official" access mode definitions; somewhat braindead since you have
   59    to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */
   60 #define SHM_R       (IPC_R)
   61 #define SHM_W       (IPC_W)
   62 
   63 /* predefine tbd *LOCK shmctl commands */
   64 #define SHM_LOCK        11
   65 #define SHM_UNLOCK      12
   66 
   67 /* ipcs shmctl commands for Linux compatibility */
   68 #define SHM_STAT        13
   69 #define SHM_INFO        14
   70 
   71 #ifndef _PID_T_DECLARED
   72 typedef __pid_t         pid_t;
   73 #define _PID_T_DECLARED
   74 #endif
   75 
   76 #ifndef _TIME_T_DECLARED
   77 typedef __time_t        time_t;
   78 #define _TIME_T_DECLARED
   79 #endif
   80 
   81 #ifndef _SIZE_T_DECLARED
   82 typedef __size_t        size_t;
   83 #define _SIZE_T_DECLARED
   84 #endif
   85 
   86 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
   87     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
   88 struct shmid_ds_old {
   89         struct ipc_perm_old shm_perm;   /* operation permission structure */
   90         int             shm_segsz;      /* size of segment in bytes */
   91         pid_t           shm_lpid;   /* process ID of last shared memory op */
   92         pid_t           shm_cpid;       /* process ID of creator */
   93         short           shm_nattch;     /* number of current attaches */
   94         time_t          shm_atime;      /* time of last shmat() */
   95         time_t          shm_dtime;      /* time of last shmdt() */
   96         time_t          shm_ctime;      /* time of last change by shmctl() */
   97         void           *shm_internal;   /* sysv stupidity */
   98 };
   99 #endif
  100 
  101 typedef unsigned int shmatt_t;
  102 
  103 struct shmid_ds {
  104         struct ipc_perm shm_perm;       /* operation permission structure */
  105         size_t          shm_segsz;      /* size of segment in bytes */
  106         pid_t           shm_lpid;   /* process ID of last shared memory 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 };
  113 
  114 #if defined(_KERNEL) || defined(_WANT_SYSVSHM_INTERNALS)
  115 /*
  116  * System 5 style catch-all structure for shared memory constants that
  117  * might be of interest to user programs.  Do we really want/need this?
  118  */
  119 struct shminfo {
  120         u_long  shmmax;         /* max shared memory segment size (bytes) */
  121         u_long  shmmin;         /* max shared memory segment size (bytes) */
  122         u_long  shmmni;         /* max number of shared memory identifiers */
  123         u_long  shmseg;         /* max shared memory segments per process */
  124         u_long  shmall;         /* max amount of shared memory (pages) */
  125 };
  126 
  127 struct vm_object;
  128 
  129 /* 
  130  * Add a kernel wrapper to the shmid_ds struct so that private info (like the
  131  * MAC label) can be added to it, without changing the user interface.
  132  */
  133 struct shmid_kernel {
  134         struct shmid_ds u;
  135         struct vm_object *object;
  136         struct label *label;    /* MAC label */
  137         struct ucred *cred;     /* creator's credendials */
  138 };
  139 #endif
  140 
  141 struct shm_info {
  142         int used_ids;
  143         unsigned long shm_tot;
  144         unsigned long shm_rss;
  145         unsigned long shm_swp;
  146         unsigned long swap_attempts;
  147         unsigned long swap_successes;
  148 };
  149 
  150 #ifdef _KERNEL
  151 struct proc;
  152 struct vmspace;
  153 
  154 extern struct shminfo   shminfo;
  155 
  156 void    shmexit(struct vmspace *);
  157 void    shmfork(struct proc *, struct proc *);
  158 
  159 #else /* !_KERNEL */
  160 
  161 #include <sys/cdefs.h>
  162 
  163 #ifndef _SIZE_T_DECLARED
  164 typedef __size_t        size_t;
  165 #define _SIZE_T_DECLARED
  166 #endif
  167 
  168 __BEGIN_DECLS
  169 #if __BSD_VISIBLE
  170 int shmsys(int, ...);
  171 #endif
  172 void *shmat(int, const void *, int);
  173 int shmget(key_t, size_t, int);
  174 int shmctl(int, int, struct shmid_ds *);
  175 int shmdt(const void *);
  176 __END_DECLS
  177 
  178 #endif /* _KERNEL */
  179 
  180 #endif /* !_SYS_SHM_H_ */

Cache object: f7f39538b4f46f12954b56df82cb7b75


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