From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70681 invoked by alias); 13 Sep 2018 15:58:29 -0000 Mailing-List: contact newlib-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-cvs-owner@sourceware.org Received: (qmail 70615 invoked by uid 9067); 13 Sep 2018 15:58:29 -0000 Date: Thu, 13 Sep 2018 15:58:00 -0000 Message-ID: <20180913155829.70612.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Hans-Peter Nilsson To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Committed, CRIS port: fix fallout from time_t defaulting to 64 bits, part 1 X-Act-Checkin: newlib-cygwin X-Git-Author: Hans-Peter Nilsson X-Git-Refname: refs/heads/master X-Git-Oldrev: d83404e41808421442c8257392ecd095042cbfbf X-Git-Newrev: a6837ca34f9aebe1bada63334eaedb5866beaa4f X-SW-Source: 2018-q3/txt/msg00121.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a6837ca34f9aebe1bada63334eaedb5866beaa4f commit a6837ca34f9aebe1bada63334eaedb5866beaa4f Author: Hans-Peter Nilsson Date: Thu Sep 13 17:45:39 2018 +0200 Committed, CRIS port: fix fallout from time_t defaulting to 64 bits, part 1 It's been a while... I see the CRIS port broke with the time_t-default-to-64-bit change, observable by a few test-cases in the gcc fortran(!) tests failing, regressing when trying a recent newlib. This is a two-part belt-and-suspenders change: adjust the CRIS port gettimeofday syscall (the only one in newlib/CRIS passing a time_t or struct timeval) to handle a userspace 64-bit time_t and secondly default time_t to 32-bit long anyway. I considered making the local "kernel_timeval" copy in _gettimeofday conditional on (userspace) time_t being 64 bits, but thought it not worth bothering with the few move insns. The effect of a 64-bit time_t is however observable as longer simulation time when running the gcc testsuite and as bigger binaries without any actual upside from the larger time_t size, so I thought better make the default for this port go back to being a "long" again. Tested by running the gcc testsuite over the three combinations of two parts of the patch and observing the expected changes. Committed. libgloss: Adjust for syscall and userspace having different time_t or timeval. * cris/linunistd.h (kernel_time_t, kernel_suseconds_t, kernel_timeval): New types. (gettimeofday): Change the type of the first argument to be a pointer to a struct kernel_timeval. * cris/gensyscalls (_gettimeofday): Use an intermediate struct kernel_timeval for the syscall and initialize the result from that. Signed-off-by: Hans-Peter Nilsson Diff: --- libgloss/cris/gensyscalls | 14 +++++++++++--- libgloss/cris/linunistd.h | 12 ++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/libgloss/cris/gensyscalls b/libgloss/cris/gensyscalls index b885a20..3e2f9af 100644 --- a/libgloss/cris/gensyscalls +++ b/libgloss/cris/gensyscalls @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2005 Axis Communications. +# Copyright (C) 2005, 2018 Axis Communications. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -93,8 +93,16 @@ cat > gettod.c < #include int -_gettimeofday (struct timeval *tp, void *tzp -${r}gettimeofday (tp, tzp)) +_gettimeofday (struct timeval *tp, void *tzp) +{ + struct kernel_timeval kt; + int retval = _Sys_gettimeofday(&kt, tzp); + if (retval == 0) + { + tp->tv_sec = kt.tv_sec; + tp->tv_usec = kt.tv_usec; + } + R (retval) EOF cat > isatty.c <