OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtin-prefetch-6.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
/* Test that __builtin_prefetch does no harm.
2
 
3
   Data prefetch should not fault if used with an invalid address.  */
4
 
5
#include <limits.h>
6
 
7
#define ARRSIZE 65
8
int *bad_addr[ARRSIZE];
9
int arr_used;
10
 
11
/* Fill bad_addr with a range of values in the hopes that on any target
12
   some will be invalid addresses.  */
13
void
14
init_addrs (void)
15
{
16
  int i;
17
  int bits_per_ptr = sizeof (void *) * 8;
18
  for (i = 0; i < bits_per_ptr; i++)
19
    bad_addr[i] = (void *)(1UL << i);
20
  arr_used = bits_per_ptr + 1;  /* The last element used is zero.  */
21
}
22
 
23
void
24
prefetch_for_read (void)
25
{
26
  int i;
27
  for (i = 0; i < ARRSIZE; i++)
28
    __builtin_prefetch (bad_addr[i], 0, 0);
29
}
30
 
31
void
32
prefetch_for_write (void)
33
{
34
  int i;
35
  for (i = 0; i < ARRSIZE; i++)
36
    __builtin_prefetch (bad_addr[i], 1, 0);
37
}
38
 
39
int
40
main ()
41
{
42
  init_addrs ();
43
  prefetch_for_read ();
44
  prefetch_for_write ();
45
  exit (0);
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.