Update copyright notices with scripts/update-copyrights.
[jlayton/glibc.git] / sysdeps / powerpc / test-gettimebase.c
1 /* Check __ppc_get_timebase() for architecture changes
2    Copyright (C) 2012-2013 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 /* Test if __ppc_get_timebase() is compatible with the current processor and if
20    it's changing between reads.  A read failure might indicate a Power ISA or
21    binutils change.  */
22
23 #include <inttypes.h>
24 #include <stdio.h>
25
26 #include <sys/platform/ppc.h>
27
28 static int
29 do_test (void)
30 {
31   uint64_t t1, t2, t3;
32   t1 = __ppc_get_timebase ();
33   printf ("Time Base = %"PRIu64"\n", t1);
34   t2 = __ppc_get_timebase ();
35   printf ("Time Base = %"PRIu64"\n", t2);
36   t3 = __ppc_get_timebase ();
37   printf ("Time Base = %"PRIu64"\n", t3);
38   if (t1 != t2 && t1 != t3 && t2 != t3)
39     return 0;
40
41   printf ("Fail: timebase reads should always be different.");
42   return 1;
43 }
44
45 #define TEST_FUNCTION do_test ()
46 #include "../test-skeleton.c"