From patchwork Mon Aug 19 08:39:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1149118 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507230-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="X8tutQaf"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46BnVM0C4Cz9s3Z for ; Mon, 19 Aug 2019 18:42:18 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=rfEso+FY+GIlmp/sMCvHnxBUyhp2oT4s6RI5XJts3Zb8hx0vul RYbB7OpHXNk/wd60d4zcttUWbn/3E7PUQ8frHEAtlYbGqDa6utv3pyP0xamaD+6x l9qlMW8mY5mFG+4lhrvXyidtYrZkb1MXX+q/UDOR9ONRqVSyViLjl9P+A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=P5POMeoBSu49VnCU05YQNy0e4PE=; b=X8tutQafCw9LyywaG9JZ PgL0reSKKc2kK3lqcJrBni3hF7s8dlDXV10VQNWsJW6+mX+76K1KBS+UdFTzdJUE QbNJbIQwIJtt2koxfG8cuz+nbOQMfeDnQOIw6hgDy1mf7ibqQPLWuA9SRcH/FV0J h+3+g7CjshoUZXNS4IbYqjk= Received: (qmail 118165 invoked by alias); 19 Aug 2019 08:39:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 116733 invoked by uid 89); 19 Aug 2019 08:39:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=libgnat X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Aug 2019 08:39:13 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzdC1-0007z1-Cf for gcc-patches@gcc.gnu.org; Mon, 19 Aug 2019 04:39:11 -0400 Received: from rock.gnat.com ([205.232.38.15]:53979) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hzdBz-0007vS-Cu for gcc-patches@gcc.gnu.org; Mon, 19 Aug 2019 04:39:07 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 022B156054; Mon, 19 Aug 2019 04:39:03 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id q+uwihsBpPqe; Mon, 19 Aug 2019 04:39:02 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id E4D5B11619A; Mon, 19 Aug 2019 04:39:02 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id E3E1D6AB; Mon, 19 Aug 2019 04:39:02 -0400 (EDT) Date: Mon, 19 Aug 2019 04:39:02 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Dmitriy Anisimkov Subject: [Ada] Conversion routines between GNAT.OS_Lib.OS_Time and long integer Message-ID: <20190819083902.GA33534@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 205.232.38.15 X-IsSubscribed: yes The new routines convert back and forth between private type OS_Time and a long integer which can be used in package Ada.Calendar.Conversions routines to convert to Ada.Calendar.Time. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-19 Dmitriy Anisimkov gcc/ada/ * libgnat/s-os_lib.ads, libgnat/s-os_lib.adb (To_Ada, To_C): New routines. --- gcc/ada/libgnat/s-os_lib.adb +++ gcc/ada/libgnat/s-os_lib.adb @@ -2979,6 +2979,15 @@ package body System.OS_Lib is end loop; end Spawn_Internal; + ------------ + -- To_Ada -- + ------------ + + function To_Ada (Time : time_t) return OS_Time is + begin + return OS_Time (Time); + end To_Ada; + --------------------------- -- To_Path_String_Access -- --------------------------- @@ -3008,6 +3017,15 @@ package body System.OS_Lib is return Return_Val; end To_Path_String_Access; + ---------- + -- To_C -- + ---------- + + function To_C (Time : OS_Time) return time_t is + begin + return time_t (Time); + end To_C; + ------------------ -- Wait_Process -- ------------------ --- gcc/ada/libgnat/s-os_lib.ads +++ gcc/ada/libgnat/s-os_lib.ads @@ -164,6 +164,15 @@ package System.OS_Lib is -- component parts to be interpreted in the local time zone, and returns -- an OS_Time. Returns Invalid_Time if the creation fails. + subtype time_t is Long_Integer; + -- C time_t type of the time representation + + function To_C (Time : OS_Time) return time_t; + -- Convert OS_Time to C time_t type + + function To_Ada (Time : time_t) return OS_Time; + -- Convert C time_t type to OS_Time + ---------------- -- File Stuff -- ---------------- @@ -1107,6 +1116,8 @@ private pragma Inline (">"); pragma Inline ("<="); pragma Inline (">="); + pragma Inline (To_C); + pragma Inline (To_Ada); type Process_Id is new Integer; Invalid_Pid : constant Process_Id := -1;