Continue LibNode 2.1.x migration,

Lot of bugs fixed,
Now compile,
Managers need a lot of fixes...
This commit is contained in:
agibert 2005-01-24 23:10:09 +00:00
parent d05bee0900
commit 4cfc687710
3 changed files with 138 additions and 116 deletions

View File

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------------*/
/* $RCSfile: libshmem.c,v $ */
/*---------------------------------------------------------------------------------*/
/* $Revision: 2.0 $ */
/* $Revision: 2.1 $ */
/* $Name: $ */
/* $Date: 2005/01/24 22:57:06 $ */
/* $Date: 2005/01/24 23:10:09 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
@ -36,7 +36,7 @@
#include <libshmem.h>
#ifdef _LIBVER_SUPPORT
VER_INFO_EXPORT(libshmem,"$Revision: 2.0 $", "$Name: $",__FILE__,"$Author: agibert $")
VER_INFO_EXPORT(libshmem,"$Revision: 2.1 $", "$Name: $",__FILE__,"$Author: agibert $")
#endif
/*------------------------------------------------------------------------------*/
@ -369,7 +369,7 @@ SMT_Status SM_Library_Dump_I( FILE *Out)
/* Affichage des informations de chaque heap */
return( ND_DataStruct_Print( Out, SM_Base->MHR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0));
return( ND_DataStruct_Value_Print( Out, SM_Base->MHR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0));
}
@ -400,7 +400,7 @@ SMT_Status SM_Library_Unlock_I( void)
/* Libération des verrous sur les heaps */
ND_Node_First_Get( SM_Base->MHR, &Node);
ND_Index_Node_First_Get( &Node, SM_Base->MHR, NDD_INDEX_PRIMARY);
while( Node)
{
@ -415,15 +415,15 @@ SMT_Status SM_Library_Unlock_I( void)
return( SMS_ERRSEM);
}
ND_Node_Next_Get( Node, &Node);
ND_Index_Node_Next_Get( &Node, Node);
}
ND_Node_First_Get( Opened_Heap_List, &Node);
ND_Index_Node_First_Get( &Node, Opened_Heap_List, NDD_INDEX_PRIMARY);
while( Node)
{
( (SMT_Heap *)(Node->Value))->Lock_Mode = SMD_NO_LOCK;
ND_Node_Next_Get( Node, &Node);
ND_Index_Node_Next_Get( &Node, Node);
}
return( SMS_OK);
@ -471,7 +471,7 @@ SMT_Status SM_Heap_Exist_I ( const char *Heap_Name)
/* Recherche dans le MHR */
ND_Node_First_Get( SM_Base->MHR, &Node);
ND_Index_Node_First_Get( &Node, SM_Base->MHR, NDD_INDEX_PRIMARY);
while( Node)
{
@ -482,7 +482,7 @@ SMT_Status SM_Heap_Exist_I ( const char *Heap_Name)
return( SMS_YES);
}
ND_Node_Next_Get( Node, &Node);
ND_Index_Node_Next_Get( &Node, Node);
}
/* Déverrouillage éventuel du heap système */
@ -565,7 +565,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
/* Ouverture d'un heap existant */
strcpy( To_Find.Name, Prefixed_Name);
ND_Node_Find( SM_Base->MHR, &Node, &To_Find, NULL);
ND_Index_Node_Find( &Node, SM_Base->MHR, NDD_INDEX_PRIMARY, &To_Find, NULL);
MHH = (SMT_MHH *)( Node->Value);
@ -584,7 +584,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
/* On ouvre tous les segments du heap */
ND_Node_First_Get( ( *Heap)->MHH->DSR, &Node);
ND_Index_Node_First_Get( &Node, ( *Heap)->MHH->DSR, NDD_INDEX_PRIMARY);
while( Node)
{
@ -598,7 +598,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
goto Error1;
}
ND_Node_Next_Get( Node, &Node);
ND_Index_Node_Next_Get( &Node, Node);
}
(*Heap)->Nb_Seg = (*Heap)->MHH->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
@ -617,7 +617,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
/* Ajout au cache des heaps ouverts */
rc = ND_Value_Add (Opened_Heap_List, *Heap);
rc = ND_DataStruct_Value_Add (Opened_Heap_List, *Heap);
if( rc != NDS_OK)
{
@ -692,7 +692,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
/* Réservation du MHH (dans la base pour le heap système, dans le heap système pour les autres heaps) */
if( ND_Allocator_Exec( SM_Base->MHR->Allocator_Ptr, (void **)(&MHH), sizeof( SMT_MHH), NULL) != NDS_OK)
if( ND_Allocator_Exec( (void **)(&MHH), sizeof( SMT_MHH), SM_Base->MHR->Allocator_Name, SM_Base->MHR->Allocator_Ptr, NULL) != NDS_OK)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to allocate memory for the heap header");
SM_Error_Print();
@ -773,7 +773,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
goto Error7;
}
rc = ND_Value_Add( MHH->DSR, New_DSH);
rc = ND_DataStruct_Value_Add( MHH->DSR, New_DSH);
if( rc != NDS_OK)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add a data segment to the DSR structure");
@ -786,7 +786,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
/* Ajout du nouveau heap à la structure MHR */
rc = ND_Value_Add( SM_Base->MHR, MHH);
rc = ND_DataStruct_Value_Add( SM_Base->MHR, MHH);
if( rc != NDS_OK)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add the new heap to the MHR structure");
@ -826,7 +826,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
( *Heap)->Lock_Mode = SMD_LOCK_MSK( Open_Mode);
( *Heap)->Nb_Seg = 1;
rc = ND_Value_Add( Opened_Heap_List, *Heap);
rc = ND_DataStruct_Value_Add( Opened_Heap_List, *Heap);
if( rc != NDS_OK)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add heap \"%s\" to the opened heap cache", Prefixed_Name);
@ -848,25 +848,25 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
*Heap = NULL;
Error10:
ND_Value_Remove( SM_Base->MHR, MHH, (void **)&MHH);
ND_DataStruct_Value_Remove( SM_Base->MHR, MHH);
Error9:
ND_Value_Remove( MHH->DSR, New_DSH, (void **)&New_DSH);
ND_DataStruct_Value_Remove( MHH->DSR, New_DSH);
Error8:
SM_DataSegment_End( MHH->DSR, New_DSH);
Error7:
ND_Desallocator_Exec( SM_Base->MHR->Desallocator_Ptr, MHH->FCR, NULL);
ND_Desallocator_Exec( MHH->FCR, SM_Base->MHR->Desallocator_Name, SM_Base->MHR->Desallocator_Ptr, NULL);
Error6:
ND_Desallocator_Exec( SM_Base->MHR->Desallocator_Ptr, MHH->ACR, NULL);
ND_Desallocator_Exec( MHH->ACR, SM_Base->MHR->Desallocator_Name, SM_Base->MHR->Desallocator_Ptr, NULL);
Error5:
ND_Desallocator_Exec( SM_Base->MHR->Desallocator_Ptr, MHH->DSR, NULL);
ND_Desallocator_Exec( MHH->DSR, SM_Base->MHR->Desallocator_Name, SM_Base->MHR->Desallocator_Ptr, NULL);
Error4:
ND_Desallocator_Exec( SM_Base->MHR->Desallocator_Ptr, MHH, NULL);
ND_Desallocator_Exec( MHH, SM_Base->MHR->Desallocator_Name, SM_Base->MHR->Desallocator_Ptr, NULL);
Error3:
semctl( SemID, 0, IPC_RMID, Sem_Ctl);
@ -901,22 +901,32 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
SMT_Status SM_Heap_IsOpen_I( const char *Heap_Name, SMT_Heap **Heap )
{
SMT_Status rc;
SMT_Heap To_Find;
NDT_Node * Node;
NDT_Node *Node_Ptr;
*Heap = NULL;
To_Find.Name = SM_Name_Prefix( Heap_Name);
rc = ND_Node_Find (Opened_Heap_List, &Node, &To_Find, NULL);
rc = ND_Index_Node_Find( &Node_Ptr, Opened_Heap_List, NDD_INDEX_PRIMARY, &To_Find, NULL);
if (SM_ERROR(rc)) return rc;
if (rc == NDS_KO) return SMS_NO;
*Heap = (SMT_Heap *)(Node->Value);
return SMS_YES;
if( ND_ERROR(rc))
{
return( SMS_KO);
}
else
{
if( Node_Ptr == NULL)
{
return( SMS_NO);
}
else
{
*Heap = (SMT_Heap *)( Node_Ptr->Value);
return( SMS_YES);
}
}
}
@ -970,7 +980,7 @@ SMT_Status SM_Heap_End_I ( const char * Heap_Name )
/* Suppression du heap */
rc = ND_Value_Remove (SM_Base->MHR, Heap->MHH, (void **)&(Heap->MHH));
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);
@ -1011,13 +1021,13 @@ SMT_Status SM_Heap_Close_I ( SMT_Heap * Heap)
en commencant par le dernier (important pour le heap système)
*/
ND_Node_Last_Get (Heap->MHH->DSR, &Node);
ND_Index_Node_Last_Get( &Node, Heap->MHH->DSR, NDD_INDEX_PRIMARY);
while (Node)
{
rc = SM_DataSegment_Close (Node->Value);
if (SM_ERROR(rc)) return rc;
ND_Node_Previous_Get (Node, &Node);
ND_Index_Node_Previous_Get( &Node, Node);
}
/* Déverrouillage du heap */
@ -1026,7 +1036,7 @@ SMT_Status SM_Heap_Close_I ( SMT_Heap * Heap)
/* Suppression du heap de la liste des heaps ouverts */
rc = ND_Value_Remove (Opened_Heap_List, Heap, (void **)&Heap);
rc = ND_DataStruct_Value_Remove( Opened_Heap_List, Heap);
if (SM_ERROR(rc)) return rc;
rc = ND_Value_Free( Opened_Heap_List, Heap);
@ -1142,7 +1152,7 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
/* On ouvre tous les segments du heap */
ND_Node_First_Get (Heap->MHH->DSR, &Node);
ND_Index_Node_First_Get( &Node, Heap->MHH->DSR, NDD_INDEX_PRIMARY);
while (Node)
{
rc = SM_DataSegment_Open (Node->Value);
@ -1155,7 +1165,7 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
return rc;
}
ND_Node_Next_Get (Node, &Node);
ND_Index_Node_Next_Get( &Node, Node);
}
Heap->Nb_Seg = Heap->MHH->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
@ -1316,11 +1326,11 @@ SMT_Status SM_Heap_Compress_I ( SMT_Heap * Heap, size_t * Compress)
/* Compression de chaque segment de données du heap */
ND_Node_First_Get (Heap->MHH->DSR, &Node);
ND_Index_Node_First_Get( &Node, Heap->MHH->DSR, NDD_INDEX_PRIMARY);
while (Node)
{
*Compress += SM_DataSegment_Compress ((SMT_DSH *)(Node->Value), Heap->MHH->FCR);
ND_Node_Next_Get (Node, &Node);
ND_Index_Node_Next_Get( &Node, Node);
}
return SMS_OK;
@ -1381,7 +1391,7 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc
/* Ouverture des segments du heap au cas ça n'aurait pas été fait */
ND_Node_First_Get (Heap->MHH->DSR, &Node);
ND_Index_Node_First_Get( &Node, Heap->MHH->DSR, NDD_INDEX_PRIMARY);
while (Node)
{
@ -1399,7 +1409,7 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc
return rc;
}
ND_Node_Next_Get (Node, &Node);
ND_Index_Node_Next_Get( &Node, Node);
}
/* Vérification de la structure ACR du heap */
@ -1518,13 +1528,13 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
Found = FALSE;
ND_Node_First_Get (Heap->MHH->FCR, &Node);
ND_Index_Node_First_Get( &Node, Heap->MHH->FCR, NDD_INDEX_PRIMARY);
while (Found == FALSE && Node)
{
Chunk = (SMT_Chunk *)(Node->Value);
if (Chunk->Size >= Alloc_Size) Found = TRUE;
else ND_Node_Next_Get (Node, &Node);
else ND_Index_Node_Next_Get( &Node, Node);
}
if (Found == FALSE)
@ -1550,7 +1560,7 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
return SMS_ERRSHM;
}
rc = ND_Value_Add (Heap->MHH->DSR, DSH);
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);
@ -1572,7 +1582,7 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
/* Suppression du chunk de la liste des chunks libres */
rc = ND_Node_Remove (Node);
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);
@ -1583,7 +1593,7 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
/* Ajout du chunk à la liste des chunks alloués */
rc = ND_Node_Add (Heap->MHH->ACR, Node);
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);
@ -1591,7 +1601,7 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
/* On tente de revenir en arrière */
ND_Node_Add (Heap->MHH->FCR, Node);
ND_Index_Node_Add( Heap->MHH->FCR, NDD_INDEX_PRIMARY, Node);
return rc;
}
@ -1635,7 +1645,7 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
New_Node->Right = NULL;
New_Node->Value = New_Chunk;
rc = ND_Node_Add (Heap->MHH->FCR, New_Node);
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);
@ -1667,7 +1677,7 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
/* On compte le nombre de chunks libres "utilisables" dans la structure FCR */
ND_Node_First_Get (Heap->MHH->FCR, &Node);
ND_Index_Node_First_Get( &Node, Heap->MHH->FCR, NDD_INDEX_PRIMARY);
while (Node)
{
Free_Chunk = Node->Value;
@ -1678,7 +1688,7 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
Free_Usable_Size += Free_Chunk->Size;
}
ND_Node_Next_Get (Node, &Node);
ND_Index_Node_Next_Get( &Node, Node);
}
/*
@ -1714,7 +1724,7 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
SM_DataSegment_Init pour éviter que ce noeud soit alloué dans le nouveau segment.
*/
SM_System_Alloc (sizeof (NDT_Node), (void **)(&New_Node), NULL);
SM_System_Alloc( (void **)(&New_Node), sizeof (NDT_Node), NULL);
New_Node->Root = NULL;
New_Node->Parent = NULL;
New_Node->Left = NULL;
@ -1735,7 +1745,7 @@ SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr )
/* On ajoute le nouveau segment au heap système */
rc = ND_Node_Add (Heap->MHH->DSR, New_Node);
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)");
@ -1798,7 +1808,7 @@ SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr)
/* Suppression du chunk de la liste des chunks alloués */
rc = ND_Node_Remove (Node);
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);
@ -1809,7 +1819,7 @@ SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr)
/* Ajout du chunk à la liste des chunks libres */
rc = ND_Node_Add (Heap->MHH->FCR, Node);
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);
@ -1817,7 +1827,7 @@ SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr)
/* Retour arrière */
ND_Node_Add (Heap->MHH->ACR, Node);
ND_Index_Node_Add( Heap->MHH->ACR, NDD_INDEX_PRIMARY, Node);
return rc;
}
@ -2467,14 +2477,12 @@ SMT_Status SM_Chunk_Free_C ( SMT_Heap * Heap, void * Ptr)
/* Allocation de mémoire dans la base */
/*------------------------------------------------------------------------------*/
SMT_Status SM_Base_Alloc (size_t Size, void ** Ptr, void * Data)
NDT_Status SM_Base_Alloc( void **Ptr, size_t Size, void *Data_Ptr)
{
*Ptr = NULL;
*Ptr = SM_Base->Free;
SM_Base->Free = (void *)((size_t)(SM_Base->Free) + Size);
return SMS_OK;
return( NDS_OK);
}
@ -2485,11 +2493,11 @@ SMT_Status SM_Base_Alloc (size_t Size, void ** Ptr, void * Data)
/* Désallocation de mémoire dans la base */
/*------------------------------------------------------------------------------*/
SMT_Status SM_Base_Free (void * Ptr, void * Data)
NDT_Status SM_Base_Free( void *Ptr, void *Data_Ptr)
{
if (!Ptr) return SMS_ERRAPI;
if( !Ptr) return( SMS_ERRAPI);
return SMS_OK;
return( NDS_OK);
}
@ -2500,9 +2508,9 @@ SMT_Status SM_Base_Free (void * Ptr, void * Data)
/* Allocation de mémoire dans le heap système */
/*------------------------------------------------------------------------------*/
SMT_Status SM_System_Alloc (size_t Size, void ** Ptr, void * Data)
NDT_Status SM_System_Alloc( void **Ptr, size_t Size, void *Data_Ptr)
{
return SM_Chunk_Alloc_I (System_Heap, Size, Ptr);
return( SM_Chunk_Alloc_I( System_Heap, Size, Ptr));
}
@ -2513,9 +2521,9 @@ SMT_Status SM_System_Alloc (size_t Size, void ** Ptr, void * Data)
/* Désallocation de mémoire dans le heap système */
/*------------------------------------------------------------------------------*/
SMT_Status SM_System_Free (void * Ptr, void * Data)
NDT_Status SM_System_Free( void *Ptr, void *Data_Ptr)
{
return SM_Chunk_Free_I (System_Heap, Ptr);
return( SM_Chunk_Free_I( System_Heap, Ptr));
}
@ -2834,13 +2842,13 @@ SMT_Status SM_Base_End ( void )
NB : à chaque destruction de heap, la base est verrouillée en écriture
*/
ND_Node_Last_Get (SM_Base->MHR, &Node);
ND_Index_Node_Last_Get( &Node, SM_Base->MHR, NDD_INDEX_PRIMARY);
while (Node)
{
SMT_MHH * MHH = (SMT_MHH *)(Node->Value);
ND_Node_Previous_Get (Node, &Previous_Node);
ND_Index_Node_Previous_Get( &Previous_Node, Node);
/*
Pour la suppression du heap système, il faut redéfinir la fonction de
@ -2854,7 +2862,7 @@ SMT_Status SM_Base_End ( void )
/* Retrait du heap de la structure du MHR */
rc = ND_Value_Remove (SM_Base->MHR, MHH, (void **)&MHH);
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);
@ -3075,12 +3083,12 @@ SMT_Status SM_Base_Close ( void )
Attention : il faut fermer le heap système en dernier.
*/
ND_Node_First_Get (Opened_Heap_List, &Node);
ND_Index_Node_First_Get( &Node, Opened_Heap_List, NDD_INDEX_PRIMARY);
while (Node)
{
NDT_Node *Next_Node;
ND_Node_Next_Get (Node, &Next_Node);
ND_Index_Node_Next_Get( &Next_Node, Node);
SM_Heap_Close_I ((SMT_Heap *)(Node->Value));
Node = Next_Node;;
}
@ -3360,13 +3368,13 @@ SMT_Status SM_MHH_End ( SMT_MHH * MHH)
du DSR pour celui-ci.
*/
ND_Node_Last_Get (MHH->DSR, &Node);
ND_Index_Node_Last_Get( &Node, MHH->DSR, NDD_INDEX_PRIMARY);
while (Node)
{
DSH = (SMT_DSH *)(Node->Value);
ND_Node_Previous_Get (Node, &Previous_Node);
ND_Index_Node_Previous_Get( &Previous_Node, Node);
/* S'agit-il du heap système ? */
@ -3377,7 +3385,7 @@ SMT_Status SM_MHH_End ( SMT_MHH * MHH)
/* Retrait du segment du DSR */
rc = ND_Value_Remove (MHH->DSR, DSH, (void **)&DSH);
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);
@ -3418,14 +3426,14 @@ SMT_Status SM_MHH_End ( SMT_MHH * MHH)
leur racine.
*/
rc = ND_Desallocator_Exec( SM_Base->MHR->Desallocator_Ptr, MHH->ACR, NULL);
rc = ND_Desallocator_Exec( MHH->ACR, SM_Base->MHR->Desallocator_Name, SM_Base->MHR->Desallocator_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 ();
}
rc = ND_Desallocator_Exec (SM_Base->MHR->Desallocator_Ptr, MHH->FCR, NULL);
rc = ND_Desallocator_Exec( MHH->FCR, SM_Base->MHR->Desallocator_Name, SM_Base->MHR->Desallocator_Ptr, NULL);
if (rc != NDS_OK)
{
sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the FCR root of heap \"%s\"", MHH->Name);
@ -3435,11 +3443,25 @@ SMT_Status SM_MHH_End ( SMT_MHH * MHH)
/* Suppression du heap de la liste des heaps ouverts */
To_Find.Name = MHH->Name;
rc = ND_Value_Remove (Opened_Heap_List, &To_Find, (void **)&Opened_Heap);
if (rc == NDS_OK)
rc = ND_DataStruct_Value_Find( (void **)&Opened_Heap, Opened_Heap_List, &To_Find);
if( ( rc == NDS_OK) && ( Opened_Heap != NULL))
{
rc = ND_DataStruct_Value_Remove( Opened_Heap_List, Opened_Heap);
if (rc != NDS_OK)
{
return( rc);
}
else
{
rc = ND_Value_Free( Opened_Heap_List, Opened_Heap);
if (rc != NDS_OK) return rc;
if( rc != NDS_OK)
{
return( rc);
}
}
}
/* Destruction du sémaphore attaché au heap */
@ -3448,7 +3470,7 @@ SMT_Status SM_MHH_End ( SMT_MHH * MHH)
/* Désallocation de la structure du MHH */
rc = ND_Desallocator_Exec( SM_Base->MHR->Desallocator_Ptr, MHH, NULL);
rc = ND_Desallocator_Exec( MHH, SM_Base->MHR->Desallocator_Name, SM_Base->MHR->Desallocator_Ptr, NULL);
if (rc != SMS_OK)
{
sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the header of heap \"%s\"", MHH->Name);
@ -3571,7 +3593,7 @@ SMT_DSH * SM_DataSegment_Init ( SMT_MHH * MHH, size_t Segment_Size)
/* Création de l'entête */
if( ND_Allocator_Exec( MHH->DSR->Allocator_Ptr, (void **)(&New_DSH), sizeof (SMT_DSH), NULL) != NDS_OK)
if( ND_Allocator_Exec( (void **)(&New_DSH), sizeof (SMT_DSH), MHH->DSR->Allocator_Name, MHH->DSR->Allocator_Ptr, NULL) != NDS_OK)
{
sprintf (SM_Error_Msg, "SM_DataSegment_Init : unable to allocate memory for the new data segment header");
SM_Error_Print ();
@ -3604,7 +3626,7 @@ SMT_DSH * SM_DataSegment_Init ( SMT_MHH * MHH, size_t Segment_Size)
SM_Error_Print ();
ND_Desallocator_Exec( MHH->DSR->Desallocator_Ptr, New_DSH, NULL);
ND_Desallocator_Exec( New_DSH, MHH->DSR->Desallocator_Name, MHH->DSR->Desallocator_Ptr, NULL);
return NULL;
}
@ -3620,7 +3642,7 @@ SMT_DSH * SM_DataSegment_Init ( SMT_MHH * MHH, size_t Segment_Size)
shmctl (New_DSH->MemID, IPC_RMID, 0);
ND_Desallocator_Exec( MHH->DSR->Desallocator_Ptr, New_DSH, NULL);
ND_Desallocator_Exec( New_DSH, MHH->DSR->Desallocator_Name, MHH->DSR->Desallocator_Ptr, NULL);
return NULL;
}
@ -3645,14 +3667,14 @@ SMT_DSH * SM_DataSegment_Init ( SMT_MHH * MHH, size_t Segment_Size)
/* Ajout du chunk libre à la liste des chunks libres du heap */
if (ND_Node_Add (MHH->FCR, Chunk_Node) != NDS_OK)
if (ND_Index_Node_Add( MHH->FCR, NDD_INDEX_PRIMARY, Chunk_Node) != NDS_OK)
{
sprintf (SM_Error_Msg, "SM_DataSegment_Init : unable to add a first chunk to the FCR structure of heap \"%s\"", MHH->Name);
SM_Error_Print ();
shmctl (New_DSH->MemID, IPC_RMID, 0);
ND_Desallocator_Exec( MHH->DSR->Desallocator_Ptr, New_DSH, NULL);
ND_Desallocator_Exec( New_DSH, MHH->DSR->Desallocator_Name, MHH->DSR->Desallocator_Ptr, NULL);
return NULL;
}
@ -3698,7 +3720,7 @@ SMT_Status SM_DataSegment_End (NDT_Root * Root, SMT_DSH *DSH)
/* Désallocation de l'entête */
rc = ND_Desallocator_Exec( Root->Desallocator_Ptr, DSH, NULL);
rc = ND_Desallocator_Exec( DSH, Root->Desallocator_Name, Root->Desallocator_Ptr, NULL);
if (rc != NDS_OK)
{
sprintf (SM_Error_Msg, "SM_DataSegment_End : the data segment header is nul");
@ -3784,7 +3806,7 @@ size_t SM_DataSegment_Compress ( SMT_DSH *DSH, NDT_Root *FCR)
/* Recherche du premier chunk libre contenu dans le segment courant */
ND_Node_First_Get (FCR, &Node);
ND_Index_Node_First_Get( &Node, FCR, NDD_INDEX_PRIMARY);
while (Found == FALSE && Node)
{
@ -3792,7 +3814,7 @@ size_t SM_DataSegment_Compress ( SMT_DSH *DSH, NDT_Root *FCR)
else
{
if (Node >= (NDT_Node *)(DSH->Start)) Found = TRUE;
else ND_Node_Next_Get (Node, &Node);
else ND_Index_Node_Next_Get( &Node, Node);
}
}
@ -3800,7 +3822,7 @@ size_t SM_DataSegment_Compress ( SMT_DSH *DSH, NDT_Root *FCR)
/* Parcours de tous les chunks libres du segment courant */
ND_Node_Next_Get (Node, &Next_Node);
ND_Index_Node_Next_Get( &Next_Node, Node);
while (Next_Node && (void *)Next_Node < DSH_End)
{
@ -3812,7 +3834,7 @@ size_t SM_DataSegment_Compress ( SMT_DSH *DSH, NDT_Root *FCR)
if (Next_Node == (NDT_Node *)((size_t)(Chunk->Data) + Chunk->Size))
{
ND_Node_Remove (Next_Node);
ND_Index_Node_Remove (Next_Node);
Compress = sizeof (SMT_Chunk) + sizeof (NDT_Node);
@ -3820,12 +3842,12 @@ size_t SM_DataSegment_Compress ( SMT_DSH *DSH, NDT_Root *FCR)
Total_Compress += Compress;
ND_Node_Next_Get (Node, &Next_Node);
ND_Index_Node_Next_Get( &Next_Node, Node);
}
else
{
Node = Next_Node;
ND_Node_Next_Get (Next_Node, &Next_Node);
ND_Index_Node_Next_Get( &Next_Node, Next_Node);
}
}

View File

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------------*/
/* $RCSfile: libshmem.h,v $ */
/*---------------------------------------------------------------------------------*/
/* $Revision: 2.0 $ */
/* $Revision: 2.1 $ */
/* $Name: $ */
/* $Date: 2005/01/24 22:57:06 $ */
/* $Date: 2005/01/24 23:10:09 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
@ -166,22 +166,22 @@ typedef union semun
/*------------------------------------------------------------------------------*/
/* Allocation de mémoire dans la base */
/*------------------------------------------------------------------------------*/
SMT_Status SM_Base_Alloc (size_t, void **, void *);
NDT_Status SM_Base_Alloc( void **, size_t, void *);
/*------------------------------------------------------------------------------*/
/* Désallocation de mémoire dans la base */
/*------------------------------------------------------------------------------*/
SMT_Status SM_Base_Free (void *, void *);
NDT_Status SM_Base_Free( void *, void *);
/*------------------------------------------------------------------------------*/
/* Allocation de mémoire dans le heap système */
/*------------------------------------------------------------------------------*/
SMT_Status SM_System_Alloc (size_t, void **, void *);
NDT_Status SM_System_Alloc( void **, size_t, void *);
/*------------------------------------------------------------------------------*/
/* Désallocation de mémoire dans le heap système */
/*------------------------------------------------------------------------------*/
SMT_Status SM_System_Free (void *, void *);
NDT_Status SM_System_Free( void *, void *);
/*------------------------------------------------------------------------------*/
/* Initialisation de la base */

View File

@ -6,7 +6,7 @@
#define SM_MODE 0 /* Utilisation des API sécurisés */
#include <shmem.h>
/* VER_INFO_EXPORT (smadmin, "$Revision: 2.0 $", "$Name: $", __FILE__, "$Author: agibert $") */
//VER_INFO_EXPORT (smadmin, "$Revision: 2.1 $", "$Name: $", __FILE__, "$Author: agibert $")
#define USAGE "Usage : %s [ --help | --version [-v] | --create | --destroy ]\n"
@ -56,13 +56,13 @@ int main (int argc, char ** argv)
fprintf (stderr, USAGE, argv[0]);
return -1;
}
else if (!strcmp (argv[1], "--version"))
/* else if (!strcmp (argv[1], "--version"))
{
if (argc >= 3 && !strcmp (argv[2], "-v"))
return VER_Object_Print (stdout, VERD_VERBOSE);
else
return VER_Object_Print (stdout, VERD_MINIMAL);
}
} */
else if (!strcmp (argv[1], "--create"))
{
if (SM_Library_Open (0, NULL, SMD_CREATE | SMD_DEBUG_ALL) != SMS_OK)
@ -261,8 +261,8 @@ int main (int argc, char ** argv)
gets (name);
if (SM_Heap_Open (name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked) == SMS_OK)
{
ND_DataStruct_Info_Print (Heap->MHH->DSR, stdout);
ND_DataStruct_Print (Heap->MHH->DSR, stdout);
ND_DataStruct_Info_Print( stdout, Heap->MHH->DSR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
ND_DataStruct_Value_Print( stdout, Heap->MHH->DSR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
if (Locked == TRUE) SM_Heap_Unlock (Heap);
}
break;
@ -272,8 +272,8 @@ int main (int argc, char ** argv)
gets (name);
if (SM_Heap_Open (name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked) == SMS_OK)
{
ND_DataStruct_Info_Print (Heap->MHH->ACR, stdout);
ND_DataStruct_Print (Heap->MHH->ACR, stdout);
ND_DataStruct_Info_Print( stdout, Heap->MHH->ACR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
ND_DataStruct_Value_Print( stdout, Heap->MHH->ACR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
if (Locked == TRUE) SM_Heap_Unlock (Heap);
}
break;
@ -283,8 +283,8 @@ int main (int argc, char ** argv)
gets (name);
if (SM_Heap_Open (name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked) == SMS_OK)
{
ND_DataStruct_Info_Print (Heap->MHH->FCR, stdout);
ND_DataStruct_Print (Heap->MHH->FCR, stdout);
ND_DataStruct_Info_Print( stdout, Heap->MHH->FCR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
ND_DataStruct_Value_Print( stdout, Heap->MHH->FCR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
if (Locked == TRUE) SM_Heap_Unlock (Heap);
}
break;