From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F1811E04AC; Thu, 3 Apr 2025 10:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743676926; cv=none; b=e1Xkw5rY+k7nbK2HbRCay57BGxokmZWwCCEicL8wHL/AQxzbZTLQP9UzkLKDo0X7FO498FbzCSleuWF/ryqi+Ftb0qsY1MYITesLwiqplolO4SflWY4aoKQX4ueHO7w+X+WPIeLjz7poWfdsK2K0hv+zi626NkZSSwvfE7c2+jU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743676926; c=relaxed/simple; bh=cQ+xu78fnQL2dNMW5nTACbZbpn5DUyuQK9MC0D500po=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=UhVfI/1ZTr4QYIFvSC0PaXWj17gBF8654Ix5XO56C0NLwkqPTyM6vKRQXx8EJ4d3rM2jFitavDkpGBUyC8qHssQjE7G6giAzUi3flZg90iNmOJjKHHewZx7ymvTNfNOjeqe9M/O5suwqnjOhlT02Euno8XtyjOxszbnu1O2us7I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nahMCi8D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nahMCi8D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 991DDC4CEE3; Thu, 3 Apr 2025 10:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743676925; bh=cQ+xu78fnQL2dNMW5nTACbZbpn5DUyuQK9MC0D500po=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nahMCi8DfymJdPrdn7QdiDD3Q8rDwmGOvJf1NoMlk42yNhXZCmhH8ZeJoSeZVMRGe mlLn7120CdMWVO+pvpRFrjFMysdwrEUOH93be8/cDYcrfqL2wLp0eMqudzz1g7b9Wc tGXtxBwGirpcKDB14QfW1H6Y3MC4HHvJuaXYtv9nMHguhCBJg44ZzkNrFbo3+X+bfo ZOi7GyCd1H9ZDWQiEAmuasS4pR8NpKq8PBjgV7CMcTxaFKBXqj7/rOFb+0yWZRmEsK qRlnBZI82XIyl0QFDyYLaATLWm0SgrvsM8SxHTbmTHTDSV0hxac8K7/3iJEQqnGtup HLlsP/XuITz0w== From: Andreas Hindborg To: "FUJITA Tomonori" Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v11 4/8] rust: time: Introduce Instant type In-Reply-To: <20250403.134038.2188356790179825602.fujita.tomonori@gmail.com> (FUJITA Tomonori's message of "Thu, 03 Apr 2025 13:40:38 +0900") References: <20250220070611.214262-1-fujita.tomonori@gmail.com> <20250220070611.214262-5-fujita.tomonori@gmail.com> <87iko1b213.fsf@kernel.org> <20250403.134038.2188356790179825602.fujita.tomonori@gmail.com> User-Agent: mu4e 1.12.7; emacs 29.4 Date: Thu, 03 Apr 2025 12:41:52 +0200 Message-ID: <87cydtv85r.fsf@kernel.org> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "FUJITA Tomonori" writes: > On Sat, 22 Mar 2025 14:58:16 +0100 > Andreas Hindborg wrote: > >> FUJITA Tomonori writes: >> >>> Introduce a type representing a specific point in time. We could use >>> the Ktime type but C's ktime_t is used for both timestamp and >>> timedelta. To avoid confusion, introduce a new Instant type for >>> timestamp. >>> >>> Rename Ktime to Instant and modify their methods for timestamp. >>> >>> Implement the subtraction operator for Instant: >>> >>> Delta = Instant A - Instant B >>> >>> Tested-by: Daniel Almeida >>> Reviewed-by: Boqun Feng >>> Reviewed-by: Gary Guo >>> Reviewed-by: Fiona Behrens >>> Signed-off-by: FUJITA Tomonori >> >> >> Reviewed-by: Andreas Hindborg >> >> >> As Boqun mentioned, we should make this generic over `ClockId` when the >> hrtimer patches land. > > Seems that I overlooked his mail. Can you give me a pointer? > > I assume that you want the Instance type to vary depending on the > clock source. Yea, basically it is only okay to subtract instants if they are derived from the same clock source. Boqun suggested here [1] before hrtimer patches landed I think. At any rate, now we have `kernel::time::ClockId`. It is an enum though, so I am not sure how to go about it in practice. But we would want `Instant - Instant` to give a compiler error. Best regards, Andreas Hindborg [1] https://lore.kernel.org/all/ZxwFyl0xIje5gv7J@Boquns-Mac-mini.local