-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[libc][c11] implement ctime #107285
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
[libc][c11] implement ctime #107285
Conversation
remove buffer length
fix: buffer length
add buffer length
fix: ctime implementation
fix: tests
fix: function declaration
format code with `clang-format`
implement `ctime_r`
fix: `ctime_r` header file
add `ctime_r` to `cmake`
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start, but I think we can simplify the code a bit. You'll also need to update the build system in a few places:
- add
ctime
andctime_r
tolibc/config/linux/x86_64
as well as any other targets you want to enable these on. - add
ctime
andctime_r
to the headergen files- for newheadergen you can run the "add_function" command described here: https://libc.llvm.org/dev/header_generation.html (the standard is
stdc
and the guard and attribute should each benull
). - for old headergen you'll still have to add them manually in
libc/spec/stdc.td
- for newheadergen you can run the "add_function" command described here: https://libc.llvm.org/dev/header_generation.html (the standard is
Feel free to reach out if you have questions on how to do any of this, and thank you for the contribution!
add `ctime` and `ctime_r` to build system
refactor `ctime` and `ctime_r` to use `asctime`
fix: `ctime_r`
add `ctime` and `ctime_r` to `aarch64` and `riscv` architecture
add `ctime` and `ctime_r` to more architectures
- add symbols for `ctime` and `ctime_r` - add `ctime` and `ctime_r` to clang formatted files list - add `ctime` to env32-c test
add header for `time_t`
removed `ctime` from analysis test
fix: `time_t` definition in `stdc.td`
fix: removed `ctime_s`
add `ctime` and `ctime_r` to unsafe functions check
fix: tests
use asctime constants and remove ctime constants
use `TimeTTypePtr` and remove `StructTimeTPtr`
Thank you for the thorough feedback. I apologize for going back and forth in this pull request. I will try to double check my work in future pull requests. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
All good, review is a normal part of LLVM development. Now that this is approved, do you need me to merge it for you? |
That would be great, since I cannot merge in LLVM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the tests locally and ran into some issues, these need to be fixed before we can merge this.
I am so sorry about this. I have now fixed them all. |
it's fine, just make sure you run the tests to see what's working and what's broken. I usually just run |
also before I forget: If the tests aren't running for you it might be because these tests only run in full build mode: https://libc.llvm.org/full_host_build.html When switching to full build mode you'll need to clean out your build folder because otherwise there are some confusing errors. |
Sure, I will try to run the full build mode. I will let you know when this is ready. |
I am testing locally and did find some issues. I will be fixing it now. |
Tests for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this, it's all working on my machine now so I'll plan on landing it on Monday (since I don't want to land right before I get off work on Friday).
I really appreciate you working through this and getting it completed. I know it took a lot of effort but it's worth it at the end to have something high quality like this.
Thank you for the thorough review. I really do appreciate it. I have a question. Since this pull request is a new API feature implementation, should I also update documentation for |
You're welcome, and yes updating the docs for ctime and ctime_r would be good. I don't know if there's an existing page tracking the status of the time functions (it'd be in |
@zimirza Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Looks like #109892 was a follow up to this PR. |
That is correct. Unfortunately, I did not compare my implementation with glibc's |
This is an implementation of
ctime
and includesctime_r
.According to documentation,
ctime
andctime_r
are defined as the following:closes #86567