--- freem/src/shmmgr.h 2025/03/26 15:17:12 1.4 +++ freem/src/shmmgr.h 2025/05/15 04:14:20 1.7 @@ -1,5 +1,5 @@ /* - * $Id: shmmgr.h,v 1.4 2025/03/26 15:17:12 snw Exp $ + * $Id: shmmgr.h,v 1.7 2025/05/15 04:14:20 snw Exp $ * shared memory manager data structures * * @@ -24,6 +24,15 @@ * along with FreeM. If not, see . * * $Log: shmmgr.h,v $ + * Revision 1.7 2025/05/15 04:14:20 snw + * Remove old SEMK_ macros since ftok is now used throughout to determine semaphore keys + * + * Revision 1.6 2025/05/09 19:44:50 snw + * Begin shm rework + * + * Revision 1.5 2025/05/08 16:29:18 snw + * Add SOM/SOA/SBM/SBA macros from RSM and modify for FreeM + * * Revision 1.4 2025/03/26 15:17:12 snw * Fall back to global-backed SSVNs when memory-backed globals fail in attempt to fix Tru64 * @@ -62,13 +71,19 @@ #define SHMS_GET_ERR 0 #define SHMS_ATTACH_ERR -1 -#define SEMK_SHM 0xBBDD21 -#define SEMK_LOCKTAB 0xBBDD22 -#define SEMK_JOBTAB 0xBBDD23 -#define SEMK_TP 0xBBDD24 - #define SHMALIGN(a) (void *) (((unsigned long) a + sysconf (_SC_PAGESIZE)) & ~(sysconf (_SC_PAGESIZE) - 1)) +/* The following macros were borrowed from Reference Standard M + * SOM/SOA: reading and writing data stored in shared memory + * SBM/SBA: for modifying pointers in shared memory + * + * Versions ending with 'A' will maintain NULL pointers. + */ +#define SOM(ptr) ((__typeof__(ptr)) ((char *) (ptr) + ((char *) shm_config->dta - (char *) shm_config->hdr->shmad))) +#define SOA(ptr) ((ptr == NULL) ? NULL : SOM(ptr)) +#define SBM(ptr) ((__typeof__(ptr)) ((char *) (ptr) - ((char *) shm_config->dta - (char *) shm_config->hdr->shmad))) +#define SBA(ptr) ((ptr == NULL) ? NULL : SBM(ptr)) + /* data structures */ /* alloc map entry */