1// UNSUPPORTED: armv6m-target-arch
2// RUN: %clang_builtins %s %librt -o %t && %run %t
3//===-- bswapdi2_test.c - Test __bswapdi2 ---------------------------------===//
4//
5// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6// See https://llvm.org/LICENSE.txt for license information.
7// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8//
9//===----------------------------------------------------------------------===//
10//
11// This file tests __bswapdi2 for the compiler_rt library.
12//
13//===----------------------------------------------------------------------===//
14
15#include <math.h>
16#include <stdint.h>
17#include <stdio.h>
18#include <stdlib.h>
19#include <inttypes.h>
20
21extern uint64_t __bswapdi2(uint64_t);
22
23int test__bswapdi2(uint64_t a, uint64_t expected) {
24  uint64_t actual = __bswapdi2(a);
25  if (actual != expected)
26    printf("error in test__bswapsi2(0x%" PRIx64 ") = 0x%" PRIx64 ", expected 0x%" PRIx64 "\n", a,
27           actual, expected);
28  return actual != expected;
29}
30
31int main() {
32  if (test__bswapdi2(0x123456789ABCDEF0LL, 0xF0DEBC9A78563412LL))
33    return 1;
34  if (test__bswapdi2(0x0000000100000002LL, 0x0200000001000000LL))
35    return 1;
36  return 0;
37}
38