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