]> git.saurik.com Git - wxWidgets.git/blame - build/aclocal/ac_raf_func_which_getservbyname_r.m4
Don't crash when creating wxStaticBox in wxGTK.
[wxWidgets.git] / build / aclocal / ac_raf_func_which_getservbyname_r.m4
CommitLineData
bebf40d5
SN
1dnl @synopsis AC_raf_FUNC_WHICH_GETSERVBYNAME_R
2dnl
3dnl Provides a test to determine the correct way to call
4dnl getservbyname_r:
5dnl
d13b34d3 6dnl - defines HAVE_FUNC_GETSERVBYNAME_R_6 if it needs 6 arguments (e.g. linux)
bebf40d5
SN
7dnl - defines HAVE_FUNC_GETSERVBYNAME_R_5 if it needs 5 arguments (e.g. solaris)
8dnl - defines HAVE_FUNC_GETSERVBYNAME_R_4 if it needs 4 arguments (e.g. osf/1)
9dnl
10dnl An example use can be found at
11dnl http://raf.org/autoconf/net_getservbyname.c
12dnl
13dnl Based on Caolan McNamara's gethostbyname_r macro. Based on David
14dnl Arnold's autoconf suggestion in the threads faq.
15dnl
16dnl @category Misc
17dnl @author raf <raf@raf.org>
18dnl @version 2001-08-20
19dnl @license GPLWithACException
20
21AC_DEFUN([AC_raf_FUNC_WHICH_GETSERVBYNAME_R],
81c330c6
VZ
22[
23AC_CACHE_CHECK(how many arguments getservbyname_r() takes,
24 ac_cv_func_which_getservbyname_r,
25 [
fd5199d6
VZ
26 dnl we need to use C++ to detect missing prototypes
27 AC_LANG_PUSH(C++)
28
81c330c6
VZ
29 AC_TRY_COMPILE([#include <netdb.h>],
30 [
31 char *name;
32 char *proto;
33 struct servent *se, *res;
34 char buffer[2048];
35 int buflen = 2048;
36 (void) getservbyname_r(name, proto, se, buffer, buflen, &res)
37 ],
38 ac_cv_func_which_getservbyname_r=six,
39 [
40 AC_TRY_COMPILE([#include <netdb.h>],
41 [
42 char *name;
43 char *proto;
44 struct servent *se;
45 char buffer[2048];
46 int buflen = 2048;
47 (void) getservbyname_r(name, proto, se, buffer, buflen)
48 ],
49 ac_cv_func_which_getservbyname_r=five,
50 [
51 AC_TRY_COMPILE([#include <netdb.h>],
52 [
53 char *name;
54 char *proto;
55 struct servent *se;
56 struct servent_data data;
57 (void) getservbyname_r(name, proto, se, &data);
58 ],
59 ac_cv_func_which_getservbyname_r=four,
60 ac_cv_func_which_getservbyname_r=no
61 )
62 ]
63 )
64 ]
65 )
fd5199d6 66 AC_LANG_POP()
81c330c6
VZ
67 ]
68)
bebf40d5
SN
69
70if test $ac_cv_func_which_getservbyname_r = six; then
71 AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_6)
72elif test $ac_cv_func_which_getservbyname_r = five; then
73 AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_5)
74elif test $ac_cv_func_which_getservbyname_r = four; then
75 AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_4)
bebf40d5
SN
76fi
77
78])