unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Reinstate ftime and move define it for POSIX.1-2001 or older
@ 2020-10-19 19:13 Adhemerval Zanella via Libc-alpha
  2020-10-19 19:13 ` [PATCH 2/2] time: Add 64-bit time_t support for ftime Adhemerval Zanella via Libc-alpha
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 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 related	[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 via Libc-alpha
2020-10-19 19:13 ` [PATCH 2/2] time: Add 64-bit time_t support for ftime Adhemerval Zanella via Libc-alpha
2020-10-20  8:18   ` Lukasz Majewski
2020-10-27 17:38   ` Joseph Myers
2020-10-27 17:44     ` Adhemerval Zanella via Libc-alpha
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 via Libc-alpha
2020-10-20 18:04 ` Szabolcs Nagy via Libc-alpha
2020-10-20 18:20   ` Adhemerval Zanella via Libc-alpha
2020-10-21  5:17 ` Florian Weimer via Libc-alpha
2020-10-21 11:03   ` Adhemerval Zanella via Libc-alpha
2020-10-21 11:05     ` Florian Weimer via Libc-alpha
2020-10-21 12:35       ` [PATCH v2] " Adhemerval Zanella via Libc-alpha
2020-10-26 12:17         ` Adhemerval Zanella via Libc-alpha
2020-10-26 16:03           ` Szabolcs Nagy via Libc-alpha
2020-10-26 16:13             ` Adhemerval Zanella via Libc-alpha
2020-10-26 16:19         ` Florian Weimer via Libc-alpha
2020-10-26 16:23           ` Adhemerval Zanella via Libc-alpha
2020-10-26 16:29             ` Florian Weimer via Libc-alpha
2020-10-26 17:09               ` Adhemerval Zanella via Libc-alpha
2020-10-28 13:54                 ` Florian Weimer via Libc-alpha
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).