--- rpl/src/rplexternals.h 2012/01/05 10:19:06 1.33 +++ rpl/src/rplexternals.h 2013/04/03 09:40:31 1.51 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.5 - Copyright (C) 1989-2012 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.14 + Copyright (C) 1989-2013 Dr. BERTRAND Joël This file is part of RPL/2. @@ -39,6 +39,11 @@ ================================================================================ */ +#define __CATCH_SYSTEM_ERROR__ \ + do { if (((*rpl_arguments).erreur != 0) && \ + ((*rpl_arguments).type_erreur == 'S')) \ + return 0; } while(0) +#define leave do { return(0); } while(0) #define allocation(a) librpl_allocation((*rpl_arguments).s_etat_processus, a) #define copie_objet(a, b) librpl_copie_objet( \ (*rpl_arguments).s_etat_processus, a, b) @@ -56,29 +61,33 @@ #define declareComplex(complex) complex16 complex #define declareDaisyChain(daisyChain) struct_liste_chainee *daisyChain = NULL -#define getDaisyChainFromList(list, daisyChain) { \ +#define getDaisyChainFromList(list, daisyChain) \ + __CATCH_SYSTEM_ERROR__; \ + do { \ typeof(list) __list = list; \ daisyChain = NULL; \ ifIsList(__list) { daisyChain = (*__list).objet; } \ else executionError("Type mistmatch error"); } while(0) #define fetchElementFromDaisyChain(daisyChain) \ - ({ typeof(daisyChain) __daisyChain = daisyChain; \ + ({ __CATCH_SYSTEM_ERROR__; typeof(daisyChain) __daisyChain = daisyChain; \ if (__daisyChain == NULL) executionError("End of daisy chain"); \ (__daisyChain == NULL) ? NULL : (*__daisyChain).donnee; }) #define replaceElementIntoDaisyChain(daisyChain, element) \ + __CATCH_SYSTEM_ERROR__; \ do { typeof(daisyChain) __daisyChain = daisyChain; \ if (__daisyChain == NULL) executionError("Nullified daisy chain"); \ + freeObject((*__daisyChain).donnee); \ (*__daisyChain).donnee = element; } while(0) #define nextElementOfDaisyChain(daisyChain) \ - ({ typeof(daisyChain) __daisyChain = daisyChain; \ + ({ __CATCH_SYSTEM_ERROR__; typeof(daisyChain) __daisyChain = daisyChain; \ if (__daisyChain == NULL) executionError("End of daisy chain"); \ (__daisyChain == NULL) ? NULL : (*__daisyChain).suivant; }) #define null NULL -#define nullify(ptr) { ptr = NULL; } while(0) +#define nullify(ptr) __CATCH_SYSTEM_ERROR__; do { ptr = NULL; } while(0) #define nullified(ptr) ((ptr) == NULL) #define postIncr(x) (x++) @@ -104,6 +113,7 @@ #define logical int #define string char * #define integer int +#define object struct_objet * #define declareStructure typedef struct { #define declareUnion typedef union { @@ -112,11 +122,23 @@ #define target(a) (*a) #define address(a) (&a) -#define beginGroup { -#define endGroup } -#define beginMacro beginGroup +#define beginGroup { __CATCH_SYSTEM_ERROR__; +#define endGroup __CATCH_SYSTEM_ERROR__; } +#define beginMacro do beginGroup #define endMacro endGroup while(0) -#define stopRequest test_arret((*rpl_arguments).s_etat_processus) +#define stopRequest __CATCH_SYSTEM_ERROR__; \ + test_arret((*rpl_arguments).s_etat_processus) + +/* +-------------------------------------------------------------------------------- + Signaux +--------------------------------------------------------------------------------*/ + +#define blockSignals \ + { __CATCH_SYSTEM_ERROR__; sigset_t set, oldset; sigfillset(&set); \ + pthread_sigmask(SIG_BLOCK, &set, &oldset); +#define unblockSignals \ + pthread_sigmask(SIG_SETMASK, &oldset, NULL); __CATCH_SYSTEM_ERROR__; } /* -------------------------------------------------------------------------------- @@ -150,7 +172,7 @@ DISABLE_SET_BUT_NOT_USED_WARNING(__masque); #define FUNCTION \ - if (__validation_instruction == d_vrai) return; \ + if (__validation_instruction == d_vrai) return 0; \ if (__presence_aide == d_faux) \ { \ systemError("Help string not defined"); \ @@ -170,8 +192,80 @@ strcpy((char *) __function_name, ""); \ if (__constante != 0) \ systemError("Constant definition error"); \ + __CATCH_SYSTEM_ERROR__; \ } } \ - return; + leave; + +/* +-------------------------------------------------------------------------------- + Destruction d'un objet +-------------------------------------------------------------------------------- +*/ + +#define freeObject(object) \ + __CATCH_SYSTEM_ERROR__; \ + do { \ + if (object == NULL) \ + systemError("Nullified object"); \ + liberation(object); \ + object = NULL; \ + } while(0) + +/* +-------------------------------------------------------------------------------- + Copie d'un objet +-------------------------------------------------------------------------------- +*/ + +#define dupObject(object) \ + __CATCH_SYSTEM_ERROR__; \ + do { if (copie_objet(object, 'P') != object) \ + systemError("Memory allocation error"); } while(0) + +/* +-------------------------------------------------------------------------------- + Déclaration des fonctions internes +-------------------------------------------------------------------------------- +*/ + +#define CONCAT(a, b) __CONCAT(a, b) +#define __CONCAT(a, b) a##b +#define FIRST(...) FIRST_HELPER(__VA_ARGS__, throwaway) +#define FIRST_HELPER(first, ...) first +#define REST(...) REST_HELPER(NUM(__VA_ARGS__), __VA_ARGS__) +#define REST_HELPER(qty, ...) REST_HELPER2(qty, __VA_ARGS__) +#define REST_HELPER2(qty, ...) REST_HELPER_##qty(__VA_ARGS__) +#define REST_HELPER_ONE(first) +#define REST_HELPER_TWOORMORE(first, ...) , __VA_ARGS__ +#define NUM(...) \ + SELECT_10TH(__VA_ARGS__, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\ + TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, ONE, throwaway) +#define SELECT_10TH(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, ...) a10 + +#define declareInternalFunction(type, ...) \ + type CONCAT(__internal_, FIRST(__VA_ARGS__)) \ + (struct_rpl_arguments *rpl_arguments REST(__VA_ARGS__)) { \ + type __internal_return; __internal_return = 0; int __type; \ + DISABLE_SET_BUT_NOT_USED_WARNING(__type); + +#define endInternalFunction return(__internal_return); } + +#define useInternalFunction(type, ...) \ + type CONCAT(__internal_, FIRST(__VA_ARGS__)) \ + (struct_rpl_arguments *rpl_arguments REST(__VA_ARGS__)) + +#define callInternalFunction(...) \ + CONCAT(__internal_, FIRST(__VA_ARGS__))(rpl_arguments REST(__VA_ARGS__)) + +/* +-------------------------------------------------------------------------------- + Déclaration des fonctions C +-------------------------------------------------------------------------------- +*/ + +#define declareCFunction(type, name, ...) \ + type name(__VA_ARGS__) { __RPL__ type __c_return; +#define endCFunction return(__c_return); } /* -------------------------------------------------------------------------------- @@ -180,29 +274,34 @@ */ #define declareExternalFunction(name) \ - void __external_##name(struct_rpl_arguments *rpl_arguments) { \ - char __function_name[] = "__external_"#name; + int __external_##name(struct_rpl_arguments *rpl_arguments) { \ + char __function_name[] = "__external_"#name; \ + __static_rpl_arguments = (*rpl_arguments); #define useExternalFunction(function) \ - void __external_##function(struct_rpl_arguments *rpl_arguments) + int __external_##function(struct_rpl_arguments *rpl_arguments) #define libraryName(name) char __library_name[] = #name; -#define __onLoading void __runOnLoading(struct_rpl_arguments *rpl_arguments) -#define __onClosing void __runOnClosing(struct_rpl_arguments *rpl_arguments) +#define __onLoading int __runOnLoading(struct_rpl_arguments *rpl_arguments) +#define __onClosing int __runOnClosing(struct_rpl_arguments *rpl_arguments) #define declareSubroutine(when) __##when { \ char __function_name[] = #when; \ + __static_rpl_arguments = (*rpl_arguments); \ HEADER \ declareHelpString(""); \ numberOfArguments(0); \ FUNCTION #define endSubroutine END } -#define notice(s, ...) do { ufprintf(s, __VA_ARGS__); fflush(s); } while(0) -#define logger(...) do { syslog(LOG_NOTICE, __VA_ARGS__); } while(0) +#define notice(s, ...) __CATCH_SYSTEM_ERROR__; \ + do { ufprintf(s, __VA_ARGS__); fflush(s); } while(0) +#define logger(...) __CATCH_SYSTEM_ERROR__; \ + do { syslog(LOG_NOTICE, __VA_ARGS__); } while(0) #define exportExternalFunctions(...) \ - char **__external_symbols(unsigned long *nb_symbols, \ + char **__external_symbols(struct_rpl_arguments *rpl_arguments, \ + integer8 *nb_symbols, \ const char *version) { \ char arguments[] = #__VA_ARGS__; \ char **tableau; \ @@ -250,9 +349,10 @@ return(tableau); \ } -#define endExternalFunction return; } +#define endExternalFunction leave; } -#define callExternalFunction(function) { \ +#define callExternalFunction(function) do { \ + __CATCH_SYSTEM_ERROR__; \ __taille_bloc = sizeof(t_8_bits) * 8; \ __indice_bloc = (35 - 1) / __taille_bloc; \ __indice_bit = (35 - 1) % __taille_bloc; \ @@ -279,20 +379,20 @@ -------------------------------------------------------------------------------- */ -#define declareHelpString(h) { \ +#define declareHelpString(h) do { \ __presence_aide = d_vrai; \ if ((*rpl_arguments).affichage_arguments == 'Y') \ { \ uprintf("%s\n", h); \ - return; \ + return 0; \ } } while(0) -#define declareSymbolicConstant { \ +#define declareSymbolicConstant do { \ numberOfArguments(0); \ (*rpl_arguments).constante_symbolique = 'Y'; \ __constante++; } while(0) -#define numberOfArguments(n) { \ +#define numberOfArguments(n) do { \ __presence_validation = d_vrai; \ if ((*rpl_arguments).test_instruction == 'Y') \ { \ @@ -321,22 +421,22 @@ */ #define loop(b, e, s) for(b; e; s) { -#define endLoop } +#define endLoop __CATCH_SYSTEM_ERROR__; } #define repeatWhile(c) while(c) { -#define endWhile } +#define endWhile __CATCH_SYSTEM_ERROR__; } #define doUntil do { -#define repeatUntil(c) } while(!(c)); +#define repeatUntil(c) __CATCH_SYSTEM_ERROR__; } while(!(c)); #define select(s) switch(s) { -#define endSelect } +#define endSelect __CATCH_SYSTEM_ERROR__; } #define nonExclusiveCase(c) case c: { -#define endNonExclusiveCase } +#define endNonExclusiveCase __CATCH_SYSTEM_ERROR__; } #define exclusiveCase(c) case c: { -#define endExclusiveCase break; } +#define endExclusiveCase break; __CATCH_SYSTEM_ERROR__; } #define defaultCase default: -#define endDefaultCase break; } +#define endDefaultCase break; __CATCH_SYSTEM_ERROR__; } /* -------------------------------------------------------------------------------- @@ -344,30 +444,42 @@ -------------------------------------------------------------------------------- */ -#define returnOnError(...) { \ +#define returnOnError(...) do { \ if ((*rpl_arguments).erreur != 0) \ { \ __VA_ARGS__; \ - return; \ + return 0; \ } } while(0) -#define systemError(message) { \ +#define systemError(message) do { \ (*rpl_arguments).erreur = __LINE__; \ (*rpl_arguments).type_erreur = 'S'; \ (*rpl_arguments).message_erreur = (unsigned char *) message; \ - return; } while(0) + return 0; } while(0) -#define executionError(message) { \ +#define executionError(message) do { \ (*rpl_arguments).erreur = __LINE__; \ (*rpl_arguments).type_erreur = 'E'; \ (*rpl_arguments).message_erreur = (unsigned char *) message; } while(0) +#define onSystemError(...) do { \ + if (((*rpl_arguments).erreur != 0) && \ + ((*rpl_arguments).type_erreur == 'S')) \ + { \ + blockSignals; \ + kill(getpid(), SIGTERM); \ + unblockSignals; \ + __VA_ARGS__; \ + } } while(0) + #define onError(...) \ + __CATCH_SYSTEM_ERROR__; \ do { if (((*rpl_arguments).type_erreur == 'E') && \ ((*rpl_arguments).erreur != 0)) { __VA_ARGS__; \ (*rpl_arguments).erreur = 0; } } while(0) #define onExecution(...) \ + __CATCH_SYSTEM_ERROR__; \ do { if (((*rpl_arguments).type_erreur == 'E') && \ ((*rpl_arguments).erreur == 0)) { __VA_ARGS__; } } while(0) @@ -377,13 +489,15 @@ -------------------------------------------------------------------------------- */ -#define pushOnStack(object) { \ +#define pushOnStack(object) do { \ + __CATCH_SYSTEM_ERROR__; \ if (((*rpl_arguments).l_base_pile = \ empilement_pile_operationnelle(rpl_arguments, object)) == NULL) \ systemError("Memory allocation error"); \ if ((*object).nombre_occurrences == 1) object = NULL; } while(0) -#define pullFromStack(object, ...) { \ +#define pullFromStack(object, ...) do { \ + __CATCH_SYSTEM_ERROR__; \ (*rpl_arguments).l_base_pile = \ depilement_pile_operationnelle(rpl_arguments, &object); \ if (object == NULL) \ @@ -425,13 +539,13 @@ */ #define then { -#define endIf } -#define elseIf } else if -#define orElse } else { +#define endIf __CATCH_SYSTEM_ERROR__; } +#define elseIf __CATCH_SYSTEM_ERROR__; } else if +#define orElse __CATCH_SYSTEM_ERROR__; } else { // Constantes symboliques -#define createSymbolicConstant(object, type, value) { \ +#define createSymbolicConstant(object, type, value) do { \ if ((strcmp(#type, "integer") != 0) && (strcmp(#type, "real") != 0)) \ systemError("Type not allowed for symbolic constant"); \ __taille_bloc = sizeof(t_8_bits) * 8; \ @@ -441,6 +555,7 @@ if (((*rpl_arguments).drapeaux_etat[__indice_bloc] & __masque) != 0) \ { \ createNameObject(object); \ + __CATCH_SYSTEM_ERROR__; \ { \ char *__constant_name; \ if ((__constant_name = malloc((strlen(__library_name) + \ @@ -457,17 +572,20 @@ if (strcmp(#type, "integer") == 0) \ { \ createIntegerObject(object); \ + __CATCH_SYSTEM_ERROR__; \ setInteger(object, value); \ } \ else if (strcmp(#type, "real") == 0) \ { \ createRealObject(object); \ + __CATCH_SYSTEM_ERROR__; \ setReal(object, value); \ } \ } \ + __CATCH_SYSTEM_ERROR__; \ __constante--; } while(0) -#define createSymbolicComplexConstant(object, rp, ip) { \ +#define createSymbolicComplexConstant(object, rp, ip) do { \ __taille_bloc = sizeof(t_8_bits) * 8; \ __indice_bloc = (35 - 1) / __taille_bloc; \ __indice_bit = (35 - 1) % __taille_bloc; \ @@ -475,6 +593,7 @@ if (((*rpl_arguments).drapeaux_etat[__indice_bloc] & __masque) != 0) \ { \ createNameObject(object); \ + __CATCH_SYSTEM_ERROR__; \ { \ char *__constant_name; \ if ((__constant_name = malloc((strlen(__library_name) + \ @@ -489,13 +608,15 @@ else \ { \ createComplexObject(object); \ + __CATCH_SYSTEM_ERROR__; \ setComplex(object, rp, im); \ } \ + __CATCH_SYSTEM_ERROR__; \ __constante--; } while(0) // Integer -#define setInteger(object, value) { \ +#define setInteger(object, value) do { \ ifIsInteger(object) \ { \ if ((*object).nombre_occurrences > 1) \ @@ -516,12 +637,12 @@ #define ifIsInteger(object) if (isInteger(object)) #define elseIfIsInteger(object) } else ifIsInteger(object) -#define getInteger(object, value) { \ +#define getInteger(object, value) do { \ value = 0; \ ifIsInteger(object) value = (*((integer8 *) (*object).objet)); \ else executionError("Type mismatch error"); } while(0) -#define createIntegerObject(object) { \ +#define createIntegerObject(object) do { \ if (object != NULL) \ systemError("Reallocated object"); \ if ((object = allocation(INT)) == NULL) \ @@ -530,7 +651,7 @@ // Real -#define setReal(object, value) { \ +#define setReal(object, value) do { \ ifIsReal(object) \ { \ if ((*object).nombre_occurrences > 1) \ @@ -551,12 +672,12 @@ #define ifIsReal(object) if (isReal(object)) #define elseIfIsReal(object) } else ifIsReal(object) -#define getReal(object, value) { \ +#define getReal(object, value) do { \ value = 0; \ ifIsReal(object) value = (*((real8 *) (*object).objet)); \ else executionError("Type mismatch error"); } while(0) -#define createRealObject(object) { \ +#define createRealObject(object) do { \ if (object != NULL) \ systemError("Reallocated object"); \ if ((object = allocation(REL)) == NULL) \ @@ -565,7 +686,7 @@ // Complex -#define setComplex(object, rp, ip) { \ +#define setComplex(object, rp, ip) do { \ typeof(rp) __rp = rp; \ typeof(ip) __ip = ip; \ ifIsComplex(object) \ @@ -583,7 +704,7 @@ } \ else executionError("Type mismatch error"); } while(0) -#define setRealPartOfComplex(object, value) { \ +#define setRealPartOfComplex(object, value) do { \ if ((*object).nombre_occurrences > 1) \ { \ struct_objet *__tmp_object; \ @@ -596,7 +717,7 @@ value; \ else executionError("Type mismatch error"); } while(0) -#define setImaginaryPartOfComplex(object, value) { \ +#define setImaginaryPartOfComplex(object, value) do { \ if ((*object).nombre_occurrences > 1) \ { \ struct_objet *__tmp_object; \ @@ -620,13 +741,13 @@ #define ifIsComplex(object) if (isComplex(object)) #define elseIfIsComplex(object) } else ifIsComplex(object) -#define getComplex(object, value) { \ +#define getComplex(object, value) do { \ value.partie_reelle = 0; \ value.partie_imaginaire = 0; \ ifIsComplex(object) value = (*((complex16 *) (*object).objet)); \ else systemError("Not a complex"); } while(0) -#define createComplexObject(object) { \ +#define createComplexObject(object) do { \ if (object != NULL) \ systemError("Reallocated object"); \ if ((object = allocation(CPL)) == NULL) \ @@ -635,7 +756,7 @@ // Generalized vectors -#define createVectorObject(object, size, otype, structure, cat) { \ +#define createVectorObject(object, size, otype, structure, cat) do { \ integer8 i; \ if (object != NULL) \ systemError("Reallocated object"); \ @@ -668,7 +789,7 @@ // Integer vector -#define setIntegerIntoVector(object, value, position) { \ +#define setIntegerIntoVector(object, value, position) do { \ typeof(position) __position = position; \ ifIsIntegerVector(object) \ { \ @@ -696,7 +817,7 @@ #define ifIsIntegerVector(object) if (isIntegerVector(object)) #define elseIfIsIntegerVector(object) } else ifIsIntegerVector(object) -#define getIntegerFromVector(object, value, position) { \ +#define getIntegerFromVector(object, value, position) do { \ typeof(position) __position = position; \ value = 0; \ ifIsIntegerVector(object) \ @@ -716,7 +837,7 @@ // Real vector -#define setRealIntoVector(object, value, position) { \ +#define setRealIntoVector(object, value, position) do { \ typeof(position) __position = position; \ ifIsRealVector(object) \ { \ @@ -744,7 +865,7 @@ #define ifIsRealVector(object) if (isRealVector(object)) #define elseIfIsRealVector(object) } else ifIsRealVector(object) -#define getRealFromVector(object, value, position) { \ +#define getRealFromVector(object, value, position) do { \ typeof(position) __position = position; \ value = 0; \ ifIsRealVector(object) \ @@ -773,7 +894,7 @@ // Binary integer -#define setBinaryInteger(object, value) { \ +#define setBinaryInteger(object, value) do { \ ifIsBinaryInteger(object) \ { \ if ((*object).nombre_occurrences > 1) \ @@ -794,12 +915,12 @@ #define ifIsBinaryInteger(object) if (isBinaryInteger(object)) #define elseIfIsBinaryInteger(object) } else ifIsBinaryInteger(object) -#define getBinaryInteger(object, value) { \ +#define getBinaryInteger(object, value) do { \ value = 0; \ ifIsBinaryInteger(object) value = (*((integer8 *) (*object).objet)); \ else executionError("Type mismatch error"); } while(0) -#define createBinaryIntegerObject(object) { \ +#define createBinaryIntegerObject(object) do { \ if (object != NULL) \ systemError("Reallocated object"); \ if ((object = allocation(BIN)) == NULL) \ @@ -814,7 +935,7 @@ #define ifIsName(object) if (isName(object)) #define elseIfIsName(object) } else if (isName(object)) -#define setName(object, value) { \ +#define setName(object, value) do { \ ifIsName(object) \ { \ if ((*object).nombre_occurrences > 1) \ @@ -835,7 +956,7 @@ } \ else executionError("Type mistmatch error"); } while(0) -#define createNameObject(object) { \ +#define createNameObject(object) do { \ if (object != NULL) \ systemError("Reallocated object"); \ if ((object = allocation(NOM)) == NULL) \ @@ -854,31 +975,34 @@ #define ifIsString(object) if (isString(object)) #define elseIfIsString(object) else if (isString(objet)) -#define setString(object, string) { \ +#define setString(object, string) do { \ ifIsString(object) \ { \ - if ((*object).nombre_occurrences > 1) \ + if (string == NULL) executionError("Nullified string"); else \ { \ - struct_objet *__tmp_object; \ - if ((__tmp_object = copie_objet(object, 'O')) == NULL) \ + if ((*object).nombre_occurrences > 1) \ + { \ + struct_objet *__tmp_object; \ + if ((__tmp_object = copie_objet(object, 'O')) == NULL) \ + systemError("Memory allocation error"); \ + liberation(object); \ + object = __tmp_object; \ + } \ + free((unsigned char *) (*object).objet); \ + if (((*object).objet = malloc((strlen(string) + 1) * \ + sizeof(unsigned char))) == NULL) \ systemError("Memory allocation error"); \ - liberation(object); \ - object = __tmp_object; \ + strcpy((char *) (*object).objet, string); \ } \ - free((unsigned char *) (*object).objet); \ - if (((*object).objet = malloc((strlen(string) + 1) * \ - sizeof(unsigned char))) == NULL) \ - systemError("Memory allocation error"); \ - strcpy((char *) (*object).objet, string); \ } \ else executionError("Type mistmatch error"); } while(0) -#define getString(object, string) { \ +#define getString(object, string) do { \ string = NULL; \ ifIsString(object) string = (char *) (*object).objet; \ else executionError("Type mismatch error"); } while(0) -#define createStringObject(object) { \ +#define createStringObject(object) do { \ if (object != NULL) \ systemError("Reallocated object"); \ if ((object = allocation(CHN)) == NULL) \ @@ -895,14 +1019,14 @@ #define ifIsList(object) if (isList(object)) #define elseIfIsList(object) else if (isList(object)) -#define createListObject(object) { \ +#define createListObject(object) do { \ if (object != NULL) \ systemError("Reallocated object"); \ if ((object = allocation(LST)) == NULL) \ systemError("Memory allocation error"); \ (*object).objet = NULL; } while(0) -#define addObjectToList(list, object) { \ +#define addObjectToList(list, object) do { \ ifIsList(list) \ { \ struct_objet *__tmp_object; \ @@ -935,7 +1059,7 @@ } \ else executionError("Type mistmatch error"); } while(0) -#define insertObjectIntoList(list, object) { \ +#define insertObjectIntoList(list, object) do { \ ifIsList(list) \ { \ struct_objet *__tmp_object; \ @@ -965,21 +1089,35 @@ } \ else executionError("Type mistmatch error"); } while(0) -#define removeObjectFromList(list, object) \ +#define removeObjectFromList(list, object) do { \ ifIsList(list) \ { \ - if ((*object).objet == NULL) \ + if ((*list).objet != NULL) \ { \ - struct_objet *__tmp_object; \ - if ((__tmp_object = copie_objet(list, 'N')) == NULL) \ - systemError("Memory allocation error"); \ - liberation(object); \ - object = __tmp_object; \ - \ - \ - \ - \ - } \ + struct_liste_chainee *__current; \ + struct_liste_chainee *__previous; \ + __current = (*list).objet; \ + __previous = NULL; \ + if ((*__current).donnee == object) \ + { \ + (*list).objet = (*__current).suivant; \ + } \ + else \ + { \ + while(__current != NULL) \ + { \ + if ((*__current).donnee == object) \ + { \ + (*__previous).suivant = (*__current).suivant; \ + break; \ + } \ + __previous = __current; \ + __current = (*__current).suivant; \ + } \ + } \ + liberation((*__current).donnee); \ + free(__current); \ + } \ } \ else executionError("Type mistmatch error"); } while(0) @@ -989,7 +1127,7 @@ #define getListFromList(list, position1, position2, object) -#define listLength(list, length) { \ +#define listLength(list, length) do { \ if (list == NULL) executionError("Nullified object"); \ if ((*list).type != LST) \ executionError("Type mistmatch error"); \ @@ -1004,31 +1142,6 @@ } \ } } while(0) - -/* --------------------------------------------------------------------------------- - Destruction d'un objet --------------------------------------------------------------------------------- -*/ - -#define freeObject(object) \ - { \ - if (object == NULL) \ - systemError("Nullified object"); \ - liberation(object); \ - object = NULL; \ - } while(0) - -/* --------------------------------------------------------------------------------- - Copie d'un objet --------------------------------------------------------------------------------- -*/ - -#define dupObject(object) \ - { if (copie_objet(object, 'P') != object) \ - systemError("Memory allocation error"); } while(0) - /* -------------------------------------------------------------------------------- Allocation mémoire @@ -1050,7 +1163,8 @@ */ #define pollSignalsAndInterrupts() \ - { scrutation_injection((*rpl_arguments).s_etat_processus); } while(0) + __CATCH_SYSTEM_ERROR__; \ + do { scrutation_injection((*rpl_arguments).s_etat_processus); } while(0) /* -------------------------------------------------------------------------------- @@ -1058,8 +1172,9 @@ -------------------------------------------------------------------------------- */ -#define intrinsic(function) { \ +#define intrinsic(function) do { \ int __status; \ + __CATCH_SYSTEM_ERROR__; \ __status = wrapper_instruction_intrinseque( \ instruction_##function, rpl_arguments); \ if (__status == 1) executionError(#function); \ @@ -1068,4 +1183,8 @@ #endif +static struct_rpl_arguments __static_rpl_arguments; +#define __RPL__ struct_rpl_arguments *rpl_arguments; \ + rpl_arguments = &__static_rpl_arguments; + // vim: ts=4