File:
[local] /
rpl /
src /
analyse.c
Revision
1.13:
download - view:
text,
annotated -
select for diffs -
revision graph
Thu Apr 29 07:30:57 2010 UTC (14 years ago) by
bertrand
Branches:
MAIN
CVS tags:
HEAD
Correction d'un point bloquant dans la gestion des processus
(affectation des interruptions logicielles survenant après l'arrêt du
processus père car le mutex de protection de la routine était déjà positionné
dans la fonction appelante). Ajout de la fonction CLRATEXIT.
1: /*
2: ================================================================================
3: RPL/2 (R) version 4.0.15
4: Copyright (C) 1989-2010 Dr. BERTRAND Joël
5:
6: This file is part of RPL/2.
7:
8: RPL/2 is free software; you can redistribute it and/or modify it
9: under the terms of the CeCILL V2 License as published by the french
10: CEA, CNRS and INRIA.
11:
12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
15: for more details.
16:
17: You should have received a copy of the CeCILL License
18: along with RPL/2. If not, write to info@cecill.info.
19: ================================================================================
20: */
21:
22:
23: #include "rpl.conv.h"
24:
25:
26: /*
27: ================================================================================
28: Analyseur syntaxique de l'interprète RPL/2
29: ================================================================================
30: Entrées :
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38:
39: static void
40: creation_instruction(struct_processus *s_etat_processus,
41: unsigned char *instruction, void (*routine)())
42: {
43: int i;
44:
45: struct_instruction *l_instruction_courante;
46:
47: unsigned char *ptr;
48:
49: if ((*s_etat_processus).arbre_instructions == NULL)
50: {
51: if (((*s_etat_processus).arbre_instructions =
52: malloc(sizeof(struct_instruction))) == NULL)
53: {
54: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
55: return;
56: }
57:
58: (*(*s_etat_processus).arbre_instructions).feuille = NULL;
59:
60: if (((*(*s_etat_processus).arbre_instructions).noeud =
61: malloc((*s_etat_processus).nombre_caracteres
62: * sizeof(struct_instruction))) == NULL)
63: {
64: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
65: return;
66: }
67:
68: for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++)
69: {
70: (*(*s_etat_processus).arbre_instructions).noeud[i] = NULL;
71: }
72: }
73:
74: l_instruction_courante = (*s_etat_processus).arbre_instructions;
75: ptr = instruction;
76:
77: while((*ptr) != d_code_fin_chaine)
78: {
79: BUG((*s_etat_processus).pointeurs_caracteres[*ptr] < 0,
80: printf("Instruction=\"%s\", (*ptr)='%c'\n",
81: instruction, *ptr));
82:
83: if ((*l_instruction_courante).noeud[(*s_etat_processus)
84: .pointeurs_caracteres[*ptr]] == NULL)
85: {
86: // Le noeud suivant n'existe pas, on le crée.
87:
88: if (((*l_instruction_courante).noeud[(*s_etat_processus)
89: .pointeurs_caracteres[*ptr]] =
90: malloc(sizeof(struct_instruction))) == NULL)
91: {
92: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
93: return;
94: }
95:
96: (*(*l_instruction_courante).noeud[(*s_etat_processus)
97: .pointeurs_caracteres[*ptr]]).feuille = NULL;
98:
99: if (((*(*l_instruction_courante).noeud[(*s_etat_processus)
100: .pointeurs_caracteres[*ptr]]).noeud =
101: malloc((*s_etat_processus).nombre_caracteres
102: * sizeof(struct_instruction))) == NULL)
103: {
104: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
105: return;
106: }
107:
108: for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++)
109: {
110: (*(*l_instruction_courante).noeud[(*s_etat_processus)
111: .pointeurs_caracteres[*ptr]]).noeud[i] = NULL;
112: }
113: }
114:
115: l_instruction_courante = (*l_instruction_courante).noeud
116: [(*s_etat_processus).pointeurs_caracteres[*ptr]];
117: ptr++;
118: }
119:
120: BUG((*l_instruction_courante).feuille != NULL,
121: printf("Instruction=\"%s\"\n", instruction));
122:
123: (*l_instruction_courante).feuille = routine;
124:
125: return;
126: }
127:
128:
129: void
130: liberation_arbre_instructions(struct_processus *s_etat_processus,
131: struct_instruction *arbre)
132: {
133: int i;
134:
135: for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++)
136: {
137: if ((*arbre).noeud[i] != NULL)
138: {
139: liberation_arbre_instructions(s_etat_processus, (*arbre).noeud[i]);
140: }
141: }
142:
143: free((*arbre).noeud);
144: free(arbre);
145:
146: return;
147: }
148:
149:
150: /*
151: * Caractères autorisés dans les instructions
152: *
153: * A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
154: * e i (mais traités comme des majuscules grâce à 'instruction_*_sensible()'
155: * + - * / % ^ < > = ? 1 2
156: */
157:
158: void
159: initialisation_instructions(struct_processus *s_etat_processus)
160: {
161: int decalage;
162: int i;
163: int longueur_tableau;
164:
165: unsigned char caractere;
166:
167: // Récupération de la longueur d'un unsigned char
168:
169: longueur_tableau = 1;
170: decalage = 0;
171: caractere = 1;
172:
173: while((1L << decalage) == (long) ((unsigned char) (caractere << decalage)))
174: {
175: decalage++;
176: longueur_tableau *= 2;
177: }
178:
179: if (((*s_etat_processus).pointeurs_caracteres =
180: malloc(longueur_tableau * sizeof(int))) == NULL)
181: {
182: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
183: return;
184: }
185:
186: for(i = 0; i < longueur_tableau; i++)
187: {
188: (*s_etat_processus).pointeurs_caracteres[i] = -1;
189: }
190:
191: (*s_etat_processus).nombre_caracteres = 0;
192:
193: #define DECLARATION_CARACTERE(c) \
194: do { (*s_etat_processus).pointeurs_caracteres[c] = \
195: (*s_etat_processus).nombre_caracteres++; } while(0)
196:
197: DECLARATION_CARACTERE('A');
198: DECLARATION_CARACTERE('B');
199: DECLARATION_CARACTERE('C');
200: DECLARATION_CARACTERE('D');
201: DECLARATION_CARACTERE('E');
202: DECLARATION_CARACTERE('F');
203: DECLARATION_CARACTERE('G');
204: DECLARATION_CARACTERE('H');
205: DECLARATION_CARACTERE('I');
206: DECLARATION_CARACTERE('J');
207: DECLARATION_CARACTERE('K');
208: DECLARATION_CARACTERE('L');
209: DECLARATION_CARACTERE('M');
210: DECLARATION_CARACTERE('N');
211: DECLARATION_CARACTERE('O');
212: DECLARATION_CARACTERE('P');
213: DECLARATION_CARACTERE('Q');
214: DECLARATION_CARACTERE('R');
215: DECLARATION_CARACTERE('S');
216: DECLARATION_CARACTERE('T');
217: DECLARATION_CARACTERE('U');
218: DECLARATION_CARACTERE('V');
219: DECLARATION_CARACTERE('W');
220: DECLARATION_CARACTERE('X');
221: DECLARATION_CARACTERE('Y');
222: DECLARATION_CARACTERE('Z');
223: DECLARATION_CARACTERE('+');
224: DECLARATION_CARACTERE('-');
225: DECLARATION_CARACTERE('/');
226: DECLARATION_CARACTERE('*');
227: DECLARATION_CARACTERE('%');
228: DECLARATION_CARACTERE('^');
229: DECLARATION_CARACTERE('<');
230: DECLARATION_CARACTERE('>');
231: DECLARATION_CARACTERE('=');
232: DECLARATION_CARACTERE('?');
233: DECLARATION_CARACTERE('1');
234: DECLARATION_CARACTERE('2');
235:
236: #undef DECLARATION_CARACTERE
237:
238: #define INSTRUCTION(chaine, fonction) \
239: creation_instruction(s_etat_processus, chaine, fonction)
240:
241: INSTRUCTION("E", instruction_sensible_e);
242: INSTRUCTION("I", instruction_sensible_i);
243: INSTRUCTION("+", instruction_plus);
244: INSTRUCTION("-", instruction_moins);
245: INSTRUCTION("*", instruction_multiplication);
246: INSTRUCTION("/", instruction_division);
247: INSTRUCTION("%", instruction_pourcent);
248: INSTRUCTION("^", instruction_puissance);
249: INSTRUCTION("<", instruction_lt);
250: INSTRUCTION("=", instruction_egalite);
251: INSTRUCTION(">", instruction_gt);
252:
253: INSTRUCTION("CF", instruction_cf);
254: INSTRUCTION("CR", instruction_cr);
255: INSTRUCTION("DO", instruction_do);
256: INSTRUCTION("FP", instruction_fp);
257: INSTRUCTION("IF", instruction_if);
258: INSTRUCTION("IM", instruction_im);
259: INSTRUCTION("IN", instruction_in);
260: INSTRUCTION("IP", instruction_ip);
261: INSTRUCTION("LN", instruction_ln);
262: INSTRUCTION("LQ", instruction_lq);
263: INSTRUCTION("LU", instruction_lu);
264: INSTRUCTION("NS", instruction_ns);
265: INSTRUCTION("OR", instruction_or);
266: INSTRUCTION("PI", instruction_pi);
267: INSTRUCTION("QR", instruction_qr);
268: INSTRUCTION("RE", instruction_re);
269: INSTRUCTION("RL", instruction_rl);
270: INSTRUCTION("RR", instruction_rr);
271: INSTRUCTION("SF", instruction_sf);
272: INSTRUCTION("SL", instruction_sl);
273: INSTRUCTION("SQ", instruction_sq);
274: INSTRUCTION("SR", instruction_sr);
275: INSTRUCTION("SX", instruction_sx);
276: INSTRUCTION("SY", instruction_sy);
277: INSTRUCTION("S+", instruction_s_plus);
278: INSTRUCTION("S-", instruction_s_moins);
279: INSTRUCTION("->", instruction_fleche);
280: INSTRUCTION("*D", instruction_star_d);
281: INSTRUCTION("*H", instruction_star_h);
282: INSTRUCTION("*S", instruction_star_s);
283: INSTRUCTION("*W", instruction_star_w);
284: INSTRUCTION("**", instruction_puissance);
285: INSTRUCTION("%T", instruction_pourcent_t);
286: INSTRUCTION("<=", instruction_le);
287: INSTRUCTION("<<", instruction_vers_niveau_superieur);
288: INSTRUCTION("<>", instruction_ne);
289: INSTRUCTION("==", instruction_same);
290: INSTRUCTION("=>", instruction_ge);
291: INSTRUCTION("=<", instruction_le);
292: INSTRUCTION(">=", instruction_ge);
293: INSTRUCTION(">>", instruction_vers_niveau_inferieur);
294:
295: INSTRUCTION("ABS", instruction_abs);
296: INSTRUCTION("AND", instruction_and);
297: //INSTRUCTION("ARC")
298: //(centre, rayon, theta1, theta2 dans le sens trigonométrique)
299: INSTRUCTION("ARG", instruction_arg);
300: INSTRUCTION("ASL", instruction_asl);
301: INSTRUCTION("ASR", instruction_asr);
302: //INSTRUCTION("BAR")
303: //Instruction HP48 (sélectionne le type de graphique à barres)
304: //Chaque point est représenté par une barre verticale.
305: INSTRUCTION("BIN", instruction_bin);
306: //INSTRUCTION("BOX")
307: //(point 1, point 2)
308: INSTRUCTION("CHR", instruction_chr);
309: INSTRUCTION("CLS", instruction_cls);
310: INSTRUCTION("CON", instruction_con);
311: INSTRUCTION("COS", instruction_cos);
312: INSTRUCTION("COV", instruction_cov);
313: INSTRUCTION("DEC", instruction_dec);
314: INSTRUCTION("DEG", instruction_deg);
315: INSTRUCTION("DER", instruction_der);
316: INSTRUCTION("DET", instruction_det);
317: INSTRUCTION("DFT", instruction_dft);
318: INSTRUCTION("DOT", instruction_dot);
319: INSTRUCTION("DUP", instruction_dup);
320: INSTRUCTION("EGV", instruction_egv);
321: INSTRUCTION("END", instruction_end);
322: INSTRUCTION("ENG", instruction_eng);
323: INSTRUCTION("EXP", instruction_exp);
324: INSTRUCTION("FC?", instruction_fc_test);
325: INSTRUCTION("FFT", instruction_fft);
326: //INSTRUCTION("FIT")
327: //Extension RPL/2 (choix de la méthode de régression, par défaut, 'LINEAR'.
328: //Les types sont
329: //'LINEAR' => y = b + mx
330: //'LOGARITHMIC' => y = b + m ln(x)
331: //'EXPONENTIAL' => y = be^(mx) ou ln(y) = ln(b) + mx
332: //'POWER' => y = bx^m ou ln(y) = ln(b) + m ln(x)
333: INSTRUCTION("FIX", instruction_fix);
334: INSTRUCTION("FOR", instruction_for);
335: INSTRUCTION("FS?", instruction_fs_test);
336: INSTRUCTION("GET", instruction_get);
337: INSTRUCTION("HEX", instruction_hex);
338: INSTRUCTION("IDN", instruction_idn);
339: INSTRUCTION("IFT", instruction_ift);
340: INSTRUCTION("INT", instruction_int);
341: INSTRUCTION("INV", instruction_inv);
342: INSTRUCTION("KEY", instruction_key);
343: INSTRUCTION("LOG", instruction_log);
344: INSTRUCTION("LSQ", instruction_lsq);
345: INSTRUCTION("MAX", instruction_max);
346: INSTRUCTION("MEM", instruction_mem);
347: INSTRUCTION("MIN", instruction_min);
348: INSTRUCTION("MOD", instruction_mod);
349: INSTRUCTION("NEG", instruction_neg);
350: INSTRUCTION("NOT", instruction_not);
351: INSTRUCTION("NUM", instruction_num);
352: INSTRUCTION("OCT", instruction_oct);
353: INSTRUCTION("POS", instruction_pos);
354: INSTRUCTION("PR1", instruction_pr1);
355: INSTRUCTION("PUT", instruction_put);
356: INSTRUCTION("RAD", instruction_rad);
357: INSTRUCTION("RCI", instruction_rci);
358: INSTRUCTION("RCL", instruction_rcl);
359: INSTRUCTION("RDM", instruction_rdm);
360: INSTRUCTION("RDZ", instruction_rdz);
361: INSTRUCTION("RES", instruction_res);
362: INSTRUCTION("RLB", instruction_rlb);
363: INSTRUCTION("RND", instruction_rnd);
364: INSTRUCTION("ROT", instruction_rot);
365: INSTRUCTION("RRB", instruction_rrb);
366: INSTRUCTION("RSD", instruction_rsd);
367: INSTRUCTION("SCI", instruction_sci);
368: INSTRUCTION("SIN", instruction_sin);
369: INSTRUCTION("SLB", instruction_slb);
370: INSTRUCTION("SRB", instruction_srb);
371: INSTRUCTION("SST", instruction_sst);
372: INSTRUCTION("STD", instruction_std);
373: INSTRUCTION("STO", instruction_sto);
374: INSTRUCTION("SVD", instruction_svd);
375: INSTRUCTION("SVL", instruction_svl);
376: INSTRUCTION("SUB", instruction_sub);
377: INSTRUCTION("SWI", instruction_swi);
378: INSTRUCTION("SX2", instruction_sx2);
379: INSTRUCTION("SXY", instruction_sxy);
380: INSTRUCTION("SY2", instruction_sy2);
381: INSTRUCTION("TAN", instruction_tan);
382: INSTRUCTION("TOT", instruction_tot);
383: INSTRUCTION("TRN", instruction_trn);
384: INSTRUCTION("USE", instruction_use);
385: INSTRUCTION("VAR", instruction_var);
386: //INSTRUCTION("V->")
387: //Instruction HP48 (éclate un vecteur [ x y ] => x y quel que soit le
388: //système de
389: //coordonnées)
390: INSTRUCTION("XOR", instruction_xor);
391: INSTRUCTION("->Q", instruction_fleche_q);
392: INSTRUCTION("%CH", instruction_pourcent_ch);
393:
394: INSTRUCTION("ACOS", instruction_acos);
395: INSTRUCTION("ALOG", instruction_alog);
396: INSTRUCTION("ASIN", instruction_asin);
397: INSTRUCTION("ATAN", instruction_atan);
398: INSTRUCTION("AXES", instruction_axes);
399: INSTRUCTION("BEEP", instruction_beep);
400: INSTRUCTION("B->R", instruction_b_vers_r);
401: INSTRUCTION("CASE", instruction_case);
402: INSTRUCTION("CEIL", instruction_ceil);
403: INSTRUCTION("CLMF", instruction_clmf);
404: INSTRUCTION("CNRM", instruction_cnrm);
405: INSTRUCTION("COLS", instruction_cols);
406: INSTRUCTION("COL+", instruction_col_plus);
407: INSTRUCTION("COL-", instruction_col_moins);
408: INSTRUCTION("COMB", instruction_comb);
409: INSTRUCTION("COND", instruction_cond);
410: INSTRUCTION("CONJ", instruction_conj);
411: INSTRUCTION("CONT", instruction_cont);
412: INSTRUCTION("COPY", instruction_copy);
413: INSTRUCTION("CORR", instruction_corr);
414: INSTRUCTION("COSH", instruction_cosh);
415: INSTRUCTION("CSWP", instruction_cswp);
416: INSTRUCTION("C->R", instruction_c_vers_r);
417: INSTRUCTION("DATE", instruction_date);
418: INSTRUCTION("DECR", instruction_decr);
419: INSTRUCTION("DISP", instruction_disp);
420: INSTRUCTION("DRAW", instruction_draw);
421: INSTRUCTION("DRAX", instruction_drax);
422: INSTRUCTION("DROP", instruction_drop);
423: INSTRUCTION("DRWS", instruction_drws);
424: INSTRUCTION("DUP2", instruction_dup2);
425: INSTRUCTION("DUPN", instruction_dupn);
426: INSTRUCTION("D->R", instruction_d_vers_r);
427: INSTRUCTION("EDIT", instruction_edit);
428: INSTRUCTION("EGVL", instruction_egvl);
429: INSTRUCTION("ELSE", instruction_else);
430: INSTRUCTION("ERRM", instruction_errm);
431: INSTRUCTION("ERRN", instruction_errn);
432: INSTRUCTION("EVAL", instruction_eval);
433: INSTRUCTION("EXIT", instruction_exit);
434: INSTRUCTION("EXPM", instruction_expm);
435: INSTRUCTION("FACT", instruction_fact);
436: INSTRUCTION("FC?C", instruction_fc_test_c);
437: INSTRUCTION("FC?S", instruction_fc_test_s);
438: //INSTRUCTION("FORM")
439: INSTRUCTION("FS?C", instruction_fs_test_c);
440: INSTRUCTION("FS?S", instruction_fs_test_s);
441: INSTRUCTION("FUSE", instruction_fuse);
442: INSTRUCTION("GEGV", instruction_gegv);
443: INSTRUCTION("GETC", instruction_getc);
444: INSTRUCTION("GETI", instruction_geti);
445: INSTRUCTION("GETR", instruction_getr);
446: INSTRUCTION("HALT", instruction_halt);
447: INSTRUCTION("HEAD", instruction_head);
448: INSTRUCTION("HELP", instruction_help);
449: INSTRUCTION("HMS+", instruction_hms_plus);
450: INSTRUCTION("HMS-", instruction_hms_moins);
451: //INSTRUCTION("HOME");
452: INSTRUCTION("IDFT", instruction_idft);
453: INSTRUCTION("IFFT", instruction_ifft);
454: INSTRUCTION("IFTE", instruction_ifte);
455: INSTRUCTION("INCR", instruction_incr);
456: //INSTRUCTION("ISOL");
457: INSTRUCTION("ISWI", instruction_iswi);
458: INSTRUCTION("KILL", instruction_kill);
459: INSTRUCTION("KIND", instruction_kind);
460: INSTRUCTION("LAST", instruction_last);
461: INSTRUCTION("LEGV", instruction_legv);
462: INSTRUCTION("LINE", instruction_line);
463: INSTRUCTION("LNP1", instruction_lnp1);
464: INSTRUCTION("LOCK", instruction_lock);
465: INSTRUCTION("MANT", instruction_mant);
466: INSTRUCTION("MARK", instruction_mark);
467: //INSTRUCTION("MAXR")
468: INSTRUCTION("MAXS", instruction_maxs);
469: INSTRUCTION("MEAN", instruction_mean);
470: //INSTRUCTION("MINR");
471: INSTRUCTION("MINS", instruction_mins); // MAXDOUBLE/MINDOUBLE
472: INSTRUCTION("NEXT", instruction_next);
473: //INSTRUCTION("NUMX");
474: //INSTRUCTION("NUMY");
475: INSTRUCTION("OPEN", instruction_open);
476: INSTRUCTION("OVER", instruction_over);
477: //INSTRUCTION("PATH");
478: INSTRUCTION("PCOV", instruction_pcov);
479: INSTRUCTION("PEEK", instruction_peek);
480: INSTRUCTION("PERM", instruction_perm);
481: INSTRUCTION("PICK", instruction_pick);
482: INSTRUCTION("PLOT", instruction_plot);
483: INSTRUCTION("PMAX", instruction_pmax);
484: INSTRUCTION("PMIN", instruction_pmin);
485: INSTRUCTION("POKE", instruction_poke);
486: INSTRUCTION("PPAR", instruction_ppar);
487: INSTRUCTION("PRMD", instruction_prmd);
488: INSTRUCTION("PRST", instruction_prst);
489: INSTRUCTION("PUTC", instruction_putc);
490: INSTRUCTION("PUTI", instruction_puti);
491: INSTRUCTION("PUTR", instruction_putr);
492: INSTRUCTION("PVAR", instruction_pvar);
493: INSTRUCTION("P->R", instruction_p_vers_r);
494: //INSTRUCTION("QUAD");
495: INSTRUCTION("RAND", instruction_rand);
496: INSTRUCTION("RANK", instruction_rank);
497: //INSTRUCTION("RANM")
498: //Instruction HP48 (crée une matrice aléatoire
499: //{ nb_lignes nb_colonnes } ou tableau quelconque dont les éléments seront
500: //modifiés pour prendre des valeurs aléatoires entre -9 et 9)
501: INSTRUCTION("RCEQ", instruction_rceq);
502: INSTRUCTION("RCIJ", instruction_rcij);
503: INSTRUCTION("RCLF", instruction_rclf);
504: INSTRUCTION("RCLS", instruction_rcls);
505: INSTRUCTION("RCWS", instruction_rcws);
506: INSTRUCTION("RDGN", instruction_rdgn);
507: INSTRUCTION("READ", instruction_read);
508: INSTRUCTION("RECV", instruction_recv);
509: INSTRUCTION("REGV", instruction_regv);
510: INSTRUCTION("REPL", instruction_repl);
511: INSTRUCTION("RNRM", instruction_rnrm);
512: INSTRUCTION("ROLL", instruction_roll);
513: //INSTRUCTION("ROOT")
514: INSTRUCTION("ROW-", instruction_row_moins);
515: INSTRUCTION("ROW+", instruction_row_plus);
516: //INSTRUCTION("RREF")
517: //Instruction HP48 (transforme [A B] en [I C] par combinaisons linéaires
518: //de lignes)
519: INSTRUCTION("RSWP", instruction_rswp);
520: INSTRUCTION("R->B", instruction_r_vers_b);
521: INSTRUCTION("R->C", instruction_r_vers_c);
522: INSTRUCTION("R->D", instruction_r_vers_d);
523: INSTRUCTION("R->P", instruction_r_vers_p);
524: INSTRUCTION("SAME", instruction_same);
525: INSTRUCTION("SAVE", instruction_save);
526: INSTRUCTION("SCLS", instruction_scls);
527: INSTRUCTION("SDEV", instruction_sdev);
528: INSTRUCTION("SEND", instruction_send);
529: //INSTRUCTION("SHOW");
530: INSTRUCTION("SIGN", instruction_sign);
531: INSTRUCTION("SINH", instruction_sinh);
532: INSTRUCTION("SINV", instruction_sinv);
533: INSTRUCTION("SIZE", instruction_size);
534: INSTRUCTION("SNEG", instruction_sneg);
535: INSTRUCTION("SORT", instruction_sort);
536: INSTRUCTION("SPAR", instruction_spar);
537: INSTRUCTION("SQRT", instruction_sqrt);
538: //INSTRUCTION("SRAD");
539: //INSTRUCTION("SRNM")
540: //Instruction HP48 (renvoie la norme spectrale d'un tableau. Pour une
541: //matrice,
542: //la norme spectrale est égale à sa plus grande valeur singulière. Pour un
543: //vecteur, la fonction est équivalente à ABS.
544: INSTRUCTION("STEP", instruction_step);
545: INSTRUCTION("STEQ", instruction_steq);
546: INSTRUCTION("STO*", instruction_sto_fois);
547: INSTRUCTION("STO+", instruction_sto_plus);
548: INSTRUCTION("STO-", instruction_sto_moins);
549: INSTRUCTION("STO/", instruction_sto_division);
550: INSTRUCTION("STOF", instruction_stof);
551: INSTRUCTION("STOP", instruction_stop);
552: INSTRUCTION("STOS", instruction_stos);
553: INSTRUCTION("STWS", instruction_stws);
554: INSTRUCTION("SWAP", instruction_swap);
555: INSTRUCTION("SYNC", instruction_sync);
556: INSTRUCTION("TAIL", instruction_tail);
557: INSTRUCTION("TANH", instruction_tanh);
558: INSTRUCTION("THEN", instruction_then);
559: INSTRUCTION("TIME", instruction_time);
560: INSTRUCTION("TRIM", instruction_trim);
561: INSTRUCTION("TRNC", instruction_trnc);
562: INSTRUCTION("TRUE", instruction_true);
563: INSTRUCTION("TYPE", instruction_type);
564: INSTRUCTION("UTPC", instruction_utpc);
565: INSTRUCTION("UTPF", instruction_utpf);
566: INSTRUCTION("UTPN", instruction_utpn);
567: INSTRUCTION("UTPT", instruction_utpt);
568: INSTRUCTION("VARS", instruction_vars);
569: INSTRUCTION("WAIT", instruction_wait);
570: INSTRUCTION("XCOL", instruction_xcol);
571: INSTRUCTION("XPON", instruction_xpon);
572: //INSTRUCTION("XRNG")
573: //INSTRUCTION("XVOL")
574: INSTRUCTION("YCOL", instruction_ycol);
575: //INSTRUCTION("YRNG")
576: //INSTRUCTION("YVOL")
577: //INSTRUCTION("ZVOL")
578: //INSTRUCTION("->V2")
579: //Instruction HP48 (combine deux réels x et y en un vecteur 2D en fonction
580: //du mode de coordonnées en cours => [ x y ] et ce quel que soit le système
581: //de coordonnées courant)
582: //INSTRUCTION("->V3")
583:
584: INSTRUCTION("ABORT", instruction_abort);
585: INSTRUCTION("ACOSH", instruction_acosh);
586: INSTRUCTION("ALARM", instruction_alarm);
587: INSTRUCTION("ASINH", instruction_asinh);
588: INSTRUCTION("ATANH", instruction_atanh);
589: //INSTRUCTION("BYTES");
590: INSTRUCTION("CENTR", instruction_centr);
591: //INSTRUCTION("CIRCL");
592: INSTRUCTION("CLEAR", instruction_clear);
593: INSTRUCTION("CLLCD", instruction_cllcd);
594: INSTRUCTION("CLOSE", instruction_close);
595: INSTRUCTION("CLUSR", instruction_clusr);
596: //INSTRUCTION("CLVAR");
597: //INSTRUCTION("COLCT")
598: INSTRUCTION("COL->", instruction_col_fleche);
599: //INSTRUCTION("CONIC")
600: //Instruction HP48 (sélectionne le type de tracé CONIC)
601: //Permet de tracer des coniques en fonction d'équations
602: //de type f(x, y) = 0.
603: //INSTRUCTION("CRDIR")
604: INSTRUCTION("CRMTX", instruction_crmtx);
605: INSTRUCTION("CROSS", instruction_cross);
606: INSTRUCTION("CRTAB", instruction_crtab);
607: INSTRUCTION("CSTOP", instruction_cstop);
608: INSTRUCTION("CYCLE", instruction_cycle);
609: //INSTRUCTION("CYLIN")
610: //Instruction HP48 (sélectionne le type de tracé CYLINDRIC)
611: INSTRUCTION("DEPND", instruction_depnd);
612: INSTRUCTION("DEPTH", instruction_depth);
613: //INSTRUCTION("DOSUB")
614: //Instruction HP48 (application séquentielle d'une fonction à une liste)
615: //liste nombre_elements_traites_a_chaque_iteration fonction DOSUB
616: //{ 1 2 3 4 5 }
617: //2
618: //<< + 2 / >>
619: //DOSUB
620: //=> { 1.5 2.5 3.5 4.5 }
621: INSTRUCTION("DGTIZ", instruction_dgtiz);
622: INSTRUCTION("DROP2", instruction_drop2);
623: INSTRUCTION("DROPN", instruction_dropn);
624: INSTRUCTION("ERASE", instruction_erase);
625: INSTRUCTION("EXGET", instruction_exget);
626: //INSTRUCTION("EXPAN");
627: INSTRUCTION("EXSUB", instruction_exsub);
628: INSTRUCTION("EYEPT", instruction_eyept);
629: INSTRUCTION("FALSE", instruction_false);
630: INSTRUCTION("FLOOR", instruction_floor);
631: INSTRUCTION("GAMMA", instruction_gamma);
632: INSTRUCTION("GEGVL", instruction_gegvl);
633: INSTRUCTION("GLEGV", instruction_glegv);
634: INSTRUCTION("GREGV", instruction_gregv);
635: INSTRUCTION("HMS->", instruction_hms_fleche);
636: INSTRUCTION("IFERR", instruction_iferr);
637: INSTRUCTION("INDEP", instruction_indep);
638: INSTRUCTION("INPUT", instruction_input);
639: INSTRUCTION("JDATE", instruction_jdate);
640: INSTRUCTION("LABEL", instruction_label);
641: INSTRUCTION("LCASE", instruction_lcase);
642: INSTRUCTION("LCHOL", instruction_lchol);
643: INSTRUCTION("LCD->", instruction_lcd_fleche);
644: //INSTRUCTION("NDIST")
645: //Instruction HP48 (distribution normale, prend la moyenne au niveau 3,
646: //la variance au niveau 2, un réel x au niveau 1 et renvoie la probabilité
647: //qu'une variable aléatoire normale soit égale à x dans une distribution
648: //normale).
649: INSTRUCTION("NRAND", instruction_nrand);
650: INSTRUCTION("OBGET", instruction_obget);
651: INSTRUCTION("OBSUB", instruction_obsub);
652: INSTRUCTION("PAPER", instruction_paper);
653: //INSTRUCTION("PCOEFF")
654: //INSTRUCTION("PEVAL")
655: //INSTRUCTION("PGDIR")
656: //INSTRUCTION("PIXEL")
657: //INSTRUCTION("PLIST")
658: //Instruction HP48 (produit des termes d'une liste)
659: INSTRUCTION("POLAR", instruction_polar);
660: INSTRUCTION("PRINT", instruction_print);
661: //INSTRUCTION("PREDV");
662: INSTRUCTION("PRLCD", instruction_prlcd);
663: //INSTRUCTION("PROOT")
664: //Instruction HP48 (calcule les racines d'un polynôme en fonction du tableau
665: //de coefficients)
666: INSTRUCTION("PRSTC", instruction_prstc);
667: INSTRUCTION("PRUSR", instruction_prusr);
668: INSTRUCTION("PRVAR", instruction_prvar);
669: INSTRUCTION("PSDEV", instruction_psdev);
670: INSTRUCTION("PURGE", instruction_purge);
671: INSTRUCTION("RDATE", instruction_rdate);
672: INSTRUCTION("RELAX", instruction_relax);
673: INSTRUCTION("RFUSE", instruction_rfuse);
674: INSTRUCTION("RSTOP", instruction_rstop);
675: INSTRUCTION("ROLLD", instruction_rolld);
676: INSTRUCTION("ROW->", instruction_row_fleche);
677: INSTRUCTION("SCALE", instruction_scale);
678: INSTRUCTION("SCHED", instruction_sched);
679: INSTRUCTION("SCHUR", instruction_schur);
680: INSTRUCTION("SCONJ", instruction_sconj);
681: INSTRUCTION("SLICE", instruction_slice);
682: //INSTRUCTION("SLIST")
683: //Instruction HP48 (somme des termes d'une liste)
684: INSTRUCTION("SPAWN", instruction_spawn);
685: INSTRUCTION("START", instruction_start);
686: INSTRUCTION("STORE", instruction_store);
687: INSTRUCTION("STR->", instruction_str_fleche);
688: INSTRUCTION("TAYLR", instruction_taylr);
689: INSTRUCTION("TITLE", instruction_title);
690: //INSTRUCTION("TRACE")
691: //INSTRUCTION("TRUTH")
692: INSTRUCTION("UCASE", instruction_ucase);
693: INSTRUCTION("UCHOL", instruction_uchol);
694: INSTRUCTION("UNTIL", instruction_until);
695: //INSTRUCTION("UPDIR")
696: INSTRUCTION("VISIT", instruction_visit);
697: INSTRUCTION("WFACK", instruction_wfack);
698: INSTRUCTION("WFSWI", instruction_wfswi);
699: INSTRUCTION("WHILE", instruction_while);
700: //INSTRUCTION("WIDTH")
701: INSTRUCTION("WRITE", instruction_write);
702: INSTRUCTION("XROOT", instruction_xroot);
703: INSTRUCTION("YIELD", instruction_yield);
704: INSTRUCTION("->COL", instruction_fleche_col);
705: INSTRUCTION("->HMS", instruction_fleche_hms);
706: INSTRUCTION("->LCD", instruction_fleche_lcd);
707: INSTRUCTION("->NUM", instruction_fleche_num);
708: INSTRUCTION("->ROW", instruction_fleche_row);
709: INSTRUCTION("->STR", instruction_fleche_str);
710:
711: INSTRUCTION("APPEND", instruction_append);
712: INSTRUCTION("ARRY->", instruction_array_fleche);
713: INSTRUCTION("ATEXIT", instruction_atexit);
714: INSTRUCTION("BESSEL", instruction_bessel);
715: INSTRUCTION("CLRERR", instruction_clrerr);
716: INSTRUCTION("CLRMTX", instruction_clrmtx);
717: INSTRUCTION("CLRSWI", instruction_clrswi);
718: INSTRUCTION("CREATE", instruction_create);
719: INSTRUCTION("DELETE", instruction_delete);
720: INSTRUCTION("DETACH", instruction_detach);
721: INSTRUCTION("DIAG->", instruction_diag_fleche);
722: //INSTRUCTION("DOLIST")
723: //Instruction HP48 (application d'une fonction à une liste)
724: //liste(s) nombre_de_listes_a_traiter fonction DOLIST
725: //{ 1 2 3 }
726: //{ 4 5 6 }
727: //{ 7 8 9 }
728: //3
729: //<< * + >>
730: //DOLIST
731: //=> { 29 42 57 }
732: INSTRUCTION("ELSEIF", instruction_elseif);
733: INSTRUCTION("FORMAT", instruction_format);
734: //INSTRUCTION("HEIGHT")
735: INSTRUCTION("ITRACE", instruction_itrace);
736: INSTRUCTION("LIST->", instruction_list_fleche);
737: INSTRUCTION("LOGGER", instruction_logger);
738: INSTRUCTION("MCLRIN", instruction_mclrin);
739: INSTRUCTION("NRPROC", instruction_nrproc);
740: INSTRUCTION("PROMPT", instruction_prompt);
741: INSTRUCTION("RCLSWI", instruction_rclswi);
742: INSTRUCTION("RECALL", instruction_recall);
743: INSTRUCTION("RECODE", instruction_recode);
744: INSTRUCTION("REDRAW", instruction_redraw);
745: INSTRUCTION("REMOVE", instruction_remove);
746: INSTRUCTION("REPEAT", instruction_repeat);
747: INSTRUCTION("RETURN", instruction_return);
748: INSTRUCTION("REWIND", instruction_rewind);
749: //INSTRUCTION("SCREEN")
750: INSTRUCTION("SELECT", instruction_select);
751: //INSTRUCTION("SPHERE")
752: INSTRUCTION("SHARED", instruction_shared);
753: INSTRUCTION("SPLASH", instruction_splash);
754: INSTRUCTION("STATIC", instruction_static);
755: INSTRUCTION("STOSWI", instruction_stoswi);
756: //INSTRUCTION("STREAM", instruction_stream);
757: //{ 1 2 3 4 5 } << * >> STREAM => 120
758: INSTRUCTION("TARGET", instruction_target);
759: INSTRUCTION("UNLOCK", instruction_unlock);
760: INSTRUCTION("VERIFY", instruction_verify);
761: INSTRUCTION("WFDATA", instruction_wfdata);
762: INSTRUCTION("WFLOCK", instruction_wflock);
763: INSTRUCTION("WFPOKE", instruction_wfpoke);
764: INSTRUCTION("WFPROC", instruction_wfproc);
765: INSTRUCTION("WFSOCK", instruction_wfsock);
766: INSTRUCTION("->ARRY", instruction_fleche_array);
767: INSTRUCTION("->DIAG", instruction_fleche_diag);
768: INSTRUCTION("->LIST", instruction_fleche_list);
769:
770: INSTRUCTION("ARRAY->", instruction_array_fleche);
771: //INSTRUCTION("BARPLOT")
772: //INSTRUCTION("BESTFIT")
773: //Instruction HP48 (choisit le meilleur modèle de régression)
774: INSTRUCTION("CLRFUSE", instruction_clrfuse);
775: INSTRUCTION("CONVERT", instruction_convert);
776: INSTRUCTION("CRSMPHR", instruction_crsmphr);
777: INSTRUCTION("CURRENC", instruction_currenc);
778: INSTRUCTION("DEFAULT", instruction_default);
779: INSTRUCTION("EPSILON", instruction_epsilon);
780: //INSTRUCTION("GRIDMAP")
781: //Instruction HP48 (sélectionne le mode de tracé GRIDMAP)
782: //Le tracé GRIDMAP transforme la grille d'échantillonnage rectiligne
783: //en appliquant la fonction en cours à valeurs complexes.
784: //Les coordonnées de chaque point de la grille (un nombre complexe)
785: //constituent
786: //les données d'entrée de la fonction qui les projette ensuite dans le
787: //grille
788: //de sortie.
789: //f(x,y)=fnct complexe évaluée sur la grille (x,y) et affichée comme une
790: //fonction paramétrique.
791: INSTRUCTION("INQUIRE", instruction_inquire);
792: INSTRUCTION("MTXLOCK", instruction_mtxlock);
793: INSTRUCTION("PERSIST", instruction_persist);
794: INSTRUCTION("PLOTTER", instruction_plotter);
795: INSTRUCTION("PRIVATE", instruction_private);
796: INSTRUCTION("PROTECT", instruction_protect);
797: INSTRUCTION("PSHPRFL", instruction_pshprfl);
798: INSTRUCTION("PULPRFL", instruction_pulprfl);
799: INSTRUCTION("REVLIST", instruction_revlist);
800: INSTRUCTION("SCATTER", instruction_scatter);
801: INSTRUCTION("SUSPEND", instruction_suspend);
802: INSTRUCTION("SWILOCK", instruction_swilock);
803: INSTRUCTION("SYSEVAL", instruction_syseval);
804: INSTRUCTION("TABLE->", instruction_table_fleche);
805: INSTRUCTION("VERSION", instruction_version);
806: INSTRUCTION("WORKDIR", instruction_workdir);
807: INSTRUCTION("->ARRAY", instruction_fleche_array);
808: INSTRUCTION("->TABLE", instruction_fleche_table);
809:
810: INSTRUCTION("CLRCNTXT", instruction_clrcntxt);
811: INSTRUCTION("CLRSMPHR", instruction_clrsmphr);
812: INSTRUCTION("CONTINUE", instruction_continue);
813: INSTRUCTION("DUPCNTXT", instruction_dupcntxt);
814: INSTRUCTION("FUNCTION", instruction_function);
815: INSTRUCTION("IMPLICIT", instruction_implicit);
816: INSTRUCTION("KEYLABEL", instruction_keylabel);
817: INSTRUCTION("KEYTITLE", instruction_keytitle);
818: INSTRUCTION("LOGSCALE", instruction_logscale);
819: INSTRUCTION("NEWPLANE", instruction_newplane);
820: INSTRUCTION("PSHCNTXT", instruction_pshcntxt);
821: INSTRUCTION("PULCNTXT", instruction_pulcntxt);
822: INSTRUCTION("SQLQUERY", instruction_sqlquery);
823: INSTRUCTION("SWIQUEUE", instruction_swiqueue);
824: INSTRUCTION("TOKENIZE", instruction_tokenize);
825: INSTRUCTION("VARIABLE", instruction_variable);
826: INSTRUCTION("VOLATILE", instruction_volatile);
827: INSTRUCTION("WARRANTY", instruction_warranty);
828:
829: INSTRUCTION("AUTOSCALE", instruction_autoscale);
830: INSTRUCTION("BACKSPACE", instruction_backspace);
831: INSTRUCTION("CLRATEXIT", instruction_clratexit);
832: INSTRUCTION("COPYRIGHT", instruction_copyright);
833: //INSTRUCTION("CYLINDRIC");
834: INSTRUCTION("DAEMONIZE", instruction_daemonize);
835: INSTRUCTION("DROPCNTXT", instruction_dropcntxt);
836: INSTRUCTION("EXTERNALS", instruction_externals);
837: INSTRUCTION("HISTOGRAM", instruction_histogram);
838: INSTRUCTION("MTXSTATUS", instruction_mtxstatus);
839: INSTRUCTION("MTXUNLOCK", instruction_mtxunlock);
840: INSTRUCTION("PARAMETER", instruction_parameter);
841: //INSTRUCTION("PSCONTOUR")
842: //INSTRUCTION("SCATRPLOT")
843: //(trace un nuage de points de SDAT et la courbe de régression)
844: INSTRUCTION("SMPHRDECR", instruction_smphrdecr);
845: INSTRUCTION("SMPHRGETV", instruction_smphrgetv);
846: INSTRUCTION("SMPHRINCR", instruction_smphrincr);
847: INSTRUCTION("SWAPCNTXT", instruction_swapcntxt);
848: INSTRUCTION("SWISTATUS", instruction_swistatus);
849: INSTRUCTION("SWIUNLOCK", instruction_swiunlock);
850: INSTRUCTION("UNPROTECT", instruction_unprotect);
851: INSTRUCTION("WIREFRAME", instruction_wireframe);
852:
853: INSTRUCTION("MTXTRYLOCK", instruction_mtxtrylock);
854: INSTRUCTION("PARAMETRIC", instruction_parametric);
855: //INSTRUCTION("PARSURFACE")
856: //Instruction HP48 (tracé PARSURFACE) Equation sous forme de liste
857: INSTRUCTION("SLICESCALE", instruction_slicescale);
858: INSTRUCTION("SQLCONNECT", instruction_sqlconnect);
859: //INSTRUCTION("SLOPEFIELD")
860: //Instruction HP48 (type de tracé)
861: //Tracé 3D en courbes de niveaux.
862: //Le type de tracé 'SLOPEFIELD' dessine un réseau de segments dont les
863: //pentes
864: //représentent la valeur de la fonction (x,y) en leur milieu.
865: //=> utile pour y'=F(x,y)
866:
867: INSTRUCTION("LOCALIZATION", instruction_localization);
868: INSTRUCTION("SMPHRTRYDECR", instruction_smphrtrydecr);
869:
870: INSTRUCTION("SQLDISCONNECT", instruction_sqldisconnect);
871: #undef INSTRUCTION
872:
873: return;
874: }
875:
876:
877: inline void *
878: analyse_instruction(struct_processus *s_etat_processus, unsigned char *ptr)
879: {
880: int pointeur;
881:
882: struct_instruction *l_instruction_courante;
883:
884: l_instruction_courante = (*s_etat_processus).arbre_instructions;
885:
886: while((*ptr) != d_code_fin_chaine)
887: {
888: pointeur = (*s_etat_processus).pointeurs_caracteres[*ptr];
889:
890: if (pointeur < 0)
891: {
892: // Caractère hors de l'alphabet des instructions
893:
894: return(NULL);
895: }
896:
897: if ((*l_instruction_courante).noeud[pointeur] == NULL)
898: {
899: // Le chemin de l'instruction candidate n'existe pas.
900:
901: return(NULL);
902: }
903:
904: l_instruction_courante = (*l_instruction_courante).noeud[pointeur];
905: ptr++;
906:
907: if ((l_instruction_courante == NULL) && ((*ptr) != d_code_fin_chaine))
908: {
909: // Le chemin de l'instruction candidate est incomplet.
910:
911: return(NULL);
912: }
913: }
914:
915: if ((*l_instruction_courante).feuille != NULL)
916: {
917: return((*l_instruction_courante).feuille);
918: }
919:
920: return(NULL);
921: }
922:
923:
924: void
925: analyse(struct_processus *s_etat_processus, void (*fonction)())
926: {
927: static logical1 initialisation = d_faux;
928:
929: real8 attente;
930: real8 pourcentage;
931: real8 temps_cpu;
932: real8 temps_reel;
933:
934: static struct timeval horodatage_initial;
935: struct timeval horodatage_final;
936:
937: static struct rusage usage_initial;
938: struct rusage usage_final;
939:
940: struct timespec temporisation;
941:
942: unsigned char *position;
943: unsigned char *bibliotheque_candidate;
944: unsigned char *instruction_majuscule;
945: unsigned char registre_instruction_valide;
946:
947: void (*instruction)();
948:
949: errno = 0;
950: (*s_etat_processus).var_volatile_exception_gsl = 0;
951:
952: (*s_etat_processus).instruction_valide = 'Y';
953: (*s_etat_processus).constante_symbolique = 'N';
954: (*s_etat_processus).nombre_arguments = -2;
955: (*s_etat_processus).instruction_intrinseque = 'I';
956:
957: /*
958: * On autorise l'exécution d'un fork() dans un thread concurrent.
959: */
960:
961: # ifndef SEMAPHORES_NOMMES
962: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
963: {
964: (*s_etat_processus).erreur_systeme = d_es_processus;
965: return;
966: }
967:
968: while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
969: {
970: if (errno != EINTR)
971: {
972: (*s_etat_processus).erreur_systeme = d_es_processus;
973: return;
974: }
975: }
976: # else
977: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
978: {
979: (*s_etat_processus).erreur_systeme = d_es_processus;
980: return;
981: }
982:
983: while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
984: {
985: if (errno != EINTR)
986: {
987: (*s_etat_processus).erreur_systeme = d_es_processus;
988: return;
989: }
990: }
991: # endif
992:
993: scrutation_injection(s_etat_processus);
994:
995: if (fonction == NULL)
996: {
997: if ((instruction_majuscule = conversion_majuscule(
998: (*s_etat_processus).instruction_courante)) == NULL)
999: {
1000: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1001: return;
1002: }
1003:
1004: instruction = analyse_instruction(s_etat_processus,
1005: instruction_majuscule);
1006:
1007: if (instruction == NULL)
1008: {
1009: // L'instruction n'existe pas.
1010:
1011: (*s_etat_processus).instruction_valide = 'N';
1012: }
1013: else
1014: {
1015: // Exécution de l'instruction associée. Le drapeau
1016: // (*s_etat_processus).instruction_valide peut passer à 'N'
1017: // dans le cas d'instructions sensibles à la casse.
1018:
1019: if ((*s_etat_processus).niveau_profilage >= 2)
1020: {
1021: profilage(s_etat_processus, instruction_majuscule);
1022: }
1023:
1024: (*s_etat_processus).instruction_valide = 'Y';
1025: instruction(s_etat_processus);
1026:
1027: if ((*s_etat_processus).niveau_profilage >= 2)
1028: {
1029: profilage(s_etat_processus, NULL);
1030: }
1031: }
1032:
1033: free(instruction_majuscule);
1034: }
1035: else
1036: {
1037: if ((*s_etat_processus).niveau_profilage >= 2)
1038: {
1039: profilage(s_etat_processus,
1040: (*s_etat_processus).instruction_courante);
1041: }
1042:
1043: (*s_etat_processus).instruction_valide = 'Y';
1044: fonction(s_etat_processus);
1045:
1046: if ((*s_etat_processus).niveau_profilage >= 2)
1047: {
1048: profilage(s_etat_processus, NULL);
1049: }
1050: }
1051:
1052: if ((*s_etat_processus).instruction_valide == 'Y')
1053: {
1054: (*s_etat_processus).instruction_intrinseque = 'Y';
1055: }
1056:
1057: if ((*s_etat_processus).instruction_valide == 'N')
1058: {
1059: if ((position = index((*s_etat_processus).instruction_courante, '$'))
1060: != NULL)
1061: {
1062: if ((bibliotheque_candidate = malloc((position + 1
1063: - (*s_etat_processus).instruction_courante)
1064: * sizeof(unsigned char))) == NULL)
1065: {
1066: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1067: return;
1068: }
1069:
1070: (*bibliotheque_candidate) = d_code_fin_chaine;
1071: strncat(bibliotheque_candidate,
1072: (*s_etat_processus).instruction_courante,
1073: position - (*s_etat_processus).instruction_courante);
1074:
1075: position++;
1076:
1077: if (execution_fonction_de_bibliotheque(s_etat_processus, position,
1078: bibliotheque_candidate) == d_vrai)
1079: {
1080: (*s_etat_processus).instruction_valide = 'Y';
1081: (*s_etat_processus).instruction_intrinseque = 'N';
1082: }
1083: else
1084: {
1085: (*s_etat_processus).instruction_valide = 'N';
1086: }
1087:
1088: free(bibliotheque_candidate);
1089: }
1090: else
1091: {
1092: if (execution_fonction_de_bibliotheque(s_etat_processus,
1093: (*s_etat_processus).instruction_courante, NULL)
1094: == d_vrai)
1095: {
1096: (*s_etat_processus).instruction_valide = 'Y';
1097: (*s_etat_processus).instruction_intrinseque = 'N';
1098: }
1099: else
1100: {
1101: (*s_etat_processus).instruction_valide = 'N';
1102: }
1103: }
1104: }
1105:
1106: /*
1107: --------------------------------------------------------------------------------
1108: Gestion des interruptions logicielles
1109: --------------------------------------------------------------------------------
1110: */
1111:
1112: if (((*s_etat_processus).erreur_systeme == d_es) &&
1113: ((*s_etat_processus).erreur_execution == d_ex) &&
1114: ((*s_etat_processus).exception == d_ep))
1115: {
1116: if ((*s_etat_processus).test_instruction == 'N')
1117: {
1118: if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
1119: {
1120: affectation_interruptions_logicielles(s_etat_processus);
1121: }
1122:
1123: if (((*s_etat_processus).nombre_interruptions_en_queue != 0) &&
1124: ((*s_etat_processus).erreur_systeme == d_es) &&
1125: ((*s_etat_processus).erreur_execution == d_ex))
1126: {
1127:
1128: registre_instruction_valide =
1129: (*s_etat_processus).instruction_valide;
1130: traitement_interruptions_logicielles(s_etat_processus);
1131: (*s_etat_processus).instruction_valide =
1132: registre_instruction_valide;
1133: }
1134: }
1135: }
1136:
1137: /*
1138: --------------------------------------------------------------------------------
1139: Limitation du pourcetage de temps CPU
1140: --------------------------------------------------------------------------------
1141: */
1142:
1143: if ((*s_etat_processus).pourcentage_maximal_cpu < 100)
1144: {
1145: getrusage(RUSAGE_SELF, &usage_final);
1146: gettimeofday(&horodatage_final, NULL);
1147:
1148: if (initialisation == d_vrai)
1149: {
1150: temps_reel = ((real8) (horodatage_final.tv_sec -
1151: horodatage_initial.tv_sec)) +
1152: (((real8) (horodatage_final.tv_usec -
1153: horodatage_initial.tv_usec)) / ((real8) 1E6));
1154:
1155: if (temps_reel >= 0.1)
1156: {
1157: temps_cpu = ((real8) ((usage_final.ru_utime.tv_sec +
1158: usage_final.ru_stime.tv_sec) -
1159: (usage_initial.ru_utime.tv_sec +
1160: usage_initial.ru_stime.tv_sec))) +
1161: (((real8) ((usage_final.ru_utime.tv_usec +
1162: usage_final.ru_stime.tv_usec) -
1163: (usage_initial.ru_utime.tv_usec +
1164: usage_initial.ru_stime.tv_usec))) / ((real8) 1E6));
1165:
1166: pourcentage = 100 * temps_cpu / temps_reel;
1167:
1168: if (pourcentage > 100)
1169: {
1170: pourcentage = 100;
1171: }
1172:
1173: if (pourcentage > (*s_etat_processus).pourcentage_maximal_cpu)
1174: {
1175: attente = ((pourcentage * temps_cpu) /
1176: (*s_etat_processus).pourcentage_maximal_cpu)
1177: - (pourcentage * temps_cpu / 100);
1178:
1179: temporisation.tv_sec = floor(attente);
1180: temporisation.tv_nsec = (attente - temporisation.tv_sec) *
1181: 1E9;
1182:
1183: nanosleep(&temporisation, NULL);
1184: }
1185:
1186: horodatage_initial = horodatage_final;
1187: usage_initial = usage_final;
1188: }
1189: }
1190: else
1191: {
1192: initialisation = d_vrai;
1193:
1194: horodatage_initial = horodatage_final;
1195: usage_initial = usage_final;
1196: }
1197: }
1198:
1199: /*
1200: --------------------------------------------------------------------------------
1201: Introduction des erreurs générées
1202: --------------------------------------------------------------------------------
1203: */
1204:
1205: if (((*s_etat_processus).test_instruction == 'N') &&
1206: ((*s_etat_processus).instruction_valide == 'Y'))
1207: {
1208: traitement_asynchrone_exceptions_gsl(s_etat_processus);
1209:
1210: if ((*s_etat_processus).erreur_processus_fils == d_vrai)
1211: {
1212: (*s_etat_processus).erreur_processus_fils = d_faux;
1213:
1214: (*s_etat_processus).erreur_systeme =
1215: (*s_etat_processus).erreur_systeme_processus_fils;
1216: (*s_etat_processus).erreur_execution =
1217: (*s_etat_processus).erreur_execution_processus_fils;
1218: (*s_etat_processus).arret_si_exception = d_vrai;
1219:
1220: if ((*s_etat_processus).pid_erreur_processus_fils == getpid())
1221: {
1222: (*s_etat_processus).invalidation_message_erreur = d_faux;
1223: }
1224: else
1225: {
1226: (*s_etat_processus).invalidation_message_erreur = d_vrai;
1227: }
1228: }
1229:
1230: if (((*s_etat_processus).erreur_execution != d_ex) ||
1231: ((*s_etat_processus).erreur_systeme != d_es) ||
1232: ((*s_etat_processus).exception != d_ep))
1233: {
1234: if ((*s_etat_processus).instruction_derniere_erreur != NULL)
1235: {
1236: free((*s_etat_processus).instruction_derniere_erreur);
1237: (*s_etat_processus).instruction_derniere_erreur = NULL;
1238: }
1239:
1240: (*s_etat_processus).niveau_derniere_erreur =
1241: (*s_etat_processus).niveau_courant;
1242:
1243: if ((*s_etat_processus).mode_execution_programme == 'Y')
1244: {
1245: if ((*s_etat_processus).instruction_courante == NULL)
1246: {
1247: if (((*s_etat_processus).instruction_derniere_erreur =
1248: malloc(16 * sizeof(unsigned char))) == NULL)
1249: {
1250: (*s_etat_processus).erreur_systeme =
1251: d_es_allocation_memoire;
1252: return;
1253: }
1254:
1255: strcpy((*s_etat_processus).instruction_derniere_erreur,
1256: "<not available>");
1257: }
1258: else
1259: {
1260: if (((*s_etat_processus).instruction_derniere_erreur =
1261: malloc((strlen((*s_etat_processus)
1262: .instruction_courante) + 1) *
1263: sizeof(unsigned char))) == NULL)
1264: {
1265: (*s_etat_processus).erreur_systeme =
1266: d_es_allocation_memoire;
1267: return;
1268: }
1269:
1270: strcpy((*s_etat_processus).instruction_derniere_erreur,
1271: (*s_etat_processus).instruction_courante);
1272: }
1273: }
1274: else
1275: {
1276: if (((*s_etat_processus).instruction_derniere_erreur =
1277: formateur(s_etat_processus, 0,
1278: (*s_etat_processus).objet_courant)) == NULL)
1279: {
1280: return;
1281: }
1282: }
1283: }
1284: }
1285:
1286: return;
1287: }
1288:
1289:
1290: /*
1291: ================================================================================
1292: Traitement asynchrone des erreurs de la bibliothèque GSL
1293: ================================================================================
1294: Entrées :
1295: --------------------------------------------------------------------------------
1296: Sorties :
1297: --------------------------------------------------------------------------------
1298: Effets de bord : néant
1299: ================================================================================
1300: */
1301:
1302: void
1303: traitement_asynchrone_exceptions_gsl(struct_processus *s_etat_processus)
1304: {
1305: if ((*s_etat_processus).var_volatile_exception_gsl != 0)
1306: {
1307: switch((*s_etat_processus).var_volatile_exception_gsl)
1308: {
1309: case GSL_EINVAL :
1310: {
1311: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
1312: break;
1313: }
1314:
1315: case GSL_EDOM :
1316: {
1317: (*s_etat_processus).exception = d_ep_domaine_definition;
1318: break;
1319: }
1320:
1321: case GSL_ERANGE :
1322: {
1323: (*s_etat_processus).exception = d_ep_resultat_indefini;
1324: break;
1325: }
1326:
1327: case GSL_EZERODIV :
1328: {
1329: (*s_etat_processus).exception = d_ep_division_par_zero;
1330: break;
1331: }
1332:
1333: case GSL_EUNDRFLW :
1334: {
1335: (*s_etat_processus).exception = d_ep_underflow;
1336: break;
1337: }
1338:
1339: case GSL_EOVRFLW :
1340: {
1341: (*s_etat_processus).exception = d_ep_overflow;
1342: break;
1343: }
1344:
1345: case GSL_ENOMEM :
1346: {
1347: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1348: break;
1349: }
1350:
1351: case GSL_ELOSS :
1352: {
1353: (*s_etat_processus).exception = d_ep_perte_precision;
1354: break;
1355: }
1356:
1357: default :
1358: {
1359: (*s_etat_processus).erreur_execution =
1360: d_ex_routines_mathematiques;
1361: break;
1362: }
1363: }
1364:
1365: (*s_etat_processus).var_volatile_exception_gsl = 0;
1366: }
1367:
1368: return;
1369: }
1370:
1371: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>