File: ftime.m4

package info (click to toggle)
zthreads 2.3.2-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,536 kB
  • sloc: sh: 8,432; cpp: 6,032; ansic: 126; makefile: 109; javascript: 6
file content (105 lines) | stat: -rw-r--r-- 2,900 bytes parent folder | download | duplicates (7)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
dnl Copyright (c) 2005, Eric Crahen
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a copy
dnl of this software and associated documentation files (the "Software"), to deal
dnl in the Software without restriction, including without limitation the rights
dnl to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
dnl copies of the Software, and to permit persons to whom the Software is furnished
dnl to do so, subject to the following conditions:
dnl 
dnl The above copyright notice and this permission notice shall be included in all
dnl copies or substantial portions of the Software.
dnl 
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
dnl AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
dnl WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
dnl CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

dnl
dnl Enables AM_DETECT_FTIME to test for 
dnl the right ftime()/_ftime() function
dnl
dnl --enable-atomic-gcc=yes|no [default=no]
dnl
dnl If support is available, then SYSTEM_FTIME
dnl is defined to be the ftime function 
dnl will be set
dnl
ifdef(AM_DETECT_FTIME,,[
  
NO_FTIME_ERROR=<<"EOF"
ftime()/_ftime() could not be found on this system.
EOF

have_ftime="detect"

AC_DEFUN(AM_DETECT_FTIME,
[

 AC_ARG_WITH(ftime,
	AC_HELP_STRING([--with-ftime],
		       [select an ftime() [default=detect]]),
 [have_ftime="$withval"
  if test $withval = "yes"; then have_ftime="detect"; fi
 ], 
 [have_ftime="detect"])

 if test $have_ftime = "detect"; then
   echo "detecting for ftime() function"
 fi

 if test $have_ftime = "win32"; then
   echo "verifying WIN32 _ftime() function"
 fi

 if test $have_ftime = "posix"; then
   echo "verifying POSIX ftime() function"
 fi

 dnl Test win32 style 
 if test $have_ftime != "posix"; then

 AC_CHECK_HEADER([sys/time.h],
 [ AC_MSG_CHECKING([for _ftime()])

   AC_TRY_LINK([#include <sys/time.h>],[_ftime(0);],
   [ AC_MSG_RESULT(yes)
     AC_DEFINE_UNQUOTED(SYSTEM_FTIME, [_ftime],
	[Defined if ftime()/_ftime() is usable])	
     have_ftime="win32"
   ],
   [ AC_MSG_RESULT(no) ])

 ])

 fi

 dnl Test posix style 
 if test $have_ftime != "win32"; then

 AC_CHECK_HEADER([sys/timeb.h],
 [ AC_MSG_CHECKING([for ftime()])

   AC_TRY_LINK([#include <sys/timeb.h>], [ ftime(0); ] ,
   [ AC_MSG_RESULT(yes)
     AC_DEFINE_UNQUOTED(SYSTEM_FTIME, [ftime],
	[Defined if ftime()/_ftime() is usable])	
     have_ftime="posix"
   ],
   [ AC_MSG_RESULT(no) ])

 ])

 fi

 dnl Display error if no ftime() is found
 if test $have_ftime = "detect"; then
  AC_MSG_ERROR(${NO_FTIME_ERROR})
 fi

 ])
])

dnl Eric Crahen <crahen at code-foo dot com>