![]() |
|
|||
0001 /** 0002 * @brief Enduro/X Standard library shared memory routines 0003 * 0004 * @file nstd_shm.h 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #ifndef NSTD_SHM_H__ 0035 #define NSTD_SHM_H__ 0036 0037 #ifdef __cplusplus 0038 extern "C" { 0039 #endif 0040 0041 /*---------------------------Includes-----------------------------------*/ 0042 #include <nstdutil.h> 0043 /*---------------------------Externs------------------------------------*/ 0044 /*---------------------------Macros-------------------------------------*/ 0045 #define NDRX_SHM_PATH_MAX 128 /**< Max shared memory file name len */ 0046 0047 #define NDRX_SEM_SVC_OPS 0 /**< Semaphore for shared memory management */ 0048 #define NDRX_SEM_SVC_GLOBAL_NUM 0 /**< Semaphore array for global svc managmenet */ 0049 #define NDRX_SEM_SV5LOCKS 1 /**< System V message queue lockings */ 0050 #define NDRX_SEM_CPMLOCKS 2 /**< Client process monitor shm lock */ 0051 #define NDRX_SEM_LCFLOCKS 3 /**< Latent command framework locks */ 0052 0053 #define NDRX_SEM_TYP_READ 0 /**< RW Lock - Read */ 0054 #define NDRX_SEM_TYP_WRITE 1 /**< RW Lock - Write */ 0055 0056 /*---------------------------Enums--------------------------------------*/ 0057 /*---------------------------Typedefs-----------------------------------*/ 0058 0059 /** 0060 * Shared memory handler 0061 */ 0062 typedef struct 0063 { 0064 char path[NDRX_SHM_PATH_MAX+1]; /**< name of shm */ 0065 int fd; /**< opened fd */ 0066 char *mem; /**< mapped memory */ 0067 int size; /**< size used by this shm block */ 0068 key_t key; /**< for APIs who need it */ 0069 } ndrx_shm_t; 0070 0071 /** 0072 * Semaphore handler 0073 */ 0074 typedef struct 0075 { 0076 key_t key; /**< Key for semaphore... */ 0077 int semid; 0078 short attached; /**< Is attached? */ 0079 int nrsems; /**< Number of semaphores */ 0080 int maxreaders; /**< Max number of readers for RW locks */ 0081 } ndrx_sem_t; 0082 0083 /*---------------------------Globals------------------------------------*/ 0084 /*---------------------------Statics------------------------------------*/ 0085 /*---------------------------Prototypes---------------------------------*/ 0086 0087 extern NDRX_API int ndrx_shm_open(ndrx_shm_t *shm, int attach_on_exists); 0088 extern NDRX_API int ndrx_shm_attach(ndrx_shm_t *shm); 0089 extern NDRX_API int ndrx_shm_close(ndrx_shm_t *shm); 0090 extern NDRX_API int ndrx_shm_remove(ndrx_shm_t *shm); 0091 extern NDRX_API int ndrx_shm_remove_name(char *path, key_t ipckey); 0092 extern NDRX_API string_list_t * ndrx_shm_shms_list(key_t ipckey); 0093 extern NDRX_API int ndrx_shm_is_attached(ndrx_shm_t *shm); 0094 0095 extern NDRX_API int ndrx_sem_attach(ndrx_sem_t *sem); 0096 extern NDRX_API int ndrx_sem_close(ndrx_sem_t *sem); 0097 extern NDRX_API int ndrx_sem_open(ndrx_sem_t *sem, int attach_on_exists); 0098 extern NDRX_API int ndrx_sem_lock(ndrx_sem_t *sem, const char *msg, int sem_num); 0099 extern NDRX_API int ndrx_sem_unlock(ndrx_sem_t *sem, const char *msg, int sem_num); 0100 extern NDRX_API int ndrx_sem_remove(ndrx_sem_t *sem, int force); 0101 extern NDRX_API int ndrx_sem_is_attached(ndrx_sem_t *sem); 0102 0103 extern NDRX_API int ndrx_sem_rwlock(ndrx_sem_t *sem, int sem_num, int typ); 0104 extern NDRX_API int ndrx_sem_rwunlock(ndrx_sem_t *sem, int sem_num, int typ); 0105 0106 extern NDRX_API unsigned int ndrx_hash_fn( void *k ); 0107 0108 #ifdef __cplusplus 0109 } 0110 #endif 0111 0112 #endif /* NSTD_CONTEXT_H */ 0113 0114 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |