mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
Reinstate ftime and add deprecate message on ftime usage
This patch revert "Move ftime to a compatibility symbol" (commit
14633d3e56
).
Checked on x86_64-linux-gnu and i686-linux-gnu.
This commit is contained in:
1
include/sys/timeb.h
Normal file
1
include/sys/timeb.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include <time/sys/timeb.h>
|
@@ -795,6 +795,7 @@ GLIBC_2.33 fsync F
|
|||||||
GLIBC_2.33 ftell F
|
GLIBC_2.33 ftell F
|
||||||
GLIBC_2.33 ftello F
|
GLIBC_2.33 ftello F
|
||||||
GLIBC_2.33 ftello64 F
|
GLIBC_2.33 ftello64 F
|
||||||
|
GLIBC_2.33 ftime F
|
||||||
GLIBC_2.33 ftok F
|
GLIBC_2.33 ftok F
|
||||||
GLIBC_2.33 ftruncate F
|
GLIBC_2.33 ftruncate F
|
||||||
GLIBC_2.33 ftruncate64 F
|
GLIBC_2.33 ftruncate64 F
|
||||||
|
@@ -22,7 +22,7 @@ subdir := time
|
|||||||
|
|
||||||
include ../Makeconfig
|
include ../Makeconfig
|
||||||
|
|
||||||
headers := time.h sys/time.h bits/time.h \
|
headers := time.h sys/time.h sys/timeb.h bits/time.h \
|
||||||
bits/types/clockid_t.h bits/types/clock_t.h \
|
bits/types/clockid_t.h bits/types/clock_t.h \
|
||||||
bits/types/struct_itimerspec.h \
|
bits/types/struct_itimerspec.h \
|
||||||
bits/types/struct_timespec.h bits/types/struct_timeval.h \
|
bits/types/struct_timespec.h bits/types/struct_timeval.h \
|
||||||
@@ -45,10 +45,9 @@ aux := era alt_digit lc-time-cleanup
|
|||||||
tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
|
tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
|
||||||
tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
|
tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
|
||||||
tst-mktime3 tst-strptime2 bug-asctime bug-asctime_r bug-mktime1 \
|
tst-mktime3 tst-strptime2 bug-asctime bug-asctime_r bug-mktime1 \
|
||||||
tst-strptime3 bug-getdate1 tst-strptime-whitespace \
|
tst-strptime3 bug-getdate1 tst-strptime-whitespace tst-ftime \
|
||||||
tst-tzname tst-y2039 bug-mktime4 tst-strftime2 tst-strftime3 \
|
tst-tzname tst-y2039 bug-mktime4 tst-strftime2 tst-strftime3 \
|
||||||
tst-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1
|
tst-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1
|
||||||
tests-internal := tst-ftime
|
|
||||||
|
|
||||||
include ../Rules
|
include ../Rules
|
||||||
|
|
||||||
|
20
time/ftime.c
20
time/ftime.c
@@ -16,23 +16,12 @@
|
|||||||
License along with the GNU C Library; if not, see
|
License along with the GNU C Library; if not, see
|
||||||
<https://www.gnu.org/licenses/>. */
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <shlib-compat.h>
|
#include <features.h>
|
||||||
|
#include <sys/timeb.h>
|
||||||
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
|
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
struct timeb
|
|
||||||
{
|
|
||||||
time_t time; /* Seconds since epoch, as from `time'. */
|
|
||||||
unsigned short int millitm; /* Additional milliseconds. */
|
|
||||||
short int timezone; /* Minutes west of GMT. */
|
|
||||||
short int dstflag; /* Nonzero if Daylight Savings Time used. */
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
attribute_compat_text_section
|
ftime (struct timeb *timebuf)
|
||||||
__ftime (struct timeb *timebuf)
|
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
__clock_gettime (CLOCK_REALTIME, &ts);
|
__clock_gettime (CLOCK_REALTIME, &ts);
|
||||||
@@ -43,6 +32,3 @@ __ftime (struct timeb *timebuf)
|
|||||||
timebuf->dstflag = 0;
|
timebuf->dstflag = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
compat_symbol (libc, __ftime, ftime, GLIBC_2_0);
|
|
||||||
#endif
|
|
||||||
|
45
time/sys/timeb.h
Normal file
45
time/sys/timeb.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/* Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _SYS_TIMEB_H
|
||||||
|
#define _SYS_TIMEB_H 1
|
||||||
|
|
||||||
|
#include <features.h>
|
||||||
|
|
||||||
|
#include <bits/types/time_t.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
/* Structure returned by the `ftime' function. */
|
||||||
|
|
||||||
|
struct timeb
|
||||||
|
{
|
||||||
|
time_t time; /* Seconds since epoch, as from `time'. */
|
||||||
|
unsigned short int millitm; /* Additional milliseconds. */
|
||||||
|
short int timezone; /* Minutes west of GMT. */
|
||||||
|
short int dstflag; /* Nonzero if Daylight Savings Time used. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Fill in TIMEBUF with information about the current time. */
|
||||||
|
|
||||||
|
extern int ftime (struct timeb *__timebuf)
|
||||||
|
__nonnull ((1))
|
||||||
|
__attribute_deprecated_msg__ ("Use gettimeofday or clock_gettime instead");
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#endif /* sys/timeb.h */
|
@@ -16,24 +16,12 @@
|
|||||||
License along with the GNU C Library; if not, see
|
License along with the GNU C Library; if not, see
|
||||||
<https://www.gnu.org/licenses/>. */
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include <features.h>
|
||||||
|
#include <sys/timeb.h>
|
||||||
|
#include <libc-diag.h>
|
||||||
|
|
||||||
#include <shlib-compat.h>
|
|
||||||
#if TEST_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
|
|
||||||
#include <time.h>
|
|
||||||
#include <support/check.h>
|
#include <support/check.h>
|
||||||
|
|
||||||
compat_symbol_reference (libc, ftime, ftime, GLIBC_2_0);
|
|
||||||
|
|
||||||
struct timeb
|
|
||||||
{
|
|
||||||
time_t time;
|
|
||||||
unsigned short int millitm;
|
|
||||||
short int timezone;
|
|
||||||
short int dstflag;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern int ftime (struct timeb *__timebuf);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
@@ -44,23 +32,23 @@ do_test (void)
|
|||||||
{
|
{
|
||||||
prev = curr;
|
prev = curr;
|
||||||
|
|
||||||
/* ftime was deprecated on 2.31 and removed on 2.33. */
|
/* ftime was deprecated on 2.31. */
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
|
||||||
|
|
||||||
TEST_COMPARE (ftime (&curr), 0);
|
TEST_COMPARE (ftime (&curr), 0);
|
||||||
TEST_VERIFY_EXIT (curr.time >= prev.time);
|
|
||||||
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
|
|
||||||
|
TEST_VERIFY (curr.time >= prev.time);
|
||||||
|
|
||||||
if (curr.time == prev.time)
|
if (curr.time == prev.time)
|
||||||
TEST_VERIFY_EXIT (curr.millitm >= prev.millitm);
|
TEST_VERIFY (curr.millitm >= prev.millitm);
|
||||||
|
|
||||||
if (curr.time > prev.time)
|
if (curr.time > prev.time)
|
||||||
sec ++;
|
sec ++;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static int
|
|
||||||
do_test (void)
|
|
||||||
{
|
|
||||||
return EXIT_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <support/test-driver.c>
|
#include <support/test-driver.c>
|
||||||
|
Reference in New Issue
Block a user