summary refs log tree commit diff stats
path: root/tinyc/win32/include/limits.h
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-11-02 10:46:30 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-11-02 10:46:30 +0100
commit1eaeccc15d15d15d2f62ea1648f7dd64722dbd37 (patch)
treeb922cdabc780fa3a8837a6804d2df31793d9e2ca /tinyc/win32/include/limits.h
parente9243a16167b24899d4fcf051f3252b3a5804811 (diff)
parentbd19b5f4d36bb40b4af93d7e15fdfa582e9fe3b7 (diff)
downloadNim-1eaeccc15d15d15d2f62ea1648f7dd64722dbd37.tar.gz
Merge branch 'devel' into araq
Diffstat (limited to 'tinyc/win32/include/limits.h')
-rw-r--r--tinyc/win32/include/limits.h200
1 files changed, 98 insertions, 102 deletions
diff --git a/tinyc/win32/include/limits.h b/tinyc/win32/include/limits.h
index 5dc6025fd..fafb04a46 100644
--- a/tinyc/win32/include/limits.h
+++ b/tinyc/win32/include/limits.h
@@ -1,115 +1,111 @@
-/* 
- * limits.h
- *
- * Defines constants for the sizes of integral types.
- *
- * NOTE: GCC should supply a version of this header and it should be safe to
- *       use that version instead of this one (maybe safer).
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *
- *  THIS SOFTWARE IS NOT COPYRIGHTED
- *
- *  This source code is offered for use in the public domain. You may
- *  use, modify or distribute it freely.
- *
- *  This code is distributed in the hope that it will be useful but
- *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- *  DISCLAIMED. This includes but is not limited to warranties of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.2 $
- * $Author: bellard $
- * $Date: 2005/04/17 13:14:29 $
- *
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within this package.
  */
-
-#ifndef _LIMITS_H_
-#define _LIMITS_H_
-
-/* All the headers include this file. */
 #include <_mingw.h>
 
-/*
- * File system limits
- *
- * TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the
- *       same as FILENAME_MAX and FOPEN_MAX from stdio.h?
- * NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
- *       required for the NUL. TODO: Test?
- */
-#define PATH_MAX	(259)
+#ifndef _INC_LIMITS
+#define _INC_LIMITS
 
 /*
- * Characteristics of the char data type.
- *
- * TODO: Is MB_LEN_MAX correct?
- */
-#define CHAR_BIT	8
-#define MB_LEN_MAX	2
-
-#define SCHAR_MIN	(-128)
-#define SCHAR_MAX	127
-
-#define UCHAR_MAX	255
+* File system limits
+*
+* TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the
+*       same as FILENAME_MAX and FOPEN_MAX from stdio.h?
+* NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
+*       required for the NUL. TODO: Test?
+*/
+#define PATH_MAX	(259)
 
-/* TODO: Is this safe? I think it might just be testing the preprocessor,
- *       not the compiler itself... */
-#if	('\x80' < 0)
-#define CHAR_MIN	SCHAR_MIN
-#define CHAR_MAX	SCHAR_MAX
-#else
-#define CHAR_MIN	0
-#define CHAR_MAX	UCHAR_MAX
+#define CHAR_BIT 8
+#define SCHAR_MIN (-128)
+#define SCHAR_MAX 127
+#define UCHAR_MAX 0xff
+
+#define CHAR_MIN SCHAR_MIN
+#define CHAR_MAX SCHAR_MAX
+
+#define MB_LEN_MAX 5
+#define SHRT_MIN (-32768)
+#define SHRT_MAX 32767
+#define USHRT_MAX 0xffff
+#define INT_MIN (-2147483647 - 1)
+#define INT_MAX 2147483647
+#define UINT_MAX 0xffffffff
+#define LONG_MIN (-2147483647L - 1)
+#define LONG_MAX 2147483647L
+#define ULONG_MAX 0xffffffffUL
+#define LLONG_MAX 9223372036854775807ll
+#define LLONG_MIN (-9223372036854775807ll - 1)
+#define ULLONG_MAX 0xffffffffffffffffull
+
+#if _INTEGRAL_MAX_BITS >= 8
+#define _I8_MIN (-127 - 1)
+#define _I8_MAX 127i8
+#define _UI8_MAX 0xffu
 #endif
 
-/*
- * Maximum and minimum values for ints.
- */
-#define INT_MAX		2147483647
-#define INT_MIN		(-INT_MAX-1)
-
-#define UINT_MAX	0xffffffff
-
-/*
- * Maximum and minimum values for shorts.
- */
-#define SHRT_MAX	32767
-#define SHRT_MIN	(-SHRT_MAX-1)
-
-#define USHRT_MAX	0xffff
-
-/*
- * Maximum and minimum values for longs and unsigned longs.
- *
- * TODO: This is not correct for Alphas, which have 64 bit longs.
- */
-#define LONG_MAX	2147483647L
-
-#define LONG_MIN	(-LONG_MAX-1)
-
-#define ULONG_MAX	0xffffffffUL
-
-
-/*
- * The GNU C compiler also allows 'long long int'
- */
-#if	!defined(__STRICT_ANSI__) && defined(__GNUC__)
-
-#define LONG_LONG_MAX	9223372036854775807LL
-#define LONG_LONG_MIN	(-LONG_LONG_MAX-1)
+#if _INTEGRAL_MAX_BITS >= 16
+#define _I16_MIN (-32767 - 1)
+#define _I16_MAX 32767i16
+#define _UI16_MAX 0xffffu
+#endif
 
-#define ULONG_LONG_MAX	(2ULL * LONG_LONG_MAX + 1)
+#if _INTEGRAL_MAX_BITS >= 32
+#define _I32_MIN (-2147483647 - 1)
+#define _I32_MAX 2147483647
+#define _UI32_MAX 0xffffffffu
+#endif
 
-/* ISO C9x macro names */
-#define LLONG_MAX LONG_LONG_MAX
-#define LLONG_MIN LONG_LONG_MIN
-#define ULLONG_MAX ULONG_LONG_MAX
+#if defined(__GNUC__)
+#undef LONG_LONG_MAX
+#define LONG_LONG_MAX 9223372036854775807ll
+#undef LONG_LONG_MIN
+#define LONG_LONG_MIN (-LONG_LONG_MAX-1)
+#undef ULONG_LONG_MAX
+#define ULONG_LONG_MAX (2ull * LONG_LONG_MAX + 1ull)
+#endif
 
-#endif /* Not Strict ANSI and GNU C compiler */
+#if _INTEGRAL_MAX_BITS >= 64
+#define _I64_MIN (-9223372036854775807ll - 1)
+#define _I64_MAX 9223372036854775807ll
+#define _UI64_MAX 0xffffffffffffffffull
+#endif
 
+#ifndef SIZE_MAX
+#ifdef _WIN64
+#define SIZE_MAX _UI64_MAX
+#else
+#define SIZE_MAX UINT_MAX
+#endif
+#endif
 
-#endif /* not _LIMITS_H_ */
+#ifdef _POSIX_
+#define _POSIX_ARG_MAX 4096
+#define _POSIX_CHILD_MAX 6
+#define _POSIX_LINK_MAX 8
+#define _POSIX_MAX_CANON 255
+#define _POSIX_MAX_INPUT 255
+#define _POSIX_NAME_MAX 14
+#define _POSIX_NGROUPS_MAX 0
+#define _POSIX_OPEN_MAX 16
+#define _POSIX_PATH_MAX 255
+#define _POSIX_PIPE_BUF 512
+#define _POSIX_SSIZE_MAX 32767
+#define _POSIX_STREAM_MAX 8
+#define _POSIX_TZNAME_MAX 3
+#define ARG_MAX 14500
+#define LINK_MAX 1024
+#define MAX_CANON _POSIX_MAX_CANON
+#define MAX_INPUT _POSIX_MAX_INPUT
+#define NAME_MAX 255
+#define NGROUPS_MAX 16
+#define OPEN_MAX 32
+#define PATH_MAX 512
+#define PIPE_BUF _POSIX_PIPE_BUF
+#define SSIZE_MAX _POSIX_SSIZE_MAX
+#define STREAM_MAX 20
+#define TZNAME_MAX 10
+#endif
+#endif