Skip to content

Commit 4b020ab

Browse files
authored
Merge pull request #309 from heavygabriel/master
Simplified code
2 parents 258f7f9 + 088a85c commit 4b020ab

File tree

6 files changed

+18
-19
lines changed

6 files changed

+18
-19
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ Compilation instructions can be found [here](COMPILE.md)
5353
Usage
5454
----
5555

56-
There are a few environment variables avaiable to control the behaviour of Box86.
56+
There are a few environment variables to control the behaviour of Box86.
5757

5858
See [here](USAGE.md) for all environment variables and what they do.
5959

60-
Note that now the Dynarec of Box86 uses a mechanism with Memory Protection and a SegFault signal handler to handle JIT code. That means if you want to use GDB to debug a running program that use JIT'd code (like mono/Unity3D), you will still have many "normal" segfaults triggering. I suggest you use something like `handle SIGSEGV nostop` in GDB to not stop at each segfault, and maybe put a breakpoint inside `my_memprotectionhandler` in `signals.c` if you want to trap SegFaults.
60+
Note: Box86's Dynarec uses a mechanism with Memory Protection and a SegFault signal handler to handle JIT code. In simpler terms, if you want to use GDB to debug a running program that use JIT'd code (like mono/Unity3D), you will still have many "normal" segfaults triggering. It is suggested to use something like `handle SIGSEGV nostop` in GDB to not stop at each segfault, and maybe put a breakpoint inside `my_memprotectionhandler` in `signals.c` if you want to trap SegFaults.
6161

6262
----
6363

@@ -73,7 +73,7 @@ Notes about 64-bit platforms
7373

7474
Because Box86 works by directly translating function calls from x86 to host system, the host system (the one Box86 is running on) needs to have 32-bit libraries. Box86 doesn't include any 32-bit <-> 64-bit translation. So basically, to run Box86 on, for example, an ARM64 platform, you will need to build Box86 for ARM 32-bit, and also need to have a chroot with 32-bit libraries.
7575

76-
Also note that, even if, on day, there is a Box86_64, this one will only be able to run x86_64 binaries on 64-bit platforms. You will still need Box86 (and see 32-bit chroot) to run x86 binaries (in fact, the same is the case on actual x86_64 Linux).
76+
Also note that, even if, on day, there is a Box86_64, this one will only be able to run x86_64 binaries on 64-bit platforms. You will still need Box86 (and a 32-bit chroot) to run x86 binaries (in fact, the same is the case on actual x86_64 Linux).
7777

7878
----
7979

src/box86context.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ int getrand(int maxval)
129129
{
130130
if(maxval<1024) {
131131
return ((random()&0x7fff)*maxval)/0x7fff;
132-
} else {
132+
}
133133
uint64_t r = random();
134134
r = (r*maxval) / RAND_MAX;
135135
return r;
136-
}
136+
137137
}
138138

139139
void free_tlsdatasize(void* p)

src/custommem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ void* customRealloc(void* p, size_t size)
235235
p_blocks[i].maxfree = getMaxFreeBlock(p_blocks[i].block, p_blocks[i].size);
236236
pthread_mutex_unlock(&mutex_blocks);
237237
return p;
238-
} else {
238+
}
239239
pthread_mutex_unlock(&mutex_blocks);
240240
void* newp = customMalloc(size);
241241
memcpy(newp, p, sizeBlock(sub));
242242
customFree(p);
243243
return newp;
244-
}
244+
245245
}
246246
}
247247
pthread_mutex_unlock(&mutex_blocks);

src/tools/fileutils.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ int FileExist(const char* filename, int flags)
2828
if(flags&IS_FILE) {
2929
if(!S_ISREG(sb.st_mode))
3030
return 0;
31-
} else {
32-
if(!S_ISDIR(sb.st_mode))
31+
} else if(!S_ISDIR(sb.st_mode))
3332
return 0;
34-
}
33+
3534
if(flags&IS_EXECUTABLE) {
3635
if((sb.st_mode&S_IXUSR)!=S_IXUSR)
3736
return 0; // nope

src/wrapped/wrappedlibc.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,9 @@ void EXPORT my___cxa_finalize(x86emu_t* emu, void* p)
473473
if(!p) {
474474
// p is null, call (and remove) all Cleanup functions
475475
CallAllCleanup(emu);
476-
} else {
477-
CallCleanup(emu, p);
476+
return;
478477
}
478+
CallCleanup(emu, p);
479479
}
480480
int EXPORT my_atexit(x86emu_t* emu, void *p)
481481
{
@@ -2280,12 +2280,11 @@ EXPORT void my___explicit_bzero_chk(x86emu_t* emu, void* dst, uint32_t len, uint
22802280

22812281
EXPORT void* my_realpath(x86emu_t* emu, void* path, void* resolved_path)
22822282
{
2283-
char* ret;
2283+
22842284
if(isProcSelf(path, "exe")) {
2285-
ret = realpath(emu->context->fullpath, resolved_path);
2286-
} else
2287-
ret = realpath(path, resolved_path);
2288-
return ret;
2285+
return realpath(emu->context->fullpath, resolved_path);
2286+
}
2287+
return realpath(path, resolved_path);
22892288
}
22902289

22912290
EXPORT void* my_mmap(x86emu_t* emu, void *addr, unsigned long length, int prot, int flags, int fd, int offset)

src/wrapped/wrappedxml2.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ EXPORT uintptr_t my_xmlMemStrdup = 0;
7474

7575
void my_wrap_xmlFree(void* p)
7676
{
77-
if(my_xmlFree)
77+
if(my_xmlFree){
7878
RunFunction(my_context, my_xmlFree, 1, p);
79-
else
79+
return;
80+
}
8081
free(p);
8182
}
8283
void* my_wrap_xmlMalloc(size_t s)

0 commit comments

Comments
 (0)