Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/absvdi2.c
35260 views
//===-- absvdi2.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 __absvdi2 for the compiler_rt library.9//10//===----------------------------------------------------------------------===//1112#include "int_lib.h"1314// Returns: absolute value1516// Effects: aborts if abs(x) < 01718COMPILER_RT_ABI di_int __absvdi2(di_int a) {19const int N = (int)(sizeof(di_int) * CHAR_BIT);20if (a == ((di_int)((du_int)1 << (N - 1))))21compilerrt_abort();22const di_int t = a >> (N - 1);23return (a ^ t) - t;24}252627