mingw complaint with recent versions of gcc
This commit is contained in:
parent
c59349d91d
commit
33190e290d
4
C/agc.c
Normal file → Executable file
4
C/agc.c
Normal file → Executable file
@ -429,7 +429,11 @@ atom_gc(void)
|
||||
tot_agc_time += agc_time;
|
||||
tot_agc_recovered += agc_collected;
|
||||
if (gc_verbose) {
|
||||
#ifdef _WIN32
|
||||
fprintf(Yap_stderr, "%% Collected %I64d bytes.\n", agc_collected);
|
||||
#else
|
||||
fprintf(Yap_stderr, "%% Collected %lld bytes.\n", agc_collected);
|
||||
#endif
|
||||
fprintf(Yap_stderr, "%% GC %d took %g sec, total of %g sec doing GC so far.\n", agc_calls, (double)agc_time/1000, (double)tot_agc_time/1000);
|
||||
}
|
||||
}
|
||||
|
4
C/bignum.c
Normal file → Executable file
4
C/bignum.c
Normal file → Executable file
@ -76,7 +76,9 @@ Yap_MkULLIntTerm(YAP_ULONG_LONG n)
|
||||
char tmp[256];
|
||||
Term t;
|
||||
|
||||
#if HAVE_SNPRINTF
|
||||
#ifdef _WIN32
|
||||
snprintf(tmp,256,"%I64u",n);
|
||||
#elif HAVE_SNPRINTF
|
||||
snprintf(tmp,256,"%llu",n);
|
||||
#else
|
||||
sprintf(tmp,"%llu",n);
|
||||
|
6
C/gmp_support.c
Normal file → Executable file
6
C/gmp_support.c
Normal file → Executable file
@ -368,7 +368,13 @@ Yap_gmp_big_from_64bits(YAP_LONG_LONG i)
|
||||
char s[64];
|
||||
MP_INT new;
|
||||
|
||||
#ifdef _WIN32
|
||||
snprintf(s,64,"%I64d", (long long int)i);
|
||||
#elif HAVE_SNPRINTF
|
||||
snprintf(s, 64, "%lld", (long long int)i);
|
||||
#else
|
||||
sprintf(s, "%lld", (long long int)i);
|
||||
#endif
|
||||
mpz_init_set_str (&new, s, 10);
|
||||
return MkBigAndClose(&new);
|
||||
}
|
||||
|
6
C/init.c
Normal file → Executable file
6
C/init.c
Normal file → Executable file
@ -1141,8 +1141,8 @@ InitThreadHandles(void)
|
||||
Yap_heap_regs->thread_handle[0].in_use = TRUE;
|
||||
Yap_heap_regs->thread_handle[0].default_yaam_regs =
|
||||
&Yap_standard_regs;
|
||||
Yap_heap_regs->thread_handle[0].handle = pthread_self();
|
||||
Yap_heap_regs->thread_handle[0].handle = pthread_self();
|
||||
Yap_heap_regs->thread_handle[0].pthread_handle = pthread_self();
|
||||
Yap_heap_regs->thread_handle[0].pthread_handle = pthread_self();
|
||||
pthread_mutex_init(&ThreadHandle[0].tlock, NULL);
|
||||
pthread_mutex_init(&ThreadHandle[0].tlock_status, NULL);
|
||||
Yap_heap_regs->thread_handle[0].tdetach = MkAtomTerm(AtomFalse);
|
||||
@ -1183,8 +1183,8 @@ InitCodes(void)
|
||||
Yap_heap_regs->wl[i].consultbase = Yap_heap_regs->wl[i].consultsp =
|
||||
Yap_heap_regs->wl[i].consultlow + Yap_heap_regs->wl[i].consultcapacity;
|
||||
Yap_heap_regs->wl[i].Gc_timestamp = 0;
|
||||
Yap_heap_regs->wl[i].ball_term = NULL;
|
||||
}
|
||||
Yap_heap_regs->wl[i].ball_term = NULL;
|
||||
}
|
||||
#else
|
||||
Yap_heap_regs->wl.dynamic_arrays = NULL;
|
||||
|
@ -522,8 +522,10 @@ InitPlIO (void)
|
||||
{
|
||||
Int i;
|
||||
|
||||
for (i = 0; i < MaxStreams; ++i)
|
||||
for (i = 0; i < MaxStreams; ++i) {
|
||||
INIT_LOCK(Stream[i].streamlock);
|
||||
Stream[i].status = Free_Stream_f;
|
||||
}
|
||||
/* alloca alias array */
|
||||
if (!FileAliases)
|
||||
FileAliases = (AliasDesc)Yap_AllocCodeSpace(sizeof(struct AliasDescS)*ALIASES_BLOCK_SIZE);
|
||||
|
19
C/sysbits.c
19
C/sysbits.c
@ -113,12 +113,6 @@ STATIC_PROTO (int chdir, (char *));
|
||||
char yap_pwd[YAP_FILENAME_MAX];
|
||||
#endif
|
||||
|
||||
#if HAVE_SIGNAL
|
||||
|
||||
static int snoozing = FALSE;
|
||||
|
||||
#endif
|
||||
|
||||
STD_PROTO (void exit, (int));
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -1492,6 +1486,13 @@ Yap_ProcessSIGINT(void)
|
||||
return ProcessSIGINT();
|
||||
}
|
||||
|
||||
|
||||
#if !_MSC_VER && !defined(__MINGW32__)
|
||||
|
||||
#if HAVE_SIGNAL
|
||||
static int snoozing = FALSE;
|
||||
#endif
|
||||
|
||||
/* This function is called from the signal handler to process signals.
|
||||
We assume we are within the context of the signal handler, whatever
|
||||
that might be
|
||||
@ -1543,6 +1544,7 @@ HandleSIGINT (int sig)
|
||||
ProcessSIGINT();
|
||||
UNLOCK(SignalLock);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32)
|
||||
/* this routine is called if the system activated the alarm */
|
||||
@ -3113,7 +3115,10 @@ p_win_registry_get_value(void)
|
||||
case REG_DWORD:
|
||||
recover_space(k, KeyAt);
|
||||
recover_space(name, NameAt);
|
||||
return Yap_unify(MkIntegerTerm(*((DWORD *)data)),ARG3);
|
||||
{
|
||||
DWORD *d = (DWORD *)data;
|
||||
return Yap_unify(MkIntegerTerm((Int)d[0]),ARG3);
|
||||
}
|
||||
default:
|
||||
recover_space(k, KeyAt);
|
||||
recover_space(name, NameAt);
|
||||
|
15
C/threads.c
Normal file → Executable file
15
C/threads.c
Normal file → Executable file
@ -263,7 +263,7 @@ p_create_thread(void)
|
||||
return FALSE;
|
||||
ThreadHandle[new_worker_id].id = new_worker_id;
|
||||
ThreadHandle[new_worker_id].ref_count = 1;
|
||||
if ((ThreadHandle[new_worker_id].ret = pthread_create(&ThreadHandle[new_worker_id].handle, NULL, thread_run, (void *)(&(ThreadHandle[new_worker_id].id)))) == 0) {
|
||||
if ((ThreadHandle[new_worker_id].ret = pthread_create(&ThreadHandle[new_worker_id].pthread_handle, NULL, thread_run, (void *)(&(ThreadHandle[new_worker_id].id)))) == 0) {
|
||||
/* wait until the client is initialised */
|
||||
return TRUE;
|
||||
}
|
||||
@ -373,7 +373,7 @@ Yap_thread_create_engine(thread_attr *ops)
|
||||
if (!init_thread_engine(new_id, ops->ssize, ops->tsize, ops->sysize, &t, &t, &(ops->egoal)))
|
||||
return FALSE;
|
||||
ThreadHandle[new_id].id = new_id;
|
||||
ThreadHandle[new_id].handle = pthread_self();
|
||||
ThreadHandle[new_id].pthread_handle = pthread_self();
|
||||
ThreadHandle[new_id].ref_count = 0;
|
||||
setup_engine(new_id);
|
||||
return TRUE;
|
||||
@ -384,13 +384,12 @@ Yap_thread_attach_engine(int wid)
|
||||
{
|
||||
DEBUG_TLOCK_ACCESS(7, wid);
|
||||
pthread_mutex_lock(&(ThreadHandle[wid].tlock));
|
||||
if (ThreadHandle[wid].ref_count &&
|
||||
ThreadHandle[wid].handle != pthread_self()) {
|
||||
if (ThreadHandle[wid].ref_count ) {
|
||||
DEBUG_TLOCK_ACCESS(8, wid);
|
||||
pthread_mutex_unlock(&(ThreadHandle[wid].tlock));
|
||||
return FALSE;
|
||||
}
|
||||
ThreadHandle[wid].handle = pthread_self();
|
||||
ThreadHandle[wid].pthread_handle = pthread_self();
|
||||
ThreadHandle[wid].ref_count++;
|
||||
worker_id = wid;
|
||||
DEBUG_TLOCK_ACCESS(9, wid);
|
||||
@ -403,8 +402,6 @@ Yap_thread_detach_engine(int wid)
|
||||
{
|
||||
DEBUG_TLOCK_ACCESS(10, wid);
|
||||
pthread_mutex_lock(&(ThreadHandle[wid].tlock));
|
||||
if (ThreadHandle[wid].handle == pthread_self())
|
||||
ThreadHandle[wid].handle = 0;
|
||||
ThreadHandle[wid].ref_count--;
|
||||
DEBUG_TLOCK_ACCESS(11, wid);
|
||||
pthread_mutex_unlock(&(ThreadHandle[wid].tlock));
|
||||
@ -442,7 +439,7 @@ p_thread_join(void)
|
||||
}
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
/* make sure this lock is accessible */
|
||||
if (pthread_join(ThreadHandle[tid].handle, NULL) < 0) {
|
||||
if (pthread_join(ThreadHandle[tid].pthread_handle, NULL) < 0) {
|
||||
/* ERROR */
|
||||
return FALSE;
|
||||
}
|
||||
@ -470,7 +467,7 @@ p_thread_detach(void)
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
pthread_mutex_lock(&(ThreadHandle[tid].tlock));
|
||||
DEBUG_TLOCK_ACCESS(14, tid);
|
||||
if (pthread_detach(ThreadHandle[tid].handle) < 0) {
|
||||
if (pthread_detach(ThreadHandle[tid].pthread_handle) < 0) {
|
||||
/* ERROR */
|
||||
DEBUG_TLOCK_ACCESS(15, tid);
|
||||
pthread_mutex_unlock(&(ThreadHandle[tid].tlock));
|
||||
|
16
C/ypsocks.c
Normal file → Executable file
16
C/ypsocks.c
Normal file → Executable file
@ -659,7 +659,11 @@ p_socket_bind(void)
|
||||
|
||||
if (IsVarTerm(tport)) {
|
||||
/* get the port number */
|
||||
#if _WIN32 || defined(__MINGW32__)
|
||||
int namelen;
|
||||
#else
|
||||
unsigned int namelen;
|
||||
#endif
|
||||
Term t;
|
||||
if (getsockname(fd, (struct sockaddr *)&saddr, &namelen) < 0) {
|
||||
#if HAVE_STRERROR
|
||||
@ -908,7 +912,11 @@ p_socket_accept(void)
|
||||
struct sockaddr_in caddr;
|
||||
Term tcli;
|
||||
char *s;
|
||||
#if _WIN32 || defined(__MINGW32__)
|
||||
int len;
|
||||
#else
|
||||
unsigned int len;
|
||||
#endif
|
||||
|
||||
len = sizeof(caddr);
|
||||
memset((void *)&caddr,(int) 0, sizeof(caddr));
|
||||
@ -950,7 +958,13 @@ p_socket_buffering(void)
|
||||
Atom mode;
|
||||
int fd;
|
||||
int writing;
|
||||
unsigned int bufsize, len;
|
||||
#if _WIN32 || defined(__MINGW32__)
|
||||
int bufsize;
|
||||
int len;
|
||||
#else
|
||||
unsigned int bufsize;
|
||||
unsigned int len;
|
||||
#endif
|
||||
int sno;
|
||||
|
||||
if ((sno = Yap_CheckSocketStream(t1, "socket_buffering/4")) < 0) {
|
||||
|
4
H/YapHeap.h
Normal file → Executable file
4
H/YapHeap.h
Normal file → Executable file
@ -209,7 +209,7 @@ typedef struct thandle {
|
||||
REGSTORE *default_yaam_regs;
|
||||
REGSTORE *current_yaam_regs;
|
||||
struct pred_entry *local_preds;
|
||||
pthread_t handle;
|
||||
pthread_t pthread_handle;
|
||||
int ref_count;
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
long long int thread_inst_count;
|
||||
@ -218,7 +218,7 @@ typedef struct thandle {
|
||||
#endif
|
||||
pthread_mutex_t tlock;
|
||||
pthread_mutex_t tlock_status;
|
||||
#if HAVE_GETRUSAGE
|
||||
#if HAVE_GETRUSAGE||defined(_WIN32)
|
||||
struct timeval *start_of_timesp;
|
||||
struct timeval *last_timep;
|
||||
#endif
|
||||
|
2
include/yap_structs.h
Normal file → Executable file
2
include/yap_structs.h
Normal file → Executable file
@ -161,7 +161,7 @@ typedef struct {
|
||||
struct yami *p;
|
||||
} YAP_dogoalinfo;
|
||||
|
||||
typedef int (*YAP_agc_hook)(YAP_Atom);
|
||||
typedef int (*YAP_agc_hook)(void *_Atom);
|
||||
|
||||
/********* execution mode ***********************/
|
||||
|
||||
|
26
library/yap2swi/yap2swi.c
Normal file → Executable file
26
library/yap2swi/yap2swi.c
Normal file → Executable file
@ -584,7 +584,11 @@ X_API int PL_get_int64(term_t ts, int64_t *i)
|
||||
return 0;
|
||||
}
|
||||
mpz_get_str (s, 10, &g);
|
||||
#ifdef _WIN32
|
||||
sscanf(s, "%I64d", (long long int *)i);
|
||||
#else
|
||||
sscanf(s, "%lld", (long long int *)i);
|
||||
#endif
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
@ -907,7 +911,13 @@ X_API int PL_put_int64(term_t t, int64_t n)
|
||||
char s[64];
|
||||
MP_INT rop;
|
||||
|
||||
#ifdef _WIN32
|
||||
snprintf(s, 64, "%I64d", (long long int)n);
|
||||
#elif HAVE_SNPRINTF
|
||||
snprintf(s, 64, "%lld", (long long int)n);
|
||||
#else
|
||||
sprintf(s, "%lld", (long long int)n);
|
||||
#endif
|
||||
mpz_init_set_str (&rop, s, 10);
|
||||
Yap_PutInSlot(t,YAP_MkBigNumTerm((void *)&rop));
|
||||
return TRUE;
|
||||
@ -1315,7 +1325,13 @@ X_API int PL_unify_int64(term_t t, int64_t n)
|
||||
char s[64];
|
||||
MP_INT rop;
|
||||
|
||||
#ifdef _WIN32
|
||||
snprintf(s, 64, "%I64d", (long long int)n);
|
||||
#elif HAVE_SNPRINTF
|
||||
snprintf(s, 64, "%lld", (long long int)n);
|
||||
#else
|
||||
sprintf(s, "%lld", (long long int)n);
|
||||
#endif
|
||||
mpz_init_set_str (&rop, s, 10);
|
||||
iterm = YAP_MkBigNumTerm((void *)&rop);
|
||||
return YAP_Unify(Yap_GetFromSlot(t),iterm);
|
||||
@ -1602,7 +1618,13 @@ X_API int PL_unify_term(term_t l,...)
|
||||
char s[64];
|
||||
MP_INT rop;
|
||||
|
||||
#ifdef _WIN32
|
||||
snprintf(s, 64, "%I64d", va_arg(ap, long long int));
|
||||
#elif HAVE_SNPRINTF
|
||||
snprintf(s, 64, "%lld", va_arg(ap, long long int));
|
||||
#else
|
||||
sprintf(s, "%lld", va_arg(ap, long long int));
|
||||
#endif
|
||||
mpz_init_set_str (&rop, s, 10);
|
||||
*pt++ = YAP_MkBigNumTerm((void *)&rop);
|
||||
}
|
||||
@ -2336,7 +2358,11 @@ PL_eval_expression_to_int64_ex(term_t t, int64_t *val)
|
||||
return PL_error(NULL,0,NULL, ERR_EVALUATION, AtomToSWIAtom(Yap_LookupAtom("int_overflow")));
|
||||
}
|
||||
mpz_get_str (s, 10, &g);
|
||||
#ifdef _WIN32
|
||||
sscanf(s, "%I64d", (long long int *)val);
|
||||
#else
|
||||
sscanf(s, "%lld", (long long int *)val);
|
||||
#endif
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user