]>
Commit | Line | Data |
---|---|---|
688903eb | 1 | /* Copyright (C) 2000-2018 Free Software Foundation, Inc. |
fc1fb585 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Ulrich Drepper <drepper@cygnus.com>. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
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. | |
fc1fb585 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
fc1fb585 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
fc1fb585 UD |
18 | |
19 | #include <byteswap.h> | |
20 | #include <stdio.h> | |
21 | ||
22 | extern unsigned long long int wash (unsigned long long int a); | |
23 | ||
fb82116f | 24 | int |
29955b5d | 25 | do_test (void) |
fc1fb585 UD |
26 | { |
27 | int result = 0; | |
28 | ||
29 | /* Test the functions with constant arguments. */ | |
30 | if (bswap_16 (0x1234) != 0x3412) | |
31 | { | |
32 | puts ("bswap_16 (constant) flunked"); | |
33 | result = 1; | |
34 | } | |
35 | if (bswap_32 (0x12345678) != 0x78563412) | |
36 | { | |
37 | puts ("bswap_32 (constant) flunked"); | |
38 | result = 1; | |
39 | } | |
40 | if (bswap_64 (0x1234567890abcdefULL) != 0xefcdab9078563412ULL) | |
41 | { | |
42 | puts ("bswap_64 (constant) flunked"); | |
43 | result = 1; | |
44 | } | |
45 | ||
46 | /* Test the functions with non-constant arguments. */ | |
47 | if (bswap_16 (wash (0x1234)) != 0x3412) | |
48 | { | |
49 | puts ("bswap_16 (non-constant) flunked"); | |
50 | result = 1; | |
51 | } | |
52 | if (bswap_32 (wash (0x12345678)) != 0x78563412) | |
53 | { | |
54 | puts ("bswap_32 (non-constant) flunked"); | |
55 | result = 1; | |
56 | } | |
57 | if (bswap_64 (wash (0x1234567890abcdefULL)) != 0xefcdab9078563412ULL) | |
58 | { | |
59 | puts ("bswap_64 (non-constant) flunked"); | |
60 | result = 1; | |
61 | } | |
62 | ||
63 | return result; | |
64 | } | |
65 | ||
66 | ||
67 | unsigned long long int | |
68 | wash (unsigned long long int a) | |
69 | { | |
70 | /* Do nothing. This function simply exists to avoid that the compiler | |
71 | regards the argument to the bswap_*() functions as constant. */ | |
72 | return a + 0; | |
73 | } | |
29955b5d | 74 | |
fb82116f | 75 | #include <support/test-driver.c> |