"Fossies" - the Fresh Open Source Software Archive

Member "dmd2/src/druntime/import/core/sys/posix/sys/shm.d" (20 Nov 2020, 7082 Bytes) of package /linux/misc/dmd.2.094.2.linux.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) D source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /**
    2  * D header file for POSIX.
    3  *
    4  * Copyright: Copyright Sean Kelly 2005 - 2009.
    5  * License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
    6  * Authors:   Sean Kelly
    7  * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
    8  */
    9 
   10 /*          Copyright Sean Kelly 2005 - 2009.
   11  * Distributed under the Boost Software License, Version 1.0.
   12  *    (See accompanying file LICENSE or copy at
   13  *          http://www.boost.org/LICENSE_1_0.txt)
   14  */
   15 module core.sys.posix.sys.shm;
   16 
   17 private import core.sys.posix.config;
   18 public import core.sys.posix.sys.types; // for pid_t, time_t, key_t
   19 public import core.sys.posix.sys.ipc;
   20 
   21 version (OSX)
   22     version = Darwin;
   23 else version (iOS)
   24     version = Darwin;
   25 else version (TVOS)
   26     version = Darwin;
   27 else version (WatchOS)
   28     version = Darwin;
   29 
   30 version (Posix):
   31 extern (C) nothrow @nogc:
   32 @system:
   33 
   34 //
   35 // XOpen (XSI)
   36 //
   37 /*
   38 SHM_RDONLY
   39 SHM_RND
   40 
   41 SHMLBA
   42 
   43 shmatt_t
   44 
   45 struct shmid_ds
   46 {
   47     ipc_perm    shm_perm;
   48     size_t      shm_segsz;
   49     pid_t       shm_lpid;
   50     pid_t       shm_cpid;
   51     shmatt_t    shm_nattch;
   52     time_t      shm_atime;
   53     time_t      shm_dtime;
   54     time_t      shm_ctime;
   55 }
   56 
   57 void* shmat(int, const scope void*, int);
   58 int   shmctl(int, int, shmid_ds*);
   59 int   shmdt(const scope void*);
   60 int   shmget(key_t, size_t, int);
   61 */
   62 
   63 version (CRuntime_Glibc)
   64 {
   65     enum SHM_RDONLY     = 0x01000; // 010000
   66     enum SHM_RND        = 0x02000; // 020000
   67 
   68     int   __getpagesize();
   69     alias __getpagesize SHMLBA;
   70 
   71     alias c_ulong   shmatt_t;
   72 
   73     /* For any changes, please check /usr/include/bits/shm.h */
   74     struct shmid_ds
   75     {
   76         ipc_perm    shm_perm;
   77         size_t      shm_segsz;
   78         time_t      shm_atime;
   79         version (X86_64) {} else c_ulong     __unused1;
   80         time_t      shm_dtime;
   81         version (X86_64) {} else c_ulong     __unused2;
   82         time_t      shm_ctime;
   83         version (X86_64) {} else c_ulong     __unused3;
   84         pid_t       shm_cpid;
   85         pid_t       shm_lpid;
   86         shmatt_t    shm_nattch;
   87         c_ulong     __unused4;
   88         c_ulong     __unused5;
   89     }
   90 
   91     void* shmat(int, const scope void*, int);
   92     int   shmctl(int, int, shmid_ds*);
   93     int   shmdt(const scope void*);
   94     int   shmget(key_t, size_t, int);
   95 }
   96 else version (FreeBSD)
   97 {
   98     enum SHM_RDONLY     = 0x01000; // 010000
   99     enum SHM_RND        = 0x02000; // 020000
  100     enum SHMLBA         = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
  101 
  102     alias c_ulong   shmatt_t;
  103 
  104     struct shmid_ds_old // <= FreeBSD7
  105     {
  106         ipc_perm_old    shm_perm;
  107         int             shm_segsz;
  108         pid_t           shm_lpid;
  109         pid_t           shm_cpid;
  110         short           shm_nattch;
  111         time_t          shm_atime;
  112         time_t          shm_dtime;
  113         time_t          shm_ctime;
  114         void*           shm_internal;
  115     }
  116 
  117     struct shmid_ds
  118     {
  119          ipc_perm    shm_perm;
  120          int         shm_segsz;
  121          pid_t       shm_lpid;
  122          pid_t       shm_cpid;
  123          short       shm_nattch;
  124          time_t      shm_atime;
  125          time_t      shm_dtime;
  126          time_t      shm_ctime;
  127     }
  128 
  129     void* shmat(int, const scope void*, int);
  130     int   shmctl(int, int, shmid_ds*);
  131     int   shmdt(const scope void*);
  132     int   shmget(key_t, size_t, int);
  133 }
  134 else version (NetBSD)
  135 {
  136     enum SHM_RDONLY     = 0x01000; // 010000
  137     enum SHM_RND        = 0x02000; // 020000
  138     enum SHMLBA         = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
  139 
  140     alias c_ulong   shmatt_t;
  141 
  142     struct shmid_ds
  143     {
  144         ipc_perm        shm_perm;
  145         size_t             shm_segsz;
  146         pid_t           shm_lpid;
  147         pid_t           shm_cpid;
  148         short           shm_nattch;
  149         time_t          shm_atime;
  150         time_t          shm_dtime;
  151         time_t          shm_ctime;
  152         void*           shm_internal;
  153     }
  154 
  155     void* shmat(int, const scope void*, int);
  156     int   shmctl(int, int, shmid_ds*);
  157     int   shmdt(const scope void*);
  158     int   shmget(key_t, size_t, int);
  159 }
  160 else version (OpenBSD)
  161 {
  162     enum SHM_RDONLY     = 0x01000; // 010000
  163     enum SHM_RND        = 0x02000; // 020000
  164     enum SHMLBA         = 1 << _MAX_PAGE_SHIFT;
  165 
  166     alias short shmatt_t;
  167 
  168     struct shmid_ds
  169     {
  170         ipc_perm   shm_perm;
  171         int        shm_segsz;
  172         pid_t      shm_lpid;
  173         pid_t      shm_cpid;
  174         shmatt_t   shm_nattch;
  175         time_t     shm_atime;
  176         c_long   __shm_atimensec;
  177         time_t     shm_dtime;
  178         c_long   __shm_dtimensec;
  179         time_t     shm_ctime;
  180         c_long   __shm_ctimensec;
  181         void*      shm_internal;
  182     }
  183 
  184     void* shmat(int, const scope void*, int);
  185     int   shmctl(int, int, shmid_ds*);
  186     int   shmdt(const scope void*);
  187     int   shmget(key_t, size_t, int);
  188 }
  189 else version (DragonFlyBSD)
  190 {
  191     enum SHM_RDONLY     = 0x01000; // 010000
  192     enum SHM_RND        = 0x02000; // 020000
  193     enum SHMLBA         = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
  194 
  195     alias c_ulong   shmatt_t;
  196 
  197     struct shmid_ds
  198     {
  199          ipc_perm       shm_perm;
  200          int            shm_segsz;
  201          pid_t          shm_lpid;
  202          pid_t          shm_cpid;
  203          short          shm_nattch;
  204          time_t         shm_atime;
  205          time_t         shm_dtime;
  206          time_t         shm_ctime;
  207          private void*  shm_internal;
  208     }
  209 
  210     void* shmat(int, const scope void*, int);
  211     int   shmctl(int, int, shmid_ds*);
  212     int   shmdt(const scope void*);
  213     int   shmget(key_t, size_t, int);
  214 }
  215 else version (Darwin)
  216 {
  217 
  218 }
  219 else version (CRuntime_UClibc)
  220 {
  221     enum SHM_RDONLY     = 0x1000; // 010000
  222     enum SHM_RND        = 0x2000; // 020000
  223     enum SHM_REMAP      = 0x4000; // 040000
  224 
  225     int   __getpagesize();
  226     alias __getpagesize SHMLBA;
  227 
  228     alias c_ulong   shmatt_t;
  229 
  230     version (X86_64)
  231         enum includeUnused  = false;
  232     else version (MIPS32)
  233         enum includeUnused  = false;
  234     else
  235         enum includeUnused  = true;
  236 
  237     struct shmid_ds
  238     {
  239         ipc_perm    shm_perm;
  240         size_t      shm_segsz;
  241         time_t      shm_atime;
  242         static if (includeUnused) c_ulong     __unused1;
  243         time_t      shm_dtime;
  244         static if (includeUnused) c_ulong     __unused2;
  245         time_t      shm_ctime;
  246         static if (includeUnused) c_ulong     __unused3;
  247         pid_t       shm_cpid;
  248         pid_t       shm_lpid;
  249         shmatt_t    shm_nattch;
  250         c_ulong     __unused4;
  251         c_ulong     __unused5;
  252     }
  253 
  254     struct shminfo
  255     {
  256         c_ulong shmmax;
  257         c_ulong shmmin;
  258         c_ulong shmmni;
  259         c_ulong shmseg;
  260         c_ulong shmall;
  261         c_ulong __unused1;
  262         c_ulong __unused2;
  263         c_ulong __unused3;
  264         c_ulong __unused4;
  265     }
  266 
  267     struct shm_info
  268     {
  269         int used_ids;
  270         c_ulong shm_tot;
  271         c_ulong shm_rss;
  272         c_ulong shm_swp;
  273         c_ulong swap_attempts;
  274         c_ulong swap_successes;
  275     }
  276 
  277     void* shmat(int, const scope void*, int);
  278     int   shmctl(int, int, shmid_ds*);
  279     int   shmdt(const scope void*);
  280     int   shmget(key_t, size_t, int);
  281 }