| Edward O'Callaghan | 37a6a45 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 1 | /*===-- negvti2.c - Implement __negvti2 -----------------------------------=== | 
 | 2 |  * | 
 | 3 |  *                     The LLVM Compiler Infrastructure | 
 | 4 |  * | 
 | 5 |  * This file is distributed under the University of Illinois Open Source | 
 | 6 |  * License. See LICENSE.TXT for details. | 
 | 7 |  * | 
 | 8 |  *===----------------------------------------------------------------------=== | 
 | 9 |  * | 
 | 10 |  *This file implements __negvti2 for the compiler_rt library. | 
 | 11 |  * | 
 | 12 |  *===----------------------------------------------------------------------=== | 
 | 13 |  */ | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 14 |  | 
 | 15 | #if __x86_64 | 
 | 16 |  | 
 | 17 | #include "int_lib.h" | 
 | 18 | #include <stdlib.h> | 
 | 19 |  | 
| Edward O'Callaghan | 37a6a45 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 20 | /* Returns: -a */ | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 21 |  | 
| Edward O'Callaghan | 37a6a45 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 22 | /* Effects: aborts if -a overflows */ | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 23 |  | 
 | 24 | ti_int | 
 | 25 | __negvti2(ti_int a) | 
 | 26 | { | 
 | 27 |     const ti_int MIN = (ti_int)1 << ((int)(sizeof(ti_int) * CHAR_BIT)-1); | 
 | 28 |     if (a == MIN) | 
| Daniel Dunbar | 48f46ac | 2010-03-31 17:00:45 +0000 | [diff] [blame^] | 29 |         compilerrt_abort(); | 
| Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 30 |     return -a; | 
 | 31 | } | 
 | 32 |  | 
 | 33 | #endif |