Re: [PUSHED] amdgcn: Provide stub 'gettimeofday'

Brian Inglis <[email protected]> Tue, 14 Apr 2026 00:04:19 -0600
Newsgroups gmane.comp.lib.newlib
Organization Systematic Software
Message-ID <[email protected]>
On 2026-04-13 15:40, Thomas Schwinge wrote:
> Similar to nvptx commit 52cb9370044d11a29ae0dc1120ffdf246f5abc20
> "nvptx: Provide stub 'gettimeofday'": instead of them FAILing due to
> 'ld: error: undefined symbol: gettimeofday', this makes PASS a number of GCC
> 'gfortran.dg' test cases, for example.
> ---
>   newlib/Makefile.in                    | 23 +++++++++++++++++++++--
>   newlib/libc/sys/amdgcn/Makefile.inc   |  2 +-
>   newlib/libc/sys/amdgcn/gettimeofday.c |  9 +++++++++
>   3 files changed, 31 insertions(+), 3 deletions(-)
>   create mode 100644 newlib/libc/sys/amdgcn/gettimeofday.c

> diff --git a/newlib/libc/sys/amdgcn/gettimeofday.c b/newlib/libc/sys/amdgcn/gettimeofday.c
> new file mode 100644
> index 0000000000..8ce09a210c
> --- /dev/null
> +++ b/newlib/libc/sys/amdgcn/gettimeofday.c
> @@ -0,0 +1,9 @@
> +#include <sys/time.h>
> +#include <errno.h>
> +
> +int
> +gettimeofday (struct timeval *tv, void *tz)
> +{
> +  errno = ENOSYS;
> +  return -1;
> +}

Would be nice to make the declarations and definitions match POSIX (and Cygwin), 
and add the embedded function docs like other man pages; see Timefns:

https://cygwin.com/git?p=newlib-cygwin.git;a=blob_plain;f=newlib/libc/time/time.tex

https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/time/time.c

and Posix:

https://cygwin.com/git?p=newlib-cygwin.git;a=blob_plain;f=newlib/libc/posix/posix.tex

https://cygwin.com/git?p=newlib-cygwin.git;a=blob_plain;f=newlib/libc/posix/popen.c

so they will be generated in the newlib libc info pages; see also:

https://git.kernel.org/pub/scm/docs/man-pages/man-pages-posix.git/tree/man-pages-posix-2017/man3p/gettimeofday.3p

'\" et
.TH GETTIMEOFDAY "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" modified Linux -> newlib
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The newlib implementation of this interface may differ (consult
the corresponding newlib manual page for details of newlib behavior),
or the interface may not be implemented in newlib.
.\"
.SH NAME
gettimeofday
\(em get the date and time
SH SYNOPSIS
.LP
.nf
#include <sys/time.h>
.P
int gettimeofday(struct timeval *restrict \fItp\fP, void *restrict \fItzp\fP);
.fi
...
.SH "RETURN VALUE"
The
\fIgettimeofday\fR()
function shall return 0 and no value shall be reserved to indicate
an error.
.SH ERRORS
No errors are defined.
...

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                 -- Antoine de Saint-Exupéry