svn: /pecl/apc/trunk/ apc_shm.c

From: Date: Tue, 22 Sep 2009 12:08:13 +0000
Subject: svn: /pecl/apc/trunk/ apc_shm.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-12918@lists.php.net to get a copy of this message
kalle Tue, 22 Sep 2009 12:08:13 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=288564 Log: ftok() implementation for Windows Changed paths: U pecl/apc/trunk/apc_shm.c Modified: pecl/apc/trunk/apc_shm.c =================================================================== --- pecl/apc/trunk/apc_shm.c 2009-09-22 12:07:48 UTC (rev 288563) +++ pecl/apc/trunk/apc_shm.c 2009-09-22 12:08:13 UTC (rev 288564) @@ -47,21 +47,32 @@ # define SHM_A 0222 /* write permission */ #endif +#ifdef PHP_WIN32 +/* Simple ftok() implementation for APC */ +key_t ftok(const char *pathname, int proj) +{ + struct stat statbuf; + key_t key = -1; + + if (stat(pathname, &statbuf) == 0) { + key = (((statbuf.st_dev & 0xff) << 16) | ((proj & 0xff) << 24)); + } + + return key; +} +#endif + int apc_shm_create(const char* pathname, int proj, size_t size) { - int shmid; /* shared memory id */ - int oflag; /* permissions on shm */ - key_t key; /* shm key returned by ftok */ + int shmid; /* shared memory id */ + int oflag; /* permissions on shm */ + key_t key = IPC_PRIVATE; /* shm key returned by ftok */ - key = IPC_PRIVATE; -#ifndef PHP_WIN32 - /* no ftok yet for win32 */ if (pathname != NULL) { if ((key = ftok(pathname, proj)) < 0) { - apc_eprint("apc_shm_create: ftok failed:"); + apc_eprint("apc_shm_create: ftok failed"); } } -#endif oflag = IPC_CREAT | SHM_R | SHM_A; if ((shmid = shmget(key, size, oflag)) < 0) {

« previous php.pecl.cvs (#12918) next »