tools/nolibc: move gettimeofday() to sys/time.h

This is the location regular userspace expects this definition.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-8-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
This commit is contained in:
Thomas Weißschuh 2025-04-16 14:06:23 +02:00 committed by Thomas Weißschuh
parent 0fd55773f4
commit face777a44
4 changed files with 38 additions and 21 deletions

View file

@ -48,6 +48,7 @@ all_files := \
sys/mman.h \
sys/stat.h \
sys/syscall.h \
sys/time.h \
time.h \
types.h \
unistd.h \

View file

@ -100,6 +100,7 @@
#include "sys/mman.h"
#include "sys/stat.h"
#include "sys/syscall.h"
#include "sys/time.h"
#include "ctype.h"
#include "elf.h"
#include "signal.h"

View file

@ -487,27 +487,6 @@ int getpagesize(void)
}
/*
* int gettimeofday(struct timeval *tv, struct timezone *tz);
*/
static __attribute__((unused))
int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
{
#ifdef __NR_gettimeofday
return my_syscall2(__NR_gettimeofday, tv, tz);
#else
return __nolibc_enosys(__func__, tv, tz);
#endif
}
static __attribute__((unused))
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
return __sysret(sys_gettimeofday(tv, tz));
}
/*
* uid_t getuid(void);
*/

View file

@ -0,0 +1,36 @@
/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
/*
* time definitions for NOLIBC
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
*/
#ifndef _NOLIBC_SYS_TIME_H
#define _NOLIBC_SYS_TIME_H
#include "../arch.h"
#include "../sys.h"
/*
* int gettimeofday(struct timeval *tv, struct timezone *tz);
*/
static __attribute__((unused))
int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
{
#ifdef __NR_gettimeofday
return my_syscall2(__NR_gettimeofday, tv, tz);
#else
return __nolibc_enosys(__func__, tv, tz);
#endif
}
static __attribute__((unused))
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
return __sysret(sys_gettimeofday(tv, tz));
}
/* make sure to include all global symbols */
#include "../nolibc.h"
#endif /* _NOLIBC_SYS_TIME_H */