···44#include "../../../../../platform-include/sys/errno.h"
55#include <linux-syscalls/linux.h>
6677+#define MADV_FREE 5
88+#define MADV_FREE_REUSABLE 7
99+#define MADV_FREE_REUSE 8
1010+711long sys_madvise(void* addr, unsigned long len, int advice)
812{
913 int ret;
10141515+ if (advice == MADV_FREE_REUSABLE || advice == MADV_FREE_REUSE)
1616+ advice = MADV_FREE;
1717+1118 // advice < 0 are identical between OS X and Linux
1219 // advice >= 5 are specific to OS X/BSD
1320 if (advice >= 5)
1414- return -ENOTSUP;
2121+ return 0;
15221623 ret = LINUX_SYSCALL(__NR_madvise, addr, len, advice);
1724
+2-1
src/kernel/emulation/linux/process/execve.c
···8787 if (arg != NULL)
8888 {
8989 *arg = '\0'; // terminate interp
9090- while (isspace(*arg))
9090+ arg++;
9191+ while (isspace(*arg) && *arg)
9192 arg++;
9293 if (*arg == '\0')
9394 arg = NULL; // no argument, just whitespace
+26-11
src/kernel/emulation/linux/signal/sigexc.c
···318318 // SIGILL -> EXC_BAD_INSTRUCTION
319319 // SIGFPE -> EXC_ARITHMETIC
320320 // * -> EXC_SOFTWARE with EXC_SOFT_SIGNAL (e.g. SIGSTOP)
321321+ kern_printf("sigexc_handler #2\n");
321322322322- switch (bsd_signum)
323323+ // Only real exceptions produced by the CPU get translated to these
324324+ // Mach exceptions. The rest comes as EXC_SOFTWARE.
325325+ if (info != NULL && info->si_code != 0)
323326 {
324324- // Only real exceptions produced by the CPU get translated to these
325325- // Mach exceptions. The rest comes as EXC_SOFTWARE.
326326- if (info != NULL && info->si_code != 0)
327327- {
327327+ switch (bsd_signum)
328328+ {
328329 case SIGSEGV:
329330 mach_exception = EXC_BAD_ACCESS;
330331 codes[0] = EXC_I386_GPFLT;
···356357 }
357358 }
358359 break;
360360+ default:
361361+ mach_exception = EXC_SOFTWARE;
362362+ codes[0] = EXC_SOFT_SIGNAL;
363363+ codes[1] = bsd_signum;
359364 }
360360- default:
361361- mach_exception = EXC_SOFTWARE;
362362- codes[0] = EXC_SOFT_SIGNAL;
363363- codes[1] = bsd_signum;
365365+ }
366366+ else
367367+ {
368368+ mach_exception = EXC_SOFTWARE;
369369+ codes[0] = EXC_SOFT_SIGNAL;
370370+ codes[1] = bsd_signum;
364371 }
365372366373 port = get_exc_port(mach_exception, &behavior);
···417424 {
418425 _pthread_setspecific_direct(SIGEXC_TSD_KEY, bsd_signum);
419426427427+ kern_return_t ret;
428428+420429 if (behavior & MACH_EXCEPTION_CODES)
421430 {
422422- mach_exception_raise(port, thread, mach_task_self(), mach_exception, codes, sizeof(codes) / sizeof(codes[0]));
431431+ ret = mach_exception_raise(port, thread, mach_task_self(), mach_exception, codes, sizeof(codes) / sizeof(codes[0]));
423432 }
424433 else
425434 {
426435 exception_data_type_t small_codes[2] = { (exception_data_type_t) codes[0], (exception_data_type_t) codes[1] };
427427- exception_raise(port, thread, mach_task_self(), mach_exception, small_codes, sizeof(small_codes) / sizeof(small_codes[0]));
436436+ ret = exception_raise(port, thread, mach_task_self(), mach_exception, small_codes, sizeof(small_codes) / sizeof(small_codes[0]));
437437+ }
438438+439439+ if (ret == MACH_RCV_PORT_DIED || ret == MACH_SEND_INVALID_DEST)
440440+ {
441441+ kern_printf("Exception handler death? ret is 0x%x\n", ret);
442442+ darling_sigexc_uninstall();
428443 }
429444430445 bsd_signum = _pthread_getspecific_direct(SIGEXC_TSD_KEY);