From patchwork Fri Apr 17 07:05:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11494243 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 911C56CA for ; Fri, 17 Apr 2020 07:06:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E918221F7 for ; Fri, 17 Apr 2020 07:06:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="IHlDk+s/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E918221F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPL4j-0001iU-1G; Fri, 17 Apr 2020 07:06:09 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPL4i-0001iJ-LZ for xen-devel@lists.xen.org; Fri, 17 Apr 2020 07:06:08 +0000 X-Inumbo-ID: e6d588fd-8079-11ea-8c80-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e6d588fd-8079-11ea-8c80-12813bfff9fa; Fri, 17 Apr 2020 07:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1587107165; x=1618643165; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=493GNuIf5KbW+Y/729Kw1IKQ8Uqsew/NWiY7HpkG1hg=; b=IHlDk+s/fHSacLfqJM1ZyUhysyyzv1zhiljbsKiX5C+T2+uj7ZiuIcX5 yxeXjz8iSBpDQ8fSLqfmzhOB4LA/ZsYxkVFbhKY6VAu3DDi2GTIgQ+yEH DPt7St+azVfn42SSIKa+jI8awMzMSBhoQf+cJgd6uxycHhsb6Jv/gGGp3 c=; IronPort-SDR: bB/uFZXPLRh/pPukLbf1/QJKMR4TloS6qG2sZfxHgYCMOuZ1ys2ILsDEwcKqcvWmqOjiZ+9jNp Mmn+b03wsatw== X-IronPort-AV: E=Sophos;i="5.72,394,1580774400"; d="scan'208";a="26002075" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 17 Apr 2020 07:05:47 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com (Postfix) with ESMTPS id 32E3AA24C6; Fri, 17 Apr 2020 07:05:46 +0000 (UTC) Received: from EX13D02EUB001.ant.amazon.com (10.43.166.150) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 17 Apr 2020 07:05:45 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13D02EUB001.ant.amazon.com (10.43.166.150) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 17 Apr 2020 07:05:44 +0000 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.62.224) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 17 Apr 2020 07:05:43 +0000 From: Pawel Wieczorkiewicz To: Subject: [XTF 3/6] time: add gettimeofday() function to time managment Date: Fri, 17 Apr 2020 07:05:25 +0000 Message-ID: <20200417070528.48329-4-wipawel@amazon.de> X-Mailer: git-send-email 2.16.6 In-Reply-To: <20200417070528.48329-1-wipawel@amazon.de> References: <20200417070528.48329-1-wipawel@amazon.de> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: semelpaul@gmail.com, andrew.cooper3@citrix.com, julien@xen.org, nmanthey@amazon.de, paul@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Semel Signed-off-by: Paul Semel --- common/time.c | 14 ++++++++++++++ include/xtf/time.h | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/common/time.c b/common/time.c index 7decd07..fffae1c 100644 --- a/common/time.c +++ b/common/time.c @@ -90,6 +90,20 @@ uint64_t current_time(void) return seconds + (since_boot_time() / 1000000000); } +/* The POSIX gettimeofday syscall normally takes a second argument, which is + * the timezone (struct timezone). However, it sould be NULL because linux + * doesn't use it anymore. So we need for us to add it in this function + */ +int gettimeofday(struct timeval *tp) +{ + if (!tp) + return -1; + + tp->sec = current_time(); + tp->nsec = shared_info.wc_nsec + (since_boot_time() % 1000000000); + return 0; +} + /* * Local variables: * mode: C diff --git a/include/xtf/time.h b/include/xtf/time.h index 52da27a..e312465 100644 --- a/include/xtf/time.h +++ b/include/xtf/time.h @@ -8,6 +8,16 @@ #include +struct timeval { +#if !defined(__i386__) + uint64_t sec; + uint64_t nsec; +#else + uint32_t sec; + uint32_t nsec; +#endif +}; + #if defined(__i386__) /* Time from boot in nanoseconds */ uint32_t since_boot_time(void); @@ -19,6 +29,8 @@ uint64_t since_boot_time(void); uint64_t current_time(void); #endif +int gettimeofday(struct timeval *tp); + #endif /* XTF_TIME_H */ /*