lkml.org 
[lkml]   [2012]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [tip:perf/core] perf/x86: Add generic Intel uncore PMU support
On Thu, 21 Jun 2012 16:22:50 -0700
"H. Peter Anvin" <hpa@zytor.com> wrote:

> On 06/21/2012 04:18 PM, Andrew Morton wrote:
> >>
> >> So why is ktime_t unsigned?
> >
> > err, actually, it isn't. But lots of the APIs to manipulate ktime_t
> > use u64. Reason?
> >
> > I do agree that time quantities should be signed.
>
> No idea... probably because when representing an actual wall time since
> the POSIX epoch that can happen during the poweron time on the system,
> the number will be positive since the POSIX epoch predates Linux.
>

hm.

I'll stick this in my tree and see what happens:

From: Andrew Morton <akpm@linux-foundation.org>
Subject: include/linux/time.h: make NSEC_PER_SEC 64-bit on 32-bit architectures

Nanoseconds are usually represented with 64-bit types (s64 and sometimes
u64). The 32-bit definition of NSEC_PER_SEC can lead to compile-time and
runtime arithmetic overflows on 32-bit systems.

So switch NSEC_PER_SEC to a 64-bit type using "LL".

Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@tglx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

include/linux/time.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN include/linux/time.h~include-linux-timeh-make-nsec_per_sec-64-bit-on-32-bit-architectures include/linux/time.h
--- a/include/linux/time.h~include-linux-timeh-make-nsec_per_sec-64-bit-on-32-bit-architectures
+++ a/include/linux/time.h
@@ -37,7 +37,7 @@ extern struct timezone sys_tz;
#define NSEC_PER_USEC 1000L
#define NSEC_PER_MSEC 1000000L
#define USEC_PER_SEC 1000000L
-#define NSEC_PER_SEC 1000000000L
+#define NSEC_PER_SEC 1000000000LL
#define FSEC_PER_SEC 1000000000000000LL

#define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
_


\
 
 \ /
  Last update: 2012-06-22 01:41    [W:0.077 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site