/* errno.h: ANSI 'C' (X3J11 Oct 88) library header, section 4.1.3 */
/* Copyright (C) Codemist Ltd., 1988                            */
/* Copyright 1991 ARM Limited. All rights reserved.             */
/* version 1 */

/*
 * RCS $Revision: 102466 $
 * Checkin $Date: 2006-08-23 11:37:17 +0100 (Wed, 23 Aug 2006) $
 * Revising $Author: drodgman $
 */

#ifndef __errno_h
#define __errno_h

#define _ARMABI_PURE __declspec(__nothrow) __pure

  #ifndef __ERRNO_DECLS
  #define __ERRNO_DECLS

    #undef __CLIBNS

    #ifdef __cplusplus
        namespace std {
        #define __CLIBNS std::
        extern "C" {
    #else
      #define __CLIBNS
    #endif  /* __cplusplus */


extern _ARMABI_PURE volatile int *__aeabi_errno_addr(void);


    #ifdef __cplusplus
         }  /* extern "C" */
      }  /* namespace std */
    #endif /* __cplusplus */
  #endif /* __ERRNO_DECLS */

  #ifdef __cplusplus
    #ifndef __ERRNO_NO_EXPORTS
      using std::__aeabi_errno_addr;
    #endif /* __ERRNO_NO_EXPORTS */
  #endif /* __cplusplus */

#define errno (*__CLIBNS __aeabi_errno_addr())

/*
 * Error numbers defined in the C standard need the ABI portability
 * mechanism.
 */
#if _AEABI_PORTABILITY_LEVEL != 0 && !defined _AEABI_PORTABLE
  #define _AEABI_PORTABLE
#endif

#if _AEABI_PORTABILITY_LEVEL != 0 || (!defined _AEABI_PORTABILITY_LEVEL && __DEFAULT_AEABI_PORTABILITY_LEVEL != 0)
extern const int __aeabi_EDOM;
extern const int __aeabi_ERANGE;
extern const int __aeabi_EILSEQ;
#define EDOM (__aeabi_EDOM)
#define ERANGE (__aeabi_ERANGE)
#define EILSEQ (__aeabi_EILSEQ)
#else

/*
 * expands to a modifiable lvalue that has type volatile int, the value of
 * which is set to a positive error code by several library functions. It is
 * initialised to zero at program startup, but is never set to zero by any
 * library function. The value of errno may be set to nonzero by a library
 * function call whether or not there is an error, provided the use of errno
 * is not documented in the description of the function in the Standard.
 */

#define EDOM    1
/*
 * if a domain error occurs (an input argument is outside the
 * domain over which the mathematical function is defined) the
 * integer expression errno acquires the value of the macro EDOM
 * and HUGE_VAL is returned. EDOM may be used by non-mathematical
 * functions.
 */
#define ERANGE 2
/*
 * ESIGNUM is generated by signal() if the user attempts to change
 * the handling of a nonexistent signal. ESIGNUM is not part of the
 * ANSI C standard.
 */
#define EILSEQ  4
/*
 * EILSEQ is generated by multi-byte character processing routines
 * (mbrtowc et al; _not_ by the non-restartable mbtowc series).
 *
 * EILSEQ is not mentioned in the C89 standard itself, but in
 * Normative Addendum 1 and C99.
 */
#endif

/*
 * a range error occurs if the result of a function can not be
 * represented as a double value. If the result overflows (the
 * magnitude of the result is so large that it cannot be
 * represented in an object of the specified type), the function
 * returns the value of the macro HUGE_VAL, with the same sign as
 * the correct value of the function; the integer expression errno
 * acquires the value of the macro ERANGE. If the result underflows
 * (the magnitude of the result is so small that it cannot be
 * represented in an object of the specified type), the function
 * returns zero; the integer expression errno acquires the value of
 * the macro ERANGE. ERANGE may be used by non-mathematical
 * functions.
 */
#define ESIGNUM 3

#endif

/* end of errno.h */
