* [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older
@ 2020-10-19 19:13 Adhemerval Zanella
2020-10-19 19:13 ` [PATCH 2/2] time: Add 64-bit time_t support for ftime Adhemerval Zanella
` (3 more replies)
0 siblings, 4 replies; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-19 19:13 UTC (permalink / raw)
To: libc-alpha; +Cc: Florian Weimer
This patch revert "Move ftime to a compatibility symbol" (commit
14633d3e568eb9770a7e5046eff257113e0453fb). The 'ftime' is handled
similar to 'gets', where it is only exported if the program is built
for POSIX.1-2001 or order (_POSIX_C_SOURCE=200112L).
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
NEWS | 6 +--
include/features.h | 10 ++++
include/sys/timeb.h | 1 +
.../unix/sysv/linux/riscv/rv32/libc.abilist | 1 +
time/Makefile | 5 +-
time/ftime.c | 22 ++-------
time/sys/timeb.h | 48 +++++++++++++++++++
time/tst-ftime.c | 40 ++++++----------
8 files changed, 84 insertions(+), 49 deletions(-)
create mode 100644 include/sys/timeb.h
create mode 100644 time/sys/timeb.h
diff --git a/NEWS b/NEWS
index 6eb577a669..6105eb0b3e 100644
--- a/NEWS
+++ b/NEWS
@@ -37,10 +37,8 @@ Deprecated and removed features, and other changes affecting compatibility:
implementations from HWCAP subdirectories are no longer loaded.
Instead, the default implementation is used.
-* The deprecated <sys/timeb.h> header and the ftime function have been
- removed. To support old binaries, the ftime function continue to exist
- as a compatibility symbol (on those architectures which had it). All
- programs should use gettimeofday or clock_gettime instead.
+* The deprecated ftime function is now only declared for POSIX.1-2001 or
+ older standard.
Changes to build and runtime requirements:
diff --git a/include/features.h b/include/features.h
index f3e62d3362..aec149ed10 100644
--- a/include/features.h
+++ b/include/features.h
@@ -143,6 +143,7 @@
#undef __GLIBC_USE_ISOC2X
#undef __GLIBC_USE_DEPRECATED_GETS
#undef __GLIBC_USE_DEPRECATED_SCANF
+#undef __GLIBC_USE_DEPRECATED_FTIME
/* Suppress kernel-name space pollution unless user expressedly asks
for it. */
@@ -438,6 +439,15 @@
# define __GLIBC_USE_DEPRECATED_SCANF 0
#endif
+/* The function 'ftime' appeared in Version 7 AT&T UNIX, it was marked
+ as LEGACY on IEEE 1003.1-2004, and removed on IEEE 1003.1-2008. */
+#if (defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) <= 200112L) \
+ || defined _XOPEN_SOURCE_EXTENDED
+# define __GLIBC_USE_DEPRECATED_FTIME 1
+#else
+# define __GLIBC_USE_DEPRECATED_FTIME 0
+#endif
+
/* Get definitions of __STDC_* predefined macros, if the compiler has
not preincluded this header automatically. */
#include <stdc-predef.h>
diff --git a/include/sys/timeb.h b/include/sys/timeb.h
new file mode 100644
index 0000000000..9f4509c35e
--- /dev/null
+++ b/include/sys/timeb.h
@@ -0,0 +1 @@
+#include <time/sys/timeb.h>
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index e977715088..36aa34a5e7 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -795,6 +795,7 @@ GLIBC_2.33 fsync F
GLIBC_2.33 ftell F
GLIBC_2.33 ftello F
GLIBC_2.33 ftello64 F
+GLIBC_2.33 ftime F
GLIBC_2.33 ftok F
GLIBC_2.33 ftruncate F
GLIBC_2.33 ftruncate64 F
diff --git a/time/Makefile b/time/Makefile
index ab8fb3303b..a4fb13d6a3 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -22,7 +22,7 @@ subdir := time
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/struct_itimerspec.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 \
tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
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-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1
-tests-internal := tst-ftime
include ../Rules
diff --git a/time/ftime.c b/time/ftime.c
index be3295ef76..ec88d9963f 100644
--- a/time/ftime.c
+++ b/time/ftime.c
@@ -16,23 +16,14 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <shlib-compat.h>
-
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
-
+#include <features.h>
+#undef __GLIBC_USE_DEPRECATED_FTIME
+#define __GLIBC_USE_DEPRECATED_FTIME 1
+#include <sys/timeb.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
-attribute_compat_text_section
-__ftime (struct timeb *timebuf)
+ftime (struct timeb *timebuf)
{
struct timespec ts;
__clock_gettime (CLOCK_REALTIME, &ts);
@@ -43,6 +34,3 @@ __ftime (struct timeb *timebuf)
timebuf->dstflag = 0;
return 0;
}
-
-compat_symbol (libc, __ftime, ftime, GLIBC_2_0);
-#endif
diff --git a/time/sys/timeb.h b/time/sys/timeb.h
new file mode 100644
index 0000000000..be7b46c178
--- /dev/null
+++ b/time/sys/timeb.h
@@ -0,0 +1,48 @@
+/* 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
+
+#if __GLIBC_USE (DEPRECATED_FTIME)
+
+/* 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__;
+
+#endif
+
+__END_DECLS
+
+#endif /* sys/timeb.h */
diff --git a/time/tst-ftime.c b/time/tst-ftime.c
index 6978feb0f1..9d3c9e08ba 100644
--- a/time/tst-ftime.c
+++ b/time/tst-ftime.c
@@ -16,24 +16,14 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <features.h>
+#undef __GLIBC_USE_DEPRECATED_FTIME
+#define __GLIBC_USE_DEPRECATED_FTIME 1
+#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>
-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
do_test (void)
{
@@ -44,23 +34,23 @@ do_test (void)
{
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_VERIFY_EXIT (curr.time >= prev.time);
+
+ DIAG_POP_NEEDS_COMMENT;
+
+ TEST_VERIFY (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)
sec ++;
}
return 0;
}
-#else
-static int
-do_test (void)
-{
- return EXIT_UNSUPPORTED;
-}
-#endif
#include <support/test-driver.c>
--
2.25.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 2/2] time: Add 64-bit time_t support for ftime
2020-10-19 19:13 [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older Adhemerval Zanella
@ 2020-10-19 19:13 ` Adhemerval Zanella
2020-10-20 8:18 ` Lukasz Majewski
2020-10-27 17:38 ` Joseph Myers
2020-10-20 8:14 ` [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older Lukasz Majewski
` (2 subsequent siblings)
3 siblings, 2 replies; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-19 19:13 UTC (permalink / raw)
To: libc-alpha; +Cc: Florian Weimer
It basically calls the 64-bit __clock_gettime64 and adds the overflow
check.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
include/bits/types/struct_timeb.h | 1 +
include/struct___timeb64.h | 16 ++++++++++++++++
include/sys/timeb.h | 12 ++++++++++++
time/Makefile | 2 +-
time/bits/types/struct_timeb.h | 15 +++++++++++++++
time/ftime.c | 28 ++++++++++++++++++++++++----
time/sys/timeb.h | 12 +-----------
7 files changed, 70 insertions(+), 16 deletions(-)
create mode 100644 include/bits/types/struct_timeb.h
create mode 100644 include/struct___timeb64.h
create mode 100644 time/bits/types/struct_timeb.h
diff --git a/include/bits/types/struct_timeb.h b/include/bits/types/struct_timeb.h
new file mode 100644
index 0000000000..fef74d2f44
--- /dev/null
+++ b/include/bits/types/struct_timeb.h
@@ -0,0 +1 @@
+#include <time/bits/types/struct_timeb.h>
diff --git a/include/struct___timeb64.h b/include/struct___timeb64.h
new file mode 100644
index 0000000000..14704a9e30
--- /dev/null
+++ b/include/struct___timeb64.h
@@ -0,0 +1,16 @@
+#ifndef _STRUCT_TIMEB64_H
+#define _STRUCT_TIMEB64_H
+
+#if __TIMESIZE == 64
+# define __timeb64 timeb
+#else
+struct __timeb64
+{
+ __time64_t time;
+ unsigned short int millitm;
+ short int timezone;
+ short int dstflag;
+};
+#endif
+
+#endif /* _STRUCT_TIMEB64_H */
diff --git a/include/sys/timeb.h b/include/sys/timeb.h
index 9f4509c35e..2b01dafea7 100644
--- a/include/sys/timeb.h
+++ b/include/sys/timeb.h
@@ -1 +1,13 @@
#include <time/sys/timeb.h>
+
+#ifndef _ISOMAC
+# if __TIMESIZE == 64
+# define __timeb64 timeb
+# define __ftime64 ftime
+# else
+# include <struct___timeb64.h>
+
+extern int __ftime64 (struct __timeb64 *) __nonnull ((1));
+libc_hidden_proto (__ftime64);
+# endif
+#endif
diff --git a/time/Makefile b/time/Makefile
index a4fb13d6a3..26aa835166 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -27,7 +27,7 @@ headers := time.h sys/time.h sys/timeb.h bits/time.h \
bits/types/struct_itimerspec.h \
bits/types/struct_timespec.h bits/types/struct_timeval.h \
bits/types/struct_tm.h bits/types/timer_t.h \
- bits/types/time_t.h
+ bits/types/time_t.h bits/types/struct_timeb.h
routines := offtime asctime clock ctime ctime_r difftime \
gmtime localtime mktime time \
diff --git a/time/bits/types/struct_timeb.h b/time/bits/types/struct_timeb.h
new file mode 100644
index 0000000000..1fe60c7131
--- /dev/null
+++ b/time/bits/types/struct_timeb.h
@@ -0,0 +1,15 @@
+#ifndef __timeb_defined
+#define __timeb_defined 1
+
+#include <bits/types/time_t.h>
+
+/* 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. */
+ };
+
+#endif
diff --git a/time/ftime.c b/time/ftime.c
index ec88d9963f..a99070d3e0 100644
--- a/time/ftime.c
+++ b/time/ftime.c
@@ -20,13 +20,13 @@
#undef __GLIBC_USE_DEPRECATED_FTIME
#define __GLIBC_USE_DEPRECATED_FTIME 1
#include <sys/timeb.h>
-#include <time.h>
+#include <errno.h>
int
-ftime (struct timeb *timebuf)
+__ftime64 (struct __timeb64 *timebuf)
{
- struct timespec ts;
- __clock_gettime (CLOCK_REALTIME, &ts);
+ struct __timespec64 ts;
+ __clock_gettime64 (CLOCK_REALTIME, &ts);
timebuf->time = ts.tv_sec;
timebuf->millitm = ts.tv_nsec / 1000000;
@@ -34,3 +34,23 @@ ftime (struct timeb *timebuf)
timebuf->dstflag = 0;
return 0;
}
+#if __TIMESIZE != 64
+libc_hidden_def (__ftime64)
+
+int
+ftime (struct timeb *timebuf)
+{
+ struct __timeb64 tb64;
+ __ftime64 (&tb64);
+ if (! in_time_t_range (tb64.time))
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+ timebuf->time = tb64.time;
+ timebuf->millitm = tb64.millitm;
+ timebuf->timezone = tb64.timezone;
+ timebuf->dstflag = tb64.dstflag;
+ return 0;
+}
+#endif
diff --git a/time/sys/timeb.h b/time/sys/timeb.h
index be7b46c178..3f44abe55e 100644
--- a/time/sys/timeb.h
+++ b/time/sys/timeb.h
@@ -20,21 +20,11 @@
#include <features.h>
-#include <bits/types/time_t.h>
-
__BEGIN_DECLS
#if __GLIBC_USE (DEPRECATED_FTIME)
-/* 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. */
- };
+# include <bits/types/struct_timeb.h>
/* Fill in TIMEBUF with information about the current time. */
--
2.25.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-19 19:13 [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older Adhemerval Zanella
2020-10-19 19:13 ` [PATCH 2/2] time: Add 64-bit time_t support for ftime Adhemerval Zanella
@ 2020-10-20 8:14 ` Lukasz Majewski
2020-10-20 20:33 ` Adhemerval Zanella
2020-10-20 18:04 ` Szabolcs Nagy
2020-10-21 5:17 ` Florian Weimer
3 siblings, 1 reply; 22+ messages in thread
From: Lukasz Majewski @ 2020-10-20 8:14 UTC (permalink / raw)
To: Adhemerval Zanella via Libc-alpha; +Cc: Adhemerval Zanella, Florian Weimer
[-- Attachment #1: Type: text/plain, Size: 9745 bytes --]
Hi Adhemerval,
> This patch revert "Move ftime to a compatibility symbol" (commit
> 14633d3e568eb9770a7e5046eff257113e0453fb). The 'ftime' is handled
> similar to 'gets', where it is only exported if the program is built
> for POSIX.1-2001 or order (_POSIX_C_SOURCE=200112L).
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> NEWS | 6 +--
> include/features.h | 10 ++++
> include/sys/timeb.h | 1 +
> .../unix/sysv/linux/riscv/rv32/libc.abilist | 1 +
> time/Makefile | 5 +-
> time/ftime.c | 22 ++-------
> time/sys/timeb.h | 48
> +++++++++++++++++++ time/tst-ftime.c |
> 40 ++++++---------- 8 files changed, 84 insertions(+), 49 deletions(-)
> create mode 100644 include/sys/timeb.h
> create mode 100644 time/sys/timeb.h
>
> diff --git a/NEWS b/NEWS
> index 6eb577a669..6105eb0b3e 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -37,10 +37,8 @@ Deprecated and removed features, and other changes
> affecting compatibility: implementations from HWCAP subdirectories
> are no longer loaded. Instead, the default implementation is used.
>
> -* The deprecated <sys/timeb.h> header and the ftime function have
> been
> - removed. To support old binaries, the ftime function continue to
> exist
> - as a compatibility symbol (on those architectures which had it).
> All
> - programs should use gettimeofday or clock_gettime instead.
> +* The deprecated ftime function is now only declared for
> POSIX.1-2001 or
> + older standard.
>
> Changes to build and runtime requirements:
>
> diff --git a/include/features.h b/include/features.h
> index f3e62d3362..aec149ed10 100644
> --- a/include/features.h
> +++ b/include/features.h
> @@ -143,6 +143,7 @@
> #undef __GLIBC_USE_ISOC2X
> #undef __GLIBC_USE_DEPRECATED_GETS
> #undef __GLIBC_USE_DEPRECATED_SCANF
> +#undef __GLIBC_USE_DEPRECATED_FTIME
>
> /* Suppress kernel-name space pollution unless user expressedly asks
> for it. */
> @@ -438,6 +439,15 @@
> # define __GLIBC_USE_DEPRECATED_SCANF 0
> #endif
>
> +/* The function 'ftime' appeared in Version 7 AT&T UNIX, it was
> marked
> + as LEGACY on IEEE 1003.1-2004, and removed on IEEE 1003.1-2008.
> */ +#if (defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) <= 200112L)
> \
> + || defined _XOPEN_SOURCE_EXTENDED
> +# define __GLIBC_USE_DEPRECATED_FTIME 1
> +#else
> +# define __GLIBC_USE_DEPRECATED_FTIME 0
> +#endif
Am I right that we only export the struct timeb when program, which
links to glibc indicates that some older POSIX standard will be used?
> +
> /* Get definitions of __STDC_* predefined macros, if the compiler has
> not preincluded this header automatically. */
> #include <stdc-predef.h>
> diff --git a/include/sys/timeb.h b/include/sys/timeb.h
> new file mode 100644
> index 0000000000..9f4509c35e
> --- /dev/null
> +++ b/include/sys/timeb.h
> @@ -0,0 +1 @@
> +#include <time/sys/timeb.h>
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist index
> e977715088..36aa34a5e7 100644 ---
> a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist @@ -795,6 +795,7 @@
> GLIBC_2.33 fsync F GLIBC_2.33 ftell F
> GLIBC_2.33 ftello F
> GLIBC_2.33 ftello64 F
> +GLIBC_2.33 ftime F
> GLIBC_2.33 ftok F
> GLIBC_2.33 ftruncate F
> GLIBC_2.33 ftruncate64 F
> diff --git a/time/Makefile b/time/Makefile
> index ab8fb3303b..a4fb13d6a3 100644
> --- a/time/Makefile
> +++ b/time/Makefile
> @@ -22,7 +22,7 @@ subdir := time
>
> 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/struct_itimerspec.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 \ tst-getdate tst-mktime tst-mktime2 tst-ftime_l
> tst-strftime \ 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-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1
> -tests-internal := tst-ftime
>
> include ../Rules
>
> diff --git a/time/ftime.c b/time/ftime.c
> index be3295ef76..ec88d9963f 100644
> --- a/time/ftime.c
> +++ b/time/ftime.c
> @@ -16,23 +16,14 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> -#include <shlib-compat.h>
> -
> -#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
> -
> +#include <features.h>
> +#undef __GLIBC_USE_DEPRECATED_FTIME
> +#define __GLIBC_USE_DEPRECATED_FTIME 1
> +#include <sys/timeb.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
> -attribute_compat_text_section
> -__ftime (struct timeb *timebuf)
> +ftime (struct timeb *timebuf)
> {
> struct timespec ts;
> __clock_gettime (CLOCK_REALTIME, &ts);
> @@ -43,6 +34,3 @@ __ftime (struct timeb *timebuf)
> timebuf->dstflag = 0;
> return 0;
> }
> -
> -compat_symbol (libc, __ftime, ftime, GLIBC_2_0);
> -#endif
> diff --git a/time/sys/timeb.h b/time/sys/timeb.h
> new file mode 100644
> index 0000000000..be7b46c178
> --- /dev/null
> +++ b/time/sys/timeb.h
> @@ -0,0 +1,48 @@
> +/* 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
> +
> +#if __GLIBC_USE (DEPRECATED_FTIME)
> +
> +/* 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__;
> +
> +#endif
> +
> +__END_DECLS
> +
> +#endif /* sys/timeb.h */
> diff --git a/time/tst-ftime.c b/time/tst-ftime.c
> index 6978feb0f1..9d3c9e08ba 100644
> --- a/time/tst-ftime.c
> +++ b/time/tst-ftime.c
> @@ -16,24 +16,14 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> +#include <features.h>
> +#undef __GLIBC_USE_DEPRECATED_FTIME
> +#define __GLIBC_USE_DEPRECATED_FTIME 1
> +#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>
>
> -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
> do_test (void)
> {
> @@ -44,23 +34,23 @@ do_test (void)
> {
> 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_VERIFY_EXIT (curr.time >= prev.time);
> +
> + DIAG_POP_NEEDS_COMMENT;
> +
> + TEST_VERIFY (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)
> sec ++;
> }
> return 0;
> }
> -#else
> -static int
> -do_test (void)
> -{
> - return EXIT_UNSUPPORTED;
> -}
> -#endif
>
> #include <support/test-driver.c>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] time: Add 64-bit time_t support for ftime
2020-10-19 19:13 ` [PATCH 2/2] time: Add 64-bit time_t support for ftime Adhemerval Zanella
@ 2020-10-20 8:18 ` Lukasz Majewski
2020-10-27 17:38 ` Joseph Myers
1 sibling, 0 replies; 22+ messages in thread
From: Lukasz Majewski @ 2020-10-20 8:18 UTC (permalink / raw)
To: Adhemerval Zanella via Libc-alpha; +Cc: Adhemerval Zanella, Florian Weimer
[-- Attachment #1: Type: text/plain, Size: 5614 bytes --]
Hi Adhemerval,
> It basically calls the 64-bit __clock_gettime64 and adds the overflow
> check.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> include/bits/types/struct_timeb.h | 1 +
> include/struct___timeb64.h | 16 ++++++++++++++++
> include/sys/timeb.h | 12 ++++++++++++
> time/Makefile | 2 +-
> time/bits/types/struct_timeb.h | 15 +++++++++++++++
> time/ftime.c | 28 ++++++++++++++++++++++++----
> time/sys/timeb.h | 12 +-----------
> 7 files changed, 70 insertions(+), 16 deletions(-)
> create mode 100644 include/bits/types/struct_timeb.h
> create mode 100644 include/struct___timeb64.h
> create mode 100644 time/bits/types/struct_timeb.h
>
> diff --git a/include/bits/types/struct_timeb.h
> b/include/bits/types/struct_timeb.h new file mode 100644
> index 0000000000..fef74d2f44
> --- /dev/null
> +++ b/include/bits/types/struct_timeb.h
> @@ -0,0 +1 @@
> +#include <time/bits/types/struct_timeb.h>
> diff --git a/include/struct___timeb64.h b/include/struct___timeb64.h
> new file mode 100644
> index 0000000000..14704a9e30
> --- /dev/null
> +++ b/include/struct___timeb64.h
> @@ -0,0 +1,16 @@
> +#ifndef _STRUCT_TIMEB64_H
> +#define _STRUCT_TIMEB64_H
> +
> +#if __TIMESIZE == 64
> +# define __timeb64 timeb
> +#else
> +struct __timeb64
> +{
> + __time64_t time;
> + unsigned short int millitm;
> + short int timezone;
> + short int dstflag;
> +};
> +#endif
> +
> +#endif /* _STRUCT_TIMEB64_H */
> diff --git a/include/sys/timeb.h b/include/sys/timeb.h
> index 9f4509c35e..2b01dafea7 100644
> --- a/include/sys/timeb.h
> +++ b/include/sys/timeb.h
> @@ -1 +1,13 @@
> #include <time/sys/timeb.h>
> +
> +#ifndef _ISOMAC
> +# if __TIMESIZE == 64
> +# define __timeb64 timeb
> +# define __ftime64 ftime
> +# else
> +# include <struct___timeb64.h>
> +
> +extern int __ftime64 (struct __timeb64 *) __nonnull ((1));
> +libc_hidden_proto (__ftime64);
> +# endif
> +#endif
> diff --git a/time/Makefile b/time/Makefile
> index a4fb13d6a3..26aa835166 100644
> --- a/time/Makefile
> +++ b/time/Makefile
> @@ -27,7 +27,7 @@ headers := time.h sys/time.h sys/timeb.h
> bits/time.h \
> bits/types/struct_itimerspec.h \
> bits/types/struct_timespec.h bits/types/struct_timeval.h \
> bits/types/struct_tm.h bits/types/timer_t.h \
> - bits/types/time_t.h
> + bits/types/time_t.h bits/types/struct_timeb.h
>
> routines := offtime asctime clock ctime ctime_r difftime \
> gmtime localtime mktime time \
> diff --git a/time/bits/types/struct_timeb.h
> b/time/bits/types/struct_timeb.h new file mode 100644
> index 0000000000..1fe60c7131
> --- /dev/null
> +++ b/time/bits/types/struct_timeb.h
> @@ -0,0 +1,15 @@
> +#ifndef __timeb_defined
> +#define __timeb_defined 1
> +
> +#include <bits/types/time_t.h>
> +
> +/* 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. */
> + };
> +
> +#endif
> diff --git a/time/ftime.c b/time/ftime.c
> index ec88d9963f..a99070d3e0 100644
> --- a/time/ftime.c
> +++ b/time/ftime.c
> @@ -20,13 +20,13 @@
> #undef __GLIBC_USE_DEPRECATED_FTIME
> #define __GLIBC_USE_DEPRECATED_FTIME 1
> #include <sys/timeb.h>
> -#include <time.h>
> +#include <errno.h>
>
> int
> -ftime (struct timeb *timebuf)
> +__ftime64 (struct __timeb64 *timebuf)
> {
> - struct timespec ts;
> - __clock_gettime (CLOCK_REALTIME, &ts);
> + struct __timespec64 ts;
> + __clock_gettime64 (CLOCK_REALTIME, &ts);
>
> timebuf->time = ts.tv_sec;
> timebuf->millitm = ts.tv_nsec / 1000000;
> @@ -34,3 +34,23 @@ ftime (struct timeb *timebuf)
> timebuf->dstflag = 0;
> return 0;
> }
> +#if __TIMESIZE != 64
> +libc_hidden_def (__ftime64)
> +
> +int
> +ftime (struct timeb *timebuf)
> +{
> + struct __timeb64 tb64;
> + __ftime64 (&tb64);
> + if (! in_time_t_range (tb64.time))
> + {
> + __set_errno (EOVERFLOW);
> + return -1;
> + }
> + timebuf->time = tb64.time;
> + timebuf->millitm = tb64.millitm;
> + timebuf->timezone = tb64.timezone;
> + timebuf->dstflag = tb64.dstflag;
> + return 0;
> +}
> +#endif
> diff --git a/time/sys/timeb.h b/time/sys/timeb.h
> index be7b46c178..3f44abe55e 100644
> --- a/time/sys/timeb.h
> +++ b/time/sys/timeb.h
> @@ -20,21 +20,11 @@
>
> #include <features.h>
>
> -#include <bits/types/time_t.h>
> -
> __BEGIN_DECLS
>
> #if __GLIBC_USE (DEPRECATED_FTIME)
>
> -/* 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. */
> - };
> +# include <bits/types/struct_timeb.h>
>
> /* Fill in TIMEBUF with information about the current time. */
>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-19 19:13 [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older Adhemerval Zanella
2020-10-19 19:13 ` [PATCH 2/2] time: Add 64-bit time_t support for ftime Adhemerval Zanella
2020-10-20 8:14 ` [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older Lukasz Majewski
@ 2020-10-20 18:04 ` Szabolcs Nagy
2020-10-20 18:20 ` Adhemerval Zanella
2020-10-21 5:17 ` Florian Weimer
3 siblings, 1 reply; 22+ messages in thread
From: Szabolcs Nagy @ 2020-10-20 18:04 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha, Florian Weimer
The 10/19/2020 16:13, Adhemerval Zanella via Libc-alpha wrote:
> This patch revert "Move ftime to a compatibility symbol" (commit
> 14633d3e568eb9770a7e5046eff257113e0453fb). The 'ftime' is handled
> similar to 'gets', where it is only exported if the program is built
> for POSIX.1-2001 or order (_POSIX_C_SOURCE=200112L).
thanks this looks reasonable to me given
that several things break without sys/timeb.h
(i know at least spec and libsanitizer build
depends on it, and i don't think it's reasonable
requiring significant source changes in legacy
code)
it seems -D_GNU_SOURCE will be enough to make
legacy code build since that implies
_XOPEN_SOURCE_EXTENDED.
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
> +/* The function 'ftime' appeared in Version 7 AT&T UNIX, it was marked
> + as LEGACY on IEEE 1003.1-2004, and removed on IEEE 1003.1-2008. */
> +#if (defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) <= 200112L) \
> + || defined _XOPEN_SOURCE_EXTENDED
> +# define __GLIBC_USE_DEPRECATED_FTIME 1
> +#else
> +# define __GLIBC_USE_DEPRECATED_FTIME 0
> +#endif
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-20 18:04 ` Szabolcs Nagy
@ 2020-10-20 18:20 ` Adhemerval Zanella
0 siblings, 0 replies; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-20 18:20 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: libc-alpha, Florian Weimer
On 20/10/2020 15:04, Szabolcs Nagy wrote:
> The 10/19/2020 16:13, Adhemerval Zanella via Libc-alpha wrote:
>> This patch revert "Move ftime to a compatibility symbol" (commit
>> 14633d3e568eb9770a7e5046eff257113e0453fb). The 'ftime' is handled
>> similar to 'gets', where it is only exported if the program is built
>> for POSIX.1-2001 or order (_POSIX_C_SOURCE=200112L).
>
> thanks this looks reasonable to me given
> that several things break without sys/timeb.h
> (i know at least spec and libsanitizer build
> depends on it, and i don't think it's reasonable
> requiring significant source changes in legacy
> code)
Indeed, I did run build-many-glibcs.py for a handful or architectures
but I haven't used --full-gcc (which should trigger the libsanitizer
issue).
>
> it seems -D_GNU_SOURCE will be enough to make
> legacy code build since that implies
> _XOPEN_SOURCE_EXTENDED.
>
> Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Thanks.
>
>> +/* The function 'ftime' appeared in Version 7 AT&T UNIX, it was marked
>> + as LEGACY on IEEE 1003.1-2004, and removed on IEEE 1003.1-2008. */
>> +#if (defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) <= 200112L) \
>> + || defined _XOPEN_SOURCE_EXTENDED
>> +# define __GLIBC_USE_DEPRECATED_FTIME 1
>> +#else
>> +# define __GLIBC_USE_DEPRECATED_FTIME 0
>> +#endif
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-20 8:14 ` [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older Lukasz Majewski
@ 2020-10-20 20:33 ` Adhemerval Zanella
0 siblings, 0 replies; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-20 20:33 UTC (permalink / raw)
To: Lukasz Majewski, Adhemerval Zanella via Libc-alpha; +Cc: Florian Weimer
[-- Attachment #1.1: Type: text/plain, Size: 1224 bytes --]
On 20/10/2020 05:14, Lukasz Majewski wrote:
>> diff --git a/include/features.h b/include/features.h
>> index f3e62d3362..aec149ed10 100644
>> --- a/include/features.h
>> +++ b/include/features.h
>> @@ -143,6 +143,7 @@
>> #undef __GLIBC_USE_ISOC2X
>> #undef __GLIBC_USE_DEPRECATED_GETS
>> #undef __GLIBC_USE_DEPRECATED_SCANF
>> +#undef __GLIBC_USE_DEPRECATED_FTIME
>>
>> /* Suppress kernel-name space pollution unless user expressedly asks
>> for it. */
>> @@ -438,6 +439,15 @@
>> # define __GLIBC_USE_DEPRECATED_SCANF 0
>> #endif
>>
>> +/* The function 'ftime' appeared in Version 7 AT&T UNIX, it was
>> marked
>> + as LEGACY on IEEE 1003.1-2004, and removed on IEEE 1003.1-2008.
>> */ +#if (defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) <= 200112L)
>> \
>> + || defined _XOPEN_SOURCE_EXTENDED
>> +# define __GLIBC_USE_DEPRECATED_FTIME 1
>> +#else
>> +# define __GLIBC_USE_DEPRECATED_FTIME 0
>> +#endif
>
> Am I right that we only export the struct timeb when program, which
> links to glibc indicates that some older POSIX standard will be used?
Yes, although as Szabolcs has pointed out-D_GNU_SOURCE implies
_XOPEN_SOURCE_EXTENDED and this will be exported.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-19 19:13 [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older Adhemerval Zanella
` (2 preceding siblings ...)
2020-10-20 18:04 ` Szabolcs Nagy
@ 2020-10-21 5:17 ` Florian Weimer
2020-10-21 11:03 ` Adhemerval Zanella
3 siblings, 1 reply; 22+ messages in thread
From: Florian Weimer @ 2020-10-21 5:17 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
* Adhemerval Zanella:
> diff --git a/NEWS b/NEWS
> index 6eb577a669..6105eb0b3e 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -37,10 +37,8 @@ Deprecated and removed features, and other changes affecting compatibility:
> implementations from HWCAP subdirectories are no longer loaded.
> Instead, the default implementation is used.
>
> -* The deprecated <sys/timeb.h> header and the ftime function have been
> - removed. To support old binaries, the ftime function continue to exist
> - as a compatibility symbol (on those architectures which had it). All
> - programs should use gettimeofday or clock_gettime instead.
> +* The deprecated ftime function is now only declared for POSIX.1-2001 or
> + older standard.
It is also declared for _GNU_SOURCE, so the NEWS entry is not correct.
> diff --git a/include/features.h b/include/features.h
> index f3e62d3362..aec149ed10 100644
> --- a/include/features.h
> +++ b/include/features.h
> @@ -143,6 +143,7 @@
> #undef __GLIBC_USE_ISOC2X
> #undef __GLIBC_USE_DEPRECATED_GETS
> #undef __GLIBC_USE_DEPRECATED_SCANF
> +#undef __GLIBC_USE_DEPRECATED_FTIME
>
> /* Suppress kernel-name space pollution unless user expressedly asks
> for it. */
> @@ -438,6 +439,15 @@
> # define __GLIBC_USE_DEPRECATED_SCANF 0
> #endif
>
> +/* The function 'ftime' appeared in Version 7 AT&T UNIX, it was marked
> + as LEGACY on IEEE 1003.1-2004, and removed on IEEE 1003.1-2008. */
> +#if (defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) <= 200112L) \
> + || defined _XOPEN_SOURCE_EXTENDED
> +# define __GLIBC_USE_DEPRECATED_FTIME 1
> +#else
> +# define __GLIBC_USE_DEPRECATED_FTIME 0
> +#endif
Due to the _XOPEN_SOURCE_EXTENDED part, this does not seem particularly
useful.
> diff --git a/time/sys/timeb.h b/time/sys/timeb.h
> new file mode 100644
> index 0000000000..be7b46c178
> --- /dev/null
> +++ b/time/sys/timeb.h
> @@ -0,0 +1,48 @@
> +/* 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
> +
> +#if __GLIBC_USE (DEPRECATED_FTIME)
I'm not sure if that #if is particularly useful. For later POSIX, this
is a non-standard header, so there is no conformance issue.
> +
> +/* 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. */
> + };
Missing __attribute_deprecated_msg__.
> +
> +/* Fill in TIMEBUF with information about the current time. */
> +
> +extern int ftime (struct timeb *__timebuf)
> + __nonnull ((1)) __attribute_deprecated__;
Please use __attribute_deprecated_msg__, pointing towards clock_gettime.
Should these deprecations be disabled for older POSIX?
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-21 5:17 ` Florian Weimer
@ 2020-10-21 11:03 ` Adhemerval Zanella
2020-10-21 11:05 ` Florian Weimer
0 siblings, 1 reply; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-21 11:03 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On 21/10/2020 02:17, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> diff --git a/NEWS b/NEWS
>> index 6eb577a669..6105eb0b3e 100644
>> --- a/NEWS
>> +++ b/NEWS
>> @@ -37,10 +37,8 @@ Deprecated and removed features, and other changes affecting compatibility:
>> implementations from HWCAP subdirectories are no longer loaded.
>> Instead, the default implementation is used.
>>
>> -* The deprecated <sys/timeb.h> header and the ftime function have been
>> - removed. To support old binaries, the ftime function continue to exist
>> - as a compatibility symbol (on those architectures which had it). All
>> - programs should use gettimeofday or clock_gettime instead.
>> +* The deprecated ftime function is now only declared for POSIX.1-2001 or
>> + older standard.
>
> It is also declared for _GNU_SOURCE, so the NEWS entry is not correct.
I removed the entry.
>
>> diff --git a/include/features.h b/include/features.h
>> index f3e62d3362..aec149ed10 100644
>> --- a/include/features.h
>> +++ b/include/features.h
>> @@ -143,6 +143,7 @@
>> #undef __GLIBC_USE_ISOC2X
>> #undef __GLIBC_USE_DEPRECATED_GETS
>> #undef __GLIBC_USE_DEPRECATED_SCANF
>> +#undef __GLIBC_USE_DEPRECATED_FTIME
>>
>> /* Suppress kernel-name space pollution unless user expressedly asks
>> for it. */
>> @@ -438,6 +439,15 @@
>> # define __GLIBC_USE_DEPRECATED_SCANF 0
>> #endif
>>
>> +/* The function 'ftime' appeared in Version 7 AT&T UNIX, it was marked
>> + as LEGACY on IEEE 1003.1-2004, and removed on IEEE 1003.1-2008. */
>> +#if (defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) <= 200112L) \
>> + || defined _XOPEN_SOURCE_EXTENDED
>> +# define __GLIBC_USE_DEPRECATED_FTIME 1
>> +#else
>> +# define __GLIBC_USE_DEPRECATED_FTIME 0
>> +#endif
>
> Due to the _XOPEN_SOURCE_EXTENDED part, this does not seem particularly
> useful.
Not a strong position here, I will remove since it will defined anyway
for most scenarios.
>
>> diff --git a/time/sys/timeb.h b/time/sys/timeb.h
>> new file mode 100644
>> index 0000000000..be7b46c178
>> --- /dev/null
>> +++ b/time/sys/timeb.h
>> @@ -0,0 +1,48 @@
>> +/* 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
>> +
>> +#if __GLIBC_USE (DEPRECATED_FTIME)
>
> I'm not sure if that #if is particularly useful. For later POSIX, this
> is a non-standard header, so there is no conformance issue.
Indeed.
>
>> +
>> +/* 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. */
>> + };
>
> Missing __attribute_deprecated_msg__.
Ack.
>
>> +
>> +/* Fill in TIMEBUF with information about the current time. */
>> +
>> +extern int ftime (struct timeb *__timebuf)
>> + __nonnull ((1)) __attribute_deprecated__;
>
> Please use __attribute_deprecated_msg__, pointing towards clock_gettime.
>
> Should these deprecations be disabled for older POSIX?
I think we should enforce these interface are really deprecated, and
clock_gettime is provided with _POSIX_C_SOURCE >= 199309L.
>
> Thanks,
> Florian
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-21 11:03 ` Adhemerval Zanella
@ 2020-10-21 11:05 ` Florian Weimer
2020-10-21 12:35 ` [PATCH v2] " Adhemerval Zanella
0 siblings, 1 reply; 22+ messages in thread
From: Florian Weimer @ 2020-10-21 11:05 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
* Adhemerval Zanella:
>>> +/* Fill in TIMEBUF with information about the current time. */
>>> +
>>> +extern int ftime (struct timeb *__timebuf)
>>> + __nonnull ((1)) __attribute_deprecated__;
>>
>> Please use __attribute_deprecated_msg__, pointing towards clock_gettime.
>>
>> Should these deprecations be disabled for older POSIX?
>
> I think we should enforce these interface are really deprecated, and
> clock_gettime is provided with _POSIX_C_SOURCE >= 199309L.
Fair enough, so __attribute_deprecated_msg__ doesn't have to be made
conditional.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-21 11:05 ` Florian Weimer
@ 2020-10-21 12:35 ` Adhemerval Zanella
2020-10-26 12:17 ` Adhemerval Zanella
2020-10-26 16:19 ` Florian Weimer
0 siblings, 2 replies; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-21 12:35 UTC (permalink / raw)
To: libc-alpha, Florian Weimer
This patch revert "Move ftime to a compatibility symbol" (commit
14633d3e568eb9770a7e5046eff257113e0453fb). It as adds a deprecated
message on ftime usage.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
NEWS | 6 +--
include/sys/timeb.h | 1 +
.../unix/sysv/linux/riscv/rv32/libc.abilist | 1 +
time/Makefile | 5 +--
time/ftime.c | 20 ++-------
time/sys/timeb.h | 45 +++++++++++++++++++
time/tst-ftime.c | 38 ++++++----------
7 files changed, 67 insertions(+), 49 deletions(-)
create mode 100644 include/sys/timeb.h
create mode 100644 time/sys/timeb.h
diff --git a/NEWS b/NEWS
index 6eb577a669..6105eb0b3e 100644
--- a/NEWS
+++ b/NEWS
@@ -37,10 +37,8 @@ Deprecated and removed features, and other changes affecting compatibility:
implementations from HWCAP subdirectories are no longer loaded.
Instead, the default implementation is used.
-* The deprecated <sys/timeb.h> header and the ftime function have been
- removed. To support old binaries, the ftime function continue to exist
- as a compatibility symbol (on those architectures which had it). All
- programs should use gettimeofday or clock_gettime instead.
+* The deprecated ftime function is now only declared for POSIX.1-2001 or
+ older standard.
Changes to build and runtime requirements:
diff --git a/include/sys/timeb.h b/include/sys/timeb.h
new file mode 100644
index 0000000000..9f4509c35e
--- /dev/null
+++ b/include/sys/timeb.h
@@ -0,0 +1 @@
+#include <time/sys/timeb.h>
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index e977715088..36aa34a5e7 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -795,6 +795,7 @@ GLIBC_2.33 fsync F
GLIBC_2.33 ftell F
GLIBC_2.33 ftello F
GLIBC_2.33 ftello64 F
+GLIBC_2.33 ftime F
GLIBC_2.33 ftok F
GLIBC_2.33 ftruncate F
GLIBC_2.33 ftruncate64 F
diff --git a/time/Makefile b/time/Makefile
index ab8fb3303b..a4fb13d6a3 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -22,7 +22,7 @@ subdir := time
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/struct_itimerspec.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 \
tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
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-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1
-tests-internal := tst-ftime
include ../Rules
diff --git a/time/ftime.c b/time/ftime.c
index be3295ef76..70a2590c17 100644
--- a/time/ftime.c
+++ b/time/ftime.c
@@ -16,23 +16,12 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <shlib-compat.h>
-
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
-
+#include <features.h>
+#include <sys/timeb.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
-attribute_compat_text_section
-__ftime (struct timeb *timebuf)
+ftime (struct timeb *timebuf)
{
struct timespec ts;
__clock_gettime (CLOCK_REALTIME, &ts);
@@ -43,6 +32,3 @@ __ftime (struct timeb *timebuf)
timebuf->dstflag = 0;
return 0;
}
-
-compat_symbol (libc, __ftime, ftime, GLIBC_2_0);
-#endif
diff --git a/time/sys/timeb.h b/time/sys/timeb.h
new file mode 100644
index 0000000000..d6cdf29111
--- /dev/null
+++ b/time/sys/timeb.h
@@ -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 */
diff --git a/time/tst-ftime.c b/time/tst-ftime.c
index 6978feb0f1..44d82620af 100644
--- a/time/tst-ftime.c
+++ b/time/tst-ftime.c
@@ -16,24 +16,12 @@
License along with the GNU C Library; if not, see
<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>
-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
do_test (void)
{
@@ -44,23 +32,23 @@ do_test (void)
{
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_VERIFY_EXIT (curr.time >= prev.time);
+
+ DIAG_POP_NEEDS_COMMENT;
+
+ TEST_VERIFY (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)
sec ++;
}
return 0;
}
-#else
-static int
-do_test (void)
-{
- return EXIT_UNSUPPORTED;
-}
-#endif
#include <support/test-driver.c>
--
2.25.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-21 12:35 ` [PATCH v2] " Adhemerval Zanella
@ 2020-10-26 12:17 ` Adhemerval Zanella
2020-10-26 16:03 ` Szabolcs Nagy
2020-10-26 16:19 ` Florian Weimer
1 sibling, 1 reply; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-26 12:17 UTC (permalink / raw)
To: libc-alpha, Florian Weimer
Florian,
Are you OK with this version?
On 21/10/2020 09:35, Adhemerval Zanella wrote:
> This patch revert "Move ftime to a compatibility symbol" (commit
> 14633d3e568eb9770a7e5046eff257113e0453fb). It as adds a deprecated
> message on ftime usage.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> NEWS | 6 +--
> include/sys/timeb.h | 1 +
> .../unix/sysv/linux/riscv/rv32/libc.abilist | 1 +
> time/Makefile | 5 +--
> time/ftime.c | 20 ++-------
> time/sys/timeb.h | 45 +++++++++++++++++++
> time/tst-ftime.c | 38 ++++++----------
> 7 files changed, 67 insertions(+), 49 deletions(-)
> create mode 100644 include/sys/timeb.h
> create mode 100644 time/sys/timeb.h
>
> diff --git a/NEWS b/NEWS
> index 6eb577a669..6105eb0b3e 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -37,10 +37,8 @@ Deprecated and removed features, and other changes affecting compatibility:
> implementations from HWCAP subdirectories are no longer loaded.
> Instead, the default implementation is used.
>
> -* The deprecated <sys/timeb.h> header and the ftime function have been
> - removed. To support old binaries, the ftime function continue to exist
> - as a compatibility symbol (on those architectures which had it). All
> - programs should use gettimeofday or clock_gettime instead.
> +* The deprecated ftime function is now only declared for POSIX.1-2001 or
> + older standard.
>
> Changes to build and runtime requirements:
>
> diff --git a/include/sys/timeb.h b/include/sys/timeb.h
> new file mode 100644
> index 0000000000..9f4509c35e
> --- /dev/null
> +++ b/include/sys/timeb.h
> @@ -0,0 +1 @@
> +#include <time/sys/timeb.h>
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> index e977715088..36aa34a5e7 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> @@ -795,6 +795,7 @@ GLIBC_2.33 fsync F
> GLIBC_2.33 ftell F
> GLIBC_2.33 ftello F
> GLIBC_2.33 ftello64 F
> +GLIBC_2.33 ftime F
> GLIBC_2.33 ftok F
> GLIBC_2.33 ftruncate F
> GLIBC_2.33 ftruncate64 F
> diff --git a/time/Makefile b/time/Makefile
> index ab8fb3303b..a4fb13d6a3 100644
> --- a/time/Makefile
> +++ b/time/Makefile
> @@ -22,7 +22,7 @@ subdir := time
>
> 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/struct_itimerspec.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 \
> tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
> 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-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1
> -tests-internal := tst-ftime
>
> include ../Rules
>
> diff --git a/time/ftime.c b/time/ftime.c
> index be3295ef76..70a2590c17 100644
> --- a/time/ftime.c
> +++ b/time/ftime.c
> @@ -16,23 +16,12 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> -#include <shlib-compat.h>
> -
> -#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
> -
> +#include <features.h>
> +#include <sys/timeb.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
> -attribute_compat_text_section
> -__ftime (struct timeb *timebuf)
> +ftime (struct timeb *timebuf)
> {
> struct timespec ts;
> __clock_gettime (CLOCK_REALTIME, &ts);
> @@ -43,6 +32,3 @@ __ftime (struct timeb *timebuf)
> timebuf->dstflag = 0;
> return 0;
> }
> -
> -compat_symbol (libc, __ftime, ftime, GLIBC_2_0);
> -#endif
> diff --git a/time/sys/timeb.h b/time/sys/timeb.h
> new file mode 100644
> index 0000000000..d6cdf29111
> --- /dev/null
> +++ b/time/sys/timeb.h
> @@ -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 */
> diff --git a/time/tst-ftime.c b/time/tst-ftime.c
> index 6978feb0f1..44d82620af 100644
> --- a/time/tst-ftime.c
> +++ b/time/tst-ftime.c
> @@ -16,24 +16,12 @@
> License along with the GNU C Library; if not, see
> <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>
>
> -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
> do_test (void)
> {
> @@ -44,23 +32,23 @@ do_test (void)
> {
> 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_VERIFY_EXIT (curr.time >= prev.time);
> +
> + DIAG_POP_NEEDS_COMMENT;
> +
> + TEST_VERIFY (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)
> sec ++;
> }
> return 0;
> }
> -#else
> -static int
> -do_test (void)
> -{
> - return EXIT_UNSUPPORTED;
> -}
> -#endif
>
> #include <support/test-driver.c>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-26 12:17 ` Adhemerval Zanella
@ 2020-10-26 16:03 ` Szabolcs Nagy
2020-10-26 16:13 ` Adhemerval Zanella
0 siblings, 1 reply; 22+ messages in thread
From: Szabolcs Nagy @ 2020-10-26 16:03 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha, Florian Weimer
The 10/26/2020 09:17, Adhemerval Zanella via Libc-alpha wrote:
> Florian,
>
> Are you OK with this version?
>
> On 21/10/2020 09:35, Adhemerval Zanella wrote:
> > This patch revert "Move ftime to a compatibility symbol" (commit
> > 14633d3e568eb9770a7e5046eff257113e0453fb). It as adds a deprecated
> > message on ftime usage.
> >
> > Checked on x86_64-linux-gnu and i686-linux-gnu.
...
> > diff --git a/NEWS b/NEWS
> > index 6eb577a669..6105eb0b3e 100644
> > --- a/NEWS
> > +++ b/NEWS
> > @@ -37,10 +37,8 @@ Deprecated and removed features, and other changes affecting compatibility:
> > implementations from HWCAP subdirectories are no longer loaded.
> > Instead, the default implementation is used.
> >
> > -* The deprecated <sys/timeb.h> header and the ftime function have been
> > - removed. To support old binaries, the ftime function continue to exist
> > - as a compatibility symbol (on those architectures which had it). All
> > - programs should use gettimeofday or clock_gettime instead.
> > +* The deprecated ftime function is now only declared for POSIX.1-2001 or
> > + older standard.
i think the news entry is no longer needed and should just be removed.
otherwise it looks good to me.
> >
> > Changes to build and runtime requirements:
> >
> > diff --git a/include/sys/timeb.h b/include/sys/timeb.h
> > new file mode 100644
> > index 0000000000..9f4509c35e
> > --- /dev/null
> > +++ b/include/sys/timeb.h
> > @@ -0,0 +1 @@
> > +#include <time/sys/timeb.h>
> > diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> > index e977715088..36aa34a5e7 100644
> > --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> > +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> > @@ -795,6 +795,7 @@ GLIBC_2.33 fsync F
> > GLIBC_2.33 ftell F
> > GLIBC_2.33 ftello F
> > GLIBC_2.33 ftello64 F
> > +GLIBC_2.33 ftime F
> > GLIBC_2.33 ftok F
> > GLIBC_2.33 ftruncate F
> > GLIBC_2.33 ftruncate64 F
> > diff --git a/time/Makefile b/time/Makefile
> > index ab8fb3303b..a4fb13d6a3 100644
> > --- a/time/Makefile
> > +++ b/time/Makefile
> > @@ -22,7 +22,7 @@ subdir := time
> >
> > 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/struct_itimerspec.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 \
> > tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
> > 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-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1
> > -tests-internal := tst-ftime
> >
> > include ../Rules
> >
> > diff --git a/time/ftime.c b/time/ftime.c
> > index be3295ef76..70a2590c17 100644
> > --- a/time/ftime.c
> > +++ b/time/ftime.c
> > @@ -16,23 +16,12 @@
> > License along with the GNU C Library; if not, see
> > <https://www.gnu.org/licenses/>. */
> >
> > -#include <shlib-compat.h>
> > -
> > -#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
> > -
> > +#include <features.h>
> > +#include <sys/timeb.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
> > -attribute_compat_text_section
> > -__ftime (struct timeb *timebuf)
> > +ftime (struct timeb *timebuf)
> > {
> > struct timespec ts;
> > __clock_gettime (CLOCK_REALTIME, &ts);
> > @@ -43,6 +32,3 @@ __ftime (struct timeb *timebuf)
> > timebuf->dstflag = 0;
> > return 0;
> > }
> > -
> > -compat_symbol (libc, __ftime, ftime, GLIBC_2_0);
> > -#endif
> > diff --git a/time/sys/timeb.h b/time/sys/timeb.h
> > new file mode 100644
> > index 0000000000..d6cdf29111
> > --- /dev/null
> > +++ b/time/sys/timeb.h
> > @@ -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 */
> > diff --git a/time/tst-ftime.c b/time/tst-ftime.c
> > index 6978feb0f1..44d82620af 100644
> > --- a/time/tst-ftime.c
> > +++ b/time/tst-ftime.c
> > @@ -16,24 +16,12 @@
> > License along with the GNU C Library; if not, see
> > <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>
> >
> > -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
> > do_test (void)
> > {
> > @@ -44,23 +32,23 @@ do_test (void)
> > {
> > 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_VERIFY_EXIT (curr.time >= prev.time);
> > +
> > + DIAG_POP_NEEDS_COMMENT;
> > +
> > + TEST_VERIFY (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)
> > sec ++;
> > }
> > return 0;
> > }
> > -#else
> > -static int
> > -do_test (void)
> > -{
> > - return EXIT_UNSUPPORTED;
> > -}
> > -#endif
> >
> > #include <support/test-driver.c>
> >
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-26 16:03 ` Szabolcs Nagy
@ 2020-10-26 16:13 ` Adhemerval Zanella
0 siblings, 0 replies; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-26 16:13 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: libc-alpha, Florian Weimer
On 26/10/2020 13:03, Szabolcs Nagy wrote:
> The 10/26/2020 09:17, Adhemerval Zanella via Libc-alpha wrote:
>> Florian,
>>
>> Are you OK with this version?
>>
>> On 21/10/2020 09:35, Adhemerval Zanella wrote:
>>> This patch revert "Move ftime to a compatibility symbol" (commit
>>> 14633d3e568eb9770a7e5046eff257113e0453fb). It as adds a deprecated
>>> message on ftime usage.
>>>
>>> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ...
>>> diff --git a/NEWS b/NEWS
>>> index 6eb577a669..6105eb0b3e 100644
>>> --- a/NEWS
>>> +++ b/NEWS
>>> @@ -37,10 +37,8 @@ Deprecated and removed features, and other changes affecting compatibility:
>>> implementations from HWCAP subdirectories are no longer loaded.
>>> Instead, the default implementation is used.
>>>
>>> -* The deprecated <sys/timeb.h> header and the ftime function have been
>>> - removed. To support old binaries, the ftime function continue to exist
>>> - as a compatibility symbol (on those architectures which had it). All
>>> - programs should use gettimeofday or clock_gettime instead.
>>> +* The deprecated ftime function is now only declared for POSIX.1-2001 or
>>> + older standard.
>
> i think the news entry is no longer needed and should just be removed.
>
> otherwise it looks good to me.
Alright, I will remove it.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-21 12:35 ` [PATCH v2] " Adhemerval Zanella
2020-10-26 12:17 ` Adhemerval Zanella
@ 2020-10-26 16:19 ` Florian Weimer
2020-10-26 16:23 ` Adhemerval Zanella
1 sibling, 1 reply; 22+ messages in thread
From: Florian Weimer @ 2020-10-26 16:19 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
* Adhemerval Zanella:
> +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. */
> + };
I think you could add __attribute_deprecated_msg__ on the struct itself.
Rest looks okay to me.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-26 16:19 ` Florian Weimer
@ 2020-10-26 16:23 ` Adhemerval Zanella
2020-10-26 16:29 ` Florian Weimer
0 siblings, 1 reply; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-26 16:23 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On 26/10/2020 13:19, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> +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. */
>> + };
>
> I think you could add __attribute_deprecated_msg__ on the struct itself.
I tried to add on it, but it would require to add the warning suppression
on ftime.c build before the header inclusion and also on check-local header
tests as well (since it includes). I think adding on the function itself
should suffice, using the struct without calling ftime should be unusual
scenario.
>
> Rest looks okay to me.
>
> Thanks,
> Florian
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-26 16:23 ` Adhemerval Zanella
@ 2020-10-26 16:29 ` Florian Weimer
2020-10-26 17:09 ` Adhemerval Zanella
0 siblings, 1 reply; 22+ messages in thread
From: Florian Weimer @ 2020-10-26 16:29 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
* Adhemerval Zanella:
> On 26/10/2020 13:19, Florian Weimer wrote:
>> * Adhemerval Zanella:
>>
>>> +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. */
>>> + };
>>
>> I think you could add __attribute_deprecated_msg__ on the struct itself.
>
> I tried to add on it, but it would require to add the warning suppression
> on ftime.c build before the header inclusion and also on check-local header
> tests as well (since it includes).
Ahh, so you get a deprecation warning on the ftime function declaration,
even though itself it is marked deprecated. Oh well. That's not how
things work in Java.
> I think adding on the function itself should suffice, using the struct
> without calling ftime should be unusual scenario.
Yes, given this compiler limitation, I do not really see an alternative.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-26 16:29 ` Florian Weimer
@ 2020-10-26 17:09 ` Adhemerval Zanella
2020-10-28 13:54 ` Florian Weimer
0 siblings, 1 reply; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-26 17:09 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On 26/10/2020 13:29, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> On 26/10/2020 13:19, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>>
>>>> +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. */
>>>> + };
>>>
>>> I think you could add __attribute_deprecated_msg__ on the struct itself.
>>
>> I tried to add on it, but it would require to add the warning suppression
>> on ftime.c build before the header inclusion and also on check-local header
>> tests as well (since it includes).
>
> Ahh, so you get a deprecation warning on the ftime function declaration,
> even though itself it is marked deprecated. Oh well. That's not how
> things work in Java.
On the struct timeb declaration to be more exact, even when then ftime
is not issued. I would expect a deprecation warning iff the code
actually uses the struct timeb.
>
>> I think adding on the function itself should suffice, using the struct
>> without calling ftime should be unusual scenario.
>
> Yes, given this compiler limitation, I do not really see an alternative.
>
> Thanks,
> Florian
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] time: Add 64-bit time_t support for ftime
2020-10-19 19:13 ` [PATCH 2/2] time: Add 64-bit time_t support for ftime Adhemerval Zanella
2020-10-20 8:18 ` Lukasz Majewski
@ 2020-10-27 17:38 ` Joseph Myers
2020-10-27 17:44 ` Adhemerval Zanella
1 sibling, 1 reply; 22+ messages in thread
From: Joseph Myers @ 2020-10-27 17:38 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha, Florian Weimer
The build of the 64-bit ftime appears broken for Hurd:
ftime.c: In function '__ftime64':
ftime.c:27:3: error: implicit declaration of function '__clock_gettime64' [-Werror=implicit-function-declaration]
27 | __clock_gettime64 (CLOCK_REALTIME, &ts);
| ^~~~~~~~~~~~~~~~~
ftime.c:27:22: error: 'CLOCK_REALTIME' undeclared (first use in this function)
27 | __clock_gettime64 (CLOCK_REALTIME, &ts);
| ^~~~~~~~~~~~~~
ftime.c:27:22: note: each undeclared identifier is reported only once for each function it appears in
ftime.c: In function 'ftime':
ftime.c:43:9: error: implicit declaration of function 'in_time_t_range'; did you mean 'in_ino_t_range'? [-Werror=implicit-function-declaration]
43 | if (! in_time_t_range (tb64.time))
| ^~~~~~~~~~~~~~~
| in_ino_t_range
https://sourceware.org/pipermail/libc-testresults/2020q4/006962.html
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 2/2] time: Add 64-bit time_t support for ftime
2020-10-27 17:38 ` Joseph Myers
@ 2020-10-27 17:44 ` Adhemerval Zanella
0 siblings, 0 replies; 22+ messages in thread
From: Adhemerval Zanella @ 2020-10-27 17:44 UTC (permalink / raw)
To: Joseph Myers; +Cc: libc-alpha, Florian Weimer
On 27/10/2020 14:38, Joseph Myers wrote:
> The build of the 64-bit ftime appears broken for Hurd:
>
> ftime.c: In function '__ftime64':
> ftime.c:27:3: error: implicit declaration of function '__clock_gettime64' [-Werror=implicit-function-declaration]
> 27 | __clock_gettime64 (CLOCK_REALTIME, &ts);
> | ^~~~~~~~~~~~~~~~~
> ftime.c:27:22: error: 'CLOCK_REALTIME' undeclared (first use in this function)
> 27 | __clock_gettime64 (CLOCK_REALTIME, &ts);
> | ^~~~~~~~~~~~~~
> ftime.c:27:22: note: each undeclared identifier is reported only once for each function it appears in
> ftime.c: In function 'ftime':
> ftime.c:43:9: error: implicit declaration of function 'in_time_t_range'; did you mean 'in_ino_t_range'? [-Werror=implicit-function-declaration]
> 43 | if (! in_time_t_range (tb64.time))
> | ^~~~~~~~~~~~~~~
> | in_ino_t_range
>
> https://sourceware.org/pipermail/libc-testresults/2020q4/006962.html
>
I think we will need to make the y2038 ftime support Linux specific
for now, I will fix it.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-26 17:09 ` Adhemerval Zanella
@ 2020-10-28 13:54 ` Florian Weimer
2020-10-28 14:12 ` Zack Weinberg
0 siblings, 1 reply; 22+ messages in thread
From: Florian Weimer @ 2020-10-28 13:54 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
* Adhemerval Zanella:
> On 26/10/2020 13:29, Florian Weimer wrote:
>> * Adhemerval Zanella:
>>
>>> On 26/10/2020 13:19, Florian Weimer wrote:
>>>> * Adhemerval Zanella:
>>>>
>>>>> +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. */
>>>>> + };
>>>>
>>>> I think you could add __attribute_deprecated_msg__ on the struct itself.
>>>
>>> I tried to add on it, but it would require to add the warning suppression
>>> on ftime.c build before the header inclusion and also on check-local header
>>> tests as well (since it includes).
>>
>> Ahh, so you get a deprecation warning on the ftime function declaration,
>> even though itself it is marked deprecated. Oh well. That's not how
>> things work in Java.
>
> On the struct timeb declaration to be more exact, even when then ftime
> is not issued. I would expect a deprecation warning iff the code
> actually uses the struct timeb.
The ftime prototype uses it (in the deprecation sense). This use should
be ignored due to the deprecation attribute on ftime itself, though.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2] Reinstate ftime and move define it for POSIX.1-2001 or older
2020-10-28 13:54 ` Florian Weimer
@ 2020-10-28 14:12 ` Zack Weinberg
0 siblings, 0 replies; 22+ messages in thread
From: Zack Weinberg @ 2020-10-28 14:12 UTC (permalink / raw)
To: Florian Weimer; +Cc: Adhemerval Zanella, GNU C Library
On Wed, Oct 28, 2020 at 9:54 AM Florian Weimer via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> * Adhemerval Zanella:
>
> > On 26/10/2020 13:29, Florian Weimer wrote:
> >> * Adhemerval Zanella:
> >>
> >>> On 26/10/2020 13:19, Florian Weimer wrote:
> >>>> * Adhemerval Zanella:
> >>>>
> >>>>> +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. */
> >>>>> + };
> >>>>
> >>>> I think you could add __attribute_deprecated_msg__ on the struct itself.
> >>>
> >>> I tried to add on it, but it would require to add the warning suppression
> >>> on ftime.c build before the header inclusion and also on check-local header
> >>> tests as well (since it includes).
> >>
> >> Ahh, so you get a deprecation warning on the ftime function declaration,
> >> even though itself it is marked deprecated. Oh well. That's not how
> >> things work in Java.
> >
> > On the struct timeb declaration to be more exact, even when then ftime
> > is not issued. I would expect a deprecation warning iff the code
> > actually uses the struct timeb.
>
> The ftime prototype uses it (in the deprecation sense). This use should
> be ignored due to the deprecation attribute on ftime itself, though.
Workaround: move the complete declaration of struct timeb, with
__attribute_deprecated__, below the declaration of ftime:
__BEGIN_DECLS
/* Forward-declare struct timeb so we can use it in the prototype
of ftime without a spurious deprecation warning.
See GCC bug xxxxxx. */
struct timeb;
/* Fill in TIMEBUF with information about the current time. */
extern int ftime (struct timeb *__timebuf)
__nonnull ((1)) __attribute_deprecated__;
/* 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. */
}
__attribute_deprecated__;
__END_DECLS
zw
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2020-10-28 14:13 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 19:13 [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older Adhemerval Zanella
2020-10-19 19:13 ` [PATCH 2/2] time: Add 64-bit time_t support for ftime Adhemerval Zanella
2020-10-20 8:18 ` Lukasz Majewski
2020-10-27 17:38 ` Joseph Myers
2020-10-27 17:44 ` Adhemerval Zanella
2020-10-20 8:14 ` [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older Lukasz Majewski
2020-10-20 20:33 ` Adhemerval Zanella
2020-10-20 18:04 ` Szabolcs Nagy
2020-10-20 18:20 ` Adhemerval Zanella
2020-10-21 5:17 ` Florian Weimer
2020-10-21 11:03 ` Adhemerval Zanella
2020-10-21 11:05 ` Florian Weimer
2020-10-21 12:35 ` [PATCH v2] " Adhemerval Zanella
2020-10-26 12:17 ` Adhemerval Zanella
2020-10-26 16:03 ` Szabolcs Nagy
2020-10-26 16:13 ` Adhemerval Zanella
2020-10-26 16:19 ` Florian Weimer
2020-10-26 16:23 ` Adhemerval Zanella
2020-10-26 16:29 ` Florian Weimer
2020-10-26 17:09 ` Adhemerval Zanella
2020-10-28 13:54 ` Florian Weimer
2020-10-28 14:12 ` Zack Weinberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).