1214152Sed/* ===-- subvdi3.c - Implement __subvdi3 -----------------------------------=== 2214152Sed * 3222656Sed * The LLVM Compiler Infrastructure 4214152Sed * 5222656Sed * This file is dual licensed under the MIT and the University of Illinois Open 6222656Sed * Source Licenses. See LICENSE.TXT for details. 7214152Sed * 8214152Sed * ===----------------------------------------------------------------------=== 9214152Sed * 10214152Sed * This file implements __subvdi3 for the compiler_rt library. 11214152Sed * 12214152Sed * ===----------------------------------------------------------------------=== 13214152Sed */ 14214152Sed 15214152Sed#include "int_lib.h" 16214152Sed 17214152Sed/* Returns: a - b */ 18214152Sed 19214152Sed/* Effects: aborts if a - b overflows */ 20214152Sed 21222656SedCOMPILER_RT_ABI di_int 22214152Sed__subvdi3(di_int a, di_int b) 23214152Sed{ 24214152Sed di_int s = a - b; 25214152Sed if (b >= 0) 26214152Sed { 27214152Sed if (s > a) 28214152Sed compilerrt_abort(); 29214152Sed } 30214152Sed else 31214152Sed { 32214152Sed if (s <= a) 33214152Sed compilerrt_abort(); 34214152Sed } 35214152Sed return s; 36214152Sed} 37