From owner-freebsd-hackers@FreeBSD.ORG Fri May 9 18:17:29 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41A9C106564A for ; Fri, 9 May 2008 18:17:29 +0000 (UTC) (envelope-from bahamasfranks@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.240]) by mx1.freebsd.org (Postfix) with ESMTP id EE9CD8FC12 for ; Fri, 9 May 2008 18:17:28 +0000 (UTC) (envelope-from bahamasfranks@gmail.com) Received: by an-out-0708.google.com with SMTP id b33so328829ana.13 for ; Fri, 09 May 2008 11:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; bh=8rHG0bMg+n8taySfHuop8yIAR2kdmieDuFxBUgr/NSE=; b=kzRhOs1aEoaRsLWAZ8Br8fv31NoyvEid4n1Sr8nCt1nrXH2ZLoVcrzU9QvSO/JdELQhx0alUuKxATgDZRN3T8cGe9RmIN87nsdZXEn3ECGl8hI/uC+wOVygvjks0tUwZ+a27NmYpzxcjjteeFRfzPIXK+yN2ESowlfehkxbOt9E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=VoesEU6Azd2WhuKkmzsnz1t3ldpApxkEu1mT3dErKJNZhCK+U6C5fIU5ex3hWGflKB1MdBTvZF27X/70mSZSLRFsPRQRGWpXHfDk9Pbs7nXUQdCzgrLsSDVCDk5W81OC29tWDMUMkQND8SYCjkezeEZ9j2K7JZYNxWPPihhX/fQ= Received: by 10.100.41.8 with SMTP id o8mr6195116ano.82.1210357047345; Fri, 09 May 2008 11:17:27 -0700 (PDT) Received: by 10.100.239.17 with HTTP; Fri, 9 May 2008 11:17:27 -0700 (PDT) Message-ID: <539c60b90805091117l57ed9966h99d6ae5f45925cdf@mail.gmail.com> Date: Fri, 9 May 2008 11:17:27 -0700 From: "Steve Franks" Sender: bahamasfranks@gmail.com To: freebsd-hackers MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 12198b4e04df3e05 Subject: CLOCK_REALTIME undefined on my system X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: stevefranks@ieee.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 May 2008 18:17:29 -0000 The manpage (http://www.freebsd.org/cgi/man.cgi?query=clock_gettime&sektion=2&apropos=0&manpath=FreeBSD+7.0-RELEASE) for clock_gettime() specifies the correct header as , which I am using, and I don't see any errors on clock_gettime(), but the param I need, listed in the manpage, CLOCK_REALTIME is undefined. Any ideas how this could be? I've recently cvsup'd standard-supfile, so you'd think I'm up to date... I'm also getting an implicit declaration of isnormal(), and math.h is clearly included... Steve /* * fclock.c * * Copyright (C) 2005 Hein Roehrig * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * */ #define _ISOC99_SOURCE #define _POSIX_C_SOURCE 199309L #include #include #include #include #ifndef __MINGW32__ #include #endif #include #include /* ------------------------------------------------------------------ */ #ifdef __APPLE__ #include #include #include long double frealtime() { long double result; static uint64_t start_mat; static long double start_time; static double multiplier; mach_timebase_info_data_t mtid; struct timeval tv; if(!mtid.denom == 0) { mach_timebase_info(&mtid); multiplier = (double)mtid.numer / (double)mtid.denom; gettimeofday(&tv, NULL); start_time = (long double)tv.tv_sec + (long double)tv.tv_usec * 1000.0; start_mat = mach_absolute_time(); } result = start_time + (mach_absolute_time() - start_mat) * multiplier; assert(isnormal(result)); assert(result > 0); return result; } #else /* def __APPLE__ */ /* ------------------------------------------------------------------ */ #ifdef _POSIX_TIMERS long double frealtime() { long double result; struct timespec t; if (clock_gettime(CLOCK_REALTIME, &t)==-1) { perror("frealtime (clock_gettime)"); exit(EXIT_FAILURE); } result = (long double)t.tv_sec + (long double)t.tv_nsec*(long double)1e-9; assert(isnormal(result)); assert(result > 0); return result; } #else /* def _POSIX_TIMERS */ /* ------------------------------------------------------------------ */ #ifdef __MINGW32__ #include long double frealtime() { long double result; struct timeb t; ftime(&t); result = (long double)t.time + (long double)t.millitm * (long double)1e-3; assert(isnormal(result)); assert(result > 0); return result; } #else /* def __MINGW32__ */ /* ------------------------------------------------------------------ */ #ifndef CLK_TCK static clock_t CLK_TCK = 0; static void set_clk_tck(void) __attribute__ ((constructor)); static void set_clk_tck(void) { long v = sysconf(_SC_CLK_TCK); if (v == -1) { perror("sysconf(_SC_CLK_TCK)"); exit(EXIT_FAILURE); } CLK_TCK = v; } #endif long double frealtime() { long double result; struct tms t; clock_t c=times(&t); if (c==(clock_t)-1) { perror("frealtime (times)"); exit(EXIT_FAILURE); } result = (long double)c/CLK_TCK; assert(isnormal(result)); assert(result > 0); return result; } #endif #endif #endif