1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.36
4: Copyright (C) 1989-2025 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: Fonction 'num'
29: ================================================================================
30: Entrées : structure processus
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_num(struct_processus *s_etat_processus)
40: {
41: integer8 longueur;
42:
43: struct_objet *s_objet_argument;
44: struct_objet *s_objet_resultat;
45:
46: unsigned char *chaine;
47:
48: (*s_etat_processus).erreur_execution = d_ex;
49:
50: if ((*s_etat_processus).affichage_arguments == 'Y')
51: {
52: printf("\n NUM ");
53:
54: if ((*s_etat_processus).langue == 'F')
55: {
56: printf("(conversion d'un caractère en entier)\n\n");
57: }
58: else
59: {
60: printf("(character to integer conversion)\n\n");
61: }
62:
63: printf(" 1: %s\n", d_CHN);
64: printf("-> 1: 0 <= %s <= 255\n", d_INT);
65:
66: return;
67: }
68: else if ((*s_etat_processus).test_instruction == 'Y')
69: {
70: (*s_etat_processus).nombre_arguments = -1;
71: return;
72: }
73:
74: if (test_cfsf(s_etat_processus, 31) == d_vrai)
75: {
76: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
77: {
78: return;
79: }
80: }
81:
82: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
83: &s_objet_argument) == d_erreur)
84: {
85: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
86: return;
87: }
88:
89: /*
90: --------------------------------------------------------------------------------
91: Chaîne de caractères
92: --------------------------------------------------------------------------------
93: */
94:
95: if ((*s_objet_argument).type == CHN)
96: {
97: if (longueur_chaine(s_etat_processus, (unsigned char *)
98: (*s_objet_argument).objet) != 1)
99: {
100: liberation(s_etat_processus, s_objet_argument);
101:
102: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
103: return;
104: }
105:
106: if ((chaine = formateur_flux(s_etat_processus, (unsigned char *)
107: (*s_objet_argument).objet, &longueur)) == NULL)
108: {
109: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
110: return;
111: }
112:
113: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
114: {
115: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
116: return;
117: }
118:
119: (*((integer8 *) (*s_objet_resultat).objet)) = chaine[0];
120: free(chaine);
121: }
122:
123: /*
124: --------------------------------------------------------------------------------
125: Type invalide
126: --------------------------------------------------------------------------------
127: */
128:
129: else
130: {
131: liberation(s_etat_processus, s_objet_argument);
132:
133: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
134: return;
135: }
136:
137: liberation(s_etat_processus, s_objet_argument);
138:
139: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
140: s_objet_resultat) == d_erreur)
141: {
142: return;
143: }
144:
145: return;
146: }
147:
148:
149: /*
150: ================================================================================
151: Fonction 'ns'
152: ================================================================================
153: Entrées : structure processus
154: --------------------------------------------------------------------------------
155: Sorties :
156: --------------------------------------------------------------------------------
157: Effets de bord : néant
158: ================================================================================
159: */
160:
161: void
162: instruction_ns(struct_processus *s_etat_processus)
163: {
164: struct_objet *s_objet_resultat;
165:
166: (*s_etat_processus).erreur_execution = d_ex;
167:
168: if ((*s_etat_processus).affichage_arguments == 'Y')
169: {
170: printf("\n NS ");
171:
172: if ((*s_etat_processus).langue == 'F')
173: {
174: printf("(nombre de données dans la matrice statistique\n\n");
175: }
176: else
177: {
178: printf("(number of data elements in statistical matrix)\n\n");
179: }
180:
181: printf("-> 1: %s\n", d_INT);
182:
183: return;
184: }
185: else if ((*s_etat_processus).test_instruction == 'Y')
186: {
187: (*s_etat_processus).nombre_arguments = -1;
188: return;
189: }
190:
191: if (test_cfsf(s_etat_processus, 31) == d_vrai)
192: {
193: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
194: {
195: return;
196: }
197: }
198:
199: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
200: {
201: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
202: return;
203: }
204:
205: if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux)
206: {
207: /*
208: * Aucune variable SIGMA
209: */
210:
211: (*s_etat_processus).erreur_systeme = d_es;
212: (*s_etat_processus).erreur_execution = d_ex;
213:
214: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
215: }
216: else
217: {
218: if (((*(*(*s_etat_processus).pointeur_variable_courante).objet)
219: .type != MIN) && ((*(*(*s_etat_processus)
220: .pointeur_variable_courante).objet).type != MRL))
221: {
222: liberation(s_etat_processus, s_objet_resultat);
223:
224: (*s_etat_processus).erreur_execution =
225: d_ex_matrice_statistique_invalide;
226: return;
227: }
228:
229: (*((integer8 *) (*s_objet_resultat).objet)) =
230: (*((struct_matrice *) (*(*(*s_etat_processus)
231: .pointeur_variable_courante).objet).objet)).nombre_lignes;
232: }
233:
234: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
235: s_objet_resultat) == d_erreur)
236: {
237: return;
238: }
239:
240: return;
241: }
242:
243:
244: /*
245: ================================================================================
246: Fonction 'newplane'
247: ================================================================================
248: Entrées : structure processus
249: --------------------------------------------------------------------------------
250: Sorties :
251: --------------------------------------------------------------------------------
252: Effets de bord : néant
253: ================================================================================
254: */
255:
256: void
257: instruction_newplane(struct_processus *s_etat_processus)
258: {
259: (*s_etat_processus).erreur_execution = d_ex;
260:
261: if ((*s_etat_processus).affichage_arguments == 'Y')
262: {
263: printf("\n NEWPLANE ");
264:
265: if ((*s_etat_processus).langue == 'F')
266: {
267: printf("(nouveau plan graphique)\n\n");
268: printf(" Aucun argument\n");
269: }
270: else
271: {
272: printf("(new graphic plane)\n\n");
273: printf(" No argument\n");
274: }
275:
276: return;
277: }
278: else if ((*s_etat_processus).test_instruction == 'Y')
279: {
280: (*s_etat_processus).nombre_arguments = -1;
281: return;
282: }
283:
284: if (test_cfsf(s_etat_processus, 31) == d_vrai)
285: {
286: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
287: {
288: return;
289: }
290: }
291:
292: (*s_etat_processus).requete_nouveau_plan = d_vrai;
293:
294: return;
295: }
296:
297:
298: /*
299: ================================================================================
300: Fonction 'nrproc'
301: ================================================================================
302: Entrées : structure processus
303: --------------------------------------------------------------------------------
304: Sorties :
305: --------------------------------------------------------------------------------
306: Effets de bord : néant
307: ================================================================================
308: */
309:
310: void
311: instruction_nrproc(struct_processus *s_etat_processus)
312: {
313: (*s_etat_processus).erreur_execution = d_ex;
314:
315: if ((*s_etat_processus).affichage_arguments == 'Y')
316: {
317: printf("\n NRPROC ");
318:
319: if ((*s_etat_processus).langue == 'F')
320: {
321: printf("(nouvelle racine des processus)\n\n");
322: printf(" Aucun argument\n");
323: }
324: else
325: {
326: printf("(new root process)\n\n");
327: printf(" No argument\n");
328: }
329:
330: return;
331: }
332: else if ((*s_etat_processus).test_instruction == 'Y')
333: {
334: (*s_etat_processus).nombre_arguments = -1;
335: return;
336: }
337:
338: if (test_cfsf(s_etat_processus, 31) == d_vrai)
339: {
340: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
341: {
342: return;
343: }
344: }
345:
346: (*s_etat_processus).var_volatile_processus_pere = -1;
347: (*s_etat_processus).pid_processus_pere = getpid();
348: (*s_etat_processus).tid_processus_pere = pthread_self();
349:
350: return;
351: }
352:
353:
354: /*
355: ================================================================================
356: Fonction 'nbrcpus'
357: ================================================================================
358: Entrées : structure processus
359: --------------------------------------------------------------------------------
360: Sorties :
361: --------------------------------------------------------------------------------
362: Effets de bord : néant
363: ================================================================================
364: */
365:
366: void
367: instruction_nbrcpus(struct_processus *s_etat_processus)
368: {
369: struct_objet *s_objet_resultat;
370:
371: (*s_etat_processus).erreur_execution = d_ex;
372:
373: if ((*s_etat_processus).affichage_arguments == 'Y')
374: {
375: printf("\n NBRCPUS ");
376:
377: if ((*s_etat_processus).langue == 'F')
378: {
379: printf("(nombre de processeurs sur le système)\n\n");
380: printf("-> 1: %s\n", d_INT);
381: }
382: else
383: {
384: printf("(number of processors on system)\n\n");
385: printf("-> 1: %s\n", d_INT);
386: }
387:
388: return;
389: }
390: else if ((*s_etat_processus).test_instruction == 'Y')
391: {
392: (*s_etat_processus).nombre_arguments = -1;
393: return;
394: }
395:
396: if (test_cfsf(s_etat_processus, 31) == d_vrai)
397: {
398: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
399: {
400: return;
401: }
402: }
403:
404: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
405: {
406: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
407: return;
408: }
409:
410: (*((integer8 *) (*s_objet_resultat).objet)) = sysconf(_SC_NPROCESSORS_ONLN);
411:
412: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
413: s_objet_resultat) == d_erreur)
414: {
415: return;
416: }
417:
418: return;
419: }
420:
421: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>