9 #define _XOPEN_SOURCE 700
17 #include <sys/types.h>
25 #include "sion_error_handler.h"
30 #if defined(_SION_LINUX)
32 #elif defined(_SION_AIX)
33 #elif defined(_SION_BGP)
59 int rc = SION_SUCCESS;
67 DPRINTFP((2,
"_sion_cache_check_env", -1,
"usecache=%d cachesize=%d flag1=%d\n", sion_filedesc->
usecache, sion_filedesc->
cachesize, sion_filedesc->
flag1));
80 int rc = SION_SUCCESS;
85 #if defined(_SION_LINUX)
87 #elif defined(_SION_AIX)
88 #elif defined(_SION_BGP)
91 #if defined(_SION_LINUX)
93 #elif defined(_SION_AIX)
94 #elif defined(_SION_BGP)
97 _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_cache_init: unknown SION mode\n");
112 int rc = SION_SUCCESS;
116 #if defined(_SION_LINUX)
118 #elif defined(_SION_AIX)
119 #elif defined(_SION_BGP)
133 int rc = SION_SUCCESS;
138 #if defined(_SION_LINUX)
142 if(sion_filedesc->
rank>0) sprintf(sion_filedesc->
cachefn,
"sion_%07d",sion_filedesc->
rank);
143 else sprintf(sion_filedesc->
cachefn,
"sion_%07d",0);
146 shmfd = shm_open(sion_filedesc->
cachefn, O_CREAT | O_EXCL | O_RDWR, S_IRWXU | S_IRWXG);
148 _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_cache_create_linux: could not create segment\n");
150 DPRINTFP((2,
"_sion_cache_create_linux", -1,
"after shm_open %s shmfd=%d\n", sion_filedesc->
cachefn, shmfd));
153 ftruncate(shmfd, sion_filedesc->
cachesize);
156 shmptr = (
char *)mmap(NULL, sion_filedesc->
cachesize, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0);
157 if (shmptr == NULL) {
158 _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_cache_create_linux: could not mmap segment\n");
160 DPRINTFP((2,
"_sion_cache_create_linux", -1,
"after mmap %d bytes\n", sion_filedesc->
cachesize));
178 int rc = SION_SUCCESS;
182 #if defined(_SION_LINUX)
186 if(sion_filedesc->
rank>0) sprintf(sion_filedesc->
cachefn,
"sion_%07d",sion_filedesc->
rank);
187 else sprintf(sion_filedesc->
cachefn,
"sion_%07d",0);
190 shmfd = shm_open(sion_filedesc->
cachefn, O_RDWR, S_IRWXU | S_IRWXG);
192 _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_cache_losd_linux: could not load segment\n");
194 DPRINTFP((2,
"_sion_cache_create_linux", -1,
"after shm_open %s shmfd=%d\n", sion_filedesc->
cachefn, shmfd));
197 ftruncate(shmfd, sion_filedesc->
cachesize);
200 shmptr = (
char *)mmap(NULL, sion_filedesc->
cachesize, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0);
201 if (shmptr == NULL) {
202 _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_cache_create_linux: could not mmap segment\n");
204 DPRINTFP((2,
"_sion_cache_create_linux", -1,
"after mmap %d bytes\n", sion_filedesc->
cachesize));
224 int rc = SION_SUCCESS;
229 #if defined(_SION_LINUX)
231 if (shm_unlink(sion_filedesc->
cachefn) != 0) {
232 _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,
"_sion_cache_destroy_linux: could not destroy segment\n");
int _sion_cache_destroy_linux(_sion_filedesc *sion_filedesc)
Deallocate cache for linux.
int _sion_cache_load_linux(_sion_filedesc *sion_filedesc)
Load an already allocated cache for linux.
int _sion_cache_init(_sion_filedesc *sion_filedesc)
Allocate and initalize the cache.
int _sion_cache_create_linux(_sion_filedesc *sion_filedesc)
Allocate cache for linux.
int _sion_cache_check_env(_sion_filedesc *sion_filedesc)
Check if environment variables are set to use cache.
int _sion_cache_destroy(_sion_filedesc *sion_filedesc)
Deallocate the cache.
#define _SION_FLAG1_USECACHE
#define SION_FILEMODE_WRITE
#define SION_FILEMODE_READ
char * _sion_getenv(const char *name)
Sion File Descriptor Structure.
char cachefn[SION_CACHE_FNLEN]