diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2023-01-28 22:00:22 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2023-01-28 22:00:22 +0100 |
| commit | 7ebfe844892f9f4822046f98f91bfa85b3e39714 (patch) | |
| tree | ffbaea7de870b4340acb6da9970e5a047e9a14fe /src | |
| parent | 4e645debaadb92a8dc38e305bac2ccdee939c3ca (diff) | |
| download | box64-7ebfe844892f9f4822046f98f91bfa85b3e39714.tar.gz box64-7ebfe844892f9f4822046f98f91bfa85b3e39714.zip | |
Fixed some isse with last lib init/fini refactor (fixed ut2004, maybe pokewilds too)
Diffstat (limited to 'src')
| -rwxr-xr-x | src/include/library.h | 2 | ||||
| -rwxr-xr-x | src/librarian/librarian.c | 4 | ||||
| -rwxr-xr-x | src/librarian/library.c | 16 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibdl.c | 1 |
4 files changed, 13 insertions, 10 deletions
diff --git a/src/include/library.h b/src/include/library.h index 4fdfa65a..48200a9e 100755 --- a/src/include/library.h +++ b/src/include/library.h @@ -40,6 +40,6 @@ lib_t* GetMaplib(library_t* lib); int GetElfIndex(library_t* lib); // -1 if no elf (i.e. wrapped) elfheader_t* GetElf(library_t* lib); // NULL if no elf (i.e. wrapped) void* GetHandle(library_t* lib); // NULL if not wrapped -void IncRefCount(library_t* lib); +void IncRefCount(library_t* lib, x64emu_t* emu); #endif //__LIBRARY_H_ diff --git a/src/librarian/librarian.c b/src/librarian/librarian.c index 5504e961..919389bc 100755 --- a/src/librarian/librarian.c +++ b/src/librarian/librarian.c @@ -168,7 +168,7 @@ int AddNeededLib_add(lib_t* maplib, int local, needed_libs_t* needed, int n, box // first check if lib is already loaded library_t *lib = getLib(my_context->maplib, path); if(lib) { - IncRefCount(lib); // increment cntref + IncRefCount(lib, emu); // increment cntref needed->libs[n] = lib; printf_log(LOG_DEBUG, "Already present in maplib => success\n"); return 0; @@ -178,7 +178,7 @@ int AddNeededLib_add(lib_t* maplib, int local, needed_libs_t* needed, int n, box if(lib) { printf_log(LOG_DEBUG, "Already present in local_maplib => success\n"); needed->libs[n] = lib; - IncRefCount(lib); // increment cntref + IncRefCount(lib, emu); // increment cntref if(local) { // add lib to maplib... if(maplib) { diff --git a/src/librarian/library.c b/src/librarian/library.c index 1c18c9dc..76fc2898 100755 --- a/src/librarian/library.c +++ b/src/librarian/library.c @@ -1058,13 +1058,17 @@ void setNeededLibs(library_t* lib, int n, ...) va_end (va); } -void IncRefCount(library_t* lib) +void IncRefCount(library_t* lib, x64emu_t* emu) { - if(lib->type!=LIB_WRAPPED && lib->type!=LIB_UNNKNOW) + if(lib->type==LIB_UNNKNOW) return; - if(lib->type==LIB_WRAPPED) { - ++lib->w.refcnt; - } else { - ++lib->e.elf->refcnt; + if(!lib->active) + ReloadLibrary(lib, emu); + switch (lib->type) { + case LIB_WRAPPED: + ++lib->w.refcnt; + break; + case LIB_EMULATED: + ++lib->e.elf->refcnt; } } \ No newline at end of file diff --git a/src/wrapped/wrappedlibdl.c b/src/wrapped/wrappedlibdl.c index 3e7cc4d4..3ad6169f 100755 --- a/src/wrapped/wrappedlibdl.c +++ b/src/wrapped/wrappedlibdl.c @@ -155,7 +155,6 @@ void* my_dlopen(x64emu_t* emu, void *filename, int flag) for (size_t i=MIN_NLIB; i<dl->lib_sz; ++i) { if(!dl->libs[i]) { dl->count[i] = dl->count[i]+1; - IncRefCount(dl->libs[i]); return (void*)(i+1); } } |