1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Description: Handle endians
The original code assumes that data are stored in little endian.
We need to convert it to host endian to let big endian machines build.
Author: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
Last-Update: 2019-01-17
Index: tgl-2.0.1+git20160323.ffb04cac/generate.c
===================================================================
--- tgl-2.0.1+git20160323.ffb04cac.orig/generate.c
+++ tgl-2.0.1+git20160323.ffb04cac/generate.c
@@ -38,6 +38,8 @@
#include <string.h>
#include <errno.h>
+#include <endian.h>
+
#if defined(_MSC_VER) || defined(__MINGW32__)
/* Find the length of STRING, but scan at most MAXLEN characters.
@@ -120,15 +122,17 @@ int skip_only = 1;
int verbosity;
int get_int (void) {
+ int ret;
assert (buf_ptr < buf_end);
- return *(buf_ptr ++);
+ ret = *(buf_ptr ++);
+ return le32toh(ret);
}
long long get_long (void) {
assert (buf_ptr + 1 < buf_end);
long long r = *(long long *)buf_ptr;
buf_ptr += 2;
- return r;
+ return le64toh(r);
}
static void *malloc0 (int size) {
|