static void register_compiled_file_exports__may_heapclean ( // ============================================= // Task* task, Picklehash* c_picklehash, // Picklehash key as a C string. Val exports_tree, Roots* extra_roots ){ Roots roots1 = { &exports_tree, extra_roots }; /////////////////////////////////////////////////////////// // Add a picklehash/exports_tree key/val naming pair // to our heap-allocated list of loaded compiled_files. /////////////////////////////////////////////////////////// // Copy the picklehash naming this compiledfile // into the Mythryl heap, so that we can use // it in a Mythryl-heap record: // Val heap_picklehash = allocate_nonempty_ascii_string__may_heapclean( task, PICKLEHASH_BYTES, &roots1 ); // allocate_nonempty_ascii_string__may_heapclean def in src/c/heapcleaner/make-strings-and-vectors-etc.c memcpy( HEAP_STRING_AS_C_STRING(heap_picklehash), (char*)c_picklehash, PICKLEHASH_BYTES ); // Allocate the list record and thread it onto the exports list: // PERVASIVE_PACKAGE_PICKLE_LIST__GLOBAL = make_three_slot_record( task, // heap_picklehash, // Key naming compiledfile -- first slot in new record. exports_tree, // Tree of values exported from compiledfile -- second slot in new record. PERVASIVE_PACKAGE_PICKLE_LIST__GLOBAL // Pointer to next record in list -- third slot in new record. ); }
Val _lib7_netdb_get_protocol_by_number (Task* task, Val arg) { //================================== // // Mythryl type: Int -> Null_Or( (String, List(String), Int) ) // // This fn gets bound as get_prot_by_number' in: // // src/lib/std/src/socket/net-protocol-db.pkg ENTER_MYTHRYL_CALLABLE_C_FN(__func__); int number = TAGGED_INT_TO_C_INT( arg ); // Last use of 'arg'. RELEASE_MYTHRYL_HEAP( task->hostthread, __func__, NULL ); // struct protoent* pentry = getprotobynumber( number ); // RECOVER_MYTHRYL_HEAP( task->hostthread, __func__ ); if (pentry == NULL) return OPTION_NULL; Val name = make_ascii_string_from_c_string__may_heapclean (task, pentry->p_name, NULL ); Roots roots1 = { &name, NULL }; Val aliases = make_ascii_strings_from_vector_of_c_strings__may_heapclean(task, pentry->p_aliases, &roots1 ); Val result = make_three_slot_record( task, name, aliases, TAGGED_INT_FROM_C_INT(pentry->p_proto) ); result = OPTION_THE( task, result ); EXIT_MYTHRYL_CALLABLE_C_FN(__func__); return result; }
Val make_mythryl_signal_handler_arg ( // Called only from handle-interprocess-signal code in src/c/main/run-mythryl-code-and-runtime-eventloop.c //=============================== // Task* task, Val* resume_after_handling_signal ){ // We're handling an interprocess signal for // // src/c/main/run-mythryl-code-and-runtime-eventloop.c // // Depending on platform, resume_after_handling_signal // is from one of // src/c/machine-dependent/prim.intel32.asm // src/c/machine-dependent/prim.intel32.masm // src/c/machine-dependent/prim.sun.asm // src/c/machine-dependent/prim.pwrpc32.asm // // Our job is to build the Mythryl argument record for // the Mythryl signal handler. The handler has type // // posix_interprocess_signal_handler : (Int, Int, Fate(Void)) -> X // // where // The first argument is the signal id // For example SIGALRM, // the second argument is the signal count // I.e., number of times signal has been recieved since last handled. // the third argument is the resumption fate. // // The return type is X because the Mythryl // signal handler should never return. // // NOTE: Maybe this should be combined with choose_signal??? XXX BUGGO FIXME Hostthread* hostthread = task->hostthread; Val run_fate = make_posthandler_resumption_fate_from_task( task, resume_after_handling_signal ); // Allocate the Mythryl signal handler's argument record: // Val arg = make_three_slot_record( task, // TAGGED_INT_FROM_C_INT( hostthread->next_posix_signal_id ), TAGGED_INT_FROM_C_INT( hostthread->next_posix_signal_count ), run_fate ); if (hostthread->next_posix_signal_id == 2 /*SIGINT*/) ramlog_printf("#%d make_mythryl_signal_handler_arg: hostthread->next_posix_signal_id==SIGINT\n", syscalls_seen ); #ifdef SIGNAL_DEBUG debug_say( "make_mythryl_signal_handler_arg: resumeC = %#x, arg = %#x\n", run_fate, arg ); #endif return arg; }
Val _lib7_netdb_get_protocol_by_name (Task* task, Val arg) { //================================ // // Mythryl type: String -> Null_Or( (String, List(String), Int) ) // // This fn gets bound as get_prot_by_name' in: // // src/lib/std/src/socket/net-protocol-db.pkg ENTER_MYTHRYL_CALLABLE_C_FN(__func__); struct protoent* pentry; char* heap_name = HEAP_STRING_AS_C_STRING( arg ); // Last use of 'arg'. // We cannot reference anything on the Mythryl // heap between RELEASE_MYTHRYL_HEAP and RECOVER_MYTHRYL_HEAP // because garbage collection might be moving // it around, so copy heap_name into C storage: // Mythryl_Heap_Value_Buffer name_buf; // { char* c_name = buffer_mythryl_heap_value( &name_buf, (void*) heap_name, strlen( heap_name ) +1 ); // '+1' for terminal NUL on string. RELEASE_MYTHRYL_HEAP( task->hostthread, __func__, NULL ); // pentry = getprotobyname( c_name ); // RECOVER_MYTHRYL_HEAP( task->hostthread, __func__ ); unbuffer_mythryl_heap_value( &name_buf ); } if (pentry == NULL) return OPTION_NULL; Val name = make_ascii_string_from_c_string__may_heapclean (task, pentry->p_name, NULL ); Roots roots1 = { &name, NULL }; Val aliases = make_ascii_strings_from_vector_of_c_strings__may_heapclean (task, pentry->p_aliases, &roots1 ); Val result = make_three_slot_record( task, name, aliases, TAGGED_INT_FROM_C_INT(pentry->p_proto) ); result = OPTION_THE( task, result ); EXIT_MYTHRYL_CALLABLE_C_FN(__func__); return result; }