Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libtock: sys: Implement _gettimeofday #355

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

alistair23
Copy link
Contributor

Implement the _gettimeofday() function, which fixes build issues with C code that uses the gettimeofday syscall.

@alistair23 alistair23 force-pushed the alistair/gettimeofday branch from 8fd79ed to 5ed6ed3 Compare November 7, 2023 02:42
@bradjc
Copy link
Contributor

bradjc commented Nov 27, 2023

What would a caller do with the results from this function? I'm a little wary of implementing this in the core library and having it not really do the correct thing. Plus we do have a RTC interface, so in theory this could use the RTC and return a valid timestamp.

@alistair23
Copy link
Contributor Author

A caller can use this to see time ticking basically.

The idea is that there are existing libraries which use gettimeofday(). If we don't implement it they will fail to link as we don't have an implementation. This provides one

@bradjc
Copy link
Contributor

bradjc commented Dec 5, 2023

Seems like there are two competing ills: not having _gettimeofday() causing compilation failures, and having gettimeofday() not actually return the time of day (when a user might expect it to). I think I would be frustrated to find out that gettimeofday() compiles but doesn't actually do what the docs say it does.

The simple solution to my issue is just to have each library implement _gettimeofday() according to whatever requirements that library needs (perhaps just returning zeros is ok, maybe ticks is ok).

I would be supportive of a middle ground, where we keep the implementation in this PR but call it something else (maybe gettimeasticks() or something), and then have individual libraries include the code:

int _gettimeofday(struct timeval *tv, void *tzvp) {
  return gettimeasticks(tv, tzvp);
}

if they want.

@alistair23 alistair23 force-pushed the alistair/gettimeofday branch 2 times, most recently from ee9f60b to b03d70e Compare December 6, 2023 23:03
Implement a helper function for the _gettimeofday() function, which can
be used to fix build issues with C code that uses the gettimeofday syscall.

Signed-off-by: Alistair Francis <[email protected]>
@alistair23 alistair23 force-pushed the alistair/gettimeofday branch from b03d70e to 45c6c48 Compare December 6, 2023 23:20
@alistair23
Copy link
Contributor Author

This is ready to merge

@bradjc bradjc added this pull request to the merge queue Dec 15, 2023
Merged via the queue into tock:master with commit d8caeec Dec 15, 2023
2 checks passed
@alistair23 alistair23 deleted the alistair/gettimeofday branch December 15, 2023 04:26
tyler-potyondy pushed a commit to tyler-potyondy/libtock-c that referenced this pull request Mar 13, 2024
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.

3 participants