ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/calfunc.c
(Generate patch)

Comparing ray/src/common/calfunc.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:34:28 1989 UTC vs.
Revision 1.5 by greg, Fri May 17 08:55:39 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 22 | Line 22 | static char SCCSid[] = "$SunId$ LBL";
22  
23   #include  "calcomp.h"
24  
25 <
25 >                                /* bits in argument flag (better be right!) */
26 > #define  AFLAGSIZ       (8*sizeof(unsigned long))
27   #define  ALISTSIZ       6       /* maximum saved argument list */
28  
29   typedef struct activation {
# Line 35 | Line 36 | typedef struct activation {
36  
37   static ACTIVATION  *curact = NULL;
38  
39 < extern double  libfunc();
39 > static double  libfunc();
40  
41   #define  MAXLIB         64      /* maximum number of library functions */
42  
43 < extern double  l_if(), l_select(), l_rand();
44 < extern double  l_floor(), l_ceil();
43 > static double  l_if(), l_select(), l_rand();
44 > static double  l_floor(), l_ceil();
45   #ifdef  BIGLIB
46 < extern double  l_sqrt();
47 < extern double  l_sin(), l_cos(), l_tan();
48 < extern double  l_asin(), l_acos(), l_atan(), l_atan2();
49 < extern double  l_exp(), l_log(), l_log10();
46 > static double  l_sqrt();
47 > static double  l_sin(), l_cos(), l_tan();
48 > static double  l_asin(), l_acos(), l_atan(), l_atan2();
49 > static double  l_exp(), l_log(), l_log10();
50   #endif
51  
52   #ifdef  BIGLIB
53                          /* functions must be listed alphabetically */
54   static LIBR  library[MAXLIB] = {
55 <    { "acos", 1, l_acos },
56 <    { "asin", 1, l_asin },
57 <    { "atan", 1, l_atan },
58 <    { "atan2", 2, l_atan2 },
59 <    { "ceil", 1, l_ceil },
60 <    { "cos", 1, l_cos },
61 <    { "exp", 1, l_exp },
62 <    { "floor", 1, l_floor },
63 <    { "if", 3, l_if },
64 <    { "log", 1, l_log },
65 <    { "log10", 1, l_log10 },
66 <    { "rand", 1, l_rand },
67 <    { "select", 1, l_select },
68 <    { "sin", 1, l_sin },
69 <    { "sqrt", 1, l_sqrt },
70 <    { "tan", 1, l_tan },
55 >    { "acos", 1, ':', l_acos },
56 >    { "asin", 1, ':', l_asin },
57 >    { "atan", 1, ':', l_atan },
58 >    { "atan2", 2, ':', l_atan2 },
59 >    { "ceil", 1, ':', l_ceil },
60 >    { "cos", 1, ':', l_cos },
61 >    { "exp", 1, ':', l_exp },
62 >    { "floor", 1, ':', l_floor },
63 >    { "if", 3, ':', l_if },
64 >    { "log", 1, ':', l_log },
65 >    { "log10", 1, ':', l_log10 },
66 >    { "rand", 1, ':', l_rand },
67 >    { "select", 1, ':', l_select },
68 >    { "sin", 1, ':', l_sin },
69 >    { "sqrt", 1, ':', l_sqrt },
70 >    { "tan", 1, ':', l_tan },
71   };
72  
73   static int  libsize = 16;
# Line 74 | Line 75 | static int  libsize = 16;
75   #else
76                          /* functions must be listed alphabetically */
77   static LIBR  library[MAXLIB] = {
78 <    { "ceil", 1, l_ceil },
79 <    { "floor", 1, l_floor },
80 <    { "if", 3, l_if },
81 <    { "rand", 1, l_rand },
82 <    { "select", 1, l_select },
78 >    { "ceil", 1, ':', l_ceil },
79 >    { "floor", 1, ':', l_floor },
80 >    { "if", 3, ':', l_if },
81 >    { "rand", 1, ':', l_rand },
82 >    { "select", 1, ':', l_select },
83   };
84  
85   static int  libsize = 5;
# Line 130 | Line 131 | double  *a;
131      act.name = fname;
132      act.prev = curact;
133      act.ap = a;
134 <    act.an = (1L<<n)-1;
134 >    if (n >= AFLAGSIZ)
135 >        act.an = ~0;
136 >    else
137 >        act.an = (1L<<n)-1;
138      act.fun = NULL;
139      curact = &act;
140  
# Line 145 | Line 149 | double  *a;
149   }
150  
151  
152 < funset(fname, nargs, fptr)              /* set a library function */
152 > funset(fname, nargs, assign, fptr)      /* set a library function */
153   char  *fname;
154   int  nargs;
155 + int  assign;
156   double  (*fptr)();
157   {
158      register LIBR  *lp;
# Line 161 | Line 166 | double  (*fptr)();
166              if (strcmp(lp[-1].fname, fname) > 0) {
167                  lp[0].fname = lp[-1].fname;
168                  lp[0].nargs = lp[-1].nargs;
169 +                lp[0].atyp = lp[-1].atyp;
170                  lp[0].f = lp[-1].f;
171              } else
172                  break;
173          libsize++;
174      }
175 <    lp[0].fname = fname;                /* string must be static! */
175 >    lp[0].fname = savestr(fname);
176      lp[0].nargs = nargs;
177 +    lp[0].atyp = assign;
178      lp[0].f = fptr;
179   }
180  
# Line 201 | Line 208 | register int  n;
208          quit(1);
209      }
210                                                  /* already computed? */
211 <    if (1L<<n & actp->an)
211 >    if (n < AFLAGSIZ && 1L<<n & actp->an)
212          return(actp->ap[n]);
213  
214      if (actp->fun == NULL || (ep = ekid(actp->fun, n+1)) == NULL) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines