Commit Graph

60 Commits

Author SHA1 Message Date
Stephen Heumann
facd1bf992 Add parentheses around negative values in float.h. 2022-12-04 22:44:48 -06:00
Stephen Heumann
5be888a2bd Make stdin/stdout/stderr into macros.
They are supposed to be macros, according to the C standards. This ordinarily doesn't matter, but it can be detected by #ifdef, as in the following program:

#include <stdio.h>
#ifdef stdin
int main(void) {
        puts("stdin is a macro");
}
#endif
2022-10-15 17:10:59 -05:00
Stephen Heumann
753c9b9f20 Adjust the way FE_DFL_ENV is defined.
This avoids any possible issue with code possibly expecting __FE_DFL_ENV to be in the data bank when using the large memory model, although I don't think that happened in practice.
2022-07-11 18:30:37 -05:00
Stephen Heumann
f6fedea288 Update release notes and header to reflect recent stdio fixes. 2022-07-04 22:28:45 -05:00
Stephen Heumann
06bf0c5f46 Remove macro definition of rewind() which does not clear the IO error indicator.
Now rewind() will always be called as a function. In combination with an update to the rewind() function in ORCALib, this will ensure that the error indicator is always cleared, as required by the C standards.
2022-06-24 18:32:08 -05:00
Stephen Heumann
3058ea6ad9 Fix FP_ILOGB0 and FP_ILOGBNAN macros.
They were missing the FP_ prefix.
2022-01-06 18:01:52 -06:00
Stephen Heumann
bccbcb132b Add headers and docs for additional functions. 2021-12-24 15:57:29 -06:00
Stephen Heumann
c767848ec9 Add headers and docs for the acosh functions. 2021-12-05 13:52:40 -06:00
Stephen Heumann
6fa294aa3b Add documentation and headers for new <math.h> functions. 2021-11-28 19:54:51 -06:00
Stephen Heumann
aaec648e69 Protect against undefinition/redefinition of fpclassify. 2021-11-28 19:39:03 -06:00
Stephen Heumann
dda37cd17c Define math_errhandling to MATH_ERREXCEPT.
This indicates that floating-point exceptions are used to report math errors. The existing functions will still also set errno in the existing cases, but the new C99 functions generally will not.
2021-11-21 14:46:47 -06:00
Stephen Heumann
b2874b8bf6 Add declarations and docs for float/long double versions of existing functions. 2021-11-21 14:38:30 -06:00
Stephen Heumann
4ebdb4ad04 Add the <tgmath.h> header containing type-generic math macros.
So far this only has macros for the newly-added functions, since the existing math functions in SysFloat do not have f- and l-suffixed versions.
2021-11-20 19:45:07 -06:00
Stephen Heumann
73a081bd55 Add header declarations and documentation for new math functions. 2021-11-20 19:33:04 -06:00
Stephen Heumann
1010f9a906 Add the FP comparison macros in <math.h> (from C99).
These rely on a new internal function that has been added to ORCALib.
2021-11-02 21:59:01 -05:00
Stephen Heumann
26d0f2ad35 Add the va_copy macro (from C99).
The previous changes to varargs handling enable this to work.
2021-10-23 22:36:53 -05:00
Stephen Heumann
a20d69a211 Revise variable argument handling to better comply with standards.
In the new implementation, variable arguments are not removed until the end of the function. This allows variable argument processing to be restarted, and it prevents the addresses of local variables from changing in the middle of the function. The requirement to turn off stack repair code around varargs functions is also removed.

This fixes #58.
2021-10-23 22:36:34 -05:00
Stephen Heumann
cc8e003860 Add <uchar.h> header. 2021-10-02 22:39:52 -05:00
Stephen Heumann
bf2c1f2266 Add EILSEQ errno value.
This is required by C95 and later; it may be set by character/string conversion functions. Note that the value of 12 conflicts with GNO's existing definition of EPERM. This should not cause much trouble, but GNO could potentially define its own different value for EILSEQ, with the GNO version of ORCALib adjusted accordingly.
2021-10-02 14:38:15 -05:00
Stephen Heumann
8ab065411f Add header declarations for strcoll, strxfrm, and mblen. 2021-09-30 18:41:17 -05:00
Stephen Heumann
02790c11e3 Add <locale.h> header.
The definitions here are aligned with the new implementation of the <locale.h> functions in ORCALib.
2021-09-30 18:40:39 -05:00
Stephen Heumann
38dc91892b Add header declaration and documentation for strftime. 2021-09-26 21:29:47 -05:00
Stephen Heumann
438942692a Make va_arg(ap,double) work correctly.
This was not working because floating-point arguments are really passed in the extended format, but based on the wording in the C standard a type of "double" should still work for arguments passed with that type.

This fixes #29. (The bug report was valid only with respect to double, not float or long double.)
2021-09-03 21:25:20 -05:00
Stephen Heumann
08dbe1eea3 Include the function name in assertion failure messages.
This is required by C99 and later, enabled by the availability of __func__.

This requires an updated assertion-printing function in ORCALib. Unfortunately, GNO has the assertion-printing function in its libc rather than in ORCALib, because it calls the GNO implementation of stdio. Therefore, we continue to use the old form under GNO for now, to maintain compatibility with its existing libc.
2021-08-24 18:35:01 -05:00
Stephen Heumann
aa5b239824 Make CLOCKS_PER_SEC and CLK_TCK work in 50Hz video mode.
Previously, they were hard-coded as 60, but the clock tick frequency actually depends on the video mode. They now call a new library function that can detect the video mode and return the proper value.

This also makes CLOCKS_PER_SEC have the type clock_t, as C99 and later require.
2021-08-23 21:58:19 -05:00
Stephen Heumann
e4515e580a Omit all non-standard stuff from <ctype.h> if __KeepNamespacePure__ is defined.
This affects the toint function and the _tolower and _toupper macros. Several other non-standard functions and macros were already being omitted.
2021-08-22 17:35:16 -05:00
Stephen Heumann
bb51e77193 Make MB_CUR_MAX have type size_t, as C99 and later require. 2021-08-22 17:35:16 -05:00
Stephen Heumann
dae27757d3 As of C11, errno must be a macro, so make it one. 2021-03-11 21:16:41 -06:00
Stephen Heumann
8fd091e119 Implement the signbit() macro.
This uses a new helper function.
2021-03-09 00:24:08 -06:00
Stephen Heumann
a3006e46b1 Add more floating-point classification macros. 2021-03-09 00:08:04 -06:00
Stephen Heumann
17a7fc5487 Add fpclassify() macro and some other stuff from C99 to <math.h>.
fpclassify() is a type-generic macro that is implemented via new internal library routines.
2021-03-08 23:42:44 -06:00
Stephen Heumann
cad042b95b Add new <float.h> macros from C99 and C11. 2021-03-08 19:16:28 -06:00
Stephen Heumann
0ba8e4adb0 Update the limit values in <float.h>.
The correct values for LDBL_MAX and LDBL_MIN can now be provided, because we support long double constants. The other values are also updated to have more precision, so that they evaluate to bit-correct values in the long double format.
2021-03-08 18:32:33 -06:00
Stephen Heumann
92048171ef Update definition of FLT_ROUNDS to reflect the dynamic rounding mode. 2021-03-06 16:40:35 -06:00
Stephen Heumann
2630b51b74 Add the <fenv.h> header. 2021-03-06 16:31:52 -06:00
Stephen Heumann
5268f37261 Merge branch 'master' into longlong 2021-02-17 15:38:06 -06:00
Stephen Heumann
28888cf824 Exclude non-standard functions in <string.h> if __KeepNamespacePure__ is defined. 2021-02-17 15:36:38 -06:00
Stephen Heumann
31adb5f5d6 Update headers to support long long (and intmax_t typedef'd as long long).
This includes:
*Functions operating on long long in <stdlib.h>
*Limits of long long types in <limits.h>
*64-bit types and limits (plus intmax_t and its limits) in <stdint.h>
*New format codes, plus functions operating on intmax_t, in <inttypes.h>

The new stuff is generally conditionalized to only be included if __ORCAC_HAS_LONG_LONG__ is defined, or if the implementation claims to be C99 or later. This allows the headers to remain usable with older versions of ORCA/C, or with any hypothetical "strict C89" mode that might be implemented in the future.
2021-02-17 14:57:18 -06:00
Stephen Heumann
25697b1fba Add prototypes for vscanf, vfscanf, and vsscanf. 2021-02-09 23:24:20 -06:00
Stephen Heumann
acab97ae08 Add <stdbool.h> header.
Also, revise handling of boolean constants in <types.h> so that they do not conflict with the definitions in <stdbool.h>.
2021-01-25 22:04:26 -06:00
Stephen Heumann
8a69b3c905 Update headers and notes to include quick_exit and at_quick_exit. 2020-01-23 18:46:22 -06:00
Stephen Heumann
9be97ebf02 Add fscanf format specifiers for 8-bit types in <inttypes.h>.
These are now supported in ORCALib.
2020-01-22 12:14:39 -06:00
Stephen Heumann
bc1f6eb457 Add <stdnoreturn.h> header. 2020-01-19 12:44:20 -06:00
Stephen Heumann
d9ebdd10df Header updates for C11 alignment functionality.
This includes the new header <stdalign.h>, the new function aligned_alloc(), and the new typedef max_align_t.
2020-01-12 18:39:07 -06:00
Stephen Heumann
6f2eb301e5 Implement C11 _Static_assert mechanism.
This allows code to contain static assertions (checked at compile time).
2020-01-04 18:16:29 -06:00
Stephen Heumann
1af7505a00 Add prototypes for SANE housekeeping calls in <sane.h>.
There still aren't prototypes for the main SANE calls, since they aren't really designed to be called directly from C, and may take variable numbers of parameters depending on the operation.
2018-11-19 21:56:24 -06:00
Stephen Heumann
a359543769 Add EACCES as another name for EACCESS in <errno.h>.
The EACCES name is used in the ORCA/C manual, and also matches the name in POSIX and GNO. EACCESS is retained as an alias for compatibility.
2018-09-10 18:26:24 -05:00
Stephen Heumann
e8d89c9b39 Add prototype for _Exit() function from C99. 2018-09-10 17:41:53 -05:00
Stephen Heumann
dc0f7dc4e4 Correct most of the LDBL_* values in <float.h>.
These had been the values appropriate for double, not accounting for the fact that long double is now the 80-bit extended type.

The integer LDBL_* values have now all been updated to be correct, as has LDBL_EPSILON. LDBL_MAX and LDBL_MIN are still not correct, because ORCA/C internally processes floating-point constants in the double format, and so the correct values would get rounded to INF and 0, respectively.

Note that the SANE 80-bit extended format is almost like the x87 80-bit extended format used for long double on many modern systems, but not entirely. The difference is that SANE allows the biased exponent field of an extended value (either normalized or denormalized) to be 0, yielding an effective exponent of 0-16383 = -16383. x87 uses an effective exponent of -16382 in these cases (which it considers to be pseudo-denormalized or denormalized), yielding values that are twice as large as the SANE values. This difference causes LDBL_MIN_EXP to be different, and would also cause LDBL_MIN to be different if it could be represented correctly.
2018-09-08 22:39:30 -05:00
Stephen Heumann
463da80902 Small tweaks to <stdarg.h>.
*Use a typedef rather than a macro definition for va_list. (The C standards specify that va_list is a type, although this would make a practical difference only if someone #undef'd it.)

*Don't include a semicolon in va_start(), so it expands to an expression rather than a statement. This could make a difference in a construct like "if (...) va_start(...); else ...".
2018-08-28 18:58:27 -05:00