version 1.6, 2003/01/15 10:16:10 |
version 1.8, 2003/02/12 08:28:41 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM: OpenXM/src/ox_math/sm_ext.c,v 1.5 2003/01/15 05:08:10 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_math/sm_ext.c,v 1.7 2003/02/04 14:27:43 ohara Exp $ */ |
|
|
/* |
/* |
Copyright (C) Katsuyoshi OHARA, 2000. |
Copyright (C) Katsuyoshi OHARA, 2000. |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <gmp.h> |
#include <signal.h> |
#include <ox_toolkit.h> |
#include <ox_toolkit.h> |
#include "sm.h" |
#include "sm.h" |
|
#include "mlo.h" |
|
|
static struct { int (*func_ptr)(); int key; } tbl_smcmd[] = { |
static struct { int (*func_ptr)(); int key; } tbl_smcmd[] = { |
{sm_executeFunction, SM_executeFunction}, |
{sm_executeFunction, SM_executeFunction}, |
Line 32 static struct { int (*func_ptr)(); int key; } tbl_smcm |
|
Line 33 static struct { int (*func_ptr)(); int key; } tbl_smcm |
|
|
|
extern OXFILE *stack_oxfp; |
extern OXFILE *stack_oxfp; |
|
|
|
static sigset_t mask; |
|
static int flag_state_interrupting = 0; |
|
|
|
/* state management for the OpenXM robust interruption */ |
|
void sm_state_set_interrupting() |
|
{ |
|
ml_state_set(RESERVE_INTERRUPTION); |
|
} |
|
|
|
int sm_state_interrupting() |
|
{ |
|
return ml_state(RESERVE_INTERRUPTION); |
|
} |
|
|
|
void sm_state_clear_interrupting() |
|
{ |
|
ml_state_clear_all(); |
|
} |
|
|
|
/* handling OpenXM singals */ |
|
static void sm_sighandler() |
|
{ |
|
sm_state_set_interrupting(); |
|
} |
|
|
|
/* generating the mask pattern */ |
|
void sm_siginit() |
|
{ |
|
signal(SIGUSR1, sm_sighandler); |
|
sigemptyset(&mask); |
|
sigaddset(&mask, SIGUSR1); |
|
} |
|
|
|
void sm_sigmask() |
|
{ |
|
sigprocmask(SIG_BLOCK, &mask, NULL); |
|
} |
|
|
|
void sm_sigunmask() |
|
{ |
|
sigprocmask(SIG_UNBLOCK, &mask, NULL); |
|
} |
|
|
int (*sm_search_f(int code))() |
int (*sm_search_f(int code))() |
{ |
{ |
int i; |
int i; |
Line 48 void sm_popString() |
|
Line 92 void sm_popString() |
|
{ |
{ |
char *s; |
char *s; |
cmo *err; |
cmo *err; |
cmo *m; |
cmo *m = pop(); |
|
|
ox_printf("ox_math:: opecode = SM_popString.\n"); |
|
m = pop(); |
|
if (m->tag == CMO_STRING) { |
if (m->tag == CMO_STRING) { |
send_ox_cmo(stack_oxfp, m); |
send_ox_cmo(stack_oxfp, m); |
}else if ((s = new_string_set_cmo(m)) != NULL) { |
}else if ((s = new_string_set_cmo(m)) != NULL) { |
Line 83 int local_execute(char *s) |
|
Line 124 int local_execute(char *s) |
|
/* The following function is depend on an implementation of a server. */ |
/* The following function is depend on an implementation of a server. */ |
void sm_executeStringByLocalParser() |
void sm_executeStringByLocalParser() |
{ |
{ |
symbol_t symp; |
|
cmo* m = pop(); |
cmo* m = pop(); |
char *s = NULL; |
char *s = NULL; |
|
|
ox_printf("ox_math:: opecode = SM_executeStringByLocalParser.\n"); |
|
if (m->tag == CMO_STRING |
if (m->tag == CMO_STRING |
&& strlen(s = ((cmo_string *)m)->s) != 0) { |
&& strlen(s = ((cmo_string *)m)->s) != 0) { |
if (s[0] == ':') { |
if (s[0] == ':') { |
Line 96 void sm_executeStringByLocalParser() |
|
Line 134 void sm_executeStringByLocalParser() |
|
/* for mathematica */ |
/* for mathematica */ |
/* Sending the string `s' to mathematica for its evaluation. */ |
/* Sending the string `s' to mathematica for its evaluation. */ |
ml_evaluateStringByLocalParser(s); |
ml_evaluateStringByLocalParser(s); |
push(ml_return()); |
sm_sigunmask(); |
|
ml_select(); |
|
sm_sigmask(); |
|
m = ml_return(); |
|
push(m); |
} |
} |
}else { |
}else { |
#ifdef DEBUG |
ox_printf(" <%s>", get_symbol_by_tag(m->tag)); |
symp = lookup_by_tag(m->tag); |
|
ox_printf("ox_math:: error. the top of stack is %s.\n", symbol_get_key(symp)); |
|
#endif |
|
push_error(SM_executeStringByLocalParser, m); |
push_error(SM_executeStringByLocalParser, m); |
} |
} |
} |
} |
Line 129 void sm_executeFunction() |
|
Line 168 void sm_executeFunction() |
|
argv[i] = pop(); |
argv[i] = pop(); |
} |
} |
ml_executeFunction(func, argc, argv); |
ml_executeFunction(func, argc, argv); |
push(ml_return()); |
sm_sigunmask(); |
|
ml_select(); |
|
sm_sigmask(); |
|
m = ml_return(); |
|
push(m); |
} |
} |
|
|
void sm_mathcap() |
void sm_mathcap() |
Line 147 void sm_set_mathcap() |
|
Line 190 void sm_set_mathcap() |
|
/* an error object must be pushed */ |
/* an error object must be pushed */ |
} |
} |
} |
} |
|
|