Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/absvti2.c
35260 views
//===-- absvti2.c - Implement __absvdi2 -----------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements __absvti2 for the compiler_rt library.9//10//===----------------------------------------------------------------------===//1112#include "int_lib.h"1314#ifdef CRT_HAS_128BIT1516// Returns: absolute value1718// Effects: aborts if abs(x) < 01920COMPILER_RT_ABI ti_int __absvti2(ti_int a) {21const int N = (int)(sizeof(ti_int) * CHAR_BIT);22if (a == (ti_int)((tu_int)1 << (N - 1)))23compilerrt_abort();24const ti_int s = a >> (N - 1);25return (a ^ s) - s;26}2728#endif // CRT_HAS_128BIT293031