.
D 2006-01-07T15:14:50
J icomment Logged\sIn:\sYES\s\nuser_id=585068\n\nThis\spatch\swill\sbreak\son\ssome\splatforms.\s\sIt\sassumes\sthat\sa\nlong\scan\sstore\sa\spointer\svalue,\swhich\sis\susually\strue,\sbut\nisn't\srequired.\s\sIIRC\sWin64\sjust\shas\s64-bit\spointers,\sand\nkeeps\slong\sas\sa\s32-bit\stype.\s\sI\salso\snote\sthat\syou're\sjust\nsupporting\smmap.\s\sVirtualAlloc\scan\sbe\sused\sin\sWindows\sto\naccomplish\sthe\ssame\sthing.\n\nSpecifically\sthis\scode:\n\s\sPoolBookkeeping\s*pagePtr\s=\s(PoolBookkeeping\s*)\n\s\s\s\s\s\s(((long)objPtr)\s&\sPOOL_ADDR_MASK);\n\nThis\scode\sclearly\sseems\swrong:\s\nif\s(devzero\s==\s-123456)\s{\n+\s\s\s\s\s\s\s/*\n+\s\s\s\s\s\s\s\s*\sThis\sleaks\sa\sfile-descriptor,\sbut\sthere's\sno\sneat\nway\sto\n+\s\s\s\s\s\s\s\s*\savoid\sit\swithout\sopening\sand\sclosing\seach\stime,\nwhich\sis\n+\s\s\s\s\s\s\s\s*\sdesperately\sinefficient.\n+\s\s\s\s\s\s\s\s*/\n+\s\s\s\s\s\s\sdevzero\s=\sTclOSOpen("/dev/zero",\sO_RDONLY);\n+\s\s\s\s}\n+\s\s\s\sif\s(devzero<0)\s{\n+\s\s\s\s\s\s\sreturn\sNULL;\n+\s\s\s\s}\n\nHow\smuch\sof\san\simpact\sis\sit\sto\sclose\sand\sreopen\s/dev/zero?\s\nHave\syou\scompared\sthe\scost\sto\sa\smemset\s(gcc\sbuiltin)?\s\s\n\nThis\scode\sscares\sme\sa\sbit:\n+#\s\s\sifndef\sMAP_FAILED\n+#\s\s\s\s\s\s\sdefine\sMAP_FAILED\s\s\s\s\s\s((VOID\s*)-1)\n+#\s\s\sendif\n\nWhat\splatforms\slack\sMAP_FAILED?\s\sCan\swe\ssafely\sassume\sthat\n-1\sis\sthe\sright\svalue\son\ssuch\sa\splatform?\n\n
J login georgeps
J mimetype text/plain
J username georgeps
K 582256ffffffffffffffffffffffffffffffffff
U georgeps
Z 36c66c251cd4c231242d30dfe9d29b71