第22å[æçµå]Appendix.3 é åã¨ãã¤ã³ã¿ãæ§é ä½ã¨å ±ç¨ä½ãmakeã«ã¤ã㦠山森ä¸ç¯ 2007-11-23
å é±ã Hacker Newsä¸ã§èå³æ·±ãè°è«ãè¡ããã¾ãã ããã¼ã㯠Linux Kernelã®ã³ã¼ãã£ã³ã°ã¹ã¿ã¤ã« ã«ã¤ãã¦ã§ãã è°è«ã®ä¸ã§ç§ã¯ã ã³ã¼ãã£ã³ã°ã§åç´æ¹åã«ããããã¤ã³ãã³ããã¨ãã¹ãã ã¨ãããããããªèæ¦ãä»æãã¾ãããç§ã¯å ¨é¢çã«è³æã§ããçç±ã説æãã¾ãããã åç´æ¹åã«ããããã¤ã³ãã³ããã¨ãã¨ã¯ï¼ ç°¡åãªä¾ãæãã¦ã¿ã¾ãã int robert_age = 32; int annalouise_age = 25; int bob_age = 250; int dorothy_age = 56; ã¡ãã£ã¨è¦ãã ãã§ããbob_ageããããããã¨åããã§ããããã¾ããç®è¦ã§ãã¡ãã¡æ¢ããªãã¦ããå ¨ã¦ã®å¤ãæ´æ°ã§ãããã¨ãç°¡åã«ç¢ºèªã§ãã¾ãã ãã®èãæ¹ã¯ ä¸è¬çã« å ±æ ããã¦ããããã§ã¯ããã¾ãããã§ãã®ã§ããªã å¤ã㮠人ãã¡ ããããæå¹ãªã¹ã¿ã¤ã«ã¬
Introduction I wrote this tiny compiler, which translates a subset of C into x86 machine code, for fun. It has no use, unless it counts as educational. I called it CC500 because I initally guessed it would take about 500 lines. It turned out to be about 600 lines even without the comments and blank lines. With the comments and blank lines it has about 750 lines. It could be made shorter, but I wan
Cã³ã³ãã¤ã©ã¨ããã°ã¨ã¦ã¤ããªãè¤éãªããã°ã©ã ã¨ããã¤ã¡ã¼ã¸ãããã¾ããã¨ãããããã®Cã³ã³ãã¤ã©ã(ãµãã»ããã¨ã¯ãã)ããã500è¡ã»ã©ã®Cã®ã½ã¼ã¹ã³ã¼ãã§å®ç¾ãããCC500ãåä»ããããããã°ã©ã ãå ¬éããã¦ãã¾ãã ã½ã¼ã¹ã³ã¼ãã¯å¯èªæ§ãç¶æããããã«ã¤ãããã空è¡ãã³ã¡ã³ããå«ããã¨ãå®éã¯750è¡ã»ã©ã«ãªãããã§ãããããã§ãããã ãã³ã³ãã¯ããªã½ã¼ã¹ã³ã¼ãã§å®è¡å¯è½ãªELFãã¤ããª(Linuxç¨ã®ãã¤ããª)ãçæã§ããã®ã¯èå³æ·±ãã®ã§ã¯ãªãã§ããããã 以ä¸å®éã«Linuxã§ã³ã³ãã¤ã«ãã¦ã¿ã¾ããã èªå·±ã³ã³ãã¤ã«ã§ãã ãã®ã³ã³ãã¤ã©ã¯Cè¨èªã®ãµãã»ããã§ãèªåèªèº«ã®ã½ã¼ã¹ã³ã¼ããã³ã³ãã¤ã«ã§ããã¨ããããããããã¨ããã§ããã¾ããcc500_1ãã¨ããå®è¡ãã¡ã¤ã«ãçæãã¾ãã gcc cc500.c -o cc500_1 çæãããå®è¡ãã¡ã¤ã«ãcc500_1ãã使
ããã°ã©ãã³ã°ãã¯ãããã ãããã2010年度ãã¯ãã¾ãã¾ããããã®æ¥ããã®æ°å ¥ç¤¾å¡ãæ°å ¥å¦çã®æ¹ã®ä¸ã«ã¯ãããããLinuxã§ããã°ã©ãã³ã°ãå§ããã¨ããæ¹ãå¤ãããã¨æãã¾ã[1]â ãWindowsã§ããã°ã©ãã³ã°ã¨ããã°ãVisual Studioã®ãããªçµ±åéçºç°å¢ã使ç¨ããã®ãä¸è¬çã®ããã§ãããUbuntuã§ã¯ã©ãããã°ããã®ã§ããããã Ubuntuã¯Unixã®æåãåãç¶ãOSã§ããããããã°ã©ãã³ã°ã®ããã®ãã¼ã«ã¯è±å¯ã«æã£ã¦ãã¾ãããããããããã«ãã¨ããããããããã°OKãã¨ããå®ç³ãããããããªãã¨ãã人ãå¤ãããããã¾ããã Linuxã«ãããéçºç°å¢ã¯è²ã ããã¾ããããã¯ãä¸çªã¡ã¸ã£ã¼ãªçµ±åéçºç°å¢ã¨ããã°Eclipseã¨NetBeansã§ãããããããä»åãã3åã«ããã£ã¦ãéçºç°å¢ã¨ãã¦ã®Emacsãç´¹ä»ãã¾ã[2]â ã Emacsã®ã¤ã³ã¹ãã¼ã« Emac
>>ï¼1ï¼ããã¤ã¥ã ååã¯åç´ãªå®è£ ãããã«ãã¹ã¬ãããã¹ã¬ãããã¼ã«ã¨é ã«è¦ã¦è¡ãã¾ãããä»åã¯ããããepollã使ã£ãå®è£ ãç´¹ä»ãã¾ãã epollä¾- 4epoll.c å¤éI/Oããªãã¡ select(2) / poll(2) ã«ããã¤ãã³ãã«ã¼ãã¯ãã«ãã¹ã¬ãããæ®åãã以åããå©ç¨ããã¦ãã¾ããã select(2) / poll(2) ã¯è¤æ°ã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ï¼ã½ã±ããï¼ã調ã¹ãI/Oå¯è½ãªãã®ãè¿ãã·ã¹ãã ã³ã¼ã«ã§ããã½ã±ããã«å¯¾ããèªã¿åãã¯ããã©ã«ãã§ã¯ãã¼ã¿ããªããã°ãããã¯ï¼ãã¼ã¿ãå°çããã¾ã§å¾ ã¤ï¼ãã¾ãããäºåã«I/Oå¯è½ãã確èªãã¦ããã°ãããã¯ãããã¨ã¯ããã¾ããã1ã·ã¹ãã ã³ã¼ã«ã§è¤æ°ã®ã½ã±ããã調ã¹ãããç¹ãéè¦ã§ã1ããã»ã¹ã§è¤æ°ã®ã¯ã©ã¤ã¢ã³ãã«ä¸¦è¡ãã¦å¯¾å¿ã§ããããã«ãªãã¾ãããããå½ç¶ãªããã対象ã½ã±ããæ°ã®å¢å ã«å¿ãã¦å¦çéãå¢ãã¾ãã
Linuxã§å ±æã©ã¤ãã©ãªï¼*.soï¼ãä½ãããã«ãªã£ãã®ã§ã¡ãã£ã¨åå¼·ãã¦ã¿ããä»ã¾ã§ã¯ä½¿ãã ãã ã£ãã®ã§ã以ä¸ã®ãããªãã¨ã¯ç¥ã£ã¦ãããä½ãã¨ãã¯gccã®-sharedãªãã·ã§ã³ã使ãã使ãã¨ãã¯gccã®"-lã©ã¤ãã©ãªå"ã§ãªã³ã¯ããã©ã¤ãã©ãªãæå®ããããªã³ã¯æã®ã©ã¤ãã©ãªæ¢ç´¢ãã¹ã¯-Lãªãã·ã§ã³ã§æå®ãããå®è¡æã®ã©ã¤ãã©ãªæ¢ç´¢ãã¹ã¯/etc/ld.so.confã«æ¸ãã¦ãããã£ã¬ã¯ããªãç°å¢å¤æ°LD_LIBRARY_PATHã§ãæå®å¯è½ãã©ã¤ãã©ãªãä½ãã¨ãã¯ã.cãã.oãä½ãã¨ãã«-fPICãã¤ããã¨ããããããæ°ããã©ã¤ãã©ãªãå ¥ããã¨ãã¯ldconfigããã¨ããããããéã«ä»ã¾ã§ãã¾ãç¥ããªãã£ããã¨ãã»ã¨ãã©ã®ã©ã¤ãã©ãªã¯libhoge.so, libhoge.so.1, libhoge.so.1.1ã®ããã«3ã¤ãããã®ãã¡ã¤ã«ããããlibhoge.soãlibh
ããã»ã¹ããããã¯ããè¦å ã®ä¸ã¤ã«ãã¡ã¤ã«I/Oãããã¾ãããããåæI/Oã¨è¨ãã¾ãããPOSIXã§ã¯AIOï¼éåæ I/OãAsynchronous I/Oï¼ãå®ç¾©ãã¦ãããI/Oä¸ã§ãããã»ã¹ããããã¯ããä»ã®å¦çãé²ããããããã«ãªãã¾ãã æ¬è¨äºã§ã¯ãããã¡ãã£ãã·ã¥ãããã¡ã¤ã« I/Oã解説ããLinuxã®io_submit(2)ãç¨ããPOSIXæºæ ã®AIOã©ã¤ãã©ãªã試ä½ãã¦ã¿ã¾ãã ãã¡ã¤ã«I/Oã¨ãããã¡ãã£ãã·ã¥ io_submit(2)ã§ã¯Direct I/Oãç¨ãã¾ãããã©ã¤ãã©ãªã®è©¦ä½ã¸é²ãåã«ã¾ããã¡ã¤ã«I/Oã®ãããã¡ï¼ãããã¡ãã£ãã·ã¥ï¼ã«ã¤ãã¦æ´çãã¾ããå®ã¯åã«ãããã¡ã¨è¨ã£ã¦ãã¾ãã¨èª¤è§£ãããå ´é¢ãå¤ããããä¾ãã°ããã°ã©ãã³ã°å ¥éä¸è¬ã¨ãã¦ãã¡ã¤ã«I/Oãåãä¸ããéã«ã¯ã CPUã®åä½ã¯éãããã£ã¹ã¯ã®åä½ã¯é ãã 両è ã®éã«é度差ãç·©åããç·©è¡
ä»åãããVimãããã°ã©ã éçºç°å¢ã«ãã¦ãã¾ãæ¹æ³ã解説ãã¾ãããããã§ããã°ãVimã§ããã°ã©ã ãç·¨éããå¾ã«ãã³ã³ã½ã¼ã«ã«æ»ã£ã¦ã³ã³ãã¤ã«ã®æ示ãåºãã¨ããé¢åãé¿ãããã¾ããï¼ç·¨éé¨ï¼ ããããå®ç¨çãªãã¨ã - Cããã°ã©ãã³ã° ããã¾ã§7åã«ããã£ã¦Vimã®åºæ¬çãªä½¿ãæ¹ã解説ãã¦ãããããã¾ã§ç´¹ä»ãã¦ããæä½æ³ã身ã«ä»ãã¦ããã°ãããªãã®é度ã§ããã¹ããã¡ã¤ã«ãç·¨éã§ããããã«ãªã£ã¦ããã¯ãã ãVimãæä½ããè½åã¯ãçç·´ããã°ããã»ã©é«éã«ãªããã¹ãã«ã¢ããã«è²»ãã対象ã¨ãã¦ã¯æªããªãé¸æè¢ã ãä»å以éãã°ããã®éã¯ãããå ·ä½çãªã·ã¼ã³ãæ³å®ãã¦ãæä½æ¹æ³ããã¾ãã¯æä½æ¹æ³ããã便å©ãªæ¬¡å ã¸å¼ãä¸ãããã©ã°ã¤ã³ã«ã¤ãã¦ç´¹ä»ãã¦ããã Vimã¨ããã°ãã¯ãããã°ã©ãã³ã°è¨èªãè¨å®ãã¡ã¤ã«ã®ç·¨éã¨ãã£ã¿ã¨ãã¦å©ç¨ãããã¨ãå¤ããä»åã¯ãCè¨èªã®ã½ã¼ã¹ã³ã¼ãç·¨éã¨ã³ã³ãã¤ã«ãå®è¡
èªä½ã®ããã°ã©ã ããï¼BIOSã®è¨å®ãå¤æ´ããäºã¯å¯è½ãªã®ãã ä¾ãã°ãã¼ãããã¤ã¹è¨å®ããã¼ãã·ã¼ã±ã³ã¹ã®è¨å®ã¯ï¼ ãµã¤ãã¯PCèµ·åæã®ãBIOSè¨å®ç»é¢ãããæåã§å¤æ´ããããã ãï¼ ãããã®é ç®ãï¼èªä½ããã°ã©ã ããæ¸ãæããäºã¯ã§ããã®ãã ï¼ï¼ï¼BIOSãCMOSãªã©é¢é£ãã¼ã¯ã¼ãã«ã¤ã㦠ï¼ï¼ï¼èªä½ããã°ã©ã ããBIOS/CMOSã«ã¢ã¯ã»ã¹ããæ¹æ³ ï¼ï¼ï¼å ·ä½çãªãµã³ãã«ã³ã¼ãã¨å®ç¾æ¹é ï¼ï¼ï¼çµè« ï¼ï¼ï¼BIOSãCMOSãªã©é¢é£ãã¼ã¯ã¼ãã«ã¤ãã¦ç°¡åã«ãããã PCã®èµ·åã®æµãï¼ ã¦ã¼ã¶ã¯PCã®é»æºãå ¥ããã PCã®ãã¶ã¼ãã¼ãã«éé»ãããããã§ï¼ãã¶ã¼ãã¼ãä¸ã«ã¯ï¼CPUï¼ROMã¾ãRAMãè¨ç½®ããã¦ããã ROMå ã«ã¯ï¼BIOSã®ããã°ã©ã ãå ¥ã£ã¦ããã ROMã¨ã¯ããï¼ãã©ãã·ã¥ã¡ã¢ãªãªã®ã§ï¼æ¸ãæãå¯è½ã§ãããããã®æ¸ãæãã¯ï¼BIOSã¢ãããã¼ããæå³ããã RA
neovimã¯ãvimãè¿ä»£åãããããã¨ããvimã®forkã§ãã https://github.com/neovim/neovim http://news.mynavi.jp/news/2014/02/26/097/ ãªããªããã£ãããã®ã§ãç¾ç¶ã©ã®ãããªæ¹ä¿®ãè¡ãããã®ãcommitã追ãããã¦ã¿ã¾ãã TL;DR éçºå§ã¾ã£ãã°ã£ãããªã®ã§ç·Commitæ°ã¾ã å°ãªã CMake使ãããã«ãã ã´ãæé¤ã¨ãµãã¼ãããããªãç°å¢ã®åãæ¨ã¦ããã å®ç¨æ®µéã«ãªãã«ã¯å°ãªãã¨ãå年以ä¸ã¯ããããã 詳ãã Import vim from changeset v5628:c9cad40b4181 ãã¡ã¼ã¹ãã³ããã ãããªãããªãã¡ã¤ã«ã¨ããã¯ãã¨ãæ¶ããããã Cmakeã«ãã«ãã移æ¤ããããã forkå ã¨ã®å·®åã¯ãªããããã¾ãä¸å¯§ãããªãã Fix build on OSX/Archl
@ITã«ä»¥ä¸ã®ãããªè¨äºãåºã¦ã ä»åãããã°ããã®éã¯ãã¾ã£ããéã®ä¾ãã¤ã¾ã使ãã¨ããã°ã©ã ã®å¦çæ§è½ãä¸ããã¨ããã·ã¹ãã ã³ã¼ã«ãç´¹ä»ãã¦ãããã·ã¹ãã ã³ã¼ã«ãå¼ã¶åæ°ã¯å°ãªãæ¹ãå¦çæ§è½ã¯é«ããªãã¨ããååã¯å¤ãããªãããå¼ã³åºãã¦ããã¨å¦çæ§è½ãåä¸ããã·ã¹ãã ã³ã¼ã«ã¨ãããã®ãåå¨ããã®ã ãããããã·ã¹ãã ã³ã¼ã«ã使ããªãã§ãããã¨ã¯ãã¨ã¦ããã£ãããªãã ä»åç´¹ä»ããã·ã¹ãã ã³ã¼ã«ã¯ãmmap(2)ãã ãããã§ã¯è©³ããä»çµã¿ã解説ããªãããmmap(2)ã¯ãããã°ã©ã ã®å¦çæ§è½ã«å¿ ãè¯ãå½±é¿ãä¸ããã ãã¯ããã£ãï¼ é«éåã«å¹ãã·ã¹ãã ã³ã¼ã« (1/2)ï¼ç¥ã£ã¦ãã¯ããã·ã¹ãã ã³ã¼ã«ï¼3ï¼ - ï¼ IT ãããçã«åããã®ãããGoè¨èªã§mmapã·ã¹ãã ã³ã¼ã«ã使ã£ããã¡ã¤ã«èªã¿è¾¼ã¿ã®é«éåæ¤è¨ã¨Cè¨èªã®ã³ã³ãã¤ã©ã®è©± - ryochack.blogãã®ãããªããã°ã¨ã³ããªã
åä¾ã®ããããã§ããã ãææããã¦ææãæãããã¨ã ãã¯é·ãã¦ããå±±æ¬ã§ãã ä»åã¯ãC/C++ ã§ä½ã£ãããã°ã©ã ãéç¨ä¸ã«ã¯ã©ãã·ã¥ããã¨ãã®ãããã°æ¹æ³ã®ã話ãã§ãã éçºä¸ã®ãããã°ã¯ gdb ãªã©ã§ã½ã¼ã¹è¿½ããªãããããã°ã§ãã¾ãããéç¨ä¸ã§ã㨠strip ãã¦ãããæé©åãã¦ããããã¦ãããã°ãé£ãããªãã¾ãã ããããããããªãã¯ã©ãã·ã¥ããã¨æ å ±ãæ®ããã«å°ã£ã¦ãã¾ãã¾ãããããªã¨ãã©ããããã Step1. ã¹ã¿ãã¯ãã¬ã¼ã¹ãåºåãã ãããªé¢æ°ãç¨æãã¾ããããLinux 以å¤ã®äººã¯ãããªãã«å®è£ ãã¦ãã ããã #include <execinfo.h> #include <unistd.h> void dump_stack() { void* bt[100]; int n = backtrace(bt, 100); backtrace_symbols_fd(bt,
æè¿ãRobert Loveå çã®æ¬ãæãªæã«ãã©ã¼ã¨èªãã§ãããããããã§ãããããã®ä¸ã«Linux Kernelå é¨ã§ä½¿ããã¦ããLinked Listã®å®è£ ãæ¸ãã¦ãã£ã¦é¢ç½ãã£ãã®ã§å ±æã ã¾ããLinked Listã®ä¸åä¸åã®ã¨ã³ããªã表ãstructãå®ç¾©ãã¾ãã struct list_head { struct list_head *next, *prev; }; ãããããããããããã«Cåã®ä½ãåã§ãæµç³ã«ããã¯ããã¾ãããé¨ããã¾ããããåå¾ã®ã¨ã³ããªã¸ã®ãã¤ã³ã¿ã¯ç¢ºãã«ããããã©ããããã«ã¯ãã¼ã¿ãæãããã®ãã¤ã³ã¿ããªããããªãã®ããããã¡ããã¾ããã¼ã¿å¿ãã¦ãã¡ãã£ãã®ï¼ãããããã ãããã¡ããã¯è¨ã£ãããããã¯ãåã®çè¦ã¨ãããã®ããããã®Linked Listã¯ä»¥ä¸ã®ã³ã¼ãã®ããã«ãã¼ã¿æ§é ã«åãè¾¼ãã§ä½¿ããã®ãªããããããããã¦ããã¯æ£ããã£ãã st
å½ãµã¤ãã¯ãUNIX/Linuxã«ã¦ãã使ç¨ãããã³ãã³ãï¼ãã¼ã«ã®ä½¿ç¨ä¾ãè¨èªã®å ¥éãã³ã¼ãäºä¾ãæ²è¼ãã¦ããã¾ãã æ·±ãç解ã¯æ±ããã«ãæã£åãæ©ã使ããããã«ã使ç¨ä¾(ãµã³ãã«)ãä¸å¿ã«ãã¦ãã¾ãã æ å ±ã®æ£ç¢ºãã«ã¯æ³¨æãæã£ã¦ããã¾ããã誤ããé©åã§ãªãè¨è¿°ãæ²è¼ãã¦ãã¾ãããããã¾ããã å½ãµã¤ãã®æ å ±ããå©ç¨ããã ãéã¯ãã©ããããèªèº«ã§ååæ¤è¨¼ãè¡ã£ã¦ãã ããã ãªããå½ãµã¤ãã®ããå©ç¨ã«ãªããã¦çºçããæ害ã«ã¤ãã¦ã¯ãå½æ¹ã¯ä¸å責任ãè² ãããã¾ãã®ã§ãããããããäºæ¿é¡ãã¾ãã ã¾ããæ²è¼å 容ã«ã¤ãã¦ã®ã質åã¯ãé æ ®é¡ãã¾ãã
Android 㯠Linux ã®ä¸ç¨®ã§ããããARM ã§åã Linux åãã®Cè¨èªã§æ¸ãããã©ã¤ãã©ãªã®å¤ããåãã¾ããï¼å¤å°éãã®ã§ãåããªãå ´åãããï¼ããã ãããã«ãæ¹æ³ãæé»ã®äºè§£äºé ã«ãªã£ã¦ãããã¦ãAndroid NDK ã«ã¡ããã¨æ¸ããã¦ããªãã£ããããã®ã§ãããã«ã¾ã¨ãã¾ãï¼ ä»¥ä¸ãæ¶ç©ºã® libhoge ããã«ããããã¨ã¨ãã¾ãã ãã«ã対象ã¯ä¸è¬çã«éçã©ã¤ãã©ãª (.a) ãã¡ã¤ã«ã«ãã¦ããã¨åã§ããèªåã§ä½¿ãéã¯ãèªåã® Android.mk ã«ä»¥ä¸ã®ç©ã追å ãã¾ãã LOCAL_CFLAGS ã« -Ihoge-1.0/include ã¿ããã®ã追å LOCAL_LDLIBS ã« -Lhoge-1.0-android-build/$(TARGET_ARCH_ABI) 㨠-l hoge ã追å ã©ã¤ãã©ãªããã«ããã¦ã§ãã libhoge.a ã¯ãã®ãã©ã«ãã«
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}