From f7fe32a03c8524d0dee053f6c22fd97ce9aa771b Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Fri, 24 Oct 2014 15:18:32 +0100 Subject: [PATCH] fix win32 warnings: unsigned long != CELL, IOSTREAM with sace restore, _ffsll and _isatty, fp patches --- C/arith1.c | 44 +++++++++++++++---------- C/pl-yap.c | 6 ++++ C/save.c | 82 +++++++++++++++++++++++----------------------- C/signals.c | 16 ++++++++- C/sysbits.c | 34 +++++++++++++++++-- H/YapSignals.h | 4 +++ H/Yatom.h | 2 ++ H/eval.h | 4 +++ OPTYap/tab.tries.c | 16 +++------ config.h.in | 6 ++++ configure | 15 +++++---- configure.in | 4 +-- misc/mkwin | 2 ++ os/pl-nt.c | 11 +++++-- os/windows/popen.c | 5 +++ 15 files changed, 166 insertions(+), 85 deletions(-) mode change 100755 => 100644 misc/mkwin diff --git a/C/arith1.c b/C/arith1.c index 77ef433b9..e5b57b2e3 100644 --- a/C/arith1.c +++ b/C/arith1.c @@ -330,22 +330,32 @@ msb(Int inp USES_REGS) /* calculate the most significant bit for an integer */ "msb/1 received %d", inp); } -#if 0 - +#if HAVE__BUILTIN_FFSLL + out = __builtin_ffsll(inp); +#elif HAVE_FFSLL + out = ffsll(inp); #else - int off = sizeof(CELL)*4; - while (off) { - Int limit = ((CELL)1) << (off); - if (inp >= limit) { - out += off; - inp >>= off; - } - off >>= 1; - } + if (inp==0) + return 0L; +#if SIZEOF_INT_P == 8 + if (inp & ((CELL)0xffffffffLL << 32)) {inp >>= 32; out += 32;} #endif - return(out); + if (inp & ((CELL)0xffffL << 16)) {inp >>= 16; out += 16;} + if (inp & ((CELL)0xffL << 8)) {inp >>= 8; out += 8;} + if (inp & ((CELL)0xfL << 4)) {inp >>= 4; out += 4;} + if (inp & ((CELL)0x3L << 2)) {inp >>= 2; out += 2;} + if (inp & ((CELL)0x1 << 1)) out++; +#endif + return out; } +Int +Yap_msb(Int inp USES_REGS) /* calculate the most significant bit for an integer */ +{ + return msb(inp PASS_REGS); +} + + static Int lsb(Int inp USES_REGS) /* calculate the least significant bit for an integer */ { @@ -359,12 +369,12 @@ lsb(Int inp USES_REGS) /* calculate the least significant bit for an integer */ if (inp==0) return 0L; #if SIZEOF_INT_P == 8 - if (!(inp & 0xffffffffLL)) {inp >>= 32; out += 32;} + if (!(inp & (CELL)0xffffffffLL)) {inp >>= 32; out += 32;} #endif - if (!(inp & 0xffffL)) {inp >>= 16; out += 16;} - if (!(inp & 0xffL)) {inp >>= 8; out += 8;} - if (!(inp & 0xfL)) {inp >>= 4; out += 4;} - if (!(inp & 0x3L)) {inp >>= 2; out += 2;} + if (!(inp & (CELL)0xffffL)) {inp >>= 16; out += 16;} + if (!(inp & (CELL)0xffL)) {inp >>= 8; out += 8;} + if (!(inp & (CELL)0xfL)) {inp >>= 4; out += 4;} + if (!(inp & (CELL)0x3L)) {inp >>= 2; out += 2;} if (!(inp & ((CELL)0x1))) out++; return out; diff --git a/C/pl-yap.c b/C/pl-yap.c index b888170c1..32c394f6a 100755 --- a/C/pl-yap.c +++ b/C/pl-yap.c @@ -4,6 +4,12 @@ #define PL_KERNEL 1 #include +#if HAVE_UNISTD_H +#include +#endif +#if HAVE_SYS_TIMES_H +#include +#endif #include "Yap.h" #include "Yatom.h" #include "pl-incl.h" diff --git a/C/save.c b/C/save.c index 37dc1045a..9639de891 100755 --- a/C/save.c +++ b/C/save.c @@ -19,8 +19,6 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90"; #endif #include "config.h" -#include "absmi.h" -#include "SWI-Stream.h" #if _MSC_VER || defined(__MINGW32__) #if HAVE_WINSOCK2_H #include @@ -28,6 +26,8 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90"; #include #include #endif +#include "absmi.h" +#include "SWI-Stream.h" #include "alloc.h" #if USE_DL_MALLOC #include "dlmalloc.h" @@ -89,9 +89,9 @@ void initIO(void); #endif -static int myread(int, char *, Int); -static Int mywrite(int, char *, Int); -static int open_file(char *, int); +static int myread(IOSTREAM *, char *, Int); +static Int mywrite(IOSTREAM *, char *, Int); +static IOSTREAM *open_file(char *, int); static int close_file(void); static Int putout(CELL); static Int putcellptr(CELL *); @@ -187,11 +187,11 @@ do_system_error(yap_error_number etype, const char *msg) inline static -int myread(int fd, char *buffer, Int len) { +int myread(IOSTREAM *fd, char *buffer, Int len) { ssize_t nread; while (len > 0) { - nread = read(fd, buffer, (int)len); + nread = Sfread(buffer, 1, (int)len, fd); if (nread < 1) { return do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"bad read on saved state"); } @@ -203,11 +203,11 @@ int myread(int fd, char *buffer, Int len) { inline static Int -mywrite(int fd, char *buff, Int len) { +mywrite(IOSTREAM *fd, char *buff, Int len) { ssize_t nwritten; while (len > 0) { - nwritten = write(fd, buff, (size_t)len); + nwritten = Sfwrite(buff, 1, (size_t)len, fd); if (nwritten < 0) { return do_system_error(SYSTEM_ERROR,"bad write on saved state"); } @@ -225,7 +225,7 @@ mywrite(int fd, char *buff, Int len) { typedef CELL *CELLPOINTER; -static int splfild = 0; +static IOSTREAM *splfild = NULL; #ifdef DEBUG @@ -242,10 +242,12 @@ static Int OldHeapUsed; static CELL which_save; /* Open a file to read or to write */ -static int +static IOSTREAM * open_file(char *my_file, int flag) { - int splfild; + IOSTREAM *splfild; + char flags[6]; + int i=0; #if __ANDROID__ if (strstr(my_file, "/assets/") == my_file) { @@ -253,36 +255,34 @@ open_file(char *my_file, int flag) my_file += strlen("/assets/"); AAsset* asset = AAssetManager_open(GLOBAL_assetManager, my_file, AASSET_MODE_UNKNOWN); if (!asset) - return -1; + return NULL; AAsset_close( asset ); - return 0; // usually the file will be compressed, so there is no point in actually trying to open it. + return NULL; // usually the file will be compressed, so there is no point in actually trying to open it. } - return -1; + return NULL; } #endif -#ifdef M_WILLIAMS - if (flag & O_CREAT) - splfild = creat(my_file, flag); - else - splfild = open(my_file, flag); - if (splfild < 0) { -#else -#ifdef O_BINARY -#if _MSC_VER - if ((splfild = _open(my_file, flag | O_BINARY), _S_IREAD | _S_IWRITE) < 0) -#else - if ((splfild = open(my_file, flag | O_BINARY, 0775)) < 0) + if (flag & O_RDONLY) { + flags[i++] = 'r'; + } + if (flag & O_CREAT) { + flags[i++] = 'w'; + } + if (flag & O_WRONLY) { + flags[i++] = 'w'; + } + if (flag & O_APPEND) { + flags[i++] = 'a'; + } +#if _WIN32 + if (flag & O_BINARY) { + flags[i++] = 'b'; + } #endif -#else /* O_BINARY */ - if ((splfild = open(my_file, flag, 0755)) < 0) -#endif /* O_BINARY */ -#endif /* M_WILLIAMS */ - { - splfild = -1; /* We do not have an open file */ - return -1; - } + flags[i] = '\0'; + splfild = Sopen_file( my_file, flags); #ifdef undf0 - fprintf(errout, "Opened file %s\n", my_file); + fprintf(errout, "Opened file %s\n", my_file); #endif return splfild; } @@ -292,7 +292,7 @@ close_file(void) { if (splfild == 0) return 0; - if (close(splfild) < 0) + if (Sclose(splfild) < 0) return do_system_error(SYSTEM_ERROR,"bad close on saved state"); splfild = 0; return 1; @@ -326,9 +326,9 @@ static CELL get_header_cell(void) { CELL l; - int count = 0, n; + size_t count = 0, n; while (count < sizeof(CELL)) { - if ((n = read(splfild, &l, sizeof(CELL)-count)) < 0) { + if ((n = Sfread(&l, 1, sizeof(CELL)-count, splfild)) < 0) { do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to read saved state header"); return 0L; } @@ -684,7 +684,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) /* skip the first line */ pp[0] = '\0'; do { - if ((n = read(splfild, pp, 1)) <= 0) { + if ((n = Sfread(pp, 1, 1, splfild)) <= 0) { do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan first line from saved state"); return FAIL_RESTORE; } @@ -694,7 +694,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) { int count = 0, n, to_read = Unsigned(strlen(msg) + 1); while (count < to_read) { - if ((n = read(splfild, pp, to_read-count)) <= 0) { + if ((n = Sfread(pp, 1, to_read-count, splfild)) <= 0) { do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan version info from saved state"); return FAIL_RESTORE; } diff --git a/C/signals.c b/C/signals.c index 525d596f9..68a9e0a1f 100755 --- a/C/signals.c +++ b/C/signals.c @@ -21,6 +21,10 @@ static char SccsId[] = "%W% %G%"; #define HAS_CACHE_REGS 1 #include "Yap.h" +#if _WIN32 +#include +#include +#endif #include "Yatom.h" #include "YapHeap.h" #include "eval.h" @@ -105,7 +109,11 @@ ProcessSIGINT(void) { CACHE_REGS int ch, out; -#if HAVE_ISATTY +#if _WIN32 + if (!_isatty(0)) { + return YAP_INT_SIGNAL; + } +#elif HAVE_ISATTY if (!isatty(0)) { return YAP_INT_SIGNAL; } @@ -318,7 +326,13 @@ p_first_signal( USES_REGS1 ) uint64_t mask = LOCAL_Signals; if (mask == 0) return FALSE; +#if HAVE___BUILTIN_FFSLL +x sig = __builtin_ffsll(mask); +#elif HAVE_FFSLL sig = ffsll(mask); +#else + sig = Yap_msb( mask ); +#endif if (get_signal(sig PASS_REGS)) { break; } diff --git a/C/sysbits.c b/C/sysbits.c index cfebc300a..336680252 100644 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -1419,12 +1419,36 @@ HandleSIGSEGV(int sig, void *sipv, void *uap) yap_error_number Yap_MathException__( USES_REGS1 ) { +#if HAVE_FETESTEXCEPT int raised; -#if HAVE_FETESTEXCEPT // #pragma STDC FENV_ACCESS ON if ((raised = fetestexcept( FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)) ) { + feclearexcept(FE_ALL_EXCEPT); + if (raised & FE_OVERFLOW) { + return EVALUATION_ERROR_FLOAT_OVERFLOW; + } else if (raised & FE_DIVBYZERO) { + return EVALUATION_ERROR_ZERO_DIVISOR; + } else if (raised & FE_UNDERFLOW) { + return EVALUATION_ERROR_FLOAT_UNDERFLOW; + //} else if (raised & (FE_INVALID|FE_INEXACT)) { + // return EVALUATION_ERROR_UNDEFINED; + } else { + return EVALUATION_ERROR_UNDEFINED; + } + } +#elif _WIN32 + unsigned int raised; + int err; + + // Show original FP control word and do calculation. + err = _controlfp_s(&raised, 0, 0); + if (err) { + return EVALUATION_ERROR_UNDEFINED; + } + if (raised ) { + feclearexcept(FE_ALL_EXCEPT); if (raised & FE_OVERFLOW) { return EVALUATION_ERROR_FLOAT_OVERFLOW; @@ -1522,7 +1546,7 @@ my_signal(int sig, void * handler) static void my_signal(int sig, void *handler) { - signal(sig, void *handler); + signal(sig, handler); } static void @@ -2544,6 +2568,9 @@ set_fpu_exceptions(bool flag) #elif HAVE_FEENABLEEXCEPT /* I shall ignore de-normalization and precision errors */ feenableexcept(FE_DIVBYZERO| FE_INVALID|FE_OVERFLOW); +#elif _WIN32 + // Enable zero-divide, overflow and underflow exception + _controlfp_s(0, ~(_EM_ZERODIVIDE|_EM_UNDERFLOW|_EM_OVERFLOW), _MCW_EM); // Line B #elif defined(__hpux) # if HAVE_FESETTRAPENABLE /* From HP-UX 11.0 onwards: */ @@ -2580,6 +2607,9 @@ set_fpu_exceptions(bool flag) #elif HAVE_FEENABLEEXCEPT /* I shall ignore de-normalization and precision errors */ feenableexcept(0); +#elif _WIN32 + // Enable zero-divide, overflow and underflow exception + _controlfp_s(0, (_EM_ZERODIVIDE|_EM_UNDERFLOW|_EM_OVERFLOW), _MCW_EM); // Line B #elif defined(__hpux) # if HAVE_FESETTRAPENABLE fesettrapenable(FE_ALL_EXCEPT); diff --git a/H/YapSignals.h b/H/YapSignals.h index def05a28e..afa58da1f 100755 --- a/H/YapSignals.h +++ b/H/YapSignals.h @@ -83,6 +83,10 @@ SIGNAL_TO_BIT( yap_signals sig) INLINE_ONLY inline EXTERN int Yap_has_a_signal__ ( USES_REGS1 ); +INLINE_ONLY inline EXTERN int Yap_has_signal__ ( yap_signals sig USES_REGS ); + +INLINE_ONLY inline EXTERN int Yap_only_has_signal__(yap_signals sig USES_REGS); + INLINE_ONLY inline EXTERN int Yap_has_a_signal__ (USES_REGS1) { diff --git a/H/Yatom.h b/H/Yatom.h index be02258a8..3a75271f3 100755 --- a/H/Yatom.h +++ b/H/Yatom.h @@ -1581,6 +1581,8 @@ INLINE_ONLY EXTERN inline Prop GetPredPropByFuncAndModHavingLock(FunctorEntry *, INLINE_ONLY EXTERN inline Prop PredPropByFuncAndMod(FunctorEntry *, Term); INLINE_ONLY EXTERN inline Prop PredPropByAtomAndMod(Atom, Term); INLINE_ONLY EXTERN inline Prop GetPredPropByFuncHavingLock(FunctorEntry *, Term); +INLINE_ONLY EXTERN inline Prop PredPropByFunc (Functor fe, Term cur_mod); +INLINE_ONLY EXTERN inline Prop PredPropByAtom (Atom at, Term cur_mod); #ifdef THREADS diff --git a/H/eval.h b/H/eval.h index 8d94dbf24..143dce452 100644 --- a/H/eval.h +++ b/H/eval.h @@ -566,6 +566,10 @@ add_int(Int i, Int j USES_REGS) #endif } +/* calculate the most significant bit for an integer */ +Int +Yap_msb(Int inp USES_REGS); + static inline Term p_plus(Term t1, Term t2 USES_REGS) { switch (ETypeOfTerm(t1)) { diff --git a/OPTYap/tab.tries.c b/OPTYap/tab.tries.c index b417f36bc..34a94fec2 100644 --- a/OPTYap/tab.tries.c +++ b/OPTYap/tab.tries.c @@ -149,7 +149,7 @@ static struct trie_statistics{ #define CHECK_DECREMENT_GLOBAL_TRIE_REFERENCE(REF,MODE) \ if (MODE == TRAVERSE_MODE_NORMAL && IsVarTerm(REF) && REF > VarIndexOfTableTerm(MAX_TABLE_VARS)) { \ register gt_node_ptr gt_node = (gt_node_ptr) (REF); \ - TrNode_child(gt_node) = (gt_node_ptr) ((unsigned long int) TrNode_child(gt_node) - 1); \ + TrNode_child(gt_node) = (gt_node_ptr) ((uintptr_t) TrNode_child(gt_node) - 1); \ if (TrNode_child(gt_node) == 0) \ FREE_GLOBAL_TRIE_BRANCH(gt_node,TRAVERSE_MODE_NORMAL); \ } @@ -842,7 +842,7 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in else { TrStat_gt_terms++; str[str_index] = 0; - SHOW_TABLE_STRUCTURE(" TERMx%ld: %s\n", (unsigned long int) TrNode_child(current_node), str); + SHOW_TABLE_STRUCTURE(" TERMx" UInt_FORMAT ": %s\n", (CELL) TrNode_child(current_node), str); } /* restore the initial state and continue with sibling nodes */ @@ -913,11 +913,7 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int mode = TRAVERSE_MODE_NORMAL; } else if (mode == TRAVERSE_MODE_LONGINT) { Int li = (Int) t; -#if SHORT_INTS - str_index += sprintf(& str[str_index], "%ld", li); -#else - str_index += sprintf(& str[str_index], "%d", li); -#endif /* SHORT_INTS */ + str_index += sprintf(& str[str_index], Int_FORMAT, li); traverse_update_arity(str, &str_index, arity); if (type == TRAVERSE_TYPE_SUBGOAL) mode = TRAVERSE_MODE_NORMAL; @@ -955,11 +951,7 @@ static inline void traverse_trie_node(Term t, char *str, int *str_index_ptr, int traverse_update_arity(str, &str_index, arity); } } else if (IsIntTerm(t)) { -#if SHORT_INTS - str_index += sprintf(& str[str_index], "%ld", IntOfTerm(t)); -#else - str_index += sprintf(& str[str_index], "%d", IntOfTerm(t)); -#endif /* SHORT_INTS */ + str_index += sprintf(& str[str_index], Int_FORMAT, IntOfTerm(t)); traverse_update_arity(str, &str_index, arity); } else if (IsAtomTerm(t)) { #ifndef TRIE_COMPACT_PAIRS diff --git a/config.h.in b/config.h.in index f28c82975..320d1c609 100644 --- a/config.h.in +++ b/config.h.in @@ -535,6 +535,9 @@ /* Define to 1 if you have the `NSLinkModule' function. */ #undef HAVE_NSLINKMODULE +/* c++ nullptr support */ +#undef HAVE_NULLPTR + /* Define to 1 if you have the `opendir' function. */ #undef HAVE_OPENDIR @@ -938,6 +941,9 @@ /* Define to 1 if you have the `_NSGetEnviron' function. */ #undef HAVE__NSGETENVIRON +/* Define to 1 if you have the `__builtin_ffsll' function. */ +#undef HAVE___BUILTIN_FFSLL + /* what is the configure host name */ #undef HOST_ALIAS diff --git a/configure b/configure index 69e3553cc..23e42c9b7 100755 --- a/configure +++ b/configure @@ -4433,7 +4433,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "$ac_cv_nullptr" = true -o $_MSC_VER -ge 1600; then - $as_echo "#define HAVE_NULLPTR 1" >>confdefs.h + +$as_echo "#define HAVE_NULLPTR /**/" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -9575,7 +9576,7 @@ _ACEOF fi done -for ac_func in feenableexcept fesetexceptflag fesettrapenable fesetround ffsl ffsll fgetpos finite +for ac_func in feenableexcept fesetexceptflag fesettrapenable fesetround ffsl ffsll __builtin_ffsll fgetpos finite do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -12343,7 +12344,7 @@ if test "$PKG_ODBC" != ""; then # Check whether --with-odbc was given. if test "${with_odbc+set}" = set; then : withval=$with_odbc; case $withval in - no|yes) echo 'Specify dir for XPM please'; + no|yes) echo 'Specify dir for ODBC please'; exit 1 ;; *) ODBC_DIR=${withval} esac @@ -13952,7 +13953,7 @@ else JAVA_TEST=Test.java CLASS_TEST=Test.class cat << \EOF > $JAVA_TEST -/* #line 13955 "configure" */ +/* #line 13956 "configure" */ public class Test { } EOF @@ -14128,7 +14129,7 @@ EOF if uudecode$EXEEXT Test.uue; then ac_cv_prog_uudecode_base64=yes else - echo "configure: 14131: uudecode had trouble decoding base 64 file 'Test.uue'" >&5 + echo "configure: 14132: uudecode had trouble decoding base 64 file 'Test.uue'" >&5 echo "configure: failed file was:" >&5 cat Test.uue >&5 ac_cv_prog_uudecode_base64=no @@ -14259,7 +14260,7 @@ else JAVA_TEST=Test.java CLASS_TEST=Test.class cat << \EOF > $JAVA_TEST -/* #line 14262 "configure" */ +/* #line 14263 "configure" */ public class Test { } EOF @@ -14294,7 +14295,7 @@ JAVA_TEST=Test.java CLASS_TEST=Test.class TEST=Test cat << \EOF > $JAVA_TEST -/* [#]line 14297 "configure" */ +/* [#]line 14298 "configure" */ public class Test { public static void main (String args[]) { System.exit (0); diff --git a/configure.in b/configure.in index ea086b6dd..19b276ce6 100755 --- a/configure.in +++ b/configure.in @@ -122,7 +122,7 @@ AC_CACHE_VAL(ac_cv_nullptr, [ac_cv_nullptr=true], [ac_cv_nullptr=false])]) if test "$ac_cv_nullptr" = true -o $_MSC_VER -ge 1600; then - AC_DEFINE(HAVE_NULLPTR) + AC_DEFINE(HAVE_NULLPTR, [], [c++ nullptr support]) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) @@ -1650,7 +1650,7 @@ AC_CHECK_FUNCS(_NSGetEnviron _chsize_s access acosh) AC_CHECK_FUNCS(alloca asinh atanh chdir clock clock_gettime) AC_CHECK_FUNCS(ctime dlopen dup2) AC_CHECK_FUNCS(erf feclearexcept) -AC_CHECK_FUNCS(feenableexcept fesetexceptflag fesettrapenable fesetround ffsl ffsll fgetpos finite) +AC_CHECK_FUNCS(feenableexcept fesetexceptflag fesettrapenable fesetround ffsl ffsll __builtin_ffsll fgetpos finite) AC_CHECK_FUNCS(flsl flsll fpclass ftime ftruncate getcwd getenv) AC_CHECK_FUNCS(getexecname) AC_CHECK_FUNCS(gethostbyname gethostent gethostid gethostname) diff --git a/misc/mkwin b/misc/mkwin old mode 100755 new mode 100644 index fda7837d3..256772f06 --- a/misc/mkwin +++ b/misc/mkwin @@ -19,6 +19,8 @@ # http://nsis.sourceforge.net/Main_Page # # +TOP=$HOME +TOP="/z" VERSION=6.3.4 # by default, compile without threads THREADS=no diff --git a/os/pl-nt.c b/os/pl-nt.c index a141ae645..44719a83c 100755 --- a/os/pl-nt.c +++ b/os/pl-nt.c @@ -1043,13 +1043,17 @@ PRED_IMPL("win_registry_get_value", 3, win_registry_get_value, 0) DEBUG(9, Sdprintf("key = %p, name = %s\n", key, name)); if ( RegQueryValueExW(key, name, NULL, &type, data, &len) == ERROR_SUCCESS ) { RegCloseKey(key); + DWORD *datap; switch(type) { case REG_SZ: return PL_unify_wchars(Value, PL_ATOM, len/sizeof(wchar_t)-1, (wchar_t*)data); case REG_DWORD: - return PL_unify_integer(Value, *((DWORD *)data)); + { + datap = (DWORD *)data; + return PL_unify_integer(Value, datap[0]); + } default: warning("get_registry_value/2: Unknown registry-type: %d", type); fail; @@ -1089,9 +1093,10 @@ setStacksFromKey(HKEY key) { if ( RegQueryValueEx(key, rd->name, NULL, &type, data, &len) == ERROR_SUCCESS && type == REG_DWORD ) - { DWORD v = *((DWORD *)data); + { DWORD v, *datap = (DWORD *)data; + v = datap[0]; - *rd->address = (int)v; + *rd->address = (int)v; } } } diff --git a/os/windows/popen.c b/os/windows/popen.c index 0910b301c..49d60687b 100755 --- a/os/windows/popen.c +++ b/os/windows/popen.c @@ -53,6 +53,11 @@ If you find this file and know better, please contact info@swi-prolog.org. #include #include "pl-utf8.h" +DWORD RunSilent(const char* strCommand); +FILE *pt_popen(const char *cmd, const char *mode); +int pt_pclose(FILE *fd); + + DWORD RunSilent(const char* strCommand) { STARTUPINFO StartupInfo;