]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/compiler-rt/lib/clear_cache.c
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / compiler-rt / lib / clear_cache.c
1 /* ===-- clear_cache.c - Implement __clear_cache ---------------------------===
2  *
3  *                     The LLVM Compiler Infrastructure
4  *
5  * This file is dual licensed under the MIT and the University of Illinois Open
6  * Source Licenses. See LICENSE.TXT for details.
7  *
8  * ===----------------------------------------------------------------------===
9  */
10
11 #include "int_lib.h"
12 #include <stdlib.h>
13
14 #if __APPLE__
15   #include <libkern/OSCacheControl.h>
16 #endif
17
18 /*
19  * The compiler generates calls to __clear_cache() when creating 
20  * trampoline functions on the stack for use with nested functions.
21  * It is expected to invalidate the instruction cache for the 
22  * specified range.
23  */
24
25 void __clear_cache(void* start, void* end)
26 {
27 #if __i386__ || __x86_64__
28 /*
29  * Intel processors have a unified instruction and data cache
30  * so there is nothing to do
31  */
32 #else
33     #if __APPLE__
34         /* On Darwin, sys_icache_invalidate() provides this functionality */
35         sys_icache_invalidate(start, end-start);
36     #else
37         compilerrt_abort();
38     #endif
39 #endif
40 }
41