arch: Customize the typedef of size_t instead of intptr_t

To ensure size_t same as toolchain definition in the first place and rename CXX_NEWLONG to ARCH_SIZET_LONG.  The change also check whether __SIZE_TYPE__ exist before CONFIG_ARCH_SIZET_LONG so our definition can align with toolchain(gcc/clang) definition automatically.
This commit is contained in:
Xiang Xiao
2020-02-17 20:19:25 +08:00
committed by Gregory Nutt
parent e7d44ee16e
commit e7d9260014
46 changed files with 413 additions and 136 deletions
+6 -5
View File
@@ -1164,11 +1164,12 @@ o C++ Support
that size_t is of a different type resulting in compilation errors that size_t is of a different type resulting in compilation errors
in the operator. Using the underlying integer type Instead of in the operator. Using the underlying integer type Instead of
size_t seems to resolve the compilation issues. size_t seems to resolve the compilation issues.
Status: Kind of open. There is a workaround. Setting CONFIG_CXX_NEWLONG=y Status: Kind of open. There is a workaround. Setting CONFIG_ARCH_SIZET_LONG
will define the operators with argument of type unsigned long; =y will define the operators with argument of type unsigned long;
Setting CONFIG_CXX_NEWLONG=n will define the operators with argument Setting CONFIG_ARCH_SIZET_LONG=n will define the operators with
of type unsigned int. But this is pretty ugly! A better solution argument of type unsigned int. But this is pretty ugly! A better
would be to get a hold of the compilers definition of size_t. solution would be to get a hold of the compilers definition of
size_t.
Priority: Low. Priority: Low.
Title: STATIC CONSTRUCTORS AND MULTITASKING Title: STATIC CONSTRUCTORS AND MULTITASKING
+8
View File
@@ -156,6 +156,14 @@ config ARCH_GNU_NO_WEAKFUNCTIONS
---help--- ---help---
Disable support for weak functions. Disable support for weak functions.
config ARCH_SIZET_LONG
bool "size_t is type long"
default n
---help---
size_t may be type long or type int. This matters for some
C++ library routines because the NuttX size_t might not have
the same underlying type as your toolchain's size_t.
comment "Architecture Options" comment "Architecture Options"
config ARCH_NOINTC config ARCH_NOINTC
+18 -3
View File
@@ -78,10 +78,25 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save(). For /* This is the size of the interrupt state save returned by up_irq_save(). For
* ARM, a 32 register value is returned, for the thumb2, Cortex-M3, the 16-bit * ARM, a 32 register value is returned, for the thumb2, Cortex-M3, the 16-bit
+15 -3
View File
@@ -76,10 +76,22 @@ typedef signed long long _int64_t; /* long long is 64-bits */
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A (near) pointer is 2 bytes */ /* A (near) size is 2 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* A FAR pointer is 4 bytes */ /* A FAR pointer is 4 bytes */
+18 -3
View File
@@ -76,10 +76,25 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save(). */ /* This is the size of the interrupt state save returned by up_irq_save(). */
+15 -3
View File
@@ -85,10 +85,22 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is two bytes */ /* A size is two bytes */
typedef signed short _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned short _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#else
typedef signed short _ssize_t;
typedef unsigned short _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save()*/ /* This is the size of the interrupt state save returned by up_irq_save()*/
+15 -3
View File
@@ -86,10 +86,22 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is two bytes */ /* A size is two bytes */
typedef signed short _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned short _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#else
typedef signed short _ssize_t;
typedef unsigned short _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save()*/ /* This is the size of the interrupt state save returned by up_irq_save()*/
+18 -3
View File
@@ -76,10 +76,25 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save(). */ /* This is the size of the interrupt state save returned by up_irq_save(). */
+18 -3
View File
@@ -76,10 +76,25 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save(). */ /* This is the size of the interrupt state save returned by up_irq_save(). */
+18 -3
View File
@@ -79,10 +79,25 @@ typedef unsigned long long _uint64_t;
#define __INT64_DEFINED 1 #define __INT64_DEFINED 1
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save(). */ /* This is the size of the interrupt state save returned by up_irq_save(). */
+15 -3
View File
@@ -78,10 +78,22 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 2 bytes */ /* A size is 2 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by /* This is the size of the interrupt state save returned by
* up_irq_save() * up_irq_save()
+18 -3
View File
@@ -76,10 +76,25 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by /* This is the size of the interrupt state save returned by
* up_irq_save() * up_irq_save()
+18 -3
View File
@@ -76,10 +76,25 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by /* This is the size of the interrupt state save returned by
* up_irq_save() * up_irq_save()
+33 -6
View File
@@ -77,19 +77,46 @@ typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
#ifdef __LP64__ #ifdef __LP64__
/* A pointer is 8 bytes */ /* A size is 8 bytes */
typedef signed long _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned long _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#else
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#endif
/* This is the size of the interrupt state save returned by irqsave(). */ /* This is the size of the interrupt state save returned by irqsave(). */
typedef unsigned long long irqstate_t; typedef unsigned long long irqstate_t;
#else #else
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by irqsave(). */ /* This is the size of the interrupt state save returned by irqsave(). */
+34 -6
View File
@@ -77,16 +77,44 @@ typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
#if defined(CONFIG_HOST_X86_64) && !defined(CONFIG_SIM_M32) #if defined(CONFIG_HOST_X86_64) && !defined(CONFIG_SIM_M32)
/* 64-bit build on 64-bit machine: A pointer is 8 bytes */ /* 64-bit build on 64-bit machine: A size is 8 bytes */
typedef signed long long _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned long long _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#else
typedef signed long long _ssize_t;
typedef unsigned long long _size_t;
#endif
#else #else
/* 32-bit build on 32- or 64-bit machine: A pointer is 4 bytes */ /* 32-bit build on 32- or 64-bit machine: A size is 4 bytes */
#if defined(__SIZE_TYPE__)
/* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
typedef signed int _intptr_t;
typedef unsigned int _uintptr_t;
#endif #endif
/* This is the size of the interrupt state save returned by /* This is the size of the interrupt state save returned by
+18 -3
View File
@@ -77,10 +77,25 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by /* This is the size of the interrupt state save returned by
* up_irq_save() * up_irq_save()
+18 -3
View File
@@ -76,10 +76,25 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed long _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned long _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save(). */ /* This is the size of the interrupt state save returned by up_irq_save(). */
+18 -3
View File
@@ -72,10 +72,25 @@ typedef unsigned short _uint16_t;
typedef signed int _int32_t; typedef signed int _int32_t;
typedef unsigned int _uint32_t; typedef unsigned int _uint32_t;
/* A pointer is 4 bytes */ /* A size is 4 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_ARCH_SIZET_LONG)
typedef signed long _ssize_t;
typedef unsigned long _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by /* This is the size of the interrupt state save returned by
* up_irq_save() * up_irq_save()
+15 -5
View File
@@ -91,12 +91,22 @@ typedef unsigned long _uint32_t;
* ADL mode - 24 bits * ADL mode - 24 bits
*/ */
#ifdef CONFIG_EZ80_Z80MODE #if defined(__SIZE_TYPE__)
typedef signed short _intptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
typedef unsigned short _uintptr_t; * We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#elif defined(CONFIG_EZ80_Z80MODE)
typedef signed short _ssize_t;
typedef unsigned short _size_t;
#else #else
typedef signed int _intptr_t; typedef signed int _ssize_t;
typedef unsigned int _uintptr_t; typedef unsigned int _size_t;
#endif #endif
/* This is the size of the interrupt state save returned by up_irq_save(). /* This is the size of the interrupt state save returned by up_irq_save().
+15 -3
View File
@@ -84,10 +84,22 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 2 bytes */ /* A size is 2 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save() */ /* This is the size of the interrupt state save returned by up_irq_save() */
+15 -3
View File
@@ -87,10 +87,22 @@ typedef unsigned int _uint16_t;
typedef signed long _int32_t; typedef signed long _int32_t;
typedef unsigned long _uint32_t; typedef unsigned long _uint32_t;
/* A pointer is 2 bytes */ /* A size is 2 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save() */ /* This is the size of the interrupt state save returned by up_irq_save() */
+15 -3
View File
@@ -84,10 +84,22 @@ typedef signed long long _int64_t;
typedef unsigned long long _uint64_t; typedef unsigned long long _uint64_t;
#define __INT64_DEFINED #define __INT64_DEFINED
/* A pointer is 2 bytes */ /* A size is 2 bytes */
typedef signed int _intptr_t; #if defined(__SIZE_TYPE__)
typedef unsigned int _uintptr_t; /* If __SIZE_TYPE__ is defined we define ssize_t based on size_t.
* We simply change "unsigned" to "signed" for this single definition
* to make sure ssize_t and size_t only differ by their signedness.
*/
#define unsigned signed
typedef __SIZE_TYPE__ _ssize_t;
#undef unsigned
typedef __SIZE_TYPE__ _size_t;
#else
typedef signed int _ssize_t;
typedef unsigned int _size_t;
#endif
/* This is the size of the interrupt state save returned by up_irq_save() */ /* This is the size of the interrupt state save returned by up_irq_save() */
@@ -48,7 +48,6 @@ CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=6965 CONFIG_BOARD_LOOPSPERMSEC=6965
CONFIG_BOOT_RUNFROMISRAM=y CONFIG_BOOT_RUNFROMISRAM=y
CONFIG_BUILTIN=y CONFIG_BUILTIN=y
CONFIG_CXX_NEWLONG=y
CONFIG_DEFAULT_SMALL=y CONFIG_DEFAULT_SMALL=y
CONFIG_FS_BINFS=y CONFIG_FS_BINFS=y
CONFIG_FS_ROMFS=y CONFIG_FS_ROMFS=y
+1 -1
View File
@@ -261,7 +261,7 @@ Configurations
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows
Library Routines -> Library Routines ->
CONFIG_CXX_NEWLONG=n : size_t is an unsigned int, not long CONFIG_ARCH_SIZET_LONG=n : size_t is an unsigned int, not long
This re-configuration should be done before making NuttX or else the This re-configuration should be done before making NuttX or else the
subsequent 'make' will fail. If you have already attempted building subsequent 'make' will fail. If you have already attempted building
@@ -27,7 +27,6 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_OABI_TOOLCHAIN=y CONFIG_ARMV7M_OABI_TOOLCHAIN=y
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=8720 CONFIG_BOARD_LOOPSPERMSEC=8720
CONFIG_CXX_NEWLONG=y
CONFIG_HAVE_CXX=y CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INPUT=y CONFIG_INPUT=y
+1 -1
View File
@@ -1074,7 +1074,7 @@ Configurations
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows
Library Routines -> Library Routines ->
CONFIG_CXX_NEWLONG=n : size_t is an unsigned int, not long CONFIG_ARCH_SIZET_LONG=n : size_t is an unsigned int, not long
This re-configuration should be done before making NuttX or else the This re-configuration should be done before making NuttX or else the
subsequent 'make' will fail. If you have already attempted building subsequent 'make' will fail. If you have already attempted building
+1 -1
View File
@@ -490,7 +490,7 @@ Configuration sub-directories
Sometimes NuttX and your toolchain will disagree on the underlying Sometimes NuttX and your toolchain will disagree on the underlying
type of size_t; sometimes it is an 'unsigned int' and sometimes it is type of size_t; sometimes it is an 'unsigned int' and sometimes it is
an 'unsigned long int'. If this error occurs, then you may need to an 'unsigned long int'. If this error occurs, then you may need to
toggle the value of CONFIG_CXX_NEWLONG. toggle the value of CONFIG_ARCH_SIZET_LONG.
2. If the I/O1 module is connected to the SAM4L Xplained Pro, then 2. If the I/O1 module is connected to the SAM4L Xplained Pro, then
support for the SD card slot can be enabled by making the following support for the SD card slot can be enabled by making the following
@@ -721,7 +721,7 @@ Configuration sub-directories
Sometimes NuttX and your toolchain will disagree on the underlying Sometimes NuttX and your toolchain will disagree on the underlying
type of size_t; sometimes it is an 'unsigned int' and sometimes it is type of size_t; sometimes it is an 'unsigned int' and sometimes it is
an 'unsigned long int'. If this error occurs, then you may need to an 'unsigned long int'. If this error occurs, then you may need to
toggle the value of CONFIG_CXX_NEWLONG. toggle the value of CONFIG_ARCH_SIZET_LONG.
4. If the I/O1 module is connected to the SAMD20 Xplained Pro, then 4. If the I/O1 module is connected to the SAMD20 Xplained Pro, then
support for the SD card slot can be enabled by making the following support for the SD card slot can be enabled by making the following
@@ -588,7 +588,7 @@ Configuration sub-directories
Sometimes NuttX and your toolchain will disagree on the underlying Sometimes NuttX and your toolchain will disagree on the underlying
type of size_t; sometimes it is an 'unsigned int' and sometimes it is type of size_t; sometimes it is an 'unsigned int' and sometimes it is
an 'unsigned long int'. If this error occurs, then you may need to an 'unsigned long int'. If this error occurs, then you may need to
toggle the value of CONFIG_CXX_NEWLONG. toggle the value of CONFIG_ARCH_SIZET_LONG.
4. If the I/O1 module is connected to the SAMD21 Xplained Pro, then 4. If the I/O1 module is connected to the SAMD21 Xplained Pro, then
support for the SD card slot can be enabled by making the following support for the SD card slot can be enabled by making the following
@@ -750,7 +750,7 @@ Configuration sub-directories
Sometimes NuttX and your toolchain will disagree on the underlying Sometimes NuttX and your toolchain will disagree on the underlying
type of size_t; sometimes it is an 'unsigned int' and sometimes it is type of size_t; sometimes it is an 'unsigned int' and sometimes it is
an 'unsigned long int'. If this error occurs, then you may need to an 'unsigned long int'. If this error occurs, then you may need to
toggle the value of CONFIG_CXX_NEWLONG. toggle the value of CONFIG_ARCH_SIZET_LONG.
4. WARNING: This info comes from the SAMD20 Xplained README. I have 4. WARNING: This info comes from the SAMD20 Xplained README. I have
not tried the I/O1 module on the SAML21! not tried the I/O1 module on the SAML21!
+2 -2
View File
@@ -753,7 +753,7 @@ Where <subdir> is one of the following:
CONFIG_HOST_WINDOWS=y : Windows CONFIG_HOST_WINDOWS=y : Windows
CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y : NuttX EABI buildroot toolchain CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y : NuttX EABI buildroot toolchain
CONFIG_CXX_NEWLONG=y : size_t is long (maybe?) CONFIG_ARCH_SIZET_LONG=y : size_t is long (maybe?)
This is easily changed by modifying the configuration. This is easily changed by modifying the configuration.
@@ -764,7 +764,7 @@ Where <subdir> is one of the following:
can try for yourself setting: can try for yourself setting:
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery under Windows CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery under Windows
CONFIG_CXX_NEWLONG=n : size_t is unsigned int (maybe?) CONFIG_ARCH_SIZET_LONG=n : size_t is unsigned int (maybe?)
3. In addition to the protected mode build, this NxWM configuration 3. In addition to the protected mode build, this NxWM configuration
differences from the nxwm configuration in that: differences from the nxwm configuration in that:
@@ -23,7 +23,6 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_ARM_MPU=y CONFIG_ARM_MPU=y
CONFIG_BOARD_LOOPSPERMSEC=16717 CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILD_PROTECTED=y CONFIG_BUILD_PROTECTED=y
CONFIG_CXX_NEWLONG=y
CONFIG_FAT_LCNAMES=y CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y CONFIG_FS_FAT=y
@@ -12,7 +12,6 @@ CONFIG_ARCH_BOARD_SIM=y
CONFIG_ARCH_CHIP="sim" CONFIG_ARCH_CHIP="sim"
CONFIG_ARCH_SIM=y CONFIG_ARCH_SIM=y
CONFIG_BOARD_LOOPSPERMSEC=100 CONFIG_BOARD_LOOPSPERMSEC=100
CONFIG_CXX_NEWLONG=y
CONFIG_HAVE_CXX=y CONFIG_HAVE_CXX=y
CONFIG_IDLETHREAD_STACKSIZE=4096 CONFIG_IDLETHREAD_STACKSIZE=4096
CONFIG_LIBM=y CONFIG_LIBM=y
@@ -14,7 +14,6 @@ CONFIG_ARCH_BOARD_SIM=y
CONFIG_ARCH_CHIP="sim" CONFIG_ARCH_CHIP="sim"
CONFIG_ARCH_SIM=y CONFIG_ARCH_SIM=y
CONFIG_BUILTIN=y CONFIG_BUILTIN=y
CONFIG_CXX_NEWLONG=y
CONFIG_DEBUG_SYMBOLS=y CONFIG_DEBUG_SYMBOLS=y
CONFIG_DISABLE_POSIX_TIMERS=y CONFIG_DISABLE_POSIX_TIMERS=y
CONFIG_EXAMPLES_NX=y CONFIG_EXAMPLES_NX=y
@@ -15,7 +15,6 @@ CONFIG_ARCH_BOARD_SIM=y
CONFIG_ARCH_CHIP="sim" CONFIG_ARCH_CHIP="sim"
CONFIG_ARCH_SIM=y CONFIG_ARCH_SIM=y
CONFIG_BOARD_LOOPSPERMSEC=0 CONFIG_BOARD_LOOPSPERMSEC=0
CONFIG_CXX_NEWLONG=y
CONFIG_DEBUG_SYMBOLS=y CONFIG_DEBUG_SYMBOLS=y
CONFIG_DISABLE_POSIX_TIMERS=y CONFIG_DISABLE_POSIX_TIMERS=y
CONFIG_EXAMPLES_NXLINES=y CONFIG_EXAMPLES_NXLINES=y
@@ -13,7 +13,6 @@ CONFIG_ARCH_BOARD="sim"
CONFIG_ARCH_BOARD_SIM=y CONFIG_ARCH_BOARD_SIM=y
CONFIG_ARCH_CHIP="sim" CONFIG_ARCH_CHIP="sim"
CONFIG_ARCH_SIM=y CONFIG_ARCH_SIM=y
CONFIG_CXX_NEWLONG=y
CONFIG_DEBUG_SYMBOLS=y CONFIG_DEBUG_SYMBOLS=y
CONFIG_DISABLE_POSIX_TIMERS=y CONFIG_DISABLE_POSIX_TIMERS=y
CONFIG_FAT_LCNAMES=y CONFIG_FAT_LCNAMES=y
+7 -3
View File
@@ -271,10 +271,14 @@ typedef _int64_t int_fast64_t;
typedef _uint64_t uint_fast64_t; typedef _uint64_t uint_fast64_t;
#endif #endif
/* Integer types capable of holding object pointers */ /* Integer types capable of holding object pointers
* As a general rule, the size of size_t should be the same as the size of
* uintptr_t: 32-bits on a machine with 32-bit addressing but 64-bits on a
* machine with 64-bit addressing.
*/
typedef _intptr_t intptr_t; typedef _ssize_t intptr_t;
typedef _uintptr_t uintptr_t; typedef _size_t uintptr_t;
/* Some architectures support a FAR pointer which is larger then the normal /* Some architectures support a FAR pointer which is larger then the normal
* (near) pointer * (near) pointer
+3 -7
View File
@@ -139,14 +139,10 @@ typedef int16_t ssize_t;
typedef uint16_t rsize_t; typedef uint16_t rsize_t;
#else /* CONFIG_SMALL_MEMORY */ #else /* CONFIG_SMALL_MEMORY */
/* As a general rule, the size of size_t should be the same as the size of
* uintptr_t: 32-bits on a machine with 32-bit addressing but 64-bits on a
* machine with 64-bit addressing.
*/
typedef uintptr_t size_t; typedef _size_t size_t;
typedef intptr_t ssize_t; typedef _ssize_t ssize_t;
typedef uintptr_t rsize_t; typedef _size_t rsize_t;
#endif /* CONFIG_SMALL_MEMORY */ #endif /* CONFIG_SMALL_MEMORY */
-8
View File
@@ -22,14 +22,6 @@ config HAVE_CXX
if HAVE_CXX if HAVE_CXX
config CXX_NEWLONG
bool "size_t is type long"
default n
---help---
size_t may be type long or type int. This matters for some
C++ library routines because the NuttX size_t might not have
the same underlying type as your toolchain's size_t.
config CXX_EXCEPTION config CXX_EXCEPTION
bool bool
+1 -1
View File
@@ -49,7 +49,7 @@
// Name: delete // Name: delete
//*************************************************************************** //***************************************************************************
void operator delete(void* ptr) void operator delete(FAR void *ptr)
{ {
lib_free(ptr); lib_free(ptr);
} }
+3 -6
View File
@@ -39,6 +39,8 @@
#include <nuttx/compiler.h> #include <nuttx/compiler.h>
#include <cstddef>
#include "libxx.hxx" #include "libxx.hxx"
#ifdef CONFIG_HAVE_CXX14 #ifdef CONFIG_HAVE_CXX14
@@ -61,12 +63,7 @@
// //
//*************************************************************************** //***************************************************************************
//void operator delete(FAR void *ptr, std::size_t size) void operator delete(FAR void *ptr, std::size_t size)
#ifdef CONFIG_CXX_NEWLONG
void operator delete(FAR void *ptr, unsigned long size)
#else
void operator delete(FAR void *ptr, unsigned int size)
#endif
{ {
lib_free(ptr); lib_free(ptr);
} }
+1 -1
View File
@@ -49,7 +49,7 @@
// Name: delete[] // Name: delete[]
//*************************************************************************** //***************************************************************************
void operator delete[](void *ptr) void operator delete[](FAR void *ptr)
{ {
lib_free(ptr); lib_free(ptr);
} }
+3 -6
View File
@@ -40,6 +40,8 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/compiler.h> #include <nuttx/compiler.h>
#include <cstddef>
#include "libxx.hxx" #include "libxx.hxx"
#ifdef CONFIG_HAVE_CXX14 #ifdef CONFIG_HAVE_CXX14
@@ -52,12 +54,7 @@
// Name: delete[] // Name: delete[]
//*************************************************************************** //***************************************************************************
//void operator delete[](void *ptr std::size_t size) void operator delete[](FAR void *ptr, std::size_t size)
#ifdef CONFIG_CXX_NEWLONG
void operator delete[](FAR void *ptr, unsigned long size)
#else
void operator delete[](FAR void *ptr, unsigned int size)
#endif
{ {
lib_free(ptr); lib_free(ptr);
} }
+2 -7
View File
@@ -61,12 +61,7 @@
// //
//*************************************************************************** //***************************************************************************
//void *operator new(size_t nbytes) FAR void *operator new(std::size_t nbytes)
#ifdef CONFIG_CXX_NEWLONG
void *operator new(unsigned long nbytes)
#else
void *operator new(unsigned int nbytes)
#endif
{ {
// We have to allocate something // We have to allocate something
@@ -77,7 +72,7 @@ void *operator new(unsigned int nbytes)
// Perform the allocation // Perform the allocation
void *alloc = lib_malloc(nbytes); FAR void *alloc = lib_malloc(nbytes);
#ifdef CONFIG_DEBUG_ERROR #ifdef CONFIG_DEBUG_ERROR
if (alloc == 0) if (alloc == 0)
+2 -7
View File
@@ -69,12 +69,7 @@
// //
//*************************************************************************** //***************************************************************************
//void *operator new[](size_t size) FAR void *operator new[](std::size_t nbytes)
#ifdef CONFIG_CXX_NEWLONG
void *operator new[](unsigned long nbytes)
#else
void *operator new[](unsigned int nbytes)
#endif
{ {
// We have to allocate something // We have to allocate something
@@ -85,7 +80,7 @@ void *operator new[](unsigned int nbytes)
// Perform the allocation // Perform the allocation
void *alloc = lib_malloc(nbytes); FAR void *alloc = lib_malloc(nbytes);
#ifdef CONFIG_DEBUG_ERROR #ifdef CONFIG_DEBUG_ERROR
if (alloc == 0) if (alloc == 0)
+2 -2
View File
@@ -180,9 +180,9 @@ function configure {
fi fi
if [ "X$sizet" != "Xdefault" ]; then if [ "X$sizet" != "Xdefault" ]; then
sed -i -e "/CONFIG_CXX_NEWLONG/d" $nuttx/.config sed -i -e "/CONFIG_ARCH_SIZET_LONG/d" $nuttx/.config
if [ "X$sizet" == "Xulong" ]; then if [ "X$sizet" == "Xulong" ]; then
sed -i -e "\$aCONFIG_CXX_NEWLONG=y" $nuttx/.config sed -i -e "\$aCONFIG_ARCH_SIZET_LONG=y" $nuttx/.config
fi fi
fi fi