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: releng/11.1/sys/sys/shm.h 301074 2016-05-31 19:24:32Z ed $ */
    2 /*      $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 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 #include <sys/ipc.h>
   44 #include <sys/_types.h>
   45 
   46 #include <machine/param.h>
   47 
   48 #define SHM_RDONLY  010000  /* Attach read-only (else read-write) */
   49 #define SHM_RND     020000  /* Round attach address to SHMLBA */
   50 #define SHMLBA      PAGE_SIZE /* Segment low boundary address multiple */
   51 
   52 /* "official" access mode definitions; somewhat braindead since you have
   53    to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */
   54 #define SHM_R       (IPC_R)
   55 #define SHM_W       (IPC_W)
   56 
   57 /* predefine tbd *LOCK shmctl commands */
   58 #define SHM_LOCK        11
   59 #define SHM_UNLOCK      12
   60 
   61 /* ipcs shmctl commands for Linux compatibility */
   62 #define SHM_STAT        13
   63 #define SHM_INFO        14
   64 
   65 #ifndef _PID_T_DECLARED
   66 typedef __pid_t         pid_t;
   67 #define _PID_T_DECLARED
   68 #endif
   69 
   70 #ifndef _TIME_T_DECLARED
   71 typedef __time_t        time_t;
   72 #define _TIME_T_DECLARED
   73 #endif
   74 
   75 #ifndef _SIZE_T_DECLARED
   76 typedef __size_t        size_t;
   77 #define _SIZE_T_DECLARED
   78 #endif
   79 
   80 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
   81     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
   82 struct shmid_ds_old {
   83         struct ipc_perm_old shm_perm;   /* operation permission structure */
   84         int             shm_segsz;      /* size of segment in bytes */
   85         pid_t           shm_lpid;   /* process ID of last shared memory op */
   86         pid_t           shm_cpid;       /* process ID of creator */
   87         short           shm_nattch;     /* number of current attaches */
   88         time_t          shm_atime;      /* time of last shmat() */
   89         time_t          shm_dtime;      /* time of last shmdt() */
   90         time_t          shm_ctime;      /* time of last change by shmctl() */
   91         void           *shm_internal;   /* sysv stupidity */
   92 };
   93 #endif
   94 
   95 struct shmid_ds {
   96         struct ipc_perm shm_perm;       /* operation permission structure */
   97         size_t          shm_segsz;      /* size of segment in bytes */
   98         pid_t           shm_lpid;   /* process ID of last shared memory op */
   99         pid_t           shm_cpid;       /* process ID of creator */
  100         int             shm_nattch;     /* number of current attaches */
  101         time_t          shm_atime;      /* time of last shmat() */
  102         time_t          shm_dtime;      /* time of last shmdt() */
  103         time_t          shm_ctime;      /* time of last change by shmctl() */
  104 };
  105 
  106 #ifdef _KERNEL
  107 #include <vm/vm.h>
  108 
  109 /*
  110  * System 5 style catch-all structure for shared memory constants that
  111  * might be of interest to user programs.  Do we really want/need this?
  112  */
  113 struct shminfo {
  114         u_long  shmmax;         /* max shared memory segment size (bytes) */
  115         u_long  shmmin;         /* max shared memory segment size (bytes) */
  116         u_long  shmmni;         /* max number of shared memory identifiers */
  117         u_long  shmseg;         /* max shared memory segments per process */
  118         u_long  shmall;         /* max amount of shared memory (pages) */
  119 };
  120 
  121 /* 
  122  * Add a kernel wrapper to the shmid_ds struct so that private info (like the
  123  * MAC label) can be added to it, without changing the user interface.
  124  */
  125 struct shmid_kernel {
  126         struct shmid_ds u;
  127         vm_object_t object;
  128         struct label *label;    /* MAC label */
  129         struct ucred *cred;     /* creator's credendials */
  130 };
  131 
  132 extern struct shminfo   shminfo;
  133 
  134 struct shm_info {
  135         int used_ids;
  136         unsigned long shm_tot;
  137         unsigned long shm_rss;
  138         unsigned long shm_swp;
  139         unsigned long swap_attempts;
  140         unsigned long swap_successes;
  141 };
  142 
  143 struct thread;
  144 struct proc;
  145 struct vmspace;
  146 
  147 void    shmexit(struct vmspace *);
  148 void    shmfork(struct proc *, struct proc *);
  149 #endif /* _KERNEL */
  150 
  151 #if !defined(_KERNEL) || defined(_WANT_SHM_PROTOTYPES)
  152 #include <sys/cdefs.h>
  153 
  154 #ifndef _SIZE_T_DECLARED
  155 typedef __size_t        size_t;
  156 #define _SIZE_T_DECLARED
  157 #endif
  158 
  159 __BEGIN_DECLS
  160 #ifdef __BSD_VISIBLE
  161 int shmsys(int, ...);
  162 #endif
  163 void *shmat(int, const void *, int);
  164 int shmget(key_t, size_t, int);
  165 int shmctl(int, int, struct shmid_ds *);
  166 int shmdt(const void *);
  167 __END_DECLS
  168 
  169 #endif /* _KERNEL || _WANT_SHM_PROTOTYPES */
  170 
  171 #endif /* !_SYS_SHM_H_ */

Cache object: 08bd2d5d3775e68c53f44dede50a510d


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