Open
Conversation
Owner
|
As the contribution guidelines state, create an issue and discuss before submitting a pull request. Did we really need a fifth method of compilation for Windows? At this point, what's our primary target - microcontrollers, or desktop machines that require 8GB RAM just to run a browser? Over half of our pull requests are compiler tweaks and tooling changes. Not actual enhancements, bugfixes, or features. It's starting to piss me off. That said, I'll still look at your commit. |
p2r3
requested changes
Sep 17, 2025
Comment on lines
+242
to
+274
| #ifdef _MSC_VER | ||
| // https://stackoverflow.com/questions/5404277/porting-clock-gettime-to-windows/51974214#51974214 | ||
| #define MS_PER_SEC 1000ULL // MS = milliseconds | ||
| #define US_PER_MS 1000ULL // US = microseconds | ||
| #define HNS_PER_US 10ULL // HNS = hundred-nanoseconds (e.g., 1 hns = 100 ns) | ||
| #define NS_PER_US 1000ULL | ||
|
|
||
| #define HNS_PER_SEC (MS_PER_SEC * US_PER_MS * HNS_PER_US) | ||
| #define NS_PER_HNS (100ULL) // NS = nanoseconds | ||
| #define NS_PER_SEC (MS_PER_SEC * US_PER_MS * NS_PER_US) | ||
|
|
||
| int clock_gettime_monotonic(struct timespec *tv) | ||
| { | ||
| static LARGE_INTEGER ticksPerSec; | ||
| LARGE_INTEGER ticks; | ||
|
|
||
| if (!ticksPerSec.QuadPart) { | ||
| QueryPerformanceFrequency(&ticksPerSec); | ||
| if (!ticksPerSec.QuadPart) { | ||
| errno = ENOTSUP; | ||
| return -1; | ||
| } | ||
| } | ||
|
|
||
| QueryPerformanceCounter(&ticks); | ||
|
|
||
| tv->tv_sec = (long)(ticks.QuadPart / ticksPerSec.QuadPart); | ||
| tv->tv_nsec = (long)(((ticks.QuadPart % ticksPerSec.QuadPart) * NS_PER_SEC) / ticksPerSec.QuadPart); | ||
|
|
||
| return 0; | ||
| } | ||
| #endif | ||
|
|
Owner
There was a problem hiding this comment.
Instead of reimplementing clock_gettime specifically, you might as well just provide a Windows-specific get_program_time implementation. clock_gettime on its own isn't used anywhere else.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pretty self-explanatory. What I did:
unistd.hinclude in all files other thanglobals.hand wrapped it in#ifndef _MSC_VER;clock_gettime()-clock_gettime_monotonic();Only 2 warnings of type
C4098(A function declared with return typevoidhas a return statement that returns a value. The compiler assumes the function returns a value of type int.) are currently issued:bareiron/src/crafting.c
Line 407 in ff89519
bareiron/src/procedures.c
Line 974 in ff89519
I'm not much a C dev (or just dev), so sorry if I did somethin' wrong, but it works at least :).