Annotation of OpenXM/src/kxx/sample_kanlib.c, Revision 1.5
1.5 ! takayama 1: /* $OpenXM: OpenXM/src/kxx/sample_kanlib.c,v 1.4 2015/10/08 11:49:38 takayama Exp $ */
1.1 takayama 2: /*
3: This is a sample program to use kanlib.a
4: gcc -g -O2 -g -D_BSD_SOURCE sample_kanlib.c -o sample_kanlib -ldl ../kan96xx/Kan/kanlib.a -L../../lib -lgmp -lgc
5: */
6:
7: #include <stdio.h>
8: #include <setjmp.h>
9: #include <signal.h>
1.5 ! takayama 10: #include "mysig.h"
1.1 takayama 11:
1.4 takayama 12: // serversm.h is not included.
13: #if defined(__CYGWIN__) || defined(__MSYS__)
1.1 takayama 14: #define JMP_BUF sigjmp_buf
1.4 takayama 15: #define SETJMP(env) _setjmp(env)
16: #define LONGJMP(env,p) _longjmp(env,p)
1.1 takayama 17: #else
18: #define JMP_BUF jmp_buf
19: #define SETJMP(env) setjmp(env)
20: #define LONGJMP(env,p) longjmp(env,p)
21: #endif
22:
23:
24: extern int Quiet;
25: extern JMP_BUF EnvOfStackMachine;
1.2 takayama 26: extern Calling_ctrlC_hook;
1.3 takayama 27: extern int RestrictedMode, RestrictedMode_saved;
1.1 takayama 28:
29: void ctrlC();
30:
31: main() {
32: char s[1024];
33: Quiet = 0;
34: KSstart();
35:
1.5 ! takayama 36: if (mysignal(SIGINT,SIG_IGN) != SIG_IGN) {
! 37: mysignal(SIGINT,ctrlC);
1.1 takayama 38: }
39: while( fgets(s,1023,stdin) != NULL) {
40: if (SETJMP(EnvOfStackMachine)) {
1.2 takayama 41: if (!Calling_ctrlC_hook) {
1.3 takayama 42: Calling_ctrlC_hook = 1; RestrictedMode = 0;
1.2 takayama 43: KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */
1.3 takayama 44: RestrictedMode = RestrictedMode_saved;
1.2 takayama 45: }
46: Calling_ctrlC_hook = 0;
1.1 takayama 47: KSexecuteString(" (Computation is interrupted.) ");
48: continue;
49: } else { }
50: KSexecuteString(s);
51: }
52: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>