mm.h | mm.h | |||
---|---|---|---|---|
/* ==================================================================== | /* ==================================================================== | |||
* Copyright (c) 1999 Ralf S. Engelschall. All rights reserved. | * Copyright (c) 1999-2000 Ralf S. Engelschall. All rights reserved. | |||
* | * | |||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | |||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | |||
* are met: | * are met: | |||
* | * | |||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | |||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | |||
* | * | |||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | |||
* notice, this list of conditions and the following disclaimer in | * notice, this list of conditions and the following disclaimer in | |||
skipping to change at line 47 | skipping to change at line 47 | |||
* OF THE POSSIBILITY OF SUCH DAMAGE. | * OF THE POSSIBILITY OF SUCH DAMAGE. | |||
* ==================================================================== | * ==================================================================== | |||
*/ | */ | |||
/* | /* | |||
** | ** | |||
** mm.h -- Shared Memory library API header | ** mm.h -- Shared Memory library API header | |||
** | ** | |||
*/ | */ | |||
#ifndef MM_H | #ifndef _MM_H_ | |||
#define MM_H 1 | #define _MM_H_ | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
/* | /* | |||
** ____ Public Part (I) of the API ________________________ | ** ____ Public Part (I) of the API ________________________ | |||
*/ | */ | |||
#include <stdio.h> | #include <stdio.h> | |||
skipping to change at line 85 | skipping to change at line 85 | |||
#include "mm_conf.h" | #include "mm_conf.h" | |||
#include <errno.h> | #include <errno.h> | |||
#include <limits.h> | #include <limits.h> | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <sys/stat.h> | #include <sys/stat.h> | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#ifdef MM_OS_SUNOS | #ifdef MM_OS_SUNOS | |||
#define KERNEL 1 | ||||
#include <memory.h> | #include <memory.h> | |||
/* SunOS lacks prototypes */ | /* SunOS4 lacks prototypes */ | |||
extern int getpagesize(void); | extern int getpagesize(void); | |||
extern int munmap(caddr_t, int); | extern int munmap(caddr_t, int); | |||
extern int ftruncate(int, off_t); | extern int ftruncate(int, off_t); | |||
extern int flock(int, int); | extern int flock(int, int); | |||
extern char *strerror(int); | extern char *strerror(int); | |||
#endif | #endif | |||
#if !defined(FALSE) | #if !defined(FALSE) | |||
#define FALSE 0 | #define FALSE 0 | |||
#endif | #endif | |||
skipping to change at line 125 | skipping to change at line 124 | |||
#endif | #endif | |||
#if !defined(offset_of) | #if !defined(offset_of) | |||
#define offset_of(type,member) ((size_t)(&((type *)0)->member)) | #define offset_of(type,member) ((size_t)(&((type *)0)->member)) | |||
#endif | #endif | |||
#if !defined(HAVE_MEMCPY) | #if !defined(HAVE_MEMCPY) | |||
#if defined(HAVE_BCOPY) | #if defined(HAVE_BCOPY) | |||
#define memcpy(to,from,len) bcopy(from,to,len) | #define memcpy(to,from,len) bcopy(from,to,len) | |||
#else | #else | |||
#define memcpy(to,from,len) \ | #define memcpy(to,from,len) \ | |||
{ int i; for (i = 0; i < (len); i++) *((to)+i) = *((from)+i); } | { int i; for (i = 0; i < (len); i++) *(((char *)(to))+i) = *(((char *)(from))+i); } | |||
#endif | #endif | |||
#endif | #endif | |||
#if !defined(HAVE_MEMSET) | #if !defined(HAVE_MEMSET) | |||
#define memset(to,ch,len) \ | #define memset(to,ch,len) \ | |||
{ int i; for (i = 0; i < (len); i++) *((to)+i) = (ch); } | { int i; for (i = 0; i < (len); i++) *(((char *)(to))+i) = (ch); } | |||
#endif | #endif | |||
#define ERR(type,str) mm_lib_error_set(type,str) | #define ERR(type,str) mm_lib_error_set(type,str) | |||
#define FAIL(type,str) { ERR(type,str); goto cus; } | #define FAIL(type,str) { ERR(type,str); goto cus; } | |||
#define BEGIN_FAILURE cus: | #define BEGIN_FAILURE cus: | |||
#define END_FAILURE | #define END_FAILURE | |||
#if defined(HAVE_PATH_MAX) | #if defined(HAVE_PATH_MAX) | |||
#define MM_MAXPATH PATH_MAX | #define MM_MAXPATH PATH_MAX | |||
#elif defined(HAVE__POSIX_PATH_MAX) | #elif defined(HAVE__POSIX_PATH_MAX) | |||
skipping to change at line 172 | skipping to change at line 171 | |||
#if !defined(MAP_FAILED) | #if !defined(MAP_FAILED) | |||
#define MAP_FAILED ((void *)-1) | #define MAP_FAILED ((void *)-1) | |||
#endif | #endif | |||
#endif | #endif | |||
#if defined(MM_SHMT_IPCSHM) || defined(MM_SEMT_IPCSEM) | #if defined(MM_SHMT_IPCSHM) || defined(MM_SEMT_IPCSEM) | |||
#include <sys/ipc.h> | #include <sys/ipc.h> | |||
#endif | #endif | |||
#if defined(MM_SHMT_IPCSHM) | #if defined(MM_SHMT_IPCSHM) | |||
#define KERNEL 1 /* For SunOS4 */ | ||||
#define _KMEMUSER /* For BS2000 to enable SHM_[RW] */ | ||||
#include <sys/shm.h> | #include <sys/shm.h> | |||
#undef KERNEL | ||||
#undef _KMEMUSER | ||||
#if !defined(SHM_R) | ||||
#define SHM_R 0400 | ||||
#endif | ||||
#if !defined(SHM_W) | ||||
#define SHM_W 0200 | ||||
#endif | ||||
#endif | ||||
#ifdef MM_SHMT_BEOS | ||||
#include <kernel/OS.h> | ||||
#endif | #endif | |||
#if defined(MM_SEMT_IPCSEM) | #if defined(MM_SEMT_IPCSEM) | |||
#include <sys/sem.h> | #include <sys/sem.h> | |||
#ifndef HAVE_UNION_SEMUN | #ifndef HAVE_UNION_SEMUN | |||
union semun { | union semun { | |||
int val; | int val; | |||
struct semid_ds *buf; | struct semid_ds *buf; | |||
u_short *array; | u_short *array; | |||
}; | }; | |||
skipping to change at line 266 | skipping to change at line 279 | |||
* required) | * required) | |||
*/ | */ | |||
struct mem_core { | struct mem_core { | |||
size_t mc_size; | size_t mc_size; | |||
size_t mc_usize; | size_t mc_usize; | |||
pid_t mc_pid; | pid_t mc_pid; | |||
int mc_fdmem; | int mc_fdmem; | |||
#if defined(MM_SHMT_MMFILE) | #if defined(MM_SHMT_MMFILE) | |||
char mc_fnmem[MM_MAXPATH]; | char mc_fnmem[MM_MAXPATH]; | |||
#endif | #endif | |||
#if defined(MM_SHMT_BEOS) | ||||
area_id mc_areaid; | ||||
#endif | ||||
#if !defined(MM_SEMT_FLOCK) | #if !defined(MM_SEMT_FLOCK) | |||
int mc_fdsem; | int mc_fdsem; | |||
#endif | #endif | |||
#if defined(MM_SEMT_FLOCK) | #if defined(MM_SEMT_FLOCK) | |||
mem_core_fd mc_fdsem[MM_MAXCHILD]; | mem_core_fd mc_fdsem[MM_MAXCHILD]; | |||
#endif | #endif | |||
#if defined(MM_SEMT_IPCSEM) | #if defined(MM_SEMT_IPCSEM) | |||
int mc_fdsem_rd; | int mc_fdsem_rd; | |||
int mc_readers; | int mc_readers; | |||
mm_lock_mode mc_lockmode; | mm_lock_mode mc_lockmode; | |||
#endif | #endif | |||
#if defined(MM_SEMT_FLOCK) || defined(MM_SEMT_FCNTL) | #if defined(MM_SEMT_FLOCK) || defined(MM_SEMT_FCNTL) | |||
char mc_fnsem[MM_MAXPATH]; | char mc_fnsem[MM_MAXPATH]; | |||
#endif | #endif | |||
#if defined(MM_SEMT_BEOS) | ||||
sem_id mc_semid; | ||||
int32 mc_ben; | ||||
#endif | ||||
mem_word mc_base; | mem_word mc_base; | |||
}; | }; | |||
typedef struct mem_core mem_core; | typedef struct mem_core mem_core; | |||
#define SIZEOF_mem_core (sizeof(mem_core)-SIZEOF_mem_word) | #define SIZEOF_mem_core (sizeof(mem_core)-SIZEOF_mem_word) | |||
#endif /* MM_PRIVATE */ | #endif /* MM_PRIVATE */ | |||
/* | /* | |||
** ____ Public Part (II) of the API _______________________ | ** ____ Public Part (II) of the API _______________________ | |||
*/ | */ | |||
skipping to change at line 350 | skipping to change at line 370 | |||
/* Internal Library API */ | /* Internal Library API */ | |||
void mm_lib_error_set(unsigned int, const char *str); | void mm_lib_error_set(unsigned int, const char *str); | |||
char *mm_lib_error_get(void); | char *mm_lib_error_get(void); | |||
int mm_lib_version(void); | int mm_lib_version(void); | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif /* MM_H */ | #endif /* _MM_H_ */ | |||
End of changes. 11 change blocks. | ||||
7 lines changed or deleted | 27 lines changed or added | |||