summaryrefslogtreecommitdiff
path: root/mcon/U/d_difftime.U
blob: 34e9430eaff5dfabe592e22f593b11292398b01d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
?RCS: $Id: d_difftime.U 167 2013-05-08 17:58:00Z rmanfredi $
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, 2013 Raphael Manfredi
?RCS: 
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: Original Author: Andy Dougherty <doughera@lafcol.lafayette.edu>
?RCS:
?MAKE:d_difftime use_difftime: Assert Trylink cat
?MAKE:	-pick add $@ %<
?S:d_difftime:
?S:	This variable conditionally defines the HAS_DIFFTIME symbol, which
?S:	indicates to the C program that the difftime() routine is available.
?S:.
?S:use_difftime:
?S:	This variable conditionally defines the USE_DIFFTIME symbol, which
?S:	indicates to the C program that the difftime() routine should be
?S:	used to compare times.
?S:.
?C:HAS_DIFFTIME :
?C:	This symbol, if defined, indicates that the difftime routine is
?C:	available.
?C:.
?C:USE_DIFFTIME :
?C:	This symbol, if defined, indicates that the difftime routine should
?C:	really be used to compare times.
?C:.
?H:#$d_difftime HAS_DIFFTIME		/**/
?H:#$use_difftime USE_DIFFTIME		/**/
?H:.
?LINT:set d_difftime use_difftime
?T:avoid_difftime
: see if difftime exists
$cat >try.c <<EOC
#include <time.h>
int main(void)
{
	static double ret;
	static time_t t0, t1;
	ret = difftime(t1, t0) * 1.0;
	return ret ? 0 : 1;
}
EOC
cyn=difftime
set d_difftime
eval $trylink

@if USE_DIFFTIME || use_difftime
: see whether difftime should be used
case "$d_difftime" in
"$define")
	$cat >try.c <<EOC
#include "static_assert.h"
#include <time.h>
int main(void)
{
?X: If time_t is not a signed integer type, we cannot calculate properly
?X: with the raw values. Define USE_DIFFTIME when this does not compile.
	STATIC_ASSERT((time_t) -1 < 0);
	return 0;
}
EOC
	cyn="whether difftime() can be avoided"
	set avoid_difftime
	eval $trylink
	;;
*) avoid_difftime="$define";;
esac
case "$avoid_difftime" in
"$define") val="$undef";;
*) val="$define";;
esac
set use_difftime
eval $setvar

@end