From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1147) id 4857F3858294; Tue, 13 Feb 2024 12:25:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4857F3858294 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707827119; bh=jHBungRf3YwQilvZIi9exnN0x4THUi0+ujVmmwre6aU=; h=From:To:Subject:Date:From; b=pr3+we0QMzLrCk8UdwaMuh4XvZqvtu1xbzbiNcrknqTKPZMOvYpOGfNRM5N62+JuT 8NNQqfzC2ulz3G2rMZPH9o4SQziMw2mhHLn4wnxQPLYUdBL4m9ak2hKd8tpf8mzo7T 7n8E/r9ICHfg4CbJQpdM7oyuwNo+tFypnTBMFsR0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Rainer Orth To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8955] libgm2: Fix libm2iso/wraptime.cc compilation on Solaris X-Act-Checkin: gcc X-Git-Author: Rainer Orth X-Git-Refname: refs/heads/master X-Git-Oldrev: 743577e36de66a082d329f71877789599f3ee3b5 X-Git-Newrev: efc71fd57539421c3939b1fe7594862d0fc66cdb Message-Id: <20240213122519.4857F3858294@sourceware.org> Date: Tue, 13 Feb 2024 12:25:19 +0000 (GMT) List-Id: https://gcc.gnu.org/g:efc71fd57539421c3939b1fe7594862d0fc66cdb commit r14-8955-gefc71fd57539421c3939b1fe7594862d0fc66cdb Author: Rainer Orth Date: Tue Feb 13 13:24:43 2024 +0100 libgm2: Fix libm2iso/wraptime.cc compilation on Solaris As it turned out, my patch to complete the libgm2 autoconf macros works on both Linux/sparc64 and Linux/x86_64, but breaks Solaris bootstrap: /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc: In function 'int m2iso_wraptime_gettimeofday(void*, timezone*)': /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc:148:24: error: invalid conversion from 'void*' to 'timeval*' [-fpermissive] 148 | return gettimeofday (tv, tz); | ^~ | | | void* In file included from /usr/include/sys/select.h:27, from /usr/include/sys/types.h:665, from /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc:35: /usr/include/sys/time.h:444:18: note: initializing argument 1 of 'int gettimeofday(timeval*, void*)' 444 | int gettimeofday(struct timeval *_RESTRICT_KYWD, void *_RESTRICT_KYWD); | ^ /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc: In function 'int m2iso_wraptime_settimeofday(void*, timezone*)': /vol/gcc/src/hg/master/local/libgm2/libm2iso/wraptime.cc:165:24: error: invalid conversion from 'void*' to 'timeval*' [-fpermissive] 165 | return settimeofday (tv, tz); | ^~ | | | void* /usr/include/sys/time.h:431:18: note: initializing argument 1 of 'int settimeofday(timeval*, void*)' 431 | int settimeofday(struct timeval *, void *); | ^~~~~~~~~~~~~~~~ This happens because on Linux only HAVE_[GS]ETTIMEOFDAY is defined, while Solaris has both that and HAVE_STRUCT_TIMEZONE, selecting different implementations. Fixed by casting tv to struct timeval *. I thought about changing the signatures instead to take a struct timeval * instead, but that seemed risky given that there's a HAVE_STRUCT_TIMEVAL, so would probably break other targets. Bootstrapped without regressions on i386-pc-solaris2.11, sparc-sun-solaris2.11, and x86_64-pc-linux-gnu. 2024-02-13 Rainer Orth libgm2: * libm2iso/wraptime.cc [HAVE_STRUCT_TIMEZONE && HAVE_GETTIMEOFDAY] (EXPORT(gettimeofday)): Cast tv to struct timeval *. [HAVE_STRUCT_TIMEZONE && HAVE_SETTIMEOFDAY] (EXPORT(settimeofday)): Likewise. Diff: --- libgm2/libm2iso/wraptime.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgm2/libm2iso/wraptime.cc b/libgm2/libm2iso/wraptime.cc index f1158ae7d38f..158086b75cc0 100644 --- a/libgm2/libm2iso/wraptime.cc +++ b/libgm2/libm2iso/wraptime.cc @@ -145,7 +145,7 @@ EXPORT(KillTM) (struct tm *tv) extern "C" int EXPORT(gettimeofday) (void *tv, struct timezone *tz) { - return gettimeofday (tv, tz); + return gettimeofday ((struct timeval *) tv, tz); } #else extern "C" int @@ -162,7 +162,7 @@ EXPORT(gettimeofday) (void *tv, void *tz) extern "C" int EXPORT(settimeofday) (void *tv, struct timezone *tz) { - return settimeofday (tv, tz); + return settimeofday ((struct timeval *) tv, tz); } #else extern "C" int