1 | /* Check __ppc_get_timebase() for architecture changes |
2 | Copyright (C) 2012-2022 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 | <https://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 | #include <stdint.h> |
26 | |
27 | #include <sys/platform/ppc.h> |
28 | |
29 | static int |
30 | do_test (void) |
31 | { |
32 | uint64_t t1, t2, t3; |
33 | t1 = __ppc_get_timebase (); |
34 | printf (format: "Time Base = %" PRIu64"\n" , t1); |
35 | t2 = __ppc_get_timebase (); |
36 | printf (format: "Time Base = %" PRIu64"\n" , t2); |
37 | t3 = __ppc_get_timebase (); |
38 | printf (format: "Time Base = %" PRIu64"\n" , t3); |
39 | if (t1 != t2 && t1 != t3 && t2 != t3) |
40 | return 0; |
41 | |
42 | printf (format: "Fail: timebase reads should always be different.\n" ); |
43 | return 1; |
44 | } |
45 | |
46 | #include <support/test-driver.c> |
47 | |