Trailing-Edge
-
PDP-10 Archives
-
SRI_NIC_PERM_FS_1_19910112
-
c/lib5/old-carm.doc
There are no other files named old-carm.doc in the archive.
CARM.DOC - CARM library status
CARM refers to the book "C: A Reference Manual" by Harbison
and Steele; this is also known as "H&S". This file summarizes the
status of all CARM-described library routines, following the same
organization as that found in the book.
For further reference, the file LIBC.DOC describes all of
the KCC library routines, following their organization on disk rather
than that of H&S.
Note: As of this writing there are two versions of CARM; the first
(V1 or I) appeared in 1984, and the second (V2 or II) in 1987. Unless
otherwise stated, all references are to the most recent (V2) version, and
the organization of this file follows sections 13-22 of V2 rather than
section 11 of V1.
The routines of each section are described in the following form:
Name Module Port-status Comments
(routine name) (source file) (see below)
Port-status code:
E = file #includes "c-env.h" for environment config.
*10 = portable to all PDP-10 OS (T20,10X,T10,WAITS,ITS)
* = fully portable (either no OS-dependent stuff, or a
fully-portable conditional exists)
<sys> - runs on the given sys, one of: T20,10X,T10,WAITS,ITS.
Section 13: Standard Language Additions - unfinished
NULL <stddef.h>,<stdio.h> *
ptrdiff_t <stddef.h> *
size_t <stddef.h> *
int errno; <.USYS>URT *
char *strerror(errnum); <.STDIO>PERROR E T20,10X
void perror(s); <.STDIO>PERROR E T20,10X
constant EDOM; <errno.h> *
constant ERANGE; <errno.h> *
__DATE__ NOT YET (in KCC)
__FILE__ in KCC
__LINE__ in KCC
__TIME__ NOT YET (in KCC)
__STDC__ NOT YET (in KCC)
va_alist,va_dcl <varargs.h> * KCC Non-ANSI form
va_list,va_start,va_arg,va_end <varargs.h> * KCC Non-ANSI form
va_list,va_start,va_arg,va_end <stdarg.h> * KCC ANSI form
Section 14 (V1 11.1): Character Processing - COMPLETE
<ctype.h> and <C.LIB>CTYPE.C implement everything.
<C.LIB.TEST>TCTYPE.C tests all these functions.
int isalnum(c); CTYPE *
int isalpha(c); CTYPE *
int isascii(i); CTYPE *
int iscntrl(c); CTYPE *
int iscsym(c); CTYPE *
int iscsymf(c); CTYPE *
int isdigit(c); CTYPE *
int isodigit(c); CTYPE *
int isxdigit(c); CTYPE *
int isgraph(c); CTYPE *
int isprint(c); CTYPE *
int ispunct(c); CTYPE * DIFFERENT (no space!) CARM goofed.
int islower(c); CTYPE *
int isupper(c); CTYPE *
int isspace(c); CTYPE *
int iswhite(c); - - rare variant of standard isspace, not provided.
int toascii(i); CTYPE *
int toint(c); CTYPE *
int tolower(c); CTYPE * allows any case
int toupper(c); CTYPE * allows any case
int _tolower(c); CTYPE *
int _toupper(c); CTYPE *
Notes:
The flag table is large enough that any unsigned 9-bit char
value can be safely used as index. Also, on the PDP-10 this is an
integer array for speed. This is fully portable, but the macro
_CT_TABTYPE can be defined if a char array is preferable.
<ctype.h> defines all of the macros. CTYPE.C defines the
_ctyp1 and _ctyp2 tables, plus some small auxiliary routines that the
macros may call.
Section 15 (V1 11.2): String Processing - COMPLETE
<string.h> and <C.LIB>STRING.C implement everything.
<C.LIB.TEST>TSTRIN.C partially tests this suite.
For BSD compatibility, the file <strings.h> exists; it just
includes <string.h>.
char *strcat(s1,s2); STRING *
char *strncat(s1,s2,n); STRING *
int strcmp(s1,s2); STRING *
int strncmp(s1,s2,n); STRING *
char *strcpy(s1,s2); STRING *
char *strncpy(s1,s2,n); STRING *
int strlen(s); STRING *
char *strchr(s,c); STRING *
char *index(s,c); STRING *
int strpos(s,c); STRING *
char *strrchr(s,c); STRING *
char *rindex(s,c); STRING *
int strrpos(s,c); STRING *
int strspn(s,set); STRING *
int strcspn(s,set); STRING *
char *strpbrk(s,set); STRING *
char *strrpbrk(s,set); STRING *
char *strstr(src, sub); STRING * New ANSI function
char *strtok(str, set); STRING * ANSI/BSD/S5/CARM
double strtod(str, ptr); ATOI *
long strtol(str,ptr,base); ATOI *
unsigned long strtoul(str,p,b); ATOI *
double atof(str); ATOI *
int atoi(str); ATOI *
long atol(str); ATOI *
Notes:
This stuff can use more conditionalizing in order to optimize for
specific configurations. The routines are portable, but are coded to
encourage use of the PDP-10 ILDB/IDPB instructions (opposite of the optimal
PDP-11 order!)
Additional non-case-sensitive versions of the above functions are
provided by the STRUNG library, declared in <strung.h>:
int strCMP(s1, s2); STRUNG *
int strnCMP(s1, s2, n); STRUNG *
char *strCHR(s, c); STRUNG *
char *strSTR(src, sub); STRUNG *
Section 16: Memory Functions - COMPLETE
Implemented by <C.LIB>MEMSTR.C
<C.LIB.TEST>TBCOPY.C tests bcopy() and bzero().
The file <memory.h> exists for BSD compatibility; it just includes
<string.h>.
char *memchr(ptr,val,len); MEMSTR E * ANSI/BSD/S5/CARM
int memcmp(ptr1,ptr2,len); MEMSTR E * ANSI/BSD/S5/CARM
int bcmp(ptr1,ptr2,len); MEMSTR E * BSD/CARM
char *memcpy(dest,src,len); MEMSTR E * ANSI/BSD/S5/CARM
char *memccpy(dest,src,len); MEMSTR E * BSD/S5/CARM
void *memmove(dest,src,len); MEMSTR E * ANSI/CARM (needs more optimiz)
char *bcopy(src,dest,len); MEMSTR E * BSD/CARM
char *memset(ptr,val,len); MEMSTR E * ANSI/BSD/S5/CARM
void bzero(ptr,len); MEMSTR E * BSD/CARM
Section 17 (V1 11.5): Input/Output Facilities (V1: "Standard I/O") - COMPLETE
See <C.LIB.STDIO>-READ-.-THIS- for implementation-specific details.
There are assorted test programs for various aspects of STDIO, but
nothing too comprehensive. <C.LIB.TEST>TFSEEK.C, TFTEL1.C, TFTEL2.C
all test the complicated fseek/ftell positioning scheme; TPRINT.C
tests printf().
constant EOF; <stdio.h> *
struct FILE; <stdio.h> *
FILE *fopen(path,typ); FOPEN * Has additional flags! (doc 'em)
int fclose(fp); FCLOSE *
int fflush(fp); FFLUSH * also works on input streams
FILE *freopen(path,typ,fp); FREOPE *
int setvbuf(fp,buf,type,size); SETBUF *
void setbuf(fp,buf); SETBUF * also _sobuf[], for what?
FILE *stdin; <stdio.h> (m) *
FILE *stdout; <stdio.h> (m) *
FILE *stderr; <stdio.h> (m) *
int fseek(fp,off,typ); FSEEK *
long ftell(fp); FTELL *
void rewind(fp); REWIND *
int fgetc(fp); FGETC *
int getc(fp); <stdio.h> (m) *
int getchar(); <stdio.h> (m) *
int ungetc(c,fp); UNGETC *
char *fgets(s,n,fp); FGETS *
char *gets(s); GETS *
int fscanf(fp,fmt,ptrs); SCANF *
int scanf(fmt,ptrs); SCANF *
int sscanf(s,fmt,ptrs); SCANF *
int fputc(c,fp); FPUTC *
int putc(c,fp); <stdio.h> (m) *
int putchar(c); <stdio.h> (m) *
int fputs(s,fp); FPUTS *
int puts(s); PUTS *
int fprintf(fp,fmt,args); PRINTF *
int printf(fmt,args); PRINTF *
int sprintf(s,fmt,args); PRINTF *
int vfprintf(fp,fmt,arg); PRINTF *
int vprintf(fmt,arg); PRINTF *
int vsprintf(s,fmt,arg); PRINTF *
int fread(ptr,siz,cnt,fp); FREAD *
int fwrite(ptr,siz,cnt,fp); FWRITE *
int feof(fp); <stdio.h> (m) *
int ferror(fp); <stdio.h> (m) *
void clearerr(fp); <stdio.h> (m) *
int remove(filename); REMOVE * just calls unlink()
int rename(oldnam,newnam); RENAME * null file, uses USYS rename().
FILE *tmpfile(); TMPFIL *
char *tmpnam(buf); TMPNAM E T20,10X
char *mktemp(buf); MKTEMP E T20,10X uses HPTIM%, not getpid
Additional non-CARM STDIO functions, most for V7/BSD compatibility:
constant BUFSIZ; <stdio.h> * V7/BSD
constant NULL; <stdio.h> * V7/BSD
FILE *fdopen(fd,type); FDOPEN * V7/BSD open w/existing FD
int getw(fp); GETW * V7/BSD Get word (int)
int putw(w,fp); PUTW * V7/BSD Put word (int)
void setbuffer(fp,buf,size); SETBUF * BSD
void setlinebuf(fp); SETBUF * BSD do linebuffering
FILE *sopen(s,type); SOPEN * (KCC only) open string for I/O
FILE _sios[]; <stdio.h> * internal array
void _cleanup(); CLEANU * called by exit() for cleanup
int _filbuf(fp); FILBUF * (KCC only) fill input buffer
These functions were seen in a write-up of ANSI C from Aug-87 Dr. Dobbs
int fgetpos(FILE *stream, fpos_t *pos)
int fsetpos(FILE *stream, const fpos_t *pos)
Section 18 (V1 11.4): Storage Allocation - COMPLETE
Source in <C.LIB>MALLOC.C
Tested with <C.LIB.TEST>TMALL1.C and TMALL2.C
char *malloc(size); MALLOC *
char *calloc(cnt,siz); MALLOC * calls malloc()
char *mlalloc(lsize); MALLOC * calls malloc()
char *clalloc(lcnt,lsize); MALLOC * calls malloc()
void free(ptr); MALLOC *
void cfree(ptr); MALLOC * calls free()
char *realloc(ptr,size); MALLOC *
char *relalloc(ptr,size); MALLOC * calls realloc()
bonus functions, non-CARM
int _palloc(n); allocate n pages of memory
void _pfree(page); free allocated pages
Notes:
The functions clalloc, mlalloc, and relalloc are peculiar to CARM.
ANSI does not have cfree, although BSD/CARM/V7 do.
The KCC functions conform to the ANSI descriptions of how they should
behave, particularly when given strange arguments like NULL pointers. This
is different from the behavior on BSD, where a zero size will still return
something from malloc and realloc (rather than ignoring and freeing).
Section 19 (V1 11.3): Mathematical Functions - COMPLETE
<C.LIB.MATH>MATH.H and a .C file for each function described below.
Tested with <C.LIB.TEST>TMATH.C
NOTE: Why don't we have good precision for atan()?? E-9 only
int abs(x); PRIMITIVE: C code
double fabs(x); PRIMITIVE: C code
long labs(x); PRIMITIVE: C code
div_t div(n,d); PRIMITIVE: C or PDP10 code
ldiv_t ldiv(n,d); PRIMITIVE: C or PDP10 code
double ceil(x); based on modf()
double floor(x); based on modf()
double fmod(x,y); based on modf()
double exp(x); PRIMITIVE: uses sign(), fabs(), modf(), ldexp()
double log(x); based on xexp(), xmant(), poly()
double log10(x); based on log()
double frexp(x,nptr); PRIMITIVE: mach dep C code
double ldexp(x,n); PRIMITIVE: mach dep C code
double modf(x,nptr); PRIMITIVE: mach dep ASM code
double pow(x,y); based on exp(), log(), modf()
double sqrt(x); based on xexp(), xmany(), ldexp()
int rand(); PRIMITIVE: mach dep C code
srand(seed); PRIMITIVE: C code
double cos(x); PRIMITIVE: uses fmod(), sin(), sqrt(), poly()
double sin(x); PRIMITIVE: uses fmod(), cos(), sqrt(), poly()
double tan(x); based on sin(), cos()
double acos(x); based on atan()
double asin(x); based on atan()
double atan(x); PRIMITIVE: uses sign(), poly()
double atan2(y,x); based on atan()
double cosh(x); based on exp()
double sinh(x); based on exp()
double tanh(x); based on exp()
additional support routines, NOT IN CARM:
double _sign(x, y); PRIMITIVE: C code
double _poly(x, y, z); PRIMITIVE: C code
int _xexp(x); PRIMITIVE: mach dep C code
double _xmant(x); PRIMITIVE: mach dep C code
NOTES ON MATH FUNCTIONS:
ANSI and CARM have the same functions. There are a few
differences about domain/range error specifications which are
minor. The BIG incompatibility is:
ANSI modf() is incompatible with CARM and BSD!
The 2nd arg is (double *) instead of (int *)!!!
The functions abs, labs, rand, and srand are declared in <stdlib.h> by
ANSI, in <math.h> by CARM.
BSD appears to have all CARM functions except labs() and fmod().
BSD has these functions which are not in ANSI or CARM:
(all return double unless otherwise indicated)
Documented in UPM: gamma, hypot, cabs, j0, h1, jn, y0, y1, yn
Undocumented: asinh, acosh, atanh, erf, erfc, expm1, log1p
rint, lgamma, copysign, drem, logb, scalb, cbrt
finite (returns int), infnan (VAX only)
Section 20: Time and Date Functions - COMPLETE
<C.LIB>CTIME.C and <C.LIB>CLOCK.C implement most of these.
<C.LIB.TEST>TTIME.C is the test program.
clock_t clock(); CLOCK E *10
clock_t <time.h>
CLK_TCK <time.h>
struct tms <sys/times.h>
void times(tmsbuf); <.USYS>TIMES
time_t time(tptr); <.USYS>TIME
time_t <time.h>
char *asctime(ts); CTIME E *10
char *ctime(timptr); CTIME E *10
struct tm *gmtime(t); CTIME E *10
struct tm *localtime(t); CTIME E *10
time_t mktime(tmptr); CTIME E *10
double difftime(t1,t0); CTIME E *10
Extra non-CARM functions:
char *timezone(mwest, dstt); CTIME E *10 For BSD/V7 compatibility (!S5)
struct tm *_lbrktime(); CTIME E ITS,T10,WAITS For use by <.USYS>TIME
int _tmisdst(); CTIME E ITS,T10,WAITS For use by <.USYS>TIME
Aug-87 Dobbs/ANSI also includes:
size_t strftime(char *s, size_t maxsize, const char *format);
Section 21: Control Functions - pretty much COMPLETE
These are in <.LIB> or <.LIB.USYS>.
macro assert(); <assert.h> *
int system(cmd); SYSTEM E T20,10X (partial implem)
exec*(); <.USYS>FORK E T20,10X (partial implem)
void exit(status); <.USYS>URT E T20,10X
void _exit(status); <.USYS>URT E T20,10X
void abort(); ABORT *10
typedef ... jmp_buf[]; <setjmp.h> E *10 KCC specific
int setjmp(env); SETJMP E *10 KCC specific
void longjmp(env,status); SETJMP E *10 KCC specific
typedef ... onexit_t; <stdlib.h> *
onexit_t onexit(func); ONEXIT *
constant SIG_IGN; <signal.h> *
constant SIG_DFL; <signal.h> *
constant SIG_ERR; <signal.h> *
constant SIGxxx; <signal.h> *
void (*signal(sig,func)); <.USYS>SIGNAL * See USYS.DOC
int raise(sig); <.USYS>SIGVEC E T20,10X See USYS.DOC
int kill(pid,sig); <.USYS>SIGVEC E T20,10X See USYS.DOC
int (*ssignal(softsig,func))(); SSIGNA *
int gsignal(softsig); SSIGNA *
void psignal(sig,prefix); PSIGNA *
void sleep(secs); <.USYS>SLEEP E *10 See USYS.DOC
unsigned alarm(secs); <.USYS>ALARM E T20 See USYS.DOC
Additional functions for BSD compatibility:
int _setjmp(env); SETJMP E *10
int _longjmp(env,val); SETJMP E *10
void longjmperror(); SETJMP E *10
In Aug-87 Dr. Dobbs they have, instead of onexit(),
int atexit(void(*func)(void))
Section 22: Miscellaneous Functions - COMPLETE
int main(argc,argv); user program
char *ctermid(s); CTERMI E T20
char *cuserid(s); CTERMI E T20
char *getcwd(buf,size); GETCWD E T20
char *getwd(path); GETCWD E T20
char *getenv(name); GETENV E T20 Note 10X does not have LNMST%.
char *getlogin(); GETLOG E T20
int getopt(argc,argv,optstr); GETOPT * Note other externals defined!
int putenv(namval); GETENV E T20
char *bsearch(ky,bs,ct,sz,cmp); BSEARC *
void qsort(base,cnt,siz,cmp); QSORT * GNU version
Aug-87 Dr. Dobbs shows this bizarro function (and the new header file
<locale.h>), of which I have no clue:
char *setlocale(int category, char *locale);