this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

More progress on darlingserver

See darlinghq/darlingserver@be93cc46b7433687df5e8fa9325db6b97135b2eb

+59 -39
+25 -15
src/kernel/emulation/linux/mach/mach_traps.c
··· 30 30 31 31 mach_port_name_t thread_self_trap_impl(void) 32 32 { 33 - return lkm_call(NR_thread_self_trap, 0); 33 + __simple_printf("Got to thread_self_trap_impl\n"); 34 + unsigned int port_name; 35 + if (dserver_rpc_thread_self_trap(&port_name) != 0) { 36 + __simple_printf("thread_self_trap_impl RPC failed\n"); 37 + port_name = MACH_PORT_NULL; 38 + } 39 + __simple_printf("Returning from thread_self_trap_impl: %d\n", port_name); 40 + //__simple_abort(); 41 + return port_name; 34 42 } 35 43 36 44 mach_port_name_t host_self_trap_impl(void) 37 45 { 38 - return lkm_call(NR_host_self_trap, 0); 46 + __simple_printf("Got to host_self_trap_impl\n"); 47 + unsigned int port_name; 48 + if (dserver_rpc_host_self_trap(&port_name) != 0) { 49 + __simple_printf("host_self_trap_impl RPC failed\n"); 50 + port_name = MACH_PORT_NULL; 51 + } 52 + __simple_printf("Returning from host_self_trap_impl: %d\n", port_name); 53 + //__simple_abort(); 54 + return port_name; 39 55 } 40 56 41 57 mach_msg_return_t mach_msg_trap_impl( ··· 64 80 mach_msg_header_t *rcv_msg, 65 81 mach_msg_size_t rcv_limit) 66 82 { 67 - struct mach_msg_overwrite_args args = { 68 - .msg = msg, 69 - .option = option, 70 - .send_size = send_size, 71 - .recv_size = rcv_size, 72 - .rcv_name = rcv_name, 73 - .timeout = timeout, 74 - .notify = notify, 75 - .rcv_msg = rcv_msg, 76 - .rcv_limit = rcv_limit 77 - }; 83 + int code = dserver_rpc_mach_msg_overwrite(msg, option, send_size, rcv_size, rcv_name, timeout, notify, rcv_msg, rcv_limit); 78 84 79 - return lkm_call(NR_mach_msg_overwrite_trap, 80 - &args); 85 + if (code < 0) { 86 + __simple_printf("mach_msg_overwrite failed (internally): %d\n", code); 87 + __simple_abort(); 88 + } 89 + 90 + return code; 81 91 } 82 92 83 93 kern_return_t semaphore_signal_trap_impl(
+21 -7
src/kernel/emulation/linux/signal/sigexc.c
··· 14 14 #include "kill.h" 15 15 #include "../simple.h" 16 16 17 + #include <darlingserver/rpc.h> 18 + 17 19 // Support for Darwin debugging. 18 20 // Unlike other Unix-like systems, macOS doesn't use wait() to handle events in the debugged process. 19 21 // wait() only receives termination events. ··· 102 104 darling_sigexc_self(); 103 105 sigexc_setup1(); 104 106 sigexc_setup2(); 107 + 105 108 #ifdef VARIANT_DYLD 106 - if (lkm_call(NR_started_suspended, 0)) 107 - { 109 + bool started_suspended; 110 + int code = dserver_rpc_started_suspended(&started_suspended); 111 + if (code < 0) { 112 + __simple_printf("Failed to get started_suspended status: %d\n", code); 113 + __simple_abort(); 114 + } 115 + if (started_suspended) { 108 116 kern_printf("sigexc: start_suspended -> suspending (ret to %p)\n", __builtin_return_address(0)); 109 117 task_suspend(mach_task_self()); 110 118 kern_printf("sigexc: start_suspended -> wokenup (ret to %p)\n", __builtin_return_address(0)); 111 - } 112 - else if (lkm_call(NR_get_tracer, NULL) != 0) 113 - { 114 - kern_printf("sigexc: already traced -> SIGTRAP\n"); 115 - sys_kill(0, SIGTRAP, 0); 119 + } else { 120 + uint32_t tracer; 121 + code = dserver_rpc_get_tracer(&tracer); 122 + if (code < 0) { 123 + __simple_printf("Failed to get tracer status: %d\n", code); 124 + __simple_abort(); 125 + } 126 + if (tracer != 0) { 127 + kern_printf("sigexc: already traced -> SIGTRAP\n"); 128 + sys_kill(0, SIGTRAP, 0); 129 + } 116 130 } 117 131 #else 118 132
+9 -13
src/kernel/emulation/linux/vchroot_userspace.c
··· 40 40 # include "common_at.h" 41 41 #include <stddef.h> 42 42 43 + #include <darlingserver/rpc.h> 44 + 43 45 typedef struct linux_stat stat_t; 44 46 45 47 struct _xlocale; ··· 150 152 151 153 static void init_vchroot_path(void) 152 154 { 153 - struct vchroot_expand_args a = { 154 - .path = "/", 155 - .dfd = -100, 156 - .flags = 0 157 - }; 155 + uint64_t tmp_len; 156 + int code = dserver_rpc_vchroot_path(prefix_path, sizeof(prefix_path), &tmp_len); 157 + if (code < 0) { 158 + __simple_printf("Failed to get vchroot path: %d\n", code); 159 + __simple_abort(); 160 + } 158 161 159 - lkm_call(NR_vchroot_expand, &a); 160 - 161 - int len = strlen(a.path); 162 - if (len > 0 && a.path[len-1] == '/') 163 - a.path[--len] = '\0'; 164 - 165 - strcpy(prefix_path, a.path); 166 - prefix_path_len = len; 162 + prefix_path_len = (int)tmp_len; 167 163 168 164 #ifndef TEST 169 165 __simple_printf("init_vchroot_path: %s\n", prefix_path);
+2 -2
src/libsimple/include/libsimple/lock.h
··· 33 33 uint32_t state; 34 34 } libsimple_once_t; 35 35 36 - typedef void (*libsimple_once_callback)(void); 36 + typedef void (*libsimple_once_callback)(void* context); 37 37 38 38 #define LIBSIMPLE_ONCE_INITIALIZER {0} 39 39 ··· 42 42 once->state = 0; 43 43 }; 44 44 45 - void libsimple_once(libsimple_once_t* once, libsimple_once_callback callback); 45 + void libsimple_once(libsimple_once_t* once, libsimple_once_callback callback, void* context); 46 46 47 47 LIBSIMPLE_DECLARATIONS_END; 48 48
+2 -2
src/libsimple/src/lock.c
··· 141 141 libsimple_once_state_completed = 3, 142 142 }; 143 143 144 - void libsimple_once(libsimple_once_t* _once, libsimple_once_callback callback) { 144 + void libsimple_once(libsimple_once_t* _once, libsimple_once_callback callback, void* context) { 145 145 libsimple_once_internal_t* once = (libsimple_once_internal_t*)_once; 146 146 147 147 libsimple_once_debug("evaluating..."); ··· 155 155 libsimple_once_debug("performing callback..."); 156 156 157 157 // we had `libsimple_once_state_untriggered` and now we have `libsimple_once_state_triggered_uncontended`, so let's do the callback 158 - callback(); 158 + callback(context); 159 159 160 160 libsimple_once_debug("callback done; updating state..."); 161 161