1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.27
4: Copyright (C) 1989-2017 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: #ifndef INCLUSION_RPLARGS
24: # define INCLUSION_RPLARGS
25:
26: /*
27: ================================================================================
28: INCLUSIONS
29: ================================================================================
30: */
31:
32: // Si TYPE_DECLARATION est défini, toutes les structures internes du RPL/2
33: // sont exposés pour travailler sur des nouveaux types de données.
34: # ifndef TYPE_DECLARATION
35: # define RPLARGS
36: # define struct_processus void
37: # endif
38:
39: # include "rpl.h"
40:
41: /*
42: ================================================================================
43: MACROS SPECIFIQUES
44: ================================================================================
45: */
46:
47: #define __RPL__ struct_rpl_arguments *rpl_arguments; \
48: rpl_arguments = &__static_rpl_arguments;
49:
50: #define __CATCH_SYSTEM_ERROR__ \
51: do { if (((*rpl_arguments).erreur != 0) && \
52: ((*rpl_arguments).type_erreur == 'S')) \
53: return 0; } while(0)
54: #define leave do { return(0); } while(0)
55: #define _allocation(a) librpl_allocation((*rpl_arguments).s_etat_processus, a)
56: #define _copie_objet(a, b) librpl_copie_objet( \
57: (*rpl_arguments).s_etat_processus, a, b)
58: #define _liberation(a) librpl_liberation((*rpl_arguments).s_etat_processus, a)
59:
60: #ifdef __RPLC_MAIN
61: struct_rpl_arguments __static_rpl_arguments;
62: # define global
63: # define initialize(a, b) a = b
64: # define declarePersistantObject(rpl_object) declareObject(rpl_object)
65: #else
66: extern struct_rpl_arguments __static_rpl_arguments;
67: # define global extern
68: # define initialize(a, b) a;
69: # define declarePersistantObject(rpl_object) extern struct_objet *rpl_object
70: #endif
71:
72: #define empty int
73:
74: /*
75: --------------------------------------------------------------------------------
76: Gestion des objets
77: --------------------------------------------------------------------------------
78: */
79:
80: // new, dup, drop, disp, parse
81: // __type_new(struct_rpl_arguments *rpl_arguments)
82: #define declareTypeExtension(fct) \
83: int __type_##fct(struct_processus *s_etat_processus, void **arg) { \
84: char *rptr, *ptr, *iptr; \
85: rptr = (char *) ((*s_etat_processus).definitions_chainees + \
86: (*s_etat_processus).position_courante); \
87: ptr = rptr; \
88: iptr = (char *) (*s_etat_processus).instruction_courante; \
89: if ((ptr != rptr) && (iptr)) goto __parse_error;
90: #define parseError { goto __parse_error; } while(0)
91: #define typeError { return(0); } while(0)
92: #define typeFound(a) { return(a); } while(0)
93: #define endTypeExtension __parse_error: return(0); }
94: #define sizeOfParse (rptr - ptr)
95: #define searchType { recherche_type(s_etat_processus); \
96: if (((*s_etat_processus).erreur_execution != d_ex) || \
97: ((*s_etat_processus).erreur_systeme != d_es)) \
98: return(0); } while(0)
99:
100: /*
101: --------------------------------------------------------------------------------
102: Types
103: --------------------------------------------------------------------------------
104: */
105:
106: #define declareObject(rpl_object) struct_objet *rpl_object = NULL
107: #define declareInteger(integer) integer8 integer
108: #define declareReal(real) real8 real
109: #define declareComplex(complex) complex16 complex
110: #define declareDaisyChain(daisyChain) struct_liste_chainee *daisyChain = NULL
111:
112: #define getDaisyChainFromList(list, daisyChain) \
113: __CATCH_SYSTEM_ERROR__; \
114: do { \
115: typeof(list) __list = list; \
116: daisyChain = NULL; \
117: ifIsList(__list) { daisyChain = (*__list).objet; } \
118: else executionError("Type mistmatch error"); } while(0)
119:
120: #define fetchElementFromDaisyChain(daisyChain) \
121: ({ __CATCH_SYSTEM_ERROR__; typeof(daisyChain) __daisyChain = daisyChain; \
122: if (__daisyChain == NULL) executionError("End of daisy chain"); \
123: (__daisyChain == NULL) ? NULL : (*__daisyChain).donnee; })
124:
125: #define replaceElementIntoDaisyChain(daisyChain, element) \
126: __CATCH_SYSTEM_ERROR__; \
127: do { typeof(daisyChain) __daisyChain = daisyChain; \
128: if (__daisyChain == NULL) executionError("Nullified daisy chain"); \
129: freeObject((*__daisyChain).donnee); \
130: (*__daisyChain).donnee = element; } while(0)
131:
132: #define nextElementOfDaisyChain(daisyChain) \
133: ({ __CATCH_SYSTEM_ERROR__; typeof(daisyChain) __daisyChain = daisyChain; \
134: if (__daisyChain == NULL) executionError("End of daisy chain"); \
135: (__daisyChain == NULL) ? NULL : (*__daisyChain).suivant; })
136:
137: #define null NULL
138: #define nullify(ptr) __CATCH_SYSTEM_ERROR__; do { ptr = NULL; } while(0)
139: #define nullified(ptr) ((ptr) == NULL)
140:
141: #define postIncr(x) (x++)
142: #define preIncr(x) (++x)
143: #define postDecr(x) (x--)
144: #define preDecr(x) (--x)
145:
146: #define eq ==
147: #define ne !=
148: #define ge >=
149: #define gt >
150: #define le <=
151: #define lt <
152: #define not !
153: #define and &&
154: #define or ||
155: #define false 0
156: #define true -1
157:
158: #define setFalse(a) a = false
159: #define setTrue(a) a = true
160:
161: #define logical int
162: #define string char *
163: #define integer int
164:
165: #define declareStructure typedef struct {
166: #define declareUnion typedef union {
167: #define as(name) } name;
168:
169: #define target(a) (*a)
170: #define address(a) (&a)
171:
172: #define subroutine(name) int name()
173: #define beginGroup { __CATCH_SYSTEM_ERROR__;
174: #define endGroup __CATCH_SYSTEM_ERROR__; }
175: #define beginMacro do beginGroup
176: #define endMacro endGroup while(0)
177: #define stopRequest ({ __CATCH_SYSTEM_ERROR__; \
178: test_arret((*rpl_arguments).s_etat_processus); })
179:
180: /*
181: --------------------------------------------------------------------------------
182: Signaux
183: --------------------------------------------------------------------------------*/
184:
185: #define blockSignals \
186: { __CATCH_SYSTEM_ERROR__; sigset_t set, oldset; sigfillset(&set); \
187: pthread_sigmask(SIG_BLOCK, &set, &oldset);
188: #define unblockSignals \
189: pthread_sigmask(SIG_SETMASK, &oldset, NULL); __CATCH_SYSTEM_ERROR__; }
190:
191: /*
192: --------------------------------------------------------------------------------
193: Constructeurs
194: --------------------------------------------------------------------------------
195: */
196:
197: #define DISABLE_SET_BUT_NOT_USED_WARNING(a) if (&a != ((&a) + 1));
198:
199: #define HEADER \
200: int __constante; \
201: logical1 __evaluation; \
202: logical1 __validation_instruction = d_faux; \
203: logical1 __presence_aide = d_faux; \
204: logical1 __presence_validation = d_faux; \
205: unsigned char __indice_bit; \
206: unsigned char __indice_bloc; \
207: unsigned char __taille_bloc; \
208: unsigned char __type; \
209: t_8_bits __masque; \
210: { \
211: (*rpl_arguments).instruction_valide = 'Y'; \
212: (*rpl_arguments).erreur = 0; \
213: __constante = 0; \
214: __evaluation = d_faux; \
215: DISABLE_SET_BUT_NOT_USED_WARNING(__evaluation); \
216: DISABLE_SET_BUT_NOT_USED_WARNING(__type); \
217: DISABLE_SET_BUT_NOT_USED_WARNING(__indice_bit); \
218: DISABLE_SET_BUT_NOT_USED_WARNING(__indice_bloc); \
219: DISABLE_SET_BUT_NOT_USED_WARNING(__taille_bloc); \
220: DISABLE_SET_BUT_NOT_USED_WARNING(__masque);
221:
222: #define FUNCTION \
223: if (__validation_instruction == d_vrai) return 0; \
224: if (__presence_aide == d_faux) \
225: { \
226: systemError("Help string not defined"); \
227: } \
228: else if (__presence_validation == d_faux) \
229: { \
230: systemError("Number of arguments not defined"); \
231: } \
232: __indice_bit = 0; \
233: __indice_bloc = 0; \
234: __taille_bloc = 0; \
235: __type = 0; \
236: __masque = 0; \
237: {
238:
239: #define END \
240: strcpy((char *) __function_name, ""); \
241: if (__constante != 0) \
242: systemError("Constant definition error"); \
243: __CATCH_SYSTEM_ERROR__; \
244: } } \
245: leave;
246:
247: /*
248: --------------------------------------------------------------------------------
249: Destruction d'un objet
250: --------------------------------------------------------------------------------
251: */
252:
253: #define freeObject(rpl_object) \
254: __CATCH_SYSTEM_ERROR__; \
255: do { \
256: if (rpl_object == NULL) \
257: systemError("Nullified object"); \
258: _liberation(rpl_object); \
259: rpl_object = NULL; \
260: } while(0)
261:
262: /*
263: --------------------------------------------------------------------------------
264: Copie d'un objet
265: --------------------------------------------------------------------------------
266: */
267:
268: #define dupObject(rpl_object) \
269: __CATCH_SYSTEM_ERROR__; \
270: do { if (_copie_objet(rpl_object, 'P') != rpl_object) \
271: systemError("Memory allocation error"); } while(0)
272:
273: /*
274: --------------------------------------------------------------------------------
275: Déclaration des fonctions internes
276: --------------------------------------------------------------------------------
277: */
278:
279: #define CONCAT(a, b) __RPL_CONCAT(a, b)
280: #define __RPL_CONCAT(a, b) a##b
281: #define FIRST(...) FIRST_HELPER(__VA_ARGS__, throwaway)
282: #define FIRST_HELPER(first, ...) first
283: #define REST(...) REST_HELPER(NUM(__VA_ARGS__), __VA_ARGS__)
284: #define REST_HELPER(qty, ...) REST_HELPER2(qty, __VA_ARGS__)
285: #define REST_HELPER2(qty, ...) REST_HELPER_##qty(__VA_ARGS__)
286: #define REST_HELPER_ONE(first)
287: #define REST_HELPER_TWOORMORE(first, ...) , __VA_ARGS__
288: #define NUM(...) \
289: SELECT_10TH(__VA_ARGS__, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\
290: TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, ONE, throwaway)
291: #define SELECT_10TH(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, ...) a10
292:
293: #define declareInternalFunction(type, ...) \
294: type CONCAT(__internal_, FIRST(__VA_ARGS__)) \
295: (struct_rpl_arguments *rpl_arguments REST(__VA_ARGS__)) { \
296: type __internal_return; __internal_return = 0; int __type; \
297: DISABLE_SET_BUT_NOT_USED_WARNING(__type);
298:
299: #define endInternalFunction return(__internal_return); }
300:
301: #define useInternalFunction(type, ...) \
302: type CONCAT(__internal_, FIRST(__VA_ARGS__)) \
303: (struct_rpl_arguments *rpl_arguments REST(__VA_ARGS__))
304:
305: #define callInternalFunction(...) \
306: CONCAT(__internal_, FIRST(__VA_ARGS__))(rpl_arguments REST(__VA_ARGS__))
307:
308: /*
309: --------------------------------------------------------------------------------
310: Déclaration des fonctions C
311: --------------------------------------------------------------------------------
312: */
313:
314: #define declareCFunction(type, name, ...) \
315: type name(__VA_ARGS__) { __RPL__ type __c_return;
316: #define endCFunction return(__c_return); }
317:
318: #define useCFunction(type, name, ...) type name(__VA_ARGS__)
319:
320: /*
321: --------------------------------------------------------------------------------
322: Déclaration des fonctions externes
323: --------------------------------------------------------------------------------
324: */
325:
326: #define declareExternalFunction(name) \
327: int __external_##name(struct_rpl_arguments *rpl_arguments) { \
328: char __function_name[] = "__external_"#name; \
329: __static_rpl_arguments = (*rpl_arguments);
330:
331: #define useExternalFunction(function) \
332: int __external_##function(struct_rpl_arguments *rpl_arguments)
333:
334: #define libraryName(name) char __library_name[] = #name;
335:
336: #define __onLoading int __runOnLoading(struct_rpl_arguments *rpl_arguments)
337: #define __onClosing int __runOnClosing(struct_rpl_arguments *rpl_arguments)
338: #define declareSubroutine(when) __##when { \
339: char __function_name[] = #when; \
340: __static_rpl_arguments = (*rpl_arguments); \
341: HEADER \
342: declareHelpString(""); \
343: numberOfArguments(0); \
344: FUNCTION
345: #define endSubroutine END }
346:
347: #define notice(s, ...) __CATCH_SYSTEM_ERROR__; \
348: do { ufprintf(s, __VA_ARGS__); fflush(s); } while(0)
349: #define logger(...) __CATCH_SYSTEM_ERROR__; \
350: do { syslog(LOG_NOTICE, __VA_ARGS__); } while(0)
351:
352: #define exportExternalFunctions(...) \
353: char **__external_symbols(struct_rpl_arguments *rpl_arguments, \
354: integer8 *nb_symbols, \
355: const char *version) { \
356: char arguments[] = #__VA_ARGS__; \
357: char **tableau; \
358: char *ptr1, *ptr2; \
359: int drapeau; \
360: unsigned long i; \
361: struct_processus *s_etat_processus; \
362: s_etat_processus = (*rpl_arguments).s_etat_processus; \
363: if (strcmp(version, _d_version_rpl) != 0) \
364: { \
365: notice(stdout, "Versions mismatch : library %s, expected %s\n", \
366: _d_version_rpl, version); \
367: (*nb_symbols) = -1; return(NULL); \
368: } \
369: (*nb_symbols) = 0; ptr1 = arguments; drapeau = 0; \
370: while((*ptr1) != 0) \
371: { \
372: if (((*ptr1) != ',') && ((*ptr1) != ' ')) drapeau = -1; \
373: ptr1++; \
374: } \
375: if (drapeau == 0) return(NULL); \
376: ptr1 = arguments; (*nb_symbols) = 1; \
377: while((*ptr1) != 0) if ((*ptr1++) == ',') (*nb_symbols)++; \
378: if ((tableau = malloc((*nb_symbols) * sizeof(char *))) == NULL) \
379: return(NULL); \
380: ptr2 = arguments; i = 0; \
381: while(*ptr2 != 0) \
382: { \
383: while(((*ptr2) == ' ') || ((*ptr2) == ',')) ptr2++; \
384: ptr1 = ptr2; \
385: while(((*ptr2) != 0) && ((*ptr2) != ',') && ((*ptr2) != ' ')) \
386: ptr2++; \
387: if ((tableau[i] = malloc((ptr2 + 2 + \
388: strlen(__library_name) - ptr1) * \
389: sizeof(unsigned char))) == NULL) \
390: return(NULL); \
391: sprintf(tableau[i], "%s$", __library_name); \
392: strncat(&tableau[i][strlen(tableau[i])], ptr1, ptr2 - ptr1); \
393: i++; \
394: if ((*ptr2) != 0) \
395: { \
396: while((*ptr2) == ' ') ptr2++; \
397: if ((*ptr2) == ',') ptr2++; \
398: } \
399: } \
400: (*nb_symbols) = i; \
401: return(tableau); \
402: }
403:
404: #define endExternalFunction leave; }
405:
406: #define callExternalFunction(function) do { \
407: __CATCH_SYSTEM_ERROR__; \
408: __taille_bloc = sizeof(t_8_bits) * 8; \
409: __indice_bloc = (35 - 1) / __taille_bloc; \
410: __indice_bit = (35 - 1) % __taille_bloc; \
411: __masque = ((t_8_bits) 1) << (__taille_bloc - __indice_bit - 1); \
412: __evaluation = ((*rpl_arguments).drapeaux_etat[__indice_bloc] & __masque) \
413: ? d_vrai : d_faux; \
414: __masque = ~(((t_8_bits) 1) << (__taille_bloc - __indice_bit - 1)); \
415: (*rpl_arguments).drapeaux_etat[__indice_bloc] &= __masque; \
416: __external_##function(rpl_arguments); \
417: if (__evaluation == d_vrai) \
418: { \
419: __masque = ((t_8_bits) 1) << (__taille_bloc - __indice_bit - 1); \
420: (*rpl_arguments).drapeaux_etat[__indice_bloc] |= __masque; \
421: } \
422: else \
423: { \
424: __masque = ~(((t_8_bits) 1) << (__taille_bloc - __indice_bit - 1)); \
425: (*rpl_arguments).drapeaux_etat[__indice_bloc] &= __masque; \
426: } } while(0)
427:
428: /*
429: --------------------------------------------------------------------------------
430: Macros spécifiques à l'en-tête
431: --------------------------------------------------------------------------------
432: */
433:
434: #define declareHelpString(h) do { \
435: __presence_aide = d_vrai; \
436: if ((*rpl_arguments).affichage_arguments == 'Y') \
437: { \
438: uprintf("%s\n", h); \
439: return 0; \
440: } } while(0)
441:
442: #define declareSymbolicConstant do { \
443: numberOfArguments(0); \
444: (*rpl_arguments).constante_symbolique = 'Y'; \
445: __constante++; } while(0)
446:
447: #define numberOfArguments(n) do { \
448: __presence_validation = d_vrai; \
449: if ((*rpl_arguments).test_instruction == 'Y') \
450: { \
451: if (n < 0) \
452: systemError("Number of arguments must be positive or null"); \
453: (*rpl_arguments).nombre_arguments = n; \
454: __validation_instruction = d_vrai; \
455: } \
456: else \
457: { \
458: __taille_bloc = sizeof(t_8_bits) * 8; \
459: __indice_bloc = (31 - 1) / __taille_bloc; \
460: __indice_bit = (31 - 1) % __taille_bloc; \
461: __masque = ((t_8_bits) 1) << (__taille_bloc - __indice_bit - 1); \
462: if (((*rpl_arguments).drapeaux_etat[__indice_bloc] & __masque) != 0) \
463: { \
464: (*rpl_arguments).l_base_pile_last = \
465: sauvegarde_arguments(rpl_arguments, n); \
466: } \
467: } } while(0)
468:
469: /*
470: --------------------------------------------------------------------------------
471: Gestion des boucles
472: --------------------------------------------------------------------------------
473: */
474:
475: #define loop(b, e, s) for(b; e; s) {
476: #define endLoop __CATCH_SYSTEM_ERROR__; }
477:
478: #define repeatWhile(c) while(c) {
479: #define endWhile __CATCH_SYSTEM_ERROR__; }
480:
481: #define doUntil do {
482: #define repeatUntil(c) __CATCH_SYSTEM_ERROR__; } while(!(c));
483:
484: #define select(s) switch(s) {
485: #define endSelect __CATCH_SYSTEM_ERROR__; }
486: #define nonExclusiveCase(c) case c: {
487: #define endNonExclusiveCase __CATCH_SYSTEM_ERROR__; }
488: #define exclusiveCase(c) case c: {
489: #define endExclusiveCase break; __CATCH_SYSTEM_ERROR__; }
490: #define defaultCase default:
491: #define endDefaultCase break; __CATCH_SYSTEM_ERROR__; }
492:
493: /*
494: --------------------------------------------------------------------------------
495: Gestion des erreurs
496: --------------------------------------------------------------------------------
497: */
498:
499: #define returnOnError(...) do { \
500: if ((*rpl_arguments).erreur != 0) \
501: { \
502: __VA_ARGS__; \
503: return 0; \
504: } } while(0)
505:
506: #define systemError(message) do { \
507: (*rpl_arguments).erreur = __LINE__; \
508: (*rpl_arguments).type_erreur = 'S'; \
509: (*rpl_arguments).message_erreur = (unsigned char *) message; \
510: return 0; } while(0)
511:
512: #define executionError(message) do { \
513: (*rpl_arguments).erreur = __LINE__; \
514: (*rpl_arguments).type_erreur = 'E'; \
515: (*rpl_arguments).message_erreur = (unsigned char *) message; } while(0)
516:
517: #define onSystemError(...) do { \
518: if (((*rpl_arguments).erreur != 0) && \
519: ((*rpl_arguments).type_erreur == 'S')) \
520: { \
521: blockSignals; \
522: kill(getpid(), SIGTERM); \
523: unblockSignals; \
524: __VA_ARGS__; \
525: } } while(0)
526:
527: #define onError(...) \
528: __CATCH_SYSTEM_ERROR__; \
529: do { if (((*rpl_arguments).type_erreur == 'E') && \
530: ((*rpl_arguments).erreur != 0)) { __VA_ARGS__; \
531: (*rpl_arguments).erreur = 0; } } while(0)
532:
533: #define onExecution(...) \
534: __CATCH_SYSTEM_ERROR__; \
535: do { if (((*rpl_arguments).type_erreur == 'E') && \
536: ((*rpl_arguments).erreur == 0)) { __VA_ARGS__; } } while(0)
537:
538: /*
539: --------------------------------------------------------------------------------
540: Gestion de la pile opérationnelle
541: --------------------------------------------------------------------------------
542: */
543:
544: #define pushOnStack(rpl_object) do { \
545: __CATCH_SYSTEM_ERROR__; \
546: if (((*rpl_arguments).l_base_pile = \
547: empilement_pile_operationnelle(rpl_arguments, rpl_object)) \
548: == NULL) \
549: systemError("Memory allocation error"); \
550: if ((*rpl_object).nombre_occurrences == 1) rpl_object = NULL; } while(0)
551:
552: #define pullFromStack(rpl_object, ...) do { \
553: __CATCH_SYSTEM_ERROR__; \
554: (*rpl_arguments).l_base_pile = \
555: depilement_pile_operationnelle(rpl_arguments, &rpl_object); \
556: if (rpl_object == NULL) \
557: { \
558: executionError("Too few arguments"); \
559: } \
560: else \
561: { \
562: if (strlen(#__VA_ARGS__) == 0) \
563: { \
564: systemError("Undefined type"); \
565: } \
566: else \
567: { \
568: __type = 0; \
569: if (strstr(#__VA_ARGS__, "integer") != NULL) \
570: if ((*rpl_object).type == INT) __type = 1; \
571: if (strstr(#__VA_ARGS__, "real") != NULL) \
572: if ((*rpl_object).type == REL) __type = 1; \
573: if (strstr(#__VA_ARGS__, "complex") != NULL) \
574: if ((*rpl_object).type == CPL) __type = 1; \
575: if (strstr(#__VA_ARGS__, "string") != NULL) \
576: if ((*rpl_object).type == CHN) __type = 1; \
577: if (strstr(#__VA_ARGS__, "list") != NULL) \
578: if ((*rpl_object).type == LST) __type = 1; \
579: if (strstr(#__VA_ARGS__, "unknown") != NULL) \
580: __type = 1; \
581: if (__type == 0) \
582: { \
583: executionError("Type not allowed"); \
584: } \
585: } \
586: } } while(0)
587:
588: /*
589: --------------------------------------------------------------------------------
590: Gestion des objets
591: --------------------------------------------------------------------------------
592: */
593:
594: #define then {
595: #define endIf __CATCH_SYSTEM_ERROR__; }
596: #define elseIf __CATCH_SYSTEM_ERROR__; } else if
597: #define orElse __CATCH_SYSTEM_ERROR__; } else {
598:
599: // Constantes symboliques
600:
601: #define createSymbolicConstant(rpl_object, type, value) do { \
602: struct_processus *s_etat_processus; \
603: s_etat_processus = (*rpl_arguments).s_etat_processus; \
604: if ((strcmp(#type, "integer") != 0) && (strcmp(#type, "real") != 0)) \
605: systemError("Type not allowed for symbolic constant"); \
606: __taille_bloc = sizeof(t_8_bits) * 8; \
607: __indice_bloc = (35 - 1) / __taille_bloc; \
608: __indice_bit = (35 - 1) % __taille_bloc; \
609: __masque = ((t_8_bits) 1) << (__taille_bloc - __indice_bit - 1); \
610: if (((*rpl_arguments).drapeaux_etat[__indice_bloc] & __masque) != 0) \
611: { \
612: createNameObject(rpl_object); \
613: __CATCH_SYSTEM_ERROR__; \
614: { \
615: char *__constant_name; \
616: if ((__constant_name = malloc((strlen(__library_name) + \
617: strlen(__function_name) - 9) * sizeof(char))) == NULL) \
618: systemError("Memory allocation error"); \
619: sprintf(__constant_name, "%s$%s", __library_name, \
620: &(__function_name[11])); \
621: setName(rpl_object, __constant_name); \
622: free(__constant_name); \
623: } \
624: } \
625: else \
626: { \
627: if (strcmp(#type, "integer") == 0) \
628: { \
629: createIntegerObject(rpl_object); \
630: __CATCH_SYSTEM_ERROR__; \
631: setInteger(rpl_object, value); \
632: } \
633: else if (strcmp(#type, "real") == 0) \
634: { \
635: createRealObject(rpl_object); \
636: __CATCH_SYSTEM_ERROR__; \
637: setReal(rpl_object, value); \
638: } \
639: } \
640: __CATCH_SYSTEM_ERROR__; \
641: __constante--; } while(0)
642:
643: #define createSymbolicComplexConstant(rpl_object, rp, ip) do { \
644: struct_processus *s_etat_processus; \
645: s_etat_processus = (*rpl_arguments).s_etat_processus; \
646: __taille_bloc = sizeof(t_8_bits) * 8; \
647: __indice_bloc = (35 - 1) / __taille_bloc; \
648: __indice_bit = (35 - 1) % __taille_bloc; \
649: __masque = ((t_8_bits) 1) << (__taille_bloc - __indice_bit - 1); \
650: if (((*rpl_arguments).drapeaux_etat[__indice_bloc] & __masque) != 0) \
651: { \
652: createNameObject(rpl_object); \
653: __CATCH_SYSTEM_ERROR__; \
654: { \
655: char *__constant_name; \
656: if ((__constant_name = malloc((strlen(__library_name) + \
657: strlen(__function_name) + 2) * sizeof(char))) == NULL) \
658: systemError("Memory allocation error"); \
659: sprintf(__constant_name, "%s$%s", __library_name, \
660: __function_name); \
661: setName(rpl_object, __constant_name); \
662: free(__constant_name); \
663: } \
664: } \
665: else \
666: { \
667: createComplexObject(rpl_object); \
668: __CATCH_SYSTEM_ERROR__; \
669: setComplex(rpl_object, rp, im); \
670: } \
671: __CATCH_SYSTEM_ERROR__; \
672: __constante--; } while(0)
673:
674: // Integer
675:
676: #define setInteger(rpl_object, value) do { \
677: ifIsInteger(rpl_object) \
678: { \
679: if ((*rpl_object).nombre_occurrences > 1) \
680: { \
681: struct_objet *__tmp_rpl_object; \
682: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \
683: systemError("Memory allocation error"); \
684: _liberation(rpl_object); \
685: rpl_object = __tmp_rpl_object; \
686: } \
687: (*((integer8 *) (*rpl_object).objet)) = (integer8) value; \
688: } \
689: else executionError("Type mistmatch error"); } while(0)
690:
691: #define isInteger(rpl_object) \
692: ((*rpl_object).type == INT)
693:
694: #define ifIsInteger(rpl_object) if (isInteger(rpl_object))
695: #define elseIfIsInteger(rpl_object) } else ifIsInteger(rpl_object)
696:
697: #define getInteger(rpl_object, value) do { \
698: value = 0; \
699: ifIsInteger(rpl_object) value = (*((integer8 *) (*rpl_object).objet)); \
700: else executionError("Type mismatch error"); } while(0)
701:
702: #define createIntegerObject(rpl_object) do { \
703: if (rpl_object != NULL) \
704: systemError("Reallocated object"); \
705: if ((rpl_object = _allocation(INT)) == NULL) \
706: systemError("Memory allocation error"); \
707: setInteger(rpl_object, 0); } while(0)
708:
709: // Real
710:
711: #define setReal(rpl_object, value) do { \
712: ifIsReal(rpl_object) \
713: { \
714: if ((*rpl_object).nombre_occurrences > 1) \
715: { \
716: struct_objet *__tmp_rpl_object; \
717: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \
718: systemError("Memory allocation error"); \
719: _liberation(rpl_object); \
720: rpl_object = __tmp_rpl_object; \
721: } \
722: (*((real8 *) (*rpl_object).objet)) = (real8) value; \
723: } \
724: else executionError("Type mistmatch error"); } while(0)
725:
726: #define isReal(rpl_object) \
727: ((*rpl_object).type == REL)
728:
729: #define ifIsReal(rpl_object) if (isReal(rpl_object))
730: #define elseIfIsReal(rpl_object) } else ifIsReal(rpl_object)
731:
732: #define getReal(rpl_object, value) do { \
733: value = 0; \
734: ifIsReal(rpl_object) value = (*((real8 *) (*rpl_object).objet)); \
735: else executionError("Type mismatch error"); } while(0)
736:
737: #define createRealObject(rpl_object) do { \
738: if (rpl_object != NULL) \
739: systemError("Reallocated object"); \
740: if ((rpl_object = _allocation(REL)) == NULL) \
741: systemError("Memory allocation error"); \
742: setReal(rpl_object, 0); } while(0)
743:
744: // Complex
745:
746: #define setComplex(rpl_object, rp, ip) do { \
747: typeof(rp) __rp = rp; \
748: typeof(ip) __ip = ip; \
749: ifIsComplex(rpl_object) \
750: { \
751: if ((*rpl_object).nombre_occurrences > 1) \
752: { \
753: struct_objet *__tmp_rpl_object; \
754: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \
755: systemError("Memory allocation error"); \
756: _liberation(rpl_object); \
757: rpl_object = __tmp_rpl_object; \
758: } \
759: setRealPartOfComplex(rpl_object, __rp); \
760: setImaginaryPartOfComplex(rpl_object, __ip); \
761: } \
762: else executionError("Type mismatch error"); } while(0)
763:
764: #define setRealPartOfComplex(rpl_object, value) do { \
765: if ((*rpl_object).nombre_occurrences > 1) \
766: { \
767: struct_objet *__tmp_rpl_object; \
768: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \
769: systemError("Memory allocation error"); \
770: _liberation(rpl_object); \
771: rpl_object = __tmp_rpl_object; \
772: } \
773: ifIsComplex(rpl_object) (*((complex16 *) (*rpl_object).objet)) \
774: .partie_reelle = value; \
775: else executionError("Type mismatch error"); } while(0)
776:
777: #define setImaginaryPartOfComplex(rpl_object, value) do { \
778: if ((*rpl_object).nombre_occurrences > 1) \
779: { \
780: struct_objet *__tmp_rpl_object; \
781: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \
782: systemError("Memory allocation error"); \
783: _liberation(rpl_object); \
784: rpl_object = __tmp_rpl_object; \
785: } \
786: (*((complex16 *) (*rpl_object).objet)).partie_imaginaire = value; \
787: else executionError("Type mismatch error"); } while(0)
788:
789: #define getRealPartOfComplex(rpl_object, value) \
790: value = (*((complex16 *) (*rpl_object).objet)).partie_reelle
791:
792: #define getImaginaryPartOfComplex(rpl_object, value) \
793: value = (*((complex16 *) (*rpl_object).objet)).partie_imaginaire
794:
795: #define isComplex(rpl_object) \
796: ((*rpl_object).type == CPL)
797:
798: #define ifIsComplex(rpl_object) if (isComplex(rpl_object))
799: #define elseIfIsComplex(rpl_object) } else ifIsComplex(rpl_object)
800:
801: #define getComplex(rpl_object, value) do { \
802: value.partie_reelle = 0; \
803: value.partie_imaginaire = 0; \
804: ifIsComplex(rpl_object) value = (*((complex16 *) (*rpl_object).objet)); \
805: else systemError("Not a complex"); } while(0)
806:
807: #define createComplexObject(rpl_object) do { \
808: if (rpl_object != NULL) \
809: systemError("Reallocated object"); \
810: if ((rpl_object = _allocation(CPL)) == NULL) \
811: systemError("Memory allocation error"); \
812: setComplex(rpl_object, 0, 0); } while(0)
813:
814: // Generalized vectors
815:
816: #define createVectorObject(rpl_object, size, otype, structure, cat) do { \
817: integer8 i; \
818: struct_processus *s_etat_processus; \
819: s_etat_processus = (*rpl_arguments).s_etat_processus; \
820: if (rpl_object != NULL) \
821: systemError("Reallocated object"); \
822: if ((rpl_object = _allocation(cat)) == NULL) \
823: systemError("Memory allocation error"); \
824: (*((structure *) (*rpl_object).objet)).taille = size; \
825: if (((*((structure *) (*rpl_object).objet)).tableau = \
826: malloc(size * sizeof(otype))) == NULL) \
827: systemError("Memory allocation error"); \
828: if (cat != VCX) \
829: { \
830: if (cat == VIN) \
831: (*((structure *) (*rpl_object).objet)).type = 'I'; \
832: else \
833: (*((structure *) (*rpl_object).objet)).type = 'R'; \
834: for(i = 0; i < size; ((otype *) (*((structure *) (*rpl_object).objet)) \
835: .tableau)[i++] = (otype) 0); \
836: } \
837: else \
838: { \
839: (*((structure *) (*rpl_object).objet)).type = 'C'; \
840: for(i = 0; i < size; i++) \
841: { \
842: ((complex16 *) (*((structure *) (*rpl_object).objet)).tableau)[i] \
843: .partie_reelle = 0; \
844: ((complex16 *) (*((structure *) (*rpl_object).objet)).tableau)[i] \
845: .partie_imaginaire = 0; \
846: } \
847: } } while(0)
848:
849: // Integer vector
850:
851: #define setIntegerIntoVector(rpl_object, value, position) do { \
852: typeof(position) __position = position; \
853: ifIsIntegerVector(rpl_object) \
854: { \
855: if ((*rpl_object).nombre_occurrences > 1) \
856: { \
857: struct_objet *__tmp_rpl_object; \
858: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \
859: systemError("Memory allocation error"); \
860: _liberation(rpl_object); \
861: rpl_object = __tmp_rpl_object; \
862: } \
863: __position--; \
864: if ((__position < 0) || (__position >= (*((struct_vecteur *) \
865: (*rpl_object).objet)).taille)) \
866: { executionError("Element out of range"); } \
867: else \
868: ((integer8 *) (*((struct_vecteur *) (*rpl_object).objet)).tableau) \
869: [__position] = (integer8) value; \
870: } \
871: else executionError("Type mistmatch error"); } while(0)
872:
873: #define isIntegerVector(rpl_object) \
874: ((*rpl_object).type == VIN)
875:
876: #define ifIsIntegerVector(rpl_object) if (isIntegerVector(rpl_object))
877: #define elseIfIsIntegerVector(rpl_object) } else ifIsIntegerVector(rpl_object)
878:
879: #define getIntegerFromVector(rpl_object, value, position) do { \
880: typeof(position) __position = position; \
881: value = 0; \
882: ifIsIntegerVector(rpl_object) \
883: { \
884: __position--; \
885: if ((__position < 0) || (__position >= (*((struct_vecteur *) \
886: (*rpl_object).objet)).taille)) \
887: executionError("Element out of range"); \
888: else \
889: value = ((integer8 *) (*((struct_vecteur *) (*rpl_object).objet)) \
890: .tableau)[__position]; \
891: } \
892: else executionError("Type mismatch error"); } while(0)
893:
894: #define createIntegerVectorObject(rpl_object, size) \
895: createVectorObject(rpl_object, size, integer8, struct_vecteur, VIN)
896:
897: // Real vector
898:
899: #define setRealIntoVector(rpl_object, value, position) do { \
900: typeof(position) __position = position; \
901: ifIsRealVector(rpl_object) \
902: { \
903: if ((*rpl_object).nombre_occurrences > 1) \
904: { \
905: struct_objet *__tmp_rpl_object; \
906: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \
907: systemError("Memory allocation error"); \
908: _liberation(rpl_object); \
909: rpl_object = __tmp_rpl_object; \
910: } \
911: __position--; \
912: if ((__position < 0) || (__position >= (*((struct_vecteur *) \
913: (*rpl_object).objet)).taille)) \
914: { executionError("Element out of range"); } \
915: else \
916: ((real8 *) (*((struct_vecteur *) (*rpl_object).objet)).tableau) \
917: [__position] = (real8) value; \
918: } \
919: else executionError("Type mistmatch error"); } while(0)
920:
921: #define isRealVector(rpl_object) \
922: ((*rpl_object).type == VRL)
923:
924: #define ifIsRealVector(rpl_object) if (isRealVector(rpl_object))
925: #define elseIfIsRealVector(rpl_object) } else ifIsRealVector(rpl_object)
926:
927: #define getRealFromVector(rpl_object, value, position) do { \
928: typeof(position) __position = position; \
929: value = 0; \
930: ifIsRealVector(rpl_object) \
931: { \
932: __position--; \
933: if ((__position < 0) || (__position >= (*((struct_vecteur *) \
934: (*rpl_object).objet)).taille)) \
935: executionError("Element out of range"); \
936: value = ((real8 *) (*((struct_vecteur *) (*rpl_object).objet)) \
937: .tableau)[__position]; \
938: } \
939: else executionError("Type mismatch error"); } while(0)
940:
941: #define createRealVectorObject(rpl_object, size) \
942: createVectorObject(rpl_object, size, real8, struct_vecteur, VRL)
943:
944: // A FIXER
945:
946: #define createComplexVectorObject
947:
948: #define createIntegerMatrixObject
949:
950: #define createRealMatrixObject
951:
952: #define createComplexMatrixObject
953:
954: // Binary integer
955:
956: #define setBinaryInteger(rpl_object, value) do { \
957: ifIsBinaryInteger(rpl_object) \
958: { \
959: if ((*rpl_object).nombre_occurrences > 1) \
960: { \
961: struct_objet *__tmp_rpl_object; \
962: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \
963: systemError("Memory allocation error"); \
964: _liberation(rpl_object); \
965: rpl_object = __tmp_rpl_object; \
966: } \
967: (*((integer8 *) (*rpl_object).objet)) = (integer8) value; \
968: } \
969: else executionError("Type mistmatch error"); } while(0)
970:
971: #define isBinaryInteger(rpl_object) \
972: ((*rpl_object).type == BIN)
973:
974: #define ifIsBinaryInteger(rpl_object) if (isBinaryInteger(rpl_object))
975: #define elseIfIsBinaryInteger(rpl_object) } else ifIsBinaryInteger(rpl_object)
976:
977: #define getBinaryInteger(rpl_object, value) do { \
978: value = 0; \
979: ifIsBinaryInteger(rpl_object) value = \
980: (*((integer8 *) (*rpl_object).objet)); \
981: else executionError("Type mismatch error"); } while(0)
982:
983: #define createBinaryIntegerObject(rpl_object) do { \
984: if (rpl_object != NULL) \
985: systemError("Reallocated object"); \
986: if ((rpl_object = _allocation(BIN)) == NULL) \
987: systemError("Memory allocation error"); \
988: setBinaryInteger(rpl_object, 0); } while(0)
989:
990: // Name
991:
992: #define isName(rpl_object) \
993: ((*rpl_object).type == NOM)
994:
995: #define ifIsName(rpl_object) if (isName(rpl_object))
996: #define elseIfIsName(rpl_object) } else if (isName(rpl_object))
997:
998: #define setName(rpl_object, value) do { \
999: struct_processus *s_etat_processus; \
1000: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1001: ifIsName(rpl_object) \
1002: { \
1003: if ((*rpl_object).nombre_occurrences > 1) \
1004: { \
1005: struct_objet *__tmp_rpl_object; \
1006: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \
1007: systemError("Memory allocation error"); \
1008: _liberation(rpl_object); \
1009: rpl_object = __tmp_rpl_object; \
1010: } \
1011: free((*((struct_nom *) (*rpl_object).objet)).nom); \
1012: (*((struct_nom *) (*rpl_object).objet)).symbole = d_faux; \
1013: if (((*((struct_nom *) (*rpl_object).objet)).nom = malloc( \
1014: (strlen(value) + 1) * sizeof(unsigned char))) == NULL) \
1015: systemError("Memory allocation error"); \
1016: strcpy((char *) (*((struct_nom *) (*rpl_object).objet)).nom, \
1017: (char *) value); \
1018: } \
1019: else executionError("Type mistmatch error"); } while(0)
1020:
1021: #define setSymbolicName(rpl_object, value) do { \
1022: setName(rpl_object, value); \
1023: (*((struct_nom *) (*rpl_object).objet)).symbole = d_vrai; } while(0)
1024:
1025: #define createNameObject(rpl_object) do { \
1026: struct_processus *s_etat_processus; \
1027: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1028: if (rpl_object != NULL) \
1029: systemError("Reallocated object"); \
1030: if ((rpl_object = _allocation(NOM)) == NULL) \
1031: systemError("Memory allocation error"); \
1032: (*((struct_nom *) (*rpl_object).objet)).symbole = d_faux; \
1033: if (((*((struct_nom *) (*rpl_object).objet)).nom = malloc( \
1034: sizeof(unsigned char))) == NULL) \
1035: systemError("Memory allocation error"); \
1036: strcpy((char *) (*((struct_nom *) (*rpl_object).objet)).nom, ""); } while(0)
1037:
1038: // String
1039:
1040: #define isString(rpl_object) \
1041: ((*rpl_object).type == CHN)
1042:
1043: #define ifIsString(rpl_object) if (isString(rpl_object))
1044: #define elseIfIsString(rpl_object) else if (isString(rpl_object))
1045:
1046: #define setString(rpl_object, string) do { \
1047: struct_processus *s_etat_processus; \
1048: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1049: ifIsString(rpl_object) \
1050: { \
1051: if (string == NULL) executionError("Nullified string"); else \
1052: { \
1053: if ((*rpl_object).nombre_occurrences > 1) \
1054: { \
1055: struct_objet *__tmp_rpl_object; \
1056: if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) \
1057: == NULL) \
1058: systemError("Memory allocation error"); \
1059: _liberation(rpl_object); \
1060: rpl_object = __tmp_rpl_object; \
1061: } \
1062: free((unsigned char *) (*rpl_object).objet); \
1063: if (((*rpl_object).objet = malloc((strlen(string) + 1) * \
1064: sizeof(unsigned char))) == NULL) \
1065: systemError("Memory allocation error"); \
1066: strcpy((char *) (*rpl_object).objet, string); \
1067: } \
1068: } \
1069: else executionError("Type mistmatch error"); } while(0)
1070:
1071: #define getString(rpl_object, string) do { \
1072: string = NULL; \
1073: ifIsString(rpl_object) string = (char *) (*rpl_object).objet; \
1074: else executionError("Type mismatch error"); } while(0)
1075:
1076: #define createStringObject(rpl_object) do { \
1077: struct_processus *s_etat_processus; \
1078: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1079: if (rpl_object != NULL) \
1080: systemError("Reallocated object"); \
1081: if ((rpl_object = _allocation(CHN)) == NULL) \
1082: systemError("Memory allocation error"); \
1083: if (((*rpl_object).objet = malloc(sizeof(unsigned char))) == NULL) \
1084: systemError("Memory allocation error"); \
1085: strcpy((char *) (*rpl_object).objet, ""); } while(0)
1086:
1087: // List
1088:
1089: #define isList(rpl_object) \
1090: ((*rpl_object).type == LST)
1091:
1092: #define ifIsList(rpl_object) if (isList(rpl_object))
1093: #define elseIfIsList(rpl_object) else if (isList(rpl_object))
1094:
1095: #define createListObject(rpl_object) do { \
1096: if (rpl_object != NULL) \
1097: systemError("Reallocated object"); \
1098: if ((rpl_object = _allocation(LST)) == NULL) \
1099: systemError("Memory allocation error"); \
1100: (*rpl_object).objet = NULL; } while(0)
1101:
1102: #define addObjectToList(list, rpl_object) do { \
1103: struct_processus *s_etat_processus; \
1104: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1105: ifIsList(list) \
1106: { \
1107: struct_objet *__tmp_rpl_object; \
1108: if ((__tmp_rpl_object = _copie_objet(list, 'N')) == NULL) \
1109: systemError("Memory allocation error"); \
1110: _liberation(list); \
1111: list = __tmp_rpl_object; \
1112: if ((*list).objet == NULL) \
1113: { \
1114: if (((*list).objet = malloc(sizeof(struct_liste_chainee))) \
1115: == NULL) \
1116: systemError("Memory allocation error"); \
1117: (*((struct_liste_chainee *) (*list).objet)).suivant = NULL; \
1118: (*((struct_liste_chainee *) (*list).objet)).donnee = rpl_object; \
1119: } \
1120: else \
1121: { \
1122: struct_liste_chainee *l_element_courant; \
1123: l_element_courant = (*list).objet; \
1124: while((*l_element_courant).suivant != NULL) \
1125: l_element_courant = (*l_element_courant).suivant; \
1126: if (((*l_element_courant).suivant = \
1127: malloc(sizeof(struct_liste_chainee))) == NULL) \
1128: systemError("Memory allocation error"); \
1129: l_element_courant = (*l_element_courant).suivant; \
1130: (*l_element_courant).suivant = NULL; \
1131: (*l_element_courant).donnee = rpl_object; \
1132: } \
1133: rpl_object = NULL; \
1134: } \
1135: else executionError("Type mistmatch error"); } while(0)
1136:
1137: #define insertObjectIntoList(list, rpl_object) do { \
1138: struct_processus *s_etat_processus; \
1139: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1140: ifIsList(list) \
1141: { \
1142: struct_objet *__tmp_rpl_object; \
1143: if ((__tmp_rpl_object = _copie_objet(list, 'N')) == NULL) \
1144: systemError("Memory allocation error"); \
1145: _liberation(list); \
1146: list = __tmp_rpl_object; \
1147: if ((*list).objet == NULL) \
1148: { \
1149: if (((*list).objet = malloc(sizeof(struct_liste_chainee))) \
1150: == NULL) \
1151: systemError("Memory allocation error"); \
1152: (*((struct_liste_chainee *) (*list).objet)).suivant = NULL; \
1153: (*((struct_liste_chainee *) (*list).objet)).donnee = rpl_object; \
1154: } \
1155: else \
1156: { \
1157: struct_liste_chainee *l_element_courant; \
1158: if ((l_element_courant = \
1159: malloc(sizeof(struct_liste_chainee))) == NULL) \
1160: systemError("Memory allocation error"); \
1161: (*l_element_courant).donnee = rpl_object; \
1162: (*l_element_courant).suivant = (*list).objet; \
1163: (*list).objet = l_element_courant; \
1164: } \
1165: rpl_object = NULL; \
1166: } \
1167: else executionError("Type mistmatch error"); } while(0)
1168:
1169: #define removeObjectFromList(list, rpl_object) do { \
1170: struct_processus *s_etat_processus; \
1171: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1172: ifIsList(list) \
1173: { \
1174: if ((*list).objet != NULL) \
1175: { \
1176: struct_liste_chainee *__current; \
1177: struct_liste_chainee *__previous; \
1178: __current = (*list).objet; \
1179: __previous = NULL; \
1180: if ((*__current).donnee == rpl_object) \
1181: { \
1182: (*list).objet = (*__current).suivant; \
1183: } \
1184: else \
1185: { \
1186: while(__current != NULL) \
1187: { \
1188: if ((*__current).donnee == rpl_object) \
1189: { \
1190: (*__previous).suivant = (*__current).suivant; \
1191: break; \
1192: } \
1193: __previous = __current; \
1194: __current = (*__current).suivant; \
1195: } \
1196: } \
1197: _liberation((*__current).donnee); \
1198: free(__current); \
1199: } \
1200: } \
1201: else executionError("Type mistmatch error"); } while(0)
1202:
1203: #define getObjectFromList(list, position, rpl_object)
1204:
1205: #define putObjectIntoList(list, position, rpl_object)
1206:
1207: #define getListFromList(list, position1, position2, rpl_object)
1208:
1209: #define listLength(list, length) do { \
1210: if (list == NULL) executionError("Nullified object"); \
1211: if ((*list).type != LST) \
1212: executionError("Type mistmatch error"); \
1213: { \
1214: struct_liste_chainee *l_element_courant; \
1215: length = 0; \
1216: l_element_courant = (*list).objet; \
1217: while(l_element_courant != NULL) \
1218: { \
1219: l_element_courant = (*l_element_courant).suivant; \
1220: length++; \
1221: } \
1222: } } while(0)
1223:
1224: /*
1225: --------------------------------------------------------------------------------
1226: Allocation mémoire
1227: --------------------------------------------------------------------------------
1228: */
1229:
1230: #define size(a) sizeof(a)
1231:
1232: #define allocate(a) ({ void *ptr; \
1233: struct_processus *s_etat_processus; \
1234: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1235: if ((ptr = malloc(a)) == NULL) \
1236: systemError("Memory allocation error"); ptr; })
1237:
1238: #define reallocate(a, s) ({ void *ptr; \
1239: struct_processus *s_etat_processus; \
1240: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1241: if ((ptr = realloc(a, s)) == NULL) \
1242: systemError("Memory allocation error"); ptr; })
1243:
1244: #define deallocate(a) do { \
1245: struct_processus *s_etat_processus; \
1246: s_etat_processus = (*rpl_arguments).s_etat_processus; \
1247: free(a); } while(0)
1248:
1249: /*
1250: --------------------------------------------------------------------------------
1251: Récupération des interruptions et des signaux
1252: --------------------------------------------------------------------------------
1253: */
1254:
1255: #define pollSignalsAndInterrupts() \
1256: __CATCH_SYSTEM_ERROR__; \
1257: do { scrutation_injection((*rpl_arguments).s_etat_processus); } while(0)
1258:
1259: /*
1260: --------------------------------------------------------------------------------
1261: Exécution d'une fonction intrinsèque
1262: --------------------------------------------------------------------------------
1263: */
1264:
1265: #define intrinsic(function) do { \
1266: int __status; \
1267: __CATCH_SYSTEM_ERROR__; \
1268: __status = wrapper_instruction_intrinseque( \
1269: instruction_##function, rpl_arguments); \
1270: if (__status == 1) executionError(#function); \
1271: if (__status == 2) systemError(#function); \
1272: } while(0)
1273:
1274: #endif
1275:
1276: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>