This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug#652356: please use argument-safe bswap macros on all architectures


Aurelien Jarno dixit:

>I am not an m68k porter, and I am not planning to try things. m68k is
>lagging upstream wrt other architectures. Please work with upstream to
>fix things, then I can include tested and accepted patches.

Iâm not an m68k porter either, but this fix is easily done from working
with a libc (BSD libc in my case) skills. But okay. Am I guessing that
libc-ports@sourceware.org is âupstreamâ? It was hard to find information
about eglibc-ports on the ânet.

Anyway, here it is:


Dixi quodâ

>Aurelien Jarno dixit:
>
>>I have dropped it in favor of the default version for the next upload.
>
>Why donât you just use these? (Tested for 32-bit and 64-bit both.)
>Iâve not looked at other architectures atm though.
>
>--- usr/include/m68k-linux-gnu/bits/byteswap.h~	2011-12-17 02:44:08.000000000 +0000
>+++ usr/include/m68k-linux-gnu/bits/byteswap.h	2011-12-17 02:49:34.000000000 +0000
>@@ -1,5 +1,5 @@
> /* Macros to swap the order of bytes in integer values.  m68k version.
>-   Copyright (C) 1997, 2002, 2008 Free Software Foundation, Inc.
>+   Copyright (C) 1997, 2002, 2008, 2011 Free Software Foundation, Inc.
>    This file is part of the GNU C Library.
> 
>    The GNU C Library is free software; you can redistribute it and/or
>@@ -50,15 +50,15 @@
> #if defined __GNUC__ && __GNUC__ >= 2 && !defined(__mcoldfire__)
> # define __bswap_32(x) \
>   __extension__							\
>-  ({ unsigned int __bswap_32_v;					\
>-     if (__builtin_constant_p (x))				\
>-       __bswap_32_v = __bswap_constant_32 (x);			\
>+  ({ unsigned int __bswap_32_v, __bswap_32_x = (x);		\
>+     if (__builtin_constant_p (__bswap_32_x))			\
>+       __bswap_32_v = __bswap_constant_32 (__bswap_32_x);	\
>      else							\
>        __asm__ __volatile__ ("ror%.w %#8, %0;"			\
> 			     "swap %0;"				\
> 			     "ror%.w %#8, %0"			\
> 			     : "=d" (__bswap_32_v)		\
>-			     : "0" ((unsigned int) (x)));	\
>+			     : "0" (__bswap_32_x));		\
>      __bswap_32_v; })
> #else
> static __inline unsigned int
>@@ -85,11 +85,12 @@
>   __extension__								\
>   ({ union { unsigned long long int __ll;				\
> 	     unsigned long int __l[2]; } __bswap_64_v, __bswap_64_r;	\
>-     if (__builtin_constant_p (x))					\
>-       __bswap_64_r.__ll = __bswap_constant_64 (x);			\
>+     unsigned long long int __bswap_64_x = (x);				\
>+     if (__builtin_constant_p (__bswap_64_x))				\
>+       __bswap_64_r.__ll = __bswap_constant_64 (__bswap_64_x);		\
>      else								\
>        {								\
>-	 __bswap_64_v.__ll = (x);					\
>+	 __bswap_64_v.__ll = __bswap_64_x;				\
> 	 __bswap_64_r.__l[0] = __bswap_32 (__bswap_64_v.__l[1]);	\
> 	 __bswap_64_r.__l[1] = __bswap_32 (__bswap_64_v.__l[0]);	\
>        }								\


Aurelien Jarno dixit:

>Other architectures don't have this problem with byteswap.h

I see. I didnât know that for sure, so I suggested that in
general someone should look at it.

bye,
//mirabilos

PS: Please fix your MTA; hall.aurel32.net is sending 8-bit
    data to a receiving MTA that does not announce 8BITMIME
    support in its EHLO response. Or your MUA to use Quoted-
    Printable by default.
-- 
âIt is inappropriate to require that a time represented as
 seconds since the Epoch precisely represent the number of
 seconds between the referenced time and the Epoch.â
	-- IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]