finish and test support for dynamic arrays
This commit is contained in:
parent
31063fdc85
commit
76dd2511a8
@ -1,6 +1,9 @@
|
|||||||
|
|
||||||
#include "parms.h"
|
#include "parms.h"
|
||||||
|
|
||||||
|
/* are dynamic arrays supported? */
|
||||||
|
#undef HAVE_DYNARRAY
|
||||||
|
|
||||||
/* are we using gcc */
|
/* are we using gcc */
|
||||||
#undef HAVE_GCC
|
#undef HAVE_GCC
|
||||||
|
|
||||||
|
36
configure
vendored
36
configure
vendored
@ -3712,6 +3712,12 @@ done
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ac_ext=c
|
||||||
|
ac_cpp='$CPP $CPPFLAGS'
|
||||||
|
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||||
|
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
|
||||||
|
ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ac_ext=c
|
ac_ext=c
|
||||||
@ -4186,6 +4192,36 @@ else
|
|||||||
use_gecode=$use_gecode_default
|
use_gecode=$use_gecode_default
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if dynamic arrays are supported" >&5
|
||||||
|
$as_echo_n "checking if dynamic arrays are supported... " >&6; }
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
void foo(int n) { int a[n]; a[1]=0; }
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
foo(3);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_compile "$LINENO"; then :
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||||
|
$as_echo "yes" >&6; }
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_DYNARRAY 1" >>confdefs.h
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||||
|
$as_echo "no" >&6; }
|
||||||
|
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
|
||||||
# Check whether --enable-tabling was given.
|
# Check whether --enable-tabling was given.
|
||||||
if test "${enable_tabling+set}" = set; then :
|
if test "${enable_tabling+set}" = set; then :
|
||||||
|
10
configure.in
10
configure.in
@ -55,6 +55,7 @@ AC_PROG_AWK
|
|||||||
AC_SUBST(GCC)
|
AC_SUBST(GCC)
|
||||||
AC_SUBST(C_INTERF_FLAGS)
|
AC_SUBST(C_INTERF_FLAGS)
|
||||||
AC_SUBST(C_PARSER_FLAGS)
|
AC_SUBST(C_PARSER_FLAGS)
|
||||||
|
AC_LANG(C)
|
||||||
|
|
||||||
dnl Gecode support
|
dnl Gecode support
|
||||||
AC_CHECK_HEADER(gecode/support/config.hpp,
|
AC_CHECK_HEADER(gecode/support/config.hpp,
|
||||||
@ -80,6 +81,15 @@ AC_ARG_ENABLE(gecode,
|
|||||||
AC_MSG_ERROR([cannot enable gecode: python not found])
|
AC_MSG_ERROR([cannot enable gecode: python not found])
|
||||||
fi
|
fi
|
||||||
fi], use_gecode=$use_gecode_default)
|
fi], use_gecode=$use_gecode_default)
|
||||||
|
AC_MSG_CHECKING([if dynamic arrays are supported])
|
||||||
|
AC_COMPILE_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([[void foo(int n) { int a[n]; a[1]=0; }]],[[foo(3);]])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
AC_DEFINE([HAVE_DYNARRAY],[1],[Define if dynamic arrays are supported])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
])
|
||||||
|
|
||||||
AC_ARG_ENABLE(tabling,
|
AC_ARG_ENABLE(tabling,
|
||||||
[ --enable-tabling support tabling ],
|
[ --enable-tabling support tabling ],
|
||||||
|
@ -57,7 +57,7 @@ gecode_yap.o: \
|
|||||||
gecode_yap_cc_forward_auto_generated.icc \
|
gecode_yap_cc_forward_auto_generated.icc \
|
||||||
$(srcdir)/disjunctor.icc \
|
$(srcdir)/disjunctor.icc \
|
||||||
$(srcdir)/disjunctor.hh
|
$(srcdir)/disjunctor.hh
|
||||||
$(CXX) -c -I. $(CXXFLAGS) $(DISJUNCTOR) -o $@ $<
|
$(CXX) -c $(CXXFLAGS) $(DISJUNCTOR) -o $@ $<
|
||||||
|
|
||||||
@DO_SECOND_LD@gecode_yap.@SO@: gecode_yap.o
|
@DO_SECOND_LD@gecode_yap.@SO@: gecode_yap.o
|
||||||
@DO_SECOND_LD@ @SHLIB_LD@ -o gecode_yap.@SO@ gecode_yap.o $(LDFLAGS) -lgecodeint -lgecodeset -lgecodesearch @EXTRA_LIBS_FOR_DLLS@
|
@DO_SECOND_LD@ @SHLIB_LD@ -o gecode_yap.@SO@ gecode_yap.o $(LDFLAGS) -lgecodeint -lgecodeset -lgecodesearch @EXTRA_LIBS_FOR_DLLS@
|
||||||
|
@ -22,6 +22,45 @@ using namespace std;
|
|||||||
using namespace generic_gecode;
|
using namespace generic_gecode;
|
||||||
using namespace Gecode;
|
using namespace Gecode;
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include "config.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace generic_gecode
|
||||||
|
{
|
||||||
|
#ifndef HAVE_DYNARRAY
|
||||||
|
#error hello
|
||||||
|
template <typename T> struct DynArray
|
||||||
|
{
|
||||||
|
T* _array;
|
||||||
|
DynArray(int n): _array(new T[n]) {}
|
||||||
|
~DynArray() { delete[] _array; }
|
||||||
|
T& operator[](int i) { return _array[i]; }
|
||||||
|
};
|
||||||
|
#define DYNARRAY(T,A,N) DynArray<T> A(N)
|
||||||
|
#else
|
||||||
|
#define DYNARRAY(T,A,N) T A[N]
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_DYNARRAY
|
||||||
|
struct SpecArray
|
||||||
|
{
|
||||||
|
int (*_array)[2];
|
||||||
|
SpecArray(int n): _array((int (*)[2]) new int[n*2]) {}
|
||||||
|
~SpecArray() { delete[] _array; }
|
||||||
|
int& operator()(int i,int j) { return _array[i][j]; }
|
||||||
|
};
|
||||||
|
#define SPECARRAY(A,N) SpecArray A(N)
|
||||||
|
#define SPECARRAYELEM(A,I,J) A(I,J)
|
||||||
|
#define SPECARRAYDEREF(A) A._array
|
||||||
|
#else
|
||||||
|
#define SPECARRAY(A,N) int A[N][2]
|
||||||
|
#define SPECARRAYELEM(A,I,J) A[I][J]
|
||||||
|
#define SPECARRAYDEREF(A) A
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include "SWI-Stream.h"
|
#include "SWI-Stream.h"
|
||||||
@ -261,22 +300,6 @@ extern "C"
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_DYNARRAY
|
|
||||||
struct SpecArray
|
|
||||||
{
|
|
||||||
int* _array;
|
|
||||||
SpecArray(int n): _array(new int[n][2]) {}
|
|
||||||
~SpecArray() { delete[] _array; }
|
|
||||||
typedef int (*_specarray)[][2];
|
|
||||||
T& operator()(int i,int j) { return ((_specarray)_array)[i][j]; }
|
|
||||||
};
|
|
||||||
#define SPECARRAY(A,N) SpecArray A(N)
|
|
||||||
#define SPECARRAYELEM(A,I,J) A(I,J)
|
|
||||||
#else
|
|
||||||
#define SPECARRAY(A,N) int A[N][2]
|
|
||||||
#define SPECARRAYELEM(A,I,J) A[I][J]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static IntSet
|
static IntSet
|
||||||
gecode_IntSet_from_term(YAP_Term specs)
|
gecode_IntSet_from_term(YAP_Term specs)
|
||||||
{
|
{
|
||||||
@ -291,7 +314,7 @@ extern "C"
|
|||||||
SPECARRAYELEM(r,i,1) = YAP_IntOfTerm(YAP_ArgOfTerm(2, head));
|
SPECARRAYELEM(r,i,1) = YAP_IntOfTerm(YAP_ArgOfTerm(2, head));
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
return IntSet(r, n);
|
return IntSet(SPECARRAYDEREF(r), n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gecode_new_intvar_from_intset(void)
|
static int gecode_new_intvar_from_intset(void)
|
||||||
@ -844,19 +867,6 @@ extern "C"
|
|||||||
return YAP_Unify(result, YAP_MkIntTerm(x.glbMax()));
|
return YAP_Unify(result, YAP_MkIntTerm(x.glbMax()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_DYNARRAY
|
|
||||||
template <typename T> struct DynArray
|
|
||||||
{
|
|
||||||
T* _array;
|
|
||||||
DynArray(int n): _array(new T[n]) {}
|
|
||||||
~DynArray() { delete[] _array; }
|
|
||||||
T& operator[](int i) { return _array[i]; }
|
|
||||||
};
|
|
||||||
#define DYNARRAY(T,A,N) DynArray<T> A(N)
|
|
||||||
#else
|
|
||||||
#define DYNARRAY(T,A,N) T A[N]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static YAP_Functor gecode_COMMA2;
|
static YAP_Functor gecode_COMMA2;
|
||||||
|
|
||||||
static int gecode_setvar_glb_ranges(void)
|
static int gecode_setvar_glb_ranges(void)
|
||||||
|
Reference in New Issue
Block a user