[PATCH]: Fix GLX crashes on RISC cpus.

David Miller davem at davemloft.net
Thu Dec 27 16:37:22 PST 2007


From: Jaymz Julian <jaymz at artificial-stupidity.net>
Date: Thu, 27 Dec 2007 22:35:34 +1100

>  int main()
>  {
>      char foop[5];
>      int *fleep=(int *)(foop+1)
>      int j;
>      foop[0]=0;
>      fleep=0x12345678;
>      j=*(int *)foop;
>      return (j==0x00123456 || j==0x00785634);
>   }

FWIW, the one I came up with was:

int main(void)
{
	union {
		unsigned int val;
		unsigned char val_bytes[4];
	} endian_test;
	unsigned short *p;
	unsigned int test_val;
	int big_endian = 0;

	endian_test.val = 0x01020304;
	if (endian_test.val_bytes[0] == 0x01)
		big_endian = 1;

	p = (unsigned short *) &endian_test.val_bytes[1];
	*p = 0x0506;

	if (big_endian)
		test_val = 0x01050604;
	else
		test_val = 0x01060504;

	if (endian_test.val != test_val)
		return 1;

	return 0;
}



More information about the xorg mailing list