time: Prevent linux time functions from being included in non-linux platforms#26596
Conversation
What exact error do you get on Mac OS 10.4 (which was last released in 2007 afaik)? |
Used "v fmt -w" on the file to format it.
|
Unfortunately I didn't record the exact error message I received. It was probably an undefined function because linux_now() uses clock_gettime(). clock_gettime() is not available in Mac OS 10.4. |
|
I was thinking about simplifying both now() and utc() to just use the generic C implementations in their "$else" clause. Is there a good reason not to do this? |
I do not see one; you can extract a function from the common block and call it in both cases. |
|
Make sure to take care of the failing CI for FreeBSD and OpenBSD however, for example https://github.com/vlang/v/actions/runs/21969029262/job/63474997526?pr=26596 . |
|
Trying to pass all tests is going to be very hard. I just removed my patch from my repo. Then I did a 'git pull'. Now I am at commit edd4a71. I then ran 'make'. It completed without any problems. I then ran 'v test .' in the vlib/time module and saw this score: How am I suppose to pass all tests when there are so many issues with the time module? |
Simply the changes.
The tests (for the As for testing on FreeBSD or OpenBSD, that can be done in a VM (see If you do not want to do that locally for whatever reason, you can also push changes in your private fork, without making a PR, then read the logs of the failed jobs (the failures are usually listed near the bottom, and the web ui scrolls automatically to the end, so they are easier to find/analyze) until the corresponding CI jobs pass on your private fork, and then make a PR. |
spytheman
left a comment
There was a problem hiding this comment.
I am going to merge the PR as it is, since after your latest change, everything passed, and it will minimize the delta for your future PR.
|
Thank you for letting me know. I just ran "./v test vlib/time" and all the tests passed 😁 |
Currently the time modules methods now() and utc() always include linux_now() or linux_utc() in the function call. This is extra code that does nothing to help and does prevent compiling V on Mac OS 10.4. This patch makes sure only the code for the specified operating system is used. It also provides a catch-all case if the host operating system is not already specifically handled.