|
Hi Phil
Because this source included in Korean Lanuge, I
send again to English.
When the T4 Witango web Application Server for Solaris
installed,
64 bit computing system (for example, Sun Enterprise 3500,
4500, 5500, 6500).
Witango is not supporting 64 bit architechure enough when
installed first (Occured Install error) ,
This program is converting program from 32bit to 64bit in
shared memory for Solaris
Enjoy yourself
KJLee
**********************
http://www.witango.co.kr
Tel: 82-2-585-9290
Mobile:82-17-786-1141
Webmail: [EMAIL PROTECTED]
email: [EMAIL PROTECTED]
**********************
----------------------
#include <stdio.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <sys/sem.h> #include <sys/shm.h> #include <errno.h> #include <unistd.h> #include <time.h> #include <netinet/in.h> #include <arpa/inet.h>
#define TRUE 1 #define FALSE 0 typedef struct { int pid; char INFname[200]; } PROC_STATE;
typedef
int
BOOL;
static key_t
gSHM_CS_Key;
static int gSHM_CS_ID; PROC_STATE* parent; int GetSharedMemory(key_t , char **, int , BOOL ); int DelSharedMemory(key_t ); int FreeSharedMemory(int ); void SHMError(void); int main(int argc, char *argv[])
{ gSHM_CS_Key = 3837247118;
printf("Hello, world\n");
if((gSHM_CS_ID = GetSharedMemory(gSHM_CS_Key, (char**)&parent, sizeof(PROC_STATE), TRUE))== -1) { printf("Shredmemory Already Exist\n"); } return 0; } int GetSharedMemory(key_t key, char **data, int size, BOOL Flag) { int shmid; /*If TRUE, Create Shared
Memory*/
if (Flag) /*Flag = TRUE*/ { if ((shmid = shmget(key, size, 0666|IPC_CREAT|IPC_EXCL)) < 0) { if (errno == EEXIST) { return -1; /* if ((shmid = shmget(key, size, 0666)) < 0) { if (DelSharedMemory(key) == -1) return -1;
if ((shmid = shmget(key,
size,
0666|IPC_CREAT|IPC_EXCL)) < 0) return -1; } */ } } } else /*Flag = FALSE*/ { if ((shmid = shmget(key, size, 0666)) < 0) return -1; /*return GetSharedMemory(key, data, size, TRUE);/*If there is no existing one, Create it again*/ } if ((*data = "" *)shmat(shmid, 0, 0)) == (char
*)-1)
{ shmctl(shmid, IPC_RMID, 0); close(shmid); return -1; } if (Flag)
memset(*data, '\0', size); return shmid;
} /*=============================================================================
int DelSharedMemory( key_t key : Shared memory key ) ------------------------------------------------------------------------------- Delete shared memory by using shared memory key. Return Values
-------------- int : success TRUE,fail : -1 Remarks -------- ==============================================================================*/ int DelSharedMemory(key_t key)
{ int shmid; if ((shmid = shmget(key, 1, 0666)) <
0){
/*SHMError();*/ printf("DelSharedMemory Error"); return -1; } shmctl(shmid, IPC_RMID, 0);
close(shmid); return TRUE;
} /*============================================================================= int FreeSharedMemory( int shmid : shared memory ID ) ------------------------------------------------------------------------------- Delete shared memory by using shared memory ID. Return Values
-------------- int : success TRUE,fail : -1 Remarks -------- ==============================================================================*/ int FreeSharedMemory(int shmid)
{ shmctl(shmid, IPC_RMID, 0); close(shmid); return TRUE;
} void SHMError() { switch(errno)
{ case EACCES: printf("A shared memory identifier exists for key but operation permission as specified by the low-order nine bits of shmflg would not be granted. See IPC.\n"); break; case EEXIST: printf("A shared memory identifier exists for the argument key but (shmflg&IPC_CREAT)&&(shmflg&IPC_EXCL) is non-zero. \n"); break; case EINVAL: printf("The value of size is less than the system-imposed minimum or greater than the system-imposed maximum, or a shared memory identifier exists for the argument key but the size of the segment associated with it is less than size and size is not 0. \n"); break; case ENOENT: printf("A shared memory identifier does not exist for the argument key and (shmflg&IPC_CREAT) is 0. \n"); break; case ENOMEM: printf("A shared memory identifier and associated shared memory segment are to be created but the amount of available physical memory is not sufficient to fill the request. \n"); break; case ENOSPC: printf("A shared memory identifier is to be created but the system-imposed limit on the maximum number of allowed shared memory identifiers system-wide would be exceeded. \n"); break; default: printf("undefined shared memory error"); }
|
iipc.c
Description: Binary data
