date: make %N work without -lrt on glibc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
5b1dfe609c
commit
4ebdae3777
@ -93,6 +93,9 @@
|
|||||||
//config: MMDDhhmm[[YY]YY][.ss] format.
|
//config: MMDDhhmm[[YY]YY][.ss] format.
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
#if ENABLE_FEATURE_DATE_NANO
|
||||||
|
# include <sys/syscall.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OPT_RFC2822 = (1 << 0), /* R */
|
OPT_RFC2822 = (1 << 0), /* R */
|
||||||
@ -208,7 +211,9 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#if ENABLE_FEATURE_DATE_NANO
|
#if ENABLE_FEATURE_DATE_NANO
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
/* libc has incredibly messy way of doing this,
|
||||||
|
* typically requiring -lrt. We just skip all this mess */
|
||||||
|
syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
|
||||||
#else
|
#else
|
||||||
time(&ts.tv_sec);
|
time(&ts.tv_sec);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user