- Start LibLog support implementation,

- Minor code cleanup.
This commit is contained in:
Arnaud G. GIBERT 2024-04-17 18:49:56 +02:00
parent ef3ca27707
commit 7c2671ee77
9 changed files with 528 additions and 463 deletions

View File

@ -1,9 +1,3 @@
# $RCSfile: Makefile,v $
# $Revision: 1.2 $
# $Name: $
# $Date: 2005/06/26 23:04:11 $
# $Author: agibert $
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Main Makefile # Main Makefile
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -14,12 +14,12 @@ include ../Makefile.rule
DEP_STATIC += ../lib/libshmem.a ../../libnode/lib/libnode.a DEP_STATIC += ../lib/libshmem.a ../../liblog/lib/liblog.a ../../libnode/lib/libnode.a
DEP_DYNAMIC += ../lib/libshmem.so ../../libnode/lib/libnode.so DEP_DYNAMIC += ../lib/libshmem.so ../../liblog/lib/liblog.so ../../libnode/lib/libnode.so
INCLUDE += -I . -I ../include -I ../../libnode/include INCLUDE += -I . -I ../include -I ../../liblog/include -I ../../libnode/include
LIBDIR += -L . -L ../lib -L ../../libnode/lib LIBDIR += -L . -L ../lib -L ../../liblog/lib -L ../../libnode/lib
LIB_STATIC += ../lib/libshmem.a ../../libnode/lib/libnode.a -ldl LIB_STATIC += ../lib/libshmem.a ../../liblog/lib/liblog.a ../../libnode/lib/libnode.a -ldl
LIB_DYNAMIC += -lshmem -lnode -ldl LIB_DYNAMIC += -lshmem -llog -lnode -ldl
CFLAGS += -rdynamic CFLAGS += -rdynamic
ifdef _LIBVER_SUPPORT ifdef _LIBVER_SUPPORT

View File

@ -1,14 +1,9 @@
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* $RCSfile: smdemo0.c,v $ */ /* smdemo0.c */
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* $Revision: 1.1 $ */
/* $Name: $ */
/* $Date: 2005/06/26 23:16:38 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* 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 */ /* 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 */ /* 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 */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -1,18 +1,13 @@
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* $RCSfile: shmem.h,v $ */ /* shmem.h */
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* $Revision: 2.3 $ */
/* $Name: $ */
/* $Date: 2005/06/26 23:07:40 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* This file is part of LibShMem */ /* This file is part of LibShMem */
/* */ /* */
/* LibShMem is free software; you can redistribute it and/or modify */ /* LibShMem is free software: you can redistribute it and/or modify it */
/* it under the terms of the GNU Lesser General Public Licence as published by */ /* under the terms of the GNU Lesser General Public License as published */
/* the Free Software Foundation; either version 2.1 of the License, or */ /* by the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */ /* (at your option) any later version. */
/* */ /* */
/* LibShMem is distributed in the hope that it will be useful, */ /* LibShMem is distributed in the hope that it will be useful, */
@ -20,14 +15,16 @@
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */ /* GNU Lesser General Public License for more details. */
/* */ /* */
/* You should have received a copy of the GNU Lesser General Public License */ /* You should have received a copy of the GNU Lesser General Public */
/* along with LibShMem; if not, write to the Free Software */ /* License along with Drummer. If not, see */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* <https://www.gnu.org/licenses/>. */
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
#ifndef _LIBSM #ifndef _LIBSM
#define _LIBSM #define _LIBSM
@ -38,11 +35,34 @@
#include <stdarg.h> #include <stdarg.h>
#include <sys/types.h> #include <sys/types.h>
#include <log.h>
#include <node.h> #include <node.h>
/*----------------------------------------------------------------------------*/
/* 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 */ /* Code retour des fonctions constituant l'API */
typedef long SMT_Status; typedef long SMT_Status;
@ -142,11 +162,8 @@ typedef int SMT_Config;
#ifdef _LIBSHMEM_C_ SMD_DATA char SM_Error_Msg [512];
char SM_Error_Msg [512];
#else
extern char SM_Error_Msg [512];
#endif
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
@ -168,11 +185,8 @@ typedef int SMT_Config;
/* Référence sur la base de heaps */ /* Référence sur la base de heaps */
#ifdef _LIBSHMEM_C_ SMD_DATA SMT_Base * SM_Base;
SMT_Base * SM_Base;
#else
extern SMT_Base * SM_Base;
#endif
@ -296,8 +310,8 @@ typedef struct {
/* (I) Context : nom du nouveau contexte */ /* (I) Context : nom du nouveau contexte */
/* (I) Flags : indicateur création/ouverture + mode d'affichage des erreurs */ /* (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 ); SMD_API 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_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 */ /* (O) Instance : adresse du numéro de l'instance utilisée */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Library_Instance_Get_I ( int * Instance); SMD_API 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_C ( int * Instance);
@ -316,8 +330,8 @@ typedef struct {
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* (I) Context : nom du nouveau contexte */ /* (I) Context : nom du nouveau contexte */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Library_Context_Set_I ( const char * Context ); SMD_API 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_C ( const char * Context );
@ -326,8 +340,8 @@ typedef struct {
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* (O) Context : adresse du nom du contexte utilisé */ /* (O) Context : adresse du nom du contexte utilisé */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Library_Context_Get_I ( char ** Context ); SMD_API 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_C ( char ** Context );
@ -336,8 +350,8 @@ typedef struct {
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* (I) Flags : mode de fermeture (destruction ou fermeture simple) */ /* (I) Flags : mode de fermeture (destruction ou fermeture simple) */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Library_Close_I ( SMT_Flags Flags ); SMD_API 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_C ( SMT_Flags Flags );
@ -346,24 +360,24 @@ typedef struct {
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* (I) Out : pointeur sur le flux de sortie */ /* (I) Out : pointeur sur le flux de sortie */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Library_Dump_I ( FILE * Out ); SMD_API SMT_Status SM_Library_Dump_I ( FILE * Out );
SMT_Status SM_Library_Dump_C ( FILE * Out ); SMD_API SMT_Status SM_Library_Dump_C ( FILE * Out );
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* Libération de tous les verrous (base, heap) */ /* Libération de tous les verrous (base, heap) */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Library_Unlock_I ( void ); SMD_API SMT_Status SM_Library_Unlock_I ( void );
SMT_Status SM_Library_Unlock_C ( void ); SMD_API SMT_Status SM_Library_Unlock_C ( void );
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* Définition de la sortie standard des messages d'erreur de la librairie */ /* Définition de la sortie standard des messages d'erreur de la librairie */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Library_Stderr_Set_I ( FILE * Out ); SMD_API 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_C ( FILE * Out );
@ -372,8 +386,8 @@ typedef struct {
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* (I) Heap_Name : nom du heap */ /* (I) Heap_Name : nom du heap */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Heap_Exist_I ( const char * Heap_Name ); SMD_API 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_C ( const char * Heap_Name );
@ -386,8 +400,8 @@ typedef struct {
/* (I) Flags : mode d'ouverture du heap */ /* (I) Flags : mode d'ouverture du heap */
/* (O) Locked : verrou effectif (TRUE ou FALSE) */ /* (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 ); SMD_API 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_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 */ /* (I) Heap_Name : nom du heap */
/* (O) Heap : adresse du pointeur sur le heap ouvert */ /* (O) Heap : adresse du pointeur sur le heap ouvert */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Heap_IsOpen_I ( const char * Heap_Name, SMT_Heap ** Heap ); SMD_API 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_C ( const char * Heap_Name, SMT_Heap ** Heap );
@ -407,8 +421,8 @@ typedef struct {
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* (I) Heap : pointeur sur un heap ouvert */ /* (I) Heap : pointeur sur un heap ouvert */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Heap_Close_I ( SMT_Heap * Heap ); SMD_API 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_C ( SMT_Heap * Heap );
@ -417,8 +431,8 @@ typedef struct {
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* (I) Heap_Name : nom du heap */ /* (I) Heap_Name : nom du heap */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Heap_End_I ( const char * Heap_Name ); SMD_API 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_C ( const char * Heap_Name );
@ -428,8 +442,8 @@ typedef struct {
/* (I) Heap : pointeur sur un heap ouvert */ /* (I) Heap : pointeur sur un heap ouvert */
/* (O) Compress : pointeur sur la taille mémoire gagnée */ /* (O) Compress : pointeur sur la taille mémoire gagnée */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Heap_Compress_I ( SMT_Heap * Heap, size_t * Compress ); SMD_API 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_C ( SMT_Heap * Heap, size_t * Compress );
@ -439,8 +453,8 @@ typedef struct {
/* (I) Heap : pointeur sur un heap ouvert */ /* (I) Heap : pointeur sur un heap ouvert */
/* (I) Tag : type de configuration */ /* (I) Tag : type de configuration */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Heap_Config_I ( SMT_Heap * Heap, SMT_Config Tag, ... ); SMD_API 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_C ( SMT_Heap * Heap, SMT_Config Tag, ... );
@ -452,8 +466,8 @@ typedef struct {
/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */ /* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */
/* (I) Out : pointeur sur le flux de sortie du rapport */ /* (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); SMD_API 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_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) */ /* (I) Flags : mode de verrouillage (SMD_READ ou SMD_WRITE) */
/* (O) Locked : verrouillage effectué (TRUE ou FALSE) */ /* (O) Locked : verrouillage effectué (TRUE ou FALSE) */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Flags, int * Locked ); SMD_API 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_C ( SMT_Heap * Heap, SMT_Flags Flags, int * Locked );
@ -474,8 +488,8 @@ typedef struct {
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* (I) Heap : pointeur sur un heap ouvert */ /* (I) Heap : pointeur sur un heap ouvert */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Heap_Unlock_I ( SMT_Heap * Heap ); SMD_API 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_C ( SMT_Heap * Heap );
@ -486,8 +500,8 @@ typedef struct {
/* (I) Size : taille du chunk */ /* (I) Size : taille du chunk */
/* (O) Ptr : pointeur sur la zone de données allouée */ /* (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 ); SMD_API 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_C ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr );
@ -497,8 +511,8 @@ typedef struct {
/* (I) Heap : pointeur sur un heap ouvert */ /* (I) Heap : pointeur sur un heap ouvert */
/* (I) Ptr : adresse de la zone de données du chunk à désallouer */ /* (I) Ptr : adresse de la zone de données du chunk à désallouer */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr ); SMD_API 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_C ( SMT_Heap * Heap, void * Ptr );

View File

@ -9,8 +9,8 @@ include ../Makefile.rule
DEP += libshmem.h ../include/shmem.h ../../libnode/include/node.h Makefile DEP += libshmem.h ../include/shmem.h ../../liblog/include/log.h ../../libnode/include/node.h Makefile
INCLUDE += -I . -I ../include -I ../../libnode/include INCLUDE += -I . -I ../include -I ../../liblog/include -I ../../libnode/include
ifdef _LIBVER_SUPPORT ifdef _LIBVER_SUPPORT
DEP += ../../libver/ver.h DEP += ../../libver/ver.h

View File

@ -1,18 +1,13 @@
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* $RCSfile: libshmem.c,v $ */ /* libshmem.c */
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* $Revision: 2.4 $ */
/* $Name: $ */
/* $Date: 2005/06/26 23:40:14 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* This file is part of LibShMem */ /* This file is part of LibShMem */
/* */ /* */
/* LibShMem is free software; you can redistribute it and/or modify */ /* LibShMem is free software: you can redistribute it and/or modify it */
/* it under the terms of the GNU Lesser General Public Licence as published by */ /* under the terms of the GNU Lesser General Public License as published */
/* the Free Software Foundation; either version 2.1 of the License, or */ /* by the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */ /* (at your option) any later version. */
/* */ /* */
/* LibShMem is distributed in the hope that it will be useful, */ /* LibShMem is distributed in the hope that it will be useful, */
@ -20,10 +15,10 @@
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */ /* GNU Lesser General Public License for more details. */
/* */ /* */
/* You should have received a copy of the GNU Lesser General Public License */ /* You should have received a copy of the GNU Lesser General Public */
/* along with LibShMem; if not, write to the Free Software */ /* License along with Drummer. If not, see */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* <https://www.gnu.org/licenses/>. */
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -35,9 +30,16 @@
#include <libshmem.h> #include <libshmem.h>
#ifdef _LIBVER_SUPPORT //#ifdef _LIBVER_SUPPORT
VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agibert $") //VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agibert $")
#endif //#endif
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
@ -49,6 +51,8 @@ VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agib
/* FONCTIONS OPTIMISEES (SM_MODE = 1) */ /* FONCTIONS OPTIMISEES (SM_MODE = 1) */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* Ouverture d'une instance de la librairie */ /* Ouverture d'une instance de la librairie */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
@ -60,6 +64,7 @@ VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agib
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; SMT_Status rc;
LGT_Status lg_status;
int ND_Debug = FALSE; int ND_Debug = FALSE;
int To_Open_Instance; int To_Open_Instance;
NDT_Index_Type index_type = ( NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED); 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( SMD_DEBUG_MSK( Open_Mode)) SM_stderr = stderr;
if( Open_Mode & SMD_DEBUG_ALL) ND_Debug = TRUE; 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 */ /* Définition de l'instance à ouvrir */
@ -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 SM_Library_Close_I( SMT_Flags Close_Mode)
{ {
SMT_Status rc; SMT_Status rc;
LGT_Status lg_status;
if( Close_Mode & SMD_DESTROY) /* Destruction de l'instance */ if( Close_Mode & SMD_DESTROY) /* Destruction de l'instance */
@ -344,6 +357,12 @@ SMT_Status SM_Library_Close_I( SMT_Flags Close_Mode)
SM_Open_Counter--; 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); return( SMS_OK);
} }
@ -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)) 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); return( SMS_ERRAPI);
} }
fprintf( stderr, "Heap to be created!!!\n");
/*Alloc du MHH qui fait l'alloccation du premier segment de donnees*/ /*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); rc = ND_Value_Alloc( (void **)&MHH, SM_Base->MHR, prefixed_name, Seg_Size);
@ -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 */ /* Rien à faire : le heap est déjà verrouillé dans ce mode */
fprintf( stderr, "Already locked !!!\n"); fprintf( stderr, "SM_Heap_Lock: heap [%s] already locked in mode: (%d)!\n", Heap->Name, Lock_Mode);
fflush( stderr); fflush( stderr);
*Locked = FALSE; *Locked = FALSE;
// *Locked = TRUE;
} }
else if( Heap->Lock_Mode == SMD_NO_LOCK) else if( Heap->Lock_Mode == SMD_NO_LOCK)
{ {
@ -1139,6 +1155,10 @@ SMT_Status SM_Heap_Unlock_I ( SMT_Heap * Heap)
{ {
SMT_Status rc; 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); rc = SM_Heap_Lock_Release (Heap->MHH, Heap->Lock_Mode);
if( rc != SMS_OK) if( rc != SMS_OK)
{ {
@ -1146,12 +1166,12 @@ SMT_Status SM_Heap_Unlock_I ( SMT_Heap * Heap)
Heap->Name, Heap->Lock_Mode & SMD_READ ? "reading" : "writing"); 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; Heap->Lock_Mode = SMD_NO_LOCK;
return SMS_OK; return( SMS_OK);
} }
@ -2400,6 +2420,8 @@ SMT_Status SM_Chunk_Free_C ( SMT_Heap * Heap, void * Ptr)
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* FONCTIONS PRIVEES */ /* FONCTIONS PRIVEES */
@ -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); sprintf( SM_Error_Msg, "Error MHR_Manager : unable to lock Heap_Name: [%s] for reading", MHH_Ptr->Name);
SM_Error_Print(); SM_Error_Print();
return( SMS_KO); // return( SMS_KO);
} }
segment_nb = MHH_Ptr->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number; segment_nb = MHH_Ptr->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
@ -5670,3 +5692,31 @@ SMT_Status SM_Name_Prefix( char *Prefixed, const char *Unprefixed)
return( SMS_OK); 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);
}

View File

@ -1,18 +1,13 @@
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* $RCSfile: libshmem.h,v $ */ /* libshmem.h */
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* $Revision: 2.3 $ */
/* $Name: $ */
/* $Date: 2005/06/26 23:02:35 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* This file is part of LibShMem */ /* This file is part of LibShMem */
/* */ /* */
/* LibShMem is free software; you can redistribute it and/or modify */ /* LibShMem is free software: you can redistribute it and/or modify it */
/* it under the terms of the GNU Lesser General Public Licence as published by */ /* under the terms of the GNU Lesser General Public License as published */
/* the Free Software Foundation; either version 2.1 of the License, or */ /* by the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */ /* (at your option) any later version. */
/* */ /* */
/* LibShMem is distributed in the hope that it will be useful, */ /* LibShMem is distributed in the hope that it will be useful, */
@ -20,10 +15,10 @@
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */ /* GNU Lesser General Public License for more details. */
/* */ /* */
/* You should have received a copy of the GNU Lesser General Public License */ /* You should have received a copy of the GNU Lesser General Public */
/* along with LibShMem; if not, write to the Free Software */ /* License along with Drummer. If not, see */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* <https://www.gnu.org/licenses/>. */
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -42,6 +37,8 @@
#include <shmem.h> #include <shmem.h>
#include <execinfo.h>
@ -164,6 +161,11 @@ typedef union semun
unsigned short int * array; unsigned short int * array;
} semun; } semun;
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* Allocation de mémoire dans la base */ /* Allocation de mémoire dans la base */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
@ -299,3 +301,11 @@ void SM_Error_Print (void);
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
SMT_Status SM_Name_Prefix( char *, const char *); SMT_Status SM_Name_Prefix( char *, const char *);
/*------------------------------------------------------------------------------*/
/* Print stack trace */
/*------------------------------------------------------------------------------*/
void SM_stack_trace_print( void);

View File

@ -9,12 +9,12 @@ include ../Makefile.rule
DEP_STATIC += ../lib/libshmem.a ../../libnode/lib/libnode.a DEP_STATIC += ../lib/libshmem.a ../../liblog/lib/liblog.a ../../libnode/lib/libnode.a
DEP_DYNAMIC += ../lib/libshmem.so ../../libnode/lib/libnode.so DEP_DYNAMIC += ../lib/libshmem.so ../../liblog/lib/liblog.so ../../libnode/lib/libnode.so
INCLUDE += -I . -I ../include -I ../../libnode/include INCLUDE += -I . -I ../include -I ../../liblog/include -I ../../libnode/include
LIBDIR += -L . -L ../lib -L ../../libnode/lib LIBDIR += -L . -L ../lib -L ../../liblog/lib -L ../../libnode/lib
LIB_STATIC += ../lib/libshmem.a ../../libnode/lib/libnode.a -ldl LIB_STATIC += ../lib/libshmem.a ../../liblog/lib/liblog.a ../../libnode/lib/libnode.a -ldl
LIB_DYNAMIC += -lshmem -lnode -ldl LIB_DYNAMIC += -lshmem -llog -lnode -ldl
CFLAGS += -rdynamic CFLAGS += -rdynamic
ifdef _LIBVER_SUPPORT ifdef _LIBVER_SUPPORT

View File

@ -314,9 +314,9 @@ int main( int argc, char **argv)
break; 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; break;
} }
@ -328,9 +328,9 @@ int main( int argc, char **argv)
break; 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; break;
} }