Re: unsigned char vs. signed char
On Tue, 15 Jul 2014 10:40:10 -0600 Orion Poplawski or...@cora.nwra.com wrote: Did you know that char defaults to signed char on x86 but unsigned char on ppc and arm? I didn't. Children these days... This variety existed since the 80s. PDP-11 was signed, IBM 370 - unsigned. -- Pete -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Re: unsigned char vs. signed char
On 07/15/2014 07:22 PM, Adam Jackson wrote: On Tue, 2014-07-15 at 10:40 -0600, Orion Poplawski wrote: Did you know that char defaults to signed char on x86 but unsigned char on ppc and arm? I didn't. Yep, found that out the hard way. It annoyed me enough that I went digging in the gcc source to find the answer for all platforms: http://ajax.fedorapeople.org/is-char-signed-or-not.txt Any idea why aarch64 and ppc64le got this wrong? (Signed chars were at the top of my list of proposed ABI fixes for ppc64le. *sigh*) -- Florian Weimer / Red Hat Product Security -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Re: unsigned char vs. signed char
On Wed, Jul 16, 2014 at 10:55:57AM +0200, Florian Weimer wrote: On 07/15/2014 07:22 PM, Adam Jackson wrote: On Tue, 2014-07-15 at 10:40 -0600, Orion Poplawski wrote: Did you know that char defaults to signed char on x86 but unsigned char on ppc and arm? I didn't. Yep, found that out the hard way. It annoyed me enough that I went digging in the gcc source to find the answer for all platforms: http://ajax.fedorapeople.org/is-char-signed-or-not.txt Any idea why aarch64 and ppc64le got this wrong? Why is char == unsigned char wrong? Because i?86/x86_64 do it differently? The decision for whether char is signed or unsigned historically is about what is more efficient in the ISA, of course once it goes into the ABI, it is part of the ABI. The reason aarch64 chose to use unsigned is most likely because it has ARM roots, which has unsigned char too. And similarly for ppc64le. Jakub -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Re: unsigned char vs. signed char
On 07/16/2014 11:00 AM, Jakub Jelinek wrote: On Wed, Jul 16, 2014 at 10:55:57AM +0200, Florian Weimer wrote: On 07/15/2014 07:22 PM, Adam Jackson wrote: On Tue, 2014-07-15 at 10:40 -0600, Orion Poplawski wrote: Did you know that char defaults to signed char on x86 but unsigned char on ppc and arm? I didn't. Yep, found that out the hard way. It annoyed me enough that I went digging in the gcc source to find the answer for all platforms: http://ajax.fedorapeople.org/is-char-signed-or-not.txt Any idea why aarch64 and ppc64le got this wrong? Why is char == unsigned char wrong? Because i?86/x86_64 do it differently? Yes, it looks like a totally avoidable portability hazard. iOS has signed chars as well, so even when considering current ARM, the natural choice is unclear. Older ARMs couldn't perform sign-extending 8-bit loads in a single instruction, but that's true for historic x86, too, and yet even the old 16-bit compilers used signed chars. History aside, I assumed that the idea behind both architectures (aarch64 and ppc64le) is to use it to run current general-purpose server loads, and those are predominantly x86 right now. That's why picking unsigned chars puzzles me. -- Florian Weimer / Red Hat Product Security -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Re: unsigned char vs. signed char
On 16 July 2014 10:28, Florian Weimer fwei...@redhat.com wrote: On 07/16/2014 11:00 AM, Jakub Jelinek wrote: On Wed, Jul 16, 2014 at 10:55:57AM +0200, Florian Weimer wrote: On 07/15/2014 07:22 PM, Adam Jackson wrote: On Tue, 2014-07-15 at 10:40 -0600, Orion Poplawski wrote: Did you know that char defaults to signed char on x86 but unsigned char on ppc and arm? I didn't. Yep, found that out the hard way. It annoyed me enough that I went digging in the gcc source to find the answer for all platforms: http://ajax.fedorapeople.org/is-char-signed-or-not.txt Any idea why aarch64 and ppc64le got this wrong? Why is char == unsigned char wrong? Because i?86/x86_64 do it differently? Yes, it looks like a totally avoidable portability hazard. iOS has signed chars as well, so even when considering current ARM, the natural choice is unclear. Older ARMs couldn't perform sign-extending 8-bit loads in a single instruction, but that's true for historic x86, too, and yet even the old 16-bit compilers used signed chars. History aside, I assumed that the idea behind both architectures (aarch64 and ppc64le) is to use it to run current general-purpose server loads, and those are predominantly x86 right now. That's why picking unsigned chars puzzles me. Implementation defined in all iterations of the C standard. End of story really. -- imalone http://ibmalone.blogspot.co.uk -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
unsigned char vs. signed char
Did you know that char defaults to signed char on x86 but unsigned char on ppc and arm? I didn't. Just a heads up. -- Orion Poplawski Technical Manager 303-415-9701 x222 NWRA, Boulder/CoRA Office FAX: 303-415-9702 3380 Mitchell Lane or...@nwra.com Boulder, CO 80301 http://www.nwra.com -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Re: unsigned char vs. signed char
According the standard, char is supposed to be a distinct type from signed/unsigned char. btw, most commonly-used compilers (gcc, msvc, etc.) does use these defaults, but you can't even assume that for every compilers. If one wants to check the signedness of char, she could check CHAR_MIN is equal to zero or SCHAR_MIN (from limits.h) Regards, H. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Re: unsigned char vs. signed char
On Tue, 2014-07-15 at 10:40 -0600, Orion Poplawski wrote: Did you know that char defaults to signed char on x86 but unsigned char on ppc and arm? I didn't. Yep, found that out the hard way. It annoyed me enough that I went digging in the gcc source to find the answer for all platforms: http://ajax.fedorapeople.org/is-char-signed-or-not.txt - ajax -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Re: unsigned char vs. signed char
On 7/15/14, 11:40 AM, Orion Poplawski wrote: Did you know that char defaults to signed char on x86 but unsigned char on ppc and arm? I didn't. Just a heads up. I did, because due to XFS's history, it maked an assumption that's not true on x86. We had -funsigned-char in the Makefile up until around 2010, when we finally decided that the code was clean without it. :) -Eric -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct