Skip to content

Commit d432b18

Browse files
committed
[BOX32][WRAPPER] Added 32bits wrapped libxcb
1 parent 98c0811 commit d432b18

14 files changed

+1085
-10
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ if(BOX32)
835835
"${BOX64_ROOT}/src/wrapped32/wrappedxinerama.c"
836836
"${BOX64_ROOT}/src/wrapped32/wrappedexpat.c"
837837
"${BOX64_ROOT}/src/wrapped32/wrappedlibx11xcb.c"
838+
"${BOX64_ROOT}/src/wrapped32/wrappedlibxcb.c"
838839
"${BOX64_ROOT}/src/wrapped32/wrappedudev0.c"
839840
"${BOX64_ROOT}/src/wrapped32/wrappedudev1.c"
840841
"${BOX64_ROOT}/src/wrapped32/wrappedlibuuid.c"

rebuild_wrappers_32.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1204,8 +1204,8 @@ def generate_files(root: str, files: Iterable[str], ver: str, gbls: SortedGlobal
12041204
CType[(value, CType.ReadWrite.none)].asarg = asarg
12051205
CType[(value, CType.ReadWrite.none)].aspost = ""
12061206
if value == 'n':
1207-
CType[(value, CType.ReadWrite.none)].aspre = f"void *aligned_xcb = align_xcb_connection32(from_ptrv(R_ESP + {{p}})); "
1208-
CType[(value, CType.ReadWrite.none)].aspost = f" unalign_xcb_connection32(aligned_xcb, from_ptrv(R_ESP + {{p}}));"
1207+
CType[(value, CType.ReadWrite.none)].aspre = f"void *aligned_xcb = align_xcb_connection32(from_ptriv(R_ESP + {{p}})); "
1208+
CType[(value, CType.ReadWrite.none)].aspost = f" unalign_xcb_connection32(aligned_xcb, from_ptriv(R_ESP + {{p}}));"
12091209
for ctn in CType.getSingletons():
12101210
CType[ctn].generate_converters()
12111211

src/library_list_32.h

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ GO("libXinerama.so.1", xinerama)
6161

6262
GO("libX11-xcb.so.1", libx11xcb)
6363
GO("libX11-xcb.so", libx11xcb)
64+
GO("libxcb.so.1", libxcb)
65+
GO("libxcb.so", libxcb)
6466

6567
GO("libopenal.so.1", openal)
6668
GO("libopenal.so.0", openal)

src/libtools/myalignxcb32.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ typedef struct my_xcb_connection_32_s {
7272

7373
#define NXCB 8
7474
static my_xcb_connection_t* my_xcb_connects[NXCB] = {0};
75-
static my_xcb_connection_32_t x64_xcb_connects[NXCB] = {0};
75+
static my_xcb_connection_32_t i386_xcb_connects[NXCB] = {0};
7676

7777
void* align_xcb_connection32(void* src)
7878
{
@@ -81,7 +81,7 @@ void* align_xcb_connection32(void* src)
8181
// find it
8282
my_xcb_connection_t * dest = NULL;
8383
for(int i=0; i<NXCB && !dest; ++i)
84-
if(src==&x64_xcb_connects[i])
84+
if(src==&i386_xcb_connects[i])
8585
dest = my_xcb_connects[i];
8686
#if 1
8787
if(!dest)
@@ -180,15 +180,15 @@ void* add_xcb_connection32(void* src)
180180
// check if already exist
181181
for(int i=0; i<NXCB; ++i)
182182
if(my_xcb_connects[i] == src) {
183-
unalign_xcb_connection32(src, &x64_xcb_connects[i]);
184-
return &x64_xcb_connects[i];
183+
unalign_xcb_connection32(src, &i386_xcb_connects[i]);
184+
return &i386_xcb_connects[i];
185185
}
186186
// find a free slot
187187
for(int i=0; i<NXCB; ++i)
188188
if(!my_xcb_connects[i]) {
189189
my_xcb_connects[i] = src;
190-
unalign_xcb_connection32(src, &x64_xcb_connects[i]);
191-
return &x64_xcb_connects[i];
190+
unalign_xcb_connection32(src, &i386_xcb_connects[i]);
191+
return &i386_xcb_connects[i];
192192
}
193193
printf_log(LOG_NONE, "BOX64: Error, no more free xcb_connect 32bits slot for %p\n", src);
194194
return src;
@@ -200,9 +200,9 @@ void del_xcb_connection32(void* src)
200200
return;
201201
// find it
202202
for(int i=0; i<NXCB; ++i)
203-
if(src==&x64_xcb_connects[i]) {
203+
if(src==&i386_xcb_connects[i]) {
204204
my_xcb_connects[i] = NULL;
205-
memset(&x64_xcb_connects[i], 0, sizeof(my_xcb_connection_32_t));
205+
memset(&i386_xcb_connects[i], 0, sizeof(my_xcb_connection_32_t));
206206
return;
207207
}
208208
printf_log(LOG_NONE, "BOX64: Error, 32bits xcb_connect %p not found for deletion\n", src);

src/wrapped32/generated/converter32.c

+58
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,22 @@ void to_struct_LLLLLLLLLLLLLLLLLL(ptr_t d, const struct_LLLLLLLLLLLLLLLLLL_t *sr
194194
*(ulong_t*)dest = to_ulong(src->L17); dest += 4;
195195
}
196196

197+
void from_struct_LpCC(struct_LpCC_t *dest, ptr_t s) {
198+
uint8_t* src = (uint8_t*)from_ptrv(s);
199+
dest->L0 = from_ulong(*(ulong_t*)src); src += 4;
200+
dest->p1 = from_ptrv(*(ptr_t*)src); src += 4;
201+
dest->C2 = *(uint8_t*)src; src += 1;
202+
dest->C3 = *(uint8_t*)src; src += 1;
203+
}
204+
void to_struct_LpCC(ptr_t d, const struct_LpCC_t *src) {
205+
if (!src) return;
206+
uint8_t* dest = (uint8_t*)from_ptrv(d);
207+
*(ulong_t*)dest = to_ulong(src->L0); dest += 4;
208+
*(ptr_t*)dest = to_ptrv(src->p1); dest += 4;
209+
*(uint8_t*)dest = src->C2; dest += 1;
210+
*(uint8_t*)dest = src->C3; dest += 1;
211+
}
212+
197213
void from_struct_h(struct_h_t *dest, ptr_t s) {
198214
uint8_t* src = (uint8_t*)from_ptrv(s);
199215
dest->h0 = from_hash(*(ulong_t*)src); src += 4;
@@ -214,6 +230,18 @@ void to_struct_H(ptr_t d, const struct_H_t *src) {
214230
*(ulong_t*)dest = to_hash_d(src->H0); dest += 4;
215231
}
216232

233+
void from_struct_pL(struct_pL_t *dest, ptr_t s) {
234+
uint8_t* src = (uint8_t*)from_ptrv(s);
235+
dest->p0 = from_ptrv(*(ptr_t*)src); src += 4;
236+
dest->L1 = from_ulong(*(long_t*)src); src += 4;
237+
}
238+
void to_struct_pL(ptr_t d, const struct_pL_t *src) {
239+
if (!src) return;
240+
uint8_t* dest = (uint8_t*)from_ptrv(d);
241+
*(ptr_t*)dest = to_ptrv(src->p0); dest += 4;
242+
*(ulong_t*)dest = to_ulong(src->L1); dest += 4;
243+
}
244+
217245
void from_struct_ppppii(struct_ppppii_t *dest, ptr_t s) {
218246
uint8_t* src = (uint8_t*)from_ptrv(s);
219247
dest->p0 = from_ptrv(*(ptr_t*)src); src += 4;
@@ -551,6 +579,20 @@ void to_struct_puu(ptr_t d, const struct_puu_t *src) {
551579
*(uint32_t*)dest = src->u2; dest += 4;
552580
}
553581

582+
void from_struct_pii(struct_pii_t *dest, ptr_t s) {
583+
uint8_t* src = (uint8_t*)from_ptrv(s);
584+
dest->p0 = from_ptrv(*(ptr_t*)src); src += 4;
585+
dest->i1 = *(int*)src; src += 4;
586+
dest->i2 = *(int*)src; src += 4;
587+
}
588+
void to_struct_pii(ptr_t d, const struct_pii_t *src) {
589+
if (!src) return;
590+
uint8_t* dest = (uint8_t*)from_ptrv(d);
591+
*(ptr_t*)dest = to_ptrv(src->p0); dest += 4;
592+
*(int*)dest = src->i1; dest += 4;
593+
*(int*)dest = src->i2; dest += 4;
594+
}
595+
554596
void from_struct_piiL(struct_piiL_t *dest, ptr_t s) {
555597
uint8_t* src = (uint8_t*)from_ptrv(s);
556598
dest->p0 = from_ptrv(*(ptr_t*)src); src += 4;
@@ -567,6 +609,22 @@ void to_struct_piiL(ptr_t d, const struct_piiL_t *src) {
567609
*(ulong_t*)dest = to_ulong(src->L3); dest += 4;
568610
}
569611

612+
void from_struct_ipip(struct_ipip_t *dest, ptr_t s) {
613+
uint8_t* src = (uint8_t*)from_ptrv(s);
614+
dest->i0 = *(int*)src; src += 4;
615+
dest->p1 = from_ptrv(*(ptr_t*)src); src += 4;
616+
dest->i2 = *(int*)src; src += 4;
617+
dest->p3 = from_ptrv(*(ptr_t*)src); src += 4;
618+
}
619+
void to_struct_ipip(ptr_t d, const struct_ipip_t *src) {
620+
if (!src) return;
621+
uint8_t* dest = (uint8_t*)from_ptrv(d);
622+
*(int*)dest = src->i0; dest += 4;
623+
*(ptr_t*)dest = to_ptrv(src->p1); dest += 4;
624+
*(int*)dest = src->i2; dest += 4;
625+
*(ptr_t*)dest = to_ptrv(src->p3); dest += 4;
626+
}
627+
570628
void from_struct_piip(struct_piip_t *dest, ptr_t s) {
571629
uint8_t* src = (uint8_t*)from_ptrv(s);
572630
dest->p0 = from_ptrv(*(ptr_t*)src); src += 4;

src/wrapped32/generated/converter32.h

+29
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ typedef struct struct_LLLLLLLLLLLLLLLLLL_s {
9696
} struct_LLLLLLLLLLLLLLLLLL_t;
9797
void from_struct_LLLLLLLLLLLLLLLLLL(struct_LLLLLLLLLLLLLLLLLL_t *dest, ptr_t src);
9898
void to_struct_LLLLLLLLLLLLLLLLLL(ptr_t dest, const struct_LLLLLLLLLLLLLLLLLL_t *src);
99+
typedef struct struct_LpCC_s {
100+
unsigned long L0;
101+
void* p1;
102+
uint8_t C2;
103+
uint8_t C3;
104+
} struct_LpCC_t;
105+
void from_struct_LpCC(struct_LpCC_t *dest, ptr_t src);
106+
void to_struct_LpCC(ptr_t dest, const struct_LpCC_t *src);
99107
typedef struct struct_h_s {
100108
uintptr_t h0;
101109
} struct_h_t;
@@ -106,6 +114,12 @@ typedef struct struct_H_s {
106114
} struct_H_t;
107115
void from_struct_H(struct_H_t *dest, ptr_t src);
108116
void to_struct_H(ptr_t dest, const struct_H_t *src);
117+
typedef struct struct_pL_s {
118+
void* p0;
119+
unsigned long L1;
120+
} struct_pL_t;
121+
void from_struct_pL(struct_pL_t *dest, ptr_t src);
122+
void to_struct_pL(ptr_t dest, const struct_pL_t *src);
109123
typedef struct struct_ppppii_s {
110124
void* p0;
111125
void* p1;
@@ -277,6 +291,13 @@ typedef struct struct_puu_s {
277291
} struct_puu_t;
278292
void from_struct_puu(struct_puu_t *dest, ptr_t src);
279293
void to_struct_puu(ptr_t dest, const struct_puu_t *src);
294+
typedef struct struct_pii_s {
295+
void* p0;
296+
int i1;
297+
int i2;
298+
} struct_pii_t;
299+
void from_struct_pii(struct_pii_t *dest, ptr_t src);
300+
void to_struct_pii(ptr_t dest, const struct_pii_t *src);
280301
typedef struct struct_piiL_s {
281302
void* p0;
282303
int i1;
@@ -299,6 +320,14 @@ typedef struct struct_ppup_s {
299320
uint32_t u2;
300321
void* p3;
301322
} struct_ppup_t;
323+
typedef struct struct_ipip_s {
324+
int i0;
325+
void* p1;
326+
int i2;
327+
void* p3;
328+
} struct_ipip_t;
329+
void from_struct_ipip(struct_ipip_t *dest, ptr_t src);
330+
void to_struct_ipip(ptr_t dest, const struct_ipip_t *src);
302331
void from_struct_ppup(struct_ppup_t *dest, ptr_t src);
303332
void to_struct_ppup(ptr_t dest, const struct_ppup_t *src);
304333
typedef struct struct_iiiiiLi_s {

0 commit comments

Comments
 (0)