summaryrefslogtreecommitdiff
path: root/StdLib
diff options
context:
space:
mode:
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-15 19:05:36 +0000
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-15 19:05:36 +0000
commita430bdb13215eac169cd1c7e3e2fe88124c84b8e (patch)
treec3cbc5768c704fab8d21b07c29a62c2e0f08bf06 /StdLib
parentabb4e5f3460fd4bf6ab1bf7ef67a8bddaf238f67 (diff)
downloadedk2-a430bdb13215eac169cd1c7e3e2fe88124c84b8e.zip
edk2-a430bdb13215eac169cd1c7e3e2fe88124c84b8e.tar.gz
edk2-a430bdb13215eac169cd1c7e3e2fe88124c84b8e.tar.bz2
Update or add comments to files and functions for use by Doxygen.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12139 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib')
-rw-r--r--StdLib/Include/Ia32/machine/signal.h22
-rw-r--r--StdLib/Include/locale.h149
-rw-r--r--StdLib/Include/math.h679
-rw-r--r--StdLib/Include/setjmp.h27
-rw-r--r--StdLib/Include/signal.h52
-rw-r--r--StdLib/Include/stdarg.h87
-rw-r--r--StdLib/Include/stdbool.h21
-rw-r--r--StdLib/Include/stddef.h56
-rw-r--r--StdLib/Include/stdio.h1335
-rw-r--r--StdLib/Include/sys/signal.h30
-rw-r--r--StdLib/LibC/Stdio/fgetpos.c2
11 files changed, 1746 insertions, 714 deletions
diff --git a/StdLib/Include/Ia32/machine/signal.h b/StdLib/Include/Ia32/machine/signal.h
index 6628eb9..235797f 100644
--- a/StdLib/Include/Ia32/machine/signal.h
+++ b/StdLib/Include/Ia32/machine/signal.h
@@ -1,21 +1,21 @@
-/**
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
+/** @file
+ Machine (processor architecture) specific portion of <signal.h>.
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _MACHINE_SIGNAL_H
#define _MACHINE_SIGNAL_H
#include <sys/EfiCdefs.h>
-/** The type sig_atomic_t is the (possibly volatile-qualified) integer type of
- an object that can be accessed as an atomic entity, even in the presence
- of asynchronous interrupts.
+/** The type sig_atomic_t is the type of an object that can be accessed as an
+ atomic entity, even in the presence of asynchronous interrupts.
**/
typedef INTN sig_atomic_t;
diff --git a/StdLib/Include/locale.h b/StdLib/Include/locale.h
index 73a6bf4..93aac0a 100644
--- a/StdLib/Include/locale.h
+++ b/StdLib/Include/locale.h
@@ -44,44 +44,97 @@
#ifndef _LOCALE_H_
#define _LOCALE_H_
-/** This is a structure containing members pertaining to the formatting of numeric values.
- There is no requirement for members of this structure to be in any particular order.
+/** This is a structure containing members pertaining to the formatting and display of numeric values.
+ Each member of this structure is commented with its value in the "C" locale.
+
+ The decimal_point member must point to a string with a length greater than zero.
+ All other pointer members may point to "" in order to indicate that the value is not available
+ in the current locale, or that it is of zero length. Except for grouping and mon_grouping, the
+ strings start and end in the initial shift state.
+
+ The remaining members, of type char, are non-negative numbers or CHAR_MAX, which indicates that
+ the value is not available in the current locale.
+
+ Members grouping and mon_grouping point to strings where each element (character) of the string
+ indicates the size of the corresponding group of digits and is interpreted as follows:
+ - CHAR_MAX No further grouping is to be performed.
+ - 0 The previous element is to be repeatedly used for the remainder of the digits.
+ - other The ISO specification states: "The integer value is the number of digits that
+ compose the current group. The next element is examined to determine the size
+ of the next group of digits before the current group." The EDK II implementation
+ interprets this to mean that the groups are specified left-to-right.
+
+ The *_sep_by_space members are interpreted as follows:
+ - 0 No space separates the currency symbol and value.
+ - 1 If the currency symbol and sign string are adjacent, a space separates them from the
+ value; otherwise, a space separates the currency symbol from the value.
+ - 2 If the currency symbol and sign string are adjacent, a space separates them;
+ otherwise, a space separates the sign string from the value.
+ For int_p_sep_by_space and int_n_sep_by_space, the fourth character of int_curr_symbol is
+ used instead of a space.
+
+ The values of the *_sign_posn members are interpreted as follows:
+ - 0 Parentheses surround the quantity and currency symbol.
+ - 1 The sign string precedes the quantity and currency symbol.
+ - 2 The sign string succeeds the quantity and currency symbol.
+ - 3 The sign string immediately precedes the currency symbol.
+ - 4 The sign string immediately succeeds the currency symbol.
**/
struct lconv {
- char *decimal_point;
- char *thousands_sep;
- char *grouping;
- char *int_curr_symbol;
- char *currency_symbol;
- char *mon_decimal_point;
- char *mon_thousands_sep;
- char *mon_grouping;
- char *positive_sign;
- char *negative_sign;
- char int_frac_digits;
- char frac_digits;
- char p_cs_precedes;
- char p_sep_by_space;
- char n_cs_precedes;
- char n_sep_by_space;
- char p_sign_posn;
- char n_sign_posn;
- char int_p_cs_precedes;
- char int_n_cs_precedes;
- char int_p_sep_by_space;
- char int_n_sep_by_space;
- char int_p_sign_posn;
- char int_n_sign_posn;
+ char *decimal_point; /**< "." Non-monetary decimal-point. */
+ char *thousands_sep; /**< "" Separates groups of digits before the decimal-point */
+ char *grouping; /**< "" A string whose elements (characters) indicate the size
+ of each group of digits in formatted nonmonetary quantities. */
+ char *int_curr_symbol; /**< "" A 4-character string providing the international currency
+ symbol. The first three characters contain the alphabetic
+ international currency symbol in accordance with those
+ specified in ISO 4217. The fourth character, immediately
+ preceding the null character, is the character used to separate
+ the international currency symbol from the monetary quantity. */
+ char *currency_symbol; /**< "" The local currency symbol for the current locale. */
+ char *mon_decimal_point; /**< "" The decimal point used for monetary values. */
+ char *mon_thousands_sep; /**< "" The separator for digit groups preceeding the decimal-point. */
+ char *mon_grouping; /**< "" A string, like grouping, for monetary values. */
+ char *positive_sign; /**< "" A string to indicate a non-negative monetary value. */
+ char *negative_sign; /**< "" A string to indicate a negative monetary value. */
+ char int_frac_digits; /**< CHAR_MAX The number of digits after the decimal-point for international
+ monetary values. */
+ char frac_digits; /**< CHAR_MAX The number of digits after the decimal-point for local
+ monetary values. */
+ char p_cs_precedes; /**< CHAR_MAX Set to 1 or 0 if the currency_symbol respectively precedes or
+ succeeds the value for non-negative local monetary values. */
+ char p_sep_by_space; /**< CHAR_MAX Value specifying the separation between the currency_symbol,
+ the sign string, and the value for non-negative local values. */
+ char n_cs_precedes; /**< CHAR_MAX Set to 1 or 0 if the currency_symbol respectively precedes or
+ succeeds the value for negative local monetary values. */
+ char n_sep_by_space; /**< CHAR_MAX Value specifying the separation between the currency_symbol,
+ the sign string, and the value for negative local values. */
+ char p_sign_posn; /**< CHAR_MAX Value specifying the positioning of the positive_sign for a
+ non-negative local monetary quantity. */
+ char n_sign_posn; /**< CHAR_MAX Value specifying the positioning of the negative_sign for a
+ negative local monetary quantity. */
+ char int_p_cs_precedes; /**< CHAR_MAX Set to 1 or 0 if the currency_symbol respectively precedes or
+ succeeds the value for non-negative international monetary values. */
+ char int_n_cs_precedes; /**< CHAR_MAX Set to 1 or 0 if the currency_symbol respectively precedes or
+ succeeds the value for negative international monetary values. */
+ char int_p_sep_by_space; /**< CHAR_MAX Value specifying the separation between the currency_symbol,
+ the sign string, and the value for non-negative international values. */
+ char int_n_sep_by_space; /**< CHAR_MAX Value specifying the separation between the currency_symbol,
+ the sign string, and the value for negative international values. */
+ char int_p_sign_posn; /**< CHAR_MAX Value specifying the positioning of the positive_sign for a
+ non-negative international monetary quantity. */
+ char int_n_sign_posn; /**< CHAR_MAX Value specifying the positioning of the negative_sign for a
+ negative international monetary quantity. */
};
-/** These macros expand to integer expressions suitable for use as the first
- argument to the setlocale() function.
+/** @{
+ These macros expand to integer expressions suitable for use as the first
+ argument (category) to the setlocale() function.
Only the first six macros are required by the C language specification.
Implementations are free to extend this list, as has been done with LC_MESSAGES,
with additional macro definitions, beginning with the characters LC_ and
an uppercase letter.
-@{
**/
#define LC_ALL 0 ///< The application's entire locale.
#define LC_COLLATE 1 ///< Affects the behavior of the strcoll and strxfrm functions.
@@ -91,25 +144,51 @@ struct lconv {
#define LC_TIME 5 ///< Affects the behavior of the strftime and wcsftime functions.
#define LC_MESSAGES 6
#define _LC_LAST 7 ///< Number of defined macros. Marks end.
-/// @}
+/*@}*/
#include <sys/EfiCdefs.h>
-/** @fn char *setlocale(int, const char *)
+/** @fn char *setlocale(int category, const char *locale)
+
+ @brief The setlocale function is used to retrieve or change parts or all of the current locale.
+
+ @details If locale is NULL, or the same as the current locale, this function just retrieves the
+ values for the specified category in the current locale. Otherwise, the specified category
+ in the current locale is set to the corresponding values from the specified locale and a pointer
+ to the new values is returned.
+
+ @param[in] category The portion of the current locale to be affected by this call.
+ The LC_ macros list the supported categories and the meaning of each.
+ @param[in] locale A value of "C" for locale specifies the minimal environment for C translation;
+ A value of "" specifies the native environment, which is "C" for this
+ implementation. If locale is NULL, the current locale is specified.
+
+ @return A pointer to the string associated with the specified category for the new locale,
+ a pointer to the string associated with the category for the current locale,
+ or NULL if category or locale can not be honored. The return value should not be
+ modified by the program, but may be overwritten by subsequent calls to either
+ setlocale or localeconv.
**/
/** @fn struct lconv *localeconv(void)
+
+ @brief The localeconv function returns a pointer to a lconv structure containing the appropriate
+ values for the current locale.
+
+ @return A pointer to a filled-in lconv structure. The returned structure should not be
+ modified by the program, but may be overwritten by subsequent calls to either
+ setlocale or localeconv.
**/
__BEGIN_DECLS
#ifdef __SETLOCALE_SOURCE__
- char *setlocale(int, const char *);
- char *__setlocale(int, const char *);
+ char *setlocale(int category, const char *locale);
+ char *__setlocale(int category, const char *locale);
#else /* !__SETLOCALE_SOURCE__ */
- char *setlocale(int, const char *) __RENAME(__setlocale_mb_len_max_32);
+ char *setlocale(int category, const char *locale) __RENAME(__setlocale_mb_len_max_32);
#endif /* !__SETLOCALE_SOURCE__ */
struct lconv *localeconv(void);
- char *__setlocale_mb_len_max_32(int, const char *);
+ char *__setlocale_mb_len_max_32(int category, const char *locale);
__END_DECLS
#endif /* _LOCALE_H_ */
diff --git a/StdLib/Include/math.h b/StdLib/Include/math.h
index 81a900e..3041120 100644
--- a/StdLib/Include/math.h
+++ b/StdLib/Include/math.h
@@ -1,6 +1,15 @@
-/* $NetBSD: math.h,v 1.44 2006/03/25 16:41:11 xtraeme Exp $ */
+/** @file
+ Floating-point Math functions and macros.
+
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
@@ -9,18 +18,20 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- */
-
-/*
- * @(#)fdlibm.h 5.1 93/09/24
- */
+ NetBSD: math.h,v 1.44 2006/03/25 16:41:11 xtraeme Exp
+ dlibm.h 5.1 93/09/24
+**/
#ifndef _MATH_H_
#define _MATH_H_
#include <sys/EfiCdefs.h>
-#include <sys/featuretest.h>
+#include <sys/featuretest.h>
+/** @{
+ @brief These are forward references to unions and macros used internaly
+ by the implementation of the math functions and macros.
+**/
union __float_u {
unsigned char __dummy[sizeof(float)];
float __val;
@@ -36,8 +47,7 @@ union __long_double_u {
long double __val;
};
-#include <machine/math.h> /* may use __float_u, __double_u,
- or __long_double_u */
+#include <machine/math.h> /* may use __float_u, __double_u, or __long_double_u */
#ifdef __HAVE_LONG_DOUBLE
#define __fpmacro_unary_floating(__name, __arg0) \
@@ -55,64 +65,290 @@ union __long_double_u {
: __ ## __name ## d (__arg0))
#endif /* __HAVE_LONG_DOUBLE */
-/*
- * ANSI/POSIX
+extern const union __double_u __infinity;
+extern const union __float_u __infinityf;
+extern const union __long_double_u __infinityl;
+
+/* C99 7.12.3.1 int fpclassify(real-floating x) */
+#define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)
+
+/* C99 7.12.3.3 int isinf(real-floating x) */
+#ifdef __isinf
+ #define isinf(__x) __isinf(__x)
+#else
+ #define isinf(__x) __fpmacro_unary_floating(isinf, __x)
+#endif
+
+/* C99 7.12.3.4 int isnan(real-floating x) */
+#ifdef __isnan
+ #define isnan(__x) __isnan(__x)
+#else
+ #define isnan(__x) __fpmacro_unary_floating(isnan, __x)
+#endif
+/*@)*/
+
+/*#############################################################
+ * ISO C95
*/
-/* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
-extern const union __double_u __infinity;
+
+/**@{
+ Double, float, and long double versions, respectively, of HUGE_VAL.
+*/
#define HUGE_VAL __infinity.__val
+#define HUGE_VALF __infinityf.__val
+#define HUGE_VALL __infinityl.__val
+/*@)*/
+__BEGIN_DECLS
/*
- * ISO C99
+ * ANSI/POSIX
*/
-/* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
-extern const union __float_u __infinityf;
-#define HUGE_VALF __infinityf.__val
+/** Compute the principal value of the arc cosine of Arg.
-extern const union __long_double_u __infinityl;
-#define HUGE_VALL __infinityl.__val
+ @param[in] Arg The value to compute the arc cosine of.
-/* 7.12#4 INFINITY */
-#ifdef __INFINITY
-#define INFINITY __INFINITY /* float constant which overflows */
-#else
-#define INFINITY HUGE_VALF /* positive infinity */
-#endif /* __INFINITY */
+ @return The computed value of the arc cosine of Arg in the interval [0,pi] radians.
+ If Arg is not in the interval [-1,+1], errno is set to EDOM.
+**/
+double acos(double Arg);
-/* 7.12#5 NAN: a quiet NaN, if supported */
-#ifdef __HAVE_NANF
-extern const union __float_u __nanf;
-#define NAN __nanf.__val
-#endif /* __HAVE_NANF */
+/** Compute the principal value of the arc sine of Arg.
-/* 7.12#6 number classification macros */
-#define FP_INFINITE 0x00
-#define FP_NAN 0x01
-#define FP_NORMAL 0x02
-#define FP_SUBNORMAL 0x03
-#define FP_ZERO 0x04
-/* NetBSD extensions */
-#define _FP_LOMD 0x80 /* range for machine-specific classes */
-#define _FP_HIMD 0xff
+ @param[in] Arg The value to compute the arc sine of.
+
+ @return The computed value of the arc sine of Arg in the interval [-pi/2,+pi/2] radians.
+ If Arg is not in the interval [-1,+1], errno is set to EDOM.
+**/
+double asin(double Arg);
+
+/** Compute the principal value of the arc tangent of Arg.
+
+ @param[in] Arg The value to compute the arc tangent of.
+
+ @return The computed value of the arc tangent of Arg in the interval [-pi/2,+pi/2] radians.
+**/
+double atan(double Arg);
+
+/** Compute the value of the arc tangent of (Num / Denom).
+ The sign of both arguments is used to determine the quadrant of the return value.
+
+ @param[in] Num The numerator of the value to compute the arc tangent of.
+ @param[in] Denom The denominator of the value to compute the arc tangent of.
+
+ @return The computed value of the arc tangent of (Num / Denom) in the interval [-pi,+pi] radians.
+**/
+double atan2(double Num, double Denom);
+
+/** Compute the value of the cosine of Arg, measured in radians.
+
+ @param[in] Arg The value to compute the cosine of.
+
+ @return The computed value of the cosine of Arg.
+**/
+double cos(double Arg);
+
+/** Compute the value of the sine of Arg.
+
+ @param[in] Arg The value to compute the sine of.
+
+ @return The computed value of the sine of Arg.
+**/
+double sin(double Arg);
+
+/** Compute the value of the tangent of Arg.
+
+ @param[in] Arg The value to compute the tangent of.
+
+ @return The computed value of the tangent of Arg.
+**/
+double tan(double Arg);
+
+
+/** Compute the value of the hyperbolic cosine of Arg.
+
+ @param[in] Arg The value to compute the hyperbolic cosine of.
+
+ @return The computed value of the hyperbolic cosine of Arg.
+ If the magnitude of Arg is too large, errno is set to ERANGE.
+**/
+double cosh(double Arg);
+
+/** Compute the value of the hyperbolic sine of Arg.
+
+ @param[in] Arg The value to compute the hyperbolic sine of.
+
+ @return The computed value of the hyperbolic sine of Arg.
+ If the magnitude of Arg is too large, errno is set to ERANGE.
+**/
+double sinh(double Arg);
+
+/** Compute the value of the hyperbolic tangent of Arg.
+
+ @param[in] Arg The value to compute the hyperbolic tangent of.
+
+ @return The computed value of the hyperbolic tangent of Arg.
+**/
+double tanh(double Arg);
+
+
+/** Compute the base-e exponential of Arg.
+
+ @param[in] Arg The value to compute the base-e exponential of.
+
+ @return The computed value of e**Arg.
+ If the magnitude of Arg is too large, errno is set to ERANGE.
+**/
+double exp(double Arg);
+
+/** Break a floating-point number into a normalized fraction and an integral power of 2.
+
+ @param[in] Value The floating-point value to be broken down.
+ @param[out] Exp A pointer to an integer object to receive the integral power of 2 exponent.
+
+ @return The frexp function returns a value R, such that Value == R**Exp.
+ If Value is zero, both parts of the result are zero.
+**/
+double frexp(double Value, int *Exp);
+
+/** Multiply a floating-point number, Value, by an integral power of 2, Exp.
+
+ @param[in] Value The floating-point value to be multiplied.
+ @param[out] Exp The integral power of 2 to multiply Value by.
+
+ @return The ldexp function returns a value R, such that R = Value x 2**Exp.
+ If a range error occurs, errno will be set to ERANGE.
+**/
+double ldexp(double Value, int Exp);
+
+/** Compute the natural logarithm of Arg.
+
+ @param[in] Arg The value to compute the natural logarithm of.
+
+ @return The log function returns log base-e of Arg. If Arg is negative, errno is set to EDOM.
+ Otherwise, errno will be set to ERANGE if a range error occurs.
+**/
+double log(double Arg);
+
+/** Compute the common (base-10) logarithm of Arg.
+
+ @param[in] Arg The value to compute the common logarithm of.
+
+ @return The log10 function returns log base-10 of Arg. If Arg is negative, errno is set to EDOM.
+ Otherwise, errno will be set to ERANGE if Arg is 0.
+**/
+double log10(double Arg);
+
+/** Compute the base-2 logarithm of Arg.
+
+ @param[in] Arg The value to compute the base-2 logarithm of.
+
+ @return The log function returns log base-2 of Arg. If Arg is negative, errno is set to EDOM.
+ Otherwise, errno will be set to ERANGE if Arg is 0.
+**/
+double log2(double Arg);
+
+/** Break Value into integral and fractional parts, each of which has the same type and sign
+ as Value. Store the integral part in the object pointed to by Integ and return the
+ fractional part.
+
+ @param[in] Value The value to compute the arc cosine of.
+ @param[out] Integ Pointer to where the integral component is to be stored.
+
+ @return The fractional part of Value is returned directly while the integral part is
+ returned in the location pointed to by Integ.
+**/
+double modf(double Value, double *Integ);
+
+/** Compute Value raised to the power Exp.
+
+ @param[in] Value The value to be raised.
+ @param[in] Exp The power Value is to be raised to.
+
+ @return The pow function returns Value**Exp. If an error occurs, errno will be set as follows:
+ - EDOM: Value is finite and negative and Exp is finite and not an integer.
+ - EDOM: Both Value and Exp are zero.
+ - EDOM: Value is zero and Exp is less than zero.
+**/
+double pow(double Value, double Exp);
+
+/** Compute the non-negative square root of Arg.
+
+ @param[in] Arg The value to compute the square root of.
+
+ @return The square root of Arg. If Arg is less than zero, errno is set to EDOM.
+**/
+double sqrt(double Arg);
+
+
+/** Compute the smallest integer value not less than Arg.
+
+ @param[in] Arg The value to compute the ceiling of.
+
+ @return The ceiling of Arg expressed as a floating-point number.
+**/
+double ceil(double Arg);
+
+/** Compute the absolute value of Arg.
+
+ @param[in] Arg The value to compute the absolute value of.
+
+ @return The absolute value of Arg.
+**/
+double fabs(double Arg);
+
+/** Compute the largest integer value not greater than Arg.
+ @param[in] Arg The value to compute the floor of.
+
+ @return The largest integer value not greater than Arg, expressed as a floating-point number.
+**/
+double floor(double);
+
+/** Compute the floating-point remainder of A1 / A2.
+
+ @param[in] A1 The dividend.
+ @param[in] A2 The divisor.
+
+ @return The remainder of A1 / A2 with the same sign as A1. If A2 is zero, the fmod function
+ returns 0.
+**/
+double fmod(double A1, double A2);
+
+
+int finite(double);
+double expm1(double);
+
+/**@{
+ C99, Posix, or NetBSD functions that are not part of the C95 specification.
+**/
/*
- * XOPEN/SVID
+ * Functions callable from C, intended to support IEEE arithmetic.
*/
-#define M_E 2.7182818284590452354 /* e */
-#define M_LOG2E 1.4426950408889634074 /* log 2e */
-#define M_LOG10E 0.43429448190325182765 /* log 10e */
-#define M_LN2 0.69314718055994530942 /* log e2 */
-#define M_LN10 2.30258509299404568402 /* log e10 */
-#define M_PI 3.14159265358979323846 /* pi */
-#define M_PI_2 1.57079632679489661923 /* pi/2 */
-#define M_PI_4 0.78539816339744830962 /* pi/4 */
-#define M_1_PI 0.31830988618379067154 /* 1/pi */
-#define M_2_PI 0.63661977236758134308 /* 2/pi */
-#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
-#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
-#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
+double copysign(double, double);
+double scalbn(double, int);
-#define MAXFLOAT ((float)3.40282346638528860e+38)
+/*
+ * Library implementation
+ */
+int __fpclassifyf(float);
+int __fpclassifyd(double);
+int __isinff(float);
+int __isinfd(double);
+int __isnanf(float);
+int __isnand(double);
+
+#ifdef __HAVE_LONG_DOUBLE
+ int __fpclassifyl(long double);
+ int __isinfl(long double);
+ int __isnanl(long double);
+#endif /* __HAVE_LONG_DOUBLE */
+/*@}*/
+
+__END_DECLS
+
+/**@{
+ Extensions provided by NetBSD but not required by the C95 standard.
+**/
extern int signgam;
enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
@@ -120,7 +356,7 @@ enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
#define _LIB_VERSION_TYPE enum fdversion
#define _LIB_VERSION _fdlib_version
-/* if global variable _LIB_VERSION is not desirable, one may
+/** If global variable _LIB_VERSION is not desirable, one may
* change the following to be a constant by:
* #define _LIB_VERSION_TYPE const enum version
* In that case, after one initializes the value _LIB_VERSION (see
@@ -146,11 +382,7 @@ struct exception {
#define HUGE MAXFLOAT
-/*
- * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
- * (one may replace the following line by "#include <values.h>")
- */
-
+/** set X_TLOSS = pi*2**52 **/
#define X_TLOSS 1.41484755040568800000e+16
#define DOMAIN 1
@@ -159,295 +391,52 @@ struct exception {
#define UNDERFLOW 4
#define TLOSS 5
#define PLOSS 6
+/*@}*/
-
-__BEGIN_DECLS
-/*
- * ANSI/POSIX
- */
-double acos(double);
-double asin(double);
-double atan(double);
-double atan2(double, double);
-double cos(double);
-double sin(double);
-double tan(double);
-
-double cosh(double);
-double sinh(double);
-double tanh(double);
-
-double exp(double);
-double frexp(double, int *);
-double ldexp(double, int);
-double log(double);
-double log2(double);
-double log10(double);
-double modf(double, double *);
-
-double pow(double, double);
-double sqrt(double);
-
-double ceil(double);
-double fabs(double);
-double floor(double);
-double fmod(double, double);
-
-//#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
-//double erf(double);
-//double erfc(double);
-//double gamma(double);
-//double hypot(double, double);
-int finite(double);
-//double j0(double);
-//double j1(double);
-//double jn(int, double);
-//double lgamma(double);
-//double y0(double);
-//double y1(double);
-//double yn(int, double);
-
-//#if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
-//double acosh(double);
-//double asinh(double);
-//double atanh(double);
-//double cbrt(double);
-double expm1(double);
-//int ilogb(double);
-//double log1p(double);
-//double logb(double);
-//double nextafter(double, double);
-//double remainder(double, double);
-//double rint(double);
-//double scalb(double, double);
-//#endif /* (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)*/
-//#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
-
-/* 7.12.3.1 int fpclassify(real-floating x) */
-#define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)
-
-#if 0
-/*
- * ISO C99
- */
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
- !defined(_XOPEN_SOURCE) || \
- ((__STDC_VERSION__ - 0) >= 199901L) || \
- ((_POSIX_C_SOURCE - 0) >= 200112L) || \
- ((_XOPEN_SOURCE - 0) >= 600) || \
- defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
-
-/* 7.12.3.2 int isfinite(real-floating x) */
-#define isfinite(__x) __fpmacro_unary_floating(isfinite, __x)
-
-/* 7.12.3.5 int isnormal(real-floating x) */
-#define isnormal(__x) (fpclassify(__x) == FP_NORMAL)
-
-/* 7.12.3.6 int signbit(real-floating x) */
-#define signbit(__x) __fpmacro_unary_floating(signbit, __x)
-
-/* 7.12.4 trigonometric */
-
-float acosf(float);
-float asinf(float);
-float atanf(float);
-float atan2f(float, float);
-float cosf(float);
-float sinf(float);
-float tanf(float);
-
-/* 7.12.5 hyperbolic */
-
-float acoshf(float);
-float asinhf(float);
-float atanhf(float);
-float coshf(float);
-float sinhf(float);
-float tanhf(float);
-
-/* 7.12.6 exp / log */
-
-float expf(float);
-float expm1f(float);
-float frexpf(float, int *);
-int ilogbf(float);
-float ldexpf(float, int);
-float logf(float);
-float log2f(float);
-float log10f(float);
-float log1pf(float);
-float logbf(float);
-float modff(float, float *);
-float scalbnf(float, int);
-
-/* 7.12.7 power / absolute */
-
-float cbrtf(float);
-float fabsf(float);
-float hypotf(float, float);
-float powf(float, float);
-float sqrtf(float);
-
-/* 7.12.8 error / gamma */
-
-float erff(float);
-float erfcf(float);
-float lgammaf(float);
-
-/* 7.12.9 nearest integer */
-
-float ceilf(float);
-float floorf(float);
-float rintf(float);
-double round(double);
-float roundf(float);
-double trunc(double);
-float truncf(float);
-long int lrint(double);
-long int lrintf(float);
-/* LONGLONG */
-long long int llrint(double);
-/* LONGLONG */
-long long int llrintf(float);
-long int lround(double);
-long int lroundf(float);
-/* LONGLONG */
-long long int llround(double);
-/* LONGLONG */
-long long int llroundf(float);
-
-/* 7.12.10 remainder */
-
-float fmodf(float, float);
-float remainderf(float, float);
-
-/* 7.2.11 manipulation */
-
-float copysignf(float, float);
-double nan(const char *);
-float nanf(const char *);
-long double nanl(const char *);
-float nextafterf(float, float);
-
-
-#endif /* !_ANSI_SOURCE && ... */
-
-#if defined(_NETBSD_SOURCE)
-#ifndef __cplusplus
-int matherr(struct exception *);
-#endif
-#endif /* _NETBSD_SOURCE */
-
-/*
- * IEEE Test Vector
- */
-double significand(double);
-#endif /* if 0 */
-
-/* 7.12.3.3 int isinf(real-floating x) */
-#ifdef __isinf
-#define isinf(__x) __isinf(__x)
-#else
-#define isinf(__x) __fpmacro_unary_floating(isinf, __x)
-#endif
-
-/* 7.12.3.4 int isnan(real-floating x) */
-#ifdef __isnan
-#define isnan(__x) __isnan(__x)
+/* 7.12#4 INFINITY */
+#ifdef __INFINITY
+#define INFINITY __INFINITY /**< float constant which overflows */
#else
-#define isnan(__x) __fpmacro_unary_floating(isnan, __x)
-#endif
-
-/*
- * Functions callable from C, intended to support IEEE arithmetic.
- */
-double copysign(double, double);
-double scalbn(double, int);
-
-#if 0
-/*
- * BSD math library entry points
- */
-#ifndef __MATH_PRIVATE__
-double cabs(/* struct complex { double r; double i; } */);
-#endif
-double drem(double, double);
-
-
-#if defined(_NETBSD_SOURCE) || defined(_REENTRANT)
-/*
- * Reentrant version of gamma & lgamma; passes signgam back by reference
- * as the second argument; user must allocate space for signgam.
- */
-double gamma_r(double, int *);
-double lgamma_r(double, int *);
-#endif /* _NETBSD_SOURCE || _REENTRANT */
-
-
-#if defined(_NETBSD_SOURCE)
-
-/* float versions of ANSI/POSIX functions */
-
-float gammaf(float);
-int isinff(float);
-int isnanf(float);
-int finitef(float);
-float j0f(float);
-float j1f(float);
-float jnf(int, float);
-float y0f(float);
-float y1f(float);
-float ynf(int, float);
-
-float scalbf(float, float);
+#define INFINITY HUGE_VALF /**< positive infinity */
+#endif /* __INFINITY */
-/*
- * float version of IEEE Test Vector
- */
-float significandf(float);
+/* 7.12#5 NAN: a quiet NaN, if supported */
+#ifdef __HAVE_NANF
+extern const union __float_u __nanf;
+#define NAN __nanf.__val
+#endif /* __HAVE_NANF */
-/*
- * float versions of BSD math library entry points
- */
-#ifndef __MATH_PRIVATE__
-float cabsf(/* struct complex { float r; float i; } */);
-#endif
-float dremf(float, float);
-#endif /* _NETBSD_SOURCE */
+/**@{
+ C99 7.12#6 Number classification macros represent mutually exclusive kinds of floating-point
+ values.
+**/
+#define FP_INFINITE 0x00
+#define FP_NAN 0x01
+#define FP_NORMAL 0x02
+#define FP_SUBNORMAL 0x03
+#define FP_ZERO 0x04
+/* NetBSD extensions */
+#define _FP_LOMD 0x80 /**< range for machine-specific classes */
+#define _FP_HIMD 0xff
+/*@)*/
-#if defined(_NETBSD_SOURCE) || defined(_REENTRANT)
-/*
- * Float versions of reentrant version of gamma & lgamma; passes
- * signgam back by reference as the second argument; user must
- * allocate space for signgam.
+/**@{
+ * Constants ala XOPEN/SVID.
*/
-float gammaf_r(float, int *);
-float lgammaf_r(float, int *);
-#endif /* !... || _REENTRANT */
-
-#endif /* if 0 */
-
-///*
-// * Library implementation
-// */
-int __fpclassifyf(float);
-int __fpclassifyd(double);
-//int __isfinitef(float);
-//int __isfinited(double);
-int __isinff(float);
-int __isinfd(double);
-int __isnanf(float);
-int __isnand(double);
-//int __signbitf(float);
-//int __signbitd(double);
-
-//#ifdef __HAVE_LONG_DOUBLE
-int __fpclassifyl(long double);
-//int __isfinitel(long double);
-int __isinfl(long double);
-int __isnanl(long double);
-//int __signbitl(long double);
-//#endif
-__END_DECLS
+#define M_E 2.7182818284590452354 /**< e */
+#define M_LOG2E 1.4426950408889634074 /**< log 2e */
+#define M_LOG10E 0.43429448190325182765 /**< log 10e */
+#define M_LN2 0.69314718055994530942 /**< log e2 */
+#define M_LN10 2.30258509299404568402 /**< log e10 */
+#define M_PI 3.14159265358979323846 /**< pi */
+#define M_PI_2 1.57079632679489661923 /**< pi/2 */
+#define M_PI_4 0.78539816339744830962 /**< pi/4 */
+#define M_1_PI 0.31830988618379067154 /**< 1/pi */
+#define M_2_PI 0.63661977236758134308 /**< 2/pi */
+#define M_2_SQRTPI 1.12837916709551257390 /**< 2/sqrt(pi) */
+#define M_SQRT2 1.41421356237309504880 /**< sqrt(2) */
+#define M_SQRT1_2 0.70710678118654752440 /**< 1/sqrt(2) */
+#define MAXFLOAT ((float)3.40282346638528860e+38)
+/*@}*/
#endif /* _MATH_H_ */
diff --git a/StdLib/Include/setjmp.h b/StdLib/Include/setjmp.h
index ed691e6..33ea161 100644
--- a/StdLib/Include/setjmp.h
+++ b/StdLib/Include/setjmp.h
@@ -1,16 +1,15 @@
/** @file
- The header <setjmp.h> defines the macro setjmp, and declares one function
- and one type, for bypassing the normal function call and return discipline.
+ This file defines the macro setjmp, and declares the function longjmp
+ and the type jmp_buf, for bypassing the normal function call and return discipline.
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _SETJMP_H
#define _SETJMP_H
@@ -40,7 +39,8 @@ typedef BASE_LIBRARY_JUMP_BUFFER jmp_buf[1];
@return If the return is from a direct invocation, the setjmp macro
returns the value zero. If the return is from a call to the longjmp
- function, the setjmp macro returns a nonzero value.
+ function, the setjmp macro returns a nonzero value based upon the value
+ of the second argument to the longjmp function.
**/
#define setjmp(env) (INTN)SetJump((env))
@@ -52,7 +52,10 @@ typedef BASE_LIBRARY_JUMP_BUFFER jmp_buf[1];
macro was within the scope of an identifier with variably modified type and
execution has left that scope in the interim, the behavior is undefined.
- After longjmp is completed, program execution continues as if the
+ @param[in] env The jump buffer containing the environment to be returned to.
+ @param[in] val A non-zero value to be returned from setjmp.
+
+ @return After longjmp is completed, program execution continues as if the
corresponding invocation of the setjmp macro had just returned the value
specified by val. The longjmp function cannot cause the setjmp macro to
return the value 0; if val is 0, the setjmp macro returns the value 1.
diff --git a/StdLib/Include/signal.h b/StdLib/Include/signal.h
index 6c1ff1b..26f8d6b 100644
--- a/StdLib/Include/signal.h
+++ b/StdLib/Include/signal.h
@@ -1,28 +1,25 @@
/** @file
- The header <signal.h> declares a type and two functions and defines several
+ This file declares a type and two functions and defines several
macros, for handling various signals (conditions that may be reported during
program execution).
- The UEFI implementation of <signal.h> maps signals onto the UEFI
- event mechanism.
+ For historical reasons; programs expect signal to be declared
+ in <sys/signal.h>. The signal function is documented in <sys/signal.h>.
- An implementation need not generate any of these signals, except as a result
- of explicit calls to the raise function. Additional signals and pointers to
- undeclarable functions, with macro definitions beginning, respectively, with
- the letters SIG and an uppercase letter or with SIG_ and an uppercase letter
- may also be specified by the implementation. The complete set of signals,
- their semantics, and their default handling is implementation-defined; all
- signal numbers shall be positive.
+ The signal function is declared in the C Standard as:<BR>
+ void (*signal(int sig, void (*func)(int)))(int);
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
+ The EDK II implementation of the library or base firmware does not generate
+ any of these signals, except as a result of explicit calls to the raise function.
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _SIGNAL_H
#define _SIGNAL_H
@@ -36,7 +33,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
This, possibly machine specific, type is defined in <machine/signal.h>.
*/
-/** The following three macros expand to constant expressions with distinct
+/** @{
+ The following three macros expand to constant expressions with distinct
values that have type compatible with the second argument to, and the
return value of, the signal function, and whose values compare unequal to
the address of any declarable function.
@@ -44,11 +42,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define SIG_IGN ((__sighandler_t *) 0)
#define SIG_DFL ((__sighandler_t *) 1)
#define SIG_ERR ((__sighandler_t *) 3)
+/*@}*/
-/** The following members expand to positive integer constant expressions with
+/** @{
+ The following macros expand to positive integer constant expressions with
type int and distinct values that are the signal numbers, each
corresponding to the specified condition.
- Many existing programs expect these to be macros.
+ The C95 specification requires these to be macros.
**/
#define SIGINT __SigInt ///< receipt of an interactive attention signal
#define SIGILL __SigIll ///< detection of an invalid function image, such as an invalid instruction
@@ -66,24 +66,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define SIGPIPE __SigPipe ///< Added for Posix timer functions
#define SIGQUIT __SigQuit ///< Added for Posix timer functions
#define SIG_LAST __Sig_Last ///< One more than the largest signal number
+/*@}*/
__BEGIN_DECLS
-/* For historical reasons; programs expect signal to be declared
- in <sys/signal.h>. The function is documented in <sys/signal.h>.
-
- The function is declared in the C Standard as:<BR>
- void (*signal(int sig, void (*func)(int)))(int);
-*/
-
/** Send a signal.
The raise function carries out the actions described for signal,
in <sys/signal.h>, for the signal sig. If a signal handler is called, the
- raise function shall not return until after the signal handler does.
+ raise function does not return until after the signal handler does.
@return The raise function returns zero if successful,
- nonzero if unsuccessful.
+ or nonzero if unsuccessful.
**/
int raise(int sig);
diff --git a/StdLib/Include/stdarg.h b/StdLib/Include/stdarg.h
index b966a5c..b9de364 100644
--- a/StdLib/Include/stdarg.h
+++ b/StdLib/Include/stdarg.h
@@ -1,54 +1,53 @@
/** @file
- The header <stdarg.h> declares a type and defines three macros, for advancing
- through a list of arguments whose number and types are not known to the
- called function when it is translated.
-
- A function may be called with a variable number of arguments of varying types.
- Its parameter list contains one or more parameters. The rightmost parameter
- plays a special role in the access mechanism, and will be designated paramN
- in this description.
-
- The type va_list is a type suitable for holding information needed by the
- macros va_start, va_arg, and va_end. If access to the varying arguments
- is desired, the called function shall declare an object (referred to as ap
- in these descriptions) having type va_list. The object ap may be passed as
- an argument to another function; if that function invokes the va_arg macro
- with parameter ap, the value of ap in the calling function is indeterminate
- and shall be passed to the va_end macro prior to any further reference to ap.
-
- The va_start and va_arg macros shall be implemented as macros, not as actual
- functions. It is unspecified, by the C library standards, whether va_end
- is a macro or an identifier declared with external linkage. If a macro
- definition is suppressed in order to access an actual function, or a
- program defines an external identifier with the name va_end, the behavior
- is undefined. The va_start and va_end macros shall be invoked in the
- function accepting a varying number of arguments, if access to the varying
- arguments is desired.
-
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
+ This header, <stdarg.h>, declares type va_list and defines macros: va_start, va_arg, va_end;
+ for advancing through a list of arguments whose number and types are not known to the
+ called function when it is translated.
+
+ A function may be called with a variable number of arguments of varying types.
+ The rightmost argument plays a special role in the access mechanism, and will
+ be designated paramN in this and subsequent descriptions.
+
+ The type va_list is a type suitable for holding information needed by the
+ macros va_start, va_arg, and va_end. If access to the varying arguments
+ is desired, the called function shall declare an object (referred to as ap
+ in these descriptions) having type va_list. The object ap may be passed as
+ an argument to another function; if the receiving function invokes the va_arg macro
+ with parameter ap, the value of ap in the calling function becomes indeterminate
+ and must be passed to the va_end macro prior to any further reference to ap.
+
+ The va_start and va_arg macros must be implemented as macros, not as actual
+ functions. The va_start and va_end macros must be invoked in the
+ function accepting a varying number of arguments, if access to the varying
+ arguments is desired.
+
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _STDARG_H
#define _STDARG_H
#include <sys/EfiCdefs.h>
-/** The type va_list is a type suitable for holding information needed by the
+/** @{
+ The type va_list is a type suitable for holding information needed by the
macros va_start, va_arg, and va_end.
+
+ Depending upon compiler or CPU architecture, different definitions are required.
**/
#if defined(__GNUC__)
typedef __builtin_va_list va_list;
#else
#define va_list VA_LIST
#endif
+/*@}*/
-/** The va_start macro shall be invoked before any access to the unnamed arguments.
+/** @{
+ The va_start macro must be invoked before any access to the unnamed arguments.
The va_start macro initializes ap for subsequent use by va_arg and va_end.
Synopsys: void va_start(va_list ap, paramN);
@@ -71,8 +70,10 @@ typedef __builtin_va_list va_list;
#else
#define va_start VA_START
#endif
+/*@}*/
-/** The va_arg macro expands to an expression that has the type and value of
+/** @{
+ The va_arg macro expands to an expression that has the type and value of
the next argument in the call. The parameter ap shall be the same as the
va_list ap initialized by va_start. Each invocation of va_arg modifies ap
so that the values of successive arguments are returned in turn. The
@@ -99,8 +100,10 @@ typedef __builtin_va_list va_list;
#else
#define va_arg VA_ARG
#endif
+/*@}*/
-/** The va_end macro facillitates a normal return from the function whose
+/** @{
+ The va_end macro facillitates a normal return from the function whose
variable argument list was referred to by the expansion of va_start that
initialized the va_list ap.
@@ -119,12 +122,16 @@ typedef __builtin_va_list va_list;
#else
#define va_end VA_END
#endif
+/*@}*/
-/** For BSD compatibility. **/
+/** @{
+ For BSD compatibility.
+**/
#if defined(__GNUC__)
#define va_copy __builtin_va_copy
#else
#define va_copy(s,d) (s) = (d)
#endif
+/*@}*/
#endif /* _STDARG_H */
diff --git a/StdLib/Include/stdbool.h b/StdLib/Include/stdbool.h
index 42dcd86..3208866 100644
--- a/StdLib/Include/stdbool.h
+++ b/StdLib/Include/stdbool.h
@@ -1,8 +1,12 @@
/** @file
- The header <stdbool.h> defines four macros: bool, true, false,
- and __bool_true_false_are_defined.
+ Macros to simplify boolean expressions and operations.
- The macro bool expands to _Bool.
+ This header is not specified by the C95 standard but is included here for
+ operational convenience.
+
+ The macro bool expands to _Bool, as required by the C99 specification.
+ This subsequently expands to BOOLEAN, is a UEFI data type which is automatically
+ defined correctly for the target CPU architecture.
The remaining three macros are suitable for use in #if preprocessing
directives. They are true, which expands to the integer constant 1,
@@ -12,23 +16,22 @@
A program may undefine and perhaps then redefine the
macros bool, true, and false.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
+ http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
**/
#ifndef _STDBOOL_H
#define _STDBOOL_H
#include <sys/EfiCdefs.h>
-#define bool _Bool
-#define true 1
-#define false 0
+#define bool _Bool
+#define true 1
+#define false 0
#define __bool_true_false_are_defined 1
#endif /* _STDBOOL_H */
diff --git a/StdLib/Include/stddef.h b/StdLib/Include/stddef.h
index c97d564..ce4483a 100644
--- a/StdLib/Include/stddef.h
+++ b/StdLib/Include/stddef.h
@@ -1,64 +1,68 @@
/** @file
- Common Definitions.
+ Common "Standard" Definitions.
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
+ The files stddef.h and stdlib.h are "catch all" headers for definitions and declarations
+ that don't fit well in the other headers. There are two separate header files because
+ the contents of <stddef.h> are valid in both freestanding and hosted environment, while the
+ header <stdlib.h> contains elements that are only valid in a hosted environment.
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ This means that the elements in this file may not impose dependencies on headers other than
+ <float.h>, <iso646.h>, <limits.h>, <stdarg.h>, <stdbool.h>, and (of course) <sys/EfiCdefs.h>.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _STDDEF_H
#define _STDDEF_H
#include <sys/EfiCdefs.h>
-/** ptrdiff_t is the signed integer type of the result of subtracting two pointers.
-**/
#ifdef _EFI_PTRDIFF_T_
+ /** ptrdiff_t is the signed integer type of the result of subtracting two pointers. **/
typedef _EFI_PTRDIFF_T_ ptrdiff_t;
#undef _EFI_PTRDIFF_T_
#endif
-/** size_t is the unsigned integer type of the result of the sizeof operator.
-**/
#ifdef _EFI_SIZE_T_
+ /** size_t is the unsigned integer type of the result of the sizeof operator. **/
typedef _EFI_SIZE_T_ size_t;
#undef _EFI_SIZE_T_
#undef _BSD_SIZE_T_
#endif
-/** wchar_t is an integer type whose range of values can represent distinct
- codes for all members of the largest extended character set specified among
- the supported locales. The null character shall have the code value zero.
-**/
#ifndef __cplusplus
#ifdef _EFI_WCHAR_T
+ /** wchar_t is an integer type whose range of values can represent distinct
+ codes for all members of the largest extended character set specified among
+ the supported locales. The null character shall have the code value zero.
+ **/
typedef _EFI_WCHAR_T wchar_t;
#undef _EFI_WCHAR_T
#undef _BSD_WCHAR_T_
#endif
#endif
-/** NULL expands to an implementation-defined null pointer constant.
+/** @def NULL
+ A macro that expands to a null pointer constant.<BR>
NULL is defined in MdePkg/Include/Base.h which is automatically included
by the EDK II build tools.
**/
-/** offsetof(type, member-designator) expands to an integer constant expression
- that has type size_t, the value of which is the offset in bytes, to the
- structure member (designated by member-designator), from the beginning of
- its structure (designated by type). The type and member designator shall be
- such that given<BR>
- static type t;<BR>
- then the expression &(t.member-designator) evaluates to an address constant.
- (If the specified member is a bit-field, the behavior is undefined.)
+/** The offsetof macro determines the offset of the beginning of a structure
+ member from the beginning of the structure.
+
+ The macro expands to an integer constant expression that has type size_t,
+ the value of which is the offset in bytes, to the structure member (Member),
+ from the beginning of its structure (StrucName).
Alliased to OFFSET_OF which is defined in MdePkg/Include/Base.h which is
automatically included by the EDK II build tools.
**/
-#define offsetof(type, member) OFFSET_OF(type, member)
+#define offsetof(StrucName, Member) OFFSET_OF(StrucName, Member)
#endif /* _STDDEF_H */
diff --git a/StdLib/Include/stdio.h b/StdLib/Include/stdio.h
index 7c3586c..7f3204b 100644
--- a/StdLib/Include/stdio.h
+++ b/StdLib/Include/stdio.h
@@ -1,4 +1,119 @@
-/*-
+/** @file
+ Macros, types, and functions for performing I/O.
+
+ The following functions are declared in this file:<BR>
+@verbatim
+ ################### Operations on files. ####
+ int remove (const char *FileName);
+ int rename (const char *, const char *);
+ FILE *tmpfile (void);
+ char *tmpnam (char *);
+
+ ################### File access functions. ####
+ int fclose (FILE *);
+ int fflush (FILE *);
+ FILE *fopen (const char * __restrict ,
+ const char * __restrict);
+ FILE *freopen (const char * __restrict,
+ const char * __restrict, FILE * __restrict);
+ void setbuf (FILE * __restrict, char * __restrict);
+ int setvbuf (FILE * __restrict, char * __restrict,
+ int, size_t);
+
+ ################### Formatted Input/Output Functions. ####
+ int fprintf (FILE * __restrict stream,
+ const char * __restrict format, ...);
+ int fscanf (FILE * __restrict, const char * __restrict, ...);
+ int printf (const char * __restrict, ...);
+ int scanf (const char * __restrict, ...);
+ int sprintf (char * __restrict, const char * __restrict, ...);
+ int sscanf (const char * __restrict,
+ const char * __restrict, ...);
+ int vfprintf (FILE * __restrict,
+ const char * __restrict, va_list);
+ int vprintf (const char * __restrict, va_list);
+ int vsprintf (char * __restrict,
+ const char * __restrict, va_list);
+
+ ################### Character Input/Output Functions. ####
+ int fgetc (FILE *);
+ char *fgets (char * __restrict, int, FILE * __restrict);
+ int fputc (int, FILE *);
+ int fputs (const char * __restrict, FILE * __restrict);
+ int getc (FILE *);
+ int getchar (void);
+ char *gets (char *);
+ int putc (int, FILE *);
+ int putchar (int);
+ int puts (const char *);
+ int ungetc (int, FILE *);
+
+ ################### Direct Input/Output Functions. ####
+ size_t fread (void * __restrict, size_t, size_t,
+ FILE * __restrict);
+ size_t fwrite (const void * __restrict, size_t, size_t,
+ FILE * __restrict);
+
+ ################### File Positioning Functions. ####
+ int fgetpos (FILE * __restrict, fpos_t * __restrict);
+ int fseek (FILE *, long, int);
+ int fsetpos (FILE *, const fpos_t *);
+ long ftell (FILE *);
+ void rewind (FILE *);
+
+ ################### Error-handling Functions. ####
+ void clearerr (FILE *);
+ int feof (FILE *);
+ int ferror (FILE *);
+ void perror (const char *);
+
+ ################### Functions NOT specified by C95 ####
+
+ FILE *fdopen (int, const char *);
+ void flockfile (FILE *);
+ int ftrylockfile (FILE *);
+ void funlockfile (FILE *);
+ int getc_unlocked (FILE *);
+ int getchar_unlocked(void);
+ int putc_unlocked (int, FILE *);
+ int putchar_unlocked(int);
+ int pclose (FILE *);
+ FILE *popen (const char *, const char *);
+ int snprintf (char * __restrict, size_t,
+ const char * __restrict, ...);
+ int vsnprintf (char * __restrict, size_t,
+ const char * __restrict, va_list);
+ char *mkdtemp (char *);
+ int mkstemp (char *);
+ char *mktemp (char *);
+ char *tempnam (const char *, const char *);
+ int fseeko (FILE *, off_t, int);
+ char *fgetln (FILE * __restrict, size_t * __restrict);
+ char *fparseln (FILE *, size_t *, size_t *, const char[3], int);
+ int fpurge (FILE *);
+ void setbuffer (FILE *, char *, int);
+ int setlinebuf (FILE *);
+ int vasprintf (char ** __restrict, const char * __restrict,
+ va_list);
+ int vscanf (const char * __restrict, va_list);
+ int vsscanf (const char * __restrict,
+ const char * __restrict, va_list);
+@endverbatim
+
+ @note To fit things in six character monocase externals, the stdio
+ code uses the prefix `__s' for stdio objects, typically followed
+ by a three-character attempt at a mnemonic.
+
+
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,9 +145,8 @@
* SUCH DAMAGE.
*
* @(#)stdio.h 8.5 (Berkeley) 4/29/95
+ NetBSD: stdio.h,v 1.66.2.3 2007/08/24 20:07:38 liamjfoy Exp
*/
-/* $NetBSD: stdio.h,v 1.66.2.3 2007/08/24 20:07:38 liamjfoy Exp $ */
-
#ifndef _STDIO_H_
#define _STDIO_H_
@@ -42,16 +156,27 @@
#include <machine/ansi.h>
#ifdef _EFI_SIZE_T_
+ /** size_t is the unsigned integer type of the result of the sizeof operator. **/
typedef _EFI_SIZE_T_ size_t;
#undef _EFI_SIZE_T_
#undef _BSD_SIZE_T_
#endif
-/*
- * This is fairly grotesque, but pure ANSI code must not inspect the
- * innards of an fpos_t anyway. The library internally uses off_t,
- * which we assume is exactly as big as eight chars.
- */
+/** @{
+ An object type capable of holding all information necessary to specify any
+ position within a file.
+
+ Each wide-oriented stream has an associated mbstate_t object that stores the
+ current parse state of the stream. A successful call to fgetpos stores a
+ representation of the value of this mbstate_t object as part of the value
+ of the fpos_t object. A later successful call to fsetpos using the same
+ stored fpos_t value restores the value of the associated mbstate_t object
+ as well as the position within the controlled stream.
+
+ This is fairly grotesque, but pure ANSI code must not inspect the
+ innards of an fpos_t anyway. The library internally uses off_t,
+ which we assume is exactly as big as eight chars.
+**/
#if (!defined(_ANSI_SOURCE) && !defined(__STRICT_ANSI__)) || defined(_LIBC)
typedef __off_t fpos_t;
#else
@@ -59,14 +184,7 @@ typedef struct __sfpos {
__off_t _pos;
} fpos_t;
#endif
-
-#define _FSTDIO /* Define for new stdio with functions. */
-
-/*
- * NB: to fit things in six character monocase externals, the stdio
- * code uses the prefix `__s' for stdio objects, typically followed
- * by a three-character attempt at a mnemonic.
- */
+/*@}*/
/* stdio buffers */
struct __sbuf {
@@ -74,15 +192,14 @@ struct __sbuf {
int _size;
};
-/*
- * stdio state variables.
+/** Structure which holds all the information needed to control a stream or file.
*
- * The following always hold:
+ * The following always hold:<BR>
*
- * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
- * _lbfsize is -_bf._size, else _lbfsize is 0
- * if _flags&__SRD, _w is 0
- * if _flags&__SWR, _r is 0
+ * - if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
+ * - _lbfsize is -_bf._size, else _lbfsize is 0
+ * - if _flags&__SRD, _w is 0
+ * - if _flags&__SWR, _r is 0
*
* This ensures that the getc and putc macros (or inline functions) never
* try to write or read from a file that is in `read' or `write' mode.
@@ -98,133 +215,295 @@ struct __sbuf {
* _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
* _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
*
- * NB: see WARNING above before changing the layout of this structure!
*/
typedef struct __sFILE {
- unsigned char *_p; /* current position in (some) buffer */
- int _r; /* read space left for getc() */
- int _w; /* write space left for putc() */
- unsigned short _flags; /* flags, below; this FILE is free if 0 */
- short _file; /* fileno, if Unix descriptor, else -1 */
- struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
- int _lbfsize; /* 0 or -_bf._size, for inline putc */
+ unsigned char *_p; /**< current position in (some) buffer */
+ int _r; /**< read space left for getc() */
+ int _w; /**< write space left for putc() */
+ unsigned short _flags; /**< flags, below; this FILE is free if 0 */
+ short _file; /**< fileno, if Unix descriptor, else -1 */
+ struct __sbuf _bf; /**< the buffer (at least 1 byte, if !NULL) */
+ int _lbfsize; /**< 0 or -_bf._size, for inline putc */
/* operations */
- void *_cookie; /* cookie passed to io functions */
+ void *_cookie; /**< cookie passed to io functions */
int (*_close)(void *);
int (*_read) (void *, char *, int);
fpos_t (*_seek) (void *, fpos_t, int);
int (*_write)(void *, const char *, int);
- /* file extension */
+ /** file extension */
struct __sbuf _ext;
- /* separate buffer for long sequences of ungetc() */
- unsigned char *_up; /* saved _p when _p is doing ungetc data */
- int _ur; /* saved _r when _r is counting ungetc data */
+ /** @{
+ Separate buffer for long sequences of ungetc().
+ **/
+ unsigned char *_up; /**< saved _p when _p is doing ungetc data */
+ int _ur; /**< saved _r when _r is counting ungetc data */
+ /*@}*/
/* tricks to meet minimum requirements even when malloc() fails */
- unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
- unsigned char _nbuf[1]; /* guarantee a getc() buffer */
+ unsigned char _ubuf[3]; /**< guarantee an ungetc() buffer */
+ unsigned char _nbuf[1]; /**< guarantee a getc() buffer */
- /* separate buffer for fgetln() when line crosses buffer boundary */
+ /** separate buffer for fgetln() when line crosses buffer boundary */
struct __sbuf _lb; /* buffer for fgetln() */
/* Unix stdio files get aligned to block boundaries on fseek() */
- int _blksize; /* stat.st_blksize (may be != _bf._size) */
- fpos_t _offset; /* current lseek offset */
+ int _blksize; /**< stat.st_blksize (may be != _bf._size) */
+ fpos_t _offset; /**< current lseek offset */
} FILE;
__BEGIN_DECLS
extern FILE __sF[];
__END_DECLS
-#define __SLBF 0x0001 /* line buffered */
-#define __SNBF 0x0002 /* unbuffered */
-#define __SRD 0x0004 /* OK to read */
-#define __SWR 0x0008 /* OK to write */
+#define __SLBF 0x0001 /**< line buffered */
+#define __SNBF 0x0002 /**< unbuffered */
+#define __SRD 0x0004 /**< OK to read */
+#define __SWR 0x0008 /**< OK to write */
/* RD and WR are never simultaneously asserted */
-#define __SRW 0x0010 /* open for reading & writing */
-#define __SEOF 0x0020 /* found EOF */
-#define __SERR 0x0040 /* found error */
-#define __SMBF 0x0080 /* _buf is from malloc */
-#define __SAPP 0x0100 /* fdopen()ed in append mode */
-#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
-#define __SOPT 0x0400 /* do fseek() optimization */
-#define __SNPT 0x0800 /* do not do fseek() optimization */
-#define __SOFF 0x1000 /* set iff _offset is in fact correct */
-#define __SMOD 0x2000 /* true => fgetln modified _p text */
-#define __SALC 0x4000 /* allocate string space dynamically */
+#define __SRW 0x0010 /**< open for reading & writing */
+#define __SEOF 0x0020 /**< found EOF */
+#define __SERR 0x0040 /**< found error */
+#define __SMBF 0x0080 /**< _buf is from malloc */
+#define __SAPP 0x0100 /**< fdopen()ed in append mode */
+#define __SSTR 0x0200 /**< this is an sprintf/snprintf string */
+#define __SOPT 0x0400 /**< do fseek() optimization */
+#define __SNPT 0x0800 /**< do not do fseek() optimization */
+#define __SOFF 0x1000 /**< set iff _offset is in fact correct */
+#define __SMOD 0x2000 /**< true => fgetln modified _p text */
+#define __SALC 0x4000 /**< allocate string space dynamically */
-/*
- * The following three definitions are for ANSI C, which took them
- * from System V, which brilliantly took internal interface macros and
- * made them official arguments to setvbuf(), without renaming them.
- * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
- *
- * Although numbered as their counterparts above, the implementation
- * does not rely on this.
+/* The following three definitions are for ANSI C, which took them
+ from System V, which brilliantly took internal interface macros and
+ made them official arguments to setvbuf(), without renaming them.
+ Hence, these ugly _IOxxx names are *supposed* to appear in user code.
+
+ Although numbered as their counterparts above, the implementation
+ does not rely on this.
*/
-#define _IOFBF 0 /* setvbuf should set fully buffered */
-#define _IOLBF 1 /* setvbuf should set line buffered */
-#define _IONBF 2 /* setvbuf should set unbuffered */
+#define _IOFBF 0 /**< setvbuf should set fully buffered */
+#define _IOLBF 1 /**< setvbuf should set line buffered */
+#define _IONBF 2 /**< setvbuf should set unbuffered */
-#define BUFSIZ 1024 /* size of buffer used by setbuf */
-#define EOF (-1)
+#define BUFSIZ 1024 /**< size of buffer used by setbuf */
+#define EOF (-1) /**< A constant integer expression indicating end-of-file. */
-/*
- * FOPEN_MAX is a minimum maximum, and is the number of streams that
- * stdio can provide without attempting to allocate further resources
- * (which could fail). Do not use this for anything.
+/** FOPEN_MAX is a minimum maximum, and is the number of streams that
+ stdio can provide without attempting to allocate further resources
+ (which could fail). Do not use this for anything.
*/
#define FOPEN_MAX OPEN_MAX /* must be <= OPEN_MAX <sys/syslimits.h> */
+
+/** Size needed for an array of char large enough to hold the longest file name string. */
#define FILENAME_MAX PATH_MAX /* must be <= PATH_MAX <sys/syslimits.h> */
+/** Size needed for an array of char large enough to hold the file name string
+ generated by the tmpname() function.
+**/
#define L_tmpnam PATH_MAX /* must be == PATH_MAX */
#ifndef TMP_MAX
-#define TMP_MAX 308915776 /* Legacy */
+#define TMP_MAX 308915776 /**< The maximum number of unique file names
+ that can be generated by tmpnam(). **/
#endif
/* Always ensure that these are consistent with <fcntl.h>! */
#ifndef SEEK_SET
-#define SEEK_SET 0 /* set file offset to offset */
+#define SEEK_SET 0 /**< set file offset to offset */
#endif
#ifndef SEEK_CUR
-#define SEEK_CUR 1 /* set file offset to current plus offset */
+#define SEEK_CUR 1 /**< set file offset to current plus offset */
#endif
#ifndef SEEK_END
-#define SEEK_END 2 /* set file offset to EOF plus offset */
+#define SEEK_END 2 /**< set file offset to EOF plus offset */
#endif
-#define stdin (&__sF[0])
-#define stdout (&__sF[1])
-#define stderr (&__sF[2])
+#define stdin (&__sF[0]) /**< FILE reference for the STanDard INput stream. */
+#define stdout (&__sF[1]) /**< FILE reference for the STanDard OUTput stream. */
+#define stderr (&__sF[2]) /**< FILE reference for the STanDard ERRor stream. */
-/*
- * Functions defined in ANSI C standard.
- */
__BEGIN_DECLS
-void clearerr(FILE *);
-int fclose (FILE *);
-int feof (FILE *);
-int ferror (FILE *);
-int fflush (FILE *);
-int fgetc (FILE *);
-int fgetpos (FILE * __restrict, fpos_t * __restrict);
-char *fgets (char * __restrict, int, FILE * __restrict);
-FILE *fopen (const char * __restrict , const char * __restrict);
+/* Functions defined in C95 standard. ###################################### */
+
+/* ################ Operations on files. */
+
+/** Remove (delete) a file.
+
+ @param[in] FileName The path to the file to be removed.
+
+ @retval Zero The operation succeeded.
+ @retval Non-zero The operation failed.
+**/
+int remove (const char *FileName);
+
+/** Rename the file named OldName to NewName.
+
+ @param[in] OldName The name of the existing file to be renamed.
+ @param[in] NewName The new name of the file.
+
+ @retval Zero The operation succeeded.
+ @retval Non-zero The operation failed. OldName still exists and has been unmodified.
+ If OldName does not exist, or a file named NewName already exists,
+ rename() will fail are return a non-zero value.
+**/
+int rename (const char *OldName, const char *NewName);
+
+/** Create a guaranteed unique temporary file.
+ A binary file is created in the _PATH_TMP directory that is guaranteed to
+ have a unique name. The file will be open for update with mode "wb+" and
+ its FILE pointer returned upon successfull completion. When the file is
+ closed, or when the creating program terminates, the file will be removed.
+
+ @retval NULL The temporary file could not be created.
+ @retval non-NULL The returned value is a pointer to the FILE object
+ associated with the newly created and open temporary file.
+**/
+FILE *tmpfile (void);
+
+/** Generate a string that is a valid file name, in the _PATH_TMP directory, that
+ is not the same as the name of an existing file. The function can potentially
+ generate up to TMP_MAX different strings.
+
+ @param[out] Buffer A pointer to an array of at least L_tmpnam char elements.
+ or NULL. If non-NULL, the tmpnam function writes its
+ result into that array and returns the argument
+ as its value.
+
+ @return If no suitable string can be generated a NULL pointer is returned.
+ Otherwise, if Buffer is NULL, the result is produced in an internal
+ static object and a pointer to that object is returned. If Buffer
+ is non-null, the results are written into the array pointed to by
+ Buffer and Buffer is returned.
+**/
+char *tmpnam (char *Buffer);
+
+/* ################ File access functions. */
+
+/** Close the open stream, specified by fp, and de-associate it from any file or device.
+
+ @param[in] fp Pointer to a stream object, of type FILE, associated with a
+ file or device.
+
+ @retval Zero The stream was successfully closed.
+ @retval Non-zero There was an error closing the stream.
+**/
+int fclose (FILE *fp);
+
+/** Empties any buffers associated with the stream specified by fp.
+
+ @param[in] fp Pointer to a stream object, of type FILE, associated with a
+ file or device.
+
+ @retval Zero The stream's buffers were successfully emptied.
+ @retval EOF There was an error writing to the stream.
+**/
+int fflush (FILE *fp);
+
+/** Associates a file, named by Path, with a stream and prepares it for subsequent
+ operations.
+
+ The parameter Mode points to a string specifying behavior characteristics for
+ the opened file. The recognized Mode strings are:
+ - r Open text file for reading.
+ - w Truncate file to zero length or create text file for writing.
+ - a Open or create a text file for writing at end-of-file (append).
+ - rb Open binary file for reading.
+ - wb Truncate file to zero length or create binary file for writing.
+ - ab Open or create a binary file for writing at end-of-file (append).
+ - r+ Open text file for update (reading and writing).
+ - w+ Truncate file to zero length or create text file for update.
+ - a+ Open or create a text file for update, writing at end-of-file.
+ - r+b or rb+ Open binary file for update (reading and writing).
+ - w+b or wb+ Truncate file to zero length or create binary file for update.
+ - a+b or ab+ Open or create a binary file for update, writing at end-of-file.
+
+ Opening a file with read mode fails if the file does not exist.
+
+ Opening a file with append mode causes all writes to the file to be forced to
+ the current end-of-file, regardless of any intervening calls to fseek.
+
+ @param[in] Path The path or name of the file or device to open.
+ @param[in] Mode The mode in which the file is to be opened.
+
+ @return A pointer to a FILE object associated with the opened file is returned
+ if the file was opened successfully. Otherwise, NULL is returned.
+**/
+FILE *fopen (const char * __restrict Path, const char * __restrict Mode);
+
+/** Closes the file associated with Ofp then opens the file specified by Path and associates it with
+ stream Ofp.
+
+ Any errors that occur when closing Ofp are ignored. The file specified by Path is opened with mode Mode
+ and associated with stream Ofp instead of producing a new stream object.
+
+ If Path is NULL, the mode of the file associated with Ofp is changed to Mode.
+
+ @param[in] Path The path or name of the file or device to open.
+ @param[in] Mode The mode in which the file is to be opened.
+ @param[in] Ofp Pointer to the FILE object to be closed and associated with the new file.
+
+ @return If Path was not able to be opened, or the mode changed, NULL is returned;
+ otherwise Ofp is returned.
+**/
+FILE *freopen (const char * __restrict Path, const char * __restrict Mode, FILE * __restrict Ofp);
+
+/** Establishes Fully Buffered or Non-buffered mode for a stream, fp, using Buff as the buffer.
+
+ The file associated with fp must have been successfully opened with no operations, other than
+ possibly an unsuccessful call to setvbuf, performed prior to the call to setbuf.
+
+ If Buff is non-NULL, the stream associated with fp is set to Fully Buffered mode using the
+ array pointed to by Buff as the buffer. The buffer is assumed to be BUFSIZ char long.
+ This is equivalent to calling setvbuf(fp, Buff, _IOFBF, BUFSIZ);
+
+ If Buff is NULL, stream fp is set to Non-buffered mode.
+ This is equivalent to calling setvbuf(fp, NULL, _IONBF, 0);
+
+ @param[in] fp Pointer to the FILE object which will have its buffer set.
+ @param[in] Buff The buffer to use for fp, or NULL.
+**/
+void setbuf (FILE * __restrict fp, char * __restrict Buff);
+
+/** Establishes a buffering mode and buffer for use by operations performed on the file associated with fp.
+
+ The file associated with fp must have been successfully opened with no operations, other than
+ possibly an unsuccessful call to setvbuf, performed prior to the call to setbuf.
+
+ Parameter BufMode determines how stream fp will be buffered:
+ - _IOFBF causes I/O to be fully buffered.
+ - _IOLBF causes I/O to be line buffered.
+ - _IONBF causes I/O to be unbuffered.
+
+ If Buff is not NULL, it points to an array to be used as an I/O buffer for stream fp. The
+ buffer is set to BufSize char in length. Otherwise, an array of BufSize char is allocated
+ by the setvbuf function if BufMode is not _IONBF.
+
+ It is an error for BufSize to be zero unless BufMode is _IONBF, in which case BufSize is ignored.
+
+ @param[in] fp Pointer to the FILE object which will have its buffer set.
+ @param[in] Buff The buffer to use for fp, or NULL.
+ @param[in] BufMode The buffering mode to use.
+ @param[in] BufSize The size of the buffer to use, specified in char.
+
+ @retval Zero The buffer and mode were established successfully.
+ @retval Non-zero The request can not be honored, or an invalid value for BufMode was given.
+**/
+int setvbuf (FILE * __restrict fp, char * __restrict Buff, int BufMode, size_t BufSize);
+
+/* ################ Formatted Input/Output Functions. */
/** The fprintf function writes output to the stream pointed to by stream,
under control of the string pointed to by format that specifies how
subsequent arguments are converted for output. If there are insufficient
- arguments for the format, the behavior is undefined. If the format is
+ arguments for the format, the behavior is indeterminate. If the format is
exhausted while arguments remain, the excess arguments are evaluated
(as always) but are otherwise ignored. The fprintf function returns when
the end of the format string is encountered.
- The format shall be a multibyte character sequence, beginning and ending in
- its initial shift state. The format is composed of zero or more directives:
+ The format is interpreted as a multibyte character sequence, beginning and ending
+ in its initial shift state. The format is composed of zero or more directives:
ordinary multibyte characters (not %), which are copied unchanged to the
output stream; and conversion specifications, each of which results in
fetching zero or more subsequent arguments, converting them, if applicable,
@@ -248,8 +527,8 @@ FILE *fopen (const char * __restrict , const char * __restrict);
conversions. The precision takes the form of a period (.) followed
either by an asterisk * (described later) or by an optional decimal
integer; if only the period is specified, the precision is taken as
- zero. If a precision appears with any other conversion specifier, the
- behavior is undefined.
+ zero. If a precision appears with any other conversion specifier, it
+ is ignored.
- An optional length modifier that specifies the size of the argument.
- A conversion specifier character that specifies the type of conversion
to be applied.
@@ -259,7 +538,7 @@ FILE *fopen (const char * __restrict , const char * __restrict);
precision. The arguments specifying field width, or precision, or both, shall
appear (in that order) before the argument (if any) to be converted. A negative
field width argument is taken as a - flag followed by a positive field width.
- A negative precision argument is taken as if the precision were omitted.
+ A negative precision argument is interpreted as if the precision were omitted.
The flag characters and their meanings are:
- The result of the conversion is left-justified within the field.
@@ -271,24 +550,24 @@ FILE *fopen (const char * __restrict , const char * __restrict);
if a signed conversion results in no characters, a space is
prefixed to the result. If the space and + flags both appear, the
space flag is ignored.
- # The result is converted to an "alternative form". For o
- conversion, it increases the precision, if and only if necessary,
- to force the first digit of the result to be a zero (if the value
- and precision are both 0, a single 0 is printed). For x (or X)
- conversion, a nonzero result has 0x (or 0X) prefixed to it. For e,
- E, f, F, g, and G conversions, the result of converting a
- floating-point number always contains a decimal-point character,
- even if no digits follow it. (Normally, a decimal-point character
- appears in the result of these conversions only if a digit follows
- it.) For g and G conversions, trailing zeros are not removed from
- the result. For other conversions, the behavior is undefined.
+ # The result is converted to an "alternative form".
+ - For o conversion, it increases the precision, if and only if necessary,
+ to force the first digit of the result to be a zero (if the value
+ and precision are both 0, a single 0 is printed).
+ - For x (or X) conversion, a nonzero result has 0x (or 0X) prefixed to it.
+ - For e, E, f, F, g, and G conversions, the result of converting a
+ floating-point number always contains a decimal-point character,
+ even if no digits follow it. (Normally, a decimal-point character
+ appears in the result of these conversions only if a digit follows
+ it.)
+ - For g and G conversions, trailing zeros are not removed from
+ the result. For other conversions, it is ignored.
0 For d, i, o, u, x, X, e, E, f, F, g, and G conversions, leading
zeros (following any indication of sign or base) are used to pad to
the field width rather than performing space padding, except when
converting an infinity or NaN. If the 0 and - flags both appear,
the 0 flag is ignored. For d, i, o, u, x, and X conversions, if a
- precision is specified, the 0 flag is ignored. For other
- conversions, the behavior is undefined.
+ precision is specified, the 0 flag is ignored.
The length modifiers and their meanings are:
hh Specifies that a following d, i, o, u, x, or X conversion specifier
@@ -329,7 +608,7 @@ FILE *fopen (const char * __restrict , const char * __restrict);
applies to a long double argument.
If a length modifier appears with any conversion specifier other than as
- specified above, the behavior is undefined.
+ specified above, it is ignored.
The conversion specifiers and their meanings are:
d,i The int argument is converted to signed decimal in the style
@@ -354,12 +633,9 @@ FILE *fopen (const char * __restrict , const char * __restrict);
decimal-point character appears. If a decimal-point character
appears, at least one digit appears before it. The value is rounded
to the appropriate number of digits.
- A double argument representing an infinity is converted in one
- of the styles [-]inf or [-]infinity - which style is
- implementation-defined. A double argument representing a NaN is
- converted in one of the styles [-]nan or [-]nan(n-char-sequence)
- - which style, and the meaning of any n-char-sequence, is
- implementation-defined. The F conversion specifier produces INF,
+ A double argument representing an infinity is converted in
+ the style [-]inf. A double argument representing a NaN is
+ converted in the style [-]nan. The F conversion specifier produces INF,
INFINITY, or NAN instead of inf, infinity, or nan, respectively.
e,E A double argument representing a floating-point number is
converted in the style [-]d.ddd e[+-]dd, where there is one digit
@@ -423,13 +699,12 @@ FILE *fopen (const char * __restrict , const char * __restrict);
past the end of the array. In no case is a partial multibyte
character written.
p The argument shall be a pointer to void. The value of the
- pointer is converted to a sequence of printing characters, in an
- implementation-defined manner.
+ pointer is converted to a sequence of printing characters.
n The argument shall be a pointer to signed integer into which is
written the number of characters written to the output stream so
far by this call to fprintf. No argument is converted, but one is
consumed. If the conversion specification includes any flags, a
- field width, or a precision, the behavior is undefined.
+ field width, or a precision, they will be ignored.
% A % character is written. No argument is converted. The
complete conversion specification shall be %%.
@@ -447,86 +722,752 @@ FILE *fopen (const char * __restrict , const char * __restrict);
@return The fprintf function returns the number of characters
transmitted, or a negative value if an output or encoding
error occurred.
-
**/
int fprintf (FILE * __restrict stream, const char * __restrict format, ...);
-int fputc (int, FILE *);
-int fputs (const char * __restrict, FILE * __restrict);
-size_t fread (void * __restrict, size_t, size_t, FILE * __restrict);
-FILE *freopen (const char * __restrict, const char * __restrict, FILE * __restrict);
-int fscanf (FILE * __restrict, const char * __restrict, ...);
-int fseek (FILE *, long, int);
-int fsetpos (FILE *, const fpos_t *);
-long ftell (FILE *);
-size_t fwrite (const void * __restrict, size_t, size_t, FILE * __restrict);
+/** Reads characters from stream, under control of format, storing the converted values
+ in variables pointed to by the variable-length parameter list.
+
+ The format is interpreted as a multibyte character sequence, beginning and ending
+ in its initial shift state. The format is composed of zero or more directives:
+ one or more white-space characters, an ordinary multibyte character
+ (neither % nor a white-space character), or a conversion specification.
+
+ Each conversion specification is introduced by the character %. After
+ the %, the following appear in sequence:
+ - An optional assignment-suppressing character, *.
+ - An optional decimal integer, greater than zero, that specifies the
+ maximum field width (in characters).
+ - An optional length modifier that specifies the size of the receiving object.
+ - A conversion specifier character that specifies the type of conversion
+ to be applied.
+
+ The fscanf function executes each directive of the format in turn. If a directive fails, as
+ detailed below, the function returns. Failures are described as input failures (due to the
+ occurrence of an encoding error or the unavailability of input characters), or matching
+ failures (due to inappropriate input).
+
+ A directive composed of white-space character(s) is executed by reading input up to the
+ first non-white-space character (which remains unread), or until no more characters can
+ be read.
+
+ A directive that is an ordinary multibyte character is executed by reading the next
+ characters of the stream. If any of those characters differ from the ones composing the
+ directive, the directive fails and the differing and subsequent characters remain unread.
+ Similarly, if end-of-file, an encoding error, or a read error prevents a character from being
+ read, the directive fails.
+
+ The length modifiers and their meanings are:
+ - hh Specifies that a following d, i, o, u, x, X, or n conversion
+ specifier applies to an argument with type pointer to signed
+ char or unsigned char.
+ - h Specifies that a following d, i, o, u, x, X, or n conversion
+ specifier applies to an argument with type pointer to short
+ int or unsigned short int.
+ - l (ell) Specifies that a following d, i, o, u, x, X, or n conversion
+ specifier applies to an argument with type pointer to
+ long int or unsigned long int; that a following a, A, e,
+ E, f, F, g, or G conversion specifier applies to an
+ argument with type pointer to double; or that a following
+ c, s, or [ conversion specifier applies to an argument
+ with type pointer to wchar_t.
+ - ll (ell-ell) Specifies that a following d, i, o, u, x, X, or n conversion
+ specifier applies to an argument with type pointer to
+ long long int or unsigned long long int.
+ - j Specifies that a following d, i, o, u, x, X, or n conversion
+ specifier applies to an argument with type pointer to
+ intmax_t or uintmax_t.
+ - z Specifies that a following d, i, o, u, x, X, or n conversion
+ specifier applies to an argument with type pointer to
+ size_t or the corresponding signed integer type.
+ - t Specifies that a following d, i, o, u, x, X, or n conversion
+ specifier applies to an argument with type pointer to
+ ptrdiff_t or the corresponding unsigned integer type.
+ - L Specifies that a following e, E, f, F, g, or G
+ conversion specifier applies to an argument with type
+ pointer to long double.
+
+ If a length modifier appears with any conversion specifier other than as specified above,
+ it will be ignored.
+
+ The conversion specifiers and their meanings are:
+ - d Matches an optionally signed decimal integer, whose format is
+ the same as expected for the subject sequence of the strtol
+ function with the value 10 for the base argument. The
+ corresponding argument shall be a pointer to signed integer.
+ - i Matches an optionally signed integer, whose format is the same
+ as expected for the subject sequence of the strtol function
+ with the value 0 for the base argument. The corresponding
+ argument shall be a pointer to signed integer.
+ - o Matches an optionally signed octal integer, whose format is the
+ same as expected for the subject sequence of the strtoul
+ function with the value 8 for the base argument. The
+ corresponding argument shall be a pointer to unsigned integer.
+ - u Matches an optionally signed decimal integer, whose format is
+ the same as expected for the subject sequence of the strtoul
+ function with the value 10 for the base argument. The
+ corresponding argument shall be a pointer to unsigned integer.
+ - x Matches an optionally signed hexadecimal integer, whose format
+ is the same as expected for the subject sequence of the strtoul
+ function with the value 16 for the base argument. The
+ corresponding argument shall be a pointer to unsigned integer.
+ - e,f,g Matches an optionally signed floating-point number, infinity,
+ or NaN, whose format is the same as expected for the subject
+ sequence of the strtod function. The corresponding argument
+ shall be a pointer to floating.
+ - c Matches a sequence of characters of exactly the number
+ specified by the field width (1 if no field width is present
+ in the directive). If no l length modifier is present, the
+ corresponding argument shall be a pointer to the initial
+ element of a character array large enough to accept the
+ sequence. No null character is added.<BR><BR>
+ If an l length modifier is present, the input shall be a
+ sequence of multibyte characters that begins in the initial
+ shift state. Each multibyte character in the sequence is
+ converted to a wide character as if by a call to the mbrtowc
+ function, with the conversion state described by an mbstate_t
+ object initialized to zero before the first multibyte character
+ is converted. The corresponding argument shall be a pointer to
+ the initial element of an array of wchar_t large enough to
+ accept the resulting sequence of wide characters. No null wide
+ character is added.
+ - s Matches a sequence of non-white-space characters.
+ If no l length modifier is present, the corresponding argument
+ shall be a pointer to the initial element of a character array
+ large enough to accept the sequence and a terminating null
+ character, which will be added automatically. If an l length
+ modifier is present, the input shall be a sequence of multibyte
+ characters that begins in the initial shift state. Each
+ multibyte character is converted to a wide character as if by a
+ call to the mbrtowc function, with the conversion state
+ described by an mbstate_t object initialized to zero before the
+ first multibyte character is converted. The corresponding
+ argument shall be a pointer to the initial element of an array
+ of wchar_t large enough to accept the sequence and the
+ terminating null wide character, which will be added automatically.
+ - [ Matches a nonempty sequence of characters from a set of
+ expected characters (the scanset).<BR><BR>
+ If no l length modifier is present, the corresponding argument
+ shall be a pointer to the initial element of a character array
+ large enough to accept the sequence and a terminating null
+ character, which will be added automatically. If an l length
+ modifier is present, the input shall be a sequence of multibyte
+ characters that begins in the initial shift state. Each
+ multibyte character is converted to a wide character as if by a
+ call to the mbrtowc function, with the conversion state
+ described by an mbstate_t object initialized to zero before the
+ first multibyte character is converted. The corresponding
+ argument shall be a pointer to the initial element of an array
+ of wchar_t large enough to accept the sequence and the
+ terminating null wide character, which will be added
+ automatically.<BR><BR>
+ The conversion specifier includes all subsequent characters in
+ the format string, up to and including the matching right
+ bracket (]). The characters between the brackets (the scanlist)
+ compose the scanset, unless the character after the left
+ bracket is a circumflex (^), in which case the scanset contains
+ all characters that do not appear in the scanlist between the
+ circumflex and the right bracket. If the conversion specifier
+ begins with [] or [^], the right bracket character is in the
+ scanlist and the next following right bracket character is the
+ matching right bracket that ends the specification; otherwise
+ the first following right bracket character is the one that
+ ends the specification. If a - character is in the scanlist and
+ is not the first, nor the second where the first character is
+ a ^, nor the last character, it will be treated as a regular character.
+ - p Matches a set of sequences, which are the same as the set of
+ sequences that are produced by the %p conversion of the fprintf
+ function. The corresponding argument must be a pointer to a
+ pointer to void. The input item is converted to a pointer value.
+ If the input item is a value converted earlier during the same
+ program execution, the pointer that results will compare equal
+ to that value; otherwise the behavior of the %p conversion is
+ indeterminate.
+ - n No input is consumed. The corresponding argument shall be a
+ pointer to signed integer into which is to be written the
+ number of characters read from the input stream so far by this
+ call to the fscanf function. Execution of a %n directive does
+ not increment the assignment count returned at the completion
+ of execution of the fscanf function. No argument is converted,
+ but one is consumed. If the conversion specification includes
+ an assignment suppressing character the conversion specification
+ is ignored. If the conversion specification contains a
+ field width, the field width will be ignored.
+ - % Matches a single % character; no conversion or assignment occurs.
+
+ @param[in] stream An open File specifier from which the input is read.
+ @param[in] format A multi-byte character sequence containing characters
+ to be matched against, and conversion specifiers
+ which convert their associated arguments. Converted
+ items are stored according to their associated arguments.
+ @param ... Variable number of parameters, as required by format,
+ specifying the objects to receive the converted input.
+
+ @return The fscanf function returns EOF if an input failure occurs before
+ any conversion. Otherwise the number of input items assigned
+ is returned; which can be fewer than provided for, or even zero
+ in the event of an early matching failure.
+**/
+int fscanf (FILE * __restrict stream, const char * __restrict format, ...);
+
+/** Formatted print to stdout.
+
+ The printf function is equivalent to fprintf with stdout used as the output stream.
+
+ @param[in] format A multi-byte character sequence containing characters
+ to be copied unchanged, and conversion specifiers
+ which convert their associated arguments. Copied and
+ converted characters are sent to the output stream.
+ @param ... Variable number of parameters as required by format.
+
+ @return The printf function returns the number of characters
+ transmitted, or a negative value if an output or encoding
+ error occurred.
+**/
+int printf (const char * __restrict format, ...);
+
+/** Formatted input from stdin.
+
+ The scanf function is equivalent to fscanf with stdin used as the input stream.
+
+ @param[in] format A multi-byte character sequence containing characters
+ to be matched against, and conversion specifiers
+ which convert their associated arguments. Converted
+ items are stored according to their associated arguments.
+ @param[out] ... Variable number of parameters, as required by format,
+ specifying the objects to receive the converted input.
+
+ @return The scanf function returns EOF if an input failure occurs before
+ any conversion. Otherwise the number of input items assigned
+ is returned; which can be fewer than provided for, or even zero
+ in the event of an early matching failure.
+**/
+int scanf (const char * __restrict format, ...);
+
+/** Formatted output to a buffer.
+
+ The sprintf function is equivalent to fprintf, except that the output is
+ written into array Buff instead of to a stream. A null character is written
+ at the end of the characters written; it is not counted as part of the
+ returned value.
+
+ @param[out] Buff A pointer to the array to receive the formatted output.
+ @param[in] Format A multi-byte character sequence containing characters
+ to be copied unchanged, and conversion specifiers
+ which convert their associated arguments. Copied and
+ converted characters are written to the array pointed
+ to by Buff.
+ @param ... Variable number of parameters as required by format.
+
+ @return The sprintf function returns the number of characters written in
+ the array, not counting the terminating null character, or a
+ negative value if an encoding error occurred.
+**/
+int sprintf (char * __restrict Buff, const char * __restrict Format, ...);
+
+/** Formatted input from a string.
+
+ The sscanf function is equivalent to fscanf, except that input is obtained
+ from a string rather than from a stream. Reaching the end of the string
+ is equivalent to encountering end-of-file for the fscanf function.
+
+ @param[in] Buff Pointer to the string from which to obtain input.
+ @param[in] Format A multi-byte character sequence containing characters
+ to be matched against, and conversion specifiers
+ which convert their associated arguments. Converted
+ items are stored according to their associated arguments.
+ @param[out] ... Variable number of parameters, as required by format,
+ specifying the objects to receive the converted input.
+
+ @return The scanf function returns EOF if an input failure occurs before
+ any conversion. Otherwise the number of input items assigned
+ is returned; which can be fewer than provided for, or even zero
+ in the event of an early matching failure.
+**/
+int sscanf (const char * __restrict Buff, const char * __restrict Format, ...);
+
+/** Print formatted values from an argument list.
+
+ The vfprintf function is equivalent to fprintf, with the variable argument
+ list replaced by Args, which must have been initialized by the va_start macro.
+ The vfprintf function does not invoke the va_end macro.
+
+ @param[in] Stream The output stream to receive the formatted output.
+ @param[in] Format A multi-byte character sequence containing characters
+ to be matched against, and conversion specifiers
+ which convert their associated arguments. Converted
+ items are stored according to their associated arguments.
+ @param[in] Args A list of arguments, initialized by the va_start macro
+ and accessed using the va_arg macro, used to satisfy
+ the directives in the Format string.
+
+ @return The vfprintf function returns the number of characters transmitted,
+ or a negative value if an output or encoding error occurred.
+**/
+int vfprintf(FILE * __restrict Stream, const char * __restrict Format, va_list Args);
+
+/** Formatted print, to stdout, from an argument list.
+
+ The vprintf function is equivalent to printf, with the variable argument
+ list replaced by Args, which must have been initialized by the va_start
+ macro (and possibly subsequent va_arg calls). The vprintf function does
+ not invoke the va_end macro.
+
+ @param[in] Format A multi-byte character sequence containing characters
+ to be matched against, and conversion specifiers
+ which convert their associated arguments. Converted
+ items are stored according to their associated arguments.
+ @param[in] Args A list of arguments, initialized by the va_start macro
+ and accessed using the va_arg macro, used to satisfy
+ the directives in the Format string.
+
+ @return The vprintf function returns the number of characters transmitted,
+ or a negative value if an output or encoding error occurred.
+**/
+int vprintf (const char * __restrict Format, va_list Args);
+
+/** Formatted print, to a buffer, from an argument list.
+
+ The vsprintf function is equivalent to sprintf, with the variable argument
+ list replaced by Args, which must have been initialized by the va_start
+ macro. The vsprintf function does not invoke the va_end macro.
+
+ @param[out] Buff A pointer to the array to receive the formatted output.
+ @param[in] Format A multi-byte character sequence containing characters
+ to be copied unchanged, and conversion specifiers
+ which convert their associated arguments. Copied and
+ converted characters are written to the array pointed
+ to by Buff.
+ @param[in] Args A list of arguments, initialized by the va_start macro
+ and accessed using the va_arg macro, used to satisfy
+ the directives in the Format string.
+
+ @return The vsprintf function returns the number of characters written in
+ the array, not counting the terminating null character, or a
+ negative value if an encoding error occurred.
+**/
+int vsprintf(char * __restrict Buff, const char * __restrict Format, va_list Args);
+
+/* ################ Character Input/Output Functions. */
+
+/** Get a character from an input Stream.
+
+ If the end-of-file indicator for the input stream pointed to by Stream is
+ not set, and a next character is present, the fgetc function obtains that
+ character as an unsigned char converted to an int and advances the
+ associated file position indicator for the stream.
+
+ @param[in] Stream An input stream from which to obtain a character.
+
+ @return If the end-of-file indicator for the stream is set, or if the
+ stream is at end-of-file, the end-of-file indicator for the
+ stream is set and the fgetc function returns EOF. Otherwise,
+ the fgetc function returns the next character from the input
+ stream pointed to by Stream. If a read error occurs, the
+ error indicator for the stream is set and the fgetc function
+ returns EOF.
+**/
+int fgetc (FILE *Stream);
+
+/** Read a string from an input stream into a buffer.
+
+ The fgets function reads at most one less than the number of characters
+ specified by Limit from the stream pointed to by Stream into the array
+ pointed to by Buff. No additional characters are read after a
+ new-line character (which is retained) or after end-of-file. A null
+ character is written immediately after the last character read into the array.
+
+ @param[out] Buff A pointer to the array to receive the input string.
+ @param[in] Limit The maximum number of characters to put into Buff,
+ including the terminating null character.
+ @param[in] Stream An input stream from which to obtain a character.
+
+ @return The fgets function returns Buff if successful. If end-of-file is
+ encountered and no characters have been read into the array, the
+ contents of the array remain unchanged and a null pointer is
+ returned. If a read error occurs during the operation, the array
+ contents are indeterminate and a null pointer is returned.
+**/
+char *fgets (char * __restrict Buff, int Limit, FILE * __restrict Stream);
+
+/** Write a character to an output stream.
+
+ The fputc function writes the character specified by C (converted to an
+ unsigned char) to the output stream pointed to by Stream, at the position
+ indicated by the associated file position indicator for the stream
+ (if defined), and advances the indicator appropriately. If the file cannot
+ support positioning requests, or if the stream was opened with append mode,
+ the character is appended to the output stream.
+
+ @param[in] C The character to be written to Stream.
+ @param[in] Stream The output stream that C is to be written to.
+
+ @return The fputc function returns the character written. If a write
+ error occurs, the error indicator for the stream is set and
+ fputc returns EOF.
+**/
+int fputc (int C, FILE *Stream);
+
+/** Write a string to an output stream.
+
+ The fputs function writes String to the stream pointed to by Stream. The
+ terminating null character is not written.
+
+ @param[in] String The character string to be written to Stream.
+ @param[in] Stream The output stream that String is to be written to.
+
+ @return The fputs function returns EOF if a write error occurs; otherwise
+ it returns a non-negative value.
+**/
+int fputs (const char * __restrict String, FILE * __restrict Stream);
+
+/** Get a character from an input stream.
+
+ The getc function is equivalent to fgetc, except that if it is implemented
+ as a macro, it may evaluate stream more than once, so the argument should
+ never be an expression with side effects.
+
+ @param[in] Stream An input stream from which to obtain a character.
+
+ @return If the end-of-file indicator for the stream is set, or if the
+ stream is at end-of-file, the end-of-file indicator for the
+ stream is set and getc returns EOF. Otherwise, getc returns
+ the next character from the input stream pointed to by Stream.
+ If a read error occurs, the error indicator for the stream is set
+ and getc returns EOF.
+**/
int getc (FILE *);
+
+/** Get a character from stdin.
+
+ The getchar function is equivalent to getc with the argument stdin.
+
+ @return If the end-of-file indicator for stdin is set, or if stdin
+ is at end-of-file, the end-of-file indicator is set and getchar
+ returns EOF. Otherwise, getchar returns the next character from
+ stdin. If a read error occurs, the error indicator for stdin is
+ set and getchar returns EOF.
+**/
int getchar (void);
-void perror (const char *);
-int printf (const char * __restrict, ...);
-int putc (int, FILE *);
-int putchar (int);
-int puts (const char *);
-int remove (const char *);
-void rewind (FILE *);
-int scanf (const char * __restrict, ...);
-void setbuf (FILE * __restrict, char * __restrict);
-int setvbuf (FILE * __restrict, char * __restrict, int, size_t);
-int sscanf (const char * __restrict, const char * __restrict, ...);
-FILE *tmpfile (void);
-int ungetc (int, FILE *);
-int vfprintf(FILE * __restrict, const char * __restrict, va_list);
-int vprintf (const char * __restrict, va_list);
-
-#ifndef __AUDIT__
-char *gets (char *);
-int sprintf (char * __restrict, const char * __restrict, ...);
-char *tmpnam (char *);
-int vsprintf(char * __restrict, const char * __restrict, va_list);
-#endif
-#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
-int rename (const char *, const char *) __RENAME(__posix_rename);
-#else
-int rename (const char *, const char *);
-#endif
+/** Read a string from stdin into a buffer.
+
+ The gets function reads characters from the input stream pointed to by
+ stdin, into the array pointed to by Buff, until end-of-file is encountered
+ or a new-line character is read. Any new-line character is discarded, and
+ a null character is written immediately after the last character read into
+ the array.
+
+ @param[out] Buff A pointer to the array to receive the input string.
+
+ @return The gets function returns Buff if successful. If end-of-file is
+ encountered and no characters have been read into the array, the
+ contents of the array remain unchanged and a null pointer is
+ returned. If a read error occurs during the operation, the array
+ contents are indeterminate and a null pointer is returned.
+**/
+char *gets (char *Buff);
+
+/** Write a character to an output stream.
+
+ The putc function is equivalent to fputc, except that if it is implemented
+ as a macro, it may evaluate Stream more than once, so that argument should
+ never be an expression with side effects.
+
+ @param[in] C The character to be written to Stream.
+ @param[in] Stream The output stream that C is to be written to.
+
+ @return The putc function returns the character written. If a write
+ error occurs, the error indicator for the stream is set and
+ putc returns EOF.
+**/
+int putc (int C, FILE *Stream);
+
+/** Write a character to stdout.
+
+ The putchar function is equivalent to putc with stdout as the Stream argument.
+
+ @param[in] C The character to be written to stdout.
+
+ @return The putchar function returns the character written. If a write
+ error occurs, the error indicator for stdout is set and putchar
+ returns EOF.
+**/
+int putchar (int C);
+
+/** Write String to stdout.
+
+ The puts function writes the string pointed to by String to the stream
+ pointed to by stdout, and appends a new-line character to the output. The
+ terminating null character is not written.
+
+ @param[in] String A pointer to the character string to write to stdout.
+
+ @return The puts function returns EOF if a write error occurs; otherwise
+ it returns a non-negative value.
+**/
+int puts (const char *String);
+
+/** Return a character to the input Stream as if it had not been read.
+
+ The ungetc function pushes the character specified by C (converted to an
+ unsigned char) back onto the input stream pointed to by Stream. Pushed-back
+ characters will be returned by subsequent reads on that stream in the
+ reverse order of their being pushed. A successful intervening call
+ (with the stream pointed to by Stream) to a file positioning function
+ (fseek, fsetpos, or rewind) discards any pushed-back characters for the
+ stream. The external storage corresponding to the stream is unchanged.
+
+ One character of pushback is guaranteed. If the ungetc function is called
+ too many times on the same stream without an intervening read or file
+ positioning operation on that stream, the operation will fail.
+
+ If the value of C equals that of the macro EOF, the operation fails and the
+ input stream is unchanged.
+
+ A successful call to the ungetc function clears the end-of-file indicator
+ for the stream. The value of the file position indicator for the stream
+ after reading or discarding all pushed-back characters is the same as it
+ was before the characters were pushed back. For a binary stream, its
+ file position indicator is decremented by each successful call to the
+ ungetc function; if its value was zero before a call, it will remain zero
+ after the call.
+
+ @param[in] C The character to push back onto the Stream.
+ @param[in] Stream The output stream that C is to be pushed back onto.
+
+ @return The ungetc function returns the character pushed back,
+ or EOF if the operation fails.
+**/
+int ungetc (int C, FILE *Stream);
+
+/* ################ Direct Input/Output Functions. */
+
+/** Read Num elements of size Size from a Stream into a Buffer.
+
+ The fread function reads, into the array pointed to by Buffer, up to Num
+ elements, whose size is specified by Size, from the stream pointed to by
+ Stream. For each object, Size calls are made to the fgetc function and the
+ results stored, in the order read, in an array of unsigned char exactly
+ overlaying the Buffer object. The file position indicator for the stream
+ (if defined) is advanced by the number of characters successfully read. If
+ an error occurs, the resulting value of the file position indicator for the
+ stream is indeterminate.
+
+ @param[out] Buffer Pointer to an object to receive the read data.
+ @param[in] Size Size of each element to be read.
+ @param[in] Num Number of elements to read.
+ @param[in] Stream Input stream to read the data from.
+
+ @return The fread function returns the number of elements successfully
+ read, which may be less than Num if a read error or end-of-file
+ is encountered. If Size or Num is zero, fread returns zero and
+ the contents of the array and the state of the stream remain
+ unchanged.
+**/
+size_t fread (void * __restrict Buffer,
+ size_t Size,
+ size_t Num,
+ FILE * __restrict Stream
+ );
+
+/** Write Num elements of size Size from Buffer to Stream.
+
+ The fwrite function writes, from the array pointed to by Buffer, up to Num
+ elements whose size is specified by Size, to the stream pointed to by
+ Stream. For each object, Size calls are made to the fputc function, taking
+ the values (in order) from an array of unsigned char exactly overlaying the
+ Buffer object. The file position indicator for the stream (if defined) is
+ advanced by the number of characters successfully written. If an error
+ occurs, the resulting value of the file position indicator for the stream is
+ indeterminate.
+
+ @param[out] Buffer Pointer to an object containing the data to be written.
+ @param[in] Size Size of each element to be written.
+ @param[in] Num Number of elements to write.
+ @param[in] Stream Output stream to write the data to.
+
+ @return The fwrite function returns the number of elements successfully
+ written, which will be less than Num only if a write error is
+ encountered. If Size or Num is zero, fwrite returns zero and
+ the state of the stream remains unchanged.
+**/
+size_t fwrite (void * __restrict Buffer,
+ size_t Size,
+ size_t Num,
+ FILE * __restrict Stream
+ );
+
+/* ################ File Positioning Functions. */
+
+/** Get a stream's position and parse state.
+
+ The fgetpos function stores the current values of the parse state (if any)
+ and file position indicator for the stream pointed to by Stream in the
+ object pointed to by Pos. The values stored contain unspecified
+ information usable by the fsetpos function for repositioning the stream
+ to its position at the time of the call to the fgetpos function.
+
+ @param[in] Stream Stream to get current position of.
+ @param[out] Pos Object to receive the stream's state and position information.
+
+ @return If successful, the fgetpos function returns zero; if either
+ parameter is NULL, the fgetpos function returns nonzero and
+ stores EINVAL in errno.
+**/
+int fgetpos (FILE * __restrict Stream, fpos_t * __restrict Pos);
+
+/** Set the file position for a stream.
+
+ The fseek function sets the file position indicator for the stream pointed
+ to by Stream. If a read or write error occurs, the error indicator for the
+ stream is set and fseek fails.
+
+ For a binary stream, the new position, measured in characters from the
+ beginning of the file, is obtained by adding Offset to the position
+ specified by Whence. The specified position is the beginning of the file if
+ Whence is SEEK_SET, the current value of the file position indicator if
+ SEEK_CUR, or end-of-file if SEEK_END.
+
+ For a text stream, Offset must either be zero or a value returned by an
+ earlier successful call to the ftell function, on a stream associated with
+ the same file, and Whence must be SEEK_SET.
+
+ After determining the new position, a successful call to the fseek function
+ undoes any effects of the ungetc function on the stream, clears the
+ end-of-file indicator for the stream, and then establishes the new position.
+ After a successful fseek call, the next operation on an update stream may
+ be either input or output.
+
+ @param[in] Stream The I/O stream to set the position of.
+ @param[in] Offset The position, interpreted depending upon the value of
+ Whence, that the stream is to be positioned to.
+ @param[in] Whence A value indicating how Offset is to be interpreted:
+ - SEEK_SET indicates Offset is an absolute position.
+ - SEEK_END indicates Offset is relative to the end of the file.
+ - SEEK_CUR indicates Offset is relative to the current position.
+
+@return The fseek function returns nonzero only for a request that cannot be satisfied.
+**/
+int fseek (FILE *Stream, long Offset, int Whence);
+
+/** Set a stream's position and parse state.
+
+ The fsetpos function sets the mbstate_t object (if any) and file position
+ indicator for the stream pointed to by Stream according to the value of the
+ object pointed to by Pos, which is a value that was obtained from an
+ earlier successful call to the fgetpos function on a stream associated with
+ the same file. If a read or write error occurs, the error indicator for the
+ stream is set and fsetpos fails.
+
+ A successful call to the fsetpos function undoes any effects of the ungetc
+ function on the stream, clears the end-of-file indicator for the stream,
+ and then establishes the new parse state and position. After a successful
+ fsetpos call, the next operation on an update stream may be either input or output.
+
+ @param[in] Stream Stream to set current position of.
+ @param[in] Pos Object containing the state and position information.
+
+ @return If successful, the fsetpos function returns zero; on failure, the
+ fsetpos function returns nonzero and stores EINVAL, or ESPIPE,
+ in errno; depending upon whether the error was because of an invalid
+ parameter, or because Stream is not seekable.
+**/
+int fsetpos (FILE *Stream, const fpos_t *Pos);
+
+/** Get Stream's current position.
+
+ The ftell function obtains the current value of the file position indicator
+ for the stream pointed to by Stream. For a binary stream, the value is the
+ number of characters from the beginning of the file. For a text stream, its
+ file position indicator contains unspecified information, usable by the
+ fseek function for returning the file position indicator for the stream to
+ its position at the time of the ftell call; the difference between two such
+ return values is not necessarily a meaningful measure of the number of
+ characters written or read.
+
+ @param[in] Stream Pointer to the FILE object to get the current position of.
+
+ @return If successful, the ftell function returns the current value of
+ the file position indicator for the stream. On failure, the
+ ftell function returns -1L and stores ESPIPE in errno indicating
+ that the stream is not seekable.
+**/
+long ftell (FILE *Stream);
+
+/** Restore a Stream's file position to the beginning of the file.
+
+ The rewind function sets the file position indicator for the stream pointed
+ to by Stream to the beginning of the file and clears the stream's error indicator.
+
+ @param[in] Stream Pointer to the stream to be positioned to its beginning.
+**/
+void rewind (FILE *Stream);
+
+/* ################ Error-handling Functions. */
+
+/** Clear a Stream's error and end-of-file indicators.
+
+ @param[in] Stream Pointer to the stream to be cleared of errors.
+**/
+void clearerr(FILE *Stream);
+
+/** Test the end-of-file indicator for Stream.
+
+ @param[in] Stream Pointer to the FILE object to be tested for EOF.
+
+ @return The feof function returns non-zero if, and only if, the end-of-file
+ indicator is set for Stream.
+**/
+int feof (FILE *Stream);
+
+/** Test the error indicator for Stream.
+
+ @param[in] Stream Pointer to the stream to be tested for error.
+
+ @return The ferror function returns non-zero if, and only if, the error
+ indicator is set for Stream.
+**/
+int ferror (FILE *Stream);
+
+/** Print an error message to stderr based upon the value of errno and String.
+
+ The perror function maps the error number in the integer expression errno
+ to an error message. It writes a sequence of characters to the standard
+ error stream thus: first (if String is not a null pointer and the character
+ pointed to by String is not the null character), the string pointed to by
+ String followed by a colon (:) and a space; then an appropriate error
+ message string followed by a new-line character. The contents of the error
+ message strings are the same as those returned by the strerror function
+ with argument errno.
+
+ @param[in] String A text string to prefix the output error message with.
+
+ @sa strerror in <string.h>
+**/
+void perror (const char *String);
+
__END_DECLS
/*
* IEEE Std 1003.1-90
*/
-#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
- defined(_NETBSD_SOURCE)
- #define L_ctermid 1024 /* size for ctermid(); PATH_MAX */
- #define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */
-
- __BEGIN_DECLS
- char *ctermid(char *);
- #ifndef __CUSERID_DECLARED
- #define __CUSERID_DECLARED
- /* also declared in unistd.h */
- char *cuserid(char *);
- #endif /* __CUSERID_DECLARED */
- FILE *fdopen(int, const char *);
- int fileno(FILE *);
- __END_DECLS
-#endif /* not ANSI */
+__BEGIN_DECLS
+FILE *fdopen(int, const char *);
+__END_DECLS
/*
* IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2
*/
-#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
- defined(_REENTRANT) || defined(_NETBSD_SOURCE)
- __BEGIN_DECLS
- void flockfile (FILE *);
- int ftrylockfile (FILE *);
- void funlockfile (FILE *);
- int getc_unlocked (FILE *);
- int getchar_unlocked(void);
- int putc_unlocked (int, FILE *);
- int putchar_unlocked(int);
- __END_DECLS
-#endif /* _POSIX_C_SOURCE >= 1995056 || _XOPEN_SOURCE >= 500 || ... */
+__BEGIN_DECLS
+void flockfile (FILE *);
+int ftrylockfile (FILE *);
+void funlockfile (FILE *);
+int getc_unlocked (FILE *);
+int getchar_unlocked(void);
+int putc_unlocked (int, FILE *);
+int putchar_unlocked(int);
+__END_DECLS
/*
* Functions defined in POSIX 1003.2 and XPG2 or later.
@@ -550,8 +1491,8 @@ __END_DECLS
* Functions defined in XPG4.2.
*/
__BEGIN_DECLS
- int getw(FILE *);
- int putw(int, FILE *);
+ //int getw(FILE *);
+ //int putw(int, FILE *);
char *mkdtemp(char *);
int mkstemp(char *);
char *mktemp(char *);
@@ -568,18 +1509,18 @@ __END_DECLS
#endif /* off_t */
__BEGIN_DECLS
-int fseeko(FILE *, off_t, int);
-off_t ftello(FILE *);
+int fseeko(FILE *, off_t, int);
+//off_t ftello(FILE *);
__END_DECLS
/*
* Routines that are purely local.
*/
-#define FPARSELN_UNESCESC 0x01
+#define FPARSELN_UNESCESC 0x01
#define FPARSELN_UNESCCONT 0x02
#define FPARSELN_UNESCCOMM 0x04
#define FPARSELN_UNESCREST 0x08
-#define FPARSELN_UNESCALL 0x0f
+#define FPARSELN_UNESCALL 0x0f
__BEGIN_DECLS
//int asprintf(char ** __restrict, const char * __restrict, ...)
@@ -594,14 +1535,14 @@ __BEGIN_DECLS
__attribute__((__format__(__printf__, 2, 0)));
int vscanf(const char * __restrict, va_list)
__attribute__((__format__(__scanf__, 1, 0)));
- int vfscanf(FILE * __restrict, const char * __restrict,
- va_list)
- __attribute__((__format__(__scanf__, 2, 0)));
+ //int vfscanf(FILE * __restrict, const char * __restrict,
+ // va_list)
+ // __attribute__((__format__(__scanf__, 2, 0)));
int vsscanf(const char * __restrict, const char * __restrict,
va_list)
__attribute__((__format__(__scanf__, 2, 0)));
- const char *fmtcheck(const char *, const char *)
- __attribute__((__format_arg__(2)));
+ //const char *fmtcheck(const char *, const char *)
+ // __attribute__((__format_arg__(2)));
__END_DECLS
/*
diff --git a/StdLib/Include/sys/signal.h b/StdLib/Include/sys/signal.h
index 6f21fcd..e93b2ab 100644
--- a/StdLib/Include/sys/signal.h
+++ b/StdLib/Include/sys/signal.h
@@ -1,19 +1,30 @@
-/**
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
+/** @file
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ Implementation and Platform specific portion of <signal.h>.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _SYS_SIGNAL_H
#define _SYS_SIGNAL_H
#include <sys/EfiCdefs.h>
#include <machine/signal.h>
+/** The actual (default) signal numbers are assigned using an anonymous enum
+ so that the compiler can do the work of assigning values. This helps
+ ensure that the developer should never have to renumber the signals or
+ figure out what number to assign to a new signal.
+
+ Properly constructed programs will NEVER depend upon signal numbers being
+ in a particular order or having a particular value. All that is guaranteed
+ is that each signal number is distinct, positive, and non-zero.
+**/
enum {
__SigInt = 1,
__SigIll,
@@ -36,6 +47,7 @@ enum {
/** The type of a signal handler function. **/
typedef void __sighandler_t(int);
+__BEGIN_DECLS
/** The signal function associates a "signal handler" with a signal number.
For historical reasons; programs expect signal to be declared
@@ -49,8 +61,8 @@ typedef void __sighandler_t(int);
the specified signal sig. Otherwise, a value of SIG_ERR is
returned and a positive value is stored in errno.
*/
-__BEGIN_DECLS
__sighandler_t *signal(int sig, __sighandler_t *func);
+
__END_DECLS
#endif /* _SYS_SIGNAL_H */
diff --git a/StdLib/LibC/Stdio/fgetpos.c b/StdLib/LibC/Stdio/fgetpos.c
index 61d6f75..8dd0fd6 100644
--- a/StdLib/LibC/Stdio/fgetpos.c
+++ b/StdLib/LibC/Stdio/fgetpos.c
@@ -56,7 +56,7 @@ fgetpos(FILE *fp, fpos_t *pos)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(pos != NULL);
- if(fp == NULL) {
+ if((fp == NULL) || (pos == NULL)) {
errno = EINVAL;
return (EOF);
}