9fans archive / 1995 / 09 / 92 /    prev next

From: Steve Hemminger sch@pos...
Subject: botch on long long byte order
Date: Wed, 6 Sep 1995 18:32:20 -0400

Order of elements in Length union is incorrect:

:Program to demonstrate:
-------------
#include <u.h>
#include <libc.h>

Length l;

void main(int argc, char *argv[]) {
	USED(argc, argv);

	l.length = 1; 
	l.hlength=0;

	print("should be 1 is %lld\n", l.vlength);

	l.hlength = 1;
	l.length = 0;
	print("should be 0x100000000 is %ullx\n", l.vlength);

	l.vlength = 1;

	print("should be 1 (0/1) is %lld (%ld/%ld)\n",
	      l.vlength, l.hlength, l.length);
}

: I get
-------------
should be 1 is 4294967296
should be 0x100000000 is 1
should be 1 (0/1) is 1 (1/0)
-------------

WARNING: putting them in the correct order (/386/include/u.h)
will mean rebuilding the world though since the file system is byte
order independant, the disk does not need to be reloaded.