limits.mh
来自「开放源码的编译器open watcom 1.6.0版的源代码」· MH 代码 · 共 859 行 · 第 1/3 页
MH
859 行
::
:: This file generates three different headers: limits.h, climits, and
:: limits. The "default" wsplice operation produces limits.h, the header
:: used in the C library. A CNAME wsplice operation produces climits, the
:: C++ partner to C's limits.h. Currently climits and limits.h are ident-
:: ical. A special CPPLIMITS wsplice operation generates C++'s limits
:: header. That header is not directly related to either limits.h or climits;
:: it contains the definition of the numeric_limits template.
:: (Peter Chapin)
::
:segment !CPPLIMITS
/***************************************************************************
* FILE: limits.h/climits (Machine and OS limits)
*
:include crwatqnx.sp
*
* Description: This header is part of the C/C++ standard library. It
* describes implementation limits.
***************************************************************************/
#ifndef _LIMITS_H_INCLUDED
#define _LIMITS_H_INCLUDED
:include readonly.sp
:include mbmax.sp
/*
* ANSI required limits
*/
#define CHAR_BIT 8 /* number of bits in a byte */
#ifdef __CHAR_SIGNED__
#define CHAR_MIN (-128) /* minimum value of a char */
#define CHAR_MAX 127 /* maximum value of a char */
#else
#define CHAR_MIN 0 /* minimum value of a char */
#define CHAR_MAX 255 /* maximum value of a char */
#endif
#define SCHAR_MIN (-128) /* minimum value of a signed char */
#define SCHAR_MAX 127 /* maximum value of a signed char */
#define UCHAR_MAX 255 /* maximum value of an unsigned char */
#define SHRT_MIN (-32767-1) /* minimum value of a short int */
#define SHRT_MAX 32767 /* maximum value of a short int */
#if defined(__386__) || defined(__AXP__) || defined(__PPC__) || defined(__MIPS__)
#define USHRT_MAX 65535 /* maximum value of an unsigned short */
#else
#define USHRT_MAX 65535U /* maximum value of an unsigned short */
#endif
#define LONG_MAX 2147483647L /* maximum value of a long int */
#define LONG_MIN (-2147483647L-1L) /* minimum value of a long int */
#define ULONG_MAX 4294967295UL /* maximum value of an unsigned long*/
#if defined(__386__) || defined(__AXP__) || defined(__PPC__) || defined(__MIPS__)
#define INT_MIN (-2147483647-1) /* minimum value of an int */
#define INT_MAX 2147483647 /* maximum value of an int */
#define UINT_MAX 4294967295U /* maximum value of an unsigned int*/
#else
#define INT_MIN (-32767-1) /* minimum value of an int */
#define INT_MAX 32767 /* maximum value of an int */
#define UINT_MAX 65535U /* maximum value of an unsigned int*/
#endif
#ifdef __WATCOM_INT64__
#define LONGLONG_MIN (-9223372036854775807I64-1I64)
/* minimum value of an __int64 */
#define LONGLONG_MAX 9223372036854775807I64
/* maximum value of an __int64 */
#define ULONGLONG_MAX 18446744073709551615UI64
/* maximum value of an unsigned __int64*/
#define LLONG_MIN (-9223372036854775807LL-1LL) /* for C99 */
#define LLONG_MAX 9223372036854775807LL /* for C99 */
#define ULLONG_MAX 18446744073709551615ULL /* for C99 */
#endif
#define _I8_MIN SCHAR_MIN /* minimum value of a signed 8 bit type */
#define _I8_MAX SCHAR_MAX /* maximum value of a signed 8 bit type */
#define _UI8_MAX 255U /* maximum value of an unsigned 8 bit type*/
#define _I16_MIN SHRT_MIN /* minimum value of a signed 16 bit type */
#define _I16_MAX SHRT_MAX /* maximum value of a signed 16 bit type */
#define _UI16_MAX 65535U /* maximum value of an unsigned 16 bit type*/
#define _I32_MIN LONG_MIN /* minimum value of a signed 32 bit type */
#define _I32_MAX LONG_MAX /* maximum value of a signed 32 bit type */
#define _UI32_MAX ULONG_MAX /* maximum value of an unsigned 32 bit type*/
#ifdef __WATCOM_INT64__
#define _I64_MIN LONGLONG_MIN /* minimum value of a signed 64 bit type */
#define _I64_MAX LONGLONG_MAX /* maximum value of a signed 64 bit type */
#define _UI64_MAX ULONGLONG_MAX /* maximum value of an unsigned 64 bit type*/
#endif
:segment !QNX & !LINUX
#define TZNAME_MAX 128 /* The maximum number of bytes */
/* supported for the name of a time */
/* zone (not of the TZ variable). */
:endsegment
:segment QNX | LINUX
:include unixext.sp
/*
* POSIX required limits.
* These are minimums values, not absolute limits,
* and the real value may be greater.
*/
#define _POSIX_ARG_MAX 4096 /* Length of args for exec */
/* functions including environment data*/
#define _POSIX_CHILD_MAX 6 /* Number of simultaneous */
/* processes per real user ID. */
#define _POSIX_LINK_MAX 8 /* Max. links per file */
#define _POSIX_MAX_CANON 255 /* No. bytes in terminal */
/* cannonical input queue. */
#define _POSIX_MAX_INPUT 255 /* Size of terminal input queue buffer */
#define _POSIX_NAME_MAX 14 /* Max bytes in a filename */
#define _POSIX_NGROUPS_MAX 0 /* Num. simultaneous supplementary */
/* group IDs per process */
#define _POSIX_OPEN_MAX 16 /* Min num. files open per process. */
#define _POSIX_PATH_MAX 255 /* Num. bytes in pathname (excl. NULL) */
#define _POSIX_PIPE_BUF 512 /* Num. bytes written atomically to a */
/* pipe. */
#define _POSIX_SSIZE_MAX 32767 /* The value that can be stored in an */
/* object of type ssize_t. */
#define _POSIX_STREAM_MAX 8 /* The number of streams that one */
/* process can have open at one time. */
#define _POSIX_SYMLOOP_MAX 8 /* The number of loops to traverse */
/* while resolving symbolic links */
/* or prefix aliases. */
#define _POSIX_TZNAME_MAX 3 /* The maximum number of bytes */
/* supported for the name of a time */
/* zone (not of the TZ variable). */
/*
* Run-time increasable values
*
*/
#define NGROUPS_MAX 1 /* Num. simultaneous supplementary */
/* group IDs per process */
/*
* Run-time invariant values (possible indeterminate)
*
* CHILD_MAX and OPEN_MAX are indeterminate.
*/
#define ARG_MAX 61440
#undef CHILD_MAX /* no child max */
#undef OPEN_MAX /* no open max */
#undef STREAM_MAX /* no stream max */
#define TZNAME_MAX 128 /* The maximum number of bytes */
/* supported for the name of a time */
/* zone (not of the TZ variable). */
/*
* Pathname variable values (may vary by pathname)
*/
#define LINK_MAX 65535u
#define MAX_CANON _POSIX_MAX_CANON
#define MAX_INPUT _POSIX_MAX_INPUT
#define NAME_MAX 48
#define PATH_MAX _POSIX_PATH_MAX
#define PIPE_BUF 5120
/*
* Invariant values
*/
#define SSIZE_MAX _POSIX_SSIZE_MAX
#define SYMLOOP_MAX 32 /* This is bigger than _POSIX_SYMLOOP_MAX */
/*
* Posix .2/9 limits.
*/
#define BC_BASE_MAX 99
#define BC_DIM_MAX 2048
#define BC_SCALE_MAX 99
#define COLL_ELEM_MAX 4
#define EXPR_NEST_MAX 32
#define LINE_MAX 2048
#define PASTE_FILES_MAX 12
#define RE_DUP_MAX 255
#define SED_PATTERN_MAX 20480
#define SENDTO_MAX 90000L
#define SORT_LINE_MAX 20480
#endif /* _POSIX_SOURCE || !NO_EXT_KEYS */
:include ext.sp
:segment QNX
#define _QNX_ROOT_PREFIX_MAX 128
#define _QNX_PROXY_SIZE_MAX 100
#define _QNX_MXTAB_LEN 255
#define _QNX_MSGLEN 65500U
#define _QNX_ATTACHEDNAME_MAX 64
#define _QNX_PREFIX_MAX 48
#define _QNX_ERRNOSTR_MAX 64
:endsegment
#endif
:endsegment
#endif
:elsesegment
///////////////////////////////////////////////////////////////////////////
// FILE: limits (Definition of std::numeric_limits)
//
:keep CPP_HDR
:include crwatcnt.sp
//
// Description: This header is part of the C++ standard library. It
// defines the numeric_limits template and provides
// specializations for all the built-in numeric types.
///////////////////////////////////////////////////////////////////////////
#ifndef _LIMITS_INCLUDED
#define _LIMITS_INCLUDED
:include readonly.sp
#ifndef __cplusplus
#error The header limits requires C++
#endif
:: I have mixed feelings about these inclusions. On one hand they allow
:: fixes in the C library to be immediately felt in numeric_limits. On
:: the other hand a C++ programmer using numeric_limits probably won't
:: want the preprocessor name pollution caused by including these headers.
:: (Peter Chapin)
#include <cfloat>
#include <climits>
#include <cstddef>
:: <cstddef> is needed for wchar_t. Once wchar_t is built-in this include
:: can be removed.
namespace std {
enum float_round_style {
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_toward_neg_infinity = 3
};
enum float_denorm_style
{ denorm_present, denorm_absent, denorm_indeterminate };
template< class Type >
class numeric_limits {
public:
static const bool is_specialized = false;
static Type min();
static Type max();
static const int digits = 0;
static const int digits10 = 0;
static const bool is_signed = false;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 0;
static Type epsilon();
static Type round_error();
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static Type infinity();
static Type quiet_NaN();
static Type signaling_NaN();
static Type denorm_min();
static const bool is_iec559 = false;
static const bool is_bounded = false;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
// The required specializations
// template< >
class numeric_limits< bool > {
public:
static const bool is_specialized = true;
static bool min() { return( 0 ); }
static bool max() { return( 1 ); }
static const int digits = 1;
static const int digits10 = 0;
static const bool is_signed = false;
static const bool is_integer = true;
static const bool is_exact = true;
static const int radix = 2;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?