Two functions to help C programs/libraries avoid having any non-const static or global variables. For programs planning to be run from a shared segment the program they will be running in read-only memory and the CMS linker does not allow global variables to be placed in another segment.
IBM calls these programs (ones that don't write to their TEXT segment) reentrant programs.
I have coined this memory - Library Global Memory. This memory is persistent across process calls and is designed for libraries to manage internal state. It could also, for example, be used to store user defaults across calls for a client program.
void* CMSLGAll(char[9] ID, SIZE) - Allocate a Library Global Memory Block
where ID is a null terminated 8 character string (no spaces).
and SIZE is LG_SMALL (for a 32 byte block) or LG_LARGE (for a 1024 byte block)
void* CMSGetLG(char[9] ID) - Get the address of the Library Global Memory Block
Notes:
It is envisaged that programs use the LG_SMALL to store pointers to malloced memory, or to store counters / integers etc. However it should be noted that malloced memory is released on an ABEND including HX. Currently there is no facility to detect if malloced memory has been junked from under you! Therefore the LG_LARGE may avoid this danger. This memory is persisted (see implementation) across ABENDS.
This area is NOT freed on program termination.
This will be implemented by RESLIB.
We will have two TEXT files / data areas LG_LARGE TEXT and LG_SMALL TEXT. They will be RESLIBed with the NAME of the provided ID. They will NOT be SYSTEM.