Initial support for LibNode 2.1.x.
Not working version... Update revision number to 2.0 !
This commit is contained in:
1418
lib/libshmem.c
1418
lib/libshmem.c
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,59 @@
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $RCSfile: libshmem.h,v $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $Revision: 2.0 $ */
|
||||
/* $Name: $ */
|
||||
/* $Date: 2005/01/24 22:57:06 $ */
|
||||
/* $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 */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <sys/sem.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <ver.h>
|
||||
|
||||
#include <shmem.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Compteur d'ouverture de la librairie */
|
||||
|
||||
unsigned int SM_Open_Counter = 0;
|
||||
|
||||
|
||||
/* Flux de sortie des messages d'erreur générés par la librairie */
|
||||
|
||||
FILE * SM_stderr;
|
||||
@@ -22,10 +62,15 @@ extern char * strdup (const char *);
|
||||
|
||||
#define max(A,B) ((A < B) ? B : A)
|
||||
|
||||
|
||||
/* Limite supérieure d'adressage */
|
||||
|
||||
#define MEM_LIMIT 1000000000
|
||||
|
||||
|
||||
#define SMD_CMD_VALUE_SUM (NDT_Command)65
|
||||
|
||||
|
||||
/* Taille d'un segment = 100 Ko par défaut */
|
||||
|
||||
#define K 1024
|
||||
@@ -34,10 +79,11 @@ extern char * strdup (const char *);
|
||||
|
||||
char Info_Msg [256];
|
||||
|
||||
|
||||
/* Etats possibles pour un heap */
|
||||
|
||||
#define SMD_STATE_VALID 0
|
||||
#define SMD_STATE_UNVALIDATED 1
|
||||
#define SMD_STATE_UNVALIDATED 1
|
||||
#define SMD_STATE_CORRUPTED 2
|
||||
|
||||
/* Référence sur le heap système */
|
||||
@@ -49,17 +95,17 @@ SMT_Heap * System_Heap;
|
||||
NDT_Root * Opened_Heap_List;
|
||||
|
||||
/*
|
||||
Taille par défaut des chunks alloués dans le heap système :
|
||||
Cette taille est fixée à la taille maximale des chunks pouvant
|
||||
y être alloué (de type NDT_Node, NDT_Root, SMT_MHH ou SMT_DSH)
|
||||
Taille par défaut des chunks alloués dans le heap système :
|
||||
Cette taille est fixée à la taille maximale des chunks pouvant
|
||||
y être alloué (de type NDT_Node, NDT_Root, SMT_MHH ou SMT_DSH)
|
||||
*/
|
||||
|
||||
#define DEFAULT_CHUNK_SIZE max(max(sizeof(NDT_Root), sizeof(NDT_Node)), max(sizeof(SMT_MHH), sizeof(SMT_DSH)))
|
||||
|
||||
/*
|
||||
Nombre de chunk libre minimum avant extension du heap système par un
|
||||
nouveau segment de données (fixé à 3 car l'ajout d'un nouveau segment
|
||||
nécessite l'allocation de 2 chunks (un noeud et une entête de segment).
|
||||
Nombre de chunk libre minimum avant extension du heap système par un
|
||||
nouveau segment de données (fixé à 3 car l'ajout d'un nouveau segment
|
||||
nécessite l'allocation de 2 chunks (un noeud et une entête de segment).
|
||||
*/
|
||||
|
||||
#define FREE_CHUNK_LIMIT 3
|
||||
@@ -76,8 +122,8 @@ char * SM_Context;
|
||||
#define CONTEXT_ENV_VAR "CONTEXT"
|
||||
|
||||
/*
|
||||
Variable globale permettant d'indiquer que l'on est en train
|
||||
d'étendre le heap système par ajout d'un nouveau segment.
|
||||
Variable globale permettant d'indiquer que l'on est en train
|
||||
d'étendre le heap système par ajout d'un nouveau segment.
|
||||
*/
|
||||
|
||||
unsigned int Adding_Segment = FALSE;
|
||||
@@ -86,8 +132,8 @@ SMT_Chunk * Tmp_Chunk;
|
||||
SMT_MHH * Tmp_MHH;
|
||||
|
||||
/*
|
||||
Définition des opérations de verouillage et de déverrouillage
|
||||
NB : la valeur 1 d'un sémaphore correspond à l'état non verrouillé
|
||||
Définition des opérations de verouillage et de déverrouillage
|
||||
NB : la valeur 1 d'un sémaphore correspond à l'état non verrouillé
|
||||
*/
|
||||
|
||||
/* Pose d'un verrou en lecture : 2 opérations : ( -1 puis +2 ) */
|
||||
@@ -112,9 +158,9 @@ struct sembuf SM_SemOp_TSL [2] = { {0, 0, SEM_UNDO|IPC_NOWAIT}, {0, 2, SEM_UNDO
|
||||
|
||||
typedef union semun
|
||||
{
|
||||
int val;
|
||||
struct semid_ds * buf;
|
||||
unsigned short int * array;
|
||||
int val;
|
||||
struct semid_ds * buf;
|
||||
unsigned short int * array;
|
||||
} semun;
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user