以前在學校,提到 VI / VIM 時,老師總會說它是個強大的編輯器。其實當時只覺得它很難用(那時用的版本還是用H、J、K、L在移動游標),不知道它強大在哪?現在跟視窗化的編輯器比起來,我想是沒有強大到哪去啦,除了它可以不需要滑鼠。不過就 command line 下,它的確是具備了不少後來視窗界面下才被覺得習以為常的功能。
2013年11月13日 星期三
2013年11月7日 星期四
C 語言預設變數 備忘
這也是一個常常會混亂的東西@@,記憶力越來越差,不知道跟什麼東西都能 Google 有關?還是年紀有關?
GCC 中有事先定義了一些變數,讓我們可用,其中 Debug 時常用的就是 __FILE__,__LINE__跟我常常會弄混的 __func__。別人都是大寫,就它是小寫。其實本來是__FUNCTION__,但後來 GNU 已經不建議使用(原因不明),所以改成了 __func__。
結果我就會搞不清到底是:
__func__,__function__,__FUNC__ 還是 __FUNCTION__。
實際上查了一下,除了這三個還有其它的,只是比較不常用。
1. __BASE_FILE__
完整的原始檔案路徑
2. __cplusplus
表示該檔案由 g++ 所編譯,當成 C++ 的檔案
3. __DATE__
編譯的日期
4. __TIME__
編譯的時間
5. __FILE__
原始檔名
6. __LINE__
所在行數
7. __VERSION__
gcc 版本
8. __func__
為了避免混淆,我就不提另一個了
GCC 中有事先定義了一些變數,讓我們可用,其中 Debug 時常用的就是 __FILE__,__LINE__跟我常常會弄混的 __func__。別人都是大寫,就它是小寫。其實本來是
結果我就會搞不清到底是:
__func__,
實際上查了一下,除了這三個還有其它的,只是比較不常用。
1. __BASE_FILE__
完整的原始檔案路徑
2. __cplusplus
表示該檔案由 g++ 所編譯,當成 C++ 的檔案
3. __DATE__
編譯的日期
4. __TIME__
編譯的時間
5. __FILE__
原始檔名
6. __LINE__
所在行數
7. __VERSION__
gcc 版本
8. __func__
為了避免混淆,我就不提另一個了
2013年11月4日 星期一
diff 參數備忘
diff 是我每次用都要查的指令@@,所以寫下來備忘一下。
diff -Naur path1 path2 > project.patch
-N In directory comparison, if a file is found in only one directory, treat it as present but empty in the other directory.
-a Treat all files as text and compare them line-by-line, even if they do not seem to be text.
-u Use the unified output format.
-r When comparing directories, recursively compare any subdirectories found.
如果要使用這個 patch 檔
patch -p# < project.patch
PS: "#" 表示要省略的路徑層數
man 的原文說明
-pnum or --strip=num
Strip the smallest prefix containing num leading slashes from each file name found in the patch file.
A sequence of one or more adjacent slashes is counted as a single slash. This controls how file names found in the patch file are treated, in case you keep your files in a different directory than the person who sent out the patch. For example, supposing the file name in the patch file was
/u/howard/src/blurfl/blurfl.c
setting -p0 gives the entire file name unmodified, -p1 gives
u/howard/src/blurfl/blurfl.c
without the leading slash, -p4 gives
blurfl/blurfl.c
and not specifying -p at all just gives you blurfl.c. Whatever you end up with is looked for either in the current directory, or the directory specified by the -d option.
diff -Naur path1 path2 > project.patch
-N In directory comparison, if a file is found in only one directory, treat it as present but empty in the other directory.
-a Treat all files as text and compare them line-by-line, even if they do not seem to be text.
-u Use the unified output format.
-r When comparing directories, recursively compare any subdirectories found.
如果要使用這個 patch 檔
patch -p# < project.patch
PS: "#" 表示要省略的路徑層數
man 的原文說明
-pnum or --strip=num
Strip the smallest prefix containing num leading slashes from each file name found in the patch file.
A sequence of one or more adjacent slashes is counted as a single slash. This controls how file names found in the patch file are treated, in case you keep your files in a different directory than the person who sent out the patch. For example, supposing the file name in the patch file was
/u/howard/src/blurfl/blurfl.c
setting -p0 gives the entire file name unmodified, -p1 gives
u/howard/src/blurfl/blurfl.c
without the leading slash, -p4 gives
blurfl/blurfl.c
and not specifying -p at all just gives you blurfl.c. Whatever you end up with is looked for either in the current directory, or the directory specified by the -d option.
2013年9月29日 星期日
Git 初學 3 - reset
用 git 好像避免不了,有時會把檔案弄亂。以前用 SVN 時好像只能重新 checkout。(也有可能有我不知道的方法?)但強大的 git 應該有辦法不需要這麼做,雖然它重新 clone 也很快。
最後我就找到了這篇:
Git 版本控制:利用 git reset 恢復檔案、暫存狀態、commit 訊息
2013年9月28日 星期六
tar.zx
上次在網路上找檔案時,找到的檔案是 tar.zx 的檔。所以它不能用以前常用的 gzip 或 bzip 來解。上網找了一下,發現現在已經很多檔案改用 zx 格式了。
我找到的文章:tar.xz format
我找到的文章:tar.xz format
2013年9月23日 星期一
Cavium SDK 2.3 DDR Debug
因為有問題懷疑跟DDR有關,所以想要印些訊息,最後找到在
bootcode/u-boot/arch/mips/cpu/octeon/lib_octeon_shared.c
中的 DDR_DEBUG 可以開啟 debug message。
這是軟體工程師的習慣,先去找 code,直接改 code。實際上人家有提供簡單的方法,經過 FAE 的指點,我去 grep 所有 'getenv("ddr_' 的字串(就是程式中有用 getenv 去抓 ddr 開頭的環境變數的地方),結果找到了:
./arch/mips/cpu/octeon/lib_octeon_shared.c
"ddr_verbose" => 印出初始化的資訊
"ddr_trace_init" => trace init 過程的訊息
"ddr_safe" => 據說是將 DDR 本來一個 clock cycle 讀取兩次,改成一次。
"ddr_narrow"
"ddr_2t"
"ddr_burst8"
"ddr_rodt_ena"
"ddr_use_ecc" => 啟動 ECC 功能,但我不知道這是什麼?
"ddr_cas_latency"
"ddr_sil_mode"
"ddr_prompt"
"ddr_debug" => 印出一些 debug message(跟我直接改 code 的結果一樣)
"ddr_four_lmc"
./arch/mips/lib/board_octeon.c
"ddr_clock_hertz" => 指定 DDR 工作時脈(不是 data rate)。小心!設定差太多,就開不起來了。
"ddr_ref_hertz" => 應該是 reference clock。
./arch/mips/cpu/octeon/lib_octeon_shared.c
"ddr_verbose" => 印出初始化的資訊
"ddr_trace_init" => trace init 過程的訊息
"ddr_safe" => 據說是將 DDR 本來一個 clock cycle 讀取兩次,改成一次。
"ddr_narrow"
"ddr_2t"
"ddr_burst8"
"ddr_rodt_ena"
"ddr_use_ecc" => 啟動 ECC 功能,但我不知道這是什麼?
"ddr_cas_latency"
"ddr_sil_mode"
"ddr_prompt"
"ddr_debug" => 印出一些 debug message(跟我直接改 code 的結果一樣)
"ddr_four_lmc"
./arch/mips/lib/board_octeon.c
"ddr_clock_hertz" => 指定 DDR 工作時脈(不是 data rate)。小心!設定差太多,就開不起來了。
"ddr_ref_hertz" => 應該是 reference clock。
訂閱:
文章 (Atom)