diff options
Diffstat (limited to 'src')
190 files changed, 411 insertions, 422 deletions
diff --git a/src/_syscall.h b/src/_syscall.h index 3a6f73c6..ca47048a 100644 --- a/src/_syscall.h +++ b/src/_syscall.h @@ -30,6 +30,8 @@ } while (0) long __syscall(long __number, ...); +#define __scall0(_n) \ + __syscall(__syscall_lookup(_n)) #define __scall1(_n, _1) \ __syscall(__syscall_lookup(_n), _1) #define __scall2(_n, _1, _2) \ diff --git a/src/assert/__assert.c b/src/assert/__assert.c index 630fdec1..22b6108c 100644 --- a/src/assert/__assert.c +++ b/src/assert/__assert.c @@ -1,6 +1,5 @@ -#include <assert.h> -#include "stdio.h" -#include "stdlib.h" +#include <stdio.h> +#include <stdlib.h> void __assert(const char *expr, const char *file, int line, const char *func) { diff --git a/src/assert/assert.c b/src/assert/assert.c index 3a3d2f4f..d49d9800 100644 --- a/src/assert/assert.c +++ b/src/assert/assert.c @@ -1,20 +1,14 @@ -#include <assert.h> - #undef assert #ifdef NDEBUG - -#define assert(__exp) ((void)0) - +# define assert(__exp) ((void)0) #else - -#if __STDC_VERSION__ < 199901L -#define __func__ ((char*)0) -#endif - -#define assert(__exp) \ - ((void)((__exp) || (__assert(#__exp, __FILE__, __LINE__, __func__), 0))) - +# if __STDC_VERSION__ < 199901L +# define __func__ ((char*)0) +# endif +# define assert(__exp) \ + ((void)((__exp) || \ + (__assert(#__exp, __FILE__, __LINE__, __func__), 0))) #endif /* in c89 - void assert(int expression); */ diff --git a/src/ctype/isalnum.c b/src/ctype/isalnum.c index d60efaeb..8c0f128e 100644 --- a/src/ctype/isalnum.c +++ b/src/ctype/isalnum.c @@ -1,5 +1,5 @@ #include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" /** test whether a character is alphanumeric **/ diff --git a/src/ctype/isalpha.c b/src/ctype/isalpha.c index 876662ad..4be702bc 100644 --- a/src/ctype/isalpha.c +++ b/src/ctype/isalpha.c @@ -1,5 +1,5 @@ #include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" /** test whether a character is alphabetic **/ diff --git a/src/ctype/iscntrl.c b/src/ctype/iscntrl.c index 06046732..0e029751 100644 --- a/src/ctype/iscntrl.c +++ b/src/ctype/iscntrl.c @@ -1,5 +1,4 @@ -#include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" #include "_ctype.h" diff --git a/src/ctype/isdigit.c b/src/ctype/isdigit.c index beb689a1..3577ec55 100644 --- a/src/ctype/isdigit.c +++ b/src/ctype/isdigit.c @@ -1,5 +1,5 @@ #include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" /** test whether a character is a digit **/ diff --git a/src/ctype/isgraph.c b/src/ctype/isgraph.c index 4ff0c92e..e2cca5d2 100644 --- a/src/ctype/isgraph.c +++ b/src/ctype/isgraph.c @@ -1,5 +1,4 @@ -#include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" #include "_ctype.h" diff --git a/src/ctype/islower.c b/src/ctype/islower.c index fe65b034..9e151725 100644 --- a/src/ctype/islower.c +++ b/src/ctype/islower.c @@ -1,5 +1,4 @@ -#include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" #include "_ctype.h" diff --git a/src/ctype/isprint.c b/src/ctype/isprint.c index 62d24126..cad5fe1d 100644 --- a/src/ctype/isprint.c +++ b/src/ctype/isprint.c @@ -1,5 +1,4 @@ -#include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" #include "_ctype.h" diff --git a/src/ctype/ispunct.c b/src/ctype/ispunct.c index 9a7656c5..cea5446d 100644 --- a/src/ctype/ispunct.c +++ b/src/ctype/ispunct.c @@ -1,5 +1,4 @@ -#include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" #include "_ctype.h" diff --git a/src/ctype/isspace.c b/src/ctype/isspace.c index b2bcb553..9d274399 100644 --- a/src/ctype/isspace.c +++ b/src/ctype/isspace.c @@ -1,5 +1,4 @@ -#include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" #include "_ctype.h" diff --git a/src/ctype/isupper.c b/src/ctype/isupper.c index 1d06124f..c2b06f1f 100644 --- a/src/ctype/isupper.c +++ b/src/ctype/isupper.c @@ -1,5 +1,4 @@ -#include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" #include "_ctype.h" diff --git a/src/ctype/isxdigit.c b/src/ctype/isxdigit.c index 9d6d7c6c..35f2e9e7 100644 --- a/src/ctype/isxdigit.c +++ b/src/ctype/isxdigit.c @@ -1,5 +1,4 @@ -#include <ctype.h> -#include "limits.h" +#include <limits.h> #include "_assert.h" #include "_ctype.h" diff --git a/src/ctype/tolower.c b/src/ctype/tolower.c index 3da90645..3a16dbab 100644 --- a/src/ctype/tolower.c +++ b/src/ctype/tolower.c @@ -1,6 +1,5 @@ -#include <ctype.h> -#include "stdio.h" -#include "limits.h" +#include <stdio.h> +#include <limits.h> #include "_ctype.h" /** convert an uppercase letter to lowercase **/ diff --git a/src/ctype/toupper.c b/src/ctype/toupper.c index 3addcada..741b6784 100644 --- a/src/ctype/toupper.c +++ b/src/ctype/toupper.c @@ -1,6 +1,5 @@ -#include <ctype.h> -#include "stdio.h" -#include "limits.h" +#include <stdio.h> +#include <limits.h> #include "_ctype.h" /** convert a lowercase letter to uppercase **/ diff --git a/src/errno/EDOM.c b/src/errno/EDOM.c index 927df956..ea1999d7 100644 --- a/src/errno/EDOM.c +++ b/src/errno/EDOM.c @@ -1,10 +1,12 @@ -#include <errno.h> #define EDOM (1) + /** domain error **/ + /*** is used to indicate that an argument supplied to a function is outside the defined input domain. ***/ + /* STDC(1) */ diff --git a/src/errno/ERANGE.c b/src/errno/ERANGE.c index c3c757e4..c6fb0bdf 100644 --- a/src/errno/ERANGE.c +++ b/src/errno/ERANGE.c @@ -1,9 +1,11 @@ -#include <errno.h> #define ERANGE (2) + /** out of range **/ + /*** is used to indicated that the result of an operation is too large or too small. ***/ + /* STDC(1) */ diff --git a/src/errno/__errno.c b/src/errno/__errno.c index 9ab71722..e4a329f2 100644 --- a/src/errno/__errno.c +++ b/src/errno/__errno.c @@ -1,4 +1,3 @@ -#include <errno.h> #include "_perthread.h" /* diff --git a/src/errno/errno.c b/src/errno/errno.c index 007526b8..c0f379c5 100644 --- a/src/errno/errno.c +++ b/src/errno/errno.c @@ -1,4 +1,3 @@ -#include <errno.h> #define errno (*__errno()) /** get system errors **/ @@ -16,8 +15,5 @@ description. UNSPECIFIED(Whether THIS() is declared as a macro or an identifier with external linkage (C89, C95, and C99 only)) UNDEFINED(A macro definition of THIS() is suppressed) UNDEFINED(A program defines an identifier named THIS()) -*/ - -/* STDC(1) */ diff --git a/src/locale/LC_ALL.c b/src/locale/LC_ALL.c index 164a18ae..12702e1a 100644 --- a/src/locale/LC_ALL.c +++ b/src/locale/LC_ALL.c @@ -1,4 +1,3 @@ -#include <locale.h> #define LC_ALL (0) /** all locale categories **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(category) in a call to FUNCTION(setlocale) to operate on all categories of the current locale. ***/ + /* STDC(1) */ diff --git a/src/locale/LC_COLLATE.c b/src/locale/LC_COLLATE.c index 2708525c..ea46b97f 100644 --- a/src/locale/LC_COLLATE.c +++ b/src/locale/LC_COLLATE.c @@ -1,4 +1,3 @@ -#include <locale.h> #define LC_COLLATE (1) /** locale collation category **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(category) in a call to FUNCTION(setlocale) to operate on the portion of the locale that affects sorting and collating strings. ***/ + /* STDC(1) */ diff --git a/src/locale/LC_CTYPE.c b/src/locale/LC_CTYPE.c index 9095cf60..cfe07f22 100644 --- a/src/locale/LC_CTYPE.c +++ b/src/locale/LC_CTYPE.c @@ -1,4 +1,3 @@ -#include <locale.h> #define LC_CTYPE (2) /** locale character handling category **/ @@ -8,6 +7,7 @@ is used as the ARGUMENT(category) in a call to FUNCTION(setlocale) to operate on the portion of the locale that affects classifying and transforming individual characters. ***/ + /* STDC(1) */ diff --git a/src/locale/LC_MONETARY.c b/src/locale/LC_MONETARY.c index cdc94832..82b5ca1c 100644 --- a/src/locale/LC_MONETARY.c +++ b/src/locale/LC_MONETARY.c @@ -1,4 +1,3 @@ -#include <locale.h> #define LC_MONETARY (3) /** locale monetary formatting category **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(category) in a call to FUNCTION(setlocale) to operate on the portion of the locale that affects formatting monetary values. ***/ + /* STDC(1) */ diff --git a/src/locale/LC_NUMERIC.c b/src/locale/LC_NUMERIC.c index 80459086..1c874956 100644 --- a/src/locale/LC_NUMERIC.c +++ b/src/locale/LC_NUMERIC.c @@ -1,4 +1,3 @@ -#include <locale.h> #define LC_NUMERIC (4) /** locale number formatting category **/ @@ -8,6 +7,7 @@ is used as the ARGUMENT(category) in a call to FUNCTION(setlocale) to operate on the portion of the locale that affects formatting numeric values, except for monetary values. ***/ + /* STDC(1) */ diff --git a/src/locale/LC_TIME.c b/src/locale/LC_TIME.c index e3e70662..f97a70a8 100644 --- a/src/locale/LC_TIME.c +++ b/src/locale/LC_TIME.c @@ -1,4 +1,3 @@ -#include <locale.h> #define LC_TIME (5) /** locale time formatting category **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(category) in a call to FUNCTION(setlocale) to operate on the portion of the locale that affects formatting date and time values. ***/ + /* STDC(1) */ diff --git a/src/locale/NULL.ref b/src/locale/NULL.ref index e1d480f2..b247705b 100644 --- a/src/locale/NULL.ref +++ b/src/locale/NULL.ref @@ -1,3 +1,2 @@ -#include <locale.h> REFERENCE(stddef/NULL.c) STDC(1) diff --git a/src/locale/__load_locale.c b/src/locale/__load_locale.c index f25392f8..66177eb6 100644 --- a/src/locale/__load_locale.c +++ b/src/locale/__load_locale.c @@ -1,19 +1,11 @@ -#include "locale.h" -#include "limits.h" -#include "stdio.h" -#include "string.h" +#include <locale.h> +#include <limits.h> +#include <stdio.h> +#include <string.h> #include "_locale.h" #include "ctype/_ctype.h" -#define LC_COLLATE_MASK (1<<0) -#define LC_CTYPE_MASK (1<<1) -#define LC_MONETARY_MASK (1<<2) -#define LC_NUMERIC_MASK (1<<3) -#define LC_TIME_MASK (1<<4) -#define LC_MESSAGES_MASK (1<<5) -#define LC_ALL_MASK (0xff) - #define setall(_map, _input, _mask) do { \ size_t _i; \ for (_i = 0; _i < sizeof(_input) - 1; _i++) { \ @@ -218,6 +210,7 @@ char * __load_locale(struct __locale_t *loc, int mask, const char *name) } } + #ifdef LC_MESSAGES if (mask & LC_MESSAGES_MASK) { strcpy(loc->messages, name); @@ -230,6 +223,7 @@ char * __load_locale(struct __locale_t *loc, int mask, const char *name) loc->lc_messages.noexpr = NULL; } } + #endif return (char*)name; } diff --git a/src/locale/_locale.h b/src/locale/_locale.h index 8f974ef3..3ca6c546 100644 --- a/src/locale/_locale.h +++ b/src/locale/_locale.h @@ -4,6 +4,34 @@ #include <locale.h> #include <limits.h> +#ifndef LC_ALL_MASK +#include "LC_ALL_MASK.c" +#endif + +#ifndef LC_COLLATE_MASK +#include "LC_COLLATE_MASK.c" +#endif + +#ifndef LC_CTYPE_MASK +#include "LC_CTYPE_MASK.c" +#endif + +#ifndef LC_NUMERIC_MASK +#include "LC_NUMERIC_MASK.c" +#endif + +#ifndef LC_TIME_MASK +#include "LC_TIME_MASK.c" +#endif + +#ifndef LC_MESSAGES_MASK +#include "LC_MESSAGES_MASK.c" +#endif + +#ifndef LC_MONETARY_MASK +#include "LC_MONETARY_MASK.c" +#endif + struct __locale_t { char all[UCHAR_MAX]; diff --git a/src/locale/localeconv.c b/src/locale/localeconv.c index 0021c13a..90432faf 100644 --- a/src/locale/localeconv.c +++ b/src/locale/localeconv.c @@ -2,6 +2,7 @@ #include "_locale.h" /** return locale-specific information **/ + struct lconv * localeconv(void) { /* @@ -18,7 +19,5 @@ use in formatting numbers and monetary values. /* LC_MONETARY LC_NUMERIC -*/ -/* STDC(1) */ diff --git a/src/locale/setlocale.c b/src/locale/setlocale.c index 72478686..5b5dbcde 100644 --- a/src/locale/setlocale.c +++ b/src/locale/setlocale.c @@ -1,15 +1,9 @@ #include <locale.h> -#include "string.h" -#include "stdlib.h" +#include <string.h> +#include <stdlib.h> #include "_locale.h" -#include "LC_ALL_MASK.c" -#include "LC_COLLATE_MASK.c" -#include "LC_CTYPE_MASK.c" -#include "LC_NUMERIC_MASK.c" -#include "LC_TIME_MASK.c" -#include "LC_MESSAGES_MASK.c" -#include "LC_MONETARY_MASK.c" +/** get or set program locale **/ char * setlocale(int category, const char *locale) { @@ -47,8 +41,6 @@ char * setlocale(int category, const char *locale) return __load_locale(l, mask, locale); } -/** get or set program locale **/ - /*** sets or retrieves the current global locale of the program. The program locale has global effects of various operations, based @@ -89,7 +81,5 @@ to support std(POSIX). RETURN(CONSTANT(NULL), the request could not be honored) RETURN(NONNULL, the current locale name for ARGUMENT(category)) IMPLEMENTATION(The native environment) -*/ -/* STDC(1) */ diff --git a/src/locale/struct_lconv.c b/src/locale/struct_lconv.c index 6f71fa20..561c59c2 100644 --- a/src/locale/struct_lconv.c +++ b/src/locale/struct_lconv.c @@ -1,4 +1,3 @@ -#include <locale.h> struct lconv { /** The character that separates the whole and decimal portions of non-monetary values **/ char *decimal_point; /* "." */ @@ -60,6 +59,7 @@ struct lconv { }; /* values specified in comments are for the "C" locale */ + /* STDC(1) */ diff --git a/src/math/HUGE_VAL.c b/src/math/HUGE_VAL.c index f72afacf..04d6da01 100644 --- a/src/math/HUGE_VAL.c +++ b/src/math/HUGE_VAL.c @@ -1,4 +1,3 @@ -#include <math.h> #define HUGE_VAL (1.0) /* TODO: massive positive double */ /** a huge value **/ diff --git a/src/math/_tgmath.h b/src/math/_tgmath.h index 8cd7871b..0d6c9551 100644 --- a/src/math/_tgmath.h +++ b/src/math/_tgmath.h @@ -68,4 +68,12 @@ #define copysign(_x, _y) (_x < 0 ? -_y : _y) #endif +#ifndef M_PI +#include "M_PI.c" +#endif + +#ifndef M_PI_2 +#include "M_PI_2.c" +#endif + #endif diff --git a/src/math/acos.c b/src/math/acos.c index 9a356100..2d391fe2 100644 --- a/src/math/acos.c +++ b/src/math/acos.c @@ -1,10 +1,11 @@ # define TGSOURCE "acos.c" +#include <errno.h> +#include <fenv.h> #include <math.h> -#include "fenv.h" -#include "errno.h" #include "_tgmath.h" /** arc cosine **/ + TYPE TGFN(acos)(TYPE x) { if (TGFN(fabs)(x) > 1) { @@ -36,7 +37,5 @@ the range [-1, +1]. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/asin.c b/src/math/asin.c index a94338f5..5a6ca259 100644 --- a/src/math/asin.c +++ b/src/math/asin.c @@ -1,9 +1,10 @@ # define TGSOURCE "asin.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** arc sine **/ + TYPE TGFN(asin)(TYPE x) { if (TGFN(fabs)(x) > 1.0) { @@ -33,7 +34,5 @@ the range [-1, +1]. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/atan.c b/src/math/atan.c index 6d9eee63..267670d3 100644 --- a/src/math/atan.c +++ b/src/math/atan.c @@ -1,11 +1,10 @@ # define TGSOURCE "atan.c" +#include <errno.h> #include <math.h> -#include "errno.h" #include "_tgmath.h" -#include "M_PI_2.c" - /** arc tangent **/ + TYPE TGFN(atan)(TYPE x) { int MAXLOOPS = 10; @@ -50,7 +49,5 @@ compute the principal value of the arc tangent of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/atan2.c b/src/math/atan2.c index 38ba944e..8d7c1260 100644 --- a/src/math/atan2.c +++ b/src/math/atan2.c @@ -1,17 +1,11 @@ # define TGSOURCE "atan2.c" +#include <errno.h> #include <math.h> -#include "_tgmath.h" -#include "errno.h" #include "_assert.h" - -#include "M_PI.c" -#include "M_PI_2.c" - -#ifndef copysign -#define copysign(_x, _y) _x -#endif +#include "_tgmath.h" /** arc tangent **/ + TYPE TGFN(atan2)(TYPE y, TYPE x) { int classy = fpclassify(y); @@ -88,7 +82,5 @@ the correct quadrant. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/ceil.c b/src/math/ceil.c index d90ba15f..34a93fe3 100644 --- a/src/math/ceil.c +++ b/src/math/ceil.c @@ -1,9 +1,10 @@ # define TGSOURCE "ceil.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** round up to nearest integer **/ + TYPE TGFN(ceil)(TYPE x) { switch (fpclassify(x)) { @@ -30,7 +31,5 @@ than ARGUMENT(x), returning it as the same floating-point type as ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/cos.c b/src/math/cos.c index 86a1c995..437428c8 100644 --- a/src/math/cos.c +++ b/src/math/cos.c @@ -1,10 +1,11 @@ # define TGSOURCE "cos.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "fenv.h" -#include "errno.h" /** cosine **/ + TYPE TGFN(cos)(TYPE x) { int MAXLOOPS = 10; @@ -51,8 +52,6 @@ compute cosine of ARGUMENT(x), in radians. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/cosh.c b/src/math/cosh.c index 0f981e36..735c8cd4 100644 --- a/src/math/cosh.c +++ b/src/math/cosh.c @@ -1,9 +1,10 @@ # define TGSOURCE "cosh.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** hyperbolic cosine **/ + TYPE TGFN(cosh)(TYPE x) { switch (fpclassify(x)) { @@ -29,7 +30,5 @@ compute the hyperbolic cosine of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/exp.c b/src/math/exp.c index 412697b2..4b25da63 100644 --- a/src/math/exp.c +++ b/src/math/exp.c @@ -1,9 +1,10 @@ # define TGSOURCE "exp.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** exponential function **/ + TYPE TGFN(exp)(TYPE x) { int MAXLOOPS = 10; @@ -44,7 +45,5 @@ compute the exponential function of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/fabs.c b/src/math/fabs.c index 5fc42750..5ee54286 100644 --- a/src/math/fabs.c +++ b/src/math/fabs.c @@ -1,9 +1,10 @@ # define TGSOURCE "fabs.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** absolute value **/ + TYPE TGFN(fabs)(TYPE x) { switch (fpclassify(x)) { @@ -29,7 +30,5 @@ compute the absolute value of a floating-point number ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/floor.c b/src/math/floor.c index 41350fe8..e2d2093a 100644 --- a/src/math/floor.c +++ b/src/math/floor.c @@ -1,9 +1,10 @@ # define TGSOURCE "floor.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** round down to nearest integer **/ + TYPE TGFN(floor)(TYPE x) { switch (fpclassify(x)) { @@ -30,7 +31,5 @@ than ARGUMENT(x), returning it as the same floating-point type as ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/fmod.c b/src/math/fmod.c index 4370830f..3d31f55b 100644 --- a/src/math/fmod.c +++ b/src/math/fmod.c @@ -1,10 +1,11 @@ # define TGSOURCE "fmod.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** floating-point remainder **/ + TYPE TGFN(fmod)(TYPE x, TYPE y) { int classx = fpclassify(x); @@ -46,7 +47,5 @@ FIXME: I am not sure I understand this. IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) IMPLEMENTATION(Whether ARGUMENT(y) being LITERAL(0) results in a domain error or THIS() returning LITERAL(0)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/frexp.c b/src/math/frexp.c index b60dadc5..04579dff 100644 --- a/src/math/frexp.c +++ b/src/math/frexp.c @@ -1,9 +1,10 @@ # define TGSOURCE "frexp.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** extract mantissa and exponent **/ + TYPE TGFN(frexp)(TYPE value, int *exp) { switch (fpclassify(value)) { @@ -40,7 +41,5 @@ Multiplying the normalized fraction by 2 to the power ARGUMENT(*exp). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/ldexp.c b/src/math/ldexp.c index 33e2f381..c56fe405 100644 --- a/src/math/ldexp.c +++ b/src/math/ldexp.c @@ -1,9 +1,10 @@ # define TGSOURCE "ldexp.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** multiply by a power of 2 **/ + TYPE TGFN(ldexp)(TYPE x, int exp) { switch (fpclassify(x)) { @@ -34,7 +35,5 @@ by 2 raised to the power ARGUMENT(exp). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/log.c b/src/math/log.c index abc29e4e..cb08aa98 100644 --- a/src/math/log.c +++ b/src/math/log.c @@ -1,10 +1,11 @@ # define TGSOURCE "log.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** natural logarithm **/ + TYPE TGFN(log)(TYPE x) { switch (fpclassify(x)) { @@ -41,7 +42,5 @@ compute the natural logarithm of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/log10.c b/src/math/log10.c index e504df44..922bfceb 100644 --- a/src/math/log10.c +++ b/src/math/log10.c @@ -1,10 +1,11 @@ # define TGSOURCE "log10.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** base-10 logarithm **/ + TYPE TGFN(log10)(TYPE x) { switch (fpclassify(x)) { @@ -41,7 +42,5 @@ compute the base-ten logarithm of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/modf.c b/src/math/modf.c index 63db6094..a9331317 100644 --- a/src/math/modf.c +++ b/src/math/modf.c @@ -1,9 +1,10 @@ # define TGSOURCE "modf.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** decompose floating-point numbers **/ + TYPE TGFN(modf)(TYPE value, TYPE *iptr) { switch (fpclassify(value)) { @@ -32,7 +33,5 @@ by ARGUMENT(iptr). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/pow.c b/src/math/pow.c index 8a070005..3400cdd1 100644 --- a/src/math/pow.c +++ b/src/math/pow.c @@ -1,10 +1,11 @@ # define TGSOURCE "pow.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** exponentiation **/ + TYPE TGFN(pow)(TYPE x, TYPE y) { int classx = fpclassify(x); @@ -114,7 +115,5 @@ compute ARGUMENT(x) raised to the power ARGUMENT(y). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/sin.c b/src/math/sin.c index e93a663b..017b750a 100644 --- a/src/math/sin.c +++ b/src/math/sin.c @@ -1,10 +1,11 @@ # define TGSOURCE "sin.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** sine **/ + TYPE TGFN(sin)(TYPE x) { int MAXLOOPS = 10; @@ -52,7 +53,5 @@ compute sine of ARGUMENT(x), in radians. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/sinh.c b/src/math/sinh.c index 2e8d498c..a39c0bbd 100644 --- a/src/math/sinh.c +++ b/src/math/sinh.c @@ -1,9 +1,10 @@ # define TGSOURCE "sinh.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** hyperbolic sine **/ + TYPE TGFN(sinh)(TYPE x) { switch (fpclassify(x)) { @@ -29,7 +30,5 @@ compute hyperbolic sine of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/sqrt.c b/src/math/sqrt.c index a53d4750..e415bd65 100644 --- a/src/math/sqrt.c +++ b/src/math/sqrt.c @@ -1,9 +1,10 @@ # define TGSOURCE "sqrt.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** square root **/ + TYPE TGFN(sqrt)(TYPE x) { if (x < 0) { @@ -28,7 +29,5 @@ compute the principal square root of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/tan.c b/src/math/tan.c index 061e6cdd..8f11e02c 100644 --- a/src/math/tan.c +++ b/src/math/tan.c @@ -1,10 +1,11 @@ # define TGSOURCE "tan.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** tangent **/ + TYPE TGFN(tan)(TYPE x) { switch (fpclassify(x)) { @@ -30,7 +31,5 @@ compute the tanget of ARGUMENT(x), in radians. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/tanh.c b/src/math/tanh.c index cf5bf028..817cac35 100644 --- a/src/math/tanh.c +++ b/src/math/tanh.c @@ -1,9 +1,10 @@ # define TGSOURCE "tanh.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** hyperbolic tangent **/ + TYPE TGFN(tanh)(TYPE x) { switch (fpclassify(x)) { @@ -29,7 +30,5 @@ compute the hyperbolic tangent of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/setjmp/jmp_buf.c b/src/setjmp/jmp_buf.c index 09786eea..5654ebba 100644 --- a/src/setjmp/jmp_buf.c +++ b/src/setjmp/jmp_buf.c @@ -1,9 +1,7 @@ -#include <setjmp.h> +typedef unsigned long int jmp_buf[32]; /** program environment **/ -typedef unsigned long int jmp_buf[32]; - /*** is used to hold all the information needed to restore a a calling environment. diff --git a/src/signal/SIGABRT.c b/src/signal/SIGABRT.c index ce42a249..918a1f5d 100644 --- a/src/signal/SIGABRT.c +++ b/src/signal/SIGABRT.c @@ -1,11 +1,14 @@ -#include <signal.h> #define SIGABRT (6) + /** abnormal termination **/ + /*** is a signal indicating that the program is being terminated abnormally, such as when FUNCTION(abort) is called. ***/ + /* Value selected to match requirements for COMMAND(kill) and COMMAND(trap). */ + /* STDC(1) */ diff --git a/src/signal/SIGFPE.c b/src/signal/SIGFPE.c index 995a21c2..b4d56e09 100644 --- a/src/signal/SIGFPE.c +++ b/src/signal/SIGFPE.c @@ -1,10 +1,12 @@ -#include <signal.h> #define SIGFPE (4) + /** floating point exception **/ + /*** is a signal that indicates an error resulting from invalid arithmetic operations, such as division by zero or overflows. ***/ + /* STDC(1) */ diff --git a/src/signal/SIGILL.c b/src/signal/SIGILL.c index bd6afce8..b1ae8219 100644 --- a/src/signal/SIGILL.c +++ b/src/signal/SIGILL.c @@ -1,10 +1,12 @@ -#include <signal.h> #define SIGILL (5) + /** illegal instruction **/ + /*** is a signal indicating that the program has attempted to execute an illegal or improperly formed instruction. ***/ + /* STDC(1) */ diff --git a/src/signal/SIGINT.c b/src/signal/SIGINT.c index d335bbe2..bdd3f74d 100644 --- a/src/signal/SIGINT.c +++ b/src/signal/SIGINT.c @@ -1,10 +1,13 @@ -#include <signal.h> #define SIGINT (2) + /** interrupt **/ + /*** is a signal that indicates the program is being interactively interrupted. ***/ + /* Value selected to match requirements for COMMAND(kill) and COMMAND(trap). */ + /* STDC(1) */ diff --git a/src/signal/SIGSEGV.c b/src/signal/SIGSEGV.c index cfda42c2..dfb5adf1 100644 --- a/src/signal/SIGSEGV.c +++ b/src/signal/SIGSEGV.c @@ -1,10 +1,12 @@ -#include <signal.h> #define SIGSEGV (7) + /** segmentation fault **/ + /*** is a signal that indicates the program is attempting to access an invalid memory address. ***/ + /* STDC(1) */ diff --git a/src/signal/SIGTERM.c b/src/signal/SIGTERM.c index 72dfa7ae..4e475279 100644 --- a/src/signal/SIGTERM.c +++ b/src/signal/SIGTERM.c @@ -1,10 +1,13 @@ -#include <signal.h> #define SIGTERM (15) + /** terminate **/ + /*** is a signal indicating that the system is requesting the program to terminate. ***/ + /* Value selected to match requirements for COMMAND(kill) and COMMAND(trap). */ + /* STDC(1) */ diff --git a/src/signal/SIG_DFL.c b/src/signal/SIG_DFL.c index 549fe6e4..e067921a 100644 --- a/src/signal/SIG_DFL.c +++ b/src/signal/SIG_DFL.c @@ -1,10 +1,12 @@ -#include <signal.h> #define SIG_DFL ((void(*)(int))-1) + /** default signal action **/ + /*** is used as the ARGUMENT(func) argument to FUNCTION(signal) to indicate that the default signal action should occur. ***/ + /* STDC(1) */ diff --git a/src/signal/SIG_ERR.c b/src/signal/SIG_ERR.c index 0200a72f..62690293 100644 --- a/src/signal/SIG_ERR.c +++ b/src/signal/SIG_ERR.c @@ -1,4 +1,3 @@ -#include <signal.h> #define SIG_ERR ((void(*)(int))-2) /** error setting signal handler **/ @@ -7,6 +6,7 @@ is a sentinal value returned by FUNCTION(signal) to indicate that an error occurred. ***/ + /* STDC(1) */ diff --git a/src/signal/SIG_IGN.c b/src/signal/SIG_IGN.c index a753adc7..ad229f0d 100644 --- a/src/signal/SIG_IGN.c +++ b/src/signal/SIG_IGN.c @@ -1,4 +1,3 @@ -#include <signal.h> #define SIG_IGN ((void(*)(int))-3) /** ignore signal **/ @@ -7,6 +6,7 @@ can be used as the ARGUMENT(func) argument in a call to FUNCTION(signal) to ignore the specified signal. ***/ + /* STDC(1) */ diff --git a/src/signal/raise.c b/src/signal/raise.c index 04bed498..08e58747 100644 --- a/src/signal/raise.c +++ b/src/signal/raise.c @@ -1,14 +1,20 @@ -#if defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || defined _XOPEN_SOURCE -#include "sys/types.h" -#include "unistd.h" -#else -#include "_syscall.h" -#define kill(pid, sig) __syscall(__syscall_lookup(kill), pid, sig) -#define getpid() __syscall(__syscall_lookup(getpid)) +#ifndef _POSIX_SOURCE +#define _POSIX_SOURCE +#define POSIX_FORCED #endif + +#include <sys/types.h> #include <signal.h> +#include <unistd.h> + +#ifdef POSIX_FORCED +#include "_syscall.h" +#define kill(pid, sig) __scall2(kill, pid, sig) +#define getpid() __scall0(getpid) +#endif /** send a signal to the current program **/ + int raise(int sig) { /* @@ -25,6 +31,7 @@ int raise(int sig) /*** sends the signal ARGUMENT(sig) to the current program. ***/ + /* STDC(1) */ diff --git a/src/signal/sig_atomic_t.c b/src/signal/sig_atomic_t.c index b3ec2a84..c881018c 100644 --- a/src/signal/sig_atomic_t.c +++ b/src/signal/sig_atomic_t.c @@ -1,4 +1,3 @@ -#include <signal.h> typedef volatile int sig_atomic_t; /** non-interruptible type **/ @@ -9,7 +8,5 @@ is a type of object that can be used atomically even in the presence of interrup /* TYPEDEF(integer) -*/ -/* STDC(1) */ diff --git a/src/signal/signal.c b/src/signal/signal.c index afeacc84..5f25269f 100644 --- a/src/signal/signal.c +++ b/src/signal/signal.c @@ -1,25 +1,18 @@ -#if defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || defined _XOPEN_SOURCE -#include "sys/types.h" +#ifndef _POSIX_SOURCE +#define _POSIX_SOURCE +#define POSIX_FORCED #endif -#include "stddef.h" +#include <sys/types.h> +#include <stddef.h> #include <signal.h> -#ifndef _POSIX_SOURCE -#include "sigset_t.c" -#include "struct_sigaction.c" -#include "sigaction.c" -#include "sigemptyset.c" -#include "sigaddset.c" -#endif - +/* FIXME: Linux specific, doesn't even work */ #undef SA_RESTART -#ifndef SA_RESTART -/* #include "SA_RESTART.c" */ #define SA_RESTART 0x10000000 -#endif /** set a signal handler **/ + void (*signal(int sig, void (*func)(int)))(int) { struct sigaction sa = { 0 }, osa = { 0 }; @@ -60,7 +53,5 @@ UNDEFINED(A signal handler calling standard library functions other than THIS() UNDEFINED(FIXME: some function calls from signal handlers) IMPLEMENTATION(Whether signal blocking is performed when a signal occurs) IMPLEMENTATION(Other signals corresponding to computation exceptions for which signal handlers must not return) -*/ -/* STDC(1) */ diff --git a/src/stdarg/va_arg.c b/src/stdarg/va_arg.c index 4ea41019..79584b2b 100644 --- a/src/stdarg/va_arg.c +++ b/src/stdarg/va_arg.c @@ -1,9 +1,7 @@ -#include <stdarg.h> +#define va_arg(__ap, __type) __builtin_va_arg(__ap, __type) /** get an unnamed parameter **/ -#define va_arg(__ap, __type) __builtin_va_arg(__ap, __type) - /*** retrieves the next unnamed parameter for use. The ARGUMENT(ap) parameter must be first initialized with a call to FUNCTION(va_start). Each successive call to diff --git a/src/stdarg/va_end.c b/src/stdarg/va_end.c index dd1c04ab..62e585ae 100644 --- a/src/stdarg/va_end.c +++ b/src/stdarg/va_end.c @@ -1,9 +1,7 @@ -#include <stdarg.h> +#define va_end(__ap) __builtin_va_end(__ap) /** end processing unnamed arguments **/ -#define va_end(__ap) __builtin_va_end(__ap) - /*** stops processing unnamed arguments that were previously begun with a call to FUNCTION(va_start) so that the enclosing function may return normally. diff --git a/src/stdarg/va_list.c b/src/stdarg/va_list.c index 4e571669..3f1e1110 100644 --- a/src/stdarg/va_list.c +++ b/src/stdarg/va_list.c @@ -1,9 +1,7 @@ -#include <stdarg.h> +typedef __builtin_va_list va_list; /** variable length argument list **/ -typedef __builtin_va_list va_list; - /*** holds the information necessary for making calls to FUNCTION(va_start), FUNCTION(va_copy), FUNCTION(va_arg), and FUNCTION(va_end). diff --git a/src/stdarg/va_start.c b/src/stdarg/va_start.c index 69c418a1..2f08ee9a 100644 --- a/src/stdarg/va_start.c +++ b/src/stdarg/va_start.c @@ -1,9 +1,7 @@ -#include <stdarg.h> +#define va_start(__ap, __parmN) __builtin_va_start(__ap, __parmN) /** begin processing unnamed arguments **/ -#define va_start(__ap, __parmN) __builtin_va_start(__ap, __parmN) - /*** prepares unnamed arguments for use. It initializes ARGUMENT(ap) with the the first argument after the argument named by ARGUMENT(parmN). The argument named diff --git a/src/stddef/NULL.c b/src/stddef/NULL.c index 330b6b6e..d93bff2f 100644 --- a/src/stddef/NULL.c +++ b/src/stddef/NULL.c @@ -1,4 +1,3 @@ -#include <stddef.h> #define NULL ((void*)0) /** null pointer **/ @@ -11,7 +10,5 @@ library functions. /* UNDEFINED(Dereferencing THIS()) IMPLEMENTATION(The value of THIS(), DEFINITION((void*)0)) -*/ -/* STDC(1) */ diff --git a/src/stddef/offsetof.c b/src/stddef/offsetof.c index 15b7a5f3..2b0d158e 100644 --- a/src/stddef/offsetof.c +++ b/src/stddef/offsetof.c @@ -1,4 +1,3 @@ -#include <stddef.h> #define offsetof(__type, __member) ((size_t)((void*)&(((__type*)0)->__member))) /** get offset of a structure member **/ @@ -11,7 +10,5 @@ determines the offset, in bytes, of a specified field in a TYPE(struct). PROTOTYPE(size_t offsetof(<var>type</var>, <var>member</var>);) RETURN_SUCCESS(the offset of ARGUMENT(member) in ARGUMENT(type)) UNDEFINED(ARGUMENT(member) is a bit-field) -*/ -/* STDC(1) */ diff --git a/src/stddef/ptrdiff_t.c b/src/stddef/ptrdiff_t.c index 1bbd99c8..c591915a 100644 --- a/src/stddef/ptrdiff_t.c +++ b/src/stddef/ptrdiff_t.c @@ -1,4 +1,3 @@ -#include <stddef.h> #ifdef __LLP64__ # if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199909L typedef __int64 ptrdiff_t; @@ -18,7 +17,5 @@ from another. /* TYPEDEF(signed integer) -*/ -/* STDC(1) */ diff --git a/src/stddef/size_t.c b/src/stddef/size_t.c index 5435d006..6ec3e04a 100644 --- a/src/stddef/size_t.c +++ b/src/stddef/size_t.c @@ -1,4 +1,3 @@ -#include <stddef.h> #ifdef __LLP64__ # if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199909L typedef unsigned __int64 size_t; @@ -18,7 +17,5 @@ OPERATOR(sizeof) operator. /* TYPEDEF(unsigned integer) -*/ -/* STDC(1) */ diff --git a/src/stddef/wchar_t.c b/src/stddef/wchar_t.c index dc4955fa..eae2d067 100644 --- a/src/stddef/wchar_t.c +++ b/src/stddef/wchar_t.c @@ -1,4 +1,3 @@ -#include <stddef.h> typedef int wchar_t; /** wide character type **/ @@ -11,7 +10,5 @@ The null character will always have the value LITERAL(0). /* TYPEDEF(integer) -*/ -/* STDC(1) */ diff --git a/src/stdio/BUFSIZ.c b/src/stdio/BUFSIZ.c index c1b315c4..c59a3851 100644 --- a/src/stdio/BUFSIZ.c +++ b/src/stdio/BUFSIZ.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define BUFSIZ (4096) /** default buffer size **/ @@ -9,7 +8,5 @@ is the buffer size used when buffering is adjusted with FUNCTION(setbuf). /* VALUE_MIN(256) -*/ -/* STDC(1) */ diff --git a/src/stdio/EOF.c b/src/stdio/EOF.c index 84f560a1..2cf3ce60 100644 --- a/src/stdio/EOF.c +++ b/src/stdio/EOF.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define EOF (-1) /** end-of-file **/ @@ -7,6 +6,7 @@ is a sentinal value used to indicated that a TYPEDEF(FILE) stream has reached the end of file. ***/ + /* STDC(1) */ diff --git a/src/stdio/FILE.c b/src/stdio/FILE.c index 854bbcee..d3a29447 100644 --- a/src/stdio/FILE.c +++ b/src/stdio/FILE.c @@ -1,5 +1,5 @@ -#include <stdio.h> -typedef struct __FILE FILE; +typedef struct __FILE + FILE; /** buffered I/O stream **/ @@ -10,6 +10,7 @@ a pointer to its buffer, an error indicator, and an end-of-file indicator. No standard defines the members of THIS(). User programs should not attempt to access or modify its members directly. ***/ + /* STDC(1) */ diff --git a/src/stdio/FILENAME_MAX.c b/src/stdio/FILENAME_MAX.c index 4acdbcfb..1bb13b85 100644 --- a/src/stdio/FILENAME_MAX.c +++ b/src/stdio/FILENAME_MAX.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define FILENAME_MAX (255) /** maximum filename length **/ @@ -7,6 +6,7 @@ is size of the longest array of TYPE(char) that the implementation guarantees can be used as a file name. ***/ + /* STDC(1) */ diff --git a/src/stdio/FOPEN_MAX.c b/src/stdio/FOPEN_MAX.c index 2cfc1fb0..548db477 100644 --- a/src/stdio/FOPEN_MAX.c +++ b/src/stdio/FOPEN_MAX.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define FOPEN_MAX (8) /** maximum open FILE streams **/ @@ -10,7 +9,5 @@ guarantees can be opened at the same time. /* VALUE_MIN(8) -*/ -/* STDC(1) */ diff --git a/src/stdio/L_tmpnam.c b/src/stdio/L_tmpnam.c index d35cb988..8467199a 100644 --- a/src/stdio/L_tmpnam.c +++ b/src/stdio/L_tmpnam.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define L_tmpnam (255) /** temporary file name length **/ @@ -6,6 +5,7 @@ /*** is the maximum length of a temporary filename returned by FUNCTION(tmpnam). ***/ + /* STDC(1) */ diff --git a/src/stdio/NULL.ref b/src/stdio/NULL.ref index d1bb9ab5..b247705b 100644 --- a/src/stdio/NULL.ref +++ b/src/stdio/NULL.ref @@ -1,3 +1,2 @@ -#include <stdio.h> REFERENCE(stddef/NULL.c) STDC(1) diff --git a/src/stdio/SEEK_CUR.c b/src/stdio/SEEK_CUR.c index 558d57ef..efa117f8 100644 --- a/src/stdio/SEEK_CUR.c +++ b/src/stdio/SEEK_CUR.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define SEEK_CUR (1) /** seek forward **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(whence) argument to FUNCTION(fseek) to indicate that seeking should begin at the current file position and move forward. ***/ + /* STDC(1) */ diff --git a/src/stdio/SEEK_END.c b/src/stdio/SEEK_END.c index 856d2074..15a56439 100644 --- a/src/stdio/SEEK_END.c +++ b/src/stdio/SEEK_END.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define SEEK_END (2) /** seek from end **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(whence) argument to FUNCTION(fseek) to indicate that seeking should begin at the end of the file and move backward. ***/ + /* STDC(1) */ diff --git a/src/stdio/SEEK_SET.c b/src/stdio/SEEK_SET.c index 213c3c33..d9ce4b88 100644 --- a/src/stdio/SEEK_SET.c +++ b/src/stdio/SEEK_SET.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define SEEK_SET (3) /** seek from beginning **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(whence) argument to FUNCTION(fseek) to indicate that seeking should begin at the start of the file and move forward. ***/ + /* STDC(1) */ diff --git a/src/stdio/TMP_MAX.c b/src/stdio/TMP_MAX.c index af429fd3..8cedfc60 100644 --- a/src/stdio/TMP_MAX.c +++ b/src/stdio/TMP_MAX.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define TMP_MAX (10000) /** maximum temporary file names **/ @@ -7,6 +6,7 @@ is the minimum number of unique file names FUNCTION(tmpnam) is guaranteed to be able to generate. ***/ + /* STDC(1) */ diff --git a/src/stdio/_IOFBF.c b/src/stdio/_IOFBF.c index 659b787d..3f0714ff 100644 --- a/src/stdio/_IOFBF.c +++ b/src/stdio/_IOFBF.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define _IOFBF (1) /** full buffering **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(mode) in calls to FUNCTION(setvbuf) to indicate that a stream should be fully buffered. ***/ + /* STDC(1) */ diff --git a/src/stdio/_IOLBF.c b/src/stdio/_IOLBF.c index 8f84ae97..e11fe4fc 100644 --- a/src/stdio/_IOLBF.c +++ b/src/stdio/_IOLBF.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define _IOLBF (2) /** line buffering **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(mode) in calls to FUNCTION(setvbuf) to indicate that a stream should be line buffered. ***/ + /* STDC(1) */ diff --git a/src/stdio/_IONBF.c b/src/stdio/_IONBF.c index aa88cb9b..215bf26b 100644 --- a/src/stdio/_IONBF.c +++ b/src/stdio/_IONBF.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define _IONBF (3) /** no buffering **/ @@ -7,6 +6,7 @@ is used as the ARGUMENT(mode) in calls to FUNCTION(setvbuf) to indicate that a stream should be unbuffered. ***/ + /* STDC(1) */ diff --git a/src/stdio/clearerr.c b/src/stdio/clearerr.c index b15ba362..44510744 100644 --- a/src/stdio/clearerr.c +++ b/src/stdio/clearerr.c @@ -2,6 +2,7 @@ #include "_stdio.h" /** reset file stream error indicator **/ + void clearerr(FILE * stream) { flockfile(stream); @@ -15,6 +16,7 @@ void clearerr(FILE * stream) /*** clears the error and end-of-file indicators of ARGUMENT(stream). ***/ + /* STDC(1) */ diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c index 1e55a0f0..cc02f5ff 100644 --- a/src/stdio/fclose.c +++ b/src/stdio/fclose.c @@ -1,13 +1,18 @@ +#ifndef _POSIX_SOURCE +#define _POSIX_SOURCE +#define POSIX_FORCED +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "_stdio.h" - -#if defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || defined _XOPEN_SOURCE #include <sys/types.h> #include <unistd.h> -#else -#define close(fd) -1 +#include "_stdio.h" + +#ifdef POSIX_FORCED +#include "_syscall.h" +#define close(_fd) __scall1(close, _fd) #endif /** close a file stream **/ @@ -47,6 +52,7 @@ function closes ARGUMENT(stream) and its associated file. Any unwritten data is flushed before closing. Any unread data is discarded. If the buffer was automatically allocated, it is freed. ***/ + /* STDC(1) */ diff --git a/src/stdio/feof.c b/src/stdio/feof.c index 80f4ddca..94531fcf 100644 --- a/src/stdio/feof.c +++ b/src/stdio/feof.c @@ -1,8 +1,9 @@ #include <stdio.h> -#include "_stdio.h" #include "_assert.h" +#include "_stdio.h" /** test for end-of-file **/ + int feof(FILE *stream) { ASSERT_NONNULL(stream); @@ -24,6 +25,7 @@ int feof(FILE *stream) /*** tests for the end-of-file indicator of ARGUMENT(stream). ***/ + /* STDC(1) */ diff --git a/src/stdio/ferror.c b/src/stdio/ferror.c index 66f76a67..b5a4a085 100644 --- a/src/stdio/ferror.c +++ b/src/stdio/ferror.c @@ -3,6 +3,7 @@ #include "_stdio.h" /** tests the file stream error indicator **/ + int ferror(FILE *stream) { ASSERT_NONNULL(stream); @@ -16,6 +17,7 @@ int ferror(FILE *stream) /*** tests the error indicator of ARGUMENT(stream). ***/ + /* STDC(1) */ diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c index 19096714..e6108fbd 100644 --- a/src/stdio/fflush.c +++ b/src/stdio/fflush.c @@ -1,12 +1,16 @@ -#include <stdio.h> -#include "_stdio.h" +#ifndef _POSIX_SOURCE +#define _POSIX_SOURCE +#define POSIX_FORCED +#endif -#ifdef _POSIX_SOURCE +#include <stdio.h> #include <sys/types.h> #include <unistd.h> -#else +#include "_stdio.h" + +#ifdef POSIX_FORCED #include "_syscall.h" -#define write(_fd, _buf, _size) __syscall(__syscall_lookup(write), _fd, _buf, _size) +#define write(_fd, _buf, _size) __scall3(write, _fd, _buf, _size) #endif /** flush buffered writes **/ @@ -51,7 +55,5 @@ If ARGUMENT(stream) is CONSTANT(NULL), THIS() will flush all open streams. /* UNDEFINED(ARGUMENT(stream) is not an output stream) UNDEFINED(ARGUMENT(stream) is an update stream in which the most recent operation was input) -*/ -/* STDC(1) */ diff --git a/src/stdio/fgetc.c b/src/stdio/fgetc.c index 56f1a348..a49a3ce8 100644 --- a/src/stdio/fgetc.c +++ b/src/stdio/fgetc.c @@ -8,6 +8,7 @@ #else /** read a character from a file stream **/ + int fgetc(FILE *stream) { flockfile(stream); @@ -27,6 +28,7 @@ reads the next character from ARGUMENT(stream) as an TYPE(unsigned char) converted to an TYPE(int). The file position indicator of ARGUMENT(stream) is advanced. ***/ + /* STDC(1) */ diff --git a/src/stdio/fgetpos.c b/src/stdio/fgetpos.c index aee57181..04241e79 100644 --- a/src/stdio/fgetpos.c +++ b/src/stdio/fgetpos.c @@ -2,6 +2,7 @@ #include "_stdio.h" /** get the file stream position indicator **/ + int fgetpos(FILE * restrict stream, fpos_t * restrict pos) { flockfile(stream); @@ -17,7 +18,5 @@ for ARGUMENT(stream) into the TYPEDEF(fpos_t) at ARGUMENT(pos). /* UNSPECIFIED(The information stored in TYPEDEF(fpos_t)) -*/ -/* STDC(1) */ diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c index cae9c887..558c2fdc 100644 --- a/src/stdio/fgets.c +++ b/src/stdio/fgets.c @@ -2,6 +2,7 @@ #include "_stdio.h" /** read a string of characters from a file stream **/ + char * fgets(char * restrict s, int n, FILE * restrict stream) { int i = 0; diff --git a/src/stdio/fpos_t.c b/src/stdio/fpos_t.c index 40d304cf..fe55a7af 100644 --- a/src/stdio/fpos_t.c +++ b/src/stdio/fpos_t.c @@ -1,5 +1,5 @@ -#include <stdio.h> -typedef struct __fpos_t * fpos_t; +typedef struct __fpos_t * + fpos_t; /** file position **/ @@ -7,6 +7,7 @@ typedef struct __fpos_t * fpos_t; is used to record information about individual positions within a TYPEDEF(FILE) stream. ***/ + /* STDC(1) */ diff --git a/src/stdio/fprintf.c b/src/stdio/fprintf.c index 40a2d42d..0e6509f8 100644 --- a/src/stdio/fprintf.c +++ b/src/stdio/fprintf.c @@ -1,8 +1,9 @@ +#include <stdarg.h> #include <stdio.h> -#include "stdarg.h" #include "_stdio.h" /** write formatted output to a file stream **/ + int fprintf(FILE * restrict stream, const char * restrict format, ...) { int ret = 0; @@ -24,6 +25,7 @@ int fprintf(FILE * restrict stream, const char * restrict format, ...) writes a formatted string to ARGUMENT(stream). The format of ARGUMENT(format) and the variadic arguments is the same as that for FUNCTION(printf). ***/ + /* STDC(1) */ diff --git a/src/stdio/fputs.c b/src/stdio/fputs.c index 22ee7d28..4f5cea8d 100644 --- a/src/stdio/fputs.c +++ b/src/stdio/fputs.c @@ -2,6 +2,7 @@ #include "_stdio.h" /** write a string to a file stream **/ + int fputs(const char * restrict s, FILE * restrict stream) { flockfile(stream); @@ -23,6 +24,7 @@ int fputs(const char * restrict s, FILE * restrict stream) writes the string ARGUMENT(s) to ARGUMENT(stream), not including the terminating CHAR(\0) character. ***/ + /* STDC(1) */ diff --git a/src/stdio/fread.c b/src/stdio/fread.c index 7929d495..bf8c5fd2 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -2,6 +2,7 @@ #include "_stdio.h" /** read directly from a file stream **/ + size_t fread(void * restrict ptr, size_t size, size_t nmemb, FILE * restrict stream) { unsigned char *buf = ptr; @@ -34,6 +35,7 @@ from ARGUMENT(stream) into the array at ARGUMENT(ptr). The file position indicate is advanced by the number of bytes read. ***/ + /* STDC(1) */ diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index 516684b4..0afec064 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -3,19 +3,19 @@ #define POSIX_FORCED #endif -#include <stdio.h> -#include <string.h> -#include <errno.h> #include <sys/types.h> +#include <errno.h> #include <fcntl.h> +#include <stdio.h> +#include <string.h> #include <unistd.h> #include "_stdio.h" #ifdef POSIX_FORCED #include "termios/_termios.h" #include "_syscall.h" -#define open(fname, flags, mode) __scall3(open, fname, flags, mode) -#define isatty(fd) ioctl(fd, TCFLSH, 0) +#define open(_p, _f, _m) __scall3(open, _p, _f, _m) +#define isatty(_fd) ioctl(_fd, TCFLSH, 0) #endif /** reopen a file stream with a new file **/ @@ -102,6 +102,7 @@ ignoring any errors. The error and end-of-file indicators are cleared. ***/ + /* STDC(1) */ diff --git a/src/stdio/fscanf.c b/src/stdio/fscanf.c index 05ec5ed8..81279d46 100644 --- a/src/stdio/fscanf.c +++ b/src/stdio/fscanf.c @@ -1,8 +1,9 @@ +#include <stdarg.h> #include <stdio.h> -#include "stdarg.h" #include "_stdio.h" /** read formatted input from a file stream **/ + int fscanf(FILE * restrict stream, const char * restrict format, ...) { int ret = 0; @@ -24,6 +25,7 @@ int fscanf(FILE * restrict stream, const char * restrict format, ...) reads formatted input from ARGUMENT(stream). The format of ARGUMENT(format) at the variadic arguments is the same as that for FUNCTION(scanf). ***/ + /* STDC(1) */ diff --git a/src/stdio/fseek.c b/src/stdio/fseek.c index 2cee57a1..42fb0d9f 100644 --- a/src/stdio/fseek.c +++ b/src/stdio/fseek.c @@ -1,6 +1,7 @@ #include <stdio.h> /** set the file position indicator **/ + int fseek(FILE *stream, long int offset, int whence) { (void)stream; (void)offset; @@ -29,7 +30,5 @@ any characters pushed with fn(ungetc). /* UNDEFINED(Specifying CONSTANT(SEEK_END) for ARGUMENT(whence) on a binary file) UNDEFINED(Specifying a value for ARGUMENT(offset) other than 0 or a previous return value of FUNCTION(ftell) on a text file) -*/ -/* STDC(1) */ diff --git a/src/stdio/fsetpos.c b/src/stdio/fsetpos.c index 8ec7cdd8..33c055ea 100644 --- a/src/stdio/fsetpos.c +++ b/src/stdio/fsetpos.c @@ -1,6 +1,7 @@ #include <stdio.h> /** set the file position indicator **/ + int fsetpos(FILE *stream, const fpos_t *pos) { (void)stream; (void)pos; @@ -16,6 +17,7 @@ FUNCTION(fgetpos). A successful call to THIS() clears the end-of-file indicator and discards any characters pushed back with FUNCTION(ungetc). ***/ + /* STDC(1) */ diff --git a/src/stdio/ftell.c b/src/stdio/ftell.c index 796a468c..f1fab68a 100644 --- a/src/stdio/ftell.c +++ b/src/stdio/ftell.c @@ -1,6 +1,7 @@ #include <stdio.h> /** get the file position indicator **/ + long int ftell(FILE *stream) { (void)stream; @@ -20,7 +21,5 @@ For binary streams, the indicator is the current byte position. /* UNSPECIFIED(The meaning of the file position indicator for text streams) -*/ -/* STDC(1) */ diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c index 047ee892..f7fe07f9 100644 --- a/src/stdio/fwrite.c +++ b/src/stdio/fwrite.c @@ -1,6 +1,7 @@ #include <stdio.h> /** write directly to a file stream **/ + size_t fwrite(const void * restrict ptr, size_t size, size_t nmemb, FILE * restrict stream) { unsigned char *buf = (unsigned char *)ptr; @@ -31,6 +32,7 @@ the array ARGUMENT(ptr) to ARGUMENT(stream). The file position inidicate is advanced by the number of bytes successfully written. ***/ + /* STDC(1) */ diff --git a/src/stdio/getc.c b/src/stdio/getc.c index 11a75d4e..f176ef5b 100644 --- a/src/stdio/getc.c +++ b/src/stdio/getc.c @@ -1,6 +1,7 @@ #include <stdio.h> /** read a character from a file stream **/ + int getc(FILE *stream) { /* @@ -14,6 +15,7 @@ int getc(FILE *stream) is the equivalent of FUNCTION(fgetc) except that if it is defined as a macro, it may evaluate ARGUMENT(stream) more than once. ***/ + /* STDC(1) */ diff --git a/src/stdio/getchar.c b/src/stdio/getchar.c index 3bd12654..d09bbdfc 100644 --- a/src/stdio/getchar.c +++ b/src/stdio/getchar.c @@ -1,6 +1,7 @@ #include <stdio.h> /** read a character from stdin **/ + int getchar(void) { /* @@ -13,6 +14,7 @@ int getchar(void) /*** reads the next character from ARGUMENT(stdin). ***/ + /* STDC(1) */ diff --git a/src/stdio/gets.c b/src/stdio/gets.c index fbe16cd2..8ad0998a 100644 --- a/src/stdio/gets.c +++ b/src/stdio/gets.c @@ -2,6 +2,7 @@ #include "limits.h" /** read a line from stdin **/ + char * gets(char *s) { /* @@ -23,6 +24,7 @@ after the last character read into the array. If end-of-file is reached before any characters are read, the contents of ARGUMENT(s) remain unchanged. ***/ + /* STDC(1,201112) */ diff --git a/src/stdio/perror.c b/src/stdio/perror.c index 2aae8470..788bb4fc 100644 --- a/src/stdio/perror.c +++ b/src/stdio/perror.c @@ -1,8 +1,9 @@ +#include <errno.h> #include <stdio.h> -#include "string.h" -#include "errno.h" +#include <string.h> /** print an error message **/ + void perror(const char *s) { if (s != NULL && *s != '\0') { @@ -23,7 +24,5 @@ pointed to by ARGUMENT(s), a colon (CHAR(:)), and a space. /* POSIX_(L_C_MESSAGES) -*/ -/* STDC(1) */ diff --git a/src/stdio/printf.c b/src/stdio/printf.c index 1dedbbea..bc90c766 100644 --- a/src/stdio/printf.c +++ b/src/stdio/printf.c @@ -1,8 +1,9 @@ +#include <stdarg.h> #include <stdio.h> -#include "stdarg.h" #include "_stdio.h" /** write formatted output **/ + int printf(const char *format, ...) { int ret = 0; @@ -103,7 +104,5 @@ FLAG(CHAR(%), `Outputs a literal CHAR(%).') IMPLEMENTATION(`The format of CHAR(p) conversions', `STRING(0x%0ARGUMENT(n)x), where ARGUMENT(n) is the number of hexadecimal digits in a canonical address on the platform of execution.') UNDEFINED(`Precision with a conversion specifier other than CHAR(d), CHAR(i), CHAR(o), CHAR(u), CHAR(x), CHAR(X), CHAR(e), CHAR(E), CHAR(f), CHAR(g), CHAR(G), or CHAR(s)') UNDEFINED(TODO: Using h or l for !(diouxXn) or L for !(eEfgG)) -*/ -/* STDC(1) */ diff --git a/src/stdio/putc.c b/src/stdio/putc.c index c3509ee2..48e11719 100644 --- a/src/stdio/putc.c +++ b/src/stdio/putc.c @@ -1,6 +1,7 @@ #include <stdio.h> /** write a character to a file stream **/ + int putc(int c, FILE *stream) { /* @@ -14,6 +15,7 @@ int putc(int c, FILE *stream) is equivalent of FUNCTION(fputc), except that if it is defined as a macro, it may evaluate ARGUMENT(stream) more than once. ***/ + /* STDC(1) */ diff --git a/src/stdio/putchar.c b/src/stdio/putchar.c index cb12ec0c..992d2f1e 100644 --- a/src/stdio/putchar.c +++ b/src/stdio/putchar.c @@ -1,6 +1,7 @@ #include <stdio.h> /** write a character to stdout **/ + int putchar(int c) { /* @@ -14,6 +15,7 @@ int putchar(int c) writes the character ARGUMENT(c) (converted to an TYPE(unsigned char)) to IDENTIFIER(stdout). ***/ + /* STDC(1) */ diff --git a/src/stdio/puts.c b/src/stdio/puts.c index 9e6c4c5b..93b98c3f 100644 --- a/src/stdio/puts.c +++ b/src/stdio/puts.c @@ -2,6 +2,7 @@ #include "_stdio.h" /** write a string to stoud **/ + int puts(const char *s) { int ret = 1; @@ -34,6 +35,7 @@ int puts(const char *s) function writes the string pointed to by ARGUMENT(s) to IDENTIFIER(stdout), followed by a newline. The terminated CHAR(\0) is not written. ***/ + /* STDC(1) */ diff --git a/src/stdio/remove.c b/src/stdio/remove.c index 2a10e443..39b5a74c 100644 --- a/src/stdio/remove.c +++ b/src/stdio/remove.c @@ -1,15 +1,18 @@ +#ifndef _POSIX_SOURCE +#define _POSIX_SOURCE +#define POSIX_FORCED +#endif + #include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> -#ifdef _POSIX_SOURCE -#include "sys/types.h" -#include "sys/stat.h" -#include "unistd.h" -#else - struct stat { int st_mode; }; -#define stat(f, b) (void)f -#define S_ISDIR(m) (m = 0) -#define rmdir(f) (-1) -#define unlink(f) (-1) +#ifdef POSIX_FORCED +#include "_syscall.h" +#define stat(_f, _b) __scall2(stat, _f, _b) +#define rmdir(_f) __scall1(rmdir, _f) +#define unlink(_f) __scall1(unlink, _f) #endif /** delete a file **/ @@ -31,7 +34,5 @@ open that file will fail unless creating a new file. /* IMPLEMENTATION(Whether the file is removed if it is open) -*/ -/* STDC(1) */ diff --git a/src/stdio/rename.c b/src/stdio/rename.c index 589b3690..ad1be639 100644 --- a/src/stdio/rename.c +++ b/src/stdio/rename.c @@ -1,20 +1,12 @@ +#include <errno.h> #include <stdio.h> -#include "errno.h" #include "_syscall.h" /** rename a file **/ + int rename(const char *old, const char *new) { - SYSCALL_NUMBER(sc, rename, -1); - int err = 0; - - err = __syscall(sc, old, new); - if (err < 0) { - errno = -err; - return -1; - } - - return 0; + SYSCALL(rename, int, -1, old, new, 0, 0, 0, 0); } /*** @@ -24,7 +16,5 @@ ARGUMENT(new). /* IMPLEMENTATION(Behavior if ARGUMENT(new) exists prior to THIS() being called) -*/ -/* STDC(1) */ diff --git a/src/stdio/rewind.c b/src/stdio/rewind.c index 73be1f57..94694edb 100644 --- a/src/stdio/rewind.c +++ b/src/stdio/rewind.c @@ -1,6 +1,7 @@ #include <stdio.h> /** reset file position indicator **/ + void rewind(FILE *stream) { fseek(stream, 0L, SEEK_SET); @@ -11,6 +12,7 @@ void rewind(FILE *stream) sets the file position indicator of ARGUMENT(stream) to the beginning of the file. The error indicator will be cleared. ***/ + /* STDC(1) */ diff --git a/src/stdio/scanf.c b/src/stdio/scanf.c index efec61d8..23e82417 100644 --- a/src/stdio/scanf.c +++ b/src/stdio/scanf.c @@ -1,8 +1,9 @@ +#include <stdarg.h> #include <stdio.h> -#include "stdarg.h" #include "_stdio.h" /** read formatted input **/ + int scanf(const char * restrict format, ...) { int ret = 0; @@ -25,6 +26,7 @@ reads formatted input from macro(stdin). FIXME: scanf format goes here ***/ + /* STDC(1) */ diff --git a/src/stdio/setbuf.c b/src/stdio/setbuf.c index 351db3d3..1efa8ea1 100644 --- a/src/stdio/setbuf.c +++ b/src/stdio/setbuf.c @@ -1,6 +1,7 @@ #include <stdio.h> /** specify file stream buffer **/ + void setbuf(FILE * restrict stream, char * restrict buf) { if (buf) { @@ -19,6 +20,7 @@ If ARGUMENT(buf) is CONSTANT(NULL), ARGUMENT(stream) will become unbuffered. It equivalent of: LITERAL(setvbuf(stream, NULL, _IONBF, 0);) ***/ + /* STDC(1) */ diff --git a/src/stdio/setvbuf.c b/src/stdio/setvbuf.c index c3aed354..2edfdaea 100644 --- a/src/stdio/setvbuf.c +++ b/src/stdio/setvbuf.c @@ -1,5 +1,5 @@ -#include <stdio.h> #include <errno.h> +#include <stdio.h> #include <stdlib.h> #include "_stdio.h" @@ -72,6 +72,7 @@ an array of at least ARGUMENT(size) characters. The ARGUMENT(size) argument specifies the size of the buffer. ***/ + /* STDC(1) */ diff --git a/src/stdio/size_t.ref b/src/stdio/size_t.ref index 5b9b0797..fc611c25 100644 --- a/src/stdio/size_t.ref +++ b/src/stdio/size_t.ref @@ -1,3 +1,2 @@ -#include <stdio.h> REFERENCE(stddef/size_t.c) STDC(1) diff --git a/src/stdio/sprintf.c b/src/stdio/sprintf.c index 9e651adb..d6776fe4 100644 --- a/src/stdio/sprintf.c +++ b/src/stdio/sprintf.c @@ -1,15 +1,9 @@ +#include <stdarg.h> #include <stdio.h> -#include "stdarg.h" #include "_stdio.h" -#if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ -#include "stdint.h" -#else -#include "limits.h" -#define SIZE_MAX INT_MAX -#endif - /** write formatted output to a string **/ + int sprintf(char * restrict s, const char * restrict format, ...) { int ret = 0; @@ -17,7 +11,7 @@ int sprintf(char * restrict s, const char * restrict format, ...) struct io_options opt = {0}; opt.fnname = "sprintf"; opt.string = s; - opt.maxlen = SIZE_MAX; + opt.maxlen = (size_t)-1; va_start(ap, format); ret = __printf(&opt, format, ap); va_end(ap); @@ -32,6 +26,7 @@ writes a formatted string to the buffer at ARGUMENT(s). The format of ARGUMENT(format) and the variadic arguments is the same as that for FUNCTION(printf). ***/ + /* STDC(1) */ diff --git a/src/stdio/sscanf.c b/src/stdio/sscanf.c index 10a08447..e8ccaf9e 100644 --- a/src/stdio/sscanf.c +++ b/src/stdio/sscanf.c @@ -1,8 +1,9 @@ +#include <stdarg.h> #include <stdio.h> -#include "stdarg.h" #include "_stdio.h" /** read formatted input from a string **/ + int sscanf(const char * restrict s, const char * restrict format, ...) { int ret = 0; @@ -25,6 +26,7 @@ reads formatted input from the string ARGUMENT(s). The format of ARGUMENT(format) at the variadic arguments is the same as that for FUNCTION(scanf). ***/ + /* STDC(1) */ diff --git a/src/stdio/stderr.c b/src/stdio/stderr.c index f2841f0d..8ec8a9aa 100644 --- a/src/stdio/stderr.c +++ b/src/stdio/stderr.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define stderr __stderr /** standard error **/ @@ -6,6 +5,7 @@ /*** is the standard error stream. ***/ + /* STDC(1) */ diff --git a/src/stdio/stdin.c b/src/stdio/stdin.c index 329d6d23..5fb14c70 100644 --- a/src/stdio/stdin.c +++ b/src/stdio/stdin.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define stdin __stdin /** standard input **/ @@ -6,6 +5,7 @@ /*** is the standard input stream. ***/ + /* STDC(1) */ diff --git a/src/stdio/stdout.c b/src/stdio/stdout.c index 08aefa24..7c62dfa0 100644 --- a/src/stdio/stdout.c +++ b/src/stdio/stdout.c @@ -1,4 +1,3 @@ -#include <stdio.h> #define stdout __stdout /** standard output **/ @@ -6,6 +5,7 @@ /*** is the standard output stream. ***/ + /* STDC(1) */ diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c index 7143b491..06662dd7 100644 --- a/src/stdio/tmpfile.c +++ b/src/stdio/tmpfile.c @@ -1,6 +1,7 @@ #include <stdio.h> -/* open a temporary file stream */ +/** open a temporary file stream **/ + FILE * tmpfile(void) { char *path = "FIXME: A temporary file name *not* calling tmpnam()"; @@ -27,7 +28,5 @@ or when the program exits. /* IMPLEMENTATION(Whether the temporary file is removed if the program terminates abnormally) -*/ -/* STDC(1) */ diff --git a/src/stdio/tmpnam.c b/src/stdio/tmpnam.c index b4b5d932..f5e79c55 100644 --- a/src/stdio/tmpnam.c +++ b/src/stdio/tmpnam.c @@ -1,6 +1,7 @@ #include <stdio.h> /** generate a temporary file name **/ + char * tmpnam(char *s) { static int ntimescalled = 0; @@ -37,7 +38,5 @@ this array. /* IMPLEMENTATION(Behavior if THIS() is called more than CONSTANT(TMP_MAX) times) -*/ -/* STDC(1) */ diff --git a/src/stdio/ungetc.c b/src/stdio/ungetc.c index 5629679a..c34f4d20 100644 --- a/src/stdio/ungetc.c +++ b/src/stdio/ungetc.c @@ -2,6 +2,7 @@ #include "_stdio.h" /** push a character back into an input stream **/ + int ungetc(int c, FILE *stream) { (void)c; (void)stream; @@ -32,6 +33,7 @@ position indicator is decremented. Calling THIS() on a binary stream when the file position indicator is zero is obsolete in ISO/IEC 9899:1999. ***/ + /* STDC(1) */ diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index 55a9a140..db60a8fd 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -1,8 +1,9 @@ +#include <stdarg.h> #include <stdio.h> -#include "stdarg.h" #include "_stdio.h" /** write formatted output to a file stream **/ + int vfprintf(FILE * restrict stream, const char * restrict format, va_list arg) { int ret = 0; @@ -24,6 +25,7 @@ initialized with FUNCTION(va_start) prior to calling THIS(). The THIS() function does not call FUNCTION(va_end), so the calling function is responsible for this. ***/ + /* STDC(1) */ diff --git a/src/stdio/vsprintf.c b/src/stdio/vsprintf.c index 14c7f7fb..8ddc4642 100644 --- a/src/stdio/vsprintf.c +++ b/src/stdio/vsprintf.c @@ -1,8 +1,9 @@ +#include <stdarg.h> #include <stdio.h> -#include "stdarg.h" #include "_stdio.h" /** write formatted output to a string **/ + int vsprintf(char *s, const char *format, va_list arg) { int ret = 0; @@ -24,6 +25,7 @@ initialized with FUNCTION(va_start) prior to calling THIS(). The THIS() function does not call FUNCTION(va_end), so the calling function is responsible for this. ***/ + /* STDC(1) */ diff --git a/src/stdlib/EXIT_FAILURE.c b/src/stdlib/EXIT_FAILURE.c index 4558c660..14d28dc0 100644 --- a/src/stdlib/EXIT_FAILURE.c +++ b/src/stdlib/EXIT_FAILURE.c @@ -1,9 +1,7 @@ -#include <stdlib.h> +#define EXIT_FAILURE (1) /** unsuccessful program termination **/ -#define EXIT_FAILURE (1) - /*** is used as the ARGUMENT(status) argument to FUNCTION(exit) or FUNCTION(_Exit), or the return value from FUNCTION(main), to indicate that the program is diff --git a/src/stdlib/EXIT_SUCCESS.c b/src/stdlib/EXIT_SUCCESS.c index ce2ed9df..3b0bc2fa 100644 --- a/src/stdlib/EXIT_SUCCESS.c +++ b/src/stdlib/EXIT_SUCCESS.c @@ -1,9 +1,7 @@ -#include <stdlib.h> +#define EXIT_SUCCESS (0) /** successful program termination **/ -#define EXIT_SUCCESS (0) - /*** is used as the ARGUMENT(status) argument to FUNCTION(exit) or FUNCTION(_Exit), or the return value from FUNCTION(main), to indicate that the program is diff --git a/src/stdlib/MB_CUR_MAX.c b/src/stdlib/MB_CUR_MAX.c index 4961e343..1b833ba4 100644 --- a/src/stdlib/MB_CUR_MAX.c +++ b/src/stdlib/MB_CUR_MAX.c @@ -1,9 +1,7 @@ -#include <stdlib.h> +#define MB_CUR_MAX (4) /** current longest multibyte character **/ -#define MB_CUR_MAX (4) - /*** is the maximum number of bytes required to store any character in the current multibyte character set as specified by CONSTANT(LC_CTYPE). diff --git a/src/stdlib/NULL.ref b/src/stdlib/NULL.ref index 87e994d4..b247705b 100644 --- a/src/stdlib/NULL.ref +++ b/src/stdlib/NULL.ref @@ -1,3 +1,2 @@ -#include <stdlib.h> REFERENCE(stddef/NULL.c) STDC(1) diff --git a/src/stdlib/RAND_MAX.c b/src/stdlib/RAND_MAX.c index dbbdbde0..08b432e5 100644 --- a/src/stdlib/RAND_MAX.c +++ b/src/stdlib/RAND_MAX.c @@ -1,9 +1,7 @@ -#include <stdlib.h> +#define RAND_MAX (32767) /** random number range **/ -#define RAND_MAX (32767) - /*** is the maximum value returned by FUNCTION(rand). ***/ diff --git a/src/stdlib/abort.c b/src/stdlib/abort.c index bfd47317..f12f8276 100644 --- a/src/stdlib/abort.c +++ b/src/stdlib/abort.c @@ -1,15 +1,5 @@ #include <stdlib.h> -#ifdef _POSIX_SOURCE -#include "sys/types.h" -#endif -/* -#include "signal.h" -*/ - -#define __SIGNAL_H__ -#define SIGABRT -#include "ungol/signal.h" -extern void raise(int); +#include <signal.h> /** cause abnormal program termination **/ diff --git a/src/stdlib/abs.c b/src/stdlib/abs.c index 9bc6ca28..5cf59b4e 100644 --- a/src/stdlib/abs.c +++ b/src/stdlib/abs.c @@ -1,5 +1,5 @@ #include <stdlib.h> -#include "limits.h" +#include <limits.h> /** absolute value **/ diff --git a/src/stdlib/atexit.c b/src/stdlib/atexit.c index 37f0ef72..79b486d0 100644 --- a/src/stdlib/atexit.c +++ b/src/stdlib/atexit.c @@ -1,5 +1,5 @@ +#include <errno.h> #include <stdlib.h> -#include "errno.h" #include "_stdlib.h" /** register a function to run at program exit **/ diff --git a/src/stdlib/calloc.c b/src/stdlib/calloc.c index ec5fbfdb..76317054 100644 --- a/src/stdlib/calloc.c +++ b/src/stdlib/calloc.c @@ -1,5 +1,5 @@ #include <stdlib.h> -#include "string.h" +#include <string.h> /** allocate and initialize memory **/ diff --git a/src/stdlib/div_t.c b/src/stdlib/div_t.c index 60acd660..7d17ddf2 100644 --- a/src/stdlib/div_t.c +++ b/src/stdlib/div_t.c @@ -1,12 +1,10 @@ -#include <stdlib.h> - -/** quotient and remainder **/ - typedef struct { int quot; int rem; } div_t; +/** quotient and remainder **/ + /*** is the type returned by FUNCTION(div) to hold both the quotient and remainder of an integer division. diff --git a/src/stdlib/getenv.c b/src/stdlib/getenv.c index 8cb99463..23b48d54 100644 --- a/src/stdlib/getenv.c +++ b/src/stdlib/getenv.c @@ -1,5 +1,5 @@ #include <stdlib.h> -#include "string.h" +#include <string.h> #include "_stdlib.h" /** get an environment variable **/ diff --git a/src/stdlib/labs.c b/src/stdlib/labs.c index 298c2e64..5a53524a 100644 --- a/src/stdlib/labs.c +++ b/src/stdlib/labs.c @@ -1,5 +1,5 @@ #include <stdlib.h> -#include "limits.h" +#include <limits.h> /** absolute value **/ diff --git a/src/stdlib/ldiv_t.c b/src/stdlib/ldiv_t.c index 00161cf6..0dac2bb0 100644 --- a/src/stdlib/ldiv_t.c +++ b/src/stdlib/ldiv_t.c @@ -1,12 +1,10 @@ -#include <stdlib.h> - -/** long quotient and remainder **/ - typedef struct { long int quot; long int rem; } ldiv_t; +/** long quotient and remainder **/ + /*** is the type returned by FUNCTION(ldiv) to hold both the quotient and remainder of an integer division. diff --git a/src/stdlib/mblen.c b/src/stdlib/mblen.c index db7c4f1c..9a575e9c 100644 --- a/src/stdlib/mblen.c +++ b/src/stdlib/mblen.c @@ -1,6 +1,7 @@ #include <stdlib.h> /** count bytes in multibyte character **/ + int mblen(const char * s, size_t n) { /* FIXME: forward dependency on AMD1 */ diff --git a/src/stdlib/rand.c b/src/stdlib/rand.c index d8f3fcff..c00515da 100644 --- a/src/stdlib/rand.c +++ b/src/stdlib/rand.c @@ -1,4 +1,3 @@ -#include <stdlib.h> #include "_stdlib.h" /** get a pseudo-random number **/ diff --git a/src/stdlib/size_t.ref b/src/stdlib/size_t.ref index e525842a..fc611c25 100644 --- a/src/stdlib/size_t.ref +++ b/src/stdlib/size_t.ref @@ -1,3 +1,2 @@ -#include <stdlib.h> REFERENCE(stddef/size_t.c) STDC(1) diff --git a/src/stdlib/srand.c b/src/stdlib/srand.c index af61570b..42d5be95 100644 --- a/src/stdlib/srand.c +++ b/src/stdlib/srand.c @@ -1,4 +1,3 @@ -#include <stdlib.h> #include "_stdlib.h" /** seed the pseudo-random number generator **/ diff --git a/src/stdlib/strtod.c b/src/stdlib/strtod.c index 9a1af627..20907ef8 100644 --- a/src/stdlib/strtod.c +++ b/src/stdlib/strtod.c @@ -1,8 +1,8 @@ +#include <ctype.h> +#include <errno.h> +#include <float.h> +#include <math.h> #include <stdlib.h> -#include "ctype.h" -#include "errno.h" -#include "float.h" -#include "math.h" #ifndef INFINITY #include "math/INFINITY.c" diff --git a/src/stdlib/strtol.c b/src/stdlib/strtol.c index 28d8f823..08ed591c 100644 --- a/src/stdlib/strtol.c +++ b/src/stdlib/strtol.c @@ -1,7 +1,7 @@ +#include <ctype.h> +#include <errno.h> +#include <limits.h> #include <stdlib.h> -#include "ctype.h" -#include "limits.h" -#include "errno.h" /** convert string to long integer **/ diff --git a/src/stdlib/strtoul.c b/src/stdlib/strtoul.c index 8ef4eb34..7a91823f 100644 --- a/src/stdlib/strtoul.c +++ b/src/stdlib/strtoul.c @@ -1,7 +1,7 @@ +#include <errno.h> +#include <ctype.h> +#include <limits.h> #include <stdlib.h> -#include "ctype.h" -#include "errno.h" -#include "limits.h" /** convert string to unsigned long integer **/ diff --git a/src/stdlib/wchar_t.ref b/src/stdlib/wchar_t.ref index d551680b..1e359832 100644 --- a/src/stdlib/wchar_t.ref +++ b/src/stdlib/wchar_t.ref @@ -1,3 +1,2 @@ -#include <stdlib.h> REFERENCE(stddef/wchar_t.c) STDC(1) diff --git a/src/string/NULL.ref b/src/string/NULL.ref index 5d6e9890..b247705b 100644 --- a/src/string/NULL.ref +++ b/src/string/NULL.ref @@ -1,3 +1,2 @@ -#include <string.h> REFERENCE(stddef/NULL.c) STDC(1) diff --git a/src/string/memchr.c b/src/string/memchr.c index 02fdfcdc..f39ef6bc 100644 --- a/src/string/memchr.c +++ b/src/string/memchr.c @@ -2,6 +2,7 @@ #include "_assert.h" /** search memory **/ + void * memchr(const void *s, int c, size_t n) { char *p = (char*)s; @@ -26,6 +27,7 @@ void * memchr(const void *s, int c, size_t n) searches the first ARGUMENT(n) bytes of memory at ARGUMENT(s) for ARGUMENT(c) (converted to an TYPE(unsigned char)). ***/ + /* STDC(1) */ diff --git a/src/string/memcmp.c b/src/string/memcmp.c index 20cb6df5..d5d94bf0 100644 --- a/src/string/memcmp.c +++ b/src/string/memcmp.c @@ -2,6 +2,7 @@ #include "_assert.h" /** compare memory regions **/ + int memcmp(const void *s1, const void *s2, size_t n) { unsigned char *p = (void*)s1; @@ -29,6 +30,7 @@ int memcmp(const void *s1, const void *s2, size_t n) compares the first ARGUMENT(n) bytes of memory at ARGUMENT(s1) and ARGUMENT(s2). ***/ + /* STDC(1) */ diff --git a/src/string/memcpy.c b/src/string/memcpy.c index 835411f3..69975605 100644 --- a/src/string/memcpy.c +++ b/src/string/memcpy.c @@ -2,6 +2,7 @@ #include "_assert.h" /** copy memory **/ + void * memcpy(void * restrict s1, const void * restrict s2, size_t n) { char *dst = (char*)s1; @@ -26,6 +27,7 @@ void * memcpy(void * restrict s1, const void * restrict s2, size_t n) copies ARGUMENT(n) bytes from the object at ARGUMENT(s2) to the object at ARGUMENT(s1). ***/ + /* STDC(1) */ diff --git a/src/string/memmove.c b/src/string/memmove.c index 5d72c862..c9ae1245 100644 --- a/src/string/memmove.c +++ b/src/string/memmove.c @@ -2,6 +2,7 @@ #include "_assert.h" /** move memory **/ + void * memmove(void *s1, const void *s2, size_t n) { ASSERT_NONNULL(s1); @@ -30,6 +31,7 @@ copies ARGUMENT(n) bytes of memory from the object at ARGUMENT(s2) to the object at ARGUMENT(s1). If ARGUMENT(s1) and ARGUMENT(s2) overlap, the memory is copied so that the ARGUMENT(n) bytes are safely written to ARGUMENT(s1). ***/ + /* STDC(1) */ diff --git a/src/string/memset.c b/src/string/memset.c index 9addc413..6991ba4e 100644 --- a/src/string/memset.c +++ b/src/string/memset.c @@ -2,6 +2,7 @@ #include "_assert.h" /** fill memory **/ + void * memset(void *s, int c, size_t n) { unsigned char *p = (unsigned char *)s; @@ -23,6 +24,7 @@ void * memset(void *s, int c, size_t n) fills the first ARGUMENT(n) bytes of memory at ARGUMENT(s) with the value ARGUMENT(c) (converted to an TYPE(unsigned char)). ***/ + /* STDC(1) */ diff --git a/src/string/size_t.ref b/src/string/size_t.ref index 3c087e0b..fc611c25 100644 --- a/src/string/size_t.ref +++ b/src/string/size_t.ref @@ -1,3 +1,2 @@ -#include <string.h> REFERENCE(stddef/size_t.c) STDC(1) diff --git a/src/string/strcat.c b/src/string/strcat.c index 51737787..77a95095 100644 --- a/src/string/strcat.c +++ b/src/string/strcat.c @@ -24,6 +24,7 @@ appends a copy of the string at ARGUMENT(s2) to the end of the string at ARGUMENT(s1). The first byte of ARGUMENT(s2) will overwrite the terminating null character of ARGUMENT(s1). ***/ + /* STDC(1) */ diff --git a/src/string/strchr.c b/src/string/strchr.c index f8a65bab..9aa16001 100644 --- a/src/string/strchr.c +++ b/src/string/strchr.c @@ -2,6 +2,7 @@ #include "_assert.h" /** string search **/ + char * strchr(const char *s, int c) { ASSERT_NONNULL(s); @@ -17,6 +18,7 @@ char * strchr(const char *s, int c) searches the string ARGUMENT(s) for the first occurrence of ARGUMENT(c) (converted to a TYPE(char)). ***/ + /* STDC(1) */ diff --git a/src/string/strcmp.c b/src/string/strcmp.c index 8925d1be..e447eb31 100644 --- a/src/string/strcmp.c +++ b/src/string/strcmp.c @@ -2,6 +2,7 @@ #include "_assert.h" /** compare strings **/ + int strcmp(const char *s1, const char *s2) { ASSERT_NONNULL(s1); @@ -35,6 +36,7 @@ int strcmp(const char *s1, const char *s2) /*** compares the strings at ARGUMENT(s1) and ARGUMENT(s2). ***/ + /* STDC(1) */ diff --git a/src/string/strcoll.c b/src/string/strcoll.c index a6a44e8d..875d990c 100644 --- a/src/string/strcoll.c +++ b/src/string/strcoll.c @@ -1,8 +1,9 @@ +#include <stdlib.h> #include <string.h> -#include "stdlib.h" #include "_assert.h" /** collate strings **/ + int strcoll(const char *s1, const char *s2) { char *x1 = NULL; @@ -38,7 +39,5 @@ compares the collation values of the strings at ARGUMENT(s1) and ARGUMENT(s2). /* LC_COLLATE -*/ -/* STDC(1) */ diff --git a/src/string/strcpy.c b/src/string/strcpy.c index ea8a9a1f..b6e3ed11 100644 --- a/src/string/strcpy.c +++ b/src/string/strcpy.c @@ -2,6 +2,7 @@ #include "_assert.h" /** copy string **/ + char * strcpy(char * restrict s1, const char * restrict s2) { char *p = s1; @@ -24,6 +25,7 @@ char * strcpy(char * restrict s1, const char * restrict s2) copies the string at ARGUMENT(s2) to ARGUMENT(s1), up to and including the terminating CHAR(\0). ***/ + /* STDC(1) */ diff --git a/src/string/strcspn.c b/src/string/strcspn.c index 49f7d92b..58d3f33b 100644 --- a/src/string/strcspn.c +++ b/src/string/strcspn.c @@ -2,6 +2,7 @@ #include "_assert.h" /** count non-matching characters **/ + size_t strcspn(const char *s1, const char *s2) { size_t i = 0; @@ -22,7 +23,8 @@ size_t strcspn(const char *s1, const char *s2) the number of characters that the beginning of the string ARGUMENT(s1) that are not in the string ARGUMENT(s2). ***/ + /* - RETURN_ALWAYS(the number of non-matching characters); +RETURN_ALWAYS(the number of non-matching characters); STDC(1) */ diff --git a/src/string/strerror.c b/src/string/strerror.c index 055a11f7..a2d43f0c 100644 --- a/src/string/strerror.c +++ b/src/string/strerror.c @@ -1,9 +1,11 @@ +#include <errno.h> +#include <stdio.h> #include <string.h> -#include "errno.h" -#include "stdio.h" + # define __LONGEST_STRERR 64 /* FIXME */ /** convert error number to string **/ + char * strerror(int errnum) { static char errstr[__LONGEST_STRERR+1]; @@ -26,6 +28,7 @@ converts the error number ARGUMENT(errnum) to an error message string. The string returned should not be modified, and may be overwritten by subsequent calls. ***/ + /* STDC(1) */ diff --git a/src/string/strlen.c b/src/string/strlen.c index 53e62e98..5425970b 100644 --- a/src/string/strlen.c +++ b/src/string/strlen.c @@ -19,7 +19,8 @@ size_t strlen(const char *s) counts the number of bytes in the string ARGUMENT(s), not including the terminating null character. ***/ + /* - RETURN_ALWAYS(the length of the string); +RETURN_ALWAYS(the length of the string); STDC(1) */ diff --git a/src/string/strncat.c b/src/string/strncat.c index e2a64ad5..cd3c8efc 100644 --- a/src/string/strncat.c +++ b/src/string/strncat.c @@ -2,6 +2,7 @@ #include "_assert.h" /** concatenate bounded string **/ + char * strncat(char * restrict s1, const char * restrict s2, size_t n) { char *append = NULL; @@ -34,7 +35,8 @@ overwrite the terminating null character of ARGUMENT(s1). No characters after th first CHAR(\0) will be copied. The resulting string will always be null terminated. ***/ + /* - RETURN_ALWAYS(ARGUMENT(s1)); +RETURN_ALWAYS(ARGUMENT(s1)); STDC(1) */ diff --git a/src/string/strncmp.c b/src/string/strncmp.c index 340ac6b8..e5d92e3e 100644 --- a/src/string/strncmp.c +++ b/src/string/strncmp.c @@ -2,6 +2,7 @@ #include "_assert.h" /** compare bound strings **/ + int strncmp(const char *s1, const char *s2, size_t n) { ASSERT_NONNULL(s1); @@ -26,6 +27,7 @@ int strncmp(const char *s1, const char *s2, size_t n) compares up to the first ARGUMENT(n) bytes of the strings at ARGUMENT(s1) and ARGUMENT(s2), or until the first CHAR(\0), whichever comes first. ***/ + /* STDC(1) */ diff --git a/src/string/strncpy.c b/src/string/strncpy.c index 0ecd19fc..b714f0cf 100644 --- a/src/string/strncpy.c +++ b/src/string/strncpy.c @@ -2,6 +2,7 @@ #include "_assert.h" /** copy bounded string **/ + char * strncpy(char * restrict s1, const char * restrict s2, size_t n) { size_t i; @@ -28,7 +29,8 @@ ARGUMENT(s1) until ARGUMENT(n) bytes have been written. If no null characters ar in the first ARGUMENT(n) bytes of ARGUMENT(s2), the resulting string will not be null terminated. ***/ + /* - RETURN_ALWAYS(ARGUMENT(s1)); +RETURN_ALWAYS(ARGUMENT(s1)); STDC(1) */ diff --git a/src/string/strpbrk.c b/src/string/strpbrk.c index 096917ff..9ad6a5ff 100644 --- a/src/string/strpbrk.c +++ b/src/string/strpbrk.c @@ -2,6 +2,7 @@ #include "_assert.h" /** count matching characters **/ + char * strpbrk(const char *s1, const char *s2) { size_t i; @@ -21,8 +22,9 @@ char * strpbrk(const char *s1, const char *s2) /*** locates the first occurence in ARGUMENT(s1) of any character in ARGUMENT(s2). ***/ + /* - RETURN_FAILURE(CONSTANT(NULL)); - RETURN_SUCCESS(a pointer to the located character); +RETURN_FAILURE(CONSTANT(NULL)); +RETURN_SUCCESS(a pointer to the located character); STDC(1) */ diff --git a/src/string/strrchr.c b/src/string/strrchr.c index 799fb3dd..8b033596 100644 --- a/src/string/strrchr.c +++ b/src/string/strrchr.c @@ -2,6 +2,7 @@ #include "_assert.h" /** search string from end **/ + char * strrchr(const char *s, int c) { int i = 0; @@ -25,6 +26,7 @@ char * strrchr(const char *s, int c) finds the last occurence of ARGUMENT(c) (converted to TYPE(char)) in the string ARGUMENT(s). ***/ + /* STDC(1) */ diff --git a/src/string/strspn.c b/src/string/strspn.c index 450b541f..098ea8d0 100644 --- a/src/string/strspn.c +++ b/src/string/strspn.c @@ -2,6 +2,7 @@ #include "_assert.h" /** count matching characters **/ + size_t strspn(const char *s1, const char *s2) { size_t i = 0; @@ -22,7 +23,8 @@ size_t strspn(const char *s1, const char *s2) computes the length of the maximum initial segment of the ARGUMENT(s1) made up of characters from ARGUMENT(s2). ***/ + /* - RETURN_ALWAYS(the number of matching characters); +RETURN_ALWAYS(the number of matching characters); STDC(1) */ diff --git a/src/string/strstr.c b/src/string/strstr.c index bdcabc9e..3dd968da 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -2,6 +2,7 @@ #include "_assert.h" /** search for substring **/ + char * strstr(const char *s1, const char *s2) { size_t l1 = 0; @@ -38,6 +39,7 @@ finds the first occurrence of the string ARGUMENT(s2) in the string ARGUMENT(s1). Specifying the empty string for ARGUMENT(s2) matches the first character of ARGUMENT(s1). ***/ + /* STDC(1) */ diff --git a/src/string/strtok.c b/src/string/strtok.c index 141d3982..f6c340ef 100644 --- a/src/string/strtok.c +++ b/src/string/strtok.c @@ -2,6 +2,7 @@ #include "_assert.h" /** split string into tokens **/ + char * strtok(char * restrict s1, const char * restrict s2) { static char *current = 0; @@ -31,6 +32,7 @@ The list of token separators in ARGUMENT(s2) may vary from call to call. When tokens are found, the next token separate character is replaced with a CHAR(\0), terminating the token. ***/ + /* STDC(1) */ diff --git a/src/string/strxfrm.c b/src/string/strxfrm.c index eb4a6d15..c107d662 100644 --- a/src/string/strxfrm.c +++ b/src/string/strxfrm.c @@ -2,6 +2,7 @@ #include "_assert.h" /** transform string **/ + size_t strxfrm(char * restrict s1, const char * restrict s2, size_t n) { /* TODO */ @@ -25,8 +26,6 @@ transformed, no further characters are transformed. /* UNDEFINED(ARGUMENT(n) is not ZERO and ARGUMENT(s1) is CONSTANT(NULL)) -*/ -/* - RETURN_ALWAYS(the length of the transformed string, not including the terminating CHAR(\0)); +RETURN_ALWAYS(the length of the transformed string, not including the terminating CHAR(\0)); STDC(1) */ diff --git a/src/time/CLOCKS_PER_SEC.c b/src/time/CLOCKS_PER_SEC.c index 7ef4bb89..e8e8350d 100644 --- a/src/time/CLOCKS_PER_SEC.c +++ b/src/time/CLOCKS_PER_SEC.c @@ -1,4 +1,3 @@ -#include <time.h> #define CLOCKS_PER_SEC ((clock_t)1000000) /** clock ticks per second **/ diff --git a/src/time/NULL.ref b/src/time/NULL.ref index 0ac4b016..b247705b 100644 --- a/src/time/NULL.ref +++ b/src/time/NULL.ref @@ -1,3 +1,2 @@ -#include <time.h> REFERENCE(stddef/NULL.c) STDC(1) diff --git a/src/time/asctime.c b/src/time/asctime.c index 06dceae8..1b96a6e0 100644 --- a/src/time/asctime.c +++ b/src/time/asctime.c @@ -1,7 +1,8 @@ +#include <stdio.h> #include <time.h> -#include "stdio.h" /** convert broken down time to string **/ + char * asctime(const struct tm * timeptr) { const char days[7][3] = { diff --git a/src/time/clock.c b/src/time/clock.c index a141e36d..bba89063 100644 --- a/src/time/clock.c +++ b/src/time/clock.c @@ -1,6 +1,7 @@ #include <time.h> /** get processor time **/ + clock_t clock(void) { return (clock_t)-1; diff --git a/src/time/clock_t.c b/src/time/clock_t.c index fe7a3842..d6e5d966 100644 --- a/src/time/clock_t.c +++ b/src/time/clock_t.c @@ -1,5 +1,5 @@ -#include <time.h> -typedef long int clock_t; +typedef long int + clock_t; /** clock ticks **/ diff --git a/src/time/size_t.ref b/src/time/size_t.ref index 75ce0309..fc611c25 100644 --- a/src/time/size_t.ref +++ b/src/time/size_t.ref @@ -1,3 +1,2 @@ -#include <time.h> REFERENCE(stddef/size_t.c) STDC(1) diff --git a/src/time/strftime.c b/src/time/strftime.c index c229e26d..dfb68276 100644 --- a/src/time/strftime.c +++ b/src/time/strftime.c @@ -1,7 +1,7 @@ +#include <locale.h> +#include <stdio.h> #include <time.h> -#include "stdio.h" #include "_assert.h" -#include "locale.h" #include "locale/_locale.h" /** convert time to a formatted string **/ @@ -189,8 +189,5 @@ UNDEFINED(Copying takes place between objects that overlap) LC_TIME RETURN_FAILURE(ZERO) RETURN_SUCCESS(the length of the converted string, not counting the terminating null) -*/ - -/* STDC(1) */ diff --git a/src/time/struct_tm.c b/src/time/struct_tm.c index 067d54f3..e7f0376f 100644 --- a/src/time/struct_tm.c +++ b/src/time/struct_tm.c @@ -1,7 +1,3 @@ -#include <time.h> - -/** broken-down time **/ - struct tm { int tm_sec; /* Seconds [0,60] */ int tm_min; /* Minutes [0, 59] */ @@ -14,6 +10,8 @@ struct tm { int tm_isdst; /* Daylight Saving Time flag */ }; +/** broken-down time **/ + /*** is used to represent time broken down into its individual components. ***/ diff --git a/src/time/time.c b/src/time/time.c index ca99964f..d6f4ba7f 100644 --- a/src/time/time.c +++ b/src/time/time.c @@ -1,5 +1,5 @@ #include <time.h> -#include "errno.h" +#include <errno.h> #include "_syscall.h" /** get current time **/ diff --git a/src/time/time_t.c b/src/time/time_t.c index df2f34e8..58cf3fb0 100644 --- a/src/time/time_t.c +++ b/src/time/time_t.c @@ -1,9 +1,8 @@ -#include <time.h> +typedef long int + time_t; /** time representation **/ -typedef long int time_t; - /*** is used for representing time. ***/ |