Mar 19, 2008

設定暫存器位置的語法

暫存器的Addrewss Uint如果是....

Word:
#define Word_Reg     (*(volatile unsigned long *)0x12345678)

Half-Word:
#define HW_Reg       (*(volatile unsigned int *)0x876543219)

Char:
#define C_Reg           (*(volatile unsigned char *)0xabcd1234)

Mar 17, 2008

gcc, 用於debug的macro...極好用

#ifdef DEBUG_STRING
#define DPRINTSTR(args...)        printf(##args)
#else
#define DPRINTSTR(args...)
#endif


C99之後開始支援不定變數巨集

Gea-Suan Lin's
一些 C Macro 的技巧 (Part I:不定變數)

一些 C Macro 的技巧 (Part II:將傳入的參數變成字串)

一些 C Macro 的技巧 (Part III:將傳入的參數名稱變化)

Silly Dust
Variadic macro

Mar 16, 2008

台灣怎麼能對西藏問題置身事外

二戰後在德國納粹荼毒下倖存的牧師Mantion Niemoller說:
起初,他們捉共產黨員,我不說話,因為我不是共產黨員;

後來,他們捉工會會員,我不說話,因為我沒有參加工會;

後來,他們捉猶太人,  我不說話,因為我是日耳曼人;

後來,他們捉天主教徒,我還是不說話,因為我是新教徒;

最後,等到他們來捉我時,已經沒有人能為我說話了..

Mar 14, 2008

bin/bash^M: bad interpreter: no such file or directory

通常會遇到這個問題的原因通常是

被執行的script檔案是從windows用ftp上傳,或是在windows複製 linux貼上

換行方式不一樣,導致這個錯誤

Windows裡換行是CR+LF,Linux裡只有LF    (CR = \r,LF = \n ..... in ascii code)

只要把windows裡使用的\r換行符號清除掉就可以了

Mar 11, 2008

Firefox 3.0 b5

哇~  真的很快~  狂電IE7

beta5 又比 beta3 快了50%左右      (而且是用portable版本做的測試)

應該是PGO的緣故
about PGO :

Profile-guided Optimizations Overview

Firefox 3 with Profile-Guided Optimization = Speeding ticket

Building with Profile-Guided Optimization

memory leak的問題應該是解決了  (addon : leak monitor)

fxPortable3b5下載

Mar 10, 2008

快畢業了

唉..................

幹~  關我屁事啊    別多管閒事了

Mar 1, 2008

ubuntu 7.10 gusty 安裝 dhcp-server

網路環境


eth0 : 對外網卡使用固定ip

eth1 : 對內網卡使用class c ip : 192.168.1.1

安裝dhcp server


# aptitude install dhcp-server

修改interfaces設定


# vim /etc/network/interfaces
auto lo
iface lo inet loopback


auto eth0
iface eth0 inet static
address 140.118.x.x
netmask 255.255.255.0
gateway 140.118.202.254


auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0

重開網路


# /etc/init.d/networking restart

修改 dhcpd 設定


# vim /etc/dhcp3/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 140.118.2.53;
option ip-forwarding off;
range dynamic-bootp 192.168.1.100 192.168.1.200;
default-lease-time 21600;
max-lease-time 43200;
}

重開dhcpd


# /etc/init.d/dhcp3-server restart

到這一步,區域網路內的電腦已經可以抓到ip了(範圍是192.168.1.100 ~ 192.168.1.200)

設定NAT


滿麻煩的,乾脆用firestarter

# aptitude install firestarter

打開之後把外部網路設定成eth0, 外部設定成eth1

把網路分享打開,設定檔照著上面填,讓firestarter把原本的設定覆蓋過去

應該就可以了