From a5f3e1e6d18735649f5dac517d35a9d0349ed42e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 1 Oct 2017 09:02:53 -0600 Subject: [PATCH] compiler.h, limits.h, types.h: Update SDCC/z80 files to include support for long long, inline, __FILE__, and __func__. --- arch/z80/include/z80/limits.h | 4 ++++ arch/z80/include/z80/types.h | 6 +++++- include/nuttx/compiler.h | 33 +++++++++++++++++++++++---------- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/arch/z80/include/z80/limits.h b/arch/z80/include/z80/limits.h index 21e06cdb94a..e858712f5a8 100644 --- a/arch/z80/include/z80/limits.h +++ b/arch/z80/include/z80/limits.h @@ -73,6 +73,10 @@ #define LONG_MAX 2147483647L #define ULONG_MAX 4294967295UL +#define LLONG_MIN (-LLONG_MAX - 1) +#define LLONG_MAX 9223372036854775807LL +#define ULLONG_MAX 18446744073709551615ULL + /* A pointer is 2 bytes */ #define PTR_MIN (-PTR_MAX - 1) diff --git a/arch/z80/include/z80/types.h b/arch/z80/include/z80/types.h index ecf2cc4132b..eece6f1f248 100644 --- a/arch/z80/include/z80/types.h +++ b/arch/z80/include/z80/types.h @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/include/z80/types.h * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -80,6 +80,10 @@ typedef unsigned int _uint16_t; typedef signed long _int32_t; typedef unsigned long _uint32_t; +typedef signed long long _int64_t; +typedef unsigned long long _uint64_t; +#define __INT64_DEFINED + /* A pointer is 2 bytes */ typedef signed int _intptr_t; diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 9ebf6758769..39f81cac3ec 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -1,7 +1,8 @@ /**************************************************************************** * include/nuttx/compiler.h * - * Copyright (C) 2007-2009, 2012-2013, 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012-2013, 2015-2017 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -55,7 +56,9 @@ # define CONFIG_CPP_HAVE_VARARGS 1 /* Supports variable argument macros */ # define CONFIG_CPP_HAVE_WARNING 1 /* Supports #warning */ -/* Intriniscs */ +/* Intriniscs. GCC supports __func__ but provides __FUNCTION__ for backward + * compatibility with older versions of GCC. + */ # define CONFIG_HAVE_FUNCTIONNAME 1 /* Has __FUNCTION__ */ # define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */ @@ -292,6 +295,7 @@ # define CONFIG_HAVE_FUNCTIONNAME 1 /* Has __FUNCTION__ */ # define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */ +# define __FUNCTION__ __func__ /* SDCC supports on __func__ */ /* Pragmas * @@ -313,9 +317,13 @@ # define weak_const_function # define restrict /* REVISIT */ -/* SDCC does not support the noreturn or packed attributes */ +/* Current SDCC supports noreturn (via stdnoreturn.h or _Noreturn) */ +/* REVISIT: #define noreturn_function _Noreturn */ # define noreturn_function + +/* SDCC does not support the packed attributes */ + # define begin_packed_struct # define end_packed_struct @@ -335,6 +343,9 @@ /* The reentrant attribute informs SDCC that the function * must be reentrant. In this case, SDCC will store input * arguments on the stack to support reentrancy. + * + * SDCC functions are always reentrant (except for the mcs51, + * ds390, hc08 and s08 backends) */ # define reentrant_function __reentrant @@ -374,22 +385,24 @@ # define CONFIG_LONG_IS_NOT_INT 1 -/* The generic pointer and int are not the same size - * (for some SDCC architectures) +/* The generic pointer and int are not the same size (for some SDCC + * architectures). REVISIT: SDCC now has more backends where pointers are + * the same size as int than just z80 and z180. */ #if !defined(__z80) && !defined(__gbz80) # define CONFIG_PTR_IS_NOT_INT 1 #endif -/* SDCC does not support inline functions */ +/* New versions of SDCC supports inline function */ -# undef CONFIG_HAVE_INLINE -# define inline +# define CONFIG_HAVE_INLINE 1 -/* SDCC does not support type long long or type double */ +/* SDCC does types long long and float, but not types double and long + * double. + */ -# undef CONFIG_HAVE_LONG_LONG +# define CONFIG_HAVE_LONG_LONG 1 # define CONFIG_HAVE_FLOAT 1 # undef CONFIG_HAVE_DOUBLE # undef CONFIG_HAVE_LONG_DOUBLE