[package] libnl: fix compilation with eglibc (closes: #4785)
[openwrt.git] / package / lua / patches / 030-archindependent-bytecode.patch
1 Index: lua-5.1.4/src/ldump.c
2 ===================================================================
3 --- lua-5.1.4.orig/src/ldump.c 2008-08-24 16:48:20.000000000 +0200
4 +++ lua-5.1.4/src/ldump.c 2008-08-24 16:48:52.000000000 +0200
5 @@ -67,12 +67,12 @@
6 {
7 if (s==NULL || getstr(s)==NULL)
8 {
9 - size_t size=0;
10 + unsigned int size=0;
11 DumpVar(size,D);
12 }
13 else
14 {
15 - size_t size=s->tsv.len+1; /* include trailing '\0' */
16 + unsigned int size=s->tsv.len+1; /* include trailing '\0' */
17 DumpVar(size,D);
18 DumpBlock(getstr(s),size,D);
19 }
20 Index: lua-5.1.4/src/lundump.c
21 ===================================================================
22 --- lua-5.1.4.orig/src/lundump.c 2008-08-24 16:48:20.000000000 +0200
23 +++ lua-5.1.4/src/lundump.c 2008-08-24 16:48:52.000000000 +0200
24 @@ -25,6 +25,7 @@
25 ZIO* Z;
26 Mbuffer* b;
27 const char* name;
28 + int swap;
29 } LoadState;
30
31 #ifdef LUAC_TRUST_BINARIES
32 @@ -40,7 +41,6 @@
33 }
34 #endif
35
36 -#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
37 #define LoadByte(S) (lu_byte)LoadChar(S)
38 #define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
39 #define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
40 @@ -51,6 +51,49 @@
41 IF (r!=0, "unexpected end");
42 }
43
44 +static void LoadMem (LoadState* S, void* b, int n, size_t size)
45 +{
46 + LoadBlock(S,b,n*size);
47 + if (S->swap)
48 + {
49 + char* p=(char*) b;
50 + char c;
51 + switch (size)
52 + {
53 + case 1:
54 + break;
55 + case 2:
56 + while (n--)
57 + {
58 + c=p[0]; p[0]=p[1]; p[1]=c;
59 + p+=2;
60 + }
61 + break;
62 + case 4:
63 + while (n--)
64 + {
65 + c=p[0]; p[0]=p[3]; p[3]=c;
66 + c=p[1]; p[1]=p[2]; p[2]=c;
67 + p+=4;
68 + }
69 + break;
70 + case 8:
71 + while (n--)
72 + {
73 + c=p[0]; p[0]=p[7]; p[7]=c;
74 + c=p[1]; p[1]=p[6]; p[6]=c;
75 + c=p[2]; p[2]=p[5]; p[5]=c;
76 + c=p[3]; p[3]=p[4]; p[4]=c;
77 + p+=8;
78 + }
79 + break;
80 + default:
81 + IF(1, "bad size");
82 + break;
83 + }
84 + }
85 +}
86 +
87 static int LoadChar(LoadState* S)
88 {
89 char x;
90 @@ -82,7 +125,7 @@
91
92 static TString* LoadString(LoadState* S)
93 {
94 - size_t size;
95 + unsigned int size;
96 LoadVar(S,size);
97 if (size==0)
98 return NULL;
99 @@ -196,6 +239,7 @@
100 char s[LUAC_HEADERSIZE];
101 luaU_header(h);
102 LoadBlock(S,s,LUAC_HEADERSIZE);
103 + S->swap=(s[6]!=h[6]); s[6]=h[6];
104 IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
105 }
106
107 @@ -230,7 +274,7 @@
108 *h++=(char)LUAC_FORMAT;
109 *h++=(char)*(char*)&x; /* endianness */
110 *h++=(char)sizeof(int);
111 - *h++=(char)sizeof(size_t);
112 + *h++=(char)sizeof(unsigned int);
113 *h++=(char)sizeof(Instruction);
114 *h++=(char)sizeof(lua_Number);
115
This page took 0.047157 seconds and 5 git commands to generate.