From 50c4e7b4975b4428ecaf30f1ffda355408917106 Mon Sep 17 00:00:00 2001 From: "Erik Falor (fadein)"
Date: Mon, 12 Aug 2013 16:27:44 -0600 Subject: [PATCH] Add support for AIX --- Makefile.aix | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ chicken.h | 12 ++++-- csc.scm | 3 ++ posixunix.scm | 4 +- tcp.scm | 2 +- tests/runtests.sh | 37 +++++++++++------- 6 files changed, 151 insertions(+), 21 deletions(-) create mode 100644 Makefile.aix diff --git a/Makefile.aix b/Makefile.aix new file mode 100644 index 0000000..d453499 --- /dev/null +++ b/Makefile.aix @@ -0,0 +1,114 @@ +# Makefile.aix - configuration for AIX -*- Makefile -*- +# +# Copyright (c) 2008-2013, The Chicken Team +# Copyright (c) 2007, Felix L. Winkelmann +# Copyright (c) 2013, Erik W. Falor +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following +# conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this list of conditions and the following +# disclaimer. +# Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with the distribution. +# Neither the name of the author nor the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +ifneq ($(CONFIG),) +include $(CONFIG) +endif + +SRCDIR ?= ./ + +# platform configuration + +ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh) + +# options + +C_COMPILER = gcc +C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -maix64 -Os +ifdef DEBUGBUILD +C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused +else +ifdef OPTIMIZE_FOR_SPEED +C_COMPILER_OPTIMIZATION_OPTIONS ?= -O3 -fomit-frame-pointer +else +C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os -fomit-frame-pointer +endif +endif + +CXX_COMPILER = g++ + +LINKER_OPTIONS = -maix64 -Wl,-bsvr4 -Wl,-bbigtoc +LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared +LINKER_EXECUTABLE_OPTIONS = -L. -Wl,-R"$(RUNTIME_LINKER_PATH)" +LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared + +LIBRARIAN_OPTIONS = -rv -X 64 +LIBRARIES = -lm -ldl +NEEDS_RELINKING = yes +USES_SONAME = yes + +# special files + +CHICKEN_CONFIG_H = chicken-config.h + +# select default and internal settings + +include $(SRCDIR)/defaults.make + +chicken-config.h: chicken-defaults.h + echo "/* GENERATED */" >$@ + echo "#define HAVE_DIRENT_H 1" >>$@ + echo "#define HAVE_DLFCN_H 1" >>$@ + echo "#define HAVE_INTTYPES_H 1" >>$@ + echo "#define HAVE_LIMITS_H 1" >>$@ + echo "#define HAVE_LONG_LONG 1" >>$@ + echo "#define HAVE_MEMMOVE 1" >>$@ + echo "#define HAVE_MEMORY_H 1" >>$@ + echo "#define HAVE_POSIX_POLL 1" >>$@ + echo "#define HAVE_SIGACTION 1" >>$@ + echo "#define HAVE_SIGSETJMP 1" >>$@ + echo "#define HAVE_STDINT_H 1" >>$@ + echo "#define HAVE_STDLIB_H 1" >>$@ + echo "#define HAVE_STRERROR 1" >>$@ + echo "#define HAVE_STRINGS_H 1" >>$@ + echo "#define HAVE_STRING_H 1" >>$@ + echo "#define HAVE_STRTOLL 1" >>$@ + echo "#define HAVE_STRTOQ 0" >>$@ + echo "#define HAVE_SYS_STAT_H 1" >>$@ + echo "#define HAVE_SYS_TYPES_H 1" >>$@ + echo "#define HAVE_UNISTD_H 1" >>$@ + echo "#define HAVE_UNSIGNED_LONG_LONG 1" >>$@ + echo "#define STDC_HEADERS 1" >>$@ + echo "#define HAVE_ALLOCA 1" >>$@ + echo "#define HAVE_ALLOCA_H 1" >>$@ + echo "#define HAVE_GRP_H 1" >>$@ + echo "#define HAVE_ERRNO_H 1" >>$@ + echo "#define HAVE_GCVT 1" >>$@ + echo "#define HAVE_SYSEXITS_H 1" >>$@ + echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@ +ifdef GCHOOKS + echo "#define C_GC_HOOKS" >>$@ +endif +ifdef SYMBOLGC + echo "#define C_COLLECT_ALL_SYMBOLS" >>$@ +endif +ifneq ($(HACKED_APPLY),) + echo "#define C_HACKED_APPLY" >>$@ +endif + cat chicken-defaults.h >>$@ + +include $(SRCDIR)/rules.make diff --git a/chicken.h b/chicken.h index cb9320e..89b8cc4 100644 --- a/chicken.h +++ b/chicken.h @@ -653,9 +653,9 @@ static inline int isinf_ld (long double x) # define C_MACHINE_TYPE "ultrasparc" #elif defined(__sparc__) # define C_MACHINE_TYPE "sparc" -#elif defined(__powerpc64__) +#elif defined(__powerpc64__) || defined(_ARCH_PPC64) # define C_MACHINE_TYPE "ppc64" -#elif defined(__ppc__) || defined(__powerpc__) +#elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) # define C_MACHINE_TYPE "ppc" #elif defined(_M_IX86) || defined(__i386__) # define C_MACHINE_TYPE "x86" @@ -671,7 +671,7 @@ static inline int isinf_ld (long double x) #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(_WIN32) || defined(__WINNT__) # define C_SOFTWARE_TYPE "windows" -#elif defined(__unix__) || defined(C_XXXBSD) +#elif defined(__unix__) || defined(C_XXXBSD) || defined(_AIX) # define C_SOFTWARE_TYPE "unix" #elif defined(ECOS) # define C_SOFTWARE_TYPE "ecos" @@ -687,6 +687,8 @@ static inline int isinf_ld (long double x) # define C_BUILD_PLATFORM "mingw32" #elif defined(__clang__) # define C_BUILD_PLATFORM "clang" +#elif defined(_AIX) +# define C_BUILD_PLATFORM "aix" #elif defined(__GNUC__) # define C_BUILD_PLATFORM "gnu" #elif defined(__MWERKS__) @@ -721,6 +723,8 @@ static inline int isinf_ld (long double x) # else # define C_SOFTWARE_VERSION "sunos" # endif +#elif defined(_AIX) +# define C_SOFTWARE_VERSION "aix" #else # define C_SOFTWARE_VERSION "unknown" #endif @@ -2951,7 +2955,7 @@ C_path_to_executable(C_char *fname) return buffer; } else return NULL; -# elif defined(__unix__) || defined(__unix) || defined(C_XXXBSD) +# elif defined(__unix__) || defined(__unix) || defined(C_XXXBSD) || defined(_AIX) int i, j, k, l; C_char *path, *dname; diff --git a/csc.scm b/csc.scm index a54c14c..1582e2d 100644 --- a/csc.scm +++ b/csc.scm @@ -70,6 +70,7 @@ (define win mingw) (define netbsd (eq? (software-version) 'netbsd)) (define cygwin (eq? (build-platform) 'cygwin)) +(define aix (eq? (build-platform) 'aix)) (define elf (memq (software-version) '(linux netbsd freebsd solaris openbsd))) @@ -271,6 +272,8 @@ INSTALL_LIB_HOME TARGET_RUN_LIB_HOME))) "\"")) ) + (aix + (list (conc "-Wl,-R\"" library-dir "\""))) (else (list (conc "-L\"" library-dir "\"")))) (if (and deployed (eq? (software-version) 'freebsd)) diff --git a/posixunix.scm b/posixunix.scm index 0de95a7..7f6d739 100644 --- a/posixunix.scm +++ b/posixunix.scm @@ -292,7 +292,7 @@ static C_TLS sigset_t C_sigset; #define C_ctime(n) (C_secs = (n), ctime(&C_secs)) -#if defined(__SVR4) || defined(C_MACOSX) +#if defined(__SVR4) || defined(C_MACOSX) || defined(_AIX) /* Seen here: http://lists.samba.org/archive/samba-technical/2002-November/025571.html */ static time_t C_timegm(struct tm *t) @@ -1600,7 +1600,7 @@ EOF (define local-timezone-abbreviation (foreign-lambda* c-string () - "\n#if !defined(__CYGWIN__) && !defined(__SVR4) && !defined(__uClinux__) && !defined(__hpux__)\n" + "\n#if !defined(__CYGWIN__) && !defined(__SVR4) && !defined(__uClinux__) && !defined(__hpux__) && !defined(_AIX)\n" "time_t clock = time(NULL);" "struct tm *ltm = C_localtime(&clock);" "char *z = ltm ? (char *)ltm->tm_zone : 0;" diff --git a/tcp.scm b/tcp.scm index 8e058bc..c3689ae 100644 --- a/tcp.scm +++ b/tcp.scm @@ -160,7 +160,7 @@ EOF "struct sockaddr_in sa;" "unsigned char *ptr;" "unsigned int len = sizeof(struct sockaddr_in);" - "if(getpeername(s, (struct sockaddr *)&sa, ((unsigned int *)&len)) != 0) C_return(NULL);" + "if(getpeername(s, (struct sockaddr *)&sa, ((socklen_t *)&len)) != 0) C_return(NULL);" "ptr = (unsigned char *)&sa.sin_addr;" "sprintf(addr_buffer, \"%d.%d.%d.%d\", ptr[ 0 ], ptr[ 1 ], ptr[ 2 ], ptr[ 3 ]);" "C_return(addr_buffer);") ) diff --git a/tests/runtests.sh b/tests/runtests.sh index 3c82d25..8c3fc15 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -13,6 +13,13 @@ LD_LIBRARY_PATH=${TEST_DIR}/.. LIBRARY_PATH=${TEST_DIR}/..:${LIBRARY_PATH} export DYLD_LIBRARY_PATH LD_LIBRARY_PATH LIBRARY_PATH +case `uname` in + AIX) + DIFF_OPTS=-b ;; + *) + DIFF_OPTS=-bu ;; +esac + rm -fr test-repository mkdir -p test-repository @@ -83,7 +90,7 @@ if test \! -f scrutiny.expected; then cp scrutiny.out scrutiny.expected fi -diff -bu scrutiny.expected scrutiny.out +diff $DIFF_OPTS scrutiny.expected scrutiny.out $compile scrutiny-tests-2.scm -A -scrutinize -analyze-only -ignore-repository -types $TYPESDB 2>scrutiny-2.out -verbose @@ -96,7 +103,7 @@ if test \! -f scrutiny-2.expected; then cp scrutiny-2.out scrutiny-2.expected fi -diff -bu scrutiny-2.expected scrutiny-2.out +diff $DIFF_OPTS scrutiny-2.expected scrutiny-2.out $compile scrutiny-tests-3.scm -specialize -block -ignore-repository -types $TYPESDB ./a.out @@ -152,10 +159,10 @@ $interpret -s reader-tests.scm echo "======================================== dynamic-wind tests ..." $interpret -s dwindtst.scm >dwindtst.out -diff -bu dwindtst.expected dwindtst.out +diff $DIFF_OPTS dwindtst.expected dwindtst.out $compile dwindtst.scm ./a.out >dwindtst.out -diff -bu dwindtst.expected dwindtst.out +diff $DIFF_OPTS dwindtst.expected dwindtst.out echo "*** Skipping \"feeley-dynwind\" for now ***" # $interpret -s feeley-dynwind.scm @@ -255,7 +262,7 @@ if test -n "$MSYSTEM"; then # the windows runtime library prints flonums differently tail r4rstest.log else - diff -bu r4rstest.out r4rstest.log + diff $DIFF_OPTS r4rstest.out r4rstest.log fi echo "======================================== syntax tests (r5rs_pitfalls) ..." @@ -405,14 +412,16 @@ CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_INSTALL -t local -l $TEST_DIR -r -csi ${TEST_DIR}/../csi CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $interpret -bnq rev-app.scm 1.0 -echo "======================================== deployment tests" -mkdir rev-app -CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_INSTALL -t local -l $TEST_DIR reverser -CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $compile2 -deploy rev-app.scm -CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_INSTALL -deploy -prefix rev-app -t local -l $TEST_DIR reverser -unset LD_LIBRARY_PATH DYLD_LIBRARY_PATH CHICKEN_REPOSITORY -rev-app/rev-app 1.1 -mv rev-app rev-app-2 -rev-app-2/rev-app 1.1 +if test $OS_NAME != AIX; then + echo "======================================== deployment tests" + mkdir rev-app + CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_INSTALL -t local -l $TEST_DIR reverser + CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $compile2 -deploy rev-app.scm + CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_INSTALL -deploy -prefix rev-app -t local -l $TEST_DIR reverser + unset LD_LIBRARY_PATH DYLD_LIBRARY_PATH CHICKEN_REPOSITORY + rev-app/rev-app 1.1 + mv rev-app rev-app-2 + rev-app-2/rev-app 1.1 +fi echo "======================================== done." -- 1.8.1.5