From owner-freebsd-i386@FreeBSD.ORG Sun Nov 14 03:10:23 2004 Return-Path: Delivered-To: freebsd-i386@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ABBCF16A4CE for ; Sun, 14 Nov 2004 03:10:23 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7CD8943D45 for ; Sun, 14 Nov 2004 03:10:23 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id iAE3ANnR060102 for ; Sun, 14 Nov 2004 03:10:23 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id iAE3ANgK060101; Sun, 14 Nov 2004 03:10:23 GMT (envelope-from gnats) Resent-Date: Sun, 14 Nov 2004 03:10:23 GMT Resent-Message-Id: <200411140310.iAE3ANgK060101@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-i386@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ted Schundler Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 62AFC16A4CE for ; Sun, 14 Nov 2004 03:01:50 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 248A743D41 for ; Sun, 14 Nov 2004 03:01:49 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.11/8.12.11) with ESMTP id iAE31nHp003405 for ; Sun, 14 Nov 2004 03:01:49 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.11/8.12.11/Submit) id iAE31n1e003404; Sun, 14 Nov 2004 03:01:49 GMT (envelope-from nobody) Message-Id: <200411140301.iAE31n1e003404@www.freebsd.org> Date: Sun, 14 Nov 2004 03:01:49 GMT From: Ted Schundler To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: i386/73921: sysctlbyname for machdep.tsc_freq doesn't handle speeds > 2^31 Hz properly X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Nov 2004 03:10:23 -0000 >Number: 73921 >Category: i386 >Synopsis: sysctlbyname for machdep.tsc_freq doesn't handle speeds > 2^31 Hz properly >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-i386 >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Nov 14 03:10:23 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Ted Schundler >Release: 5.3-STABLE >Organization: >Environment: FreeBSD ****.scu.edu 5.3-STABLE FreeBSD 5.3-STABLE #4: Mon Oct 18 15:50:18 PDT 2004 ted@****.scu.edu:/usr/obj/usr/src/sys/GX280 i386 >Description: In an app that needs the CPU speed, I'm calling sysctlbyname("machdep.tsc_freq",.... with an 64-bit long long (so when 5GHz CPUs come around, it should still work). However I'm getting very large numbers are a result. It seems that internally it is getting the value as a 32 bit integer and converting that to 64 bits by extending the sign. It shouldn't be 32 bits to begin with imho, but even if it is, it should at least be treated as unsigned. >How-To-Repeat: On a sufficiently fast system (in my case 3.1Ghz): unsigned long long sysctl_data; bl=8; sysctlbyname("machdep.tsc_freq", &sysctl_data,&bl,NULL,0); printf("cpuspeed: %llu\n",sysctl_data); result: cpuspeed: 13817017134246676192 should be: spuspeed: 3192014560 >Fix: >Release-Note: >Audit-Trail: >Unformatted: