am c5eea6d3
: Merge "Fix WCHAR_MAX, WCHAR_MIN, WINT_MAX, and WINT_MIN."
* commit 'c5eea6d386c23bde6f0400a8959ed21081d8365b': Fix WCHAR_MAX, WCHAR_MIN, WINT_MAX, and WINT_MIN.
This commit is contained in:
commit
607475b857
42
libc/include/machine/wchar_limits.h
Normal file
42
libc/include/machine/wchar_limits.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_WCHAR_LIMITS_H_
|
||||
#define _MACHINE_WCHAR_LIMITS_H_
|
||||
|
||||
/* Both GCC and clang define __WCHAR_MAX__. */
|
||||
#define WCHAR_MAX __WCHAR_MAX__
|
||||
|
||||
/* As of 3.4, clang still doesn't define __WCHAR_MIN__. */
|
||||
#if defined(__WCHAR_UNSIGNED__)
|
||||
# define WCHAR_MIN L'\0'
|
||||
#else
|
||||
# define WCHAR_MIN (-(WCHAR_MAX) - 1)
|
||||
#endif
|
||||
|
||||
#endif /* _MACHINE_WCHAR_LIMITS_H_ */
|
@ -30,6 +30,7 @@
|
||||
#define _STDINT_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <machine/wchar_limits.h>
|
||||
|
||||
typedef __signed char __int8_t;
|
||||
typedef unsigned char __uint8_t;
|
||||
@ -86,7 +87,7 @@ typedef uint8_t uint_fast8_t;
|
||||
typedef int64_t int_fast64_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
#ifdef __LP64__
|
||||
#if defined(__LP64__)
|
||||
typedef int64_t int_fast16_t;
|
||||
typedef uint64_t uint_fast16_t;
|
||||
typedef int64_t int_fast32_t;
|
||||
@ -135,7 +136,7 @@ typedef int64_t intmax_t;
|
||||
#define INTMAX_C(c) INT64_C(c)
|
||||
#define UINTMAX_C(c) UINT64_C(c)
|
||||
|
||||
#ifdef __LP64__
|
||||
#if defined(__LP64__)
|
||||
# define INT64_C(c) c ## L
|
||||
# define UINT64_C(c) c ## UL
|
||||
# define INTPTR_C(c) INT64_C(c)
|
||||
@ -200,15 +201,15 @@ typedef int64_t intmax_t;
|
||||
#define SIG_ATOMIC_MAX INT32_MAX
|
||||
#define SIG_ATOMIC_MIN INT32_MIN
|
||||
|
||||
#ifndef WCHAR_MAX /* These might also have been defined by <wchar.h>. */
|
||||
# define WCHAR_MAX INT32_MAX
|
||||
# define WCHAR_MIN INT32_MIN
|
||||
#if defined(__WINT_UNSIGNED__)
|
||||
# define WINT_MAX UINT32_MAX
|
||||
# define WINT_MIN UINT32_MIN
|
||||
#else
|
||||
# define WINT_MAX INT32_MAX
|
||||
# define WINT_MIN INT32_MIN
|
||||
#endif
|
||||
|
||||
#define WINT_MAX INT32_MAX
|
||||
#define WINT_MIN INT32_MIN
|
||||
|
||||
#ifdef __LP64__
|
||||
#if defined(__LP64__)
|
||||
# define INTPTR_MIN INT64_MIN
|
||||
# define INTPTR_MAX INT64_MAX
|
||||
# define UINTPTR_MAX UINT64_MAX
|
||||
|
@ -34,7 +34,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <time.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include <machine/wchar_limits.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
@ -58,11 +59,6 @@ typedef enum {
|
||||
WC_TYPE_MAX
|
||||
} wctype_t;
|
||||
|
||||
#ifndef WCHAR_MAX
|
||||
#define WCHAR_MAX INT_MAX
|
||||
#define WCHAR_MIN INT_MIN
|
||||
#endif
|
||||
|
||||
#define WEOF ((wint_t)(-1))
|
||||
|
||||
extern wint_t btowc(int);
|
||||
|
@ -155,3 +155,7 @@ TEST(wchar, wcstombs_wcrtombs) {
|
||||
bytes[3] = 0;
|
||||
EXPECT_STREQ("hix", bytes);
|
||||
}
|
||||
|
||||
TEST(wchar, limits) {
|
||||
ASSERT_LT(WCHAR_MIN, WCHAR_MAX);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user