about summary refs log tree commit diff stats
path: root/src/librarian
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2025-01-21 23:13:51 +0800
committerGitHub <noreply@github.com>2025-01-21 16:13:51 +0100
commit044dec0bfa0f3f8f62f7703d6b0a8600c1354dc5 (patch)
treedc41c611965cec299dcb62185c5fba4935b6251f /src/librarian
parented8b6fe9db863a8d9e473a645e84700c7291bb06 (diff)
downloadbox64-044dec0bfa0f3f8f62f7703d6b0a8600c1354dc5.tar.gz
box64-044dec0bfa0f3f8f62f7703d6b0a8600c1354dc5.zip
[ENV] Initial refactor of env variables infrastructure (#2274)
* [ENV] Initial refactor of env variables infrastructure

* Ported BOX64_DYNAREC_LOG

* Ported more options

* Ported BOX64_MALLOC_HACK

* Ported BOX64_DYNAREC_TEST

* Ported more options

* Ported more options

* Ported more options

* Ported all options

* Removed old rcfile parser

* Fix

* review

* fix

* fix

* more fixes
Diffstat (limited to 'src/librarian')
-rw-r--r--src/librarian/librarian.c12
-rw-r--r--src/librarian/library.c34
2 files changed, 23 insertions, 23 deletions
diff --git a/src/librarian/librarian.c b/src/librarian/librarian.c
index 4298ee05..c130e092 100644
--- a/src/librarian/librarian.c
+++ b/src/librarian/librarian.c
@@ -361,7 +361,7 @@ int AddNeededLib(lib_t* maplib, int local, int bindnow, int deepbind, needed_lib
             DecRefCount(&needed->libs[n-i-1], emu);
     }
     // all done
-    if(allow_missing_libs) return 0;
+    if(BOX64ENV(allow_missing_libs)) return 0;
     return ret;
 }
 EXPORTDYN
@@ -370,7 +370,7 @@ void RemoveNeededLib(lib_t* maplib, int local, needed_libs_t* needed, box64conte
     if(!needed) // no needed libs, no problems
         return;
     for(int i=0; i<needed->size; ++i) {
-        if(box64_log>=LOG_DEBUG && needed->libs[i])
+        if (BOX64ENV(log)>=LOG_DEBUG && needed->libs[i])
             printf_dump(LOG_DEBUG, "Will remove after failed init %s\n", needed->names[i]);
         AddNeededLib_remove(maplib, local, &needed->libs[i], box64, emu);
     }
@@ -585,13 +585,13 @@ int GetGlobalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, u
     }
     #ifndef STATICBUILD
     // some special case symbol, defined inside box64 itself
-    if(!strcmp(name, "gdk_display") && !box64_nogtk) {
+    if(!strcmp(name, "gdk_display") && !BOX64ENV(nogtk)) {
         *start = (uintptr_t)my_GetGTKDisplay();
         *end = *start+sizeof(void*);
         printf_log(LOG_INFO, "Using global gdk_display for gdk-x11 (%p:%p)\n", start, *(void**)start);
         return 1;
     }
-    if(!strcmp(name, "g_threads_got_initialized") && !box64_nogtk) {
+    if(!strcmp(name, "g_threads_got_initialized") && !BOX64ENV(nogtk)) {
         *start = (uintptr_t)my_GetGthreadsGotInitialized();
         *end = *start+sizeof(int);
         printf_log(LOG_INFO, "Using global g_threads_got_initialized for gthread2 (%p:%p)\n", start, *(void**)start);
@@ -658,14 +658,14 @@ int GetGlobalWeakSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* star
     }
     #ifndef STATICBUILD
     // some special case symbol, defined inside box64 itself
-    if(!strcmp(name, "gdk_display") && !box64_nogtk) {
+    if(!strcmp(name, "gdk_display") && !BOX64ENV(nogtk)) {
         *start = (uintptr_t)my_GetGTKDisplay();
         *end = *start+sizeof(void*);
         if(elfsym) *elfsym = NULL;
         printf_log(LOG_INFO, "Using global gdk_display for gdk-x11 (%p:%p)\n", start, *(void**)start);
         return 1;
     }
-    if(!strcmp(name, "g_threads_got_initialized") && !box64_nogtk) {
+    if(!strcmp(name, "g_threads_got_initialized") && !BOX64ENV(nogtk)) {
         *start = (uintptr_t)my_GetGthreadsGotInitialized();
         *end = *start+sizeof(int);
         if(elfsym) *elfsym = NULL;
diff --git a/src/librarian/library.c b/src/librarian/library.c
index 76e9770f..6ad8d57b 100644
--- a/src/librarian/library.c
+++ b/src/librarian/library.c
@@ -357,29 +357,29 @@ static int loadEmulatedLib(const char* libname, library_t *lib, box64context_t*
 
         printf_dump(LOG_INFO, "Using emulated %s\n", libname);
         #ifdef DYNAREC
-        if(libname && box64_dynarec_bleeding_edge && strstr(libname, "libmonobdwgc-2.0.so")) {
+        if(libname && BOX64ENV(dynarec_bleeding_edge) && strstr(libname, "libmonobdwgc-2.0.so")) {
             printf_dump(LOG_INFO, "MonoBleedingEdge detected, disable Dynarec BigBlock and enable Dynarec StrongMem\n");
-            box64_dynarec_bigblock = 0;
-            box64_dynarec_strongmem = 1;
+            SET_BOX64ENV(dynarec_bigblock, 0);
+            SET_BOX64ENV(dynarec_strongmem, 1);
         }
-        if(libname && box64_dynarec_tbb && strstr(libname, "libtbb.so")) {
+        if(libname && BOX64ENV(dynarec_tbb) && strstr(libname, "libtbb.so")) {
             printf_dump(LOG_INFO, "libtbb detected, enable Dynarec StrongMem\n");
-            box64_dynarec_strongmem = 1;
+            SET_BOX64ENV(dynarec_strongmem, 1);
         }
         #endif
-        if(libname && box64_jvm && strstr(libname, "libjvm.so")) {
+        if(libname && BOX64ENV(jvm) && strstr(libname, "libjvm.so")) {
             #ifdef DYNAREC
             printf_dump(LOG_INFO, "libjvm detected, disable Dynarec BigBlock and enable Dynarec StrongMem, hide SSE 4.2\n");
-            box64_dynarec_bigblock = 0;
-            box64_dynarec_strongmem = 1;
+            SET_BOX64ENV(dynarec_bigblock, 0);
+            SET_BOX64ENV(dynarec_strongmem, 1);
             #else
             printf_dump(LOG_INFO, "libjvm detected, hide SSE 4.2\n");
             #endif
-            box64_sse42 = 0;
+            SET_BOX64ENV(sse42, 0);
         }
-        if(libname && box64_libcef && strstr(libname, "libcef.so")) {
+        if(libname && BOX64ENV(libcef) && strstr(libname, "libcef.so")) {
             printf_dump(LOG_INFO, "libcef detected, using malloc_hack_2\n");
-            box64_malloc_hack = 2;
+            SET_BOX64ENV(malloc_hack, 2);
         }
         return 1;
     }
@@ -442,7 +442,7 @@ static int isEssentialLib(const char* name) {
     for (unsigned int i=0; i<sizeof(essential_libs)/sizeof(essential_libs[0]); ++i)
         if(!strcmp(name, essential_libs[i]))
             return 1;
-    if(box64_wrap_egl)
+    if(BOX64ENV(wrap_egl))
         for (unsigned int i=0; i<sizeof(essential_libs_egl)/sizeof(essential_libs_egl[0]); ++i)
             if(!strcmp(name, essential_libs_egl[i]))
                 return 1;
@@ -481,14 +481,14 @@ library_t *NewLibrary(const char* path, box64context_t* context, elfheader_t* ve
     lib->path = box_realpath(path, NULL);
     if(!lib->path)
         lib->path = box_strdup(path);
-    if(box64_libGL && !strcmp(path, box64_libGL))
+    if(BOX64ENV(libgl) && !strcmp(path, BOX64ENV(libgl)))
         lib->name = box_strdup("libGL.so.1");
     else
         lib->name = Path2Name(path);
     lib->nbdot = NbDot(lib->name);
     lib->type = LIB_UNNKNOW;
     printf_dump(LOG_DEBUG, "Simplified name is \"%s\"\n", lib->name);
-    if(box64_nopulse) {
+    if(BOX64ENV(nopulse)) {
         if(strstr(lib->name, "libpulse.so")==lib->name || strstr(lib->name, "libpulse-simple.so")==lib->name) {
             box_free(lib->name);
             box_free(lib->path);
@@ -497,7 +497,7 @@ library_t *NewLibrary(const char* path, box64context_t* context, elfheader_t* ve
             return NULL;
         }
     }
-    if(box64_novulkan) {
+    if(BOX64ENV(novulkan)) {
         if(strstr(lib->name, "libvulkan.so")==lib->name) {
             box_free(lib->name);
             box_free(lib->path);
@@ -508,9 +508,9 @@ library_t *NewLibrary(const char* path, box64context_t* context, elfheader_t* ve
     }
     int notwrapped = FindInCollection(lib->name, &context->box64_emulated_libs);
     int essential = isEssentialLib(lib->name);
-    if(!notwrapped && box64_prefer_emulated && !essential)
+    if(!notwrapped && BOX64ENV(prefer_emulated) && !essential)
         notwrapped = 1;
-    int precise = (!box64_prefer_wrapped && !essential && path && strchr(path, '/'))?1:0;
+    int precise = (!BOX64ENV(prefer_wrapped) && !essential && path && strchr(path, '/'))?1:0;
     if(!notwrapped && precise && strstr(path, "libtcmalloc_minimal.so"))
         precise = 0;    // allow native version for tcmalloc_minimum
     /*