From a446d587cf25aaba6fe9fdbff2e367c27ccaedfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:58:00 +0800 Subject: [PATCH] add Cosmopolitan --- base16384.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/base16384.c b/base16384.c index 31d479d..ee91a99 100644 --- a/base16384.c +++ b/base16384.c @@ -6,6 +6,10 @@ #ifdef __WINNT__ #include #endif +#else +struct timespec { + unsigned long tv_sec; +}; #endif #include "base14.h" @@ -133,7 +137,6 @@ void decode_file(const char* input, const char* output) { 以缩短程序运行时间 */ } -#ifndef __cosmopolitan #ifndef __WINNT__ unsigned long get_start_ms() { struct timespec ts; @@ -141,7 +144,6 @@ unsigned long get_start_ms() { return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000); } #endif -#endif #define CHOICE argv[1][1] int main(int argc, char** argv) { @@ -151,24 +153,20 @@ int main(int argc, char** argv) { fputs("\t-d decode\n", stderr); exit(EXIT_FAILURE); } - #ifndef __cosmopolitan #ifdef __WINNT__ clock_t t = clock(); #else unsigned long t = get_start_ms(); #endif - #endif switch(CHOICE) { case 'e': encode_file(argv[2], argv[3]); break; case 'd': decode_file(argv[2], argv[3]); break; default: break; } - #ifndef __cosmopolitan #ifdef __WINNT__ printf("spend time: %lums\n", clock() - t); #else printf("spend time: %lums\n", get_start_ms() - t); #endif - #endif return 0; }