Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

my_shm.h

Go to the documentation of this file.
00001 /*! \file my_shm.h
00002     Header file for shm.c.
00003  */
00004 
00005 #ifdef __cplusplus
00006 extern "C" {
00007 #endif
00008 
00009 #ifndef SHM_HD
00010 
00011   #include <sys/types.h>
00012   #include <sys/ipc.h>
00013   #include <sys/shm.h>
00014 
00015 
00016   #ifdef SUN
00017   #define SHM_addr    void*
00018   #endif
00019 
00020   #ifdef LINUX
00021   #define SHM_addr    char*
00022   #endif
00023 
00024   #ifndef SHM_addr
00025   #error "ERROR: You must specify a build target (LINUX or SUN)."
00026   #endif
00027 
00028   /*! \brief Define default permissions for all newly created SHM. It should ne read just like file permissions:
00029              0x1C0 = 111000000 in binary, that is 111 000 000. This gives all rights for the user and nothing for other 
00030              users.
00031    */
00032 
00033   #define SHM_PERMISSION 0x000001C0
00034 
00035   /* ============================================================= */
00036   /* Return value for the function create_shared_memory_segment()  */
00037   /* ============================================================= */
00038 
00039   /*! \brief Return value for the function create_shared_memory_segment(). This means that the SHM has been successfully 
00040              created.
00041    */
00042   #define CREATE_SHM_OK               -1
00043 
00044   /*! \brief Return value for the function create_shared_memory_segment(). This means that the SHM has already been created.
00045    */
00046   #define CREATE_SHM_ALREADY_CREATED  -2
00047 
00048   /*! \brief Return value for the function create_shared_memory_segment(). This means that an error occured while creating
00049              the shared memory segment.
00050    */
00051   #define CREATE_SHM_ERROR            -3
00052 
00053   /* ============================================================= */
00054   /* Return value for the function get_shared_memory_segment_id()  */
00055   /* ============================================================= */
00056 
00057   /*! \brief Return value for the function get_shared_memory_segment_sys_id(). This means that the SHM system identifier
00058              has been looked up successfully.
00059    */
00060   #define GET_SHM_OK                  -1
00061 
00062   /*! \brief Return value for the function get_shared_memory_segment_sys_id(). This means that the SHM system identifier
00063              jas already been looked up.
00064    */
00065   #define GET_SHM_ALREADY_GET         -2
00066 
00067   /*! \brief Return value for the function get_shared_memory_segment_sys_id(). This means that an error occured while
00068              getting the system's identifier.
00069    */
00070   #define GET_SHM_ERROR               -3 
00071 
00072   /* ============================================================= */
00073   /* Module's API                                                  */
00074   /* ============================================================= */
00075 
00076   void change_shm_access_permission (int new_permission);
00077   int create_shared_memory_segment (key_t ipc_key, int size);
00078   int get_shared_memory_segment_sys_id (key_t ipc_key, int size);
00079   int get_shared_memory_segment_id();
00080   SHM_addr attache_shared_memory_segment ();
00081   SHM_addr get_shm_address();
00082   int set_shm_auto_destroy();
00083   struct shmid_ds* get_shm_info();
00084   int detache_shm();
00085 
00086   #define SHM_HD
00087 
00088 #endif
00089 
00090 #ifdef __cplusplus
00091 }
00092 #endif
00093 

Generated on Thu Apr 3 16:23:43 2003 for Common_C_libraries by doxygen1.3-rc1