- 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
#------------------------------------------------------------------------------

View File

@ -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

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -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 */
/* <https://www.gnu.org/licenses/>. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
#ifndef _LIBSM
#define _LIBSM
@ -38,11 +35,34 @@
#include <stdarg.h>
#include <sys/types.h>
#include <log.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 */
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 );

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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 */
/* <https://www.gnu.org/licenses/>. */
/*----------------------------------------------------------------------------*/
@ -42,6 +37,8 @@
#include <shmem.h>
#include <execinfo.h>
@ -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);

View File

@ -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

View File

@ -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;
}