Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / toolchain / prefetch_test.c
1 /*
2  * Copyright (c) 2014 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /*
8  * This tests that the compiler handles __builtin_prefetch.
9  * All we're testing is that the compiler doesn't fall over
10  * and that it doesn't produce code that goes bad.  We don't
11  * try to test that it actually emits prefetch instructions.
12  * (As of 2014-6-18, arm-nacl-gcc and x86_64-nacl-gcc -m64 do
13  * but x86_64-nacl-gcc -m32 and all pnacl compilers do not.)
14  * This is a regression test for:
15  *      https://code.google.com/p/nativeclient/issues/detail?id=3582
16  */
17
18 static void DoPrefetch(char *p) {
19   __builtin_prefetch(p);
20   __builtin_prefetch(p + 17);
21 }
22
23 static char g_buf[32];
24
25 int main(void) {
26   char l_buf[32];
27
28   DoPrefetch(l_buf);  /* Stack case: shouldn't require sandboxing.  */
29   DoPrefetch(g_buf);  /* Heap case: should require sandboxing.  */
30
31   return 0;
32 }