diff mbox

newlib-stdint.h: Remove 32 bit longs

Message ID ce3defa4-20aa-5829-5c00-4b5ef71a5e48@intel.com
State New
Headers show

Commit Message

Andy Ross Aug. 22, 2016, 4:19 p.m. UTC
Same code.  Includes an attempt to format a change log entry in a more
gcc-friendly way.  I'm new here.

From c208b51fb55c6758c1059dfaee398c27da398e9d Mon Sep 17 00:00:00 2001
From: Andy Ross <andrew.j.ross@intel.com>
Date: Fri, 19 Aug 2016 09:40:42 -0700
Subject: [PATCH] newlib-stdint.h: Remove 32 bit longs

This would make __INT32_TYPE__ a "long" instead of an "int", which
would then percolate down in newlib's own headers into a typedef for
int32_t.  Which is wrong.  Newlib's headers, if __INT32_TYPE__ were
not defined, actually would chose an int for this type.  The comment
that newlib uses a 32 bit long appears to be a lie, perhaps
historical.

* gcc/config/newlib-stdint.h: synchronize 32 bit type macros with
  newlib's own headers.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
---
 gcc/config/newlib-stdint.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Pavel Pisa Aug. 22, 2016, 10:26 p.m. UTC | #1
Hello all,

I am not expert but I would like bring attention to some
facts which come to my mind

On Monday 22 of August 2016 18:19:06 Andy Ross wrote:
> --- a/gcc/config/newlib-stdint.h
> +++ b/gcc/config/newlib-stdint.h
> @@ -22,10 +22,9 @@ a copy of the GCC Runtime Library Exception along with
> this program; see the files COPYING3 and COPYING.RUNTIME respectively.  If
> not, see <http://www.gnu.org/licenses/>.  */
>
> -/* newlib uses 32-bit long in certain cases for all non-SPU
> -   targets.  */
> +/* newlib used to use a 32-bit long, no longer */
>  #ifndef STDINT_LONG32
> -#define STDINT_LONG32 (LONG_TYPE_SIZE == 32)
> +#define STDINT_LONG32 0
>  #endif

how this change would work on some H8 toolchain variants and
for each MSP430 build. They have int type only 16 bits
wide.

If there is available INT_TYPE_SIZE 

#ifndef STDINT_LONG32
#define STDINT_LONG32 (INT_TYPE_SIZE < 32)
#endif

could be OK. But INT_TYPE_SIZE seems is not used/available
in NewLib from the first glimpse.

But you get into significant troubles on Windows platform
with that probably because LONG is equivalent of int32_t
on both 32-bit and 64-bit platform there and most of the APIs
use it this way which means that all kind of warning would
appear if uint32_t *ptr is passed to LONG *ptr used in API.
It would change from long * and long * to
                     int * and long *

So I think that these problems should be considered before
change. Limiting use of int for int32_t only to 64-bit targets
with 64-bit long (as it is now) seems reasonable if used
consistent way.


Best wishes,

                Pavel
diff mbox

Patch

diff --git a/gcc/config/newlib-stdint.h b/gcc/config/newlib-stdint.h
index eb99556..0275948 100644
--- a/gcc/config/newlib-stdint.h
+++ b/gcc/config/newlib-stdint.h
@@ -22,10 +22,9 @@  a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */

-/* newlib uses 32-bit long in certain cases for all non-SPU
-   targets.  */
+/* newlib used to use a 32-bit long, no longer */
 #ifndef STDINT_LONG32
-#define STDINT_LONG32 (LONG_TYPE_SIZE == 32)
+#define STDINT_LONG32 0
 #endif

 #define SIG_ATOMIC_TYPE "int"