Skip to content

Conversation

ethanavatar
Copy link

Motivation is to move towards Nix on Windows.

libexpr uses getrusage from the sys/resource.h Unix header to get the current process's running duration. This PR creates a new function in libutil which has both a Unix implementation and a new Windows implementation, and removes several conditional compile guards related to getting the cpu-time on Windows.

The expected behavior is entirely unchanged because Nix doesn't target Windows yet.

The test suite is passing on my machine, but I did not do anything to test the change itself.

@ethanavatar ethanavatar requested a review from edolstra as a code owner August 15, 2025 23:54
@ethanavatar ethanavatar force-pushed the master branch 2 times, most recently from a14edaa to e9ff717 Compare August 18, 2025 02:57
@Ericson2314 Ericson2314 enabled auto-merge August 24, 2025 01:19
@Ericson2314
Copy link
Member

Thanks for this! Yeah I assume it's fine to just throw now. And only if we see it failing in practice do we need to worry about adding code to catch the failure.

@ethanavatar
Copy link
Author

Many thanks, @Ericson2314 and others for bearing with me and looking through this pretty minor change.

Copy link
Contributor

@xokdvium xokdvium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking much better, thanks! I do have one comment though.

auto-merge was automatically disabled August 25, 2025 01:41

Head branch was pushed to by a user without write access

…Time stat and implement windows version

Update src/libutil/windows/current-process.cc

Prefer `nullptr` over `NULL`

Co-authored-by: Sergei Zimmerman <[email protected]>

Update src/libutil/unix/current-process.cc

Prefer C++ type casts

Co-authored-by: Sergei Zimmerman <[email protected]>

Update src/libutil/windows/current-process.cc

Prefer C++ type casts

Co-authored-by: Sergei Zimmerman <[email protected]>

Update src/libutil/unix/current-process.cc

Don't allocate exception

Co-authored-by: Sergei Zimmerman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants