Back to index

glibc  2.9
shm.h
Go to the documentation of this file.
00001 /* Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef _SYS_SHM_H
00020 # error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
00021 #endif
00022 
00023 #include <sys/types.h>
00024 
00025 /* Permission flag for shmget.  */
00026 #define SHM_R           0400            /* or S_IRUGO from <linux/stat.h> */
00027 #define SHM_W           0200            /* or S_IWUGO from <linux/stat.h> */
00028 
00029 /* Flags for `shmat'.  */
00030 #define SHM_RDONLY   010000        /* attach read-only else read-write */
00031 #define SHM_RND             020000        /* round attach address to SHMLBA */
00032 #define SHM_REMAP    040000        /* take-over region on attach */
00033 
00034 /* Commands for `shmctl'.  */
00035 #define SHM_LOCK     11            /* lock segment (root only) */
00036 #define SHM_UNLOCK   12            /* unlock segment (root only) */
00037 
00038 /* Segment low boundary address multiple.  */
00039 #define SHMLBA              (1024 * 1024)
00040 
00041 /* Type to count number of attaches.  */
00042 typedef unsigned long int shmatt_t;
00043 
00044 /* Data structure describing a shared memory segment.  */
00045 struct shmid_ds
00046   {
00047     struct ipc_perm shm_perm;             /* operation permission struct */
00048     size_t shm_segsz;                     /* size of segment in bytes */
00049     __time_t shm_atime;                   /* time of last shmat() */
00050     __time_t shm_dtime;                   /* time of last shmdt() */
00051     __time_t shm_ctime;                   /* time of last change by shmctl() */
00052     __pid_t shm_cpid;                     /* pid of creator */
00053     __pid_t shm_lpid;                     /* pid of last shmop */
00054     shmatt_t shm_nattch;           /* number of current attaches */
00055     unsigned long int __unused1;
00056     unsigned long int __unused2;
00057   };
00058 
00059 #ifdef __USE_MISC
00060 
00061 /* ipcs ctl commands */
00062 # define SHM_STAT    13
00063 # define SHM_INFO    14
00064 
00065 /* shm_mode upper byte flags */
00066 # define SHM_DEST    01000  /* segment will be destroyed on last detach */
00067 # define SHM_LOCKED  02000   /* segment will not be swapped */
00068 # define SHM_HUGETLB 04000  /* segment is mapped via hugetlb */
00069 # define SHM_NORESERVE      010000 /* don't check for reservations */
00070 
00071 struct shminfo
00072   {
00073     unsigned long int shmmax;
00074     unsigned long int shmmin;
00075     unsigned long int shmmni;
00076     unsigned long int shmseg;
00077     unsigned long int shmall;
00078     unsigned long int __unused1;
00079     unsigned long int __unused2;
00080     unsigned long int __unused3;
00081     unsigned long int __unused4;
00082   };
00083 
00084 struct shm_info
00085   {
00086     int used_ids;
00087     unsigned long int shm_tot;     /* total allocated shm */
00088     unsigned long int shm_rss;     /* total resident shm */
00089     unsigned long int shm_swp;     /* total swapped shm */
00090     unsigned long int swap_attempts;
00091     unsigned long int swap_successes;
00092   };
00093 
00094 #endif /* __USE_MISC */