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