Annotation of OpenXM/src/kxx/sample_kanlib.c, Revision 1.4
1.4 ! takayama 1: /* $OpenXM: OpenXM/src/kxx/sample_kanlib.c,v 1.3 2004/09/17 02:42:58 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>
10:
1.4 ! takayama 11: // serversm.h is not included.
! 12: #if defined(__CYGWIN__) || defined(__MSYS__)
1.1 takayama 13: #define JMP_BUF sigjmp_buf
1.4 ! takayama 14: #define SETJMP(env) _setjmp(env)
! 15: #define LONGJMP(env,p) _longjmp(env,p)
1.1 takayama 16: #else
17: #define JMP_BUF jmp_buf
18: #define SETJMP(env) setjmp(env)
19: #define LONGJMP(env,p) longjmp(env,p)
20: #endif
21:
22:
23: extern int Quiet;
24: extern JMP_BUF EnvOfStackMachine;
1.2 takayama 25: extern Calling_ctrlC_hook;
1.3 takayama 26: extern int RestrictedMode, RestrictedMode_saved;
1.1 takayama 27:
28: void ctrlC();
29:
30: main() {
31: char s[1024];
32: Quiet = 0;
33: KSstart();
34:
35: if (signal(SIGINT,SIG_IGN) != SIG_IGN) {
36: signal(SIGINT,ctrlC);
37: }
38: while( fgets(s,1023,stdin) != NULL) {
39: if (SETJMP(EnvOfStackMachine)) {
1.2 takayama 40: if (!Calling_ctrlC_hook) {
1.3 takayama 41: Calling_ctrlC_hook = 1; RestrictedMode = 0;
1.2 takayama 42: KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */
1.3 takayama 43: RestrictedMode = RestrictedMode_saved;
1.2 takayama 44: }
45: Calling_ctrlC_hook = 0;
1.1 takayama 46: KSexecuteString(" (Computation is interrupted.) ");
47: continue;
48: } else { }
49: KSexecuteString(s);
50: }
51: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>