1214152Sed/* ===-- subvsi3.c - Implement __subvsi3 -----------------------------------=== 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 __subvsi3 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 si_int 22214152Sed__subvsi3(si_int a, si_int b) 23214152Sed{ 24214152Sed si_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