about summary refs log tree commit diff stats
path: root/src/wrapped32/wrappedlibxcb.c
blob: 47bc12e122d2ee8cbd7f68cd4232ea4b528de1e9 (plain) (blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE         /* See feature_test_macros(7) */
#include <dlfcn.h>

#include "wrappedlibs.h"

#include "debug.h"
#include "wrapper32.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "callback.h"
#include "librarian.h"
#include "box32context.h"
#include "emu/x64emu_private.h"
#include "myalign32.h"
#include "converter32.h"

static const char* libxcbName = "libxcb.so.1";
#define ALTNAME "libxcb.so"

#define LIBNAME libxcb

typedef struct my_xcb_XXX_iterator_s {
    void*             data;
    int               rem;
    int               index;
} my_xcb_XXX_iterator_t;

typedef struct my_xcb_XXX_iterator_32_s {
    ptr_t             data;
    int               rem;
    int               index;
} my_xcb_XXX_iterator_32_t;

typedef struct my_xcb_cookie_s {
    uint32_t        data;
} my_xcb_cookie_t;

typedef my_xcb_cookie_t (*zFppp_t)(void*, void*, void*);
typedef my_xcb_cookie_t (*zFpCWp_t)(void*, uint8_t, uint16_t, void*);
typedef my_xcb_cookie_t (*zFpCuuuuu_t)(void*, uint8_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
typedef my_xcb_cookie_t (*zFpCuuuCup_t)(void*, uint8_t, uint32_t, uint32_t, uint32_t, uint8_t, uint32_t, void*);
typedef my_xcb_XXX_iterator_t (*ZFp_t)(void*);

#define ADDED_FUNCTIONS()       				\
GO(xcb_change_property, zFpCuuuCup_t)           \
GO(xcb_delete_property, zFppp_t)                \
GO(xcb_get_property, zFpCuuuuu_t)               \
GO(xcb_intern_atom, zFpCWp_t)                   \
GO(xcb_setup_roots_iterator, ZFp_t)             \

#include "generated/wrappedlibxcbtypes32.h"

#include "wrappercallback32.h"

EXPORT void* my32_xcb_connect(x64emu_t* emu, void* dispname, void* screen)
{
	return add_xcb_connection32(my->xcb_connect(dispname, screen));
}

EXPORT void my32_xcb_disconnect(x64emu_t* emu, void* conn)
{
	my->xcb_disconnect(align_xcb_connection32(conn));
	del_xcb_connection32(conn);
}

#define SUPER(F, P, ...)           \
    EXPORT void* my32_##F P        \
    {                              \
        (void)emu;                 \
        *ret = my->F(__VA_ARGS__); \
        return ret;                \
    }

SUPER(xcb_change_property, (x64emu_t* emu, my_xcb_cookie_t* ret, void* c, uint8_t mode, uint32_t w, uint32_t prop, uint32_t type, uint8_t f, uint32_t len, void* data), c, mode, w, prop, type, f, len, data)
SUPER(xcb_delete_property, (x64emu_t* emu, my_xcb_cookie_t* ret, void* c, void* w, void* p), c, w, p)
SUPER(xcb_get_property, (x64emu_t* emu, my_xcb_cookie_t* ret, void* c, uint8_t _del, uint32_t w, uint32_t p, uint32_t type, uint32_t off, uint32_t len), c, _del, w, p, type, off, len)
SUPER(xcb_intern_atom, (x64emu_t* emu, my_xcb_cookie_t* ret, void* c, uint8_t only, uint16_t len, void* name), c, only, len, name)

#undef SUPER

#define SUPER(F)           		   												\
    EXPORT void* my32_##F(x64emu_t* emu, my_xcb_XXX_iterator_32_t* ret, void* R)\
    {                              												\
        (void)emu;       														\
		my_xcb_XXX_iterator_t ret_l = my->F(R);									\
        ret->data = to_ptrv(ret_l.data); 										\
        ret->rem = ret_l.rem; 													\
        ret->index = ret_l.index; 												\
        return ret;      														\
    }

SUPER(xcb_setup_roots_iterator)

#undef SUPER

#if 0
#ifdef ANDROID
#define NEEDED_LIBS "libXau.so", "libXdmcp.so"
#else
#define NEEDED_LIBS "libXau.so.6", "libXdmcp.so.6"
#endif
#endif

#include "wrappedlib_init32.h"