__devinit ??

atomaths의 이미지

static int __devinit eepro100_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 과 같이 함수의 리턴값 외에 __devinit 등 의 또다른 문자(?)들은 뭔가요? __devexit 도 있고, 그 외에 다른것도 보이던데...

flyduck의 이미지

리눅스 커널 헤더 파일을 쭈욱 쫒아가면 나옵니다. __devinit은 디바이스 드라이버 초기화 코드임을 나타낼 때 사용하는 것인데, include/linux/init.h 파일을 보면 :

#ifdef CONFIG_HOTPLUG
#define __devinit
#else
#define __devinit __init
#endif

__init은 다음과 같이 정의되어 있습니다.

#define __init __attribute__ ((__section__ (".init.text")))

__attribute__ 부터는 gcc extenion입니다. 함수 코드를 특정 section에 집어 넣는 directive입니다.

Freedom is another word for nothing left to lose,
Nothing doesn't mean nothing if it ain't free.