Commit 948e0838 authored by ROOL's avatar ROOL :robot:
Browse files

CLib header updates

Detail:
  assert.h - definition of static_assert
  complex.h - definition of CMPLX[F|L]
  float.h - various implementation defines
  stdio.h - hide gets() as it's been withdrawn
  wchar.h - guard mbstate_t as it can also be in uchar.h, fix missing __valist definition
Admin:
  In order that the functions can be defined in the stubs now (despite not having a compiler to support C11/C18) they are enabled when 'DDE' is defined so that C library builds work.
......@@ -14,10 +14,10 @@
*/
#pragma force_top_level
/* assert.h: ISO 'C' (9899:1999) library header, section 7.2 */
/* assert.h: ISO 'C' (9899:2018) library header, section 7.2 */
/* Copyright (C) Codemist Ltd. */
/* Copyright (C) Acorn Computers Ltd. 1991, 1992 */
/* version 2.01 */
/* version 2.02 */
/*
* The assert macro puts diagnostics into programs. When it is executed,
......@@ -44,6 +44,9 @@
#else
extern void __assert(const char *, const char *, int);
extern void __assert2(const char *, const char *, const char *, int);
# if __STDC_VERSION__ >= 201112
# define static_assert _Static_assert
# endif
#endif
#else
# undef assert
......
......@@ -15,9 +15,9 @@
#pragma force_top_level
#pragma include_only_once
/* complex.h: ISO 'C' (9899:1999) library header, sections 7.3 and G.6 */
/* complex.h: ISO 'C' (9899:2018) library header, sections 7.3 and G.6 */
/* Copyright (C) Acorn Computers Ltd. 2005 */
/* version 1.00 */
/* version 1.01 */
/*
* The header <complex.h> defines macros and declares functions that support
......@@ -207,6 +207,11 @@ long double cimagl(long double complex /*z*/);
#define cimagl(z) ((void) sizeof cimagl(z), (long double _Imaginary)(z)/_Imaginary_I)
/* computes the imaginary part of z. */
/* Returns: the imaginary part value (as a real) */
#define CMPLX(x,y) (double _Complex)((double)(x) + ___i * (double)(y))
#define CMPLXF(x,y) (float _Complex)((float)(x) + ___i * (float)(y))
#define CMPLXL(x,y) (long double _Complex)((long double)(x) + ___i * (long double)(y))
/* an expression suitable for use as an initialiser for an object with */
/* static or thread storage duration, with the complex value x + iy */
double complex conj(double complex /*z*/);
float complex conjf(float complex /*z*/);
long double complex conjl(long double complex /*z*/);
......
......@@ -15,10 +15,10 @@
#pragma force_top_level
#pragma include_only_once
/* float.h: ISO 'C' (9899 Dec 99) library header, section 5.2.4.2.2 */
/* float.h: ISO 'C' (9899:2018) library header, section 5.2.4.2.2 */
/* Copyright (C) Codemist Ltd, 1988 */
/* Copyright (C) Acorn Computers Ltd. 1991, 1992 */
/* version 3.00 */
/* version 3.01 */
#ifndef __float_h
#define __float_h
......@@ -54,15 +54,31 @@
* ? : all other negative values are implementation defined.
*/
#define FLT_HAS_SUBNORM 1
#define DBL_HAS_SUBNORM 1
#define LDBL_HAS_SUBNORM 1
/*
* The implementation's handling of subnormal numbers:
* -1 : indeterminable.
* 0 : absent (type does not support subnormal numbers)
* 1 : present (type does support subnormal numbers)
*/
#define FLT_MANT_DIG 24
#define DBL_MANT_DIG 53
#define LDBL_MANT_DIG 53
/* number of base-FLT_RADIX digits in the floating point mantissa */
#define DECIMAL_DIG 17
#define FLT_DECIMAL_DIG 9
#define DBL_DECIMAL_DIG 17
#define LDBL_DECIMAL_DIG 17
/* number of decimal digits required to hold a floating-point number */
/* accurately. */
#define DECIMAL_DIG 17
/* number of decimal digits required to hold a floating-point number */
/* accurately in the widest supported type. */
#define FLT_DIG 6
#define DBL_DIG 15
#define LDBL_DIG 15
......@@ -107,6 +123,11 @@
#define LDBL_MIN 2.22507385850720138e-308L
/* minimum normalised positive floating-point number. */
#define FLT_TRUE_MIN 1.40129846e-45F
#define DBL_TRUE_MIN 4.94065645841246544e-324
#define LDBL_TRUE_MIN 4.94065645841246544e-324L
/* minimum positive floating-point number. */
#endif
/* end of float.h */
......@@ -15,10 +15,10 @@
#pragma force_top_level
#pragma include_only_once
/* stdio.h: ISO 'C' (9899:1999) library header, section 7.19 */
/* stdio.h: ISO 'C' (9899:2018) library header, section 7.21 */
/* Copyright (C) Codemist Ltd. */
/* Copyright (C) Acorn Computers Ltd., 1990, 1992 */
/* version 3.03 */
/* version 3.04 */
/*
* stdio.h declares three types, several macros, and many functions for
......@@ -620,6 +620,7 @@ int (getchar)(void);
* set and getchar returns EOF. If a read error occurs, the error
* indicator is set and getchar returns EOF.
*/
#if __STDC_VERSION__ < 201112
char *gets(char * /*s*/);
/*
* reads characters from the input stream pointed to by stdin into the array
......@@ -632,6 +633,7 @@ char *gets(char * /*s*/);
* during the operation, the array contents are indeterminate and a
* null pointer is returned.
*/
#endif
int __flsbuf(int /*c*/, FILE * /*stream*/);
/*
* SYSTEM USE ONLY, called by putc to flush buffer and or sort out flags.
......
......@@ -36,17 +36,20 @@
typedef unsigned int size_t; /* from <stddef.h> */
#endif
typedef struct __mbstate_t_struct
{
wchar_t __c; // current character?
int __n; // pending bytes?
wchar_t __min;
} mbstate_t;
#ifndef __mbstate_t
# define __mbstate_t 1
typedef struct __mbstate_struct
{
wchar_t __c; /* current character? */
int __n; /* pending bytes? */
wchar_t __min;
} mbstate_t;
/*
* an object type other than an array type that can hold the conversion
* state information necessary to convert between sequences of multibyte
* characters and wide characters
*/
#endif
typedef int wint_t;
/*
......@@ -58,6 +61,7 @@ typedef int wint_t;
struct tm; /* see <time.h> */
struct __FILE_struct; /* see <stdio.h> */
typedef char *__va_listwc[1]; /* keep in step with <stdarg.h> */
#ifndef NULL
# define NULL 0 /* see <stddef.h> */
......@@ -185,7 +189,7 @@ int swscanf(const wchar_t * restrict /*s*/,
*/
#pragma -v0 /* back to default */
int vfwprintf(struct __FILE_struct * restrict /*stream*/,
const wchar_t * restrict /*format*/, __valist /*arg*/);
const wchar_t * restrict /*format*/, __va_listwc /*arg*/);
/*
* is equivalent to fwprintf, with the variable argument list replaced by
* arg, which shall have been initialised by the va_start macro (and possibly
......@@ -195,7 +199,7 @@ int vfwprintf(struct __FILE_struct * restrict /*stream*/,
* an output or encoding error occurred.
*/
int vfwscanf(struct __FILE_struct * restrict /*stream*/,
const wchar_t * restrict /*format*/, __valist /*arg*/);
const wchar_t * restrict /*format*/, __va_listwc /*arg*/);
/*
* is equivalent to fwscanf, with the variable argument list replaced by
* arg, which shall have been initialised by the va_start macro (and possibly
......@@ -206,7 +210,7 @@ int vfwscanf(struct __FILE_struct * restrict /*stream*/,
* of input items assigned, which can be fewer than provided for,
* or even zero, in the event of an early matching failure.
*/
int vwprintf(const wchar_t * restrict /*format*/, __valist /*arg*/);
int vwprintf(const wchar_t * restrict /*format*/, __va_listwc /*arg*/);
/*
* is equivalent to wprintf, with the variable argument list replaced by arg,
* which shall have been initialised by the va_start macro (and possibly
......@@ -215,7 +219,7 @@ int vwprintf(const wchar_t * restrict /*format*/, __valist /*arg*/);
* Returns: the number of wide characters transmitted, or a negative value if
* an output or encoding error occurred.
*/
int vwscanf(const wchar_t * restrict /*format*/, __valist /*arg*/);
int vwscanf(const wchar_t * restrict /*format*/, __va_listwc /*arg*/);
/*
* is equivalent to wscanf, with the variable argument list replaced by arg,
* which shall have been initialised by the va_start macro (and possibly
......@@ -227,7 +231,7 @@ int vwscanf(const wchar_t * restrict /*format*/, __valist /*arg*/);
* even zero, in the event of an early matching failure.
*/
int vswprintf(wchar_t * restrict /*s*/, size_t n,
const wchar_t * restrict /*format*/, __valist /*arg*/);
const wchar_t * restrict /*format*/, __va_listwc /*arg*/);
/*
* is equivalent to swprintf, with the variable argument list replaced by
* arg, which shall have been initialised by the va_start macro (and possibly
......@@ -239,7 +243,7 @@ int vswprintf(wchar_t * restrict /*s*/, size_t n,
* requested to be generated.
*/
int vswscanf(const wchar_t * restrict /*s*/,
const wchar_t * restrict /*format*/, __valist /*arg*/);
const wchar_t * restrict /*format*/, __va_listwc /*arg*/);
/*
* is equivalent to swscanf, with the variable argument list replaced by arg,
* which shall have been initialised by the va_start macro (and possibly
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment