`pure'
Many functions have no effects except the return value and their
return value depends only on the parameters and/or global
variables. Such a function can be subject to common subexpression
elimination and loop optimization just as an arithmetic operator
would be. These functions should be declared with the attribute
`pure'. For example,
int square (int) __attribute__ ((pure));
says that the hypothetical function `square' is safe to call fewer
times than the program says.
Some of common examples of pure functions are `strlen' or `memcmp'.
Interesting non-pure functions are functions with infinite loops
or those depending on volatile memory or other system resource,
that may change between two consecutive calls (such as `feof' in a
multithreading environment).
The attribute `pure' is not implemented in GCC versions earlier
than 2.96.
Many functions have no effects except the return value and their
return value depends only on the parameters and/or global
variables. Such a function can be subject to common subexpression
elimination and loop optimization just as an arithmetic operator
would be. These functions should be declared with the attribute
`pure'. For example,
int square (int) __attribute__ ((pure));
says that the hypothetical function `square' is safe to call fewer
times than the program says.
Some of common examples of pure functions are `strlen' or `memcmp'.
Interesting non-pure functions are functions with infinite loops
or those depending on volatile memory or other system resource,
that may change between two consecutive calls (such as `feof' in a
multithreading environment).
The attribute `pure' is not implemented in GCC versions earlier
than 2.96.
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
공지 | [공지] 하이퍼바이져 스터디 관련 Q&A 게시판 입니다. | woos | 2016.04.09 | 237 |
215 | 게시판 생성 [4] | 백창우 | 2007.11.15 | 4707 |
214 | Xen 소스 및 문서자료 | 백창우 | 2007.11.15 | 6533 |
213 | Virtualization 자료 [2] | 백창우 | 2007.11.15 | 6825 |
212 | KVM 소스 및 문서자료 | 백창우 | 2007.11.15 | 8006 |
211 | 이건 정말 기막힌 응용이네요. [2] | 백창우 | 2007.11.22 | 5457 |
210 | Xen을 이용한 server 가상화 데모 [3] | 백창우 | 2007.12.09 | 7036 |
209 | Hypervisor 세미나는 언제부터 시작인가요? [2] | 정찬호 | 2007.12.12 | 4361 |
208 | 우리 만나기 전에 자기 소개에 대해서 잠깐 할까요? | 백창우 | 2007.12.13 | 5306 |
207 | 안녕하세요 정찬호라고 합니다. [2] | 정찬호 | 2007.12.14 | 5185 |
206 | 안녕하세요 [2] | 정성욱 | 2007.12.17 | 5055 |
205 | 안녕하세요 - 이일렬 입니다. | 이일렬 | 2007.12.18 | 5368 |
204 | 안녕하세요. 원민수입니다. | 원민수 | 2007.12.18 | 4886 |
203 | 안녕하세요. | 백정민 | 2007.12.18 | 4950 |
202 | Xen의 구성입니다. | 정성욱 | 2007.12.19 | 6310 |
201 | 안녕하세요 스터디 참가 문의드립니다. [2] | 김기오 | 2007.12.22 | 4805 |
200 | 안녕하세요 제 소개를 올립니다. | 김기오 | 2007.12.24 | 4818 |
199 | 안녕하세요 장동일입니다. | 장동일 | 2007.12.25 | 5299 |
198 | Xen관련된 참고 논문입니다.(1) | 정성욱 | 2007.12.26 | 5539 |
197 | Xen관련된 참고 논문입니다.(2) | 정성욱 | 2007.12.26 | 5188 |
196 | 추천 책 [2] | 정성욱 | 2007.12.26 | 6639 |
.
결국 한번만 호출하고 loop 내에서 그 결과를 계속 사용해도 되는 함수등을 의미하는것 같습니다.
volatile memory 즉 하드웨어 레지스트를 읽는 함수 같은 경우에는 매번 그 값이 변경될수 있기에 매번 호출해야 되지만 그렇지 않고 특정 메모리 영역을 읽는 함수 같은 경우에 DMA 영역이 아니면 그 값은 저절로 바뀌는 일이 없기 때문에 1번만 호출하고 그 결과를 계속 사용해도 무방하다는 의미 인것 같네요.
결국 pure 타입의 함수에 대해 __attribute__ ((pure))를 붙이면 컴파일러가 최적화를 할때 이를 고려해서 좀 더 최적화하는데 용의하겠네요.