diff --git a/Makefile b/Makefile index 41f2c00..bb88aab 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,3 @@ -# $RCSfile: Makefile,v $ -# $Revision: 1.2 $ -# $Name: $ -# $Date: 2005/06/26 23:04:11 $ -# $Author: agibert $ - #------------------------------------------------------------------------------ # Main Makefile #------------------------------------------------------------------------------ diff --git a/demo/Makefile b/demo/Makefile index 3285430..0130dcc 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -14,12 +14,12 @@ include ../Makefile.rule -DEP_STATIC += ../lib/libshmem.a ../../libnode/lib/libnode.a -DEP_DYNAMIC += ../lib/libshmem.so ../../libnode/lib/libnode.so -INCLUDE += -I . -I ../include -I ../../libnode/include -LIBDIR += -L . -L ../lib -L ../../libnode/lib -LIB_STATIC += ../lib/libshmem.a ../../libnode/lib/libnode.a -ldl -LIB_DYNAMIC += -lshmem -lnode -ldl +DEP_STATIC += ../lib/libshmem.a ../../liblog/lib/liblog.a ../../libnode/lib/libnode.a +DEP_DYNAMIC += ../lib/libshmem.so ../../liblog/lib/liblog.so ../../libnode/lib/libnode.so +INCLUDE += -I . -I ../include -I ../../liblog/include -I ../../libnode/include +LIBDIR += -L . -L ../lib -L ../../liblog/lib -L ../../libnode/lib +LIB_STATIC += ../lib/libshmem.a ../../liblog/lib/liblog.a ../../libnode/lib/libnode.a -ldl +LIB_DYNAMIC += -lshmem -llog -lnode -ldl CFLAGS += -rdynamic ifdef _LIBVER_SUPPORT diff --git a/demo/smdemo0.c b/demo/smdemo0.c index bb518f7..db6c430 100644 --- a/demo/smdemo0.c +++ b/demo/smdemo0.c @@ -1,14 +1,9 @@ -/*---------------------------------------------------------------------------------*/ -/* $RCSfile: smdemo0.c,v $ */ -/*---------------------------------------------------------------------------------*/ -/* $Revision: 1.1 $ */ -/* $Name: $ */ -/* $Date: 2005/06/26 23:16:38 $ */ -/* $Author: agibert $ */ -/*---------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* smdemo0.c */ +/*----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/ -/* This file is a program test of libshmem */ +/* This file is part of LibShMem */ /* */ /* LibShMem is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU Lesser General Public Licence as published by */ @@ -25,6 +20,8 @@ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /*---------------------------------------------------------------------------------*/ + + #include #include #include diff --git a/include/shmem.h b/include/shmem.h index e337556..4e853a2 100644 --- a/include/shmem.h +++ b/include/shmem.h @@ -1,33 +1,30 @@ -/*---------------------------------------------------------------------------------*/ -/* $RCSfile: shmem.h,v $ */ -/*---------------------------------------------------------------------------------*/ -/* $Revision: 2.3 $ */ -/* $Name: $ */ -/* $Date: 2005/06/26 23:07:40 $ */ -/* $Author: agibert $ */ -/*---------------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------------*/ -/* This file is part of LibShMem */ -/* */ -/* LibShMem is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public Licence as published by */ -/* the Free Software Foundation; either version 2.1 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* LibShMem is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with LibShMem; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/*---------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* shmem.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* This file is part of LibShMem */ +/* */ +/* LibShMem is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU Lesser General Public License as published */ +/* by the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* LibShMem is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU Lesser General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with Drummer. If not, see */ +/* . */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* Includes */ +/*----------------------------------------------------------------------------*/ #ifndef _LIBSM #define _LIBSM @@ -38,11 +35,34 @@ #include #include + +#include #include + + + +/*----------------------------------------------------------------------------*/ +/* Definitions */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* SMD_API definition */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBSHMEM_C_ +# define SMD_API +# define SMD_DATA +# else +# define SMD_API extern +# define SMD_DATA extern +# endif + + + /* Code retour des fonctions constituant l'API */ typedef long SMT_Status; @@ -142,11 +162,8 @@ typedef int SMT_Config; -#ifdef _LIBSHMEM_C_ - char SM_Error_Msg [512]; -#else - extern char SM_Error_Msg [512]; -#endif +SMD_DATA char SM_Error_Msg [512]; + /*------------------------------------------------------------------------------*/ @@ -168,11 +185,8 @@ typedef int SMT_Config; /* Référence sur la base de heaps */ -#ifdef _LIBSHMEM_C_ - SMT_Base * SM_Base; -#else - extern SMT_Base * SM_Base; -#endif +SMD_DATA SMT_Base * SM_Base; + @@ -296,8 +310,8 @@ typedef struct { /* (I) Context : nom du nouveau contexte */ /* (I) Flags : indicateur création/ouverture + mode d'affichage des erreurs */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Library_Open_I ( int Instance, const char * Context, SMT_Flags Flags ); - SMT_Status SM_Library_Open_C ( int Instance, const char * Context, SMT_Flags Flags ); +SMD_API SMT_Status SM_Library_Open_I ( int Instance, const char * Context, SMT_Flags Flags ); +SMD_API SMT_Status SM_Library_Open_C ( int Instance, const char * Context, SMT_Flags Flags ); @@ -306,8 +320,8 @@ typedef struct { /*------------------------------------------------------------------------------*/ /* (O) Instance : adresse du numéro de l'instance utilisée */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Library_Instance_Get_I ( int * Instance); - SMT_Status SM_Library_Instance_Get_C ( int * Instance); +SMD_API SMT_Status SM_Library_Instance_Get_I ( int * Instance); +SMD_API SMT_Status SM_Library_Instance_Get_C ( int * Instance); @@ -316,8 +330,8 @@ typedef struct { /*------------------------------------------------------------------------------*/ /* (I) Context : nom du nouveau contexte */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Library_Context_Set_I ( const char * Context ); - SMT_Status SM_Library_Context_Set_C ( const char * Context ); +SMD_API SMT_Status SM_Library_Context_Set_I ( const char * Context ); +SMD_API SMT_Status SM_Library_Context_Set_C ( const char * Context ); @@ -326,8 +340,8 @@ typedef struct { /*------------------------------------------------------------------------------*/ /* (O) Context : adresse du nom du contexte utilisé */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Library_Context_Get_I ( char ** Context ); - SMT_Status SM_Library_Context_Get_C ( char ** Context ); +SMD_API SMT_Status SM_Library_Context_Get_I ( char ** Context ); +SMD_API SMT_Status SM_Library_Context_Get_C ( char ** Context ); @@ -336,8 +350,8 @@ typedef struct { /*------------------------------------------------------------------------------*/ /* (I) Flags : mode de fermeture (destruction ou fermeture simple) */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Library_Close_I ( SMT_Flags Flags ); - SMT_Status SM_Library_Close_C ( SMT_Flags Flags ); +SMD_API SMT_Status SM_Library_Close_I ( SMT_Flags Flags ); +SMD_API SMT_Status SM_Library_Close_C ( SMT_Flags Flags ); @@ -346,24 +360,24 @@ typedef struct { /*------------------------------------------------------------------------------*/ /* (I) Out : pointeur sur le flux de sortie */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Library_Dump_I ( FILE * Out ); - SMT_Status SM_Library_Dump_C ( FILE * Out ); +SMD_API SMT_Status SM_Library_Dump_I ( FILE * Out ); +SMD_API SMT_Status SM_Library_Dump_C ( FILE * Out ); /*------------------------------------------------------------------------------*/ /* Libération de tous les verrous (base, heap) */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Library_Unlock_I ( void ); - SMT_Status SM_Library_Unlock_C ( void ); +SMD_API SMT_Status SM_Library_Unlock_I ( void ); +SMD_API SMT_Status SM_Library_Unlock_C ( void ); /*------------------------------------------------------------------------------*/ /* Définition de la sortie standard des messages d'erreur de la librairie */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Library_Stderr_Set_I ( FILE * Out ); - SMT_Status SM_Library_Stderr_Set_C ( FILE * Out ); +SMD_API SMT_Status SM_Library_Stderr_Set_I ( FILE * Out ); +SMD_API SMT_Status SM_Library_Stderr_Set_C ( FILE * Out ); @@ -372,8 +386,8 @@ typedef struct { /*------------------------------------------------------------------------------*/ /* (I) Heap_Name : nom du heap */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_Exist_I ( const char * Heap_Name ); - SMT_Status SM_Heap_Exist_C ( const char * Heap_Name ); +SMD_API SMT_Status SM_Heap_Exist_I ( const char * Heap_Name ); +SMD_API SMT_Status SM_Heap_Exist_C ( const char * Heap_Name ); @@ -386,8 +400,8 @@ typedef struct { /* (I) Flags : mode d'ouverture du heap */ /* (O) Locked : verrou effectif (TRUE ou FALSE) */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_Open_I ( const char * Heap_Name, SMT_Heap ** Heap, size_t Seg_Size, SMT_Flags Flags, int * Locked ); - SMT_Status SM_Heap_Open_C ( const char * Heap_Name, SMT_Heap ** Heap, size_t Seg_Size, SMT_Flags Flags, int * Locked ); +SMD_API SMT_Status SM_Heap_Open_I ( const char * Heap_Name, SMT_Heap ** Heap, size_t Seg_Size, SMT_Flags Flags, int * Locked ); +SMD_API SMT_Status SM_Heap_Open_C ( const char * Heap_Name, SMT_Heap ** Heap, size_t Seg_Size, SMT_Flags Flags, int * Locked ); @@ -397,8 +411,8 @@ typedef struct { /* (I) Heap_Name : nom du heap */ /* (O) Heap : adresse du pointeur sur le heap ouvert */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_IsOpen_I ( const char * Heap_Name, SMT_Heap ** Heap ); - SMT_Status SM_Heap_IsOpen_C ( const char * Heap_Name, SMT_Heap ** Heap ); +SMD_API SMT_Status SM_Heap_IsOpen_I ( const char * Heap_Name, SMT_Heap ** Heap ); +SMD_API SMT_Status SM_Heap_IsOpen_C ( const char * Heap_Name, SMT_Heap ** Heap ); @@ -407,8 +421,8 @@ typedef struct { /*------------------------------------------------------------------------------*/ /* (I) Heap : pointeur sur un heap ouvert */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_Close_I ( SMT_Heap * Heap ); - SMT_Status SM_Heap_Close_C ( SMT_Heap * Heap ); +SMD_API SMT_Status SM_Heap_Close_I ( SMT_Heap * Heap ); +SMD_API SMT_Status SM_Heap_Close_C ( SMT_Heap * Heap ); @@ -417,8 +431,8 @@ typedef struct { /*------------------------------------------------------------------------------*/ /* (I) Heap_Name : nom du heap */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_End_I ( const char * Heap_Name ); - SMT_Status SM_Heap_End_C ( const char * Heap_Name ); +SMD_API SMT_Status SM_Heap_End_I ( const char * Heap_Name ); +SMD_API SMT_Status SM_Heap_End_C ( const char * Heap_Name ); @@ -428,8 +442,8 @@ typedef struct { /* (I) Heap : pointeur sur un heap ouvert */ /* (O) Compress : pointeur sur la taille mémoire gagnée */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_Compress_I ( SMT_Heap * Heap, size_t * Compress ); - SMT_Status SM_Heap_Compress_C ( SMT_Heap * Heap, size_t * Compress ); +SMD_API SMT_Status SM_Heap_Compress_I ( SMT_Heap * Heap, size_t * Compress ); +SMD_API SMT_Status SM_Heap_Compress_C ( SMT_Heap * Heap, size_t * Compress ); @@ -439,8 +453,8 @@ typedef struct { /* (I) Heap : pointeur sur un heap ouvert */ /* (I) Tag : type de configuration */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_Config_I ( SMT_Heap * Heap, SMT_Config Tag, ... ); - SMT_Status SM_Heap_Config_C ( SMT_Heap * Heap, SMT_Config Tag, ... ); +SMD_API SMT_Status SM_Heap_Config_I ( SMT_Heap * Heap, SMT_Config Tag, ... ); +SMD_API SMT_Status SM_Heap_Config_C ( SMT_Heap * Heap, SMT_Config Tag, ... ); @@ -452,8 +466,8 @@ typedef struct { /* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */ /* (I) Out : pointeur sur le flux de sortie du rapport */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Corrected, FILE * Out); - SMT_Status SM_Heap_Check_C ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Corrected, FILE * Out); +SMD_API SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Corrected, FILE * Out); +SMD_API SMT_Status SM_Heap_Check_C ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Corrected, FILE * Out); @@ -464,8 +478,8 @@ typedef struct { /* (I) Flags : mode de verrouillage (SMD_READ ou SMD_WRITE) */ /* (O) Locked : verrouillage effectué (TRUE ou FALSE) */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Flags, int * Locked ); - SMT_Status SM_Heap_Lock_C ( SMT_Heap * Heap, SMT_Flags Flags, int * Locked ); +SMD_API SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Flags, int * Locked ); +SMD_API SMT_Status SM_Heap_Lock_C ( SMT_Heap * Heap, SMT_Flags Flags, int * Locked ); @@ -474,8 +488,8 @@ typedef struct { /*------------------------------------------------------------------------------*/ /* (I) Heap : pointeur sur un heap ouvert */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Heap_Unlock_I ( SMT_Heap * Heap ); - SMT_Status SM_Heap_Unlock_C ( SMT_Heap * Heap ); +SMD_API SMT_Status SM_Heap_Unlock_I ( SMT_Heap * Heap ); +SMD_API SMT_Status SM_Heap_Unlock_C ( SMT_Heap * Heap ); @@ -486,8 +500,8 @@ typedef struct { /* (I) Size : taille du chunk */ /* (O) Ptr : pointeur sur la zone de données allouée */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ); - SMT_Status SM_Chunk_Alloc_C ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ); +SMD_API SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ); +SMD_API SMT_Status SM_Chunk_Alloc_C ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ); @@ -497,8 +511,8 @@ typedef struct { /* (I) Heap : pointeur sur un heap ouvert */ /* (I) Ptr : adresse de la zone de données du chunk à désallouer */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr ); - SMT_Status SM_Chunk_Free_C ( SMT_Heap * Heap, void * Ptr ); +SMD_API SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr ); +SMD_API SMT_Status SM_Chunk_Free_C ( SMT_Heap * Heap, void * Ptr ); diff --git a/lib/Makefile b/lib/Makefile index ef12fbd..5de7e9b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -9,8 +9,8 @@ include ../Makefile.rule -DEP += libshmem.h ../include/shmem.h ../../libnode/include/node.h Makefile -INCLUDE += -I . -I ../include -I ../../libnode/include +DEP += libshmem.h ../include/shmem.h ../../liblog/include/log.h ../../libnode/include/node.h Makefile +INCLUDE += -I . -I ../include -I ../../liblog/include -I ../../libnode/include ifdef _LIBVER_SUPPORT DEP += ../../libver/ver.h diff --git a/lib/libshmem.c b/lib/libshmem.c index 724a67d..e0e6700 100644 --- a/lib/libshmem.c +++ b/lib/libshmem.c @@ -1,29 +1,24 @@ -/*---------------------------------------------------------------------------------*/ -/* $RCSfile: libshmem.c,v $ */ -/*---------------------------------------------------------------------------------*/ -/* $Revision: 2.4 $ */ -/* $Name: $ */ -/* $Date: 2005/06/26 23:40:14 $ */ -/* $Author: agibert $ */ -/*---------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* libshmem.c */ +/*----------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------------*/ -/* This file is part of LibShMem */ -/* */ -/* LibShMem is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public Licence as published by */ -/* the Free Software Foundation; either version 2.1 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* LibShMem is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with LibShMem; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/*---------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* This file is part of LibShMem */ +/* */ +/* LibShMem is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU Lesser General Public License as published */ +/* by the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* LibShMem is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU Lesser General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with Drummer. If not, see */ +/* . */ +/*----------------------------------------------------------------------------*/ @@ -35,9 +30,16 @@ #include -#ifdef _LIBVER_SUPPORT -VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agibert $") -#endif +//#ifdef _LIBVER_SUPPORT +//VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agibert $") +//#endif + + + + + + + /*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/ @@ -49,6 +51,8 @@ VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agib /* FONCTIONS OPTIMISEES (SM_MODE = 1) */ /*------------------------------------------------------------------------------*/ + + /*------------------------------------------------------------------------------*/ /* Ouverture d'une instance de la librairie */ /*------------------------------------------------------------------------------*/ @@ -57,9 +61,10 @@ VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agib /* (I) Open_Mode : indicateur création/ouverture + mode d'affichage des erreurs */ /*------------------------------------------------------------------------------*/ - SMT_Status SM_Library_Open_I( int Instance, const char *Context, SMT_Flags Open_Mode) +SMT_Status SM_Library_Open_I( int Instance, const char *Context, SMT_Flags Open_Mode) { SMT_Status rc; + LGT_Status lg_status; int ND_Debug = FALSE; int To_Open_Instance; NDT_Index_Type index_type = ( NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED); @@ -70,6 +75,13 @@ VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agib if( SMD_DEBUG_MSK( Open_Mode)) SM_stderr = stderr; if( Open_Mode & SMD_DEBUG_ALL) ND_Debug = TRUE; + if( ( lg_status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, true)) != LGS_OK) + { + fprintf( stderr, "Can't open LibLog library: (%d)\n", lg_status); + return( -1); + } + + /* Définition de l'instance à ouvrir */ @@ -132,7 +144,7 @@ VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agib if( SM_Open_Counter > 0 && To_Open_Instance != SM_Instance) { sprintf( SM_Error_Msg, "SM_Library_Open : the current process cannot open instance %d because it is already accessing instance %d", To_Open_Instance, SM_Instance); - SM_Error_Print (); + SM_Error_Print(); return( SMS_ERRAPI); } @@ -220,7 +232,7 @@ SMT_Status SM_Library_Instance_Get_I( int *Instance) /* (O) Context : adresse du nom du contexte utilisé */ /*------------------------------------------------------------------------------*/ -SMT_Status SM_Library_Context_Get_I ( char **Context) +SMT_Status SM_Library_Context_Get_I( char **Context) { *Context = SM_Context; @@ -249,11 +261,11 @@ SMT_Status SM_Library_Context_Set_I( const char *Context ) { if( getenv( CONTEXT_ENV_VAR) && strlen ( getenv( CONTEXT_ENV_VAR))) { - SM_Context = strdup (getenv (CONTEXT_ENV_VAR)); + SM_Context = strdup( getenv (CONTEXT_ENV_VAR)); } else { - SM_Context = strdup (DEFAULT_CONTEXT); + SM_Context = strdup( DEFAULT_CONTEXT); } } @@ -273,6 +285,7 @@ SMT_Status SM_Library_Context_Set_I( const char *Context ) SMT_Status SM_Library_Close_I( SMT_Flags Close_Mode) { SMT_Status rc; + LGT_Status lg_status; if( Close_Mode & SMD_DESTROY) /* Destruction de l'instance */ @@ -343,7 +356,13 @@ SMT_Status SM_Library_Close_I( SMT_Flags Close_Mode) SM_Open_Counter--; } - + + if( ( lg_status = LG_Library_Close( true)) != LGS_OK) + { + fprintf( stderr, "Can't close LibLog library: (%d)\n", lg_status); + return( SMS_KO); + } + return( SMS_OK); } @@ -596,8 +615,8 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Open : unable to open one of the data segments of heap \"%s\"", prefixed_name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Open : unable to open one of the data segments of heap \"%s\"", prefixed_name); + SM_Error_Print(); goto Error1; } @@ -642,8 +661,6 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se } } - fprintf( stderr, "Heap not Open!!!\n"); - if( !( Open_Mode & SMD_CREATE)) { @@ -653,8 +670,6 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se return( SMS_ERRAPI); } - fprintf( stderr, "Heap to be created!!!\n"); - /*Alloc du MHH qui fait l'alloccation du premier segment de donnees*/ rc = ND_Value_Alloc( (void **)&MHH, SM_Base->MHR, prefixed_name, Seg_Size); @@ -832,8 +847,8 @@ SMT_Status SM_Heap_End_I ( const char * Heap_Name ) if( SM_ERROR(rc)) return rc; if( rc == SMS_NO) { - sprintf (SM_Error_Msg, "SM_Heap_End: heap \"%s\" does not exist", Heap_Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_End: heap \"%s\" does not exist", Heap_Name); + SM_Error_Print(); return SMS_KO; } @@ -853,8 +868,8 @@ SMT_Status SM_Heap_End_I ( const char * Heap_Name ) rc = SM_Heap_Open_I (Heap_Name, &Heap, 0, SMD_OPEN | SMD_WRITE, &Locked); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_End : unable to open the heap to remove for writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_End : unable to open the heap to remove for writing"); + SM_Error_Print(); return rc; } @@ -865,8 +880,8 @@ SMT_Status SM_Heap_End_I ( const char * Heap_Name ) rc = ND_DataStruct_Value_Remove( SM_Base->MHR, Heap->MHH); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_End: unable to remove heap \"%s\" from the MHR structure", Heap_Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_End: unable to remove heap \"%s\" from the MHR structure", Heap_Name); + SM_Error_Print(); return rc; } @@ -874,8 +889,8 @@ SMT_Status SM_Heap_End_I ( const char * Heap_Name ) rc = ND_Value_Free( SM_Base->MHR, Heap->MHH); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_End: unable to free heap \"%s\"", Heap_Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_End: unable to free heap \"%s\"", Heap_Name); + SM_Error_Print(); return rc; } @@ -947,10 +962,11 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) { /* Rien à faire : le heap est déjà verrouillé dans ce mode */ - fprintf( stderr, "Already locked !!!\n"); - fflush( stderr); + fprintf( stderr, "SM_Heap_Lock: heap [%s] already locked in mode: (%d)!\n", Heap->Name, Lock_Mode); + fflush( stderr); *Locked = FALSE; +// *Locked = TRUE; } else if( Heap->Lock_Mode == SMD_NO_LOCK) { @@ -965,7 +981,7 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) if( Heap->MHH->State == SMD_STATE_CORRUPTED) { sprintf( SM_Error_Msg, "SM_Heap_Lock : heap \"%s\" is flagged as being corrupted", Heap->Name); - SM_Error_Print (); + SM_Error_Print(); return SMS_KO; } @@ -975,8 +991,8 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) rc = SM_Heap_Lock_Set( Heap->MHH, Lock_Mode); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to lock heap \"%s\" for %s", Heap->Name, Lock_Mode & SMD_READ ? "reading" : "writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : unable to lock heap \"%s\" for %s", Heap->Name, Lock_Mode & SMD_READ ? "reading" : "writing"); + SM_Error_Print(); return rc; } @@ -992,8 +1008,8 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) rc = SM_Heap_Lock_Change( Heap->MHH, SMD_WRITE); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to lock heap \"%s\" for writing before checking", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : unable to lock heap \"%s\" for writing before checking", Heap->Name); + SM_Error_Print(); SM_Heap_Unlock_I (Heap); return rc; @@ -1006,8 +1022,8 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) rc = SM_Heap_Check_I (Heap, &Nb_Detected, &Nb_Corrected, SM_stderr); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to check heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : unable to check heap \"%s\"", Heap->Name); + SM_Error_Print(); SM_Heap_Unlock_I (Heap); return rc; @@ -1020,8 +1036,8 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) rc = SM_Heap_Lock_Change (Heap->MHH, SMD_READ); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to lock heap \"%s\" for reading", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : unable to lock heap \"%s\" for reading", Heap->Name); + SM_Error_Print(); SM_Heap_Unlock_I (Heap); return rc; @@ -1038,8 +1054,8 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) if( SM_Heap_IsOpen_I( "system", &heap_ptr) != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : Internal Error 1 !"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : Internal Error 1 !"); + SM_Error_Print(); } else { @@ -1049,8 +1065,8 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) if( node_ptr == NULL) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : Internal Error 2 !"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : Internal Error 2 !"); + SM_Error_Print(); } else { @@ -1058,14 +1074,14 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) { if( ( rc = SM_DataSegment_Open( node_ptr->Value)) != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to open one of the data segments of heap \"%s\"", + sprintf( SM_Error_Msg, "SM_Heap_Lock : unable to open one of the data segments of heap \"%s\"", ( (SMT_MHH *)(node_ptr->Value))->Name); - SM_Error_Print (); + SM_Error_Print(); } else { -// sprintf (SM_Error_Msg, "SM_Heap_Lock : Opening Segment (%x)", node_ptr->Value); -// SM_Error_Print (); +// sprintf( SM_Error_Msg, "SM_Heap_Lock : Opening Segment (%x)", node_ptr->Value); +// SM_Error_Print(); } ND_Index_Node_Next_Get( &node_ptr, node_ptr); @@ -1089,8 +1105,8 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) rc = SM_DataSegment_Open (Node->Value); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to open one of the data segments of heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : unable to open one of the data segments of heap \"%s\"", Heap->Name); + SM_Error_Print(); SM_Heap_Unlock_I (Heap); return rc; @@ -1112,8 +1128,8 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) rc = SM_Heap_Lock_Change (Heap->MHH, Lock_Mode); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to change lock of heap \"%s\" for %s", Heap->Name, Lock_Mode & SMD_READ ? "reading" : "writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : unable to change lock of heap \"%s\" for %s", Heap->Name, Lock_Mode & SMD_READ ? "reading" : "writing"); + SM_Error_Print(); return rc; } @@ -1139,19 +1155,23 @@ SMT_Status SM_Heap_Unlock_I ( SMT_Heap * Heap) { SMT_Status rc; + + sprintf( SM_Error_Msg, "SM_Heap_UnLock: heap [%s] lock_mode: (%d)...", Heap->Name, Heap->Lock_Mode); + SM_Error_Print(); + rc = SM_Heap_Lock_Release (Heap->MHH, Heap->Lock_Mode); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Unlock : unable to unlock heap \"%s\" for %s", + sprintf( SM_Error_Msg, "SM_Heap_Unlock : unable to unlock heap \"%s\" for %s", Heap->Name, Heap->Lock_Mode & SMD_READ ? "reading" : "writing"); - SM_Error_Print (); + SM_Error_Print(); - return rc; + return( rc); } Heap->Lock_Mode = SMD_NO_LOCK; - return SMS_OK; + return( SMS_OK); } @@ -1203,8 +1223,8 @@ SMT_Status SM_Heap_Config_I ( SMT_Heap * Heap, SMT_Config Tag, ... ) if( Current_Size > Size) { - sprintf (SM_Error_Msg, "SM_Heap_Config : the heap has already exceeded the limit size (%d bytes)", Current_Size); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Config : the heap has already exceeded the limit size (%d bytes)", Current_Size); + SM_Error_Print(); va_end (Arguments); return SMS_ERRAPI; @@ -1216,8 +1236,8 @@ SMT_Status SM_Heap_Config_I ( SMT_Heap * Heap, SMT_Config Tag, ... ) break; default : - sprintf (SM_Error_Msg, "SM_Heap_Config : unknown config tag %d", Tag); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Config : unknown config tag %d", Tag); + SM_Error_Print(); va_end (Arguments); return SMS_ERRAPI; @@ -1288,16 +1308,16 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc SMT_Status rc; NDT_Node * Node; - if( Out) fprintf (Out, "Checking heap \"%s\" ...\n", Heap->Name); + if( Out) fprintf( Out, "Checking heap \"%s\" ...\n", Heap->Name); if( Heap->MHH->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number == 0) { - sprintf (SM_Error_Msg, "SM_Heap_Check : unable to check heap \"%s\" which has no data segment", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Check : unable to check heap \"%s\" which has no data segment", Heap->Name); + SM_Error_Print(); (*Nb_Detected) ++; - if( Out) fprintf (Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); + if( Out) fprintf( Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); Heap->MHH->State = SMD_STATE_CORRUPTED; return SMS_ERRAPI; @@ -1306,22 +1326,22 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc { /* Vérification de la structure DSR du heap */ - if( Out) fprintf (Out, "Checking the DSR node structure ...\n"); + if( Out) fprintf( Out, "Checking the DSR node structure ...\n"); rc = ND_DataStruct_Check (Heap->MHH->DSR, Nb_Detected, Nb_Corrected, Out); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Check : unable to check the DSR structure"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Check : unable to check the DSR structure"); + SM_Error_Print(); - if( Out) fprintf (Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); + if( Out) fprintf( Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); Heap->MHH->State = SMD_STATE_CORRUPTED; return rc; } } - fprintf (Out, "Trying to open every data segment of the heap ...\n"); + fprintf( Out, "Trying to open every data segment of the heap ...\n"); /* Ouverture des segments du heap au cas ça n'aurait pas été fait */ @@ -1332,12 +1352,12 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc rc = SM_DataSegment_Open (Node->Value); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Check : unable to open one of the data segments of heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Check : unable to open one of the data segments of heap \"%s\"", Heap->Name); + SM_Error_Print(); (*Nb_Detected) ++; - if( Out) fprintf (Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); + if( Out) fprintf( Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); Heap->MHH->State = SMD_STATE_CORRUPTED; return rc; @@ -1348,15 +1368,15 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc /* Vérification de la structure ACR du heap */ - if( Out) fprintf (Out, "Checking the ACR node structure ...\n"); + if( Out) fprintf( Out, "Checking the ACR node structure ...\n"); rc = ND_DataStruct_Check (Heap->MHH->ACR, Nb_Detected, Nb_Corrected, Out); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Check : unable to check the ACR node structure"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Check : unable to check the ACR node structure"); + SM_Error_Print(); - if( Out) fprintf (Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); + if( Out) fprintf( Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); Heap->MHH->State = SMD_STATE_CORRUPTED; return rc; @@ -1364,15 +1384,15 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc /* Vérification de la structure FCR du heap */ - if( Out) fprintf (Out, "Checking the FCR node structure ...\n"); + if( Out) fprintf( Out, "Checking the FCR node structure ...\n"); rc = ND_DataStruct_Check (Heap->MHH->FCR, Nb_Detected, Nb_Corrected, Out); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Check : unable to check the ACR node structure"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Check : unable to check the ACR node structure"); + SM_Error_Print(); - if( Out) fprintf (Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); + if( Out) fprintf( Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); Heap->MHH->State = SMD_STATE_CORRUPTED; return rc; @@ -1384,7 +1404,7 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc { /* On déclare le heap corrompu afin que plus personne n'y accède */ - if( Out) fprintf (Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); + if( Out) fprintf( Out, "%d error(s) could not be corrected in heap \"%s\" which will be declared as corrupted.\n Please contact an administrator about it.\n", *Nb_Detected - *Nb_Corrected, Heap->Name); Heap->MHH->State = SMD_STATE_CORRUPTED; @@ -1395,11 +1415,11 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc if( *Nb_Detected == 0) { - if( Out) fprintf (Out, "No error detected on heap \"%s\" which will be declared as a valid heap\n", Heap->Name); + if( Out) fprintf( Out, "No error detected on heap \"%s\" which will be declared as a valid heap\n", Heap->Name); } else { - if( Out) fprintf (Out, "Every %d error(s) have beeen corrected on heap \"%s\" which will be declared as a valid heap\n", *Nb_Corrected, Heap->Name); + if( Out) fprintf( Out, "Every %d error(s) have beeen corrected on heap \"%s\" which will be declared as a valid heap\n", *Nb_Corrected, Heap->Name); } Heap->MHH->State = SMD_STATE_VALID; @@ -1489,8 +1509,8 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ) rc = ND_Value_Alloc( (void**)&DSH, Heap->MHH->DSR, Heap->MHH, Seg_Size); if( rc != NDS_OK ) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : unable to create a new data segment for heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : unable to create a new data segment for heap \"%s\"", Heap->Name); + SM_Error_Print(); return SMS_ERRSHM; } @@ -1498,8 +1518,8 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ) rc = ND_DataStruct_Value_Add (Heap->MHH->DSR, DSH); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : unable to add a data segment to the DSR structure of heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : unable to add a data segment to the DSR structure of heap \"%s\"", Heap->Name); + SM_Error_Print(); ND_Value_Free(Heap->MHH->DSR, DSH); @@ -1521,8 +1541,8 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ) rc = ND_Index_Node_Remove (Node); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : unable to remove a chunk from the FCR structure of heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : unable to remove a chunk from the FCR structure of heap \"%s\"", Heap->Name); + SM_Error_Print(); return rc; } @@ -1532,8 +1552,8 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ) rc = ND_Index_Node_Add( Heap->MHH->ACR, NDD_INDEX_PRIMARY, Node); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : unable to add a chunk to the ACR structure of heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : unable to add a chunk to the ACR structure of heap \"%s\"", Heap->Name); + SM_Error_Print(); /* On tente de revenir en arrière */ @@ -1584,8 +1604,8 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ) rc = ND_Index_Node_Add( Heap->MHH->FCR, NDD_INDEX_PRIMARY, New_Node); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : unable to add a chunk to the FCR structure of heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : unable to add a chunk to the FCR structure of heap \"%s\"", Heap->Name); + SM_Error_Print(); return rc; } @@ -1670,8 +1690,8 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ) rc = ND_Value_Alloc( (void**)&DSH, Heap->MHH->DSR, Heap->MHH, Heap->MHH->Segment_Size); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : unable to create un new data segment for the system heap (anticipation)"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : unable to create un new data segment for the system heap (anticipation)"); + SM_Error_Print(); return SMS_ERRSHM; } @@ -1683,8 +1703,8 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr ) rc = ND_Index_Node_Add( Heap->MHH->DSR, NDD_INDEX_PRIMARY, New_Node); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : unable to add a data segment to the DSR structure of the system heap (anticipation)"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : unable to add a data segment to the DSR structure of the system heap (anticipation)"); + SM_Error_Print(); ND_Value_Free( Heap->MHH->DSR, DSH); @@ -1746,8 +1766,8 @@ SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr) rc = ND_Index_Node_Remove (Node); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Chunk_Free : unable to remove the allocated chunk from the ACR structure of heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Free : unable to remove the allocated chunk from the ACR structure of heap \"%s\"", Heap->Name); + SM_Error_Print(); return rc; } @@ -1757,8 +1777,8 @@ SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr) rc = ND_Index_Node_Add( Heap->MHH->FCR, NDD_INDEX_PRIMARY, Node); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Chunk_Free : unable to add the free chunk to the FCR structure of heap \"%s\"", Heap->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Free : unable to add the free chunk to the FCR structure of heap \"%s\"", Heap->Name); + SM_Error_Print(); /* Retour arrière */ @@ -1784,8 +1804,8 @@ SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr) rc = SM_Heap_Compress (Heap, &Compress_Size); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Chunk_Free : unable to compress FCR structure of heap \"%s\" which contains %ld free chunks", Heap->Name, Heap->MHH->FCR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Free : unable to compress FCR structure of heap \"%s\" which contains %ld free chunks", Heap->Name, Heap->MHH->FCR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + SM_Error_Print(); return rc; } } @@ -1873,8 +1893,8 @@ SMT_Status SM_Library_Close_C ( SMT_Flags Close_Mode ) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Library_Close : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Library_Close : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -1894,8 +1914,8 @@ SMT_Status SM_Library_Dump_C (FILE * Out) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Library_Dump : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Library_Dump : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -1914,8 +1934,8 @@ SMT_Status SM_Library_Unlock_C ( void ) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Library_Unlock : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Library_Unlock : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -1949,15 +1969,15 @@ SMT_Status SM_Heap_Exist_C ( const char * Heap_Name ) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_Exist : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Exist : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap_Name) { - sprintf (SM_Error_Msg, "SM_Heap_Exist : the heap name is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Exist : the heap name is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -1982,16 +2002,16 @@ SMT_Status SM_Heap_Open_C ( const char * Heap_Name, SMT_Heap ** Heap, size_t Seg { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_Open : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Open : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap_Name) { - sprintf (SM_Error_Msg, "SM_Heap_Open : the heap name is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Open : the heap name is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2013,16 +2033,16 @@ SMT_Status SM_Heap_IsOpen_C ( const char * Heap_Name, SMT_Heap ** Heap ) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_IsOpen : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_IsOpen : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap_Name) { - sprintf (SM_Error_Msg, "SM_Heap_IsOpen : the heap name is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_IsOpen : the heap name is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2043,16 +2063,16 @@ SMT_Status SM_Heap_End_C ( const char * Heap_Name ) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_End : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_End : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap_Name) { - sprintf (SM_Error_Msg, "SM_Heap_End : the heap name is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_End : the heap name is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2073,16 +2093,16 @@ SMT_Status SM_Heap_Close_C ( SMT_Heap * Heap ) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_Close : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Close : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap) { - sprintf (SM_Error_Msg, "SM_Heap_Close : the heap is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Close : the heap is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2105,16 +2125,16 @@ SMT_Status SM_Heap_Lock_C ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked ) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap) { - sprintf (SM_Error_Msg, "SM_Heap_Lock : the heap is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock : the heap is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2135,16 +2155,16 @@ SMT_Status SM_Heap_Unlock_C ( SMT_Heap * Heap ) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_Unlock : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Unlock : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap) { - sprintf (SM_Error_Msg, "SM_Heap_Unlock : the heap is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Unlock : the heap is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2171,16 +2191,16 @@ SMT_Status SM_Heap_Config_C ( SMT_Heap * Heap, SMT_Config Tag, ... ) if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_Config : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Config : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap) { - sprintf (SM_Error_Msg, "SM_Heap_Config : the heap is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Config : the heap is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2209,8 +2229,8 @@ SMT_Status SM_Heap_Config_C ( SMT_Heap * Heap, SMT_Config Tag, ... ) if( Current_Size > Limit_Size) { - sprintf (SM_Error_Msg, "SM_Heap_Config : the heap has already exceeded the limit size (%d bytes)", Current_Size); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Config : the heap has already exceeded the limit size (%d bytes)", Current_Size); + SM_Error_Print(); va_end (Arguments); return SMS_ERRAPI; @@ -2222,8 +2242,8 @@ SMT_Status SM_Heap_Config_C ( SMT_Heap * Heap, SMT_Config Tag, ... ) break; default : - sprintf (SM_Error_Msg, "SM_Heap_Config : unknown config tag %d", Tag); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Config : unknown config tag %d", Tag); + SM_Error_Print(); va_end (Arguments); return SMS_ERRAPI; @@ -2249,23 +2269,23 @@ SMT_Status SM_Heap_Compress_C ( SMT_Heap * Heap, size_t * Compress ) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_Compress : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Compress : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap) { - sprintf (SM_Error_Msg, "SM_Heap_Compress : the heap is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Compress : the heap is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Compress) { - sprintf (SM_Error_Msg, "SM_Heap_Compress : the compress size pointer is null"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Compress : the compress size pointer is null"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2289,30 +2309,30 @@ SMT_Status SM_Heap_Check_C ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Heap_Check : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Check : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap) { - sprintf (SM_Error_Msg, "SM_Heap_Check : the heap is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Check : the heap is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Nb_Detected || !Nb_Corrected) { - sprintf (SM_Error_Msg, "SM_Heap_Check : the error number pointer is null"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Check : the error number pointer is null"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Out) { - sprintf (SM_Error_Msg, "SM_Heap_Check : the out stream is null"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Check : the out stream is null"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2335,23 +2355,23 @@ SMT_Status SM_Chunk_Alloc_C ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : the heap is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : the heap is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Ptr) { - sprintf (SM_Error_Msg, "SM_Chunk_Alloc : the chunk address is null"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Alloc : the chunk address is null"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2373,23 +2393,23 @@ SMT_Status SM_Chunk_Free_C ( SMT_Heap * Heap, void * Ptr) { if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Chunk_Free : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Free : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Heap) { - sprintf (SM_Error_Msg, "SM_Chunk_Free : the heap is undefined"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Free : the heap is undefined"); + SM_Error_Print(); return SMS_ERRAPI; } if( !Ptr) { - sprintf (SM_Error_Msg, "SM_Chunk_Free : the chunk pointer is null"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Chunk_Free : the chunk pointer is null"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -2400,6 +2420,8 @@ SMT_Status SM_Chunk_Free_C ( SMT_Heap * Heap, void * Ptr) + + /*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/ /* FONCTIONS PRIVEES */ @@ -2489,19 +2511,19 @@ SMT_Status SM_Base_Init ( void ) switch (errno) { case ENOMEM: - sprintf (SM_Error_Msg, "SM_Base_Init : the amount of memory is not sufficient to create a new semaphore"); + sprintf( SM_Error_Msg, "SM_Base_Init : the amount of memory is not sufficient to create a new semaphore"); break; case ENOSPC: - sprintf (SM_Error_Msg, "SM_Base_Init : the number of semaphores exceeds the system-imposed limit"); + sprintf( SM_Error_Msg, "SM_Base_Init : the number of semaphores exceeds the system-imposed limit"); break; default : - sprintf (SM_Error_Msg, "SM_Base_Init : unknown error (%d) while creating a semaphore", errno); + sprintf( SM_Error_Msg, "SM_Base_Init : unknown error (%d) while creating a semaphore", errno); break; } - SM_Error_Print (); + SM_Error_Print(); return SMS_ERRSEM; } @@ -2512,8 +2534,8 @@ SMT_Status SM_Base_Init ( void ) if( semctl (SemId, 0, SETVAL, Sem_Ctl )) { - sprintf (SM_Error_Msg, "SM_Base_Init : unable to initialize the value of semaphore %d", SemId); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Init : unable to initialize the value of semaphore %d", SemId); + SM_Error_Print(); rc = SMS_ERRSEM; goto Error1; @@ -2530,27 +2552,27 @@ SMT_Status SM_Base_Init ( void ) switch (errno) { case EEXIST: - sprintf (SM_Error_Msg, "SM_Base_Init : the shared memory segment identifier %d already exists", SM_Instance); + sprintf( SM_Error_Msg, "SM_Base_Init : the shared memory segment identifier %d already exists", SM_Instance); break; case EINVAL: - sprintf (SM_Error_Msg, "SM_Base_Init : the size of the shared memory segment (%d) is out of the system-imposed bounds", sizeof (SMT_Base)); + sprintf( SM_Error_Msg, "SM_Base_Init : the size of the shared memory segment (%d) is out of the system-imposed bounds", sizeof (SMT_Base)); break; case ENOMEM: - sprintf (SM_Error_Msg, "SM_Base_Init : the amount of memory is not sufficient to create the shared memory segment"); + sprintf( SM_Error_Msg, "SM_Base_Init : the amount of memory is not sufficient to create the shared memory segment"); break; case ENOSPC: - sprintf (SM_Error_Msg, "SM_Base_Init : the number of shared memory segments exceeds the system-imposed limit"); + sprintf( SM_Error_Msg, "SM_Base_Init : the number of shared memory segments exceeds the system-imposed limit"); break; default : - sprintf (SM_Error_Msg, "SM_Base_Init : unknown error (%d) while creating the shared memory segment", errno); + sprintf( SM_Error_Msg, "SM_Base_Init : unknown error (%d) while creating the shared memory segment", errno); break; } - SM_Error_Print (); + SM_Error_Print(); rc = SMS_ERRSHM; goto Error1; @@ -2562,8 +2584,8 @@ SMT_Status SM_Base_Init ( void ) SM_Base = shmat( SysMemId, 0, 0); if( errno) { - sprintf (SM_Error_Msg, "SM_Base_Init : unable to attach the first shared memory segment to the current process (error %d)", errno); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Init : unable to attach the first shared memory segment to the current process (error %d)", errno); + SM_Error_Print(); rc = SMS_ERRSHM; goto Error2; @@ -2598,23 +2620,23 @@ SMT_Status SM_Base_Init ( void ) switch (errno) { case EINVAL: - sprintf (SM_Error_Msg, "SM_Base_Init : the size of the shared memory segment (%d) is out of the system-imposed bounds", Size); + sprintf( SM_Error_Msg, "SM_Base_Init : the size of the shared memory segment (%d) is out of the system-imposed bounds", Size); break; case ENOMEM: - sprintf (SM_Error_Msg, "SM_Base_Init : the amount of memory is not sufficient to create the shared memory segment"); + sprintf( SM_Error_Msg, "SM_Base_Init : the amount of memory is not sufficient to create the shared memory segment"); break; case ENOSPC: - sprintf (SM_Error_Msg, "SM_Base_Init : the number of shared memory segments exceeds the system-imposed limit"); + sprintf( SM_Error_Msg, "SM_Base_Init : the number of shared memory segments exceeds the system-imposed limit"); break; default : - sprintf (SM_Error_Msg, "SM_Base_Init : unknown error (%d) while creating a shared memory segment", errno); + sprintf( SM_Error_Msg, "SM_Base_Init : unknown error (%d) while creating a shared memory segment", errno); break; } - SM_Error_Print (); + SM_Error_Print(); rc = SMS_ERRSHM; goto Error3; @@ -2647,8 +2669,8 @@ SMT_Status SM_Base_Init ( void ) if( errno) { - sprintf (SM_Error_Msg, "SM_Base_Init : unable to attach the second shared memory segment to the current process (error %d)", errno); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Init : unable to attach the second shared memory segment to the current process (error %d)", errno); + SM_Error_Print(); rc = SMS_ERRSHM; goto Error4; @@ -2661,8 +2683,8 @@ SMT_Status SM_Base_Init ( void ) rc = ND_DataStruct_Open( &( SM_Base->MHR), 1, &index_type, "MHR_Manager", NULL, "SM_Base_Alloc", NULL, "SM_Base_Free", NULL, TRUE, NULL); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Base_Init : unable to create the MHR structure"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Init : unable to create the MHR structure"); + SM_Error_Print(); goto Error4; } @@ -2677,8 +2699,8 @@ SMT_Status SM_Base_Init ( void ) rc = SM_Heap_Open_I (HEAP_SYSTEM, &System_Heap, 0, SMD_CREATE, &Locked); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_Init : unable to create the system heap"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Init : unable to create the system heap"); + SM_Error_Print(); goto Error5; } @@ -2710,8 +2732,8 @@ SMT_Status SM_Base_Init ( void ) rc = SM_Base_Lock (SMD_READ); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_Init : unable to lock the shared memory base for reading"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Init : unable to lock the shared memory base for reading"); + SM_Error_Print(); goto Error5; } @@ -2757,8 +2779,8 @@ SMT_Status SM_Base_End ( void ) rc = SM_Base_Unlock (SMD_READ); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_End : unable to unlock the shared memory base"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_End : unable to unlock the shared memory base"); + SM_Error_Print(); return rc; } @@ -2768,8 +2790,8 @@ SMT_Status SM_Base_End ( void ) rc = SM_Base_Lock (SMD_WRITE); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_End : unable to lock the shared memory base for writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_End : unable to lock the shared memory base for writing"); + SM_Error_Print(); SM_Base_Lock (SMD_READ); @@ -2806,8 +2828,8 @@ SMT_Status SM_Base_End ( void ) rc = ND_DataStruct_Value_Remove( SM_Base->MHR, MHH); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Base_End : unable to remove heap \"%s\" from the MHR", MHH->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_End : unable to remove heap \"%s\" from the MHR", MHH->Name); + SM_Error_Print(); SM_Base_Unlock (SMD_WRITE); SM_Base_Lock (SMD_READ); @@ -2820,8 +2842,8 @@ SMT_Status SM_Base_End ( void ) rc = ND_Value_Free (SM_Base->MHR, MHH); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_Base_End : unable to free heap \"%s\"", MHH->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_End : unable to free heap \"%s\"", MHH->Name); + SM_Error_Print(); SM_Base_Unlock (SMD_WRITE); SM_Base_Lock (SMD_READ); @@ -2843,19 +2865,19 @@ SMT_Status SM_Base_End ( void ) switch (errno) { case EPERM: - sprintf (SM_Error_Msg, "SM_Base_End : current process (%d) is not allowed to destroy the shared memory segment %d or %d", (int)getpid (), SysMemId, DataMemId); + sprintf( SM_Error_Msg, "SM_Base_End : current process (%d) is not allowed to destroy the shared memory segment %d or %d", (int)getpid (), SysMemId, DataMemId); break; case EINVAL: - sprintf (SM_Error_Msg, "SM_Base_End : no shared memory segment exists for identifier %d or %d", SysMemId, DataMemId); + sprintf( SM_Error_Msg, "SM_Base_End : no shared memory segment exists for identifier %d or %d", SysMemId, DataMemId); break; default : - sprintf (SM_Error_Msg, "SM_Base_End : unknown error (%d) while destroying the shared memory segment %d or %d", errno, SysMemId, DataMemId); + sprintf( SM_Error_Msg, "SM_Base_End : unknown error (%d) while destroying the shared memory segment %d or %d", errno, SysMemId, DataMemId); break; } - SM_Error_Print (); + SM_Error_Print(); SM_Base = NULL; @@ -2872,19 +2894,19 @@ SMT_Status SM_Base_End ( void ) switch (errno) { case EPERM: - sprintf (SM_Error_Msg, "SM_Base_End : current process (%d) is not allowed to destroy semaphore %d", (int)getpid (), SemId); + sprintf( SM_Error_Msg, "SM_Base_End : current process (%d) is not allowed to destroy semaphore %d", (int)getpid (), SemId); break; case EINVAL: - sprintf (SM_Error_Msg, "SM_Base_End : no semaphore corresponds to the identifier %d", SemId); + sprintf( SM_Error_Msg, "SM_Base_End : no semaphore corresponds to the identifier %d", SemId); break; default : - sprintf (SM_Error_Msg, "SM_Base_End : unknown error (%d) while destroying semaphore %d", errno, SemId); + sprintf( SM_Error_Msg, "SM_Base_End : unknown error (%d) while destroying semaphore %d", errno, SemId); break; } - SM_Error_Print (); + SM_Error_Print(); return SMS_ERRSEM; } @@ -2918,23 +2940,23 @@ SMT_Status SM_Base_Open ( void ) switch (errno) { case EACCES: - sprintf (SM_Error_Msg, "SM_Base_Open : the shared memory segment %d is not accessible to the current process", SM_Instance); + sprintf( SM_Error_Msg, "SM_Base_Open : the shared memory segment %d is not accessible to the current process", SM_Instance); break; case EIDRM: - sprintf (SM_Error_Msg, "SM_Base_Open : the shared memory segment %d has been deleted", SM_Instance); + sprintf( SM_Error_Msg, "SM_Base_Open : the shared memory segment %d has been deleted", SM_Instance); break; case ENOENT: - sprintf (SM_Error_Msg, "SM_Base_Open : no shared memory segment corresponds to the identifier %d", SM_Instance); + sprintf( SM_Error_Msg, "SM_Base_Open : no shared memory segment corresponds to the identifier %d", SM_Instance); break; default : - sprintf (SM_Error_Msg, "SM_Base_Open : unknown error %d while retrieving a shared memory segment", errno); + sprintf( SM_Error_Msg, "SM_Base_Open : unknown error %d while retrieving a shared memory segment", errno); break; } - SM_Error_Print (); + SM_Error_Print(); return SMS_ERRSHM; } @@ -2945,8 +2967,8 @@ SMT_Status SM_Base_Open ( void ) SM_Base = shmat( MemId, 0, 0); if( errno) { - sprintf (SM_Error_Msg, "SM_Base_Open : unable to attach the shared memory segment to the current process (error %d)", errno); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Open : unable to attach the shared memory segment to the current process (error %d)", errno); + SM_Error_Print(); SM_Base = NULL; @@ -2957,8 +2979,8 @@ SMT_Status SM_Base_Open ( void ) Ptr = shmat (SM_Base->DataMemId, SM_Base->MHR, 0); if( errno) { - sprintf (SM_Error_Msg, "SM_Base_Open : unable to attach the shared memory segment to the current process at the specified address %p (error %d)", SM_Base->MHR, errno); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Open : unable to attach the shared memory segment to the current process at the specified address %p (error %d)", SM_Base->MHR, errno); + SM_Error_Print(); shmdt ((void *)SM_Base); SM_Base = NULL; @@ -2971,8 +2993,8 @@ SMT_Status SM_Base_Open ( void ) rc = SM_Base_Lock (SMD_READ); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_Open : unable to lock the shared memory base for reading"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Open : unable to lock the shared memory base for reading"); + SM_Error_Print(); shmdt ((void *)SM_Base); SM_Base = NULL; @@ -2985,8 +3007,8 @@ SMT_Status SM_Base_Open ( void ) rc = SM_Heap_Open_I (HEAP_SYSTEM, &System_Heap, 0, SMD_OPEN, &Locked); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_Open : unable to open the system heap"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Open : unable to open the system heap"); + SM_Error_Print(); shmdt ((void *)SM_Base); SM_Base = NULL; @@ -3012,8 +3034,8 @@ SMT_Status SM_Base_Close ( void ) if( !SM_Base) { - sprintf (SM_Error_Msg, "SM_Base_Close : the LIBSHMEM library is not open"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Close : the LIBSHMEM library is not open"); + SM_Error_Print(); return SMS_ERRAPI; } @@ -3065,8 +3087,8 @@ SMT_Status SM_Base_Lock ( SMT_Flags Lock_Mode ) rc = SM_Semaphore_Operate (SM_Base->SemId, SM_SemOp_SSL, 2); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_Lock : unable to lock the library base for reading"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Lock : unable to lock the library base for reading"); + SM_Error_Print(); return rc; } @@ -3077,8 +3099,8 @@ SMT_Status SM_Base_Lock ( SMT_Flags Lock_Mode ) rc = SM_Semaphore_Operate (SM_Base->SemId, SM_SemOp_SEL, 2); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_Lock : unable to lock the library base for writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Lock : unable to lock the library base for writing"); + SM_Error_Print(); return rc; } @@ -3104,8 +3126,8 @@ SMT_Status SM_Base_Unlock ( SMT_Flags Lock_Mode ) rc = SM_Semaphore_Operate (SM_Base->SemId, SM_SemOp_RSL, 2); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_Unlock : unable to unlock the library base which had been locked for reading"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Unlock : unable to unlock the library base which had been locked for reading"); + SM_Error_Print(); return rc; } @@ -3116,8 +3138,8 @@ SMT_Status SM_Base_Unlock ( SMT_Flags Lock_Mode ) rc = SM_Semaphore_Operate (SM_Base->SemId, SM_SemOp_REL, 2); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Base_Unlock : unable to unlock the library base which had been locked for writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Base_Unlock : unable to unlock the library base which had been locked for writing"); + SM_Error_Print(); return rc; } @@ -3679,7 +3701,7 @@ NDT_Status MHR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node /* Destruction de la structure DSR (et de toutes ses valeurs) */ - if( !strcmp (MHH_Ptr->Name, HEAP_SYSTEM)) + if( !strcmp( MHH_Ptr->Name, HEAP_SYSTEM)) { NDT_Node * Node, * Previous_Node; SMT_DSH * DSH; @@ -3714,8 +3736,8 @@ NDT_Status MHR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node rc = ND_DataStruct_Value_Remove( MHH_Ptr->DSR, DSH); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to remove the shared memory segment (address=%p) from the DSR structure", DSH->Start); - SM_Error_Print (); + sprintf( SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to remove the shared memory segment (address=%p) from the DSR structure", DSH->Start); + SM_Error_Print(); if( SM_ERROR(rc)) return rc; } @@ -3725,8 +3747,8 @@ NDT_Status MHR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node rc = ND_Value_Free( MHH_Ptr->DSR, DSH); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, " MHR_Manager NDD_CMD_VALUE_FREE: unable to free the shared memory segment (address=%p)", DSH->Start); - SM_Error_Print (); + sprintf( SM_Error_Msg, " MHR_Manager NDD_CMD_VALUE_FREE: unable to free the shared memory segment (address=%p)", DSH->Start); + SM_Error_Print(); if( SM_ERROR(rc)) return rc; } @@ -3739,8 +3761,8 @@ NDT_Status MHR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node rc = ND_DataStruct_Close (MHH_Ptr->DSR); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to destroy the DSR structure of heap \"%s\"", MHH_Ptr->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to destroy the DSR structure of heap \"%s\"", MHH_Ptr->Name); + SM_Error_Print(); } } @@ -3755,15 +3777,15 @@ NDT_Status MHR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node rc = ND_Deallocator_Exec( MHH_Ptr->ACR, SM_Base->MHR->Deallocator_Name, SM_Base->MHR->Deallocator_Ptr, NULL); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to free the ACR root of heap \"%s\"", MHH_Ptr->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to free the ACR root of heap \"%s\"", MHH_Ptr->Name); + SM_Error_Print(); } rc = ND_Deallocator_Exec( MHH_Ptr->FCR, SM_Base->MHR->Deallocator_Name, SM_Base->MHR->Deallocator_Ptr, NULL); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to free the FCR root of heap \"%s\"", MHH_Ptr->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to free the FCR root of heap \"%s\"", MHH_Ptr->Name); + SM_Error_Print(); } /* Suppression du heap de la liste des heaps ouverts */ @@ -3799,8 +3821,8 @@ NDT_Status MHR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node rc = ND_Deallocator_Exec( MHH_Ptr, SM_Base->MHR->Deallocator_Name, SM_Base->MHR->Deallocator_Ptr, NULL); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to free the header of heap \"%s\"", MHH_Ptr->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "MHR_Manager NDD_CMD_VALUE_FREE : unable to free the header of heap \"%s\"", MHH_Ptr->Name); + SM_Error_Print(); } @@ -3962,7 +3984,7 @@ NDT_Status MHR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node sprintf( SM_Error_Msg, "Error MHR_Manager : unable to lock Heap_Name: [%s] for reading", MHH_Ptr->Name); SM_Error_Print(); - return( SMS_KO); +// return( SMS_KO); } segment_nb = MHH_Ptr->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number; @@ -4054,7 +4076,7 @@ SMT_Status SM_MHH_End( SMT_MHH *MHH) /* Destruction de la structure DSR (et de toutes ses valeurs) */ - if( !strcmp (MHH->Name, HEAP_SYSTEM)) + if( !strcmp( MHH->Name, HEAP_SYSTEM)) { NDT_Node * Node, * Previous_Node; SMT_DSH * DSH; @@ -4089,8 +4111,8 @@ SMT_Status SM_MHH_End( SMT_MHH *MHH) rc = ND_DataStruct_Value_Remove( MHH->DSR, DSH); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_MHH_End : unable to remove the shared memory segment (address=%p) from the DSR structure", DSH->Start); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_MHH_End : unable to remove the shared memory segment (address=%p) from the DSR structure", DSH->Start); + SM_Error_Print(); if( SM_ERROR(rc)) return rc; } @@ -4100,8 +4122,8 @@ SMT_Status SM_MHH_End( SMT_MHH *MHH) rc = ND_Value_Free( MHH->DSR, DSH); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the shared memory segment (address=%p)", DSH->Start); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_MHH_End : unable to free the shared memory segment (address=%p)", DSH->Start); + SM_Error_Print(); if( SM_ERROR(rc)) return rc; } @@ -4114,8 +4136,8 @@ SMT_Status SM_MHH_End( SMT_MHH *MHH) rc = ND_DataStruct_Close (MHH->DSR); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_MHH_End : unable to destroy the DSR structure of heap \"%s\"", MHH->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_MHH_End : unable to destroy the DSR structure of heap \"%s\"", MHH->Name); + SM_Error_Print(); } } @@ -4130,15 +4152,15 @@ SMT_Status SM_MHH_End( SMT_MHH *MHH) rc = ND_Deallocator_Exec( MHH->ACR, SM_Base->MHR->Deallocator_Name, SM_Base->MHR->Deallocator_Ptr, NULL); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the ACR root of heap \"%s\"", MHH->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_MHH_End : unable to free the ACR root of heap \"%s\"", MHH->Name); + SM_Error_Print(); } rc = ND_Deallocator_Exec( MHH->FCR, SM_Base->MHR->Deallocator_Name, SM_Base->MHR->Deallocator_Ptr, NULL); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the FCR root of heap \"%s\"", MHH->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_MHH_End : unable to free the FCR root of heap \"%s\"", MHH->Name); + SM_Error_Print(); } /* Suppression du heap de la liste des heaps ouverts */ @@ -4174,8 +4196,8 @@ SMT_Status SM_MHH_End( SMT_MHH *MHH) rc = ND_Deallocator_Exec( MHH, SM_Base->MHR->Deallocator_Name, SM_Base->MHR->Deallocator_Ptr, NULL); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the header of heap \"%s\"", MHH->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_MHH_End : unable to free the header of heap \"%s\"", MHH->Name); + SM_Error_Print(); } return rc; @@ -4293,8 +4315,8 @@ NDT_Status SM_DSR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node if( Current_Size + Segment_Size > MHH_Ptr->Limit_Size) { - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : the heap limit size would be exceeded"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : the heap limit size would be exceeded"); + SM_Error_Print(); *DSH_Ptr_Ptr = NULL; @@ -4306,8 +4328,8 @@ NDT_Status SM_DSR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node if( ND_Allocator_Exec( (void **)DSH_Ptr_Ptr, sizeof (SMT_DSH), MHH_Ptr->DSR->Allocator_Name, MHH_Ptr->DSR->Allocator_Ptr, NULL) != NDS_OK) { - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : unable to allocate memory for the new data segment header"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : unable to allocate memory for the new data segment header"); + SM_Error_Print(); return( NDS_KO); } @@ -4318,23 +4340,23 @@ NDT_Status SM_DSR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node switch (errno) { case EINVAL: - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : the size of the shared memory segment (%d) is out of the system-imposed bounds", Segment_Size); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : the size of the shared memory segment (%d) is out of the system-imposed bounds", Segment_Size); break; case ENOMEM: - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : the amount of memory is not sufficient to create the shared memory segment"); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : the amount of memory is not sufficient to create the shared memory segment"); break; case ENOSPC: - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : the number of shared memory segments exceeds the system-imposed limit"); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : the number of shared memory segments exceeds the system-imposed limit"); break; default : - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : unknown error (%d) while creating a shared memory segment", errno); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : unknown error (%d) while creating a shared memory segment", errno); break; } - SM_Error_Print (); + SM_Error_Print(); ND_Deallocator_Exec( (*DSH_Ptr_Ptr), MHH_Ptr->DSR->Deallocator_Name, MHH_Ptr->DSR->Deallocator_Ptr, NULL); @@ -4351,8 +4373,8 @@ NDT_Status SM_DSR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node #endif if( errno) { - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : unable to attach the shared memory segment to the current process (error %d)", errno); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : unable to attach the shared memory segment to the current process (error %d)", errno); + SM_Error_Print(); shmctl ((*DSH_Ptr_Ptr)->MemId, IPC_RMID, 0); @@ -4383,8 +4405,8 @@ NDT_Status SM_DSR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node if( ND_Index_Node_Add( MHH_Ptr->FCR, NDD_INDEX_PRIMARY, Chunk_Node) != NDS_OK) { - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : unable to add a first chunk to the FCR structure of heap \"%s\"", MHH_Ptr->Name); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_ALLOC : unable to add a first chunk to the FCR structure of heap \"%s\"", MHH_Ptr->Name); + SM_Error_Print(); shmctl ((*DSH_Ptr_Ptr)->MemId, IPC_RMID, 0); @@ -4423,19 +4445,19 @@ NDT_Status SM_DSR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node switch (errno) { case EPERM: - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_FREE : current process (%d) is not allowed to destroy the shared memory segment %d", (int)getpid (), DSH_Ptr->MemId); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_FREE : current process (%d) is not allowed to destroy the shared memory segment %d", (int)getpid (), DSH_Ptr->MemId); break; case EINVAL: - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_FREE : no shared memory segment exists for identifier %d", DSH_Ptr->MemId); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_FREE : no shared memory segment exists for identifier %d", DSH_Ptr->MemId); break; default : - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_FREE: unknown error %d while destroying the shared memory segment %d", errno, DSH_Ptr->MemId); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_FREE: unknown error %d while destroying the shared memory segment %d", errno, DSH_Ptr->MemId); break; } - SM_Error_Print (); + SM_Error_Print(); return SMS_ERRSHM; } @@ -4445,8 +4467,8 @@ NDT_Status SM_DSR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node rc = ND_Deallocator_Exec( DSH_Ptr, Root_Ptr->Deallocator_Name, Root_Ptr->Deallocator_Ptr, NULL); if( rc != NDS_OK) { - sprintf (SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_FREE : the data segment header is nul"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_DSR_Manager NDD_CMD_VALUE_FREE : the data segment header is nul"); + SM_Error_Print(); return rc; } @@ -4673,8 +4695,8 @@ SMT_Status SM_DataSegment_Open ( SMT_DSH *DSH) Ptr = shmat( DSH->MemId, DSH->Start, 0); if( errno) { - sprintf (SM_Error_Msg, "SM_DataSegment_Open : unable to attach the shared memory segment at the specified address %p (error %d)", DSH->Start, errno); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_DataSegment_Open : unable to attach the shared memory segment at the specified address %p (error %d)", DSH->Start, errno); + SM_Error_Print(); return SMS_ERRSHM; } @@ -5388,8 +5410,8 @@ SMT_Status SM_Heap_Lock_Set ( SMT_MHH * MHH, SMT_Flags Lock_Mode ) rc = SM_Semaphore_Operate (MHH->SemId, SM_SemOp_SSL, 2); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock_Set : unable to lock the heap for reading"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock_Set : unable to lock the heap for reading"); + SM_Error_Print(); return rc; } @@ -5400,8 +5422,8 @@ SMT_Status SM_Heap_Lock_Set ( SMT_MHH * MHH, SMT_Flags Lock_Mode ) rc = SM_Semaphore_Operate (MHH->SemId, SM_SemOp_SEL, 2); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock_Set : unable to lock the heap for writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock_Set : unable to lock the heap for writing"); + SM_Error_Print(); return rc; } @@ -5434,16 +5456,16 @@ SMT_Status SM_Heap_Lock_Change ( SMT_MHH * MHH, SMT_Flags Lock_Mode ) if( (rc = SM_Semaphore_Operate (MHH->SemId, SM_SemOp_RSL, 2)) != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock_Change : unable to transform the heap lock for writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock_Change : unable to transform the heap lock for writing"); + SM_Error_Print(); return rc; } if( (rc = SM_Semaphore_Operate (MHH->SemId, SM_SemOp_SEL, 2)) != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock_Change : unable to transform the heap lock for writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock_Change : unable to transform the heap lock for writing"); + SM_Error_Print(); /* On tente de revenir à l'état de verrouillage précédent */ @@ -5457,8 +5479,8 @@ SMT_Status SM_Heap_Lock_Change ( SMT_MHH * MHH, SMT_Flags Lock_Mode ) rc = SM_Semaphore_Operate (MHH->SemId, SM_SemOp_TSL, 2); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock_Change : unable to transform the heap lock for reading"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock_Change : unable to transform the heap lock for reading"); + SM_Error_Print(); return rc; } @@ -5484,8 +5506,8 @@ SMT_Status SM_Heap_Lock_Release ( SMT_MHH * MHH, SMT_Flags Lock_Mode ) rc = SM_Semaphore_Operate (MHH->SemId, SM_SemOp_RSL, 2); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock_Release : unable to unlock the heap which had been locked for reading"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock_Release : unable to unlock the heap which had been locked for reading"); + SM_Error_Print(); return rc; } @@ -5496,8 +5518,8 @@ SMT_Status SM_Heap_Lock_Release ( SMT_MHH * MHH, SMT_Flags Lock_Mode ) rc = SM_Semaphore_Operate (MHH->SemId, SM_SemOp_REL, 2); if( rc != SMS_OK) { - sprintf (SM_Error_Msg, "SM_Heap_Lock_Release : unable to unlock the heap which had been locked for writing"); - SM_Error_Print (); + sprintf( SM_Error_Msg, "SM_Heap_Lock_Release : unable to unlock the heap which had been locked for writing"); + SM_Error_Print(); return rc; } @@ -5521,41 +5543,41 @@ SMT_Status SM_Semaphore_Operate (int SemId, struct sembuf * Operations, unsigned switch (errno) { case EAGAIN: - sprintf (SM_Error_Msg, "SM_Semaphore_Operate : the operation would result in suspension of the calling process but the operations have been defined in no wait mode"); + sprintf( SM_Error_Msg, "SM_Semaphore_Operate : the operation would result in suspension of the calling process but the operations have been defined in no wait mode"); return SMS_NO_WAIT; break; case EACCES: - sprintf (SM_Error_Msg, "SM_Semaphore_Operate : current process is not allowed to operate on semaphore %d", SemId); + sprintf( SM_Error_Msg, "SM_Semaphore_Operate : current process is not allowed to operate on semaphore %d", SemId); break; case EIDRM: - sprintf (SM_Error_Msg, "SM_Semaphore_Operate : semaphore %d does not exist", SemId); + sprintf( SM_Error_Msg, "SM_Semaphore_Operate : semaphore %d does not exist", SemId); break; case EINTR: - sprintf (SM_Error_Msg, "SM_Semaphore_Operate : a signal was received while operating on semaphore %d", SemId); + sprintf( SM_Error_Msg, "SM_Semaphore_Operate : a signal was received while operating on semaphore %d", SemId); return SMS_ERRSIG; break; case EINVAL: - sprintf (SM_Error_Msg, "SM_Semaphore_Operate : the semaphore identifier %d is incorrect or the number of operations which can be done in UNDO mode exceeds the system-imposed limit", SemId); + sprintf( SM_Error_Msg, "SM_Semaphore_Operate : the semaphore identifier %d is incorrect or the number of operations which can be done in UNDO mode exceeds the system-imposed limit", SemId); break; case ENOSPC: - sprintf (SM_Error_Msg, "SM_Semaphore_Operate : the maximum number of process which can operate on semaphore in UNDO mode has been reached"); + sprintf( SM_Error_Msg, "SM_Semaphore_Operate : the maximum number of process which can operate on semaphore in UNDO mode has been reached"); break; case ERANGE: - sprintf (SM_Error_Msg, "SM_Semaphore_Operate: the value of semaphore %d has reached the system-imposed limit", SemId); + sprintf( SM_Error_Msg, "SM_Semaphore_Operate: the value of semaphore %d has reached the system-imposed limit", SemId); break; default : - sprintf (SM_Error_Msg, "SM_Semaphore_Operate : unknown error %d while operating on semaphore %d", errno, SemId); + sprintf( SM_Error_Msg, "SM_Semaphore_Operate : unknown error %d while operating on semaphore %d", errno, SemId); break; } - SM_Error_Print (); + SM_Error_Print(); return SMS_ERRSEM; } @@ -5641,9 +5663,9 @@ char *SM_Lock_Status_Get( const char *Type_Name, void *Struct_Ptr) /* Routine d'affichage d'un message d'erreur */ /*------------------------------------------------------------------------------*/ -void SM_Error_Print ( void ) +void SM_Error_Print( void ) { - if( SM_stderr) fprintf (SM_stderr, "Error %s\n", SM_Error_Msg); + if( SM_stderr) fprintf( SM_stderr, "Error %s\n", SM_Error_Msg); } @@ -5670,3 +5692,31 @@ SMT_Status SM_Name_Prefix( char *Prefixed, const char *Unprefixed) return( SMS_OK); } + + + + + +/*------------------------------------------------------------------------------*/ +/* Print stack trace */ +/*------------------------------------------------------------------------------*/ + +void SM_stack_trace_print( void) +{ + void *array[10]; + char **strings; + int size, i; + + + size = backtrace( array, 10); + strings = backtrace_symbols( array, size); + + if( strings != NULL) + { + printf( "Obtained %d stack frames.\n", size); + + for( i = 0; i < size; i++) printf( "%s\n", strings[i]); + } + + free( strings); +} diff --git a/lib/libshmem.h b/lib/libshmem.h index cccb067..b2b8496 100644 --- a/lib/libshmem.h +++ b/lib/libshmem.h @@ -1,29 +1,24 @@ -/*---------------------------------------------------------------------------------*/ -/* $RCSfile: libshmem.h,v $ */ -/*---------------------------------------------------------------------------------*/ -/* $Revision: 2.3 $ */ -/* $Name: $ */ -/* $Date: 2005/06/26 23:02:35 $ */ -/* $Author: agibert $ */ -/*---------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* libshmem.h */ +/*----------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------------*/ -/* This file is part of LibShMem */ -/* */ -/* LibShMem is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public Licence as published by */ -/* the Free Software Foundation; either version 2.1 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* LibShMem is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with LibShMem; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/*---------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* This file is part of LibShMem */ +/* */ +/* LibShMem is free software: you can redistribute it and/or modify it */ +/* under the terms of the GNU Lesser General Public License as published */ +/* by the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* LibShMem is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU Lesser General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with Drummer. If not, see */ +/* . */ +/*----------------------------------------------------------------------------*/ @@ -42,6 +37,8 @@ #include +#include + @@ -164,6 +161,11 @@ typedef union semun unsigned short int * array; } semun; + + + + + /*------------------------------------------------------------------------------*/ /* Allocation de mémoire dans la base */ /*------------------------------------------------------------------------------*/ @@ -299,3 +301,11 @@ void SM_Error_Print (void); /*------------------------------------------------------------------------------*/ SMT_Status SM_Name_Prefix( char *, const char *); + + + +/*------------------------------------------------------------------------------*/ +/* Print stack trace */ +/*------------------------------------------------------------------------------*/ + +void SM_stack_trace_print( void); diff --git a/util/Makefile b/util/Makefile index bdc04d4..5e1254b 100644 --- a/util/Makefile +++ b/util/Makefile @@ -9,12 +9,12 @@ include ../Makefile.rule -DEP_STATIC += ../lib/libshmem.a ../../libnode/lib/libnode.a -DEP_DYNAMIC += ../lib/libshmem.so ../../libnode/lib/libnode.so -INCLUDE += -I . -I ../include -I ../../libnode/include -LIBDIR += -L . -L ../lib -L ../../libnode/lib -LIB_STATIC += ../lib/libshmem.a ../../libnode/lib/libnode.a -ldl -LIB_DYNAMIC += -lshmem -lnode -ldl +DEP_STATIC += ../lib/libshmem.a ../../liblog/lib/liblog.a ../../libnode/lib/libnode.a +DEP_DYNAMIC += ../lib/libshmem.so ../../liblog/lib/liblog.so ../../libnode/lib/libnode.so +INCLUDE += -I . -I ../include -I ../../liblog/include -I ../../libnode/include +LIBDIR += -L . -L ../lib -L ../../liblog/lib -L ../../libnode/lib +LIB_STATIC += ../lib/libshmem.a ../../liblog/lib/liblog.a ../../libnode/lib/libnode.a -ldl +LIB_DYNAMIC += -lshmem -llog -lnode -ldl CFLAGS += -rdynamic ifdef _LIBVER_SUPPORT diff --git a/util/smadmin.c b/util/smadmin.c index 553df0a..a620da5 100644 --- a/util/smadmin.c +++ b/util/smadmin.c @@ -314,9 +314,9 @@ int main( int argc, char **argv) break; } - case BASE_END: + case BASE_INFO: { - fprintf( stdout, "\nReturn code = %s\n", SM_Library_Close( SMD_DESTROY) == SMS_OK ? "OK" : "NOK" ); + SM_Library_Dump( stderr); break; } @@ -328,9 +328,9 @@ int main( int argc, char **argv) break; } - case BASE_INFO: + case BASE_END: { - SM_Library_Dump( stderr); + fprintf( stdout, "\nReturn code = %s\n", SM_Library_Close( SMD_DESTROY) == SMS_OK ? "OK" : "NOK" ); break; }