mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Update for old osx versions.
This commit is contained in:
		| @@ -34,6 +34,12 @@ | |||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | /* For macos */ | ||||||
|  | #ifdef __MACH__ | ||||||
|  | #include <mach/clock.h> | ||||||
|  | #include <mach/mach.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| static int os_which(JanetArgs args) { | static int os_which(JanetArgs args) { | ||||||
|     #ifdef JANET_WINDOWS |     #ifdef JANET_WINDOWS | ||||||
|         JANET_RETURN_CSYMBOL(args, ":windows"); |         JANET_RETURN_CSYMBOL(args, ":windows"); | ||||||
| @@ -208,10 +214,15 @@ static int os_exit(JanetArgs args) { | |||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Clock shim for windows */ | static int os_time(JanetArgs args) { | ||||||
|  |     JANET_FIXARITY(args, 0); | ||||||
|  |     double dtime = (double)(time(NULL)); | ||||||
|  |     JANET_RETURN_REAL(args, dtime); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* Clock shims */ | ||||||
| #ifdef JANET_WINDOWS | #ifdef JANET_WINDOWS | ||||||
| static int clock_gettime(int x, struct timespec *spec) { | static int gettime(struct timespec *spec) { | ||||||
|     (void) x; |  | ||||||
|     int64_t wintime = 0LL; |     int64_t wintime = 0LL; | ||||||
|     GetSystemTimeAsFileTime((FILETIME*)&wintime); |     GetSystemTimeAsFileTime((FILETIME*)&wintime); | ||||||
|     /* Windows epoch is January 1, 1601 apparently*/ |     /* Windows epoch is January 1, 1601 apparently*/ | ||||||
| @@ -221,14 +232,20 @@ static int clock_gettime(int x, struct timespec *spec) { | |||||||
|     spec->tv_nsec = wintime % 10000000LL * 100; |     spec->tv_nsec = wintime % 10000000LL * 100; | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| #define CLOCK_MONOTONIC 0 | #elif defined(__MACH__) | ||||||
| #endif | static int gettime(struct timespec *spec) { | ||||||
|  |     clock_serv_t cclock; | ||||||
| static int os_time(JanetArgs args) { |     mach_timespec_t mts; | ||||||
|     JANET_FIXARITY(args, 0); |     host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); | ||||||
|     double dtime = (double)(time(NULL)); |     clock_get_time(cclock, &mts); | ||||||
|     JANET_RETURN_REAL(args, dtime); |     mach_port_deallocate(mach_task_self(), cclock); | ||||||
|  |     spec->tv_sec = mts.tv_sec; | ||||||
|  |     spec->tv_nsec = mts.tv_nsec; | ||||||
|  |     return 0; | ||||||
| } | } | ||||||
|  | #else  | ||||||
|  | #define gettime(TV) clock_gettime(CLOCK_MONOTONIC, (TV)) | ||||||
|  | #endif | ||||||
|  |  | ||||||
| static int os_clock(JanetArgs args) { | static int os_clock(JanetArgs args) { | ||||||
|     JANET_FIXARITY(args, 0); |     JANET_FIXARITY(args, 0); | ||||||
|   | |||||||
| @@ -1333,7 +1333,7 @@ int janet_init(void) { | |||||||
|      * a collection pretty much every cycle, which is |      * a collection pretty much every cycle, which is | ||||||
|      * incredibly horrible for performance, but can help ensure |      * incredibly horrible for performance, but can help ensure | ||||||
|      * there are no memory bugs during development */ |      * there are no memory bugs during development */ | ||||||
|     janet_vm_gc_interval = 0x1000000; |     janet_vm_gc_interval = 0x4000000; | ||||||
|     janet_symcache_init(); |     janet_symcache_init(); | ||||||
|     /* Initialize gc list */ |     /* Initialize gc list */ | ||||||
|     janet_vm_gc_marklist = NULL; |     janet_vm_gc_marklist = NULL; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose