cygwin does not have getaddrinfo so I added a compatibility

implementation in src/ikarus-getaddrinfo.[ch]
This commit is contained in:
Abdulaziz Ghuloum 2007-12-26 22:28:48 -05:00
parent 4f0a816295
commit 648991d793
13 changed files with 136 additions and 17 deletions

View File

@ -223,9 +223,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \ exit 1;; \
esac; \ esac; \
done; \ done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu benchmarks/Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign benchmarks/Makefile'; \
cd $(top_srcdir) && \ cd $(top_srcdir) && \
$(AUTOMAKE) --gnu benchmarks/Makefile $(AUTOMAKE) --foreign benchmarks/Makefile
.PRECIOUS: Makefile .PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \

View File

@ -18,6 +18,9 @@
/* Define to 1 if you have the `fork' function. */ /* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK #undef HAVE_FORK
/* Define to 1 if you have the `getaddrinfo' function. */
#undef HAVE_GETADDRINFO
/* Define to 1 if you have the `getpagesize' function. */ /* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE #undef HAVE_GETPAGESIZE

3
configure vendored
View File

@ -8787,7 +8787,8 @@ fi
for ac_func in bzero gettimeofday memmove memset munmap setenv sqrt strerror
for ac_func in bzero gettimeofday memmove memset munmap setenv sqrt strerror getaddrinfo
do do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5 { echo "$as_me:$LINENO: checking for $ac_func" >&5

View File

@ -92,7 +92,7 @@ AC_FUNC_MMAP
AC_FUNC_STAT AC_FUNC_STAT
AC_FUNC_STRFTIME AC_FUNC_STRFTIME
AC_FUNC_STRTOD AC_FUNC_STRTOD
AC_CHECK_FUNCS([bzero gettimeofday memmove memset munmap setenv sqrt strerror]) AC_CHECK_FUNCS([bzero gettimeofday memmove memset munmap setenv sqrt strerror getaddrinfo])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES(Makefile src/Makefile scheme/Makefile doc/Makefile lib/Makefile benchmarks/Makefile) AC_CONFIG_FILES(Makefile src/Makefile scheme/Makefile doc/Makefile lib/Makefile benchmarks/Makefile)
AC_OUTPUT #(Makefile src/Makefile scheme/Makefile doc/Makefile) AC_OUTPUT #(Makefile src/Makefile scheme/Makefile doc/Makefile)

View File

@ -170,9 +170,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \ exit 1;; \
esac; \ esac; \
done; \ done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \
cd $(top_srcdir) && \ cd $(top_srcdir) && \
$(AUTOMAKE) --gnu doc/Makefile $(AUTOMAKE) --foreign doc/Makefile
.PRECIOUS: Makefile .PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \

View File

@ -172,9 +172,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \ exit 1;; \
esac; \ esac; \
done; \ done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/Makefile'; \
cd $(top_srcdir) && \ cd $(top_srcdir) && \
$(AUTOMAKE) --gnu lib/Makefile $(AUTOMAKE) --foreign lib/Makefile
.PRECIOUS: Makefile .PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \

View File

@ -23,7 +23,7 @@ EXTRA_DIST=ikarus.boot.prebuilt ikarus.enumerations.ss \
psyntax.internal.ss psyntax.library-manager.ss \ psyntax.internal.ss psyntax.library-manager.ss \
ikarus/code-objects.ss ikarus/compiler.ss ikarus/intel-assembler.ss \ ikarus/code-objects.ss ikarus/compiler.ss ikarus/intel-assembler.ss \
ikarus/fasl/write.ss unicode/unicode-char-cases.ss \ ikarus/fasl/write.ss unicode/unicode-char-cases.ss \
unicode/unicode-charinfo.ss ikarus.io.ss unicode/unicode-charinfo.ss ikarus.io.ss ikarus.time-and-date.ss
all: $(nodist_pkglib_DATA) all: $(nodist_pkglib_DATA)

View File

@ -177,7 +177,7 @@ EXTRA_DIST = ikarus.boot.prebuilt ikarus.enumerations.ss \
psyntax.internal.ss psyntax.library-manager.ss \ psyntax.internal.ss psyntax.library-manager.ss \
ikarus/code-objects.ss ikarus/compiler.ss ikarus/intel-assembler.ss \ ikarus/code-objects.ss ikarus/compiler.ss ikarus/intel-assembler.ss \
ikarus/fasl/write.ss unicode/unicode-char-cases.ss \ ikarus/fasl/write.ss unicode/unicode-char-cases.ss \
unicode/unicode-charinfo.ss ikarus.io.ss unicode/unicode-charinfo.ss ikarus.io.ss ikarus.time-and-date.ss
revno = "$(shell sed 's/ .*//' ../.bzr/branch/last-revision 2>/dev/null)" revno = "$(shell sed 's/ .*//' ../.bzr/branch/last-revision 2>/dev/null)"
CLEANFILES = $(nodist_pkglib_DATA) ikarus.config.ss CLEANFILES = $(nodist_pkglib_DATA) ikarus.config.ss
@ -194,9 +194,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \ exit 1;; \
esac; \ esac; \
done; \ done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scheme/Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign scheme/Makefile'; \
cd $(top_srcdir) && \ cd $(top_srcdir) && \
$(AUTOMAKE) --gnu scheme/Makefile $(AUTOMAKE) --foreign scheme/Makefile
.PRECIOUS: Makefile .PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \

View File

@ -6,7 +6,7 @@ ikarus_SOURCES = ikarus-collect.c ikarus-exec.c ikarus-fasl.c \
ikarus-runtime.c ikarus-symbol-table.c ikarus-verify-integrity.c \ ikarus-runtime.c ikarus-symbol-table.c ikarus-verify-integrity.c \
ikarus-weak-pairs.c ikarus-winmmap.c ikarus-data.h \ ikarus-weak-pairs.c ikarus-winmmap.c ikarus-data.h \
ikarus-winmmap.h ikarus-enter.s cpu_has_sse2.s ikarus-io.c \ ikarus-winmmap.h ikarus-enter.s cpu_has_sse2.s ikarus-io.c \
ikarus-process.c ikarus-process.c ikarus-getaddrinfo.h ikarus-getaddrinfo.c
scheme_script_SOURCES = scheme-script.c scheme_script_SOURCES = scheme-script.c

View File

@ -54,7 +54,7 @@ am_ikarus_OBJECTS = ikarus-collect.$(OBJEXT) ikarus-exec.$(OBJEXT) \
ikarus-verify-integrity.$(OBJEXT) ikarus-weak-pairs.$(OBJEXT) \ ikarus-verify-integrity.$(OBJEXT) ikarus-weak-pairs.$(OBJEXT) \
ikarus-winmmap.$(OBJEXT) ikarus-enter.$(OBJEXT) \ ikarus-winmmap.$(OBJEXT) ikarus-enter.$(OBJEXT) \
cpu_has_sse2.$(OBJEXT) ikarus-io.$(OBJEXT) \ cpu_has_sse2.$(OBJEXT) ikarus-io.$(OBJEXT) \
ikarus-process.$(OBJEXT) ikarus-process.$(OBJEXT) ikarus-getaddrinfo.$(OBJEXT)
nodist_ikarus_OBJECTS = nodist_ikarus_OBJECTS =
ikarus_OBJECTS = $(am_ikarus_OBJECTS) $(nodist_ikarus_OBJECTS) ikarus_OBJECTS = $(am_ikarus_OBJECTS) $(nodist_ikarus_OBJECTS)
ikarus_LDADD = $(LDADD) ikarus_LDADD = $(LDADD)
@ -180,7 +180,7 @@ ikarus_SOURCES = ikarus-collect.c ikarus-exec.c ikarus-fasl.c \
ikarus-runtime.c ikarus-symbol-table.c ikarus-verify-integrity.c \ ikarus-runtime.c ikarus-symbol-table.c ikarus-verify-integrity.c \
ikarus-weak-pairs.c ikarus-winmmap.c ikarus-data.h \ ikarus-weak-pairs.c ikarus-winmmap.c ikarus-data.h \
ikarus-winmmap.h ikarus-enter.s cpu_has_sse2.s ikarus-io.c \ ikarus-winmmap.h ikarus-enter.s cpu_has_sse2.s ikarus-io.c \
ikarus-process.c ikarus-process.c ikarus-getaddrinfo.h ikarus-getaddrinfo.c
scheme_script_SOURCES = scheme-script.c scheme_script_SOURCES = scheme-script.c
nodist_ikarus_SOURCES = bootfileloc.h nodist_ikarus_SOURCES = bootfileloc.h
@ -200,9 +200,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \ exit 1;; \
esac; \ esac; \
done; \ done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
cd $(top_srcdir) && \ cd $(top_srcdir) && \
$(AUTOMAKE) --gnu src/Makefile $(AUTOMAKE) --foreign src/Makefile
.PRECIOUS: Makefile .PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \
@ -260,6 +260,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-exec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-exec.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-fasl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-fasl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-flonums.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-flonums.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-getaddrinfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-io.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-io.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-numerics.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikarus-numerics.Po@am__quote@

View File

@ -19,6 +19,7 @@
#ifndef IKARUS_H #ifndef IKARUS_H
#define IKARUS_H #define IKARUS_H
#include "ikarus-getaddrinfo.h"
#include <stdio.h> #include <stdio.h>
#include <sys/resource.h> #include <sys/resource.h>

69
src/ikarus-getaddrinfo.c Normal file
View File

@ -0,0 +1,69 @@
/*
* Ikarus Scheme -- A compiler for R6RS Scheme.
* Copyright (C) 2006,2007 Abdulaziz Ghuloum
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#if (!HAVE_GETADDRINFO)
#include "ikarus-getaddrinfo.h"
#include <netdb.h>
#include <sys/socket.h>
#include <cygwin/in.h>
#include <string.h>
#include <stdio.h>
int
getaddrinfo(const char *hostname, const char* servname,
const struct addrinfo* hints, struct addrinfo** res){
/* hints not used */
struct servent* sent = getservbyname(servname, "tcp");
if(sent == 0) return -1;
struct hostent* hent = gethostbyname(hostname);
if (!hent){
return -1;
}
struct addrinfo* r = malloc(sizeof(struct addrinfo));
if(r == 0) return -1;
r->ai_family = hent->h_addrtype;
r->ai_socktype = SOCK_STREAM;
r->ai_protocol = 0;
r->ai_addrlen = sizeof(struct sockaddr_in);
r->ai_addr = malloc(r->ai_addrlen);
if (r->ai_addr == 0){
free(r);
return -1;
}
struct sockaddr_in* sa_in = (struct sockaddr_in *)r->ai_addr;
memset(sa_in, 0, sizeof(struct sockaddr_in));
sa_in->sin_family = PF_INET;
sa_in->sin_port = sent->s_port;
struct in_addr** ap = (struct in_addr **)hent->h_addr_list;
memcpy(&sa_in->sin_addr, *ap, sizeof(struct in_addr));
r->ai_next = NULL;
*res = r;
return (0);
}
void
freeaddrinfo(struct addrinfo *ai){
free(ai->ai_addr);
free(ai);
}
#endif

44
src/ikarus-getaddrinfo.h Normal file
View File

@ -0,0 +1,44 @@
/*
* Ikarus Scheme -- A compiler for R6RS Scheme.
* Copyright (C) 2006,2007 Abdulaziz Ghuloum
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#if (!HAVE_GETADDRINFO)
#include <stdlib.h>
#include <sys/types.h>
#include <netdb.h>
struct addrinfo {
int ai_family;
int ai_socktype;
int ai_protocol;
size_t ai_addrlen;
struct sockaddr *ai_addr;
struct addrinfo *ai_next;
};
extern int
getaddrinfo(const char *hostname, const char* servname,
const struct addrinfo* hints, struct addrinfo** res);
extern void
freeaddrinfo(struct addrinfo *ai);
#endif