Implement memory-mapped files for shared memory

svn path=/trunk/boinc/; revision=13470
This commit is contained in:
Charlie Fenton 2007-08-27 12:29:00 +00:00
parent e1681640ea
commit 25ec43a839
2 changed files with 3 additions and 6 deletions

View File

@ -17,12 +17,7 @@ extern void boinc_app_key_release(int, int);
//
extern void boinc_graphics_loop(int, char**);
extern void* boinc_graphics_make_shmem(char*, int);
#ifdef USE_FILE_MAPPED_SHMEM
// Use boinc_graphics_make_shmem() instead of boinc_graphics_get_shmem()
#else
extern void* boinc_graphics_get_shmem(char*);
#endif
// Implementation stuff
//

View File

@ -21,6 +21,7 @@ static void get_shmem_name(char* prog_name, char* shmem_name) {
sprintf(shmem_name, "boinc_%s_%d", prog_name, aid.slot);
}
#else
#ifndef USE_FILE_MAPPED_SHMEM
static key_t get_shmem_name(char* prog_name) {
char cwd[256], path[256];
boinc_getcwd(cwd);
@ -28,6 +29,7 @@ static key_t get_shmem_name(char* prog_name) {
return ftok(path, 2);
}
#endif
#endif
void* boinc_graphics_make_shmem(char* prog_name, int size) {
#ifdef _WIN32
@ -66,7 +68,7 @@ void* boinc_graphics_get_shmem(char* prog_name) {
void* p;
#ifdef USE_FILE_MAPPED_SHMEM
struct stat sbuf;
retval = stat(GFX_MMAPPED_FILE_NAME, &sbuf);
int retval = stat(GFX_MMAPPED_FILE_NAME, &sbuf);
if (retval == 0) {
retval = create_shmem(GFX_MMAPPED_FILE_NAME, sbuf.st_size, &p);
}