Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932265AbWB0IWi (ORCPT ); Mon, 27 Feb 2006 03:22:38 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932245AbWB0IWh (ORCPT ); Mon, 27 Feb 2006 03:22:37 -0500 Received: from pentafluge.infradead.org ([213.146.154.40]:6321 "EHLO pentafluge.infradead.org") by vger.kernel.org with ESMTP id S932301AbWB0IWh (ORCPT ); Mon, 27 Feb 2006 03:22:37 -0500 Subject: Re: [Patch 1/7] timespec diff utility From: Arjan van de Ven To: nagar@watson.ibm.com Cc: linux-kernel , lse-tech In-Reply-To: <1141027367.5785.42.camel@elinux04.optonline.net> References: <1141026996.5785.38.camel@elinux04.optonline.net> <1141027367.5785.42.camel@elinux04.optonline.net> Content-Type: text/plain Date: Mon, 27 Feb 2006 09:22:34 +0100 Message-Id: <1141028554.2992.53.camel@laptopd505.fenrus.org> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-SRS-Rewrite: SMTP reverse-path rewritten from by pentafluge.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 871 Lines: 28 > +/* > + * timespec_diff_ns - Return difference of two timestamps in nanoseconds > + * In the rare case of @end being earlier than @start, return zero > + */ > +static inline nsec_t timespec_diff_ns(struct timespec *start, struct timespec *end) > +{ > + nsec_t ret; > + > + ret = (nsec_t)(end->tv_sec - start->tv_sec)*NSEC_PER_SEC; > + ret += (nsec_t)(end->tv_nsec - start->tv_nsec); > + if (ret < 0) > + return 0; > + return ret; > +} > #endif /* __KERNEL__ */ > wouldn't it be more useful to have this return a timespec as well, and then it'd be generically useful (and it also probably should then be uninlined ;) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/