MCPcopy Create free account
hub / github.com/F-Stack/f-stack / is_leap_year

Function is_leap_year

app/redis-6.2.6/src/localtime.c:52–57  ·  view source on GitHub ↗

This is a safe version of localtime() which contains no locks and is * fork() friendly. Even the _r version of localtime() cannot be used safely * in Redis. Another thread may be calling localtime() while the main thread * forks(). Later when the child process calls localtime() again, for instance * in order to log something to the Redis log, it may deadlock: in the copy * of the address spac

Source from the content-addressed store, hash-verified

50 * designed to work with what time(NULL) may return, and to support Redis
51 * logging of the dates, it's not really a complete implementation. */
52static int is_leap_year(time_t year) {
53 if (year % 4) return 0; /* A year not divisible by 4 is not leap. */
54 else if (year % 100) return 1; /* If div by 4 and not 100 is surely leap. */
55 else if (year % 400) return 0; /* If div by 100 *and* not by 400 is not leap. */
56 else return 1; /* If div by 100 and 400 is leap. */
57}
58
59void nolocks_localtime(struct tm *tmp, time_t t, time_t tz, int dst) {
60 const time_t secs_min = 60;

Callers 1

nolocks_localtimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected