2 * have_gettime - determine if we have clock_gettime()
4 * Copyright (C) 1999 Landon Curt Noll
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.1 $
21 * @(#) $Id: have_gettime.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/RCS/have_gettime.c,v $
24 * Under source code control: 1999/10/20 23:43:42
25 * File existed as early as: 1999
27 * chongo <was here> /\oo/\ http://www.isthe.com/chongo/
28 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
35 * Not all systems have the clock_gettime() function, so this may not
36 * compile on your system.
38 * This prog outputs several defines:
41 * defined ==> use clock_gettime() for either CLOCK_SGI_CYCLE
42 * and/or CLOCK_REALTIME
43 * undefined ==> clock_gettime() is not available for both
44 * CLOCK_SGI_CYCLE and CLOCK_REALTIME
53 #if defined(HAVE_NO_GETTIME)
55 printf("#undef HAVE_GETTIME /* no */\n");
57 #else /* HAVE_NO_GETTIME */
59 # if defined(CLOCK_SGI_CYCLE)
61 struct timespec sgi_cycle
; /* SGI hardware clock */
62 (void) clock_gettime(CLOCK_SGI_CYCLE
, &sgi_cycle
);
63 printf("#define HAVE_GETTIME /* yes - w/CLOCK_SGI_CYCLE */\n");
65 # elif defined(CLOCK_REALTIME)
67 struct timespec realtime
; /* POSIX realtime clock */
68 (void) clock_gettime(CLOCK_REALTIME
, &realtime
);
69 printf("#define HAVE_GETTIME /* yes - CLOCK_REALTIME only */\n");
73 printf("#undef HAVE_GETTIME /* no - no SGI_CYCLE and no REALTIME */\n");
75 # endif /* CLOCK_REALTIME */
77 #endif /* HAVE_NO_GETTIME */