1 1.1 joerg //===-- bswapsi2_test.c - Test __bswapsi2 ---------------------------------===// 2 1.1 joerg // 3 1.1 joerg // The LLVM Compiler Infrastructure 4 1.1 joerg // 5 1.1 joerg // This file is dual licensed under the MIT and the University of Illinois Open 6 1.1 joerg // Source Licenses. See LICENSE.TXT for details. 7 1.1 joerg // 8 1.1 joerg //===----------------------------------------------------------------------===// 9 1.1 joerg // 10 1.1 joerg // This file tests __bswapsi2 for the compiler_rt library. 11 1.1 joerg // 12 1.1 joerg //===----------------------------------------------------------------------===// 13 1.1 joerg 14 1.1 joerg #include <stdlib.h> 15 1.1 joerg #include <stdint.h> 16 1.1 joerg #include <stdio.h> 17 1.1 joerg #include <math.h> 18 1.1 joerg 19 1.1 joerg 20 1.1 joerg extern uint32_t __bswapsi2(uint32_t); 21 1.1 joerg 22 1.1 joerg #if __arm__ 23 1.1 joerg int test__bswapsi2(uint32_t a, uint32_t expected) 24 1.1 joerg { 25 1.1 joerg uint32_t actual = __bswapsi2(a); 26 1.1 joerg if (actual != expected) 27 1.1 joerg printf("error in test__bswapsi2(0x%0X) = 0x%0X, expected 0x%0X\n", 28 1.1 joerg a, actual, expected); 29 1.1 joerg return actual != expected; 30 1.1 joerg } 31 1.1 joerg #endif 32 1.1 joerg 33 1.1 joerg int main() 34 1.1 joerg { 35 1.1 joerg #if __arm__ 36 1.1 joerg if (test__bswapsi2(0x12345678, 0x78563412)) 37 1.1 joerg return 1; 38 1.1 joerg if (test__bswapsi2(0x00000001, 0x01000000)) 39 1.1 joerg return 1; 40 1.1 joerg #else 41 1.1 joerg printf("skipped\n"); 42 1.1 joerg #endif 43 1.1 joerg return 0; 44 1.1 joerg } 45