快轉到主要內容

Posts

2016

2015

在mutt設定gmail

·1068 字·3 分鐘
總設定 # set editor = "vim" set send_charset="us-ascii:utf-8" set from = "你的帳號@gmail.com" set realname = "你的名字 可隨便打" set imap_user = "你的帳號@gmail.com" set imap_pass = "你的密碼" set folder = "imaps://imap.gmail.com:993" set spoolfile = "+INBOX" set postponed ="+[Gmail]/Drafts" set header_cache =~/.mutt/cache/headers set message_cachedir =~/.mutt/cache/bodies set certificate_file =~/.mutt/certificates set smtp_url = "smtp://你的帳號@smtp.gmail.com:587/" set smtp_pass = "你的密碼" set move = no set imap_keepalive = 900 bind pager <up> previous-line #scroll inside the message rather than the index bind pager <down> next-line bind index <left> last-entry bind pager <left> exit bind index <right> display-message bind pager <right> next-page bind browser <right> select-entry 細部設定 # 編碼與編輯器 # 通常在Ubuntu底下的預設編輯器是nano而不是vim,所以需要調整。 utf-8則是Linux Cross Reference中建議的。

llvm - helloworld

·213 字·1 分鐘
環境設置 # ubuntu體系:sudo apt-get install llvm MAC: brew install llvm makefile (MAC) # BIN_PATH=/usr/local/Cellar/llvm/3.6.1/bin/ export PATH:=$(PATH):$(BIN_PATH) LLVM_CONFIG=llvm-config FLAGS= --cxxflags --ldflags --system-libs --libs core toy: toy.cpp clang++ -g -O3 toy.cpp `$(LLVM_CONFIG) $(FLAGS)` -o toy clean: rm -f toy top module # #include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Support/IRBuilder.h" int main() { llvm::LLVMContext& context = llvm::getGlobalContext(); llvm::Module* module = new llvm::Module("top", context); llvm::IRBuilder<> builder(context); module->dump( ); } function # 宣告function # 無參數 # llvm::FunctionType *funcType = llvm::FunctionType::get(builder.getInt32Ty(), false); llvm::Function *mainFunc = llvm::Function::Create(funcType, llvm::Function::ExternalLinkage, "main", module); 有參數 # std::vector< llvm::Type* > putsArgs; putsArgs.push_back(builder.getInt8Ty()->getPointerTo()); llvm::ArrayRef< llvm::Type* > argsRef(putsArgs); llvm::FunctionType *putsType = llvm::FunctionType::get(builder.getInt32Ty(), argsRef, false); 定義function # 引用已有的function # llvm::Constant *putsFunc = module->getOrInsertFunction("puts", putsType); 創造新的function # llvm::BasicBlock *entry = llvm::BasicBlock::Create(context, "entrypoint", mainFunc); builder.SetInsertPoint(entry); 增添function內容

llvm study

·622 字·2 分鐘
Overview # llvm 示意圖 通過front end後程式碼會被轉為中間碼( LLVM Intermediate Representation (IR) ) 紅色部分為llvm提供的功能。 出作業應該不會用到1 (要自己寫),但可能會用到 2. IR interpreter (指令lli) 3. IR compiler (指令 llc)

git 基本指令

·387 字·1 分鐘
初始化 git init git config --global user.name "你的ID" git config --global user.email "你的信箱" 狀態 git status