Fix return type on lock macros

Fixes #515
This commit is contained in:
Justine Tunney 2022-08-13 14:18:02 -07:00
parent 0ea0d33a77
commit e62d7b8789
2 changed files with 7 additions and 17 deletions

View file

@ -47,7 +47,7 @@
: "X"(FUNC), "X"(IMAGE_BASE_VIRTUAL) \
: "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", \
"r11", "memory", "cc"); \
0; \
(void)0; \
})
#define _NOPL1(SECTION, FUNC, ARG) \
@ -64,7 +64,7 @@
: "X"(FUNC), "X"(IMAGE_BASE_VIRTUAL) \
: "rax", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11", \
"memory", "cc"); \
0; \
(void)0; \
})
#endif /* !ASSEMBLER && !LINKER && GNUC && !CHIBICC && !LLVM && !ANSI */

View file

@ -2,8 +2,8 @@
vi: set et ft=c ts=8 tw=8 fenc=utf-8 :vi
*/
#define LOCALTIME_IMPLEMENTATION
#include "libc/intrin/bits.h"
#include "libc/calls/calls.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/nopl.h"
#include "libc/intrin/pthread.h"
#include "libc/intrin/spinlock.h"
@ -1417,8 +1417,7 @@ localtime_tzset_unlocked(void)
void
tzset(void)
{
if (localtime_lock() != 0)
return;
localtime_lock();
localtime_tzset_unlocked();
localtime_unlock();
}
@ -1432,8 +1431,7 @@ static void
localtime_gmtcheck(void)
{
static bool gmt_is_set;
if (localtime_lock() != 0)
return;
localtime_lock();
if (! gmt_is_set) {
gmtptr = malloc(sizeof *gmtptr);
__cxa_atexit(FreeGmt, gmtptr, 0);
@ -1545,11 +1543,7 @@ localsub(struct state const *sp, time_t const *timep, int_fast32_t setname,
static struct tm *
localtime_tzset(time_t const *timep, struct tm *tmp, bool setname)
{
int err = localtime_lock();
if (err) {
errno = err;
return NULL;
}
localtime_lock();
if (setname || !lcl_is_set)
localtime_tzset_unlocked();
tmp = localsub(lclptr, timep, setname, tmp);
@ -2160,11 +2154,7 @@ time_t
mktime(struct tm *tmp)
{
time_t t;
int err = localtime_lock();
if (err) {
errno = err;
return -1;
}
localtime_lock();
localtime_tzset_unlocked();
t = mktime_tzname(lclptr, tmp, true);
localtime_unlock();