Giter Site home page Giter Site logo

adesutherland / cms-370-gcclib Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 2.0 1.16 MB

Native VM/CMS C Library. Developed by Robert O'Hara, Redmond Washington, April 2009. Based on code written by Paul Edwards and modified by Dave Wade. Released to the public domain.

License: The Unlicense

C 99.11% C++ 0.33% Shell 0.46% CMake 0.10%

cms-370-gcclib's People

Contributors

adesutherland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cms-370-gcclib's Issues

READ WRITE functions in gcclib

In converting old gcc code READ and WRITE are used instead of fputs and fgets. It would be very helpful it READ and WRITE were added. They are basically fputs and fgets, but the variables are in different order. Not a big deal but
would really help in old gcc code conversion.

Default Signal Handlers

These can't be linked with GCCRES because real functions are used (and they don't exist in the client program).

We need to change these to fake pointers (as hinted by the standards)

Facility for "Process Global Memory" for programs running in read-only TEXT segments

Two functions to help C programs 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 - Process Global Memory.

void* CMSPGAll(size_t size) - Allocate / Reallocate Process Global Memory Block
void* CMSGetPG(void) - Get the address of the Process Global Memory Block

Note: that this area is freed automatically on normal program termination.

This will be implemented by malloced memory pointed to by a member in the GCCCRAB (which can always be found indirectly via R13).

fopen() Error

fopen("Fn ft" ...) - i.e. without the fm causes a freeze/loop

READONLYCODE build option/flag needed

These are mandated C standard globals. These have been moved from the RESLIB GCCLIB to the stub code of the client program. But of course for BREXX that also needs not to have these globals!

/* Stdlib Public Global Variables */
FILE stdin; / predefined stream for standard input: we map it to console */
FILE stdout; / predefined stream for standard output: we map it to console */
FILE stderr; / predefined stream for error output: we map it to console /
int errno = 0; /
Std error number */

In cmsrtstb.c

Anyway - we need to add a READONLYCODE build option/flag - that will instead make these available as macros for client programs like BREXX that are targeting a shared segment.

Arguments not always null terminated

Note the call sequence : 8 chars resident followed by 8 chars non-resident (weird - not to say wired!)

When running BREXX resident with a 8 char name
REXXVERS

followed by nonresident BREXX with a 8 char name
BREXX version1
gives
Arg 0=(BREXX)
Arg 1=(VERSION1S)

Note the S - it seems the last character of the resident run is appended

Set Storage for Stack

"Even if it doesn't do dynamic allocation, I'm surprised it doesn't get storage. (I'd bypass getmain, that's OS emulation)"

Calling / Receiving arguments flakey

Might be because it is not reentrant - might be because of the extended plist - who knows.

Anyway calls between programs struggle ...

Test programs below

argtest.c

#include <stdio.h>
int main(int argc, char *argv[]) {
int i;
printf("Argument Test\n");
for (i=0; i<argc; i++) {
printf("Arg %d is (%s)\n", i, argv[i]);
}
return 0;
}

calltest.c

#include <stdio.h>
#include <string.h>
#include <cmssys.h>
int main(int argc, char argv[]) {
int i;
char command[100];
printf("Call Test\n");
command[0]=0;
for (i=1; i<argc; i++) {
strcat(command, argv[i]);
strcat(command, " ");
}
printf("Command is (%s)\n", command);
return CMScommand(command,1); /
1=command, 11=typed */
}

Anchor Pointer Cannot be Stored in a Global

This is because of need to ensure that a program does not need to write to a global variable becuase they want to be run from a shared segment.

Waiting for a CMS Modification.

Incorrect parsing of CMS EPLIST command name field

I found this during BREXX testing of the CMS installer code. The parsing of
the EPLIST command name field is incorrect. When a command has no operands (like DMSREX),
and is issued within a CMS EXEC program (like SYSPROF EXEC) that is a vartiable length file, the
end of the command name is not found correctly. It was not found in the github test environment
because the SYSPROF EXEC had RECFM F. In CMSRUNTM C from release 0.8.2, change these lines
starting at line 122:

    a = 0;                                                                
    for (i = 0; i < 8; i++) {                                             
        ch = gcccrab->eplist->Command[i];                                 
        if (ch && ch != 0xFF && ch != ' ') gcccrab->argbuffer[a++] = ch;  
        else break;                                                       
    }     
    gcccrab->argbuffer[a++] = 0;                            
    gcccrab->argv[gcccrab->argc++] = gcccrab->argbuffer;    

Change code to this:

    len = gcccrab->eplist->BeginArgs - gcccrab->eplist->Command;      
    if (len > 8) len = 8;                                             
    a = 0;                                                            
    for (i = 0; i < len; i++) {                                       
        gcccrab->argbuffer[a++] = gcccrab->eplist->Command[i];        
    }                                                                 

Facility for "Library Global Memory" for programs running in read-only TEXT segments

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.

FSSTAT signature

int __FSSTAT(char * fileid, FST * fst)

should be

int __FSSTAT(char * fileid, FST ** fst)

i.e. a handle

Macros in ctype.h need reinstating for performance reasons

Macros in ctype.h need reinstating for performance reasons. This means that we need to be able to expose the RESLIB address of __isfuff[] etc. to a client program

extern unsigned short *__isbuf;
extern short *__tolow;
extern short *__toup;

#define isalnum(c) (__isbuf[(c)] & 0x0001U)
#define isalpha(c) (__isbuf[(c)] & 0x0002U)
#define iscntrl(c) (__isbuf[(c)] & 0x0004U)
#define isdigit(c) (__isbuf[(c)] & 0x0008U)
#define isgraph(c) (__isbuf[(c)] & 0x0010U)
#define islower(c) (__isbuf[(c)] & 0x0020U)
#define isprint(c) (__isbuf[(c)] & 0x0040U)
#define ispunct(c) (__isbuf[(c)] & 0x0080U)
#define isspace(c) (__isbuf[(c)] & 0x0100U)
#define isupper(c) (__isbuf[(c)] & 0x0200U)
#define isxdigit(c) (__isbuf[(c)] & 0x0400U)
#define tolower(c) (__tolow[(c)])
#define toupper(c) (__toup[(c)])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.