fix alarm in WIN32/cygwin (I hope).
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@314 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
363a201ad2
commit
04aae3895d
45
C/sysbits.c
45
C/sysbits.c
@ -1940,13 +1940,27 @@ static Int p_file_age(void)
|
|||||||
/* wrapper for alarm system call */
|
/* wrapper for alarm system call */
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
#if _MSC_VER || defined(__MINGW32__)
|
||||||
|
|
||||||
static VOID CALLBACK HandleTimer(LPVOID v, DWORD d1, DWORD d2) {
|
static DWORD WINAPI
|
||||||
/* force the system to creep */
|
DoTimerThread(LPVOID targ)
|
||||||
exit(0);
|
{
|
||||||
|
Int time = *(Int *)targ;
|
||||||
|
HANDLE htimer;
|
||||||
|
LARGE_INTEGER liDueTime;
|
||||||
|
|
||||||
|
htimer = CreateWaitableTimer(NULL,FALSE,NULL);
|
||||||
|
liDueTime.QuadPart = -10000000LL*time;
|
||||||
|
/* Copy the relative time into a LARGE_INTEGER. */
|
||||||
|
if (SetWaitableTimer(htimer, &liDueTime,0,NULL,NULL,0) == 0) {
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
if (WaitForSingleObject(htimer, INFINITE) != WAIT_OBJECT_0)
|
||||||
|
fprintf(stderr,"WaitForSingleObject failed (%ld)\n", GetLastError());
|
||||||
p_creep ();
|
p_creep ();
|
||||||
/* now, say what is going on */
|
/* now, say what is going on */
|
||||||
PutValue(AtomAlarm, MkAtomTerm(AtomTrue));
|
PutValue(AtomAlarm, MkAtomTerm(AtomTrue));
|
||||||
|
ExitThread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
@ -1964,22 +1978,23 @@ p_alarm(void)
|
|||||||
#if _MSC_VER || defined(__MINGW32__)
|
#if _MSC_VER || defined(__MINGW32__)
|
||||||
{
|
{
|
||||||
Term tout;
|
Term tout;
|
||||||
HANDLE htimer;
|
Int time = IntegerOfTerm(t);
|
||||||
Int time = -IntegerOfTerm(t);
|
|
||||||
|
|
||||||
if (time != 0) {
|
if (time != 0) {
|
||||||
__int64 due_time;
|
DWORD dwThreadId;
|
||||||
LARGE_INTEGER liDueTime;
|
HANDLE hThread;
|
||||||
|
|
||||||
htimer = CreateWaitableTimer(NULL,FALSE,NULL);
|
hThread = CreateThread(
|
||||||
due_time = time;
|
NULL, /* no security attributes */
|
||||||
due_time *= 10000000;
|
0, /* use default stack size */
|
||||||
/* Copy the relative time into a LARGE_INTEGER. */
|
DoTimerThread, /* thread function */
|
||||||
liDueTime.LowPart = (DWORD) ( due_time & 0xFFFFFFFF );
|
(LPVOID)&time, /* argument to thread function */
|
||||||
liDueTime.HighPart = (LONG) ( due_time >> 32 );
|
0, /* use default creation flags */
|
||||||
if (SetWaitableTimer(htimer, &liDueTime,0,HandleTimer,NULL,0) == 0) {
|
&dwThreadId); /* returns the thread identifier */
|
||||||
|
|
||||||
|
/* Check the return value for success. */
|
||||||
|
if (hThread == NULL) {
|
||||||
WinError("trying to use alarm");
|
WinError("trying to use alarm");
|
||||||
return(FALSE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tout = MkIntegerTerm(0);
|
tout = MkIntegerTerm(0);
|
||||||
|
@ -110,6 +110,7 @@ assertz_static(V) :- var(V), !,
|
|||||||
throw(error(instantiation_error,assertz_static(V))).
|
throw(error(instantiation_error,assertz_static(V))).
|
||||||
assertz_static(C) :-
|
assertz_static(C) :-
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
|
(predicate_property(short(_), dynamic) -> write(yes), nl ; write(no),nl),
|
||||||
'$assert_static'(C,Mod,last,_,assertz_static(C)).
|
'$assert_static'(C,Mod,last,_,assertz_static(C)).
|
||||||
|
|
||||||
'$assert_static'(V,M,_,_,_) :- var(V), !,
|
'$assert_static'(V,M,_,_,_) :- var(V), !,
|
||||||
|
Reference in New Issue
Block a user