| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #include <sys/ipc.h> |
| #include <sys/shm.h> |
| #include <sys/sem.h> |
|
|
| #ifdef _AIX |
| #include <fcntl.h> |
| #else |
| #include <sys/fcntl.h> |
| #endif |
|
|
| |
|
|
| #define SHARED_MAXSEG (16) |
|
|
| #define SHARED_KEYBASE (14011963) |
| #define SHARED_FDNAME ("/tmp/.shmem-lockfile") |
|
|
| #define SHARED_ENV_KEYBASE ("SHMEM_LIB_KEYBASE") |
| #define SHARED_ENV_MAXSEG ("SHMEM_LIB_MAXSEG") |
|
|
| |
|
|
| #define SHARED_RDONLY (0) |
| #define SHARED_RDWRITE (1) |
| #define SHARED_WAIT (0) |
| #define SHARED_NOWAIT (2) |
| #define SHARED_NOLOCK (0x100) |
|
|
| #define SHARED_RESIZE (4) |
| #define SHARED_PERSIST (8) |
|
|
| #define SHARED_INVALID (-1) |
|
|
| #define SHARED_EMPTY (0) |
| #define SHARED_USED (1) |
|
|
| #define SHARED_GRANUL (16384) |
|
|
|
|
|
|
| |
|
|
| #define SHARED_ID_0 ('J') |
| #define SHARED_ID_1 ('B') |
|
|
| #define BLOCK_REG (0) |
| #define BLOCK_SHARED (1) |
|
|
| |
|
|
| #define SHARED_OK (0) |
|
|
| #define SHARED_ERR_MIN_IDX SHARED_BADARG |
| #define SHARED_ERR_MAX_IDX SHARED_NORESIZE |
|
|
|
|
| #define DAL_SHM_FREE (0) |
| #define DAL_SHM_USED (1) |
|
|
| #define DAL_SHM_ID0 ('D') |
| #define DAL_SHM_ID1 ('S') |
| #define DAL_SHM_ID2 ('M') |
|
|
| #define DAL_SHM_SEGHEAD_ID (0x19630114) |
|
|
|
|
|
|
| |
|
|
| |
| |
|
|
| typedef union |
| { struct BLKHEADstruct |
| { char ID[2]; |
| char tflag; |
| int handle; |
| } s; |
| double d; |
| } BLKHEAD; |
|
|
| typedef void *SHARED_P; |
|
|
| typedef struct SHARED_GTABstruct /* data type used in global table */ |
| { int sem; |
| int semkey; |
| int key; |
| int handle; |
| int size; |
| int nprocdebug; |
| char attr; |
| } SHARED_GTAB; |
|
|
| typedef struct SHARED_LTABstruct /* data type used in local table */ |
| { BLKHEAD *p; |
| int tcnt; |
| int lkcnt; |
| long seekpos; |
| } SHARED_LTAB; |
|
|
|
|
| |
|
|
| #ifndef HAVE_FLOCK_T |
| typedef struct flock flock_t; |
| #define HAVE_FLOCK_T |
| #endif |
|
|
| #ifndef HAVE_UNION_SEMUN |
| union semun |
| { int val; |
| struct semid_ds *buf; |
| unsigned short *array; |
| }; |
| #define HAVE_UNION_SEMUN |
| #endif |
|
|
|
|
| typedef struct DAL_SHM_SEGHEAD_STRUCT DAL_SHM_SEGHEAD; |
|
|
| struct DAL_SHM_SEGHEAD_STRUCT |
| { int ID; |
| int h; |
| int size; |
| int nodeidx; |
| }; |
|
|
| |
|
|
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
|
|
| void shared_cleanup(void); |
| int shared_init(int debug_msgs); |
| int shared_recover(int id); |
| int shared_malloc(long size, int mode, int newhandle); |
| int shared_attach(int idx); |
| int shared_free(int idx); |
| SHARED_P shared_lock(int idx, int mode); |
| SHARED_P shared_realloc(int idx, long newsize); |
| int shared_size(int idx); |
| int shared_attr(int idx); |
| int shared_set_attr(int idx, int newattr); |
| int shared_unlock(int idx); |
| int shared_set_debug(int debug_msgs); |
| int shared_set_createmode(int mode); |
| int shared_list(int id); |
| int shared_uncond_delete(int id); |
| int shared_getaddr(int id, char **address); |
|
|
| int smem_init(void); |
| int smem_shutdown(void); |
| int smem_setoptions(int options); |
| int smem_getoptions(int *options); |
| int smem_getversion(int *version); |
| int smem_open(char *filename, int rwmode, int *driverhandle); |
| int smem_create(char *filename, int *driverhandle); |
| int smem_close(int driverhandle); |
| int smem_remove(char *filename); |
| int smem_size(int driverhandle, LONGLONG *size); |
| int smem_flush(int driverhandle); |
| int smem_seek(int driverhandle, LONGLONG offset); |
| int smem_read(int driverhandle, void *buffer, long nbytes); |
| int smem_write(int driverhandle, void *buffer, long nbytes); |
|
|
| #ifdef __cplusplus |
| } |
| #endif |
|
|