blob: df44935f1a78778cba2fec4fbdcaf129008f8b03 [file] [log] [blame]
Edward O'Callaghan55836322009-08-07 20:30:09 +00001/*===-- 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 Dunbarfd089992009-06-26 16:47:03 +000014
15#if __x86_64
16
17#include "int_lib.h"
18#include <stdlib.h>
19
Edward O'Callaghan55836322009-08-07 20:30:09 +000020/* Returns: -a */
Daniel Dunbarfd089992009-06-26 16:47:03 +000021
Edward O'Callaghan55836322009-08-07 20:30:09 +000022/* Effects: aborts if -a overflows */
Daniel Dunbarfd089992009-06-26 16:47:03 +000023
24ti_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)
29 abort();
30 return -a;
31}
32
33#endif