[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFH: segfault on s390x (hyperestraier)



On Sat, 18 Aug 2012 05:39:07 -0400 (EDT), Philipp Kern wrote:
> On Fri, Aug 17, 2012 at 07:11:26PM +0900, Satoru KURASHIKI wrote:
>> This segfault occurs only on s390x, so I guess it is some of platform
>> specific one. Are there any pattern or best practice about such problems?
> 
> Casts of pointers usually are a problem.  Like casting size_t* to int*
> and vice versa.
> 
> Kind regards
> Philipp Kern
> 
> PS: The liberal use of casts from (unsigned) char* to int* does not make me
> that happy.  Like «return (int *)"";»…

On a related subject, Satoru, s390 and s390x are "big-endian"
machine architectures, whereas most computers, including i386
and amd64, are "little-endian" architectures.  That is to say
that s390 and s390x store integers in storage with the high-order
byte at the low address and the low-order byte at the high
address.  For example, the decimal number 19,088,743, when
converted to a 32-bit binary integer and expressed in hexadecimal
notation, is 01234567.  When that number is in a register, both
on amd64 and s390x, it is stored with the high-order byte on the
left, the next high-order byte adjacent to that, and so on,
with the low-order byte on the right.  But when the number is
stored into RAM, the two architectures do it differently.
On s390x, the number is stored in big-endian format, with the
high-order byte at the lowest storage address and the low-order
byte at the highest storage address: 01 23 45 67.  amd64 stores
the bytes in RAM in reverse order: 67 45 23 01.  This is
"little-endian" format.  Sometimes hidden assumptions of little-
endian format creep into programs that cause them to not work
properly on s390x.

-- 
  .''`.     Stephen Powell    
 : :'  :
 `. `'`
   `-


Reply to: