泚é
ãã®èšäºã§ã¯ã32ãããWindowsã¢ããªã±ãŒã·ã§ã³ã64ãããWindowsã·ã¹ãã ã«æ£ãã移æ€ããããã®äž»ãªæé ã«ã€ããŠèª¬æããŸãã ãã®èšäºã¯Visual Studio 2005/2008ç°å¢ã§C / C ++ã䜿çšããéçºè ã察象ãšããŠããŸãããã¢ããªã±ãŒã·ã§ã³ã64ãããã·ã¹ãã ã«ç§»è¡ããããšãèšç»ããŠããä»ã®éçºè ã«ã圹ç«ã¡ãŸãã
ã¯ããã«
ãã®èšäºã§ã¯ã32ãããããã°ã©ã ã64ãããã·ã¹ãã ã«ç§»è¡ããããšãèšç»ããŠããéçºè ãçŽé¢ããäž»ãªãã€ã³ãã«ã€ããŠèª¬æããŸãã ãã¡ããã察åŠãããåé¡ã®ãªã¹ãã¯å®å šã§ã¯ãããŸããããæéãçµã€ã«ã€ããŠããã®èšäºã®æ¡åŒµçãæäŸãããããšãé¡ã£ãŠããŸãã èè ã¯ããã®èšäºã®æ å ±å 容ãæ¹åããã¬ãã¥ãŒãã³ã¡ã³ãã質åã«æè¬ããŸãã
1.ã¹ããã1ã 64ãããã¯ç°ãªããŸãã
ãããææ¡ããŸããã
ã³ã³ãã¥ãŒã¿ã¢ãŒããã¯ãã£ã®ãã¬ãŒã ã¯ãŒã¯å ã§ãã 64ããã ããšããçšèªã¯ã64ãããã®æŽæ°ãšããµã€ãºã64ãããã®ãã®ä»ã®çš®é¡ã®ããŒã¿ãæããŸãã ã64ããããã·ã¹ãã ã¯ã64ããããã€ã¯ãããã»ããµã¢ãŒããã¯ãã£ïŒEM64TãIA-64ãªã©ïŒãŸãã¯64ããããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ïŒWindows XP Professional x64 Editionãªã©ïŒãšããŠç解ã§ããŸã[ 1 ]ã
AMD64ïŒå¥åx86-64ãIntel 64ãEM64Tãx64ïŒã¯64ããããã€ã¯ãããã»ããµã¢ãŒããã¯ãã£ã§ãããAMDãéçºãã察å¿ããåœä»€ã»ããã§ã[ 2 ]ã ãã®åœä»€ã»ããã¯ãEM64TïŒIntel64ïŒãšããååã§Intelã«ãã£ãŠã©ã€ã»ã³ã¹ãããŠããŸãã AMD64ã¢ãŒããã¯ãã£ã¯ãå®å šãªäžäœäºææ§ãåããx86ã¢ãŒããã¯ãã£ã®æ¡åŒµã§ãã ã¢ãŒããã¯ãã£ã¯ãããŒãœãã«ã³ã³ãã¥ãŒã¿ããã³ã¯ãŒã¯ã¹ããŒã·ã§ã³ã®ããŒã¹ãšããŠåºãæ®åããŠããŸãã
IA-64ã¯ãIntelãšHewlett Packardãå ±åéçºãã64ããããã€ã¯ãããã»ããµã¢ãŒããã¯ãã£ã§ã[ 3 ]ã Itaniumããã³Itanium 2ãã€ã¯ãããã»ããµã«å®è£ ãããŠããŸã[ 4 ]ã ãã®ã¢ãŒããã¯ãã£ã¯ãäž»ã«ãã«ãããã»ããµãµãŒããŒãšã¯ã©ã¹ã¿ãŒã·ã¹ãã ã§äœ¿çšãããŸãã
AMD64ãšIA-64ã¯ãäºãã«äºææ§ã®ãªã2ã€ã®ç°ãªã64ãããã¢ãŒããã¯ãã£ã§ãã ãããã£ãŠãéçºè ã¯ããããã®ã¢ãŒããã¯ãã£ã®äž¡æ¹ããµããŒããããã1ã€ã ãããµããŒãããããçŽã¡ã«æ±ºå®ããå¿ èŠããããŸãã ã»ãšãã©ã®å Žåãã¯ã©ã¹ã¿ãŒã·ã¹ãã çšã®é«åºŠã«å°éåããããœãããŠã§ã¢ãéçºããªãå ŽåããŸãã¯é«æ§èœDBMSãå®è£ ããªãå Žåãé«ã確çã§ãIA-64ããã¯ããã«æ®åããŠããAMD64ã¢ãŒããã¯ãã£ã®ã¿ã®ãµããŒããå®è£ ããå¿ èŠããããŸãã ããã¯ãAMD64ã¢ãŒããã¯ãã£ã§ã»ãŒ100ïŒ å æãããŠããããœã³ã³åžå Žã®ãœãããŠã§ã¢ã«ç¹ã«åœãŠã¯ãŸããŸãã
ãã®èšäºã®æ®ãã®éšåã§ã¯ãAMD64ã¢ãŒããã¯ãã£ãŒïŒEM64Tãx64ïŒã«ã€ããŠã®ã¿èª¬æããŸããAMD64ã®äœ¿çšã¯ãã¢ããªã±ãŒã·ã§ã³ãœãããŠã§ã¢éçºè ã«æãé¢é£æ§ãããããã§ãã
ç°ãªãã¢ãŒããã¯ãã£ã«ã€ããŠèšãã°ãã ããŒã¿ã¢ãã« ãã®æŠå¿µã«èšåããå¿ èŠããããŸãã ããŒã¿ã¢ãã«ã¯ãéçºç°å¢å ã§æ¡çšãããŠããåã®ãã£ã¡ã³ã·ã§ã³ã®æ¯çãšããŠç解ãããå¿ èŠããããŸãã 1ã€ã®ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã«å¯ŸããŠãç°ãªãããŒã¿ã¢ãã«ã«æºæ ããããã€ãã®éçºããŒã«ãååšããå ŽåããããŸãã ãã ããéåžžã¯ãæãé©åãªããŒããŠã§ã¢ããã³ãœãããŠã§ã¢ç°å¢ãšãã1ã€ã®ã¢ãã«ã®ã¿ãåªå ãããŸãã äŸã¯ã LLP64ããã€ãã£ãããŒã¿ã¢ãã«ã§ãã64ãããWindowsãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã§ãã ãã ããäºææ§ã®ããã«ã64ãããWindowsã·ã¹ãã ã¯ã ILP32LLããŒã¿ã¢ãã«ã¢ãŒãã§åäœãã32ãããããã°ã©ã ã®å®è¡ããµããŒãããŠããŸãã è¡šN1ã¯ãäž»èŠãªããŒã¿ã¢ãã«ã«é¢ããæ å ±ãæäŸããŸãã
è¡šN1ã ããŒã¿ã¢ãã«
ããã°ã©ã ã³ãŒãã§ã¯äœ¿çšããŒã¿ã®ããã深床ãèæ ®ããå¿ èŠãããããã䜿çšããŒã¿ã¢ãã«ã¯64ãããã¢ããªã±ãŒã·ã§ã³ã®éçºããã»ã¹ã«ãã®è¶³è·¡ãæ®ããŸã[ 5 ]ã
2.ã¹ããã2ã 補åã®64ãããããŒãžã§ã³ãå¿ èŠãã©ããã調ã¹ã
64ãããã·ã¹ãã ã®éçºã¯ãã64ãããã·ã¹ãã çšã«ãããžã§ã¯ããåæ§ç¯ããå¿ èŠããããŸããïŒããšãã質åããå§ããå¿ èŠããããŸãã ãã®è³ªåã«ã¯çããªããã°ãªããŸããããæ¥ãã§èããŠã¯ãããŸããã äžæ¹ã§ã¯ãã¿ã€ã ãªãŒã«64ããããœãªã¥ãŒã·ã§ã³ãæäŸããããšãªãã競åä»ç€Ÿã«é ãããšãããšãã§ããŸãã äžæ¹ã64ãããã¢ããªã±ãŒã·ã§ã³ã§ã¯æéã浪費ããå¯èœæ§ãããã競äºäžã®åªäœæ§ã¯åŸãããŸããã
éžæãæ¯æŽããäž»ãªèŠå ããªã¹ãããŸãã
2.1ã ã¢ããªã±ãŒã·ã§ã³ã®ã©ã€ããµã€ã¯ã«
çãã©ã€ããµã€ã¯ã«ã§ã¢ããªã±ãŒã·ã§ã³ã®64ãããããŒãžã§ã³ãäœæããªãã§ãã ããã WOW64ãµãã·ã¹ãã ã®ãããã§ãå€ã32ãããã¢ããªã±ãŒã·ã§ã³ã¯64ãããWindowsã·ã¹ãã ã§éåžžã«ããæ©èœããããã64ãããããã°ã©ã ãäœæããŠãæå³ããããŸãããããã¯2幎åŸã«ãµããŒããããªããªããŸã[ 6 ]ã ããã«ãå®éã«ã¯ãWindowsã®64ãããããŒãžã§ã³ãžã®ç§»è¡ãé ããŠãããã»ãšãã©ã®ãŠãŒã¶ãŒãçæçã«ã¯ãœãããŠã§ã¢ãœãªã¥ãŒã·ã§ã³ã®32ãããããŒãžã§ã³ã®ã¿ã䜿çšããå¯èœæ§ããããŸãã
ãœãããŠã§ã¢è£œåã®é·æã«ãããéçºãšé·æçãªãµããŒããèšç»ããŠããå Žåã¯ããœãªã¥ãŒã·ã§ã³ã®64ãããããŒãžã§ã³ã§äœæ¥ãéå§ããå¿ èŠããããŸãã ããã¯ãã£ãããšè¡ãããšãã§ããŸãããæ¬æ Œçãª64ãããããŒãžã§ã³ããªãå Žåã¯ã64ãããããŒãžã§ã³ã®Windowsã«ã€ã³ã¹ããŒã«ããããã®ãããªã¢ããªã±ãŒã·ã§ã³ã®ãµããŒãã§ããå€ãã®åé¡ãçºçããå¯èœæ§ãããããšã«æ³šæããŠãã ããã
2.2ã ã¢ããªã±ãŒã·ã§ã³ãªãœãŒã¹ã®åŒ·åºŠ
64ãããã·ã¹ãã çšã«ããã°ã©ã ãåã³ã³ãã€ã«ãããšãèšå€§ãªéã®RAMã䜿çšã§ããããã«ãªããäœæ¥ã5ã15ïŒ éããªããŸãã 64ãããããã»ããµã®ã¢ãŒããã¯ãã£æ©èœãããšãã°ããå€ãã®ã¬ãžã¹ã¿ã®äœ¿çšã«ããã5ã10ïŒ ã®é«éåãè¡ãããŸãã å¥ã®1ïŒ ãã5ïŒ ã®é床ã®åäžã¯ã32ãããã¢ããªã±ãŒã·ã§ã³ãš64ããããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®éã§APIåŒã³åºããå€æããWOW64ã¬ã€ã€ãŒããªãããã§ãã
ããã°ã©ã ã倧éã®ããŒã¿ïŒ2GBãè¶ ããïŒã§åäœããããã®é床ãéèŠã§ãªãå Žåãè¿ãå°æ¥ã®64ãããã·ã¹ãã ãžã®ç§»è¡ã¯ããã»ã©éèŠã§ã¯ãããŸããã
ãšããã§ãåçŽãª32ãããã¢ããªã±ãŒã·ã§ã³ã§ãã64ãããç°å¢ã§ã®èµ·åãå©çšã§ããŸãã / LARGEADDRESSAWAREïŒYESã¹ã€ããã§ã³ã³ãã€ã«ãããããã°ã©ã ã¯ã32ãããWindowsãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã/ 3gbã¹ã€ããã§å®è¡ãããŠããå Žåãæ倧3ã®ã¬ãã€ãã®ã¡ã¢ãªãå²ãåœãŠãããšãã§ããããšããåç¥ã§ãããã 64ãããã·ã¹ãã ã§å®è¡ãããåã32ãããããã°ã©ã ã¯ãã»ãŒ4 GBã®ã¡ã¢ãªïŒå®éã«ã¯çŽ3.5 GBïŒãå²ãåœãŠãããšãã§ããŸãã
2.3ã ã©ã€ãã©ãªéçº
ã©ã€ãã©ãªãã³ã³ããŒãã³ãããŸãã¯ãµãŒãããŒãã£ã®éçºè ããœãããŠã§ã¢ãäœæãããã®ä»ã®èŠçŽ ãéçºããŠããå Žåã補åã®64ãããããŒãžã§ã³ããã°ããäœæããå¿ èŠããããŸãã ããããªããšã64ãããããŒãžã§ã³ã®ãªãªãŒã¹ã«é¢å¿ã®ãã顧客ã¯ã代æ¿ãœãªã¥ãŒã·ã§ã³ãæ¢ãããšãäœåãªããããŸãã ããšãã°ãããŒããŠã§ã¢ããã³ãœãããŠã§ã¢ä¿è·ã®éçºè ã®äžã«ã¯ã64ãããããã°ã©ã ã®åºçŸã«é·ãé 延ã§å¿çãããããå€ãã®ã¯ã©ã€ã¢ã³ããããã°ã©ã ãä¿è·ããããã«ä»ã®ããŒã«ãæ¢ãå¿ èŠããããŸããã
ã©ã€ãã©ãªã®64ãããããŒãžã§ã³ã®ãªãªãŒã¹ã®è¿œå ã®å©ç¹ã¯ãåå¥ã®è£œåãšããŠè²©å£²ã§ããããšã§ãã ãããã£ãŠã32ãããã¢ããªã±ãŒã·ã§ã³ãš64ãããã¢ããªã±ãŒã·ã§ã³ã®äž¡æ¹ãäœæãã顧客ã¯ã2ã€ã®ç°ãªãã©ã€ã»ã³ã¹ãè³Œå ¥ããå¿ èŠããããŸãã ããšãã°ãSpatial Corporationã¯ãã®ããªã·ãŒã䜿çšããŠãSpatial ACISã©ã€ãã©ãªã販売ããŠããŸãã
2.4ã ãµãŒãããŒãã£ã©ã€ãã©ãªãžã®è£œåã®äŸåé¢ä¿
補åã®64ãããããŒãžã§ã³ãäœæããäœæ¥ãèšç»ããåã«ã䜿çšããã©ã€ãã©ãªãšã³ã³ããŒãã³ãã®64ãããããŒãžã§ã³ããããã©ããã確èªããŠãã ããã ãŸãã64ãããããŒãžã§ã³ã®ã©ã€ãã©ãªã®äŸ¡æ Œèšå®ããªã·ãŒã確èªããŠãã ããã ãããã¯ãã¹ãŠãã©ã€ãã©ãªã®éçºè åããµã€ãã«ã¢ã¯ã»ã¹ããŠç¢ºèªã§ããŸãã ãµããŒããå©çšã§ããªãå Žåã¯ã64ãããã·ã¹ãã ããµããŒããã代æ¿ãœãªã¥ãŒã·ã§ã³ãäºåã«æ¢ããŠãã ããã
2.5ã 16ãããã¢ããªã±ãŒã·ã§ã³ã®ååš
ãœãªã¥ãŒã·ã§ã³ã«16ãããã¢ãžã¥ãŒã«ããŸã ããå Žåã¯ãããããåé€ããŸãã 64ãããããŒãžã§ã³ã®Windowsã§ã®16ãããã¢ããªã±ãŒã·ã§ã³ã®æäœã¯ãµããŒããããŠããŸããã
ããã§ã¯ã16ãããã€ã³ã¹ããŒã©ãŒã®äœ¿çšã«é¢ãã1ã€ã®ãã€ã³ããæ確ã«ããå¿ èŠããããŸãã äžéšã®32ãããã¢ããªã±ãŒã·ã§ã³ã®ã€ã³ã¹ããŒã«ã«ã¯åŒãç¶ã䜿çšãããŸãã æã人æ°ã®ããå€ãã®16ãããã€ã³ã¹ããŒã©ãŒãæ°ããããŒãžã§ã³ã«å³åº§ã«çœ®ãæããç¹å¥ãªã¡ã«ããºã ãäœæãããŸããã ããã¯ã16ãããããã°ã©ã ã64ãããç°å¢ã§ãåäœãããšãã誀解ãæãå¯èœæ§ããããŸãã èŠããŠãããŠãããã¯ããã§ã¯ãããŸããã
2.6ã ã¢ã»ã³ããªã³ãŒãã®å¯çšæ§
倧éã®ã¢ã»ã³ãã©ã³ãŒãã䜿çšãããšã64ãããããŒãžã§ã³ã®ã¢ããªã±ãŒã·ã§ã³ãäœæããã³ã¹ããå€§å¹ ã«å¢å ããå¯èœæ§ãããããšãå¿ããªãã§ãã ããã
äžèšã®ãã¹ãŠã®äºå®ãé·æãšçæãæ€èšããåŸããããžã§ã¯ãã64ãããã·ã¹ãã ã«è»¢éãããã©ããã決å®ããŸãã ãããããªãã次ã«é²ã¿ãŸãããã
3. 3çªç®ã®ã¹ãããã ããŒã«ããã
補åã®64ãããããŒãžã§ã³ãéçºããããšã«æ±ºããæéãè²»ããæºåãã§ããŠããå Žåãããã¯æåãä¿èšŒãããã®ã§ã¯ãããŸããã å®éã«ã¯ãå¿ èŠãªãã¹ãŠã®ããŒã«ãçšæããå¿ èŠããããäžå¿«ãªã€ã³ã·ãã³ããçºçããå¯èœæ§ããããŸãã
æãåçŽãªããããæãä¹ãè¶ããããªãåé¡ã¯ã64ãããã³ã³ãã€ã©ã®æ¬ åŠãããããŸããã ãã®èšäºã¯2009幎ã«äœæãããŸãããã64ãããCodegear C ++ Builderã³ã³ãã€ã©ãŒã¯ãŸã ãããŸãã[ 7 ]ã ãã®ãªãªãŒã¹ã¯ä»å¹Žã®çµãããŸã§ã«äºå®ãããŠããŸãã ãã¡ãããããã§ãªãéããåæ§ã®åé¡ãåé¿ããããšã¯ã§ããŸããããããšãã°Visual Studioã䜿çšããŠãããžã§ã¯ãå šäœãæžãçŽããŠãã ããã ãããã64ãããã³ã³ãã€ã©ãŒããªãããšã§ãã¹ãŠãæããã«ãªããšãä»ã®åæ§ã®åé¡ãããç§å¯ã«ãªãããããžã§ã¯ããæ°ããã¢ãŒããã¯ãã£ã«ç§»è¡ããäœæ¥ã®æ®µéã§æ¢ã«æãåºãå¯èœæ§ããããŸãã ãããã£ãŠã補åã®64ãããããŒãžã§ã³ãå®è£ ããããã«å¿ èŠãªãã¹ãŠã®ã³ã³ããŒãã³ãããããã©ãããäºåã«èª¿æ»ããããšããå§ãããŸãã äžå¿«ãªé©ããããªããåŸ ã£ãŠããŸãã
ãã¡ãããããã§ãããžã§ã¯ãã«å¿ èŠãªå¯èœæ§ã®ãããã®ãã¹ãŠããªã¹ãããããšã¯ã§ããŸããããããã§ãããªããããªãã®æ¹äœãã€ããã®ã«åœ¹ç«ã€ãªã¹ããæäŸããããããããªãã®64ããããããžã§ã¯ãã®å®è£ ã«å¿ èŠãªä»ã®ãã€ã³ããèŠããŠããŸãïŒ
3.1ã 64ãããã³ã³ãã€ã©ã®ååš
64ãããã³ã³ãã€ã©ãæã€ããšã®éèŠæ§ã«ã€ããŠä»ã®ããšãèšãã®ã¯å°é£ã§ãã ããã ãã§ããå¿ èŠããããŸãã
ææ°ããŒãžã§ã³ïŒå·çæç¹ïŒã®Visual Studio 2008ã䜿çšããŠ64ãããã¢ããªã±ãŒã·ã§ã³ãéçºããå Žåã次ã®è¡šN2ãå¿ èŠãªVisual Studioã®ãšãã£ã·ã§ã³ãå€æããã®ã«åœ¹ç«ã¡ãŸãã
è¡šN2ã Visual Studio 2008ã®ããŸããŸãªãšãã£ã·ã§ã³ã®æ©èœ
3.2ã 64ããããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãå®è¡ããŠãã64ãããã³ã³ãã¥ãŒã¿ãŒã®ååš
確ãã«ä»®æ³ãã·ã³ã䜿çšããŠ32ããããã¯ãããžã§64ãããã¢ããªã±ãŒã·ã§ã³ãå®è¡ã§ããŸãããããã¯éåžžã«äžäŸ¿ã§ãããå¿ èŠãªã¬ãã«ã®ãã¹ããã¹ããæäŸããŸããã å°ãªããšã4ã8ã®ã¬ãã€ãã®RAMããã·ã³ã«ã€ã³ã¹ããŒã«ãããŠããããšãæãŸããã§ãã
3.3ã 䜿çšãããŠãããã¹ãŠã®ã©ã€ãã©ãªã®64ãããããªã¢ã³ãã®å¯çšæ§
ã©ã€ãã©ãªããœãŒã¹ã³ãŒãã§æ瀺ãããŠããå Žåã64ããããããžã§ã¯ãæ§æãååšããå¿ èŠããããŸãã ã©ã€ãã©ãªãåå¥ã«ã¢ããã°ã¬ãŒãããŠ64ãããã·ã¹ãã çšã«ãã«ãããããšã¯ãæ©æµã®ãªãå°é£ãªäœæ¥ã§ããå¯èœæ§ããããçµæã¯ä¿¡é Œæ§ãäœãããšã©ãŒãå«ãŸããããšããããŸãã ãŸãããããã®ã©ã€ã»ã³ã¹å¥çŽã«éåããå¯èœæ§ããããŸãã ãã€ããªã¢ãžã¥ãŒã«ã®åœ¢åŒã§ã©ã€ãã©ãªã䜿çšããå Žåã¯ã64ãããã¢ãžã¥ãŒã«ãååšãããã©ããã確èªããå¿ èŠããããŸãã 64ãããã¢ããªã±ãŒã·ã§ã³å ã§32ãããDLLã䜿çšããããšã¯ã§ããŸããã COMãä»ããŠç¹å¥ãªãã€ã³ãã£ã³ã°ãäœæã§ããŸãããããã¯å¥ã®å€§èŠæš¡ã§è€éãªã¿ã¹ã¯[ 8 ]ã«ãªããŸãã ãŸããã©ã€ãã©ãªã®64ãããããŒãžã§ã³ãååŸãããšè¿œå ã®è²»çšããããå¯èœæ§ãããããšã«æ³šæããŠãã ããã
3.4ã ã€ã³ã©ã€ã³ã¢ã»ã³ãã©ã³ãŒãã®æ¬ åŠ
Visual C ++ã¯ã64ãããã®ã€ã³ã©ã€ã³ã¢ã»ã³ãã©ããµããŒãããŠããŸããã å€éšã®64ãããã¢ã»ã³ãã©ãŒïŒMASMãªã©ïŒã䜿çšããããC / C ++ [ 9 ]ã§åãæ©èœãå®è£ ããå¿ èŠããããŸãã
3.5ã ãã¹ãæ¹æ³ã®è¿ä»£å
ãã¹ãæ¹æ³ã®å€§å¹ ãªæ¹èšãåäœãã¹ãã®è¿ä»£åãæ°ããããŒã«ã®äœ¿çšã ããã«ã€ããŠã¯ä»¥äžã§è©³ãã説æããŸãããã¢ããªã±ãŒã·ã§ã³ãæ°ããã·ã¹ãã ã«ç§»è¡ããã®ã«ãããæéãè©äŸ¡ããéã«ã¯ããããèæ ®ããããšãå¿ããªãã§ãã ãã[ 10 ]ã
3.6ã ãã¹ãçšã®æ°ããããŒã¿
倧éã®RAMãæ¶è²»ãããªãœãŒã¹éçŽåã¢ããªã±ãŒã·ã§ã³ãéçºããŠããå Žåã¯ããã¹ãå ¥åããŒã¿ã®ããŒã¿ããŒã¹ãè£å ããå¿ èŠããããŸãã 64ãããã¢ããªã±ãŒã·ã§ã³ã®è² è·ãã¹ãã§ã¯ã4ã®ã¬ãã€ãã®ã¡ã¢ãªæ¶è²»ãè¶ ããããšãæãŸããã§ãã å€ãã®ãšã©ãŒã¯ããã®ãããªç¶æ³ã§ã®ã¿çºçããŸãã
3.7ã 64ãããã»ãã¥ãªãã£ã·ã¹ãã ã®ååš
䜿çšããä¿è·ã·ã¹ãã ã¯ãå¿ èŠãªç¯å²ã§64ãããã·ã¹ãã ããµããŒãããå¿ èŠããããŸãã ããšãã°ãã¢ã©ãžã³ã¯HaspããŒããŠã§ã¢ããŒããµããŒããã64ããããã©ã€ããŒãè¿ éã«ãªãªãŒã¹ããŸããã ããããéåžžã«é·ãéã64ããããã€ããªãã¡ã€ã«ïŒHasp Envelopããã°ã©ã ïŒãèªåçã«ä¿è·ããã·ã¹ãã ã¯ãããŸããã§ããã ãããã£ãŠãä¿è·ã¡ã«ããºã ã¯ããã°ã©ã ã³ãŒãå ã§ç¬ç«ããŠå®è£ ããå¿ èŠããããããã¯ã¹ãã«ãšæéãå¿ èŠãšããè¿œå ã®å°é£ãªã¿ã¹ã¯ã§ããã ã»ãã¥ãªãã£ãæŽæ°ã·ã¹ãã ãªã©ã«é¢é£ãããã®ãããªç¬éãå¿ããªãã§ãã ããã
3.8ã ã€ã³ã¹ããŒã©ãŒ
64ãããã¢ããªã±ãŒã·ã§ã³ãå®å šã«ã€ã³ã¹ããŒã«ã§ããæ°ããã€ã³ã¹ããŒã©ãŒãå¿ èŠã§ãã ããã§ãç§ã¯ããã«1ã€ã®äŒçµ±çãªééãã«ã€ããŠèŠåããããšæããŸãã ããã¯ã32/64ããããœãããŠã§ã¢è£œåãã€ã³ã¹ããŒã«ããããã®64ãããã€ã³ã¹ããŒã©ãŒã®äœæã§ãã éçºè ã¯ãã¢ããªã±ãŒã·ã§ã³ã®64ãããããŒãžã§ã³ãæºåããéã«ãã64ããããã絶察çãªãã®ã«ããããšèããããšããããããŸãã ãŸãã64ãããã€ã³ã¹ããŒã©ãŒãäœæããŸããã32ããããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ãŠãŒã¶ãŒã«ãšã£ãŠã¯ããã®ãããªã€ã³ã¹ããŒã«ããã±ãŒãžã¯åã«èµ·åããŸããã ãã£ã¹ããªãã¥ãŒã·ã§ã³ã«å«ãŸããŠããé32ãããã¢ããªã±ãŒã·ã§ã³ãš64ãããã¢ããªã±ãŒã·ã§ã³ãã€ãŸãã€ã³ã¹ããŒã©ãŒèªäœã¯èµ·åããªãããšã«æ³šæããŠãã ããã å®éããã£ã¹ããªãã¥ãŒã·ã§ã³ã64ãããã¢ããªã±ãŒã·ã§ã³ã§ããå Žåããã¡ãã32ããããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã§ã¯èµ·åããŸããã ããã«é¢ããæãåä»ãªããšã¯ããŠãŒã¶ãŒãäœãèµ·ãã£ãŠããã®ãæšæž¬ã§ããªãããšã§ãã å®è¡ã§ããªãã€ã³ã¹ããŒã«ããã±ãŒãžã®ã¿ã衚瀺ãããŸãã
4. 4çªç®ã®ã¹ãããã Visual Studio 2005/2008ã§ãããžã§ã¯ããã»ããã¢ãããã
Visual Studio 2005/2008ã§64ããããããžã§ã¯ãæ§æãäœæããã®ã¯éåžžã«ç°¡åã§ãã æ°ããæ§æãæ§ç¯ãããã®æ§æã®ãšã©ãŒãæ€çŽ¢ãã段éã§ãåé¡ãçºçããŸãã 64ãããæ§æãäœæããã«ã¯ã次ã®4ã€ã®æé ãå®è¡ããã ãã§ååã§ãã
å³N1ã«ç€ºãããã«ãæ§æãããŒãžã£ãŒãèµ·åããŸãã
å³1.æ§æãããŒãžã£ãŒã®èµ·å
æ§æãããŒãžã£ãŒã§ãæ°ãããã©ãããã©ãŒã ã®ãµããŒããéžæããŸãïŒå³N2ïŒïŒ
å³2.æ°ããæ§æã®äœæ
64ããããã©ãããã©ãŒã ïŒx64ïŒãéžæããããŒã¹ãšããŠ32ãããããŒãžã§ã³ããèšå®ãéžæããŸãïŒå³N3ïŒã ãã«ãã¢ãŒãã«åœ±é¿ãããããã®èšå®ã¯ãVisual Studioã«ãã£ãŠèªåçã«èª¿æŽãããŸãã
å³3. x64ããã©ãããã©ãŒã ãšããŠéžæããWin32æ§æãåºç€ãšããŠ
æ°ããæ§æã®è¿œå ãå®äºãã64ãããæ§æãªãã·ã§ã³ãéžæããŠã64ãããã¢ããªã±ãŒã·ã§ã³ã®ã³ã³ãã€ã«ã«é²ãããšãã§ããŸãã ã¢ã»ã³ããªã®64ãããæ§æã®éžæãå³N4ã«ç€ºããŸãã
å³4. 32ãããããã³64ãããæ§æãå©çšå¯èœã«ãªããŸããã
éããããã°ã64ããããããžã§ã¯ãã®è¿œå æ§æãè¡ãå¿ èŠã¯ãããŸããã ãã ããããã¯ãããžã§ã¯ãããã®è€éããããã³äœ¿çšããã©ã€ãã©ãªã®æ°ã«å€§ããäŸåããŸãã ããã«å€æŽãã䟡å€ãããã®ã¯ãã¹ã¿ãã¯ã®ãµã€ãºã ãã§ãã ãããžã§ã¯ãã§ããã©ã«ãã®ãµã€ãºã¹ã¿ãã¯ãã€ãŸã1ã¡ã¬ãã€ãã䜿çšããŠããå Žåã64ãããããŒãžã§ã³ã®ãµã€ãºã2ã¡ã¬ãã€ãã«èšå®ããããšã¯çã«ããªã£ãŠããŸãã ããã¯å¿ é ã§ã¯ãããŸããããäºåã«èªåã§ä¿éºããããæ¹ãè¯ãã§ãã ããã©ã«ãã®ãµã€ãºãšã¯ç°ãªãã¹ã¿ãã¯ãµã€ãºã䜿çšããå Žåã¯ã64ãããããŒãžã§ã³çšã«2å倧ããããã®ãçã«ããªã£ãŠããŸãã ãããè¡ãã«ã¯ããããžã§ã¯ãèšå®ã§ãStack Reserve Sizeããã³Stack Commit Sizeãã©ã¡ãŒã¿ãŒãèŠã€ããŠå€æŽããŸãã
5.ã¹ããã5ã ã¢ããªã±ãŒã·ã§ã³ã®ã³ã³ãã€ã«
64ãããæ§æã®ã³ã³ãã€ã«ãã§ãŒãºã§çºçããäžè¬çãªåé¡ã«ã€ããŠã話ãã§ãããããããã§ãã ãµãŒãããŒãã£ã©ã€ãã©ãªã§ã©ã®ãããªåé¡ãçºçããããèæ ®ããWINInAPIé¢æ°ã«é¢é£ä»ããããã³ãŒãå ã®ã³ã³ãã€ã©ãŒã§ã¯ãã€ã³ã¿ãŒãLONGåã«é 眮ã§ããªããªããã³ãŒããã¢ããã°ã¬ãŒãããŠLONG_PTGåã䜿çšããå¿ èŠãããããšãäŒããŸãã ãããŠãã¯ããã«ã æ®å¿µãªãããéåžžã«å€ãã®ãšã©ãŒãããã1ã€ã®èšäºãŸãã¯ããããæ¬ã§ãããè¿°ã¹ãæ¹æ³ã¯ãããŸããã ã³ã³ãã€ã©ãŒãåºããã¹ãŠã®ãšã©ãŒãšã以åã¯ååšããªãã£ãæ°ããèŠåã調ã¹ãããããã®å Žåã«ã³ãŒããã¢ããã°ã¬ãŒãããæ¹æ³ãèŠã€ãåºãå¿ èŠããããŸãã
64ãããã¢ããªã±ãŒã·ã§ã³ã®éçºå°çšã®ãªãœãŒã¹ãžã®ãªã³ã¯ã®ã³ã¬ã¯ã·ã§ã³ã«ãããéšåçã«äœæ¥ã楜ã«ãªããŸãïŒ http : //www.viva64.com/links/64-bit-development/ ã³ã¬ã¯ã·ã§ã³ã¯çµ¶ããæŽæ°ãããŠãããèè ã¯ã圌ãã®æèŠã§ã¯æ³šç®ã«å€ãããªãœãŒã¹ãžã®ãªã³ã¯ãéã£ãŠãããèªè ã«æè¬ããŸãã
ã¢ããªã±ãŒã·ã§ã³ã移è¡ãããšãã«éçºè ãé¢å¿ãæã€å¯èœæ§ã®ããã¿ã€ãã®ã¿ãæ€èšããŸãããã ãããã®ã¿ã€ããè¡šN3ã«ç€ºããŸãã ã»ãšãã©ã®ã³ã³ãã€ã«ãšã©ãŒã¯ããããã®ã¿ã€ãã®äœ¿çšã«é¢é£ä»ããããŸãã
çš®é¡ | ãã©ãããã©ãŒã ã¿ã€ãx32 / x64 | ã泚æ |
int | 32/32 | åºæ¬ã¿ã€ãã 64ãããã·ã¹ãã ã§ã¯ã32ãããã®ãŸãŸã§ããã |
é·ã | 32/32 | åºæ¬ã¿ã€ãã 64ãããWindowsã·ã¹ãã ã§ã¯ã32ãããã®ãŸãŸã§ããã 64ãããLinuxã·ã¹ãã ã§ã¯ããã®ã¿ã€ãã¯64ãããã«æ¡åŒµãããŠããããšã«æ³šæããŠãã ããã Windowsããã³Linuxã·ã¹ãã çšã«ã³ã³ãã€ã«ããŠåäœããã³ãŒããéçºããŠããå Žåã¯ãå¿ããªãã§ãã ããã |
size_t | 32/64 | åºæ¬çãªç¬Šå·ãªãã¿ã€ãã åã®ãµã€ãºã¯ãçè«çã«å¯èœãªé åã®æ倧ãµã€ãºãæžã蟌ãããšãã§ããããã«éžæãããŸãã ãã€ã³ã¿ãŒã¯å®å šã«size_tã«é 眮ã§ããŸãïŒã¯ã©ã¹é¢æ°ãžã®ãã€ã³ã¿ãŒã¯äŸå€ã§ãããããã¯ç¹å¥ãªå Žåã§ãïŒã |
ptrdiff_t | 32/64 | ããã¯ãsize_tåã«äŒŒãŠããŸãããéèŠã§ãã 1ã€ã®ãã€ã³ã¿ãŒãä»ã®ãã€ã³ã¿ãŒïŒptr1-ptr2ïŒããæžç®ãããåŒã®çµæã¯ãptrdiff_tåã«ãªããŸãã |
ãã€ã³ã¿ | 32/64 | ãã€ã³ã¿ãŒã®ãµã€ãºã¯ããã©ãããã©ãŒã ã®ããã深床ã«çŽæ¥äŸåããŸãã ã¬ã€ããä»ã®ã¿ã€ãã«å€æãããšãã¯æ³šæããŠãã ããã |
__int64 | 64/64 | 笊å·ä»ã64ãããåã |
DWORD | 32/32 | 32ããã笊å·ãªãåã WinDef.hã§å®£èšïŒtypedef unsigned long DWORD; |
DWORDLONG | 64/64 | 64ãããã®ç¬Šå·ãªãåã WinNT.hã§å®£èšïŒtypedef ULONGLONG DWORDLONG; |
DWORD_PTR | 32/64 | ãã€ã³ã¿ãŒãé 眮ãã笊å·ãªãã¿ã€ãã BaseTsd.hã§æ¬¡ã®ããã«å®£èšãããŠããŸãïŒtypedef ULONG_PTR DWORD_PTR; |
DWORD32 | 32/32 | 32ããã笊å·ãªãåã BaseTsd.hã§æ¬¡ã®ããã«å®£èšãããŠããŸãïŒtypedef unsigned int DWORD32; |
DWORD64 | 64/64 | 64ãããã®ç¬Šå·ãªãåã BaseTsd.hã§æ¬¡ã®ããã«å®£èšãããŠããŸãïŒtypedef unsigned __int64 DWORD64; |
HALF_PTR | 16/32 | ããŒããã€ã³ã¿ãŒã Basetsd.hã§æ¬¡ã®ããã«å®£èšïŒ#ifdef _WIN64 typedef int HALF_PTR; #else typedef short HALF_PTR; #endif |
INT_PTR | 32/64 | ãã€ã³ã¿ãŒãé 眮ã§ããæåã¿ã€ãã BaseTsd.hã§æ¬¡ã®ããã«å®£èšãããŠããŸãïŒ#if definedïŒ_WIN64ïŒtypedef __int64 INT_PTR; #else typedef int INT_PTR; #endif |
é·ã | 32/32 | 32ãããã®ãŸãŸã®ç¬Šå·ä»ãã¿ã€ãã ãããã£ãŠãå€ãã®å ŽåãLONG_PTRã䜿çšããå¿ èŠããããŸãã WinNT.hã§å®£èšïŒtypedef long LONG; |
LONG_PTR | 32/64 | ãã€ã³ã¿ãŒãé 眮ã§ããæåã¿ã€ãã BaseTsd.hã§æ¬¡ã®ããã«å®£èšãããŠããŸãïŒ#if definedïŒ_WIN64ïŒtypedef __int64 LONG_PTR; #else typedef long LONG_PTR; #endif |
LPARAM | 32/64 | ã¡ãã»ãŒãžãéä¿¡ããããã®ãã©ã¡ãŒã¿ãŒã WinNT.hã§å®£èšïŒtypedef LONG_PTR LPARAM; |
SIZE_T | 32/64 | size_tåã®é¡äŒŒç©ã BaseTsd.hã§æ¬¡ã®ããã«å®£èšãããŠããŸãïŒtypedef ULONG_PTR SIZE_T; |
SSIZE_T | 32/64 | ã¿ã€ãptrdiff_tã®é¡äŒŒç©ã BaseTsd.hã§æ¬¡ã®ããã«å®£èšãããŠããŸãïŒtypedef LONG_PTR SSIZE_T; |
ULONG_PTR | 32/64 | ãã€ã³ã¿ãŒãé 眮ãã笊å·ãªãã¿ã€ãã BaseTsd.hã§æ¬¡ã®ããã«å®£èšïŒ#if definedïŒ_WIN64ïŒtypedef unsigned __int64 ULONG_PTR; #else typedef unsigned long ULONG_PTR; #endif |
WORD | 16/16 | 笊å·ãªã16ãããåã WinDef.hã§æ¬¡ã®ããã«å®£èšãããŠããŸãïŒtypedef unsigned short WORD; |
WPARAM | 32/64 | ã¡ãã»ãŒãžãéä¿¡ããããã®ãã©ã¡ãŒã¿ãŒã WinDef.hã§å®£èšïŒtypedef UINT_PTR WPARAM; |
è¡šN3ã 32ãããããã°ã©ã ã64ãããWindowsã·ã¹ãã ã«ç§»æ€ããå Žåã®å¯Ÿè±¡ã®ã¿ã€ãã
6.é ãããšã©ãŒã®èšºæ
ãã¹ãŠã®ã³ã³ãã€ã«ãšã©ãŒãä¿®æ£ããåŸãåŸ æã®64ãããã¢ããªã±ãŒã·ã§ã³ãåãåããšæãå Žåã¯ããã£ããããå¿ èŠããããŸãã äžçªé£ãããã®ã ã³ã³ãã€ã«æ®µéã§ãã³ã³ãã€ã©ãæ€åºã§ããæãæçœãªãšã©ãŒãä¿®æ£ããŸããããã¯äž»ã«ãæé»çãªåå€æã®äžå¯èœæ§ã«é¢é£ããŠããŸãã ããããããã¯æ°·å±±ã®äžè§ã§ãã ã»ãšãã©ã®ãšã©ãŒã¯é ãããŠããŸãã æœè±¡C ++èšèªã®èŠ³ç¹ããèŠããšããããã®ãšã©ãŒã¯å®å šã«èŠããããæ瀺çãªåå€æã«ãã£ãŠãã¹ã¯ãããŠããŸãã ãã®ãããªãšã©ãŒã¯ãã³ã³ãã€ã«æ®µéã§ç¹å®ããããšã©ãŒã®æ°ã®æ°åãããŸãã
/ Wp64ã¹ã€ããã¯æåŸ ãããã¹ãã§ã¯ãããŸããã ãã®ããŒã¯ãå€ãã®å Žåã64ããããšã©ãŒãèŠã€ããããã®ãã°ãããããŒã«ãšããŠæ瀺ãããŸãã å®éã/ Wp64ã¹ã€ããã¯ã32ãããã³ãŒããã³ã³ãã€ã«ãããšãã«ãã³ãŒãã®ç¹å®ã®éšåã64ãããã¢ãŒãã§æ£ãããªããšããèŠåãã³ã³ãã€ã«ããæ©äŒãäžããã ãã§ãã 64ãããã³ãŒããã³ã³ãã€ã«ããå Žåããããã®èŠåã¯ã©ã®ãããªå Žåã§ãã³ã³ãã€ã©ãŒã«ãã£ãŠçºè¡ãããŸãã ãããã£ãŠã64ãããã¢ããªã±ãŒã·ã§ã³ãã³ã³ãã€ã«ããå Žåã/ Wp64ã¹ã€ããã¯ç¡èŠãããŸãã ããã«ããã®ããŒã¯é ãããšã©ãŒã®æ€çŽ¢ã«ã¯åœ¹ç«ã¡ãŸãã[ 11 ]ã
é ãããšã©ãŒã®äŸãããã€ãèŠãŠã¿ãŸãããã
6.1ã æ瀺çãªãã£ã¹ã
ãšã©ãŒã®ã¯ã©ã¹ã¯æãç°¡åã§ã¯ãããŸãããæ€åºãæãç°¡åã§ã¯ãããŸããããéèŠãªããããåãæšãŠãããæ瀺çãªåå€æã«é¢é£ä»ããããŠããŸãã
äžè¬çãªäŸã¯ãSendMessageãªã©ã®é¢æ°ã«æž¡ããšãã«32ãããåãžã®ãã€ã³ã¿ãŒããã£ã¹ãããããšã§ãã
MyObj * pObj = ... :: SendMessageïŒhwndãmsgãïŒWORDïŒxãïŒDWORDïŒpObjïŒ; |
ããã§ã¯ãæ瀺çãªåå€æã䜿çšããŠããã€ã³ã¿ãŒãæ°å€åã«å€æããŠããŸãã 32ãããã¢ãŒããã¯ãã£ã®å ŽåãSendMessageé¢æ°ã®æåŸã®ãã©ã¡ãŒã¿ãŒã¯LPARAMã¿ã€ãã§ããã32ãããã¢ãŒããã¯ãã£ã§ã¯DWORDãšåãã§ããããããã®äŸã¯æ£ããã§ãã 64ãããã¢ãŒããã¯ãã£ã§ã¯ãDWORDã®äœ¿çšã«èª€ãããããLPARAMã«çœ®ãæããå¿ èŠããããŸãã LPARAMã¿ã€ãã¯ãã¢ãŒããã¯ãã£ã«å¿ããŠ32ããããŸãã¯64ãããã§ãã
ããã¯åçŽãªã±ãŒã¹ã§ãããå€ãã®å Žåãåãã£ã¹ãã¯ãããšã¬ã¬ã³ãã«èŠããã³ã³ãã€ã©ã®èŠåã䜿çšããŠããŸãã¯ããã°ã©ã ããã¹ããæ€çŽ¢ããŠæ€åºããããšã¯äžå¯èœã§ãã æ瀺çãªåå€æã¯ãåãã£ã¹ããæ£ããããšãã³ã³ãã€ã©ãŒã«äŒããããã«æ£ç¢ºã«èšèšãããŠãããããã°ã©ããŒãã³ãŒãã®ã»ãã¥ãªãã£ãæ åœãããããã³ã³ãã€ã©ãŒã®èšºæãæå¶ããŸãã æ瀺çãªæ€çŽ¢ã圹ã«ç«ã¡ãŸããã åã¯æšæºåïŒtypedefãä»ããŠããã°ã©ããŒã«ãã£ãŠå®çŸ©ãããïŒã§ã¯ãªãå Žåããããæ瀺çãªåå€æãå®è£ ããå€ãã®æ¹æ³ããããŸãã ãã®ãããªãšã©ãŒã確å®ã«èšºæããã«ã¯ã Viva64ãPC-Lintã¢ãã©ã€ã¶ãŒãªã©ã®ç¹å¥ãªããŒã«ã®ã¿ã䜿çšããå¿ èŠããããŸãã
6.2ã æé»çãªãã£ã¹ã
次ã®äŸã¯ãã§ã«æé»çãªåå€æã«é¢é£ä»ããããŠãããéèŠãªãããã倱ãããŸãã freadé¢æ°ã®ã³ãŒãã¯ãã¡ã€ã«ããèªã¿åããŸããã64ãããã·ã¹ãã ã§2ã®ã¬ãã€ããè¶ ããããŒã¿ãèªã¿åãããšãããšæ£ãããããŸããã
size_t __freadïŒvoid * __restrict bufãsize_t sizeã size_t countãFILE * __restrict fpïŒ; size_t freadïŒvoid * __restrict bufãsize_t sizeãsize_t countã ãã¡ã€ã«* __restrict fpïŒ { int ret; FLOCKFILEïŒfpïŒ; ret = __freadïŒbufãsizeãcountãfpïŒ; FUNLOCKFILEïŒfpïŒ; returnïŒretïŒ; } |
__freadé¢æ°ã¯size_tåãè¿ããŸãããintåã¯èªã¿åããããã€ãæ°ãæ ŒçŽããããã«äœ¿çšãããŸãã ãã®çµæã倧éã®èªã¿åãããŒã¿ã§ã¯ãå®éã«èªã¿åããããã€ãæ°ã誀ã£ãŠè¿ãããå ŽåããããŸãã
ããã¯åå¿è åãã®éèåã³ãŒãã§ããããã®ãããªåå€æã¯ã³ã³ãã€ã©ã«ãã£ãŠå ±åãããäžè¬ã«ãã®ãããªã³ãŒãã¯ç°¡åã«èŠã€ããŠä¿®æ£ã§ãããšèšãããšãã§ããŸãã ããã¯çè«çã«ã¯ã§ãã ããããå®éã®å€§èŠæš¡ãããžã§ã¯ãã§ã¯ãç¶æ³ã¯ç°ãªãå ŽåããããŸãã ãã®äŸã¯ãFreeBSDã®ãœãŒã¹ã³ãŒãããåŒçšãããã®ã§ãã ãšã©ãŒã¯2008幎12æã«ã®ã¿ä¿®æ£ãããŸããïŒ ããã¯ãFreeBSDã®æåã®ïŒå®éšçïŒ64ãããããŒãžã§ã³ã2003幎6æã«ãªãªãŒã¹ããããšããäºå®ã«ããããããã§ãã
ä¿®æ£åã®ãœãŒã¹ã³ãŒãã¯æ¬¡ã®ãšããã§ãã
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdio/fread.c?rev=1.14
ãããŠãããã«ä¿®æ£çããããŸãïŒ2008幎12æïŒïŒ
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdio/fread.c?rev=1.15
6.3ã ããããã·ãããæäœãã
åã ã®ãããã§åäœããã³ãŒããééããã®ã¯ç°¡åã§ãã 次ã®ã¿ã€ãã®ãšã©ãŒã¯ãã·ããæäœã«é¢é£ããŠããŸãã äŸãèããŠã¿ãŸãããïŒ
ptrdiff_t SetBitNïŒptrdiff_tå€ã笊å·ãªãbitNumïŒ{ ptrdiff_t mask = 1 << bitNum; æ»ãå€| ãã¹ã¯; } |
äžèšã®ã³ãŒãã¯32ãããã¢ãŒããã¯ãã£ã§åäœãããŠãããããšã«0ã31ã®æ°åã§ããããèšå®ã§ããŸãã ããã°ã©ã ã64ããããã©ãããã©ãŒã ã«è»¢éããåŸã0ã63ã®ããããèšå®ããå¿ èŠããããŸãããããããã®ã³ãŒãã¯32ã63ã®ããããèšå®ããŸããã ã1ãã¯intåã§ãããå³5ã«ç€ºãããã«32æ¡ã·ãããããšãªãŒããŒãããŒãçºçããããšã«æ³šæããŠãã ãããã³ã³ãã€ã©ã®å®è£ ã«å¿ããŠ0ïŒå³5-BïŒãŸãã¯1ïŒå³5-CïŒã®çµæãåŸãããŸãã
å³5. A-32ãããã³ãŒãã®31çªç®ã®ãããã®æ£ããèšå®ã BãC-64ãããã·ã¹ãã ã§ã®32ãããã®èšå®ãšã©ãŒïŒ2ã€ã®åäœïŒ
ã³ãŒããä¿®æ£ããã«ã¯ããã¹ã¯å€æ°ãšåãåã®å®æ°ã1ããäœæããå¿ èŠããããŸãã
ptrdiff_t mask = ptrdiff_tïŒ1ïŒ<< bitNum; |
ãŸããä¿®æ£ãããŠããªãã³ãŒããå¥ã®èå³æ·±ããšã©ãŒã«ã€ãªããããšã«æ³šæããŠãã ããã 64ãããã·ã¹ãã ã§31ããããèšå®ãããšãé¢æ°ã®çµæã¯å€0xffffffff80000000ã«ãªããŸãïŒå³6ãåç §ïŒã åŒ1 << 31ã®çµæã¯ãè² ã®æ°-2147483648ã§ãã ãã®æ°ã¯ã64ãããæŽæ°å€æ°ã§0xffffffff80000000ãšããŠè¡šãããŸãã
å³6. 64ãããã·ã¹ãã ã§31ãããç®ãèšå®ããéã®ãšã©ãŒ
6.4ã ããžãã¯ãã³ããŒ
ããžãã¯å®æ°ãã€ãŸããããã¿ã€ããŸãã¯å¥ã®ã¿ã€ãã®ãµã€ãºãèšå®ããããã«äœ¿çšã§ããæ°å€ã¯ãå€ãã®åé¡ãåŒãèµ·ããå¯èœæ§ããããŸãã æ£ãã解決çã¯ããã®ãããªç®çã§sizeofïŒïŒæŒç®åã䜿çšããããšã§ããã倧ããªããã°ã©ã ã§ã¯å€ãã³ãŒãã倱ãããå¯èœæ§ãããããã€ã³ã¿ãŒã®ãµã€ãºã¯4ãã€ãã§ãããsize_tåã¯åžžã«32ãããã§ãããšç¢ºä¿¡ããŠããŸããã éåžžããã®ãããªãšã©ãŒã¯æ¬¡ã®ããã«ãªããŸãã
size_t ArraySize = N * 4; size_t *é å=ïŒsize_t *ïŒmallocïŒArraySizeïŒ; |
è¡šN4ã«ã64ããããã©ãããã©ãŒã ã«åãæ¿ããéã«æ³šæãå¿ èŠãªäž»èŠãªæ°å€ã瀺ããŸãã
è¡šN4ã ã¢ããªã±ãŒã·ã§ã³ã32ããããã64ããããã©ãããã©ãŒã ã«ç§»æ€ãããšãã«å±éºãªäž»ãªéæ³ã®äŸ¡å€
6.5ã ã€ã³ããã¯ã¹ãšããŠ32ãããå€æ°ã䜿çšããéã®ãšã©ãŒ
倧éã®ããŒã¿ãåŠçããããã°ã©ã ã§ã¯ã倧ããªé åã®ã€ã³ããã¯ã¹ä»ãã«é¢é£ãããšã©ãŒãçºçããããæ°žç¶çãªãµã€ã¯ã«ãçºçãããããå ŽåããããŸãã 次ã®äŸã«ã¯ãäžåºŠã«2ã€ã®ãšã©ãŒãå«ãŸããŠããŸãã
const size_t size = ...; char * array = ...; char * end = array + size; forïŒç¬Šå·ãªãi = 0; iïŒ=ãµã€ãº; ++ iïŒ { const int one = 1; end [-i-one] = 0; } |
æåã®ãšã©ãŒã¯ãåŠçãããããŒã¿ã®ãµã€ãºã4ã®ã¬ãã€ãïŒ0xFFFFFFFFïŒãè¶ ãããšãå€æ° 'i'ã®ã¿ã€ãã 'unsigned'ã«ãªããå€0xFFFFFFFFã«å°éããªããããæ°žé ã®ãµã€ã¯ã«ãçºçããå¯èœæ§ãããããšã§ãã çºçã¯å¯èœã§ãããå¿ ãããçºçãããšã¯éããŸããã ã³ã³ãã€ã©ãã©ã®ã³ãŒãããã«ããããã«ãããŸãã ããšãã°ããããã°ã¢ãŒãã§ã¯æ°žé ã®ã«ãŒããååšãããªãªãŒã¹ã³ãŒãã§ã¯ã«ãŒããæ¶ããã®ã§ãã³ã³ãã€ã©ãŒã¯ã«ãŠã³ã¿ãŒã«64ãããã¬ãžã¹ã¿ãŒã䜿çšããŠã³ãŒããæé©åããããšã決å®ããã«ãŒãã¯æ£ãããªããŸãã ãããã¯ãã¹ãŠæ··ä¹±ãæããæšæ¥æ©èœããŠããã³ãŒãã¯ç¿æ¥çªç¶æ©èœããªããªãå¯èœæ§ããããŸãã
2çªç®ã®ãšã©ãŒã¯ãè² ã®ã€ã³ããã¯ã¹å€ã䜿çšãããŠããé åãæåŸããæåã«æž¡ãããšã«é¢é£ããŠããŸãã äžèšã®ã³ãŒãã¯32ãããã¢ãŒãã§åäœããŸãããã«ãŒãã®æåã®å埩ã§64ããããã·ã³ã§å®è¡ãããšãã¢ã¯ã»ã¹ãé åã®å¢çãè¶ ããŠããŸããããã°ã©ã ãã¯ã©ãã·ã¥ããŸãã ãã®åäœã®çç±ãèæ ®ããŠãã ããã
32ãããã·ã¹ãã ã§ã®C ++èšèªèŠåã«åŸã£ãŠãåŒã-i-oneãã¯æ¬¡ã®ããã«èšç®ãããŸãïŒæåã®ã¹ãããi = 0ïŒïŒ
- åŒã-iãã¯ç¬Šå·ãªãã¿ã€ãã§ãå€ã¯0x00000000uã§ãã
- å€æ°ãoneãã¯ãã¿ã€ããintãããã¿ã€ãunsignedã«å±éããã0x00000001uã«ãªããŸãã 泚ïŒintåã¯ã2çªç®ã®åŒæ°ã笊å·ãªãã®åã§ããæäœã«é¢ä¿ããŠããå ŽåãïŒC ++æšæºã«åŸã£ãŠïŒå 'unsigned'ã«å±éãããŸãã
- 2ã€ã®ç¬Šå·ãªãã®å€ãé¢äžããæžç®æŒç®ãè¡ãããæŒç®ã®çµæã¯0x00000000u-0x00000001u = 0xFFFFFFFFuã§ãã çµæã¯ç¬Šå·ãªãã®åã§ããããšã«æ³šæããŠãã ããã
- 32ãããã·ã¹ãã ã§ã¯ãã€ã³ããã¯ã¹0xFFFFFFFFuã®é åã«ã¢ã¯ã»ã¹ããããšã¯ãã€ã³ããã¯ã¹-1ã䜿çšããããšãšåçã§ãã ã€ãŸããçµäº[0xFFFFFFFFu]ã¯çµäº[-1]ã«é¡äŒŒããŠããŸãã ãã®çµæãé åèŠçŽ ã¯æ£ããåŠçãããŸãã
64ãããã·ã¹ãã ã§ã¯ãæåŸã®æ®µèœã§å³ãç°ãªããŸãã 眲åãããptrdiff_tã«çœ²åãããŠããªãã¿ã€ãã®æ¡åŒµãçºçããé åã®ã€ã³ããã¯ã¹ã¯0x00000000FFFFFFFFFFi64ã«ãªããŸãã ãã®çµæãé åã®ã¹ã³ãŒããè¶ ããŸãã
ã³ãŒããä¿®æ£ããã«ã¯ãptrdiff_tãsize_tãªã©ã®åã䜿çšããå¿ èŠããããŸãã
6.6ã 䜿çšããé¢æ°ã®çš®é¡ã®å€æŽã«é¢é£ãããšã©ãŒ
äžè¬ã«ã誰ã責任ãè² ããªããšããééãããããŸãããããã¯ééãã§ã¯ãããŸããã ãã£ãšåã«ïŒVisual Studio 6.0ã®ïŒé æ¹ã®éæ²³ã§ãCWinAppããã®ç¶æ¿ã§ããCSampleAppã¯ã©ã¹ãååšãããããžã§ã¯ããéçºãããããšãæ³åããŠãã ããã åºæ¬ã¯ã©ã¹ã«ã¯ãä»®æ³WinHelpé¢æ°ããããŸãã çžç¶äººã¯ãã®æ©èœããªãŒããŒã©ããããå¿ èŠãªã¢ã¯ã·ã§ã³ãå®è¡ããŸãã èŠèŠçã«ã¯ããããå³7ã«ç€ºããŸãã
å³7. Visual Studio 6.0ã§äœæãããå®è¡å¯èœãªæå¹ãªã³ãŒã
次ã«ããããžã§ã¯ãã¯Visual Studio 2005ã«è»¢éãããWinHelpé¢æ°ã®ãããã¿ã€ããå€æŽãããŸããã32ãããã¢ãŒãã§ã¯DWORDåãšDWORD_PTRåãäžèŽããããã°ã©ã ãåŒãç¶ãæ£åžžã«åäœããããã誰ãæ°ã¥ããŸããïŒå³8ïŒã
å³8.æ£ãããããŸããããå®è¡å¯èœãª32ãããã³ãŒã
ãã®ãšã©ãŒã¯ãDWORDåãšDWORD_PTRåã®ãµã€ãºãç°ãªã64ãããã·ã¹ãã ã§ããèªäœã蚌æããã®ãåŸ ã£ãŠããŸãïŒå³9ïŒã 64ãããã¢ãŒãã§ã¯ãã¯ã©ã¹ã«2ã€ã®ç°ãªãWinHelpé¢æ°ãå«ãŸããŠããŸãããããã¯åœç¶æ£ãããããŸããã ãã®ãããªãã©ããã¯ãäžéšã®é¢æ°ãåŒæ°ã®ã¿ã€ããå€æŽããMFCã ãã§ãªããã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒããšãµãŒãããŒãã£ã©ã€ãã©ãªã§ãé衚瀺ã«ã§ããããšã«æ³šæããŠãã ããã
å³9.ãšã©ãŒã¯64ãããã³ãŒãã§çŸããŸã
6.7ã é ãããšã©ãŒèšºæ
ãã®ãããª64ããããšã©ãŒã®äŸãåŒçšããŠåŒçšã§ããŸãã ãã®ãããªãšã©ãŒã«èå³ãããããããã®ãšã©ãŒã«ã€ããŠè©³ããç¥ãããå Žåã¯ãèšäºãC ++ã³ãŒãã64ããããã©ãããã©ãŒã ã«ç§»æ€ãã20ã®trapã[ 12 ]ã«èå³ããããŸãã
ã芧ã®ããã«ãç¹ã«å€ãã®ãšã©ãŒãäžèŠåã«ããŸãã¯å€§éã®å ¥åããŒã¿ã«ã®ã¿è¡šç€ºããããããé ãããšã©ãŒãæ€çŽ¢ãã段éã¯ç°¡åãªäœæ¥ã§ã¯ãããŸããã éçã³ãŒãã¢ãã©ã€ã¶ãŒã¯ãå ¥åããŒã¿ãå®éã®ç¶æ ã§ã®ã»ã¯ã·ã§ã³ã®å®è¡é »åºŠã«é¢ä¿ãªããã¢ããªã±ãŒã·ã§ã³ã³ãŒãå šäœããã§ãã¯ã§ããããããã®ãããªãšã©ãŒã®èšºæã«é©ããŠããŸããæåã®æ®µéã§ã»ãšãã©ã®ãšã©ãŒãèŠã€ããããã«ãã¢ããªã±ãŒã·ã§ã³ã64ããããã©ãããã©ãŒã ã«ç§»æ€ãã段éãšã64ããããœãªã¥ãŒã·ã§ã³ã®ãããªãéçºã®äž¡æ¹ã§ãéçåæã䜿çšããããšã¯çã«ããªã£ãŠããŸããéçåæã¯ã64ãããã¢ãŒããã¯ãã£ã«é¢é£ãããšã©ãŒã®ç¹åŸŽãããããç解ããããå¹ççãªã³ãŒããèšè¿°ããããã«ããã°ã©ãã«èŠåããæããŸãããã®èšäºã®èè ã¯ãViva64 [ 13 ] ãšåŒã°ãããã®ãããªç¹æ®ãªã³ãŒãã¢ãã©ã€ã¶ãŒã®éçºè ã§ãããã®ããŒã«ããã詳ããç解ããäŒç€Ÿã®Webãµã€ãããœãããŠã§ã¢æ€èšŒã·ã¹ãã ããããã¢ããŒãžã§ã³ãããŠã³ããŒãã§ããŸãã
å ¬å¹³ã«èšããšãGimpel PC-LintãParasoft C ++ Testãªã©ã®ã³ãŒãã¢ãã©ã€ã¶ãŒã§ã¯ã64ããããšã©ãŒã蚺æããããã®äžé£ã®ã«ãŒã«ããããŸãããã ãã第äžã«ããããã¯æ±çšã¢ãã©ã€ã¶ãŒã§ããããããã®64ããããšã©ãŒã蚺æããããã®ã«ãŒã«ã¯ããŸãè¡šçŸãããŠããŸããã第äºã«ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®Linuxãã¡ããªã§äœ¿çšãããLP64ããŒã¿ã¢ãã«ã«éç¹ã眮ããŠãããããLLP64ããŒã¿ã¢ãã«ã䜿çšãããŠããWindowsããã°ã©ã ã§ã®äœ¿çšãåæžãããŸã[ 14 ]ã
7.ã¹ããã7ããã¹ãããã»ã¹ã®ã¢ããã°ã¬ãŒã
åã®ã»ã¯ã·ã§ã³ã§èª¬æããããã°ã©ã ã³ãŒãã®ãšã©ãŒãæ€çŽ¢ããæé ã¯ãå¿ èŠã§ããäžååãªæé ã§ããéçã³ãŒãåæãå«ãåäžã®æ¹æ³ã§ã¯ããã¹ãŠã®ãšã©ãŒãå®å šã«æ€åºã§ããããã§ã¯ãªããããŸããŸãªææ³ãçµã¿åãããŠåããŠæè¯ã®çµæãåŸãããŸãã
64ãããããã°ã©ã ã32ãããããŒãžã§ã³ãããå€ãã®ããŒã¿ãåŠçããå Žåããã¹ããæ¡åŒµããŠã4ã®ã¬ãã€ããè¶ ãã容éã®ããŒã¿åŠçãå«ããå¿ èŠããããŸããããã¯ãå€ãã®64ããããšã©ãŒãçŸããå¢çç·ã§ãããã®ãããªãã¹ãã«ã¯ã1æ¡ä»¥äžã®æéããããå¯èœæ§ããããããäºåã«æºåããå¿ èŠããããŸããéåžžããã¹ãã¯ãåãã¹ãã§å°æ°ã®èŠçŽ ãåŠçããããã«èšè¿°ãããŠãããããããšãã°ããã¹ãŠã®å éšåäœãã¹ãã«åæ Œã§ããŸããïŒæ°åã§ãèªååããããã¹ãïŒããšãã°ãAutomatedQA TestCompleteã䜿çšããŠïŒæ°æéã§ã32ãããã·ã¹ãã ã®äžŠã¹æ¿ãé¢æ°ã¯ã100åã®èŠçŽ ã䞊ã¹æ¿ããå Žåã100,000åã®èŠçŽ ã§æ£ããåäœããã»ãŒå®å šã«ä¿èšŒãããŸãããã ãã50åèŠçŽ ãåŠçããããšãããšã64ãããã·ã¹ãã ã§åãæ©èœã倱æããå ŽåããããŸããåäœãã¹ãã®å®è¡é床ã¯æ°çŸäžåäœäžããå¯èœæ§ããããŸãã64ãããã·ã¹ãã ããã¹ã¿ãŒããéã«ããã¹ãã調æŽããã³ã¹ããå¿ããã«æ±ºããŠãã ããã解決çã®1ã€ã¯ãåäœãã¹ããé«éãã¹ãïŒå°éã®ã¡ã¢ãªã§åäœïŒãšã®ã¬ãã€ããåŠçããŠå€éãªã©ã«å®è¡ããäœéãã¹ãã«åå²ããããšã§ãããªãœãŒã¹ãéäžçã«äœ¿çšãã64ãããããã°ã©ã ã®èªåãã¹ãã¯ãåæ£ã³ã³ãã¥ãŒãã£ã³ã°ã«åºã¥ããŠæ§ç¯ã§ããŸãã