Patches from Petteri Aimonen + stdbool and rand() changes for Freddie Chopin

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5415 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-12-07 16:00:56 +00:00
parent 419bb814c5
commit 5306523bce
34 changed files with 1110 additions and 181 deletions
+22 -1
View File
@@ -3737,4 +3737,25 @@
* arch/z80/src/Makefile.sdccw: Renamed makefiles with extensions zdiil,
zdiiw, sdccl, and sdccw for the ZDS-II vs SDCC compilers and for the
POSIX vs Windows native builds.
* nuttx/drivers/mtd/ftl.c: Fix for the flash translation layer. Short
unaligned writes were buggy. From Petteri Aimonen.
* nuttx/libc/math/lib_round*.c: Add rounding functions to the math
library. Contributed by Petteri Aimonen.
* include/cxx/cstdlib: Add stroul(). From Petteri Aimonen.
* arch/*/include/limits.h: Change signed minimum values from, for example,
(-128) to (-127 - 1) to avoid overflows under certain conditions. From
Peterri Aimonen.
* graphics/nxtk/nxtk_subwindowmove.c: Previously it was very difficult to
do e.g. "scroll by dx, dy". When given the full window area, nxtk_subwindowmove
would clip the offset always to 0,0. It makes more sense for it to clip the
source area and not modify the offset. From Petteri Aimonen.
* graphics/nxtk/nxtk_getwindow.c: Clipping would change the offset of returned
data, and caller has no way to know what the new offset would be. This messes
up font drawing when the text is partially out of window, e.g. when scrolling.
Also from Petteri Aimonen.
* include/stdbool.h: Can now be disabled for C++ files if CONFIG_C99_BOOL8 is
defined. CONFIG_C99_BOOL8 indicates (1) that the sizeof(_Bool) is one in both
C and C++, and (2) the the C compiler is C99 and supports the _Bool intrinsic
type. Requested by Freddie Chopin.
* include/stdlib/lib_rand.c: Various additional changes so that the integer
value zero can be returned. Requested by Freddie Chopin.
+8 -8
View File
@@ -45,7 +45,7 @@
************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,17 +59,17 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-32768)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 32767
#define UINT_MAX 65535
#define UINT_MAX 65535U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
@@ -77,8 +77,8 @@
* first byte holding data space information.
*/
#define PTR_MIN (-8388608)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 8388607
#define UPTR_MAX 16777215
#define UPTR_MAX 16777215U
#endif /* __ARCH_8051_INCLUDE_LIMITS_H */
+9 -9
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,28 +59,28 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-2147483648)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295
#define UINT_MAX 4294967295U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is 4 bytes */
#define PTR_MIN (-2147483648)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 2147483647
#define UPTR_MAX 4294967295
#define UPTR_MAX 4294967295U
#endif /* __ARCH_ARM_INCLUDE_LIMITS_H */
+9 -9
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,31 +59,31 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
/* Integer is two bytes */
#define INT_MIN (-32768)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 32767
#define UINT_MAX 65535
#define UINT_MAX 65535U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is two bytes */
#define PTR_MIN (-32768)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 32767
#define UPTR_MAX 65535
#define UPTR_MAX 65535U
#endif /* __ARCH_AVR_INCLUDE_AVR_LIMITS_H */
+9 -9
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,31 +59,31 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
/* Integer is four bytes */
#define INT_MIN (-2147483648)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295
#define UINT_MAX 4294967295U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is four bytes */
#define PTR_MIN (-2147483648)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 2147483647
#define UPTR_MAX 4294967295
#define UPTR_MAX 4294967295U
#endif /* __ARCH_AVR_INCLUDE_AVR32_LIMITS_H */
+9 -10
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,39 +59,38 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
/* The size of an integer is controlled with the -mshort or -mnoshort GCC
* options. GCC will set the pre-defined symbol __INT__ to indicate the size
* of an integer
*/
#define INT_MIN (-INT_MAX - 1)
#if __INT__ == 32
# define INT_MIN (-2147483648)
# define INT_MAX 2147483647
# define UINT_MAX 4294967295
#else
# define INT_MIN (-32768)
# define INT_MAX 32767
# define UINT_MAX 65535
# define UINT_MAX 65535U
#endif
/* Long is 4-bytes and long long is 8 bytes in any case */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is 2 bytes */
#define PTR_MIN (-32768)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 32767
#define UPTR_MAX 65535
#define UPTR_MAX 65535U
#endif /* __ARCH_HC_INCLUDE_HC12_LIMITS_H */
+9 -10
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,39 +59,38 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
/* The size of an integer is controlled with the -mshort or -mnoshort GCC
* options. GCC will set the pre-defined symbol __INT__ to indicate the size
* of an integer
*/
#define INT_MIN (-INT_MAX - 1)
#if __INT__ == 32
# define INT_MIN (-2147483648)
# define INT_MAX 2147483647
# define UINT_MAX 4294967295
#else
# define INT_MIN (-32768)
# define INT_MAX 32767
# define UINT_MAX 65535
# define UINT_MAX 65535U
#endif
/* Long is 4-bytes and long long is 8 bytes in any case */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is 2 bytes */
#define PTR_MIN (-32768)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 32767
#define UPTR_MAX 65535
#define UPTR_MAX 65535U
#endif /* __ARCH_HC_INCLUDE_HCS12_LIMITS_H */
+9 -9
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,29 +59,29 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-2147483648)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295
#define UINT_MAX 4294967295U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is 4 bytes */
#define PTR_MIN (-2147483648)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 2147483647
#define UPTR_MAX 4294967295
#define UPTR_MAX 4294967295U
#endif /* __ARCH_MIPS_INCLUDE_LIMITS_H */
+9 -9
View File
@@ -45,7 +45,7 @@
************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,28 +59,28 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-2147483648)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295
#define UINT_MAX 4294967295U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is 4 bytes */
#define PTR_MIN (-2147483648)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 2147483647
#define UPTR_MAX 4294967295
#define UPTR_MAX 4294967295U
#endif /* __ARCH_RGMP_INCLUDE_LIMITS_H */
+7 -7
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,9 +59,9 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
/* For M16C, type int is 16-bits, the same size as type 'short int' */
@@ -71,18 +71,18 @@
/* For M16C, typle 'long int' is 32-bits */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is 2 bytes */
#define PTR_MIN (-32768)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 32767
#define UPTR_MAX 65535
#define UPTR_MAX 65535U
#endif /* __ARCH_SH_INCLUDE_M16C_LIMITS_H */
+9 -9
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,30 +59,30 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
/* On SH-1, type 'int' is 32-bits */
#define INT_MIN (-2147483648)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295
#define UINT_MAX 4294967295U
/* On SH-1, type 'long' is the same size as type 'int', 32-bits */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is 4 bytes */
#define PTR_MIN (-2147483648)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 2147483647
#define UPTR_MAX 4294967295
#define UPTR_MAX 4294967295U
#endif /* __ARCH_SH_INCLUDE_SH1_LIMITS_H */
+9 -9
View File
@@ -45,7 +45,7 @@
************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,28 +59,28 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-2147483648)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295
#define UINT_MAX 4294967295U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is 4 bytes */
#define PTR_MIN (-2147483648)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 2147483647
#define UPTR_MAX 4294967295
#define UPTR_MAX 4294967295U
#endif /* __ARCH_SIM_INCLUDE_LIMITS_H */
+9 -9
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,28 +59,28 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-2147483648)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295
#define UINT_MAX 4294967295U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
/* A pointer is 4 bytes */
#define PTR_MIN (-2147483648)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 2147483647
#define UPTR_MAX 4294967295
#define UPTR_MAX 4294967295U
#endif /* __ARCH_X86_INCLUDE_I486_LIMITS_H */
+11 -11
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,26 +59,26 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-2147483648)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295
#define UINT_MAX 4294967295U
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
#define LLONG_MIN (-2147483648L)
#define LLONG_MAX 2147483647L
#define ULLONG_MAX 4294967295UL
#define LLONG_MIN (-LLONG_MAX - 1)
#define LLONG_MAX 2147483647LL
#define ULLONG_MAX 4294967295ULL
/* A pointer is 4 bytes */
#define PTR_MIN (-2147483648)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 2147483647
#define UPTR_MAX 4294967295
#define UPTR_MAX 4294967295U
#endif /* __ARCH_Z16_INCLUDE_LIMITS_H */
+9 -10
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,17 +59,17 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-32768)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 32767
#define UINT_MAX 65535
#define UINT_MAX 65535U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
@@ -80,14 +80,13 @@
* ADL mode - 24 bits
*/
#define PTR_MIN (-PTR_MAX - 1)
#ifdef CONFIG_EZ80_Z80MODE
#define PTR_MIN (-32768)
#define PTR_MAX 32767
#define UPTR_MAX 65535
#define UPTR_MAX 65535U
#else
#define PTR_MIN (-8388608)
#define PTR_MAX 8388607
#define UPTR_MAX 16777215
#define UPTR_MAX 16777215U
#endif
#endif /* __ARCH_Z80_INCLUDE_EZ80_LIMITS_H */
+8 -8
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,24 +59,24 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-32768)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 32767
#define UINT_MAX 65535
#define UINT_MAX 65535U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
/* A pointer is 2 bytes */
#define PTR_MIN (-32768)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 32767
#define UPTR_MAX 65535
#define UPTR_MAX 65535U
#endif /* __ARCH_Z80_INCLUDE_Z8_LIMITS_H */
+8 -8
View File
@@ -45,7 +45,7 @@
****************************************************************************/
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
@@ -59,24 +59,24 @@
#define CHAR_MAX SCHAR_MAX
#endif
#define SHRT_MIN (-32768)
#define SHRT_MIN (-SHRT_MAX - 1)
#define SHRT_MAX 32767
#define USHRT_MAX 65535
#define USHRT_MAX 65535U
#define INT_MIN (-32768)
#define INT_MIN (-INT_MAX - 1)
#define INT_MAX 32767
#define UINT_MAX 65535
#define UINT_MAX 65535U
/* These change on 32-bit and 64-bit platforms */
#define LONG_MIN (-2147483648L)
#define LONG_MIN (-LONG_MAX - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL
/* A pointer is 2 bytes */
#define PTR_MIN (-32768)
#define PTR_MIN (-PTR_MAX - 1)
#define PTR_MAX 32767
#define UPTR_MAX 65535
#define UPTR_MAX 65535U
#endif /* __ARCH_Z80_INCLUDE_Z80_LIMITS_H */
+4
View File
@@ -51,6 +51,10 @@ ifeq ($(CONFIG_MTD_W25),y)
CSRCS += w25.c
endif
ifeq ($(CONFIG_MTD_AT25),y)
CSRCS += at25.c
endif
# Include MTD driver support
DEPPATH += --dep-path mtd
+708
View File
File diff suppressed because it is too large Load Diff
+27 -4
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* drivers/mtd/ftl.c
*
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -229,6 +229,10 @@ static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
remaining = nblocks;
if (alignedblock > startblock)
{
/* Check if the write is shorter than to the end of the erase block */
bool short_write = (remaining < (alignedblock - startblock));
/* Read the full erase block into the buffer */
rwblock = startblock & ~mask;
@@ -252,9 +256,19 @@ static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
/* Copy the user data at the end of the buffered erase block */
offset = (startblock & mask) * dev->geo.blocksize;
nbytes = dev->geo.erasesize - offset;
if (short_write)
{
nbytes = remaining * dev->geo.blocksize;
}
else
{
nbytes = dev->geo.erasesize - offset;
}
fvdbg("Copy %d bytes into erase block=%d at offset=%d\n",
nbytes, eraseblock, offset);
memcpy(dev->eblock + offset, buffer, nbytes);
/* And write the erase back to flash */
@@ -268,8 +282,16 @@ static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
/* Then update for amount written */
remaining -= dev->blkper - (startblock & mask);
buffer += nbytes;
if (short_write)
{
remaining = 0;
}
else
{
remaining -= dev->blkper - (startblock & mask);
}
buffer += nbytes;
}
/* How handle full erase pages in the middle */
@@ -290,6 +312,7 @@ static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
fvdbg("Write %d bytes into erase block=%d at offset=0\n",
dev->geo.erasesize, alignedblock);
nxfrd = MTD_BWRITE(dev->mtd, alignedblock, dev->blkper, buffer);
if (nxfrd != dev->blkper)
{
+7 -4
View File
@@ -110,12 +110,15 @@ int nxtk_getwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect,
}
#endif
/* Clip the rectangle so that it lies within the sub-window bounds
* then move the rectangle to that it is relative to the containing
* window.
/* Move the rectangle to that it is relative to the containing
* window. If part of the rectangle lies outside the window,
* it will contain garbage data, but the contained area will be
* valid.
*/
nxtk_subwindowclip(fwnd, &getrect, rect, &fwnd->fwrect);
nxgl_rectoffset(&getrect, rect,
fwnd->fwrect.pt1.x - fwnd->wnd.bounds.pt1.x,
fwnd->fwrect.pt1.y - fwnd->wnd.bounds.pt1.y);
/* Then get it */
+5 -7
View File
@@ -112,21 +112,19 @@ void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd,
nxgl_rectintersect(&abssrc, &abssrc, &fwnd->fwrect);
/* Clip the offset so that the source rectangle does not move out of the
* the client sub-window.
*/
/* Clip the source rectangle so that destination area is within the window. */
destoffset->x = srcoffset->x;
if (destoffset->x < 0)
{
if (abssrc.pt1.x + destoffset->x < bounds->pt1.x)
{
destoffset->x = bounds->pt1.x - abssrc.pt1.x;
abssrc.pt1.x = bounds->pt1.x - destoffset->x;
}
}
else if (abssrc.pt2.x + destoffset->x > bounds->pt2.x)
{
destoffset->x = bounds->pt2.x - abssrc.pt2.x;
abssrc.pt2.x = bounds->pt2.x - destoffset->x;
}
destoffset->y = srcoffset->y;
@@ -134,12 +132,12 @@ void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd,
{
if (abssrc.pt1.y + destoffset->y < bounds->pt1.y)
{
destoffset->y = bounds->pt1.y - abssrc.pt1.y;
abssrc.pt1.y = bounds->pt1.y - destoffset->y;
}
}
else if (abssrc.pt2.y + destoffset->y > bounds->pt2.y)
{
destoffset->y = bounds->pt2.y - abssrc.pt2.y;
abssrc.pt2.y = bounds->pt2.y - destoffset->y;
}
+3
View File
@@ -69,6 +69,7 @@ namespace std
using ::log10f;
using ::log2f;
using ::modff;
using ::roundf;
using ::powf;
using ::sinf;
using ::sinhf;
@@ -95,6 +96,7 @@ namespace std
using ::log10;
using ::log2;
using ::modf;
using ::round;
using ::pow;
using ::sin;
using ::sinh;
@@ -121,6 +123,7 @@ namespace std
using ::log10l;
using ::log2l;
using ::modfl;
using ::roundl;
using ::powl;
using ::sinl;
using ::sinhl;
+1
View File
@@ -70,6 +70,7 @@ namespace std
#endif
using ::strtol;
using ::strtoul;
using ::strtod;
using ::malloc;
+1 -1
View File
@@ -176,7 +176,7 @@ struct mountpt_operations
int (*statfs)(FAR struct inode *mountpt, FAR struct statfs *buf);
/* Operations on pathes */
/* Operations on paths */
int (*unlink)(FAR struct inode *mountpt, FAR const char *relpath);
int (*mkdir)(FAR struct inode *mountpt, FAR const char *relpath, mode_t mode);
+8
View File
@@ -141,6 +141,14 @@ double floor (double x);
long double floorl(long double x);
#endif
float roundf(float x);
#if CONFIG_HAVE_DOUBLE
double round (double x);
#endif
#ifdef CONFIG_HAVE_LONG_DOUBLE
long double roundl(long double x);
#endif
float fabsf (float x);
#if CONFIG_HAVE_DOUBLE
double fabs (double x);
+2 -1
View File
@@ -220,7 +220,6 @@ EXTERN FAR struct mtd_dev_s *at24c_initialize(FAR struct i2c_dev_s *dev);
EXTERN FAR struct mtd_dev_s *sst25_initialize(FAR struct spi_dev_s *dev);
/****************************************************************************
* Name: w25_initialize
*
@@ -233,6 +232,8 @@ EXTERN FAR struct mtd_dev_s *sst25_initialize(FAR struct spi_dev_s *dev);
EXTERN FAR struct mtd_dev_s *w25_initialize(FAR struct spi_dev_s *dev);
EXTERN FAR struct mtd_dev_s *at25_initialize(FAR struct spi_dev_s *dev);
#undef EXTERN
#ifdef __cplusplus
}
+33 -2
View File
@@ -42,10 +42,33 @@
#include <nuttx/config.h>
/* If CONFIG_ARCH_STDBOOL_H is set, then the archecture will provide its own
* stdbool.h file. In this case, this header file will simply re-direct to
* the architecture-specfiic stdbool.h header file.
*/
#ifdef CONFIG_ARCH_STDBOOL_H
# include <arch/stdbool.h>
/* NuttX will insist that the sizeof(bool) is 8-bits. The sizeof of _Bool
* used by any specific compiler is implementation specific: It can vary from
* compiler-to-compiler and even vary between different versions of the same
* compiler. Compilers seems to be converging to sizeof(_Bool) == 1. If that
* is true for your compiler, you should define CONFIG_C99_BOOL8 in your NuttX
* configuration for better standards compatibility.
*
* CONFIG_C99_BOOL8 - Means (1) your C++ compiler has sizeof(_Bool) == 8,
* (2) your C compiler supports the C99 _Bool intrinsic type, and (2) that
* the C99 _Bool type also has size 1.
*/
#else
/* nuttx/compiler.h may also define or undefine CONFIG_C99_BOOL8 */
# include <nuttx/compiler.h>
#if !defined(__cplusplus) || !defined(CONFIG_C99_BOOL8)
# include <stdint.h>
/****************************************************************************
@@ -58,10 +81,15 @@
* NOTE: Under C99 'bool' is required to be defined to be the intrinsic type
* _Bool. However, in this NuttX context, we need backward compatibility
* to pre-C99 standards where _Bool is not an intrinsic type. Hence, we
* use _Bool8 as the underlying type.
* use _Bool8 as the underlying type (unless CONFIG_C99_BOOL8 is defined)
*/
#define bool _Bool8
#ifdef CONFIG_C99_BOOL8
# define bool _Bool
#else
# define bool _Bool8
#endif
#define true 1
#define false 0
@@ -83,7 +111,10 @@
* as the underlying type.
*/
#ifndef CONFIG_C99_BOOL8
typedef uint8_t _Bool8;
#endif
#endif /* __cplusplus && CONFIG_C99_BOOL8 */
#endif /* CONFIG_ARCH_STDBOOL_H */
#endif /* __INCLUDE_STDBOOL_H */
+3 -3
View File
@@ -40,17 +40,17 @@ ifeq ($(CONFIG_LIBM),y)
CSRCS += lib_acosf.c lib_asinf.c lib_atan2f.c lib_atanf.c lib_ceilf.c lib_cosf.c
CSRCS += lib_coshf.c lib_expf.c lib_fabsf.c lib_floorf.c lib_fmodf.c lib_frexpf.c
CSRCS += lib_ldexpf.c lib_logf.c lib_log10f.c lib_log2f.c lib_modff.c lib_powf.c
CSRCS += lib_sinf.c lib_sinhf.c lib_sqrtf.c lib_tanf.c lib_tanhf.c
CSRCS += lib_roundf.c lib_sinf.c lib_sinhf.c lib_sqrtf.c lib_tanf.c lib_tanhf.c
CSRCS += lib_acos.c lib_asin.c lib_atan.c lib_atan2.c lib_ceil.c lib_cos.c
CSRCS += lib_cosh.c lib_exp.c lib_fabs.c lib_floor.c lib_fmod.c lib_frexp.c
CSRCS += lib_ldexp.c lib_log.c lib_log10.c lib_log2.c lib_modf.c lib_pow.c
CSRCS += lib_sin.c lib_sinh.c lib_sqrt.c lib_tan.c lib_tanh.c
CSRCS += lib_round.c lib_sin.c lib_sinh.c lib_sqrt.c lib_tan.c lib_tanh.c
CSRCS += lib_acosl.c lib_asinl.c lib_atan2l.c lib_atanl.c lib_ceill.c lib_cosl.c
CSRCS += lib_coshl.c lib_expl.c lib_fabsl.c lib_floorl.c lib_fmodl.c lib_frexpl.c
CSRCS += lib_ldexpl.c lib_logl.c lib_log10l.c lib_log2l.c lib_modfl.c lib_powl.c
CSRCS += lib_sinl.c lib_sinhl.c lib_sqrtl.c lib_tanl.c lib_tanhl.c
CSRCS += lib_roundl.c lib_sinl.c lib_sinhl.c lib_sqrtl.c lib_tanl.c lib_tanhl.c
CSRCS += lib_libexpi.c lib_libsqrtapprox.c
+40
View File
@@ -0,0 +1,40 @@
/************************************************************************
* lib/math/lib_round.c
*
* This file is a part of NuttX:
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* (C) 2012 Petteri Aimonen <jpa@nx.mail.kapsi.fi>
*
************************************************************************/
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <math.h>
/************************************************************************
* Public Functions
************************************************************************/
#ifdef CONFIG_HAVE_DOUBLE
double round(double x)
{
double f = modf(x, &x);
if (x <= 0.0 && f <= -0.5)
{
x -= 1.0;
}
if (x >= 0.0 && f >= 0.5)
{
x += 1.0;
}
return x;
}
#endif
+38
View File
@@ -0,0 +1,38 @@
/************************************************************************
* lib/math/lib_roundf.c
*
* This file is a part of NuttX:
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* (C) 2012 Petteri Aimonen <jpa@nx.mail.kapsi.fi>
*
************************************************************************/
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <math.h>
/************************************************************************
* Public Functions
************************************************************************/
float roundf(float x)
{
float f = modff(x, &x);
if (x <= 0.0f && f <= -0.5f)
{
x -= 1.0f;
}
if (x >= 0.0f && f >= 0.5f)
{
x += 1.0f;
}
return x;
}
+40
View File
@@ -0,0 +1,40 @@
/************************************************************************
* lib/math/lib_round.c
*
* This file is a part of NuttX:
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* (C) 2012 Petteri Aimonen <jpa@nx.mail.kapsi.fi>
*
************************************************************************/
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <math.h>
/************************************************************************
* Public Functions
************************************************************************/
#ifdef CONFIG_HAVE_LONG_DOUBLE
long double roundl(long double x)
{
long double f = modfl(x, &x);
if (x <= 0.0 && f <= -0.5)
{
x -= 1.0;
}
if (x >= 0.0 && f >= 0.5)
{
x += 1.0;
}
return x;
}
#endif
+19 -14
View File
@@ -74,7 +74,7 @@ static unsigned int nrand(unsigned int nLimit);
/* First order congruential generators */
static inline void fgenerate1(void);
static inline unsigned long fgenerate1(void);
#if (CONFIG_LIB_RAND_ORDER == 1)
static double_t frand1(void);
#endif
@@ -82,7 +82,7 @@ static double_t frand1(void);
/* Second order congruential generators */
#if (CONFIG_LIB_RAND_ORDER > 1)
static inline void fgenerate2(void);
static inline unsigned long fgenerate2(void);
#if (CONFIG_LIB_RAND_ORDER == 2)
static double_t frand2(void);
#endif
@@ -90,7 +90,7 @@ static double_t frand2(void);
/* Third order congruential generators */
#if (CONFIG_LIB_RAND_ORDER > 2)
static inline void fgenerate3(void);
static inline unsigned long fgenerate3(void);
static double_t frand3(void);
#endif
#endif
@@ -141,7 +141,7 @@ static unsigned int nrand(unsigned int nLimit)
/* First order congruential generators */
static inline void fgenerate1(void)
static inline unsigned long fgenerate1(void)
{
unsigned long randint;
@@ -152,6 +152,7 @@ static inline void fgenerate1(void)
randint = (RND1_CONSTK * g_randint1) % RND1_CONSTP;
g_randint1 = (randint == 0 ? 1 : randint);
return randint;
}
#if (CONFIG_LIB_RAND_ORDER == 1)
@@ -159,18 +160,18 @@ static double_t frand1(void)
{
/* First order congruential generator. */
fgenerate1();
unsigned long randint = fgenerate1();
/* Construct an floating point value in the range from 0.0 up to 1.0 */
return ((double_t)g_randint1) / ((double_t)RND1_CONSTP);
return ((double_t)randint) / ((double_t)RND1_CONSTP);
}
#endif
/* Second order congruential generators */
#if (CONFIG_LIB_RAND_ORDER > 1)
static inline void fgenerate2(void)
static inline unsigned long fgenerate2(void)
{
unsigned long randint;
@@ -190,6 +191,8 @@ static inline void fgenerate2(void)
{
g_randint2 = 1;
}
return randint;
}
#if (CONFIG_LIB_RAND_ORDER == 2)
@@ -197,18 +200,18 @@ static double_t frand2(void)
{
/* Second order congruential generator */
fgenerate2();
unsigned long randint = fgenerate2();
/* Construct an floating point value in the range from 0.0 up to 1.0 */
return ((double_t)g_randint1) / ((double_t)RND2_CONSTP);
return ((double_t)randint) / ((double_t)RND2_CONSTP);
}
#endif
/* Third order congruential generators */
#if (CONFIG_LIB_RAND_ORDER > 2)
static inline void fgenerate3(void)
static inline unsigned long fgenerate3(void)
{
unsigned long randint;
@@ -230,17 +233,19 @@ static inline void fgenerate3(void)
{
g_randint3 = 1;
}
return randint;
}
static double_t frand3(void)
{
/* Third order congruential generator */
fgenerate3();
unsigned long randint = fgenerate3();
/* Construct an floating point value in the range from 0.0 up to 1.0 */
return ((double_t)g_randint1) / ((double_t)RND3_CONSTP);
return ((double_t)randint) / ((double_t)RND3_CONSTP);
}
#endif
#endif
@@ -258,10 +263,10 @@ void srand(unsigned int seed)
g_randint1 = seed;
#if (CONFIG_LIB_RAND_ORDER > 1)
g_randint2 = seed;
fgenerate1();
(void)fgenerate1();
#if (CONFIG_LIB_RAND_ORDER > 2)
g_randint3 = seed;
fgenerate2();
(void)fgenerate2();
#endif
#endif
}
+8
View File
@@ -5,6 +5,14 @@
comment "Basic CXX Support"
config C99_BOOL8
bool "sizeof(_Bool) is 8-bits"
default n
---help---
This setting means (1) your C++ compiler has sizeof(_Bool) == 8, (2)
your C compiler supports the C99 _Bool intrinsic type, and (2) that
the C99 _Bool type also has size 1.
config HAVE_CXX
bool "Have C++ compiler"
default n