-
Notifications
You must be signed in to change notification settings - Fork 90
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
implement strtotime() via timelib to make it identical to PHP strtotime() #86
Conversation
9c53940
to
7e09e0e
Compare
057ed04
to
6069b2b
Compare
f0e0aee
to
3b54960
Compare
6a8fb81
to
8a87021
Compare
runtime/timelib_wrapper.cpp
Outdated
auto now_deleter = vk::finally([now]() { timelib_time_dtor(now); }); | ||
|
||
// timelib destructors do timelib_free which is a macro that expands to free(); | ||
// so we probably don't need a CriticalSectionGuard here |
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.
timelib_free call is not the main issue. The main issue is an invalid internal library state. If you sure, that timelib doesn't use any static/global vars inside (which can be spoiled with signal interruption), then we don't need a CriticalSectionGuard here, otherwise we must use the guard.
And if you add the guard, the second question is: Is timelib ready for nullptrs from malloc family calls?
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 updated the comment.
- timelib can't handle nullptr from malloc gracefully
- timelib is thread-safe
So it looks like CriticalSectionGuard is not needed here.
8a87021
to
7a8fd89
Compare
I addressed the review comments, but the CI build failed. |
246a004
to
d1dad72
Compare
…me() PHP uses timelib more intensively and we could replace some of out lookup tables from datetime.cpp with its help, but it might be a better idea to do this (if ever) later. This patch also includes a fix to date_default_timezone_get(), so if anyone uses a date_default_timezone_set() with a supported argument, calling date_default_timezone_get() would return that value.
d1dad72
to
d0cdaba
Compare
Timelib: https://github.com/derickr/timelib
For this WIP I used this fork (cmake is added): https://github.com/quasilyte/timelib/tree/kphp
The fork has 0 changes except for the added CMake file.
TODO:
timelib-kphp-vk
package for it (likecurl-kphp-vk
)Benchmark results:
Benchmarks: