1156cd587Sjoerg /* ===-- subvsi3.c - Implement __subvsi3 -----------------------------------=== 2156cd587Sjoerg * 3156cd587Sjoerg * The LLVM Compiler Infrastructure 4156cd587Sjoerg * 5156cd587Sjoerg * This file is dual licensed under the MIT and the University of Illinois Open 6156cd587Sjoerg * Source Licenses. See LICENSE.TXT for details. 7156cd587Sjoerg * 8156cd587Sjoerg * ===----------------------------------------------------------------------=== 9156cd587Sjoerg * 10156cd587Sjoerg * This file implements __subvsi3 for the compiler_rt library. 11156cd587Sjoerg * 12156cd587Sjoerg * ===----------------------------------------------------------------------=== 13156cd587Sjoerg */ 14156cd587Sjoerg 15156cd587Sjoerg #include "int_lib.h" 16156cd587Sjoerg 17156cd587Sjoerg /* Returns: a - b */ 18156cd587Sjoerg 19156cd587Sjoerg /* Effects: aborts if a - b overflows */ 20156cd587Sjoerg 21156cd587Sjoerg COMPILER_RT_ABI si_int __subvsi3(si_int a,si_int b)22156cd587Sjoerg__subvsi3(si_int a, si_int b) 23156cd587Sjoerg { 24*ef84fd3bSjoerg si_int s = (su_int) a - (su_int) b; 25156cd587Sjoerg if (b >= 0) 26156cd587Sjoerg { 27156cd587Sjoerg if (s > a) 28156cd587Sjoerg compilerrt_abort(); 29156cd587Sjoerg } 30156cd587Sjoerg else 31156cd587Sjoerg { 32156cd587Sjoerg if (s <= a) 33156cd587Sjoerg compilerrt_abort(); 34156cd587Sjoerg } 35156cd587Sjoerg return s; 36156cd587Sjoerg } 37