Back to index

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