|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesshmop-cas (last revision 2011-10-04 16:11 UTC by brohreit at gmx dot net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-08-03 18:16 UTC] 14463068 at qq dot com
[2016-10-07 13:02 UTC] cmb@php.net
-Package: Unknown/Other Function
+Package: *Extensibility Functions
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 03:00:01 2025 UTC |
Description: ------------ hi, think it would be a good idea to have some kind of atomic functions in php otherwise having any kind of shared memory is pointless imo so the patch adds a shmop-cas function current version is gcc specific i could also provide an x86 asm version (in gcc syntax) that should at least be adaptable to other compilers tested and working on 32bit linux, php built using gcc 4.5.2 bj Test script: --------------- if ($shm = shmop_open(0, 'c', 0640, 4096)) { $val1 = rand(); $val2 = rand(); echo("random values: $val1, $val2\n"); $wr = shmop_write($shm, pack('V', $val1), 0); echo("$wr bytes written\n"); $ov = shmop_cas($shm, 0, 0, $val2); echo("old val = $ov, should be $val1\n"); $tv = shmop_cas($shm, 0, $ov, $val2); echo("temp = $tv, should still be $val1\n"); $cv = shmop_cas($shm, 0, $ov, $val1); echo("current val = $cv, should be $val2\n"); $rstr = shmop_read($shm, 0, 4); $rarr = unpack("Vval", $rstr); $rval = $rarr['val']; echo("value read: $rval, should still be $val2\n"); if (! shmop_delete($shm)) echo("delete shm failed\n"); shmop_close($shm); }