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