Skip to content

Commit bfeb736

Browse files
author
dtrg
committed
Stripped down the library to something approaching the ANSI C minimum and replaced most of the header files, to provide a reasonably consistent base to work up from.
1 parent 740940c commit bfeb736

32 files changed

+598
-800
lines changed

lang/cem/libcc.ansi/headers/LIST

Lines changed: 0 additions & 20 deletions
This file was deleted.

lang/cem/libcc.ansi/headers/Makefile

Lines changed: 0 additions & 2 deletions
This file was deleted.

lang/cem/libcc.ansi/headers/assert.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
*/
77
/* $Id$ */
88

9-
void __bad_assertion(const char *_mess);
9+
#ifndef _ASSERT_H
10+
#define _ASSERT_H
11+
12+
extern void __bad_assertion(const char *_mess);
1013

1114
#undef assert
1215

@@ -21,3 +24,5 @@ void __bad_assertion(const char *_mess);
2124
"\" failed, file " __xstr(__FILE__) \
2225
", line " __xstr(__LINE__) "\n"))
2326
#endif /* NDEBUG */
27+
28+
#endif

lang/cem/libcc.ansi/headers/ctype.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
/* $Id$ */
55

6-
#if !defined(_CTYPE_H)
6+
#ifndef _CTYPE_H
77
#define _CTYPE_H
88

99
extern char __ctype[]; /* located in chartab.c */
@@ -16,19 +16,19 @@ extern char __ctype[]; /* located in chartab.c */
1616
#define _C 0x20 /* this bit is for control characters */
1717
#define _X 0x40 /* this bit is for hex digits [a-f] and [A-F]*/
1818

19-
int isalnum(int _c); /* alphanumeric [a-z], [A-Z], [0-9] */
20-
int isalpha(int _c); /* alphabetic */
21-
int iscntrl(int _c); /* control characters */
22-
int isdigit(int _c); /* digit [0-9] */
23-
int isgraph(int _c); /* graphic character */
24-
int islower(int _c); /* lower-case letter [a-z] */
25-
int isprint(int _c); /* printable character */
26-
int ispunct(int _c); /* punctuation mark */
27-
int isspace(int _c); /* white space sp, \f, \n, \r, \t, \v */
28-
int isupper(int _c); /* upper-case letter [A-Z] */
29-
int isxdigit(int _c); /* hex digit [0-9], [a-f], [A-F] */
30-
int tolower(int _c); /* convert to lower case character */
31-
int toupper(int _c); /* convert to upper case character */
19+
extern int isalnum(int _c); /* alphanumeric [a-z], [A-Z], [0-9] */
20+
extern int isalpha(int _c); /* alphabetic */
21+
extern int iscntrl(int _c); /* control characters */
22+
extern int isdigit(int _c); /* digit [0-9] */
23+
extern int isgraph(int _c); /* graphic character */
24+
extern int islower(int _c); /* lower-case letter [a-z] */
25+
extern int isprint(int _c); /* printable character */
26+
extern int ispunct(int _c); /* punctuation mark */
27+
extern int isspace(int _c); /* white space sp, \f, \n, \r, \t, \v */
28+
extern int isupper(int _c); /* upper-case letter [A-Z] */
29+
extern int isxdigit(int _c); /* hex digit [0-9], [a-f], [A-F] */
30+
extern int tolower(int _c); /* convert to lower case character */
31+
extern int toupper(int _c); /* convert to upper case character */
3232

3333
#define isalpha(c) ((__ctype+1)[c]&(_U|_L))
3434
#define isspace(c) ((__ctype+1)[c]&_S)

lang/cem/libcc.ansi/headers/dirent.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

lang/cem/libcc.ansi/headers/errno.h

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,51 @@
33
*/
44
/* $Id$ */
55

6-
#if !defined(_ERRNO_H)
6+
#ifndef _ERRNO_H
77
#define _ERRNO_H
88

9-
#include <sys/errno.h>
9+
/* These values are defined by the ANSI standard. */
1010

11-
/* The standard requires the next two definitions. If they are also in
12-
* <sys/errno.h>, their values should be equal. The <sys/errno.h> supplied
13-
* with the compiler doesn't contain them.
14-
*/
15-
#define EDOM 33 /* math arg out of domain of func */
16-
#define ERANGE 34 /* math result not representable */
11+
#define EDOM 33
12+
#define ERANGE 34
13+
#define EILSEQ 88
1714

18-
extern int errno; /* error number */
15+
/* These are not, but most platforms standardise on these numbers, so we
16+
* define them here. */
17+
18+
#define EPERM 1 /* Not owner */
19+
#define ENOENT 2 /* No such file or directory */
20+
#define ESRCH 3 /* No such process */
21+
#define EINTR 4 /* Interrupted system call */
22+
#define EIO 5 /* I/O error */
23+
#define ENXIO 6 /* No such device or address */
24+
#define E2BIG 7 /* Arg list too long */
25+
#define ENOEXEC 8 /* Exec format error */
26+
#define EBADF 9 /* Bad file number */
27+
#define ECHILD 10 /* No children */
28+
#define EAGAIN 11 /* No more processes */
29+
#define ENOMEM 12 /* Not enough core */
30+
#define EACCES 13 /* Permission denied */
31+
#define EFAULT 14 /* Bad address */
32+
#define ENOTBLK 15 /* Block device required */
33+
#define EBUSY 16 /* Mount device busy */
34+
#define EEXIST 17 /* File exists */
35+
#define EXDEV 18 /* Cross-device link */
36+
#define ENODEV 19 /* No such device */
37+
#define ENOTDIR 20 /* Not a directory*/
38+
#define EISDIR 21 /* Is a directory */
39+
#define EINVAL 22 /* Invalid argument */
40+
#define ENFILE 23 /* File table overflow */
41+
#define EMFILE 24 /* Too many open files */
42+
#define ENOTTY 25 /* Not a typewriter */
43+
#define ETXTBSY 26 /* Text file busy */
44+
#define EFBIG 27 /* File too large */
45+
#define ENOSPC 28 /* No space left on device */
46+
#define ESPIPE 29 /* Illegal seek */
47+
#define EROFS 30 /* Read-only file system */
48+
#define EMLINK 31 /* Too many links */
49+
#define EPIPE 32 /* Broken pipe */
50+
51+
extern int errno;
1952

20-
#endif /* _ERRNO_H */
53+
#endif
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* fcntl.h - file I/O primitives
3+
*/
4+
/* $Id$ */
5+
6+
#ifndef _FCNTL_H
7+
#define _FCNTL_H
8+
9+
#include <unistd.h>
10+
11+
#endif
Lines changed: 42 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,43 @@
11
/*
2-
* float.h - implementation limits
3-
*/
4-
/* $Id$ */
5-
6-
#if !defined(_FLOAT_H)
7-
#define _FLOAT_H
8-
9-
#if defined(__vax) || defined(__pdp)
10-
#define FLT_DIG 6
11-
#define FLT_EPSILON 5.96046448e-08F
12-
#define FLT_MANT_DIG 8
13-
#define FLT_MAX 1.70141173e+38F
14-
#define FLT_MAX_10_EXP 38
15-
#define FLT_MAX_EXP 127
16-
#define FLT_MIN 2.93873588e-39F
17-
#define FLT_MIN_10_EXP (-38)
18-
#define FLT_MIN_EXP (-127)
19-
20-
#define DBL_DIG 16
21-
#define DBL_EPSILON 1.38777878078144568e-17
22-
#define DBL_MANT_DIG 8
23-
#define DBL_MAX 1.70141183460469229e+38
24-
#define DBL_MAX_10_EXP 38
25-
#define DBL_MAX_EXP 127
26-
#define DBL_MIN 2.93873587705571877e-39
27-
#define DBL_MIN_10_EXP (-38)
28-
#define DBL_MIN_EXP (-127)
29-
30-
#define LDBL_DIG 16
31-
#define LDBL_EPSILON 1.38777878078144568e-17L
32-
#define LDBL_MANT_DIG 8
33-
#define LDBL_MAX 1.70141183460469229e+38L
34-
#define LDBL_MAX_10_EXP 38
35-
#define LDBL_MAX_EXP 127
36-
#define LDBL_MIN 2.93873587705571877e-39L
37-
#define LDBL_MIN_10_EXP (-38)
38-
#define LDBL_MIN_EXP (-127)
39-
40-
#define FLT_ROUNDS 1
41-
#define FLT_RADIX 2
42-
43-
#else /* IEEE format */
44-
#define FLT_DIG 6
45-
#define FLT_EPSILON 1.19209290e-07F
46-
#define FLT_MANT_DIG 24
47-
#define FLT_MAX 3.40282347e+38F
48-
#define FLT_MAX_10_EXP 38
49-
#define FLT_MAX_EXP 128
50-
#define FLT_MIN 1.17549435e-38F
51-
#define FLT_MIN_10_EXP (-37)
52-
#define FLT_MIN_EXP (-125)
53-
54-
#define DBL_DIG 15
55-
#define DBL_EPSILON 2.2204460492503131e-16
56-
#define DBL_MANT_DIG 53
57-
#define DBL_MAX 1.7976931348623157e+308
58-
#define DBL_MAX_10_EXP 308
59-
#define DBL_MAX_EXP 1024
60-
#define DBL_MIN 2.2250738585072014e-308
61-
#define DBL_MIN_10_EXP (-307)
62-
#define DBL_MIN_EXP (-1021)
63-
64-
#define LDBL_DIG 15
65-
#define LDBL_EPSILON 2.2204460492503131e-16L
66-
#define LDBL_MANT_DIG 53
67-
#define LDBL_MAX 1.7976931348623157e+308L
68-
#define LDBL_MAX_10_EXP 308
69-
#define LDBL_MAX_EXP 1024
70-
#define LDBL_MIN 2.2250738585072014e-308L
71-
#define LDBL_MIN_10_EXP (-307)
72-
#define LDBL_MIN_EXP (-1021)
73-
74-
#define FLT_ROUNDS 1
75-
#define FLT_RADIX 2
76-
77-
#endif /* vax, pdp or ieee */
78-
79-
#endif /* _FLOAT_H */
2+
<float.h> -- simple version used by "gimplify"
3+
4+
last edit: 2007-02-12 D A Gwyn
5+
*/
6+
7+
/* Does not exactly fit any model, and is minimal for "universality". */
8+
9+
#define FLT_ROUNDS (-1)
10+
#define FLT_EVAL_METHOD (-1)
11+
#define FLT_RADIX 2
12+
#define DECIMAL_DIG 10
13+
14+
/* assumes that "gimplify" specifies "-Dfloat=double" */
15+
#define FLT_MANT_DIG 10
16+
#define FLT_EPSILON (1E-9F)
17+
#define FLT_DIG 10
18+
#define FLT_MIN_EXP (-31)
19+
#define FLT_MIN (1E-37F)
20+
#define FLT_MIN_10_EXP (-37)
21+
#define FLT_MAX_EXP 37
22+
#define FLT_MAX (1E+37F)
23+
#define FLT_MAX_10_EXP 37
24+
25+
#define DBL_MANT_DIG 10
26+
#define DBL_EPSILON (1E-9)
27+
#define DBL_DIG 10
28+
#define DBL_MIN_EXP (-31)
29+
#define DBL_MIN (1E-37)
30+
#define DBL_MIN_10_EXP (-37)
31+
#define DBL_MAX_EXP 37
32+
#define DBL_MAX (1E+37)
33+
#define DBL_MAX_10_EXP 37
34+
35+
#define LDBL_MANT_DIG 10
36+
#define LDBL_EPSILON (1E-9L)
37+
#define LDBL_DIG 10
38+
#define LDBL_MIN_EXP (-31)
39+
#define LDBL_MIN (1E-37L)
40+
#define LDBL_MIN_10_EXP (-37)
41+
#define LDBL_MAX_EXP 37
42+
#define LDBL_MAX (1E+37L)
43+
#define LDBL_MAX_10_EXP 37

lang/cem/libcc.ansi/headers/grp.h

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* limits.h - implementation limits
3+
*/
4+
/* $Id$ */
5+
6+
#ifndef _ISO646_H
7+
#define _ISO646_H
8+
9+
#define and &&
10+
#define and_eq &=
11+
#define bitand &
12+
#define bitor |
13+
#define compl ~
14+
#define not !
15+
#define not_eq !=
16+
#define or ||
17+
#define or_eq |=
18+
#define xor ^
19+
#define xor_eq ^=
20+
21+
#endif

0 commit comments

Comments
 (0)