From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id C984339518B4 for ; Mon, 19 Apr 2021 04:19:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C984339518B4 Received: from vapier (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E1AC7340E15; Mon, 19 Apr 2021 04:19:41 +0000 (UTC) Date: Mon, 19 Apr 2021 00:19:41 -0400 From: Mike Frysinger To: Jim Wilson Cc: gdb-patches@sourceware.org, Kuan-Lin Chen Subject: Re: [PATCH 13/24] RISC-V sim: Add gettimeofday. Message-ID: Mail-Followup-To: Jim Wilson , gdb-patches@sourceware.org, Kuan-Lin Chen References: <20210417175831.16413-1-jimw@sifive.com> <20210417175831.16413-14-jimw@sifive.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210417175831.16413-14-jimw@sifive.com> X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Apr 2021 04:19:43 -0000 On 17 Apr 2021 10:58, Jim Wilson wrote: > + case TARGET_SYS_gettimeofday: > + { > + int rv; > + struct timeval tv; > + > + rv = gettimeofday (&tv, 0); > + if (RISCV_XLEN (cpu) == 32) > + { > + sim_core_write_unaligned_4 (cpu, cpu->pc, write_map, > + cpu->a0, tv.tv_sec); > + sim_core_write_unaligned_4 (cpu, cpu->pc, write_map, > + cpu->a0 + 4, > + tv.tv_usec); > + } > + else > + { > + sim_core_write_unaligned_8 (cpu, cpu->pc, write_map, > + cpu->a0, tv.tv_sec); > + sim_core_write_unaligned_8 (cpu, cpu->pc, write_map, > + cpu->a0 + 8, > + tv.tv_usec); > + } this is incomplete/buggy. if arg0==0, you'll write to the wrong place. if arg1!=0, you leave the memory uninitialized. if rv!=0, you write to the arg0 struct. see bfin/interp.c for a "full" implementation. if we extended host_callback_struct to include a timeval_map, we would be able to implement this in the common code and do so with full support for everyone. -mike