1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/**************************************
* Copyright Jean-Philippe Chancelier
* ENPC
**************************************/
#include <setjmp.h>
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include "../machine.h"
#include "../os_specific/addinter.h" /* for DynInterfStart */
#include "../os_specific/Os_specific.h" /* for DynInterfStart */
static jmp_buf jmp_env;
extern int C2F(error) __PARAMS((int *));
extern void sciprint __PARAMS((char* ,...));
extern int Scierror __PARAMS((int iv,char *fmt,...));
extern void errjump(int n);
extern void sci_sig_tstp(int n);
extern void controlC_handler(int n);
static void sci_sigint_addinter(int n);
/***********************************************************
* interface function
***********************************************************/
static int c_local = 9999;
void C2F(NoTclsci)(void)
{
sciprint("TclSci interface not loaded \n");
C2F(error)(&c_local);
return;
}
void C2F(NoPvm)(void)
{
sciprint("pvm interface not loaded \n");
C2F(error)(&c_local);
return;
}
/** table of interfaces **/
typedef struct {
void (*fonc)();} OpTab ;
#include "callinterf.h"
/***********************************************************
* call the apropriate interface according to the value of k
* iflagint is no more used here ....
***********************************************************/
static int sig_ok = 0;
int C2F(callinterf) ( int *k, int * iflagint)
{
int returned_from_longjump ;
static int count = 0;
if ( count == 0)
{
if (sig_ok) signal(SIGINT,sci_sigint_addinter);
if (( returned_from_longjump = setjmp(jmp_env)) != 0 )
{
if (sig_ok) signal(SIGINT, controlC_handler);
Scierror(999,"SIGSTP: aborting current computation\r\n");
count = 0;
return 0;
}
}
count++;
if (*k > DynInterfStart)
C2F(userlk)(k);
else
(*(Interfaces[*k-1].fonc))();
count--;
if (count == 0) {
if (sig_ok) signal(SIGINT, controlC_handler);
}
return 0;
}
static void sci_sigint_addinter(int n)
{
int c;
sciprint("Trying to stop scilab in the middle of an interface\n");
sciprint("Do you really want to abort computation (y n ?) ");
c = getchar();
if ( c == 'y' ) errjump(n);
}
/***********************************************************
* Unused function just here to force linker to load some
* functions
***********************************************************/
extern int Blas_contents __PARAMS((int));
extern int Lapack_contents __PARAMS((int));
extern int Calelm_contents __PARAMS((int));
extern int Sun_contents __PARAMS((int));
extern int System2_contents __PARAMS((int));
extern int System_contents __PARAMS((int));
extern int Intersci_contents __PARAMS((int));
extern int Sparse_contents __PARAMS((int));
#ifndef WIN32
int ForceLink(void)
{
Blas_contents(0);
Lapack_contents(0);
Calelm_contents(0);
Sun_contents(0);
System2_contents(0);
System_contents(0);
Intersci_contents(0);
Sparse_contents(0);
return 0;
}
#endif
/*-------------------------------------
* long jump to stop interface computation
*-------------------------------------*/
void errjump(int n)
{
longjmp(jmp_env,-1);
}
|