Val _lib7_P_ProcEnv_times (Task* task, Val arg) { //===================== // // Mythryl type: Void -> (Int, Int, Int, Int, Int) // // Return process and child process times, in clock ticks. // // This fn gets bound as times' in: // // src/lib/std/src/posix-1003.1b/posix-id.pkg ENTER_MYTHRYL_CALLABLE_C_FN("_lib7_P_ProcEnv_times"); Val e; Val u, s; Val cu, cs; struct tms ts; RELEASE_MYTHRYL_HEAP( task->pthread, "_lib7_P_ProcEnv_times", NULL ); // clock_t t = times( &ts ); // RECOVER_MYTHRYL_HEAP( task->pthread, "_lib7_P_ProcEnv_times" ); if (t == -1) return RAISE_SYSERR__MAY_HEAPCLEAN(task, -1, NULL); e = make_one_word_int(task, t ); u = make_one_word_int(task, ts.tms_utime ); s = make_one_word_int(task, ts.tms_stime ); cu = make_one_word_int(task, ts.tms_cutime); cs = make_one_word_int(task, ts.tms_cstime); return make_five_slot_record(task, e, u, s, cu, cs ); }
Val _lib7_Time_timeofday (Task* task, Val arg) { //==================== // // Mythryl type: Void -> (one_word_int::Int, Int) // // Return the time of day. // NOTE: gettimeofday() is not POSIX (time() returns seconds, and is POSIX and ISO C). // // This fn gets bound as get_time_of_day in: // // src/lib/std/src/time-guts.pkg ENTER_MYTHRYL_CALLABLE_C_FN(__func__); int c_microseconds; Val lib7_seconds; RELEASE_MYTHRYL_HEAP( task->hostthread, __func__, NULL ); // int c_seconds = _lib7_time_gettimeofday( &c_microseconds ); // RECOVER_MYTHRYL_HEAP( task->hostthread, __func__ ); lib7_seconds = make_one_word_int(task, c_seconds ); Val result = make_two_slot_record(task, lib7_seconds, TAGGED_INT_FROM_C_INT( c_microseconds ) ); EXIT_MYTHRYL_CALLABLE_C_FN(__func__); return result; }
Val _lib7_P_ProcEnv_time (Task* task, Val arg) { //==================== // // Mythryl type: Void -> one_word_int::Int // // Return time in seconds from 00:00:00 UTC, January 1, 1970 // // This fn gets bound as time in: // // src/lib/std/src/psx/posix-id.pkg ENTER_MYTHRYL_CALLABLE_C_FN(__func__); RELEASE_MYTHRYL_HEAP( task->hostthread, __func__, NULL ); // time_t t = time( NULL ); // RECOVER_MYTHRYL_HEAP( task->hostthread, __func__ ); Val result = make_one_word_int(task, t ); EXIT_MYTHRYL_CALLABLE_C_FN(__func__); return result; }