`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 |
214 | 안녕하세요 | 컴퓨터 | 2016.11.12 | 205 |
213 | 안녕하세요. | 김태훈91 | 2013.06.15 | 1387 |
212 | 안녕하세요 [2] | 김동선1 | 2013.05.03 | 1849 |
211 | 다시 인사드리겠습니다. [1] | 동선 | 2011.03.27 | 2056 |
210 | Xen 4.3 RC test day | 최연기 | 2013.05.08 | 2252 |
209 | ㅋㅋㅋCCMM빌딩만 4번째 돌고 있습니다 | 동선 | 2011.04.09 | 2332 |
208 | 오늘 하루도 수고하셨습니다! [3] | 구사무엘 | 2011.04.02 | 2333 |
207 | 저도 다시 인사드립니다! | 구사무엘 | 2011.03.26 | 2349 |
206 | VMCS 정리 일부 입니다. | 최연기 | 2013.06.20 | 2366 |
205 | ^^ 오늘 즐거웠습니다~~ [1] | 동선 | 2011.04.09 | 2464 |
204 | 디버깅 n배 빠르게 하는 방법에 대한 글 | 동선 | 2011.04.16 | 2499 |
203 | intel manual | 조정욱 | 2012.04.28 | 2526 |
202 | 연락처 [1] | 황선욱 | 2011.04.09 | 2567 |
201 | [6/26 스터디 여론 조사] [4] | 박은병 | 2010.06.23 | 2605 |
200 | KVM 스터디 진행을 알고 싶어요 [2] | 김강수 | 2011.04.09 | 2652 |
199 | 금일은 개인 사정으로 참석 못할거 같습니다;;; | 김연희 | 2011.05.28 | 2717 |
198 | [그리스전 스터디~~] | 박은병 | 2010.06.11 | 2755 |
197 | 금주 토요일 스터디는 정상 진행 하는것이죠? 리플 달아주세요~ [4] | 김연희 | 2011.06.24 | 2779 |
196 | 차주 스터디 과제 [2] | 황선욱 | 2011.05.24 | 2909 |
.
결국 한번만 호출하고 loop 내에서 그 결과를 계속 사용해도 되는 함수등을 의미하는것 같습니다.
volatile memory 즉 하드웨어 레지스트를 읽는 함수 같은 경우에는 매번 그 값이 변경될수 있기에 매번 호출해야 되지만 그렇지 않고 특정 메모리 영역을 읽는 함수 같은 경우에 DMA 영역이 아니면 그 값은 저절로 바뀌는 일이 없기 때문에 1번만 호출하고 그 결과를 계속 사용해도 무방하다는 의미 인것 같네요.
결국 pure 타입의 함수에 대해 __attribute__ ((pure))를 붙이면 컴파일러가 최적화를 할때 이를 고려해서 좀 더 최적화하는데 용의하겠네요.