// Rowley C Compiler, runtime support.
//
// Copyright (c) 2001, 2002 Rowley Associates Limited.
//
// This file may be distributed under the terms of the License Agreement
// provided with this software.
//
// THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

#ifndef __errno_h
#define __errno_h


/*! \brief  Domain error \ingroup Error numbers \synopsis

  \desc \b \this - an input argument is outside the defined domain of the mathematical function.
*/
#define EDOM     0x01


/*! \brief  Illegal byte sequence \ingroup Error numbers \synopsis

  \desc \b \this - A wide-character code has been detected that does not correspond to a valid character, 
  or a byte sequence does not form a valid wide-character code.
*/
#define EILSEQ   0x02


/*! \brief Result too large or too small \ingroup Error numbers \synopsis

  \desc \b \this - the result of the function is too large (overflow) or too small (underflow) to be represented 
  in the available space.
*/
#define ERANGE   0x03


#define EHEAP    0x04

/*! \brief User-defined behavior for the errno macro \ingroup Functions \synopsis

 \desc There is no default implementation of \b \this. Keeping \b \this 
  out of the library means that you can can customize its behavior without rebuilding 
  the library.  A default implementation could be

  \code static int errno; \endcode
  \code int *_errno(void) { return &errno; } \endcode
*/
int *__errno(void);


/*! \brief Allows you to access the errno implementation \ingroup Macros \synopsis

  \desc \b \this macro expands to a function call to \b __errno
  that returns a pointer to an \b int. This function can be implemented by the application to provide
  a thread specific errno. 

  The value of \b \this is zero at program startup, but is never set to 
  zero by any library function. The value of \b \this may be set to a nonzero 
  value by a library function, and this effect is documented in each function that 
  does so.

  \note The ISO standard does not specify whether \b \this is a macro or an identifier 
  declared with external linkage. Portable programs must not make assumptions 
  about the implementation of \b \this.
*/
#define errno (*__errno())


#endif