summaryrefslogtreecommitdiff
path: root/m4/ace_func.m4
blob: f031f563ae072ab397d1d0f60c6eb4def95a71ca (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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# ACE_FUNC_STRCASECMP
# + Defines ACE_LACKS_STRCASECMP to 1 if platform lacks strcasecmp()
# + Defines ACE_STRCASECMP_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
# + Defines ACE_LACKS_STRCASECMP_PROTOTYPE to 1 if platform lacks
#   declaration for strcasecmp().
#---------------------------------------------------------------------------
AC_DEFUN([ACE_FUNC_STRCASECMP],
[ACE_CHECK_LACKS_FUNCS(strcasecmp)
if test "$ac_cv_func_strcasecmp" = yes; then
    AC_CHECK_DECL([strcasecmp],
		  [],
		  [AC_DEFINE([ACE_LACKS_STRCASECMP_PROTOTYPE], 1,
			     [Define to 1 if platform lacks a declaration for strcasecmp()])],
		  [
#if !defined(ACE_LACKS_STRINGS_H)
#include <strings.h>
#endif
#if !defined(ACE_LACKS_STRING_H)
#include <string.h>
#endif
		  ])
else
    AC_CHECK_FUNC(stricmp)
    if test "$ac_cv_func_stricmp" = yes; then
        AC_DEFINE(ACE_STRCASECMP_EQUIVALENT, [::stricmp],
		  [Define to function that is equivalent to strcasecmp()])
    else
	AC_CHECK_FUNC(_stricmp)
	if test "$ac_cv_func__stricmp" = yes; then
	    AC_DEFINE(ACE_STRCASECMP_EQUIVALENT, [::_stricmp])
	fi
    fi
fi
])

# ACE_FUNC_STRNCASECMP
# + Defines ACE_LACKS_STRNCASECMP to 1 if platform lacks strncasecmp()
# + Defines ACE_STRNCASECMP_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
# + Defines ACE_LACKS_STRNCASECMP_PROTOTYPE to 1 if platform lacks
#   declaration for strncasecmp().
#---------------------------------------------------------------------------
AC_DEFUN([ACE_FUNC_STRNCASECMP],
[ACE_CHECK_LACKS_FUNCS(strncasecmp)
if test "$ac_cv_func_strncasecmp" = yes; then
    AC_CHECK_DECL([strncasecmp],
		  [],
		  [AC_DEFINE([ACE_LACKS_STRNCASECMP_PROTOTYPE], 1,
			     [Define to 1 if platform lacks a declaration for strncasecmp()])],
		  [
#if !defined(ACE_LACKS_STRINGS_H)
#include <strings.h>
#endif
#if !defined(ACE_LACKS_STRING_H)
#include <string.h>
#endif
		  ])
else
    AC_CHECK_FUNC(strnicmp)
    if test "$ac_cv_func_strnicmp" = yes; then
        AC_DEFINE(ACE_STRNCASECMP_EQUIVALENT, [::strnicmp],
		  [Define to function that is equivalent to strncasecmp()])
    else
	AC_CHECK_FUNC(_strnicmp)
	if test "$ac_cv_func__strnicmp" = yes; then
	    AC_DEFINE(ACE_STRNCASECMP_EQUIVALENT, [::_strnicmp])
	fi
    fi
fi
])

# ACE_FUNC_STRDUP
# + Defines ACE_LACKS_STRDUP to 1 if platform lacks strdup()
# + Defines ACE_STRDUP_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
# + Defines ACE_HAS_NONCONST_STRDUP if argument is char*. (TODO)
#---------------------------------------------------------------------------
AC_DEFUN([ACE_FUNC_STRDUP],
[ACE_CHECK_LACKS_FUNCS(strdup)
if test "$ac_cv_func_strdup" = no; then
    AC_CHECK_FUNC(_strdup)
    if test "$ac_cv_func__strdup" = yes; then
        AC_DEFINE(ACE_STRDUP_EQUIVALENT, [::_strdup],
		  [Define to function that is equivalent to strdup()])
    fi
fi
])

# ACE_FUNC_STRTOLL
# + Defines ACE_LACKS_STRTOLL to 1 if platform lacks strtoll()
# + Defines ACE_STRTOLL_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
# + Defines ACE_LACKS_STRTOLL_PROTOTYPE to 1 if platform lacks
#   declaration for strtoll().
AC_DEFUN([ACE_FUNC_STRTOLL],
[ACE_CHECK_LACKS_FUNCS(strtoll)
if test $ac_cv_func_strtoll = "no"; then
    AC_CHECK_FUNC(__strtoll)
    if test $ac_cv_func___strtoll = "yes"; then
        AC_DEFINE([ACE_STRTOLL_EQUIVALENT], [::__strtoll], 
                  [Define to function that is equivalent to strtoll()])
    else
        AC_CHECK_FUNC(_strtoi64)
        if test $ac_cv_func__strtoi64 = "yes"; then
	    AC_DEFINE([ACE_STRTOLL_EQUIVALENT], [::_strtoi64])
        fi
    fi 
else
    AC_CHECK_DECL([strtoll], 
                  [], 
		  [AC_DEFINE([ACE_LACKS_STRTOLL_PROTOTYPE], 1,
			     [Define to 1 if platform lacks a declaration for strtoll()])],
                  [#include <stdlib.h>])
fi
])

# ACE_FUNC_STRTOULL
# + Defines ACE_LACKS_STRTOULL to 1 if platform lacks strtoull()
# + Defines ACE_STRTOULL_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
# + Defines ACE_LACKS_STRTOULL_PROTOTYPE to 1 if platform lacks
#   declaration for strtoull().
#---------------------------------------------------------------------------
AC_DEFUN([ACE_FUNC_STRTOULL],
[ACE_CHECK_LACKS_FUNCS(strtoull)
if test $ac_cv_func_strtoull = "no"; then
    AC_CHECK_FUNC(__strtoull)
    if test $ac_cv_func___strtoull = "yes"; then
        AC_DEFINE([ACE_STRTOULL_EQUIVALENT], [::__strtoull], 
                  [Define to function that is equivalent to strtoull()])
    else
        AC_CHECK_FUNC(_strtoui64)
        if test $ac_cv_func__strtoui64 = "yes"; then
	    AC_DEFINE([ACE_STRTOULL_EQUIVALENT], [::_strtoui64])
        fi
    fi
else
    AC_CHECK_DECL([strtoull], 
                  [], 
		  [AC_DEFINE([ACE_LACKS_STRTOULL_PROTOTYPE], 1,
			     [Define to 1 if platform lacks a declaration for strtoull()])],
                  [#include <stdlib.h>])
fi
])

# ACE_FUNC_WCSCASECMP
# + Defines ACE_LACKS_WCSCASECMP to 1 if platform lacks wcscasecmp()
# + Defines ACE_WCSCASECMP_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
#---------------------------------------------------------------------------
AC_DEFUN([ACE_FUNC_WCSCASECMP],
[ACE_CHECK_LACKS_FUNCS(wcscasecmp)
if test "$ac_cv_func_wcscasecmp" = no; then
    AC_CHECK_FUNC(wcsicmp)
    if test "$ac_cv_func_wcsicmp" = yes; then
        AC_DEFINE(ACE_WCSCASECMP_EQUIVALENT, [::wcsicmp],
		  [Define to function that is equivalent to wcscasecmp()])
    else
	AC_CHECK_FUNC(_wcsicmp)
	if test "$ac_cv_func__wcsicmp" = yes; then
	    AC_DEFINE(ACE_WCSCASECMP_EQUIVALENT, [::_wcsicmp])
	fi
    fi
fi
])

# ACE_FUNC_WCSNCASECMP
# + Defines ACE_LACKS_WCSNCASECMP to 1 if platform lacks wcsncasecmp()
# + Defines ACE_WCSNCASECMP_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
#---------------------------------------------------------------------------
AC_DEFUN([ACE_FUNC_WCSNCASECMP],
[ACE_CHECK_LACKS_FUNCS(wcsncasecmp)
if test "$ac_cv_func_wcsncasecmp" = no; then
    AC_CHECK_FUNC(wcsnicmp)
    if test "$ac_cv_func_wcsnicmp" = yes; then
        AC_DEFINE(ACE_WCSNCASECMP_EQUIVALENT, [::wcsnicmp],
		  [Define to function that is equivalent to wcsncasecmp()])
    else
	AC_CHECK_FUNC(_wcsnicmp)
	if test "$ac_cv_func__wcsnicmp" = yes; then
	    AC_DEFINE(ACE_WCSNCASECMP_EQUIVALENT, [::_wcsnicmp])
	fi
    fi
fi
])

# ACE_FUNC_WCSDUP
# + Defines ACE_LACKS_WCSDUP to 1 if platform lacks wcsdup()
# + Defines ACE_WCSDUP_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
# + Defines ACE_HAS_NONCONST_WCSDUP if argument is char*. (TODO)
#---------------------------------------------------------------------------
AC_DEFUN([ACE_FUNC_WCSDUP],
[ACE_CHECK_LACKS_FUNCS(wcsdup)
if test "$ac_cv_func_wcsdup" = no; then
    AC_CHECK_FUNC(_wcsdup)
    if test "$ac_cv_func__wcsdup" = yes; then
        AC_DEFINE(ACE_WCSDUP_EQUIVALENT, [::_wcsdup],
		  [Define to function that is equivalent to wcsdup()])
    fi
fi
])

# ACE_FUNC_WCSTOLL
# + Defines ACE_LACKS_WCSTOLL to 1 if platform lacks wcstoll()
# + Defines ACE_WCSTOLL_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
AC_DEFUN([ACE_FUNC_WCSTOLL],
[ACE_CHECK_LACKS_FUNCS(wcstoll)
if test $ac_cv_func_wcstoll = "no"; then
    AC_CHECK_FUNC(__wcstoll)
    if test $ac_cv_func___wcstoll = "yes"; then
        AC_DEFINE([ACE_WCSTOLL_EQUIVALENT], [::__wcstoll], 
                  [Define to function that is equivalent to wcstoll()])
    else
	AC_CHECK_FUNC(_wcstoi64)
	if test $ac_cv_func__wcstoi64 = "yes"; then
	    AC_DEFINE([ACE_WCSTOLL_EQUIVALENT], [::_wcstoi64],
		      [Define to function that is equivalent to wcstoll()])
	fi
    fi
fi
])

# ACE_FUNC_WCSTOULL
# + Defines ACE_LACKS_WCSTOULL to 1 if platform lacks wcstoull()
# + Defines ACE_WCSTOULL_EQUIVALENT to identifier name if platform
#   has a equivalent function that differs in name only.
AC_DEFUN([ACE_FUNC_WCSTOULL],
[ACE_CHECK_LACKS_FUNCS(wcstoull)
if test $ac_cv_func_wcstoull = "no"; then
    AC_CHECK_FUNC(__wcstoull)
    if test $ac_cv_func___wcstoull = "yes"; then
        AC_DEFINE([ACE_WCSTOULL_EQUIVALENT], [::__wcstoull], 
                  [Define to function that is equivalent to wcstoull()])
    else
	AC_CHECK_FUNC(_wcstoui64)
	if test $ac_cv_func__wcstoui64 = "yes"; then
	    AC_DEFINE([ACE_WCSTOULL_EQUIVALENT], [::_wcstoui64],
		      [Define to function that is equivalent to wcstoull()])
	fi
    fi
fi
])

# ACE_CHECK_SYSINFO
#
# HP/UX, SVR4/POSIX and Linux have completely independent
# implementations of the # sysinfo() system / library call.
#
# The HP/UX syscall is undocumented.
#
# The SVR4 signature is:
#   #include <sys/systeminfo.h>
#   long sysinfo (int command, char *buf, long count)
#
# While the Linux signature is:
#   #include <sys/sysinfo.h>
#   int sysinfo (struct sysinfo* info);
#
# SVR4 (or at least Solaris) also has a sys/sysinfo.h header, so that
# cannot be used to distinguish between the two varients. As far as I
# know, Linux does not have a sys/systeminfo.h header, so that can.
# To further avoid false positives, small programs that use the two
# APIs are compiled as part of the feature tests.
#
# ACE uses the ACE_HAS_SYSV_SYSINFO feature test macro for the first
# and ACE_HAS_LINUX_SYSINFO for the second.
#
AC_DEFUN([ACE_CHECK_FUNC_SYSINFO],[
ACE_CHECK_HAS_HEADERS(sys/sysinfo.h sys/systeminfo.h)
AC_CHECK_FUNC(sysinfo)
if test "$ac_cv_func_sysinfo" = yes; then
  if test "$ac_cv_header_sys_systeminfo_h" = yes; then
     AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
		[#include <sys/systeminfo.h>],
		[char buf[256];
		sysinfo (SI_SYSNAME, buf, sizeof(buf));
		return 0;])],
	[AC_DEFINE([ACE_HAS_SYSV_SYSINFO], 1,
		[Define to 1 if system has SysV version of sysinfo().])])

  elif test "$ac_cv_header_sys_sysinfo_h" = yes; then
     AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM(
		[#include <sys/sysinfo.h>],
		[struct sysinfo s;
		sysinfo (&s);
		return 0;])],
        [AC_DEFINE([ACE_HAS_LINUX_SYSINFO], 1,
		[Define to 1 if system has Linux version of sysinfo().])])
  fi
fi
])