shithub: riscv

Download patch

ref: cf74c80e7b38a6ae521da16d4bdf84783ef320e7
parent: 0b48d5fdbfd91033765acbbc66e820a363a5d660
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Aug 16 09:41:14 EDT 2015

6l: fix vlong byte order when running on big endian machine (thanks erik quanstro)

--- a/sys/src/cmd/6l/l.h
+++ b/sys/src/cmd/6l/l.h
@@ -354,6 +354,7 @@
 void	errorexit(void);
 void	export(void);
 int	find1(long, int);
+int	find1v(vlong, int);
 int	find2(long, int);
 void	follow(void);
 void	gethunk(void);
--- a/sys/src/cmd/6l/obj.c
+++ b/sys/src/cmd/6l/obj.c
@@ -1417,12 +1417,14 @@
 		if(i < 1)
 			inuxi1[i] = c;
 		inuxi4[i] = c;
-		inuxi8[i] = c;
-		inuxi8[i+4] = c+4;
 		fnuxi4[i] = c;
 		fnuxi8[i] = c;
 		fnuxi8[i+4] = c+4;
 	}
+
+	for(i=0; i<8; i++)
+		inuxi8[i] = find1v(0x0807060504030201LL, i+1);
+
 	if(debug['v']) {
 		Bprint(&bso, "inuxi = ");
 		for(i=0; i<1; i++)
@@ -1455,6 +1457,19 @@
 
 	p = (char*)&l;
 	for(i=0; i<4; i++)
+		if(*p++ == c)
+			return i;
+	return 0;
+}
+
+int
+find1v(vlong l, int c)
+{
+	char *p;
+	int i;
+
+	p = (char*)&l;
+	for(i=0; i<8; i++)
 		if(*p++ == c)
 			return i;
 	return 0;