Continue LibNode 2.1.x migration,
Lot of bugs fixed, Now compile, Managers need a lot of fixes...
This commit is contained in:
parent
d05bee0900
commit
4cfc687710
222
lib/libshmem.c
222
lib/libshmem.c
@ -1,9 +1,9 @@
|
|||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* $RCSfile: libshmem.c,v $ */
|
/* $RCSfile: libshmem.c,v $ */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* $Revision: 2.0 $ */
|
/* $Revision: 2.1 $ */
|
||||||
/* $Name: $ */
|
/* $Name: $ */
|
||||||
/* $Date: 2005/01/24 22:57:06 $ */
|
/* $Date: 2005/01/24 23:10:09 $ */
|
||||||
/* $Author: agibert $ */
|
/* $Author: agibert $ */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -36,7 +36,7 @@
|
|||||||
#include <libshmem.h>
|
#include <libshmem.h>
|
||||||
|
|
||||||
#ifdef _LIBVER_SUPPORT
|
#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
|
#endif
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------------*/
|
||||||
@ -369,7 +369,7 @@ SMT_Status SM_Library_Dump_I( FILE *Out)
|
|||||||
|
|
||||||
/* Affichage des informations de chaque heap */
|
/* 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 */
|
/* 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)
|
while( Node)
|
||||||
{
|
{
|
||||||
@ -415,15 +415,15 @@ SMT_Status SM_Library_Unlock_I( void)
|
|||||||
return( SMS_ERRSEM);
|
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)
|
while( Node)
|
||||||
{
|
{
|
||||||
( (SMT_Heap *)(Node->Value))->Lock_Mode = SMD_NO_LOCK;
|
( (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);
|
return( SMS_OK);
|
||||||
@ -471,7 +471,7 @@ SMT_Status SM_Heap_Exist_I ( const char *Heap_Name)
|
|||||||
|
|
||||||
/* Recherche dans le MHR */
|
/* 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)
|
while( Node)
|
||||||
{
|
{
|
||||||
@ -482,7 +482,7 @@ SMT_Status SM_Heap_Exist_I ( const char *Heap_Name)
|
|||||||
return( SMS_YES);
|
return( SMS_YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
ND_Node_Next_Get( Node, &Node);
|
ND_Index_Node_Next_Get( &Node, Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Déverrouillage éventuel du heap système */
|
/* 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 */
|
/* Ouverture d'un heap existant */
|
||||||
|
|
||||||
strcpy( To_Find.Name, Prefixed_Name);
|
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);
|
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 */
|
/* 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)
|
while( Node)
|
||||||
{
|
{
|
||||||
@ -598,7 +598,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
|
|||||||
goto Error1;
|
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;
|
(*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 */
|
/* 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)
|
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) */
|
/* 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");
|
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to allocate memory for the heap header");
|
||||||
SM_Error_Print();
|
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;
|
goto Error7;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ND_Value_Add( MHH->DSR, New_DSH);
|
rc = ND_DataStruct_Value_Add( MHH->DSR, New_DSH);
|
||||||
if( rc != NDS_OK)
|
if( rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add a data segment to the DSR structure");
|
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 */
|
/* 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)
|
if( rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add the new heap to the MHR structure");
|
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)->Lock_Mode = SMD_LOCK_MSK( Open_Mode);
|
||||||
( *Heap)->Nb_Seg = 1;
|
( *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)
|
if( rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add heap \"%s\" to the opened heap cache", Prefixed_Name);
|
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;
|
*Heap = NULL;
|
||||||
|
|
||||||
Error10:
|
Error10:
|
||||||
ND_Value_Remove( SM_Base->MHR, MHH, (void **)&MHH);
|
ND_DataStruct_Value_Remove( SM_Base->MHR, MHH);
|
||||||
|
|
||||||
Error9:
|
Error9:
|
||||||
ND_Value_Remove( MHH->DSR, New_DSH, (void **)&New_DSH);
|
ND_DataStruct_Value_Remove( MHH->DSR, New_DSH);
|
||||||
|
|
||||||
Error8:
|
Error8:
|
||||||
SM_DataSegment_End( MHH->DSR, New_DSH);
|
SM_DataSegment_End( MHH->DSR, New_DSH);
|
||||||
|
|
||||||
Error7:
|
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:
|
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:
|
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:
|
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:
|
Error3:
|
||||||
semctl( SemID, 0, IPC_RMID, Sem_Ctl);
|
semctl( SemID, 0, IPC_RMID, Sem_Ctl);
|
||||||
@ -898,25 +898,35 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
|
|||||||
/* (O) Heap : pointeur sur le heap ouvert */
|
/* (O) Heap : pointeur sur le heap ouvert */
|
||||||
/*------------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
SMT_Status SM_Heap_IsOpen_I ( const char * Heap_Name, SMT_Heap ** Heap )
|
SMT_Status SM_Heap_IsOpen_I( const char *Heap_Name, SMT_Heap **Heap )
|
||||||
{
|
{
|
||||||
SMT_Status rc;
|
SMT_Status rc;
|
||||||
|
|
||||||
SMT_Heap To_Find;
|
SMT_Heap To_Find;
|
||||||
NDT_Node * Node;
|
NDT_Node *Node_Ptr;
|
||||||
|
|
||||||
|
|
||||||
*Heap = NULL;
|
*Heap = NULL;
|
||||||
|
|
||||||
To_Find.Name = SM_Name_Prefix (Heap_Name);
|
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( ND_ERROR(rc))
|
||||||
|
{
|
||||||
if (rc == NDS_KO) return SMS_NO;
|
return( SMS_KO);
|
||||||
|
}
|
||||||
*Heap = (SMT_Heap *)(Node->Value);
|
else
|
||||||
return SMS_YES;
|
{
|
||||||
|
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 */
|
/* 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)
|
if (rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf (SM_Error_Msg, "SM_Heap_End: unable to remove heap \"%s\" from the MHR structure", Heap_Name);
|
sprintf (SM_Error_Msg, "SM_Heap_End: unable to remove heap \"%s\" from the MHR structure", Heap_Name);
|
||||||
@ -979,7 +989,7 @@ SMT_Status SM_Heap_End_I ( const char * Heap_Name )
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ND_Value_Free (SM_Base->MHR, Heap->MHH);
|
rc = ND_Value_Free( SM_Base->MHR, Heap->MHH);
|
||||||
if (rc != NDS_OK)
|
if (rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf (SM_Error_Msg, "SM_Heap_End: unable to free heap \"%s\"", Heap_Name);
|
sprintf (SM_Error_Msg, "SM_Heap_End: unable to free heap \"%s\"", 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)
|
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)
|
while (Node)
|
||||||
{
|
{
|
||||||
rc = SM_DataSegment_Close (Node->Value);
|
rc = SM_DataSegment_Close (Node->Value);
|
||||||
if (SM_ERROR(rc)) return rc;
|
if (SM_ERROR(rc)) return rc;
|
||||||
|
|
||||||
ND_Node_Previous_Get (Node, &Node);
|
ND_Index_Node_Previous_Get( &Node, Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Déverrouillage du heap */
|
/* Déverrouillage du heap */
|
||||||
@ -1026,10 +1036,10 @@ SMT_Status SM_Heap_Close_I ( SMT_Heap * Heap)
|
|||||||
|
|
||||||
/* Suppression du heap de la liste des heaps ouverts */
|
/* 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;
|
if (SM_ERROR(rc)) return rc;
|
||||||
|
|
||||||
rc = ND_Value_Free (Opened_Heap_List, Heap);
|
rc = ND_Value_Free( Opened_Heap_List, Heap);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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 */
|
/* 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)
|
while (Node)
|
||||||
{
|
{
|
||||||
rc = SM_DataSegment_Open (Node->Value);
|
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;
|
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;
|
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 */
|
/* 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)
|
while (Node)
|
||||||
{
|
{
|
||||||
*Compress += SM_DataSegment_Compress ((SMT_DSH *)(Node->Value), Heap->MHH->FCR);
|
*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;
|
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 */
|
/* 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)
|
while (Node)
|
||||||
{
|
{
|
||||||
@ -1399,7 +1409,7 @@ SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Correc
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ND_Node_Next_Get (Node, &Node);
|
ND_Index_Node_Next_Get( &Node, Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vérification de la structure ACR du heap */
|
/* 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;
|
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)
|
while (Found == FALSE && Node)
|
||||||
{
|
{
|
||||||
Chunk = (SMT_Chunk *)(Node->Value);
|
Chunk = (SMT_Chunk *)(Node->Value);
|
||||||
|
|
||||||
if (Chunk->Size >= Alloc_Size) Found = TRUE;
|
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)
|
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;
|
return SMS_ERRSHM;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ND_Value_Add (Heap->MHH->DSR, DSH);
|
rc = ND_DataStruct_Value_Add (Heap->MHH->DSR, DSH);
|
||||||
if (rc != NDS_OK)
|
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);
|
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 */
|
/* Suppression du chunk de la liste des chunks libres */
|
||||||
|
|
||||||
rc = ND_Node_Remove (Node);
|
rc = ND_Index_Node_Remove (Node);
|
||||||
if (rc != NDS_OK)
|
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);
|
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 */
|
/* 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)
|
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);
|
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 */
|
/* 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;
|
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->Right = NULL;
|
||||||
New_Node->Value = New_Chunk;
|
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)
|
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);
|
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 */
|
/* 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)
|
while (Node)
|
||||||
{
|
{
|
||||||
Free_Chunk = Node->Value;
|
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;
|
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_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->Root = NULL;
|
||||||
New_Node->Parent = NULL;
|
New_Node->Parent = NULL;
|
||||||
New_Node->Left = 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 */
|
/* 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)
|
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)");
|
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 */
|
/* 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)
|
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);
|
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 */
|
/* 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)
|
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);
|
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 */
|
/* Retour arrière */
|
||||||
|
|
||||||
ND_Node_Add (Heap->MHH->ACR, Node);
|
ND_Index_Node_Add( Heap->MHH->ACR, NDD_INDEX_PRIMARY, Node);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -2467,14 +2477,12 @@ SMT_Status SM_Chunk_Free_C ( SMT_Heap * Heap, void * Ptr)
|
|||||||
/* Allocation de mémoire dans la base */
|
/* 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;
|
*Ptr = SM_Base->Free;
|
||||||
SM_Base->Free = (void *)((size_t)(SM_Base->Free) + Size);
|
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 */
|
/* 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 */
|
/* 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 */
|
/* 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
|
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)
|
while (Node)
|
||||||
{
|
{
|
||||||
SMT_MHH * MHH = (SMT_MHH *)(Node->Value);
|
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
|
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 */
|
/* 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)
|
if (rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf (SM_Error_Msg, "SM_Base_End : unable to remove heap \"%s\" from the MHR", MHH->Name);
|
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.
|
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)
|
while (Node)
|
||||||
{
|
{
|
||||||
NDT_Node *Next_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));
|
SM_Heap_Close_I ((SMT_Heap *)(Node->Value));
|
||||||
Node = Next_Node;;
|
Node = Next_Node;;
|
||||||
}
|
}
|
||||||
@ -3360,13 +3368,13 @@ SMT_Status SM_MHH_End ( SMT_MHH * MHH)
|
|||||||
du DSR pour celui-ci.
|
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)
|
while (Node)
|
||||||
{
|
{
|
||||||
DSH = (SMT_DSH *)(Node->Value);
|
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 ? */
|
/* S'agit-il du heap système ? */
|
||||||
|
|
||||||
@ -3377,7 +3385,7 @@ SMT_Status SM_MHH_End ( SMT_MHH * MHH)
|
|||||||
|
|
||||||
/* Retrait du segment du DSR */
|
/* 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)
|
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);
|
sprintf (SM_Error_Msg, "SM_MHH_End : unable to remove the shared memory segment (address=%p) from the DSR structure", DSH->Start);
|
||||||
@ -3388,7 +3396,7 @@ SMT_Status SM_MHH_End ( SMT_MHH * MHH)
|
|||||||
|
|
||||||
/* Destruction du segment */
|
/* Destruction du segment */
|
||||||
|
|
||||||
rc = ND_Value_Free (MHH->DSR, DSH);
|
rc = ND_Value_Free( MHH->DSR, DSH);
|
||||||
if (rc != NDS_OK)
|
if (rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the shared memory segment (address=%p)", DSH->Start);
|
sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the shared memory segment (address=%p)", DSH->Start);
|
||||||
@ -3418,14 +3426,14 @@ SMT_Status SM_MHH_End ( SMT_MHH * MHH)
|
|||||||
leur racine.
|
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)
|
if (rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the ACR root of heap \"%s\"", MHH->Name);
|
sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the ACR root of heap \"%s\"", MHH->Name);
|
||||||
SM_Error_Print ();
|
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)
|
if (rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the FCR root of heap \"%s\"", MHH->Name);
|
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 */
|
/* Suppression du heap de la liste des heaps ouverts */
|
||||||
|
|
||||||
To_Find.Name = MHH->Name;
|
To_Find.Name = MHH->Name;
|
||||||
rc = ND_Value_Remove (Opened_Heap_List, &To_Find, (void **)&Opened_Heap);
|
rc = ND_DataStruct_Value_Find( (void **)&Opened_Heap, Opened_Heap_List, &To_Find);
|
||||||
if (rc == NDS_OK)
|
|
||||||
|
if( ( rc == NDS_OK) && ( Opened_Heap != NULL))
|
||||||
{
|
{
|
||||||
rc = ND_Value_Free (Opened_Heap_List, Opened_Heap);
|
rc = ND_DataStruct_Value_Remove( Opened_Heap_List, Opened_Heap);
|
||||||
if (rc != NDS_OK) return rc;
|
|
||||||
|
if (rc != NDS_OK)
|
||||||
|
{
|
||||||
|
return( rc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rc = ND_Value_Free( Opened_Heap_List, Opened_Heap);
|
||||||
|
|
||||||
|
if( rc != NDS_OK)
|
||||||
|
{
|
||||||
|
return( rc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destruction du sémaphore attaché au heap */
|
/* 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 */
|
/* 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)
|
if (rc != SMS_OK)
|
||||||
{
|
{
|
||||||
sprintf (SM_Error_Msg, "SM_MHH_End : unable to free the header of heap \"%s\"", MHH->Name);
|
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 */
|
/* 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");
|
sprintf (SM_Error_Msg, "SM_DataSegment_Init : unable to allocate memory for the new data segment header");
|
||||||
SM_Error_Print ();
|
SM_Error_Print ();
|
||||||
@ -3604,7 +3626,7 @@ SMT_DSH * SM_DataSegment_Init ( SMT_MHH * MHH, size_t Segment_Size)
|
|||||||
|
|
||||||
SM_Error_Print ();
|
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;
|
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);
|
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;
|
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 */
|
/* 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);
|
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 ();
|
SM_Error_Print ();
|
||||||
|
|
||||||
shmctl (New_DSH->MemID, IPC_RMID, 0);
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -3698,7 +3720,7 @@ SMT_Status SM_DataSegment_End (NDT_Root * Root, SMT_DSH *DSH)
|
|||||||
|
|
||||||
/* Désallocation de l'entête */
|
/* 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)
|
if (rc != NDS_OK)
|
||||||
{
|
{
|
||||||
sprintf (SM_Error_Msg, "SM_DataSegment_End : the data segment header is nul");
|
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 */
|
/* 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)
|
while (Found == FALSE && Node)
|
||||||
{
|
{
|
||||||
@ -3792,7 +3814,7 @@ size_t SM_DataSegment_Compress ( SMT_DSH *DSH, NDT_Root *FCR)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Node >= (NDT_Node *)(DSH->Start)) Found = TRUE;
|
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 */
|
/* 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)
|
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))
|
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);
|
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;
|
Total_Compress += Compress;
|
||||||
|
|
||||||
ND_Node_Next_Get (Node, &Next_Node);
|
ND_Index_Node_Next_Get( &Next_Node, Node);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Node = Next_Node;
|
Node = Next_Node;
|
||||||
ND_Node_Next_Get (Next_Node, &Next_Node);
|
ND_Index_Node_Next_Get( &Next_Node, Next_Node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* $RCSfile: libshmem.h,v $ */
|
/* $RCSfile: libshmem.h,v $ */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* $Revision: 2.0 $ */
|
/* $Revision: 2.1 $ */
|
||||||
/* $Name: $ */
|
/* $Name: $ */
|
||||||
/* $Date: 2005/01/24 22:57:06 $ */
|
/* $Date: 2005/01/24 23:10:09 $ */
|
||||||
/* $Author: agibert $ */
|
/* $Author: agibert $ */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -166,22 +166,22 @@ typedef union semun
|
|||||||
/*------------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------------*/
|
||||||
/* Allocation de mémoire dans la base */
|
/* 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 */
|
/* 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 */
|
/* 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 */
|
/* 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 */
|
/* Initialisation de la base */
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define SM_MODE 0 /* Utilisation des API sécurisés */
|
#define SM_MODE 0 /* Utilisation des API sécurisés */
|
||||||
#include <shmem.h>
|
#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"
|
#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]);
|
fprintf (stderr, USAGE, argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (!strcmp (argv[1], "--version"))
|
/* else if (!strcmp (argv[1], "--version"))
|
||||||
{
|
{
|
||||||
if (argc >= 3 && !strcmp (argv[2], "-v"))
|
if (argc >= 3 && !strcmp (argv[2], "-v"))
|
||||||
return VER_Object_Print (stdout, VERD_VERBOSE);
|
return VER_Object_Print (stdout, VERD_VERBOSE);
|
||||||
else
|
else
|
||||||
return VER_Object_Print (stdout, VERD_MINIMAL);
|
return VER_Object_Print (stdout, VERD_MINIMAL);
|
||||||
}
|
} */
|
||||||
else if (!strcmp (argv[1], "--create"))
|
else if (!strcmp (argv[1], "--create"))
|
||||||
{
|
{
|
||||||
if (SM_Library_Open (0, NULL, SMD_CREATE | SMD_DEBUG_ALL) != SMS_OK)
|
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);
|
gets (name);
|
||||||
if (SM_Heap_Open (name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked) == SMS_OK)
|
if (SM_Heap_Open (name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked) == SMS_OK)
|
||||||
{
|
{
|
||||||
ND_DataStruct_Info_Print (Heap->MHH->DSR, stdout);
|
ND_DataStruct_Info_Print( stdout, Heap->MHH->DSR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
|
||||||
ND_DataStruct_Print (Heap->MHH->DSR, stdout);
|
ND_DataStruct_Value_Print( stdout, Heap->MHH->DSR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
|
||||||
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -272,8 +272,8 @@ int main (int argc, char ** argv)
|
|||||||
gets (name);
|
gets (name);
|
||||||
if (SM_Heap_Open (name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked) == SMS_OK)
|
if (SM_Heap_Open (name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked) == SMS_OK)
|
||||||
{
|
{
|
||||||
ND_DataStruct_Info_Print (Heap->MHH->ACR, stdout);
|
ND_DataStruct_Info_Print( stdout, Heap->MHH->ACR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
|
||||||
ND_DataStruct_Print (Heap->MHH->ACR, stdout);
|
ND_DataStruct_Value_Print( stdout, Heap->MHH->ACR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
|
||||||
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -283,8 +283,8 @@ int main (int argc, char ** argv)
|
|||||||
gets (name);
|
gets (name);
|
||||||
if (SM_Heap_Open (name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked) == SMS_OK)
|
if (SM_Heap_Open (name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked) == SMS_OK)
|
||||||
{
|
{
|
||||||
ND_DataStruct_Info_Print (Heap->MHH->FCR, stdout);
|
ND_DataStruct_Info_Print( stdout, Heap->MHH->FCR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
|
||||||
ND_DataStruct_Print (Heap->MHH->FCR, stdout);
|
ND_DataStruct_Value_Print( stdout, Heap->MHH->FCR, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
|
||||||
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user