Skip to content

Commit 221dec5

Browse files
author
Christian Thalinger
committed
2007-04-12 Christian Thalinger <[email protected]>
* LICENSE: Added m4/ax_func_which_gethostbyname_r.m4 license. * configure.ac: Added AX_FUNC_WHICH_GETHOSTBYNAME_R check. * m4/ax_func_which_gethostbyname_r.m4: New file. * native/jni/native-lib/cpnet.c (cpnet_getHostByName): Check for different number of arguments of gethostbyname_r.
1 parent 9905dbe commit 221dec5

File tree

5 files changed

+219
-0
lines changed

5 files changed

+219
-0
lines changed

ChangeLog

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2007-04-12 Christian Thalinger <[email protected]>
2+
3+
* LICENSE: Added m4/ax_func_which_gethostbyname_r.m4 license.
4+
* configure.ac: Added AX_FUNC_WHICH_GETHOSTBYNAME_R check.
5+
* m4/ax_func_which_gethostbyname_r.m4: New file.
6+
* native/jni/native-lib/cpnet.c (cpnet_getHostByName): Check for
7+
different number of arguments of gethostbyname_r.
8+
19
2007-04-12 Mark Wielaard <[email protected]>
210

311
* gnu/java/awt/peer/ClasspathFontPeer.java (LRUCache): New static

LICENSE

+36
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,39 @@ the following notice:
358358
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
359359
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
360360
SUCH DAMAGE.
361+
362+
363+
* m4/ax_func_which_gethostbyname_r.m4
364+
365+
Copyright � 2005 Caolan McNamara <[email protected]>
366+
Copyright � 2005 Daniel Richard G. <[email protected]>
367+
368+
This program is free software; you can redistribute it and/or modify
369+
it under the terms of the GNU General Public License as published by
370+
the Free Software Foundation; either version 2 of the License, or
371+
(at your option) any later version.
372+
373+
This program is distributed in the hope that it will be useful, but
374+
WITHOUT ANY WARRANTY; without even the implied warranty of
375+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376+
General Public License for more details.
377+
378+
You should have received a copy of the GNU General Public License
379+
along with this program; if not, write to the Free Software
380+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
381+
USA.
382+
383+
As a special exception, the respective Autoconf Macro's copyright
384+
owner gives unlimited permission to copy, distribute and modify the
385+
configure scripts that are the output of Autoconf when processing the
386+
Macro. You need not follow the terms of the GNU General Public License
387+
when using or distributing such scripts, even though portions of the
388+
text of the Macro appear in them. The GNU General Public License
389+
(GPL) does govern all other use of the material that constitutes the
390+
Autoconf Macro.
391+
392+
This special exception to the GPL applies to versions of the
393+
Autoconf Macro released by the Autoconf Macro Archive. When you make
394+
and distribute a modified version of the Autoconf Macro, you may
395+
extend this special exception to the GPL to apply to your modified
396+
version as well.

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ if test "x${COMPILE_JNI}" = xyes; then
421421
AC_C_CONST
422422
AC_C_INLINE
423423
AC_C_ATTRIBUTE
424+
AX_FUNC_WHICH_GETHOSTBYNAME_R
424425

425426
dnl See if we HAVE_ICONV, how ICONV_CONST is set and LTLIBICONV
426427
AM_ICONV

m4/ax_func_which_gethostbyname_r.m4

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# m4/ax_func_which_gethostbyname_r.m4
2+
3+
# Copyright © 2005 Caolan McNamara <[email protected]>
4+
# Copyright © 2005 Daniel Richard G. <[email protected]>
5+
6+
# This program is free software; you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation; either version 2 of the License, or
9+
# (at your option) any later version.
10+
11+
# This program is distributed in the hope that it will be useful, but
12+
# WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
# General Public License for more details.
15+
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program; if not, write to the Free Software
18+
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19+
# 02111-1307, USA.
20+
21+
# As a special exception, the respective Autoconf Macro's copyright
22+
# owner gives unlimited permission to copy, distribute and modify the
23+
# configure scripts that are the output of Autoconf when processing
24+
# the Macro. You need not follow the terms of the GNU General Public
25+
# License when using or distributing such scripts, even though
26+
# portions of the text of the Macro appear in them. The GNU General
27+
# Public License (GPL) does govern all other use of the material that
28+
# constitutes the Autoconf Macro.
29+
30+
# This special exception to the GPL applies to versions of the
31+
# Autoconf Macro released by the Autoconf Macro Archive. When you make
32+
# and distribute a modified version of the Autoconf Macro, you may
33+
# extend this special exception to the GPL to apply to your modified
34+
# version as well.
35+
36+
37+
AC_DEFUN([AX_FUNC_WHICH_GETHOSTBYNAME_R], [
38+
39+
AC_LANG_PUSH(C)
40+
AC_MSG_CHECKING([how many arguments gethostbyname_r() takes])
41+
42+
AC_CACHE_VAL(ac_cv_func_which_gethostbyname_r, [
43+
44+
################################################################
45+
46+
ac_cv_func_which_gethostbyname_r=unknown
47+
48+
#
49+
# ONE ARGUMENT (sanity check)
50+
#
51+
52+
# This should fail, as there is no variant of gethostbyname_r() that takes
53+
# a single argument. If it actually compiles, then we can assume that
54+
# netdb.h is not declaring the function, and the compiler is thereby
55+
# assuming an implicit prototype. In which case, we're out of luck.
56+
#
57+
AC_COMPILE_IFELSE(
58+
AC_LANG_PROGRAM(
59+
[[#include <netdb.h>]],
60+
[[
61+
char *name = "www.gnu.org";
62+
(void)gethostbyname_r(name) /* ; */
63+
]]),
64+
ac_cv_func_which_gethostbyname_r=no)
65+
66+
#
67+
# SIX ARGUMENTS
68+
# (e.g. Linux)
69+
#
70+
71+
if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
72+
73+
AC_COMPILE_IFELSE(
74+
AC_LANG_PROGRAM(
75+
[[#include <netdb.h>]],
76+
[[
77+
char *name = "www.gnu.org";
78+
struct hostent ret, *retp;
79+
char buf@<:@1024@:>@;
80+
int buflen = 1024;
81+
int my_h_errno;
82+
(void)gethostbyname_r(name, &ret, buf, buflen, &retp, &my_h_errno) /* ; */
83+
]]),
84+
ac_cv_func_which_gethostbyname_r=six)
85+
86+
fi
87+
88+
#
89+
# FIVE ARGUMENTS
90+
# (e.g. Solaris)
91+
#
92+
93+
if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
94+
95+
AC_COMPILE_IFELSE(
96+
AC_LANG_PROGRAM(
97+
[[#include <netdb.h>]],
98+
[[
99+
char *name = "www.gnu.org";
100+
struct hostent ret;
101+
char buf@<:@1024@:>@;
102+
int buflen = 1024;
103+
int my_h_errno;
104+
(void)gethostbyname_r(name, &ret, buf, buflen, &my_h_errno) /* ; */
105+
]]),
106+
ac_cv_func_which_gethostbyname_r=five)
107+
108+
fi
109+
110+
#
111+
# THREE ARGUMENTS
112+
# (e.g. AIX, HP-UX, Tru64)
113+
#
114+
115+
if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
116+
117+
AC_COMPILE_IFELSE(
118+
AC_LANG_PROGRAM(
119+
[[#include <netdb.h>]],
120+
[[
121+
char *name = "www.gnu.org";
122+
struct hostent ret;
123+
struct hostent_data data;
124+
(void)gethostbyname_r(name, &ret, &data) /* ; */
125+
]]),
126+
ac_cv_func_which_gethostbyname_r=three)
127+
128+
fi
129+
130+
################################################################
131+
132+
]) dnl end AC_CACHE_VAL
133+
134+
case "$ac_cv_func_which_gethostbyname_r" in
135+
three)
136+
AC_MSG_RESULT([three])
137+
AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_3], 1, [three-argument gethostbyname_r])
138+
;;
139+
140+
five)
141+
AC_MSG_RESULT([five])
142+
AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_5], 1, [five-argument gethostbyname_r])
143+
;;
144+
145+
six)
146+
AC_MSG_RESULT([six])
147+
AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_6], 1, [six-argument gethostbyname_r])
148+
;;
149+
150+
no)
151+
AC_MSG_RESULT([cannot find function declaration in netdb.h])
152+
;;
153+
154+
unknown)
155+
AC_MSG_RESULT([can't tell])
156+
;;
157+
158+
*)
159+
AC_MSG_ERROR([internal error])
160+
;;
161+
esac
162+
163+
AC_LANG_POP(C)
164+
165+
]) dnl end AC_DEFUN

native/jni/native-lib/cpnet.c

+9
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,17 @@ jint cpnet_getHostByName (JNIEnv *env, const char *hostname, cpnet_address ***ad
635635
do
636636
{
637637
buf = (char *)JCL_malloc(env, buflen);
638+
638639
#ifdef HAVE_GETHOSTBYNAME_R
640+
# if defined(HAVE_FUNC_GETHOSTBYNAME_R_6)
639641
ret = gethostbyname_r (hostname, &hret, buf, buflen, &result, &herr);
642+
# elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5)
643+
result = gethostbyname_r(hostname, &hret, buf, buflen, &herr);
644+
# elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
645+
# error IMPLEMENT ME!
646+
# else
647+
# error unknown number of arguments for gethostbyname_r
648+
# endif
640649
#else
641650
hret.h_addr_list = NULL;
642651
hret.h_addrtype = 0;

0 commit comments

Comments
 (0)