From 5320b4f22fcb8894c81d698ee48a87d7e97b165a Mon Sep 17 00:00:00 2001 From: rajdakin Date: Tue, 13 Apr 2021 22:14:41 +0200 Subject: [PATCH 1/3] Added some documentation --- rebuild_wrappers.py | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/rebuild_wrappers.py b/rebuild_wrappers.py index f763eed049..b88d403dcf 100755 --- a/rebuild_wrappers.py +++ b/rebuild_wrappers.py @@ -3,6 +3,57 @@ import os import sys +""" +Generates all files in src/wrapped/generated +=== + +TL;DR: Automagically creates type definitions (/.F.+/ functions/typedefs...). + All '//%' in the headers are used by the script. + +Reads each lines of each "_private.h" headers (plus wrappedd3dadapter9_gen.h as a special case). +For each of them: +- If if starts with a #ifdef, #else, #ifndef, #endif, it memorizes which definition is required +- If it starts with a "GO", it will do multiple things: + - It memorizes the type used by the function (second macro argument) + - It memorizes the type it is mapped to, if needed (eg, iFEv is mapped to iFE: the second argument is dropped) + - It checks if the type given (both original and ) + - If the signature contains a 'E', it will memorize the original function's signature: + - If it is the special file case, or if the line contains "//%%", it stops there. + - Otherwise, if it starts with "GOS": + - It will search for the special marker "//%". + That special marker is used to detect the following step: + - If the marker is followed by a registered structure ID (see later), it transforms the assembly function signature + into the original signature (eg, transforms pFEp into XFv if //%X was used) + - If the marker is followed by a '{', it will not attempt to alter the given signature, and instead use the + signature between '{' and '}' + - Otherwise, if the line contains '//%{', like before it will use the signature given and not the original one. + - Finally, if it still didn't stop, it will use the assembly signature (without the emulator). +- If the line starts with a '//%' + +`gbl` contains the first list, `redirects` the second, `mytypedefs` the third. +`mystructs` and `mystructs_vals` constains data about the structures. + +After sorting the data, it generates: + +wrapper.c +--------- +(Private) type definitions (/.F.+_t/) +Function definitions (/.F.+/ functions, that actually execute the function given as argument) +isSimpleWrapper definition + +wrapper.h +--------- +Generic "wrapper_t" type definition +Function declarations (/.F.+/ functions) + +*types.h +-------- +Local types definition, for the original signatures (eg, XFv for the earlier example) +The SUPER() macro definition, used to generate and initialize the `*_my_t` library structure +(TODO: also automate this declaration/definition? It would require more metadata, + and may break sometime in the future due to the system changing...) +""" + # Free values: # AB F H J QR T XYZab gh jk mno qrst xyz values = ['E', 'e', 'v', 'c', 'w', 'i', 'I', 'C', 'W', 'u', 'U', 'f', 'd', 'D', 'K', 'l', 'L', 'p', 'V', 'O', 'S', '2', 'P', 'G', 'N', 'M'] @@ -48,6 +99,7 @@ def main(root, defines, files, ver): mystructs_vals = {} # First read the files inside the headers + # TODO: remove the special case... for filepath in files + [os.path.join(root, "src", "wrapped", "wrappedd3dadapter9_gen.h")]: filename = filepath.split("/")[-1] dependants = [] From 307a4f5010a2f64694329b9116f6515f7a8f1ac7 Mon Sep 17 00:00:00 2001 From: rajdakin Date: Tue, 13 Apr 2021 22:15:11 +0200 Subject: [PATCH 2/3] Automated libbz2 and libcrypto --- src/wrapped/generated/functions_list.txt | 3 ++- src/wrapped/generated/wrappedcryptotypes.h | 2 ++ src/wrapped/generated/wrapper.c | 4 ++-- src/wrapped/generated/wrapper.h | 2 +- src/wrapped/wrappedbz2.c | 14 +---------- src/wrapped/wrappedcrypto.c | 27 +++------------------- src/wrapped/wrappedcrypto_private.h | 12 +++++----- src/wrapped/wrappedlibjpeg62_private.h | 4 ++-- src/wrapped/wrappedlibjpeg_private.h | 4 +--- src/wrapped/wrappedlibtiff_private.h | 6 ++--- 10 files changed, 23 insertions(+), 55 deletions(-) diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 04af3b9012..1a64cb89c3 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -1268,7 +1268,6 @@ #() iFppUipp #() iFppUupp #() iFppdidd -#() iFpplppi #() iFppLupp #() iFppLpLp #() iFppLppp @@ -1411,6 +1410,7 @@ #() iFEppiuui #() iFEppupIi #() iFEppuppp +#() iFEpplppi #() iFEpppiiu #() iFEpppppp #() iFiiiiiip @@ -1941,6 +1941,7 @@ wrappedcrypto/SupFpppp3PEM_read_bio_EC_PUBKEY wrappedcrypto/SupFpppp3PEM_read_bio_RSAPrivateKey wrappedcrypto/SupFpppp3PEM_read_bio_RSA_PUBKEY wrappedcrypto/SuiFpiipp3ENGINE_ctrl +wrappedcrypto/SuiFpplppi3ENGINE_ctrl_cmd wrappedcrypto/SuiFppppipp3PEM_write_bio_DSAPrivateKey wrappedcrypto/SuiFppppipp3PEM_write_bio_ECPrivateKey wrappedcrypto/SuiFppppipp3PEM_write_bio_RSAPrivateKey diff --git a/src/wrapped/generated/wrappedcryptotypes.h b/src/wrapped/generated/wrappedcryptotypes.h index dd840d8ce2..88d136dd03 100644 --- a/src/wrapped/generated/wrappedcryptotypes.h +++ b/src/wrapped/generated/wrappedcryptotypes.h @@ -16,6 +16,7 @@ typedef void* (*pFp_t)(void*); typedef void (*vFpp_t)(void*, void*); typedef void* (*pFpppp_t)(void*, void*, void*, void*); typedef int32_t (*iFpiipp_t)(void*, int32_t, int32_t, void*, void*); +typedef int32_t (*iFpplppi_t)(void*, void*, intptr_t, void*, void*, int32_t); typedef int32_t (*iFppppipp_t)(void*, void*, void*, void*, int32_t, void*, void*); #define SUPER() ADDED_FUNCTIONS() \ @@ -30,6 +31,7 @@ typedef int32_t (*iFppppipp_t)(void*, void*, void*, void*, int32_t, void*, void* GO(PEM_read_bio_RSAPrivateKey, pFpppp_t) \ GO(PEM_read_bio_RSA_PUBKEY, pFpppp_t) \ GO(ENGINE_ctrl, iFpiipp_t) \ + GO(ENGINE_ctrl_cmd, iFpplppi_t) \ GO(PEM_write_bio_DSAPrivateKey, iFppppipp_t) \ GO(PEM_write_bio_ECPrivateKey, iFppppipp_t) \ GO(PEM_write_bio_RSAPrivateKey, iFppppipp_t) diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 0dd872cf44..3dbed595cc 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -1340,7 +1340,6 @@ typedef int32_t (*iFppuppp_t)(void*, void*, uint32_t, void*, void*, void*); typedef int32_t (*iFppUipp_t)(void*, void*, uint64_t, int32_t, void*, void*); typedef int32_t (*iFppUupp_t)(void*, void*, uint64_t, uint32_t, void*, void*); typedef int32_t (*iFppdidd_t)(void*, void*, double, int32_t, double, double); -typedef int32_t (*iFpplppi_t)(void*, void*, intptr_t, void*, void*, int32_t); typedef int32_t (*iFppLupp_t)(void*, void*, uintptr_t, uint32_t, void*, void*); typedef int32_t (*iFppLpLp_t)(void*, void*, uintptr_t, void*, uintptr_t, void*); typedef int32_t (*iFppLppp_t)(void*, void*, uintptr_t, void*, void*, void*); @@ -1483,6 +1482,7 @@ typedef int32_t (*iFEpUuppp_t)(x86emu_t*, void*, uint64_t, uint32_t, void*, void typedef int32_t (*iFEppiuui_t)(x86emu_t*, void*, void*, int32_t, uint32_t, uint32_t, int32_t); typedef int32_t (*iFEppupIi_t)(x86emu_t*, void*, void*, uint32_t, void*, int64_t, int32_t); typedef int32_t (*iFEppuppp_t)(x86emu_t*, void*, void*, uint32_t, void*, void*, void*); +typedef int32_t (*iFEpplppi_t)(x86emu_t*, void*, void*, intptr_t, void*, void*, int32_t); typedef int32_t (*iFEpppiiu_t)(x86emu_t*, void*, void*, void*, int32_t, int32_t, uint32_t); typedef int32_t (*iFEpppppp_t)(x86emu_t*, void*, void*, void*, void*, void*, void*); typedef int32_t (*iFiiiiiip_t)(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, void*); @@ -3255,7 +3255,6 @@ void iFppuppp(x86emu_t *emu, uintptr_t fcn) { iFppuppp_t fn = (iFppuppp_t)fcn; R void iFppUipp(x86emu_t *emu, uintptr_t fcn) { iFppUipp_t fn = (iFppUipp_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint64_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 20), *(void**)(R_ESP + 24), *(void**)(R_ESP + 28)); } void iFppUupp(x86emu_t *emu, uintptr_t fcn) { iFppUupp_t fn = (iFppUupp_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint64_t*)(R_ESP + 12), *(uint32_t*)(R_ESP + 20), *(void**)(R_ESP + 24), *(void**)(R_ESP + 28)); } void iFppdidd(x86emu_t *emu, uintptr_t fcn) { iFppdidd_t fn = (iFppdidd_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(double*)(R_ESP + 12), *(int32_t*)(R_ESP + 20), *(double*)(R_ESP + 24), *(double*)(R_ESP + 32)); } -void iFpplppi(x86emu_t *emu, uintptr_t fcn) { iFpplppi_t fn = (iFpplppi_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(intptr_t*)(R_ESP + 12), *(void**)(R_ESP + 16), *(void**)(R_ESP + 20), *(int32_t*)(R_ESP + 24)); } void iFppLupp(x86emu_t *emu, uintptr_t fcn) { iFppLupp_t fn = (iFppLupp_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uintptr_t*)(R_ESP + 12), *(uint32_t*)(R_ESP + 16), *(void**)(R_ESP + 20), *(void**)(R_ESP + 24)); } void iFppLpLp(x86emu_t *emu, uintptr_t fcn) { iFppLpLp_t fn = (iFppLpLp_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uintptr_t*)(R_ESP + 12), *(void**)(R_ESP + 16), *(uintptr_t*)(R_ESP + 20), *(void**)(R_ESP + 24)); } void iFppLppp(x86emu_t *emu, uintptr_t fcn) { iFppLppp_t fn = (iFppLppp_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uintptr_t*)(R_ESP + 12), *(void**)(R_ESP + 16), *(void**)(R_ESP + 20), *(void**)(R_ESP + 24)); } @@ -3398,6 +3397,7 @@ void iFEpUuppp(x86emu_t *emu, uintptr_t fcn) { iFEpUuppp_t fn = (iFEpUuppp_t)fcn void iFEppiuui(x86emu_t *emu, uintptr_t fcn) { iFEppiuui_t fn = (iFEppiuui_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(uint32_t*)(R_ESP + 16), *(uint32_t*)(R_ESP + 20), *(int32_t*)(R_ESP + 24)); } void iFEppupIi(x86emu_t *emu, uintptr_t fcn) { iFEppupIi_t fn = (iFEppupIi_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(void**)(R_ESP + 16), *(int64_t*)(R_ESP + 20), *(int32_t*)(R_ESP + 28)); } void iFEppuppp(x86emu_t *emu, uintptr_t fcn) { iFEppuppp_t fn = (iFEppuppp_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(void**)(R_ESP + 16), *(void**)(R_ESP + 20), *(void**)(R_ESP + 24)); } +void iFEpplppi(x86emu_t *emu, uintptr_t fcn) { iFEpplppi_t fn = (iFEpplppi_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(intptr_t*)(R_ESP + 12), *(void**)(R_ESP + 16), *(void**)(R_ESP + 20), *(int32_t*)(R_ESP + 24)); } void iFEpppiiu(x86emu_t *emu, uintptr_t fcn) { iFEpppiiu_t fn = (iFEpppiiu_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12), *(int32_t*)(R_ESP + 16), *(int32_t*)(R_ESP + 20), *(uint32_t*)(R_ESP + 24)); } void iFEpppppp(x86emu_t *emu, uintptr_t fcn) { iFEpppppp_t fn = (iFEpppppp_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12), *(void**)(R_ESP + 16), *(void**)(R_ESP + 20), *(void**)(R_ESP + 24)); } void iFiiiiiip(x86emu_t *emu, uintptr_t fcn) { iFiiiiiip_t fn = (iFiiiiiip_t)fcn; R_EAX=fn(*(int32_t*)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16), *(int32_t*)(R_ESP + 20), *(int32_t*)(R_ESP + 24), *(void**)(R_ESP + 28)); } diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index 9831040fef..2ef7a3d0e2 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -1300,7 +1300,6 @@ void iFppuppp(x86emu_t *emu, uintptr_t fnc); void iFppUipp(x86emu_t *emu, uintptr_t fnc); void iFppUupp(x86emu_t *emu, uintptr_t fnc); void iFppdidd(x86emu_t *emu, uintptr_t fnc); -void iFpplppi(x86emu_t *emu, uintptr_t fnc); void iFppLupp(x86emu_t *emu, uintptr_t fnc); void iFppLpLp(x86emu_t *emu, uintptr_t fnc); void iFppLppp(x86emu_t *emu, uintptr_t fnc); @@ -1443,6 +1442,7 @@ void iFEpUuppp(x86emu_t *emu, uintptr_t fnc); void iFEppiuui(x86emu_t *emu, uintptr_t fnc); void iFEppupIi(x86emu_t *emu, uintptr_t fnc); void iFEppuppp(x86emu_t *emu, uintptr_t fnc); +void iFEpplppi(x86emu_t *emu, uintptr_t fnc); void iFEpppiiu(x86emu_t *emu, uintptr_t fnc); void iFEpppppp(x86emu_t *emu, uintptr_t fnc); void iFiiiiiip(x86emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedbz2.c b/src/wrapped/wrappedbz2.c index 6fd24ea500..c9b4fd5f00 100755 --- a/src/wrapped/wrappedbz2.c +++ b/src/wrapped/wrappedbz2.c @@ -22,18 +22,7 @@ const char* bz2Name = "libbz2.so.1"; #define LIBNAME bz2 static library_t* my_lib = NULL; -typedef int (*iFp_t)(void*); -typedef int (*iFpi_t)(void*, int); -typedef int (*iFpii_t)(void*, int, int); -typedef int (*iFpiii_t)(void*, int, int, int); - -#define SUPER() \ - GO(BZ2_bzCompressInit, iFpiii_t) \ - GO(BZ2_bzCompress, iFpi_t) \ - GO(BZ2_bzCompressEnd, iFp_t) \ - GO(BZ2_bzDecompressInit, iFpii_t) \ - GO(BZ2_bzDecompress, iFp_t) \ - GO(BZ2_bzDecompressEnd, iFp_t) +#include "generated/wrappedbz2types.h" typedef struct bz2_my_s { // functions @@ -227,4 +216,3 @@ EXPORT int my_BZ2_bzDecompressEnd(x86emu_t* emu, my_bz_stream_t* strm) my_lib = NULL; #include "wrappedlib_init.h" - diff --git a/src/wrapped/wrappedcrypto.c b/src/wrapped/wrappedcrypto.c index a2af86fca4..d0356b2f95 100755 --- a/src/wrapped/wrappedcrypto.c +++ b/src/wrapped/wrappedcrypto.c @@ -26,34 +26,13 @@ const char* cryptoName = "libcrypto.so.1.0.0"; static library_t* my_lib = NULL; typedef void (*vFv_t) (void); -typedef void (*vFp_t) (void*); -typedef void* (*pFp_t) (void*); -typedef void (*vFpp_t) (void*, void*); -typedef void* (*pFpppp_t) (void*, void*, void*, void*); -typedef int32_t (*iFpiipp_t) (void*, int32_t, int32_t, void*, void*); -typedef int32_t (*iFpplppi_t) (void*, void*, long, void*, void*, int32_t); -typedef int32_t (*iFppppipp_t) (void*, void*, void*, void*, int, void*, void*); -#define SUPER() \ - GO(ENGINE_ctrl, iFpiipp_t) \ - GO(ENGINE_ctrl_cmd, iFpplppi_t) \ - GO(CRYPTO_set_id_callback, vFp_t) \ - GO(CRYPTO_set_locking_callback, vFp_t) \ - GO(PEM_read_bio_DSAPrivateKey, pFpppp_t) \ - GO(PEM_read_bio_DSA_PUBKEY, pFpppp_t) \ - GO(PEM_read_bio_RSAPrivateKey, pFpppp_t) \ - GO(PEM_read_bio_RSA_PUBKEY, pFpppp_t) \ - GO(PEM_read_bio_ECPrivateKey, pFpppp_t) \ - GO(PEM_read_bio_EC_PUBKEY, pFpppp_t) \ - GO(PEM_write_bio_DSAPrivateKey, iFppppipp_t) \ - GO(PEM_write_bio_RSAPrivateKey, iFppppipp_t) \ - GO(PEM_write_bio_ECPrivateKey, iFppppipp_t) \ - GO(sk_new, pFp_t) \ - GO(sk_pop_free, vFpp_t) \ +#define ADDED_FUNCTIONS() \ GO(OPENSSL_add_all_algorithms_conf, vFv_t) \ GO(OPENSSL_add_all_algorithms_noconf, vFv_t) \ GO(OpenSSL_add_all_ciphers, vFv_t) \ - GO(OpenSSL_add_all_digests, vFv_t) \ + GO(OpenSSL_add_all_digests, vFv_t) +#include "generated/wrappedcryptotypes.h" typedef struct crypto_my_s { // functions diff --git a/src/wrapped/wrappedcrypto_private.h b/src/wrapped/wrappedcrypto_private.h index be5f1d48a7..2c8ff5541e 100755 --- a/src/wrapped/wrappedcrypto_private.h +++ b/src/wrapped/wrappedcrypto_private.h @@ -1,5 +1,5 @@ #if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)) -#error meh! +#error Meh! #endif //GO(a2d_ASN1_OBJECT, @@ -1500,7 +1500,7 @@ GO(ENGINE_cleanup, vFv) //GO(engine_cleanup_add_last, GO(ENGINE_cmd_is_executable, iFpi) GOM(ENGINE_ctrl, iFEpiipp) -GOM(ENGINE_ctrl_cmd, iFpplppi) +GOM(ENGINE_ctrl_cmd, iFEpplppi) GO(ENGINE_ctrl_cmd_string, iFpppi) GO(ENGINE_finish, iFp) GO(ENGINE_free, iFp) @@ -2596,10 +2596,10 @@ GO(OBJ_txt2obj, pFpi) //GO(OCSP_SINGLERESP_get_ext_count, //GO(OCSP_SINGLERESP_new, //GO(OCSP_url_svcloc_new, -GOM(OPENSSL_add_all_algorithms_conf, vFv) -GOM(OPENSSL_add_all_algorithms_noconf, vFv) -GOM(OpenSSL_add_all_ciphers, vFv) -GOM(OpenSSL_add_all_digests, vFv) +GOM(OPENSSL_add_all_algorithms_conf, vFv) // No emu parameter +GOM(OPENSSL_add_all_algorithms_noconf, vFv) // No emu parameter +GOM(OpenSSL_add_all_ciphers, vFv) // No emu parameter +GOM(OpenSSL_add_all_digests, vFv) // No emu parameter //GO(OPENSSL_asc2uni, //GO(OPENSSL_atomic_add, //GO(OPENSSL_cleanse, diff --git a/src/wrapped/wrappedlibjpeg62_private.h b/src/wrapped/wrappedlibjpeg62_private.h index 13f4c8c20f..678ef94c04 100755 --- a/src/wrapped/wrappedlibjpeg62_private.h +++ b/src/wrapped/wrappedlibjpeg62_private.h @@ -109,7 +109,7 @@ GOM(jpeg_set_defaults, vFEp) GO(jpeg_set_linear_quality, vFpii) GOM(jpeg_set_marker_processor, vFEpip) GOM(jpeg_set_quality, vFEpii) -GOM(jpeg_simd_cpu_support, iFv) +GOM(jpeg_simd_cpu_support, iFv) // No emu parameter GO(jpeg_simple_progression, vFp) GO(jpeg_skip_scanlines, uFpu) GOM(jpeg_start_compress, vFEpi) @@ -132,4 +132,4 @@ GO(jzero_far, vFpu) //dummy for the bridge wrappers GO(jppeg_dummy_virt_array, pFpiiuuu) -GO(jppeg_dummy_virt_access, pFppuui) \ No newline at end of file +GO(jppeg_dummy_virt_access, pFppuui) diff --git a/src/wrapped/wrappedlibjpeg_private.h b/src/wrapped/wrappedlibjpeg_private.h index 7ad1f732d7..ac9e940a2f 100755 --- a/src/wrapped/wrappedlibjpeg_private.h +++ b/src/wrapped/wrappedlibjpeg_private.h @@ -2,7 +2,6 @@ #error Meh.... #endif - GO(jcopy_block_row, vFppu) GO(jcopy_sample_rows, vFpipiiu) GO(jdiv_round_up, iFii) @@ -109,7 +108,7 @@ GO(jpeg_set_defaults, vFp) GO(jpeg_set_linear_quality, vFpii) GOM(jpeg_set_marker_processor, vFEpip) GO(jpeg_set_quality, vFpii) -GOM(jpeg_simd_cpu_support, iFv) +GOM(jpeg_simd_cpu_support, iFv) // No emu parameter GO(jpeg_simple_progression, vFp) GO(jpeg_skip_scanlines, uFpu) GO(jpeg_start_compress, vFpi) @@ -129,4 +128,3 @@ GO(jpeg_write_scanlines, uFppu) GO(jpeg_write_tables, vFp) GO(jround_up, iFii) GO(jzero_far, vFpu) - diff --git a/src/wrapped/wrappedlibtiff_private.h b/src/wrapped/wrappedlibtiff_private.h index d6c67f01b0..1f636770e4 100755 --- a/src/wrapped/wrappedlibtiff_private.h +++ b/src/wrapped/wrappedlibtiff_private.h @@ -1,5 +1,5 @@ #if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)) -#error meh! +#error Meh! #endif //GO(libport_dummy_function, @@ -22,7 +22,7 @@ //GO(TIFFCIELabToXYZ, //GO(TIFFCleanup, //GO(TIFFClientdata, -GOM(TIFFClientOpen, pFpppppppppp) +GOM(TIFFClientOpen, pFpppppppppp) // No emu parameter GO(TIFFClose, vFp) //GO(TIFFComputeStrip, //GO(TIFFComputeTile, @@ -244,4 +244,4 @@ GO(TIFFWriteScanline, iFppuW) //GO(TIFFYCbCrToRGBInit, //GO(uv_decode, //GO(uv_encode, -//GO(XYZtoRGB24, \ No newline at end of file +//GO(XYZtoRGB24, From 336b0a42e96de8b361ff3ddeeb0c16e9d5153669 Mon Sep 17 00:00:00 2001 From: rajdakin Date: Tue, 13 Apr 2021 22:32:13 +0200 Subject: [PATCH 3/3] Added a pseudo-documentation for the second generator --- rebuild_printer.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/rebuild_printer.py b/rebuild_printer.py index 74c2546279..ae74e36ee0 100755 --- a/rebuild_printer.py +++ b/rebuild_printer.py @@ -5,6 +5,13 @@ import sys from math import ceil +""" +Generates src/dynarec/arm_printer.c +=== + +See src/dynarec/arm_instructions.txt (the input file) for the syntax documentation. +""" + # Helper class to avoid displaying '\x1b[' on errors class string(str): def __repr__(self): @@ -172,13 +179,6 @@ def generate_bin_test(positions=[], specifics=[]): - specifics is an array of arrays the same length as positions that contains a tuple (mask, correctBit) that is at position positions[current_pos] """ - if len(positions) != len(specifics): - fail( - AssertionError, - "generate_bin_tests requires the same length for positions ({}) and specifics ({})!".format( - len(positions), len(specifics) - ) - ) if specifics == []: append("if ((opcode & " + arr2hex(mask) + ") == " + arr2hex(correctBits) + ") {\n") @@ -194,8 +194,9 @@ def generate_bin_test(positions=[], specifics=[]): if any(map(lambda s: len(s) != l, specifics)): fail( AssertionError, - "generate_bin_tests requires the same length for positions ({}) and specifics ({})!".format( - len(positions), len(specifics) + "generate_bin_tests requires the same length for positions ({}) and each element " + "of the specifics array ({})!".format( + len(positions), [len(s) for s in specifics] ) ) @@ -290,7 +291,7 @@ def add_custom_variables(): # Custom ifs # Also, requires only a single '=' if eq != "=": - fail(ValueError, "Too many '=' switches (!@ modifier)") + fail(ValueError, "Too many '=' switches (@@ modifier)") # Extract the statements statements = [] @@ -1653,7 +1654,7 @@ def add_custom_variables(): # No C variable since we're invalidating! - # Now print the invalidation, numerote if debugging + # Now print the invalidation, number if debugging if numberInvalids: append("strcpy(ret, \"??? #" + str(invalidationCount) + "\");\n} else ") invalidationCount = invalidationCount + 1 @@ -1963,12 +1964,12 @@ def add_custom_variables(): """} for f in files_header: - # Save the string for the next iteration, writing was successful with open(os.path.join(root, "src", "dynarec", f), 'w') as file: file.write(header.format(version = ver)) file.write(files_header[f]) file.write(output) file.write(files_guard[f]) + # Save the string for the next iteration, writing was successful with open(os.path.join(root, "src", "dynarec", "last_run.txt"), 'w') as file: file.write('\n'.join(insts))