Merge "Nullability check for time module."
This commit is contained in:
commit
47fc44c73c
3 changed files with 47 additions and 41 deletions
|
@ -37,7 +37,7 @@ __BEGIN_DECLS
|
|||
|
||||
#define CLOCKS_PER_SEC 1000000
|
||||
|
||||
extern char* tzname[];
|
||||
extern char* _Nonnull tzname[];
|
||||
extern int daylight;
|
||||
extern long int timezone;
|
||||
|
||||
|
@ -54,62 +54,64 @@ struct tm {
|
|||
int tm_yday;
|
||||
int tm_isdst;
|
||||
long int tm_gmtoff;
|
||||
const char* tm_zone;
|
||||
const char* _Nullable tm_zone;
|
||||
};
|
||||
|
||||
#define TM_ZONE tm_zone
|
||||
|
||||
time_t time(time_t* __t);
|
||||
int nanosleep(const struct timespec* __request, struct timespec* __remainder);
|
||||
time_t time(time_t* _Nullable __t);
|
||||
int nanosleep(const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
|
||||
|
||||
char* asctime(const struct tm* __tm);
|
||||
char* asctime_r(const struct tm* __tm, char* __buf);
|
||||
char* _Nullable asctime(const struct tm* _Nonnull __tm);
|
||||
char* _Nullable asctime_r(const struct tm* _Nonnull __tm, char* _Nonnull __buf);
|
||||
|
||||
double difftime(time_t __lhs, time_t __rhs);
|
||||
time_t mktime(struct tm* __tm);
|
||||
time_t mktime(struct tm* _Nonnull __tm);
|
||||
|
||||
struct tm* localtime(const time_t* __t);
|
||||
struct tm* localtime_r(const time_t* __t, struct tm* __tm);
|
||||
struct tm* _Nullable localtime(const time_t* _Nonnull __t);
|
||||
struct tm* _Nullable localtime_r(const time_t* _Nonnull __t, struct tm* _Nonnull __tm);
|
||||
|
||||
struct tm* gmtime(const time_t* __t);
|
||||
struct tm* gmtime_r(const time_t* __t, struct tm* __tm);
|
||||
struct tm* _Nullable gmtime(const time_t* _Nonnull __t);
|
||||
struct tm* _Nullable gmtime_r(const time_t* _Nonnull __t, struct tm* _Nonnull __tm);
|
||||
|
||||
char* strptime(const char* __s, const char* __fmt, struct tm* __tm) __strftimelike(2);
|
||||
char* strptime_l(const char* __s, const char* __fmt, struct tm* __tm, locale_t __l) __strftimelike(2) __INTRODUCED_IN(28);
|
||||
char* _Nullable strptime(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm) __strftimelike(2);
|
||||
char* _Nullable strptime_l(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm, locale_t _Nonnull __l) __strftimelike(2) __INTRODUCED_IN(28);
|
||||
|
||||
size_t strftime(char* __buf, size_t __n, const char* __fmt, const struct tm* __tm) __strftimelike(3);
|
||||
size_t strftime(char* _Nonnull __buf, size_t __n, const char* _Nonnull __fmt, const struct tm* _Nullable __tm) __strftimelike(3);
|
||||
#if __ANDROID_API__ >= 21
|
||||
size_t strftime_l(char* __buf, size_t __n, const char* __fmt, const struct tm* __tm, locale_t __l) __strftimelike(3) __INTRODUCED_IN(21);
|
||||
size_t strftime_l(char* _Nonnull __buf, size_t __n, const char* _Nonnull __fmt, const struct tm* _Nullable __tm, locale_t _Nonnull __l) __strftimelike(3) __INTRODUCED_IN(21);
|
||||
#else
|
||||
// Implemented as static inline before 21.
|
||||
#endif
|
||||
|
||||
char* ctime(const time_t* __t);
|
||||
char* ctime_r(const time_t* __t, char* __buf);
|
||||
|
||||
char* _Nullable ctime(const time_t* _Nonnull __t);
|
||||
char* _Nullable ctime_r(const time_t* _Nonnull __t, char* _Nonnull __buf);
|
||||
|
||||
void tzset(void);
|
||||
|
||||
clock_t clock(void);
|
||||
|
||||
int clock_getcpuclockid(pid_t __pid, clockid_t* __clock) __INTRODUCED_IN(23);
|
||||
int clock_getcpuclockid(pid_t __pid, clockid_t* _Nonnull __clock) __INTRODUCED_IN(23);
|
||||
|
||||
int clock_getres(clockid_t __clock, struct timespec* __resolution);
|
||||
int clock_gettime(clockid_t __clock, struct timespec* __ts);
|
||||
int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* __request, struct timespec* __remainder);
|
||||
int clock_settime(clockid_t __clock, const struct timespec* __ts);
|
||||
|
||||
int timer_create(clockid_t __clock, struct sigevent* __event, timer_t* __timer_ptr);
|
||||
int timer_delete(timer_t __timer);
|
||||
int timer_settime(timer_t __timer, int __flags, const struct itimerspec* __new_value, struct itimerspec* __old_value);
|
||||
int timer_gettime(timer_t __timer, struct itimerspec* __ts);
|
||||
int timer_getoverrun(timer_t __timer);
|
||||
int clock_getres(clockid_t __clock, struct timespec* _Nullable __resolution);
|
||||
int clock_gettime(clockid_t __clock, struct timespec* _Nonnull __ts);
|
||||
int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
|
||||
int clock_settime(clockid_t __clock, const struct timespec* _Nonnull __ts);
|
||||
|
||||
int timer_create(clockid_t __clock, struct sigevent* _Nullable __event, timer_t _Nonnull * _Nonnull __timer_ptr);
|
||||
int timer_delete(timer_t _Nonnull __timer);
|
||||
int timer_settime(timer_t _Nonnull __timer, int __flags, const struct itimerspec* _Nonnull __new_value, struct itimerspec* _Nullable __old_value);
|
||||
int timer_gettime(timer_t _Nonnull _timer, struct itimerspec* _Nonnull __ts);
|
||||
int timer_getoverrun(timer_t _Nonnull __timer);
|
||||
|
||||
/* Non-standard extensions that are in the BSDs and glibc. */
|
||||
time_t timelocal(struct tm* __tm);
|
||||
time_t timegm(struct tm* __tm);
|
||||
time_t timelocal(struct tm* _Nonnull __tm);
|
||||
time_t timegm(struct tm* _Nonnull __tm);
|
||||
|
||||
#define TIME_UTC 1
|
||||
int timespec_get(struct timespec* __ts, int __base) __INTRODUCED_IN(29);
|
||||
int timespec_get(struct timespec* _Nonnull __ts, int __base) __INTRODUCED_IN(29);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -47,17 +47,17 @@ __BEGIN_DECLS
|
|||
|
||||
typedef int64_t time64_t;
|
||||
|
||||
char* asctime64(const struct tm*);
|
||||
char* asctime64_r(const struct tm*, char*);
|
||||
char* ctime64(const time64_t*);
|
||||
char* ctime64_r(const time64_t*, char*);
|
||||
struct tm* gmtime64(const time64_t*);
|
||||
struct tm* gmtime64_r(const time64_t*, struct tm*);
|
||||
struct tm* localtime64(const time64_t*);
|
||||
struct tm* localtime64_r(const time64_t*, struct tm*);
|
||||
time64_t mktime64(const struct tm*);
|
||||
time64_t timegm64(const struct tm*);
|
||||
time64_t timelocal64(const struct tm*);
|
||||
char* _Nullable asctime64(const struct tm* _Nonnull);
|
||||
char* _Nullable asctime64_r(const struct tm* _Nonnull, char* _Nonnull);
|
||||
char* _Nullable ctime64(const time64_t* _Nonnull);
|
||||
char* _Nullable ctime64_r(const time64_t* _Nonnull, char* _Nonnull);
|
||||
struct tm* _Nullable gmtime64(const time64_t* _Nonnull);
|
||||
struct tm* _Nullable gmtime64_r(const time64_t* _Nonnull, struct tm* _Nonnull);
|
||||
struct tm* _Nullable localtime64(const time64_t* _Nonnull);
|
||||
struct tm* _Nullable localtime64_r(const time64_t* _Nonnull, struct tm* _Nonnull);
|
||||
time64_t mktime64(const struct tm* _Nonnull);
|
||||
time64_t timegm64(const struct tm* _Nonnull);
|
||||
time64_t timelocal64(const struct tm* _Nonnull);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -998,6 +998,10 @@ TEST(time, clock_getres_unknown) {
|
|||
ASSERT_EQ(-1, ts.tv_sec);
|
||||
}
|
||||
|
||||
TEST(time, clock_getres_null_resolution) {
|
||||
ASSERT_EQ(0, clock_getres(CLOCK_REALTIME, nullptr));
|
||||
}
|
||||
|
||||
TEST(time, clock) {
|
||||
// clock(3) is hard to test, but a 1s sleep should cost less than 10ms on average.
|
||||
static const clock_t N = 5;
|
||||
|
|
Loading…
Reference in a new issue