Add __clear_cache implementation in libtcc1

Add __clear_cache function for flushing caches to libtcc1.
This commit is contained in:
Thomas Preud'homme
2013-02-28 16:55:10 +01:00
parent b7d017dec8
commit fbb4841606
3 changed files with 36 additions and 2 deletions

View File

@@ -107,7 +107,7 @@ union float_long {
};
/* XXX: we don't support several builtin supports for now */
#ifndef __x86_64__
#if !defined(__x86_64__) && !defined(__arm__)
/* XXX: use gcc/tcc intrinsic ? */
#if defined(__i386__)
@@ -713,6 +713,28 @@ void __clear_cache(char *beginning, char *end)
{
}
#elif defined(__arm__)
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
void __clear_cache(char *beginning, char *end)
{
/* __ARM_NR_cacheflush is kernel private and should not be used in user space.
* However, there is no ARM asm parser in tcc so we use it for now */
#if 1
syscall(__ARM_NR_cacheflush);
#else
__asm__ ("push {r7}\n\t"
"mov r7, #0xf0002\n\t"
"mov r2, #0\n\t"
"swi 0\n\t"
"pop {r7}\n\t"
"ret");
#endif
}
#else
#warning __clear_cache not defined for this architecture, avoid using tcc -run
#endif