64 bit cleanups.

This commit is contained in:
Vítor Santos Costa 2010-05-06 15:00:44 +01:00
parent c074076e89
commit 11641c5f94
15 changed files with 132 additions and 119 deletions

View File

@ -869,11 +869,12 @@ static MALLOC_T
InitWorkSpace(Int s)
{
SYSTEM_INFO si;
Int psz;
GetSystemInfo(&si);
Yap_page_size = si.dwPageSize;
psz = Yap_page_size = si.dwPageSize;
s = ((s+ (YAP_ALLOC_SIZE-1))/YAP_ALLOC_SIZE)*YAP_ALLOC_SIZE;
brk = (LPVOID)Yap_page_size;
brk = (LPVOID)psz;
if (!ExtendWorkSpace(s,0))
return FALSE;
return (MALLOC_T)brk-s;
@ -1535,13 +1536,8 @@ Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack)
(UInt) Yap_LocalBase, (UInt) Yap_TrailTop);
#endif
#if !SHORT_INTS
fprintf(stderr, "Heap+Aux: %d\tLocal+Global: %d\tTrail: %d\n",
fprintf(stderr, "Heap+Aux: " UInt_FORMAT "\tLocal+Global: " UInt_FORMAT "\tTrail: " UInt_FORMAT "\n",
pm - sa - ta, sa, ta);
#else /* SHORT_INTS */
fprintf(stderr, "Heap+Aux: %ld\tLocal+Global: %ld\tTrail: %ld\n",
pm - sa - ta, sa, ta);
#endif /* SHORT_INTS */
}
#endif /* DEBUG */
}

View File

@ -2031,22 +2031,14 @@ addcl_permission_error(AtomEntry *ap, Int Arity, int in_use)
sprintf(Yap_ErrorMessage, "static predicate %s is in use", ap->StrOfAE);
else
sprintf(Yap_ErrorMessage,
#if SHORT_INTS
"static predicate %s/%ld is in use",
#else
"static predicate %s/%d is in use",
#endif
"static predicate %s/" Int_FORMAT " is in use",
ap->StrOfAE, Arity);
} else {
if (Arity == 0)
sprintf(Yap_ErrorMessage, "system predicate %s", ap->StrOfAE);
else
sprintf(Yap_ErrorMessage,
#if SHORT_INTS
"system predicate %s/%ld",
#else
"system predicate %s/%d",
#endif
"system predicate %s/" Int_FORMAT,
ap->StrOfAE, Arity);
}
}

View File

@ -94,7 +94,7 @@ typedef struct mem_blk {
#define FIRST_CMEM_BLK_SIZE (16*4096)
static char *
AllocCMem (int size, struct intermediates *cip)
AllocCMem (UInt size, struct intermediates *cip)
{
#if SIZEOF_INT_P==8
size = (size + 7) & 0xfffffffffffffff8L;
@ -179,7 +179,7 @@ Yap_ReleaseCMem (struct intermediates *cip)
}
char *
Yap_AllocCMem (int size, struct intermediates *cip)
Yap_AllocCMem (UInt size, struct intermediates *cip)
{
return AllocCMem(size, cip);
}

View File

@ -3848,7 +3848,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
fprintf(Yap_stderr, "%% Mark: Marked %ld cells of %ld (efficiency: %ld%%) in %g sec\n",
(long int)tot, (long int)heap_cells, (long int)effectiveness, (double)(m_time-time_start)/1000);
if (HGEN-H0)
fprintf(Yap_stderr,"%% previous generation has size %lu, with %lu (%lu%%) unmarked\n", (unsigned long)(HGEN-H0), (HGEN-H0)-total_oldies, 100*((HGEN-H0)-total_oldies)/(HGEN-H0));
fprintf(Yap_stderr,"%% previous generation has size " UInt_FORMAT ", with " UInt_FORMAT " (" UInt_FORMAT "%%) unmarked\n", (UInt)(HGEN-H0), (UInt)((HGEN-H0)-total_oldies), (UInt)(100*((HGEN-H0)-total_oldies)/(HGEN-H0)));
#ifdef INSTRUMENT_GC
{
int i;

View File

@ -2000,7 +2000,7 @@ find_csult_file (char *source, char *buf, StreamDesc * st, char *io_mode)
}
/* given a stream index, get the corresponding fd */
static int
static Int
GetStreamFd(int sno)
{
#if USE_SOCKET
@ -2010,7 +2010,7 @@ GetStreamFd(int sno)
#endif
if (Stream[sno].status & Pipe_Stream_f) {
#if _MSC_VER || defined(__MINGW32__)
return((int)(Stream[sno].u.pipe.hdl));
return((Int)(Stream[sno].u.pipe.hdl));
#else
return(Stream[sno].u.pipe.fd);
#endif
@ -2020,7 +2020,7 @@ GetStreamFd(int sno)
return(YP_fileno(Stream[sno].u.file.file));
}
int
Int
Yap_GetStreamFd(int sno)
{
return GetStreamFd(sno);
@ -5990,7 +5990,7 @@ p_all_char_conversions(void)
return(Yap_unify(ARG1,out));
}
int
Int
Yap_StreamToFileNo(Term t)
{
int sno =
@ -5998,7 +5998,7 @@ Yap_StreamToFileNo(Term t)
if (Stream[sno].status & Pipe_Stream_f) {
UNLOCK(Stream[sno].streamlock);
#if _MSC_VER || defined(__MINGW32__)
return((int)(Stream[sno].u.pipe.hdl));
return((Int)(Stream[sno].u.pipe.hdl));
#else
return(Stream[sno].u.pipe.fd);
#endif

View File

@ -948,11 +948,7 @@ p_name(void)
String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
#if SHORT_INTS
sprintf(String, "%ld", IntOfTerm(AtomNameT));
#else
sprintf(String, "%d", IntOfTerm(AtomNameT));
#endif
sprintf(String, Int_FORMAT, IntOfTerm(AtomNameT));
} else if (IsFloatTerm(AtomNameT)) {
String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
@ -964,11 +960,7 @@ p_name(void)
if (String + 1024 > (char *)AuxSp)
goto expand_auxsp;
#if SHORT_INTS
sprintf(String, "%ld", LongIntOfTerm(AtomNameT));
#else
sprintf(String, "%d", LongIntOfTerm(AtomNameT));
#endif
sprintf(String, Int_FORMAT, LongIntOfTerm(AtomNameT));
#if USE_GMP
} else if (IsBigIntTerm(AtomNameT)) {
String = Yap_PreAllocCodeSpace();
@ -1505,9 +1497,9 @@ p_atomic_concat(void)
char *cptr = (char *)wcptr;
#if HAVE_SNPRINTF
sz = snprintf(cptr, (wtop-wcptr)-1024,"%ld", (long int)IntegerOfTerm(thead));
sz = snprintf(cptr, (wtop-wcptr)-1024,Int_FORMAT, IntegerOfTerm(thead));
#else
sz = sprintf(cptr,"%ld", (long int)IntegerOfTerm(thead));
sz = sprintf(cptr,Int_FORMAT, IntegerOfTerm(thead));
#endif
for (i=sz; i>0; i--) {
wcptr[i-1] = cptr[i-1];
@ -1608,9 +1600,9 @@ p_atomic_concat(void)
cptr += sz;
} else if (IsIntegerTerm(thead)) {
#if HAVE_SNPRINTF
snprintf(cptr, (top-cptr)-1024,"%ld", (long int)IntegerOfTerm(thead));
snprintf(cptr, (top-cptr)-1024,Int_FORMAT, IntegerOfTerm(thead));
#else
sprintf(cptr,"%ld", (long int)IntegerOfTerm(thead));
sprintf(cptr, Int_FORMAT, IntegerOfTerm(thead));
#endif
while (*cptr && cptr < top-1024) cptr++;
} else if (IsFloatTerm(thead)) {
@ -1957,19 +1949,11 @@ p_number_chars(void)
Yap_Error(TYPE_ERROR_NUMBER, t1, "number_chars/2");
return(FALSE);
} else if (IsIntTerm(t1)) {
#if SHORT_INTS
sprintf(String, "%ld", IntOfTerm(t1));
#else
sprintf(String, "%d", IntOfTerm(t1));
#endif
sprintf(String, Int_FORMAT, IntOfTerm(t1));
} else if (IsFloatTerm(t1)) {
sprintf(String, "%f", FloatOfTerm(t1));
} else if (IsLongIntTerm(t1)) {
#if SHORT_INTS
sprintf(String, "%ld", LongIntOfTerm(t1));
#else
sprintf(String, "%d", LongIntOfTerm(t1));
#endif
sprintf(String, Int_FORMAT, LongIntOfTerm(t1));
#if USE_GMP
} else if (IsBigIntTerm(t1)) {
mpz_get_str(String, 10, Yap_BigIntOfTerm(t1));
@ -2111,20 +2095,12 @@ p_number_atom(void)
if (IsIntTerm(t1)) {
#if SHORT_INTS
sprintf(String, "%ld", IntOfTerm(t1));
#else
sprintf(String, "%d", IntOfTerm(t1));
#endif
sprintf(String, Int_FORMAT, IntOfTerm(t1));
} else if (IsFloatTerm(t1)) {
sprintf(String, "%f", FloatOfTerm(t1));
} else if (IsLongIntTerm(t1)) {
#if SHORT_INTS
sprintf(String, "%ld", LongIntOfTerm(t1));
#else
sprintf(String, "%d", LongIntOfTerm(t1));
#endif
sprintf(String, Int_FORMAT, LongIntOfTerm(t1));
#if USE_GMP
} else if (IsBigIntTerm(t1)) {
@ -2177,19 +2153,11 @@ p_number_codes(void)
}
if (IsNonVarTerm(t1) && IsVarTerm(t)) {
if (IsIntTerm(t1)) {
#if SHORT_INTS
sprintf(String, "%ld", IntOfTerm(t1));
#else
sprintf(String, "%d", IntOfTerm(t1));
#endif
sprintf(String, Int_FORMAT, IntOfTerm(t1));
} else if (IsFloatTerm(t1)) {
sprintf(String, "%f", FloatOfTerm(t1));
} else if (IsLongIntTerm(t1)) {
#if SHORT_INTS
sprintf(String, "%ld", LongIntOfTerm(t1));
#else
sprintf(String, "%d", LongIntOfTerm(t1));
#endif
sprintf(String, Int_FORMAT, LongIntOfTerm(t1));
#if USE_GMP
} else if (IsBigIntTerm(t1)) {
mpz_get_str(String, 10, Yap_BigIntOfTerm(t1));
@ -2276,19 +2244,11 @@ p_atom_number(void)
}
}
if (IsIntTerm(t2)) {
#if SHORT_INTS
sprintf(String, "%ld", IntOfTerm(t2));
#else
sprintf(String, "%d", IntOfTerm(t2));
#endif
sprintf(String, Int_FORMAT, IntOfTerm(t2));
} else if (IsFloatTerm(t2)) {
sprintf(String, "%g", FloatOfTerm(t2));
} else if (IsLongIntTerm(t2)) {
#if SHORT_INTS
sprintf(String, "%ld", LongIntOfTerm(t2));
#else
sprintf(String, "%d", LongIntOfTerm(t2));
#endif
sprintf(String, Int_FORMAT, LongIntOfTerm(t2));
#if USE_GMP
} else if (IsBigIntTerm(t2)) {
mpz_get_str(String, 10, Yap_BigIntOfTerm(t2));

View File

@ -71,8 +71,6 @@ clean_dirty_tr(tr_fr_ptr TR0) {
}
}
int show;
static int
copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf, CELL *HLow)
{
@ -92,7 +90,6 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
register CELL d0;
register CELL *ptd0;
++ pt0;
if (show) fprintf(stderr,"pt0=%p\n",pt0);
ptd0 = pt0;
d0 = *ptd0;
deref_head(d0, copy_term_unk);
@ -144,7 +141,6 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
register CELL *ap2;
/* store the terms to visit */
ap2 = RepAppl(d0);
if (show) fprintf(stderr,"d0=%lx %p %lx\n",d0,ap2,*ap2);
if (ap2 >= HB && ap2 <= H) {
/* If this is newer than the current term, just reuse */
*ptf++ = d0;

View File

@ -98,17 +98,9 @@ wrputn(Int n, wrf writewch) /* writes an integer */
wrputc(' ', writewch);
}
#if HAVE_SNPRINTF
#if SHORT_INTS
snprintf(s, 256, "%ld", n);
snprintf(s, 256, Int_FORMAT, n);
#else
snprintf(s, 256, "%d", n);
#endif
#else
#if SHORT_INTS
sprintf(s, "%ld", n);
#else
sprintf(s, "%d", n);
#endif
sprintf(s, Int_FORMAT, n);
#endif
while (*s1)
wrputc(*s1++, writewch);

View File

@ -165,8 +165,8 @@
/* */ typedef long int Int;
/* */ typedef unsigned long int UInt;
#define Int_FORMAT "%l"
#define UInt_FORMAT "%ul"
#define Int_FORMAT "%ld"
#define UInt_FORMAT "%lu"
#else
# error Yap require integer types of the same size as a pointer
@ -193,7 +193,7 @@
/* */ typedef long int Int;
/* */ typedef unsigned long int UInt;
#define Int_FORMAT "%l"
#define Int_FORMAT "%ld"
#define UInt_FORMAT "%lu"
# elif SIZEOF_LONG_LONG_INT==8

View File

@ -326,7 +326,7 @@ void STD_PROTO(Yap_emit,(compiler_vm_op,Int,CELL, struct intermediates *));
void STD_PROTO(Yap_emit_3ops,(compiler_vm_op,CELL,CELL,CELL, struct intermediates *));
void STD_PROTO(Yap_emit_4ops,(compiler_vm_op,CELL,CELL,CELL,CELL, struct intermediates *));
CELL *STD_PROTO(Yap_emit_extra_size,(compiler_vm_op,CELL,int, struct intermediates *));
char *STD_PROTO(Yap_AllocCMem,(int, struct intermediates *));
char *STD_PROTO(Yap_AllocCMem,(UInt, struct intermediates *));
void STD_PROTO(Yap_ReleaseCMem, (struct intermediates *));
int STD_PROTO(Yap_is_a_test_pred,(Term, Term));
void STD_PROTO(Yap_bip_name,(Int, char *));

View File

@ -303,7 +303,7 @@ void STD_PROTO(Yap_UnLockStream,(int));
#define Yap_LockStream(X)
#define Yap_UnLockStream(X)
#endif
int STD_PROTO(Yap_GetStreamFd,(int));
Int STD_PROTO(Yap_GetStreamFd,(int));
void STD_PROTO(Yap_CloseStreams,(int));
void STD_PROTO(Yap_FlushStreams,(void));
void STD_PROTO(Yap_CloseStream,(int));
@ -311,7 +311,7 @@ int STD_PROTO(Yap_PlGetchar,(void));
int STD_PROTO(Yap_PlGetWchar,(void));
int STD_PROTO(Yap_PlFGetchar,(void));
int STD_PROTO(Yap_GetCharForSIGINT,(void));
int STD_PROTO(Yap_StreamToFileNo,(Term));
Int STD_PROTO(Yap_StreamToFileNo,(Term));
Term STD_PROTO(Yap_OpenStream,(FILE *,char *,Term,int));
Term STD_PROTO(Yap_StringToTerm,(char *,Term *));
Term STD_PROTO(Yap_TermToString,(Term,char *,unsigned int,int));

61
configure vendored
View File

@ -753,6 +753,7 @@ enable_use_malloc
enable_condor
enable_chr
enable_clpqr
enable_win64
enable_april
enable_dlcompat
enable_cplint
@ -1419,6 +1420,7 @@ Optional Features:
--enable-condor allow Yap to be used from condor
--enable-chr install chr library
--enable-clpqr install clpqr library
--enable-win64 compile YAP for win64
--enable-april compile Yap to support April ILP system
--enable-dlcompat use dlcompat library for dynamic loading on Mac OS X
--enable-cplint=DIR enable the cplint library using the glu library in DIR/lib
@ -3683,6 +3685,13 @@ else
use_clpqr=yes
fi
# Check whether --enable-win64 was given.
if test "${enable_win64+set}" = set; then :
enableval=$enable_win64; target_win64="$enableval"
else
target_win64=no
fi
# Check whether --enable-april was given.
if test "${enable_april+set}" = set; then :
@ -4897,13 +4906,55 @@ then
INSTALL_COMMAND=install_win32
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
then
if test "$target_win64" = yes
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lws2_32" >&5
$as_echo_n "checking for main in -lws2_32... " >&6; }
if test "${ac_cv_lib_ws2_32_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lws2_32 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_ws2_32_main=yes
else
ac_cv_lib_ws2_32_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ws2_32_main" >&5
$as_echo "$ac_cv_lib_ws2_32_main" >&6; }
if test "x$ac_cv_lib_ws2_32_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBWS2_32 1
_ACEOF
LIBS="-lws2_32 $LIBS"
fi
else
if test "$target_os" = "cygwin"
then
CC="${CC} -mno-cygwin"
CXX="${CXX} -mno-cygwin"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lwsock32" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lwsock32" >&5
$as_echo_n "checking for main in -lwsock32... " >&6; }
if test "${ac_cv_lib_wsock32_main+set}" = set; then :
$as_echo_n "(cached) " >&6
@ -4981,6 +5032,7 @@ _ACEOF
fi
fi
yap_cv_readline=no
if test "$prefix" = "NONE"
then
@ -6780,7 +6832,7 @@ fi
# and -fomit-frame-point -DBP_FREE
JAVALIBPATH=""
JAVAINCPATH="-I\"$JAVA_HOME\"/include -I\"$JAVA_HOME\"/include/win32"
YAPLIB="libWYap.a"
YAPLIB="yap.dll"
SHLIB_CFLAGS=""
SHLIB_LD="\$(CC) -shared -Wl,--export-all-symbols ../../yap.dll"
SHLIB_LOWER_LD="\$(CC) -shared -Wl,--export-all-symbols ../../../yap.dll"
@ -6788,7 +6840,10 @@ fi
SHLIB_SWI_LD="\$(CC) -shared -Wl,--export-all-symbols ../../yap.dll ../../packages/PLStream/plstream.dll"
SHLIB_SUFFIX=".dll"
C_PARSER_FLAGS="$C_INTERF_FLAGS"
if test "$target_win64" = no
then
LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
fi
EXEC_SUFFIX=".exe"
INSTALL_DLLS=""
DO_SECOND_LD=""

View File

@ -74,6 +74,9 @@ AC_ARG_ENABLE(chr,
AC_ARG_ENABLE(clpqr,
[ --enable-clpqr install clpqr library ],
use_clpqr="$enableval", use_clpqr=yes)
AC_ARG_ENABLE(win64,
[ --enable-win64 compile YAP for win64 ],
target_win64="$enableval", target_win64=no)
AC_ARG_ENABLE(april,
[ --enable-april compile Yap to support April ILP system],
@ -513,12 +516,17 @@ then
INSTALL_COMMAND=install_win32
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
then
if test "$target_win64" = yes
then
AC_CHECK_LIB(ws2_32,main)
else
if test "$target_os" = "cygwin"
then
CC="${CC} -mno-cygwin"
CXX="${CXX} -mno-cygwin"
fi
AC_CHECK_LIB(wsock32,main)
fi
AC_CHECK_LIB(psapi,main)
yap_cv_readline=no
if test "$prefix" = "NONE"
@ -964,7 +972,7 @@ dnl Linux has both elf and a.out, in this case we found elf
# and -fomit-frame-point -DBP_FREE
JAVALIBPATH=""
JAVAINCPATH="-I\"$JAVA_HOME\"/include -I\"$JAVA_HOME\"/include/win32"
YAPLIB="libWYap.a"
YAPLIB="yap.dll"
SHLIB_CFLAGS=""
SHLIB_LD="\$(CC) -shared -Wl,--export-all-symbols ../../yap.dll"
SHLIB_LOWER_LD="\$(CC) -shared -Wl,--export-all-symbols ../../../yap.dll"
@ -972,7 +980,10 @@ dnl Linux has both elf and a.out, in this case we found elf
SHLIB_SWI_LD="\$(CC) -shared -Wl,--export-all-symbols ../../yap.dll ../../packages/PLStream/plstream.dll"
SHLIB_SUFFIX=".dll"
C_PARSER_FLAGS="$C_INTERF_FLAGS"
if test "$target_win64" = no
then
LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
fi
EXEC_SUFFIX=".exe"
INSTALL_DLLS=""
DO_SECOND_LD=""

View File

@ -97,10 +97,21 @@ stuff.
*******************************/
typedef unsigned long term_t;
#ifdef __WINDOWS__
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#if (_MSC_VER < 1300)
typedef long intptr_t;
typedef unsigned long uintptr_t;
#endif
#else
#include <inttypes.h> /* more portable than stdint.h */
#endif
typedef uintptr_t term_t;
typedef void *module_t;
typedef void *record_t;
typedef unsigned long atom_t;
typedef uintptr_t atom_t;
typedef YAP_Term *predicate_t;
typedef struct open_query_struct *qid_t;
typedef long functor_t;

View File

@ -984,7 +984,7 @@ X_API int PL_cons_functor(term_t d, functor_t f,...)
{
va_list ap;
int arity, i;
YAP_Term *tmp = (YAP_CELL *)buffers;
Term *tmp = (Term *)buffers;
Functor ff = SWIFunctorToFunctor(f);
if (IsAtomTerm((Term)ff)) {