* [Ada] The Unix Epochalypse of 2038 - Use OS_Time
@ 2021-07-05 13:13 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-07-05 13:13 UTC (permalink / raw)
To: gcc-patches; +Cc: Doug Rupp
[-- Attachment #1: Type: text/plain, Size: 379 bytes --]
__gnat_set_file_time_name is called from Ada with OS_Time, but the C
function argument is time_t. This is a violation of the interface rule
that calls to the C parts use OS_Time. It currently works by accident.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* adaint.h (__gnat_set_file_time_name): Use OS_Time.
* adaint.c (__gnat_set_file_time_name): Likewise.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1150 bytes --]
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -1570,7 +1570,7 @@ extern long long __gnat_file_time(char* name)
/* Set the file time stamp. */
void
-__gnat_set_file_time_name (char *name, time_t time_stamp)
+__gnat_set_file_time_name (char *name, OS_Time time_stamp)
{
#if defined (__vxworks)
@@ -1606,7 +1606,7 @@ __gnat_set_file_time_name (char *name, time_t time_stamp)
time_t t;
/* Set modification time to requested time. */
- utimbuf.modtime = time_stamp;
+ utimbuf.modtime = (time_t) time_stamp;
/* Set access time to now in local time. */
t = time (NULL);
diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h
--- a/gcc/ada/adaint.h
+++ b/gcc/ada/adaint.h
@@ -201,7 +201,7 @@ extern OS_Time __gnat_file_time_name (char *);
extern OS_Time __gnat_file_time_fd (int);
/* return -1 in case of error */
-extern void __gnat_set_file_time_name (char *, time_t);
+extern void __gnat_set_file_time_name (char *, OS_Time);
extern int __gnat_dup (int);
extern int __gnat_dup2 (int, int);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-05 13:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 13:13 [Ada] The Unix Epochalypse of 2038 - Use OS_Time Pierre-Marie de Rodat
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).