-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed astronomy function on older windows versions (#1)
- Loading branch information
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
From 34694ee7a8092cf6619c6fa6264f4f72bef9a8dc Mon Sep 17 00:00:00 2001 | ||
From: Yani <[email protected]> | ||
Date: Wed, 31 Jul 2024 00:34:45 +0200 | ||
Subject: [PATCH] fix missing initializer warning | ||
|
||
--- | ||
source/c/astronomy.c | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/source/c/astronomy.c b/source/c/astronomy.c | ||
index 08ec6c76..07fc730e 100644 | ||
--- a/source/c/astronomy.c | ||
+++ b/source/c/astronomy.c | ||
@@ -11230,7 +11230,7 @@ static const constel_boundary_t ConstelBounds[] = { | ||
astro_constellation_t Astronomy_Constellation(double ra, double dec) | ||
{ | ||
static astro_time_t epoch2000; | ||
- static astro_rotation_t rot = { ASTRO_NOT_INITIALIZED }; | ||
+ static astro_rotation_t rot = { ASTRO_NOT_INITIALIZED, {{0}} }; | ||
astro_constellation_t constel; | ||
astro_spherical_t s2000; | ||
astro_equatorial_t b1875; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
From 5773820d9cf1c1c1836028f7dd80dfe27669e194 Mon Sep 17 00:00:00 2001 | ||
From: Yani <[email protected]> | ||
Date: Sat, 10 Aug 2024 18:02:10 +0200 | ||
Subject: [PATCH] Check if GetSystemTimePreciseAsFileTime() is available and | ||
fallback to GetSystemTimeAsFileTime() | ||
|
||
--- | ||
source/c/astronomy.c | 19 ++++++++++++++++++- | ||
1 file changed, 18 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/source/c/astronomy.c b/source/c/astronomy.c | ||
index 08ec6c76..8325a764 100644 | ||
--- a/source/c/astronomy.c | ||
+++ b/source/c/astronomy.c | ||
@@ -1013,7 +1013,24 @@ astro_time_t Astronomy_CurrentTime(void) | ||
FILETIME ft; | ||
ULARGE_INTEGER large; | ||
/* Get time in 100-nanosecond units from January 1, 1601. */ | ||
- GetSystemTimePreciseAsFileTime(&ft); | ||
+ /* GetSystemTimePreciseAsFileTime is only available since Windows 8 */ | ||
+ typedef void (WINAPI *GetSystemTimePreciseAsFileTimeFunc)(LPFILETIME); | ||
+ GetSystemTimePreciseAsFileTimeFunc pGetSystemTimePreciseAsFileTime = NULL; | ||
+ HMODULE hModule = GetModuleHandleA("kernel32.dll"); | ||
+ if (hModule) { | ||
+ union { | ||
+ FARPROC proc; | ||
+ GetSystemTimePreciseAsFileTimeFunc func; | ||
+ } converter; | ||
+ converter.proc = GetProcAddress(hModule, "GetSystemTimePreciseAsFileTime"); | ||
+ pGetSystemTimePreciseAsFileTime = converter.func; | ||
+ } | ||
+ // Use the function if available, otherwise fallback | ||
+ if (pGetSystemTimePreciseAsFileTime) { | ||
+ pGetSystemTimePreciseAsFileTime(&ft); | ||
+ } else { | ||
+ GetSystemTimeAsFileTime(&ft); | ||
+ } | ||
large.u.LowPart = ft.dwLowDateTime; | ||
large.u.HighPart = ft.dwHighDateTime; | ||
sec = (large.QuadPart - 116444736000000000ULL) / 1.0e+7; |