160786Sps/*===-- negvti2.c - Implement __negvti2 -----------------------------------===
2221715Sdelphij *
360786Sps *                     The LLVM Compiler Infrastructure
460786Sps *
560786Sps * This file is dual licensed under the MIT and the University of Illinois Open
660786Sps * Source Licenses. See LICENSE.TXT for details.
760786Sps *
860786Sps *===----------------------------------------------------------------------===
960786Sps *
1060786Sps *This file implements __negvti2 for the compiler_rt library.
1160786Sps *
1260786Sps *===----------------------------------------------------------------------===
1360786Sps */
1460786Sps
1560786Sps#include "int_lib.h"
1660786Sps
1760786Sps#ifdef CRT_HAS_128BIT
1860786Sps
1960786Sps/* Returns: -a */
2060786Sps
2160786Sps/* Effects: aborts if -a overflows */
2260786Sps
2360786SpsCOMPILER_RT_ABI ti_int
2460786Sps__negvti2(ti_int a)
2560786Sps{
2660786Sps    const ti_int MIN = (ti_int)1 << ((int)(sizeof(ti_int) * CHAR_BIT)-1);
2760786Sps    if (a == MIN)
2860786Sps        compilerrt_abort();
2960786Sps    return -a;
3060786Sps}
3160786Sps
3260786Sps#endif /* CRT_HAS_128BIT */
3360786Sps