From 17004f202c892fd4d933b94c6b7441c45a06e80b Mon Sep 17 00:00:00 2001 From: dos-reis Date: Thu, 29 Jul 2010 15:43:35 +0000 Subject: * algebra/sf.spad.pamphlet (DoubleFloat): Use builtin trigonometric functions. * interp/g-opt.boot ($VMsideEffectFreeOperators): Include them. * interp/g-util.boot: Expand them. * include/edible.H1: Move declarations to clef/edible.c. Remove. * driver/utils.h: Give G linkage to declarations. * sman/Makefile.in: Link programs against C++ runtime. --- src/ChangeLog | 10 +++++++++ src/algebra/sf.spad.pamphlet | 51 +++++++++++++++++++++++++++++--------------- src/algebra/strap/DFLOAT.lsp | 36 +++++++++++++++---------------- src/clef/edible.c | 42 ++++++++++++++++-------------------- src/driver/utils.h | 10 +++++++++ src/include/edible.H1 | 13 ----------- src/interp/g-opt.boot | 2 ++ src/interp/g-util.boot | 17 +++++++++++++++ src/sman/Makefile.in | 8 +++---- 9 files changed, 113 insertions(+), 76 deletions(-) delete mode 100644 src/include/edible.H1 (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index a54a1ef7..0f1ff3d3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2010-07-29 Gabriel Dos Reis + + * algebra/sf.spad.pamphlet (DoubleFloat): Use builtin + trigonometric functions. + * interp/g-opt.boot ($VMsideEffectFreeOperators): Include them. + * interp/g-util.boot: Expand them. + * include/edible.H1: Move declarations to clef/edible.c. Remove. + * driver/utils.h: Give G linkage to declarations. + * sman/Makefile.in: Link programs against C++ runtime. + 2010-07-29 Gabriel Dos Reis * driver/main.c (main): Add explicit conversion to diff --git a/src/algebra/sf.spad.pamphlet b/src/algebra/sf.spad.pamphlet index 1b51d3a0..1585af6a 100644 --- a/src/algebra/sf.spad.pamphlet +++ b/src/algebra/sf.spad.pamphlet @@ -279,6 +279,7 @@ DoubleFloat(): Join(FloatingPointSystem, DifferentialRing, OpenMath, == add MER ==> Record(MANTISSA:Integer,EXPONENT:Integer) + import %hash: % -> SingleInteger from Foreign Builtin import %fminval: () -> % from Foreign Builtin import %fmaxval: () -> % from Foreign Builtin import %fbase: () -> PositiveInteger from Foreign Builtin @@ -298,6 +299,22 @@ DoubleFloat(): Join(FloatingPointSystem, DifferentialRing, OpenMath, import %fle: (%,%) -> Boolean from Foreign Builtin import %fgt: (%,%) -> Boolean from Foreign Builtin import %fge: (%,%) -> Boolean from Foreign Builtin + import %fsin: % -> % from Foreign Builtin + import %fcos: % -> % from Foreign Builtin + import %ftan: % -> % from Foreign Builtin + import %fcot: % -> % from Foreign Builtin + import %fsec: % -> % from Foreign Builtin + import %fcsc: % -> % from Foreign Builtin + import %fatan: % -> % from Foreign Builtin + import %facot: % -> % from Foreign Builtin + import %fsinh: % -> % from Foreign Builtin + import %fcosh: % -> % from Foreign Builtin + import %ftanh: % -> % from Foreign Builtin + import %fcsch: % -> % from Foreign Builtin + import %fcoth: % -> % from Foreign Builtin + import %fsech: % -> % from Foreign Builtin + import %fasinh: % -> % from Foreign Builtin + import %facsch: % -> % from Foreign Builtin manexp: % -> MER @@ -381,35 +398,35 @@ DoubleFloat(): Join(FloatingPointSystem, DifferentialRing, OpenMath, exp x == EXP(x)$Lisp log x == checkComplex LN(x)$Lisp log2 x == checkComplex LOG2(x)$Lisp - sin x == SIN(x)$Lisp - cos x == COS(x)$Lisp - tan x == TAN(x)$Lisp - cot x == COT(x)$Lisp - sec x == SEC(x)$Lisp - csc x == CSC(x)$Lisp + sin x == %fsin x + cos x == %fcos x + tan x == %ftan x + cot x == %fcot x + sec x == %fsec x + csc x == %fcsc x asin x == checkComplex ASIN(x)$Lisp -- can be complex acos x == checkComplex ACOS(x)$Lisp -- can be complex - atan x == ATAN(x)$Lisp + atan x == %fatan x acsc x == checkComplex ACSC(x)$Lisp - acot x == ACOT(x)$Lisp + acot x == %facot x asec x == checkComplex ASEC(x)$Lisp - sinh x == SINH(x)$Lisp - cosh x == COSH(x)$Lisp - tanh x == TANH(x)$Lisp - csch x == CSCH(x)$Lisp - coth x == COTH(x)$Lisp - sech x == SECH(x)$Lisp - asinh x == ASINH(x)$Lisp + sinh x == %fsinh x + cosh x == %fcosh x + tanh x == %ftanh x + csch x == %fcsch x + coth x == %fcoth x + sech x == %fsech x + asinh x == %fasinh x acosh x == checkComplex ACOSH(x)$Lisp -- can be complex atanh x == checkComplex ATANH(x)$Lisp -- can be complex - acsch x == ACSCH(x)$Lisp + acsch x == %facsch x acoth x == checkComplex ACOTH(x)$Lisp asech x == checkComplex ASECH(x)$Lisp x:% / y:% == %fdiv(x,y) negative? x == x < 0 zero? x == x = 0 one? x == x = 1 - hash x == HASHEQ(x)$Lisp + hash x == %hash x recip(x) == (zero? x => "failed"; 1 / x) differentiate x == 0 diff --git a/src/algebra/strap/DFLOAT.lsp b/src/algebra/strap/DFLOAT.lsp index 6ce53de0..0736ea62 100644 --- a/src/algebra/strap/DFLOAT.lsp +++ b/src/algebra/strap/DFLOAT.lsp @@ -184,32 +184,32 @@ (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;sin;2$;41|)) -(PUT '|DFLOAT;sin;2$;41| '|SPADreplace| 'SIN) +(PUT '|DFLOAT;sin;2$;41| '|SPADreplace| '|%fsin|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;cos;2$;42|)) -(PUT '|DFLOAT;cos;2$;42| '|SPADreplace| 'COS) +(PUT '|DFLOAT;cos;2$;42| '|SPADreplace| '|%fcos|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;tan;2$;43|)) -(PUT '|DFLOAT;tan;2$;43| '|SPADreplace| 'TAN) +(PUT '|DFLOAT;tan;2$;43| '|SPADreplace| '|%ftan|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;cot;2$;44|)) -(PUT '|DFLOAT;cot;2$;44| '|SPADreplace| 'COT) +(PUT '|DFLOAT;cot;2$;44| '|SPADreplace| '|%fcot|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;sec;2$;45|)) -(PUT '|DFLOAT;sec;2$;45| '|SPADreplace| 'SEC) +(PUT '|DFLOAT;sec;2$;45| '|SPADreplace| '|%fsec|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;csc;2$;46|)) -(PUT '|DFLOAT;csc;2$;46| '|SPADreplace| 'CSC) +(PUT '|DFLOAT;csc;2$;46| '|SPADreplace| '|%fcsc|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;asin;2$;47|)) @@ -220,7 +220,7 @@ (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;atan;2$;49|)) -(PUT '|DFLOAT;atan;2$;49| '|SPADreplace| 'ATAN) +(PUT '|DFLOAT;atan;2$;49| '|SPADreplace| '|%fatan|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;acsc;2$;50|)) @@ -228,7 +228,7 @@ (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;acot;2$;51|)) -(PUT '|DFLOAT;acot;2$;51| '|SPADreplace| 'ACOT) +(PUT '|DFLOAT;acot;2$;51| '|SPADreplace| '|%facot|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;asec;2$;52|)) @@ -236,37 +236,37 @@ (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;sinh;2$;53|)) -(PUT '|DFLOAT;sinh;2$;53| '|SPADreplace| 'SINH) +(PUT '|DFLOAT;sinh;2$;53| '|SPADreplace| '|%fsinh|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;cosh;2$;54|)) -(PUT '|DFLOAT;cosh;2$;54| '|SPADreplace| 'COSH) +(PUT '|DFLOAT;cosh;2$;54| '|SPADreplace| '|%fcosh|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;tanh;2$;55|)) -(PUT '|DFLOAT;tanh;2$;55| '|SPADreplace| 'TANH) +(PUT '|DFLOAT;tanh;2$;55| '|SPADreplace| '|%ftanh|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;csch;2$;56|)) -(PUT '|DFLOAT;csch;2$;56| '|SPADreplace| 'CSCH) +(PUT '|DFLOAT;csch;2$;56| '|SPADreplace| '|%fcsch|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;coth;2$;57|)) -(PUT '|DFLOAT;coth;2$;57| '|SPADreplace| 'COTH) +(PUT '|DFLOAT;coth;2$;57| '|SPADreplace| '|%fcoth|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;sech;2$;58|)) -(PUT '|DFLOAT;sech;2$;58| '|SPADreplace| 'SECH) +(PUT '|DFLOAT;sech;2$;58| '|SPADreplace| '|%fsech|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;asinh;2$;59|)) -(PUT '|DFLOAT;asinh;2$;59| '|SPADreplace| 'ASINH) +(PUT '|DFLOAT;asinh;2$;59| '|SPADreplace| '|%fasinh|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;acosh;2$;60|)) @@ -277,7 +277,7 @@ (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;acsch;2$;62|)) -(PUT '|DFLOAT;acsch;2$;62| '|SPADreplace| 'ACSCH) +(PUT '|DFLOAT;acsch;2$;62| '|SPADreplace| '|%facsch|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%DoubleFloat|) |DFLOAT;acoth;2$;63|)) @@ -303,7 +303,7 @@ (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%Short|) |DFLOAT;hash;$Si;69|)) -(PUT '|DFLOAT;hash;$Si;69| '|SPADreplace| 'HASHEQ) +(PUT '|DFLOAT;hash;$Si;69| '|SPADreplace| '|%hash|) (DECLAIM (FTYPE (FUNCTION (|%DoubleFloat| |%Shell|) |%Pair|) |DFLOAT;recip;$U;70|)) @@ -590,7 +590,7 @@ (DEFUN |DFLOAT;one?;$B;68| (|x| $) (DECLARE (IGNORE $)) (= |x| 1.0)) -(DEFUN |DFLOAT;hash;$Si;69| (|x| $) (DECLARE (IGNORE $)) (HASHEQ |x|)) +(DEFUN |DFLOAT;hash;$Si;69| (|x| $) (DECLARE (IGNORE $)) (SXHASH |x|)) (DEFUN |DFLOAT;recip;$U;70| (|x| $) (COND ((ZEROP |x|) (CONS 1 "failed")) (T (CONS 0 (/ 1.0 |x|))))) diff --git a/src/clef/edible.c b/src/clef/edible.c index a1270eef..baacf5fa 100644 --- a/src/clef/edible.c +++ b/src/clef/edible.c @@ -55,7 +55,6 @@ #include "prt.H1" #include "edin.H1" #include "wct.H1" -#include "edible.H1" #include "fnct_key.H1" #include "cfuns.h" @@ -68,6 +67,13 @@ #define Cursor_shape(x) +static void check_flip(void); +static void catch_signals(void); +static void init_parent(void); +static void set_function_chars(void); +static void flip_canonical(int ); +static void flip_raw(int ); + #ifdef siglog int sigfile; @@ -324,7 +330,7 @@ main(int argc, char *argv[]) } -void +static void init_parent(void) { @@ -370,7 +376,7 @@ init_parent(void) } -void +static void hangup_handler(int sig) { #ifdef siglog @@ -392,7 +398,7 @@ hangup_handler(int sig) exit(-1); } -void +static void terminate_handler(int sig) { #ifdef siglog @@ -414,7 +420,7 @@ terminate_handler(int sig) exit(0); } -void +static void interrupt_handler(int sig) { #ifdef siglog @@ -426,7 +432,7 @@ interrupt_handler(int sig) kill(child_pid, SIGINT); } -void +static void child_handler(int sig) { #ifdef siglog @@ -448,7 +454,7 @@ child_handler(int sig) exit(0); } -void +static void alarm_handler(int sig) { int newppid = getppid(); @@ -478,7 +484,7 @@ alarm_handler(int sig) } /* a procedure which tells my parent how to catch signals from its children */ -void +static void catch_signals(void) { #ifdef siglog @@ -498,7 +504,7 @@ catch_signals(void) /* Here is where I check the child's termio settings, and try to copy them. I simply trace through the main modes (CLEFRAW, CLEFCANONICAL) and try to simulate them */ -void +static void check_flip(void) { return; @@ -529,7 +535,7 @@ check_flip(void) -void +static void flip_raw(int chann) { @@ -543,7 +549,7 @@ flip_raw(int chann) } -void +static void flip_canonical(int chann) { if(tcsetattr(0, TCSAFLUSH, &canonbuf) == -1) { @@ -556,22 +562,10 @@ flip_canonical(int chann) Cursor_shape(2); } -void -etc_get_next_line(char * line,int * nr,int fd) -{ - *nr = read(fd, line, 1024); - if(*nr == -1) { - perror("Reading /etc/master"); - } - if(*nr == 0) { - fprintf(stderr, "Not found \n"); - } -} - #define etc_whitespace(c) ((c == ' ' || c == '\t')?(1):(0)) -void +static void set_function_chars(void) { /* get the special characters */ diff --git a/src/driver/utils.h b/src/driver/utils.h index 83c168ae..eebb1783 100644 --- a/src/driver/utils.h +++ b/src/driver/utils.h @@ -42,6 +42,10 @@ # include #endif +#ifdef __cplusplus +extern "C" { +#endif + /* A list of drivers for OpenAxiom. */ typedef enum openaxiom_driver { openaxiom_unknown_driver, /* unknown driver */ @@ -81,4 +85,10 @@ void openaxiom_build_rts_options(openaxiom_command*, openaxiom_driver); openaxiom_driver openaxiom_preprocess_arguments(openaxiom_command*, int, char**); + + +#ifdef __cplusplus +} +#endif + #endif /* OPENAXIOM_UTILS_INCLUDED */ diff --git a/src/include/edible.H1 b/src/include/edible.H1 deleted file mode 100644 index d61da787..00000000 --- a/src/include/edible.H1 +++ /dev/null @@ -1,13 +0,0 @@ -extern void check_flip(void); -extern int main(int , char * []); -extern void catch_signals(void); -extern void init_parent(void); -extern void set_function_chars(void); -extern void hangup_handler(int ); -extern void terminate_handler(int ); -extern void interrupt_handler(int ); -extern void child_handler(int ); -extern void alarm_handler(int ); -extern void flip_canonical(int ); -extern void flip_raw(int ); -extern void etc_get_next_line(char * , int * , int ); diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 32f7c426..1c45d60f 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -446,6 +446,8 @@ $VMsideEffectFreeOperators == %irem %iquo %idivide %feq %flt %fle %fgt %fge %fmul %fadd %fsub %fexp %fmin %fmax %float? %fpow %fdiv %fneg %i2f %fminval %fmaxval %fbase %fprec %ftrunc + %fsin %fcos %ftan %fcot %fsec %fcsc %fatan %facot + %fsinh %fcosh %ftanh %fcsch %fcoth %fsech %fasinh %facsch %nil %pair? %lconcat %llength %lfirst %lsecond %lthird %lreverse %lempty? %hash %ismall? %string? %f2s %ccst %ceq %clt %cle %cgt %cge %c2i %i2c %sname diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot index d9145d47..96bbe1fd 100644 --- a/src/interp/g-util.boot +++ b/src/interp/g-util.boot @@ -413,6 +413,23 @@ for x in [ ['%fpow, :'EXPT], ['%fsub, :"-"], + ['%fsin, :'SIN], + ['%fcos, :'COS], + ['%ftan, :'TAN], + ['%fcot, :'COT], + ['%fsec, :'SEC], + ['%fcsc, :'CSC], + ['%fatan, :'ATAN], + ['%facot, :'ACOT], + ['%fsinh, :'SINH], + ['%fcosh, :'COSH], + ['%ftanh, :'TANH], + ['%fcsch, :'CSCH], + ['%fcoth, :'COTH], + ['%fsech, :'SECH], + ['%fasinh, :'ASINH], + ['%facsch, :'ACSCH], + -- string operations ['%f2s, :'DFLOAT_-FORMAT_-GENERAL], diff --git a/src/sman/Makefile.in b/src/sman/Makefile.in index 87086d02..2d01a620 100644 --- a/src/sman/Makefile.in +++ b/src/sman/Makefile.in @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2009, Gabriel Dos Reis. +# Copyright (C) 2007-2010, Gabriel Dos Reis. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -85,16 +85,16 @@ stamp: $(OUTLIB)/session$(EXEEXT) \ -I$(top_srcdir)/src/driver $< ${OUTLIB}/session$(EXEEXT): $(session_objects) $(session_DEPENDENCIES) - $(LINK) -o $@ $(session_objects) $(session_LDADD) + $(CXXLINK) -o $@ $(session_objects) $(session_LDADD) ${OUTLIB}/spadclient$(EXEEXT): $(spadclient_objects) $(spadclient_DEPENDENCIES) - $(LINK) -o $@ $(spadclient_objects) $(spadclient_LDADD) + $(CXXLINK) -o $@ $(spadclient_objects) $(spadclient_LDADD) spadclient.$(OBJEXT): ${INC}/useproto.h ${INC}/spadclient.H1 \ $(axiom_configdir)/axiom-c-macros.h ${OUT}/sman$(EXEEXT): $(sman_objects) $(sman_DEPENDENCIES) - $(LINK) -o $@ $(sman_objects) $(sman_LDADD) + $(CXXLINK) -o $@ $(sman_objects) $(sman_LDADD) $(sman_objects): sman.h $(axiom_c_macros_h) -- cgit v1.2.3