xref: /src/contrib/llvm-project/llvm/lib/Support/MathExtras.cpp (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
167c32a98SDimitry Andric //===-- MathExtras.cpp - Implement the MathExtras header --------------===//
267c32a98SDimitry Andric //
3e6d15924SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e6d15924SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e6d15924SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
667c32a98SDimitry Andric //
767c32a98SDimitry Andric //===----------------------------------------------------------------------===//
867c32a98SDimitry Andric //
967c32a98SDimitry Andric // This file implements the MathExtras.h header
1067c32a98SDimitry Andric //
1167c32a98SDimitry Andric //===----------------------------------------------------------------------===//
1267c32a98SDimitry Andric 
1367c32a98SDimitry Andric #include "llvm/Support/MathExtras.h"
1467c32a98SDimitry Andric 
1567c32a98SDimitry Andric #ifdef _MSC_VER
1667c32a98SDimitry Andric #include <limits>
1767c32a98SDimitry Andric #else
18145449b1SDimitry Andric #include <cmath>
1967c32a98SDimitry Andric #endif
2067c32a98SDimitry Andric 
2167c32a98SDimitry Andric namespace llvm {
2267c32a98SDimitry Andric 
2367c32a98SDimitry Andric #if defined(_MSC_VER)
2467c32a98SDimitry Andric   // Visual Studio defines the HUGE_VAL class of macros using purposeful
2567c32a98SDimitry Andric   // constant arithmetic overflow, which it then warns on when encountered.
2667c32a98SDimitry Andric   const float huge_valf = std::numeric_limits<float>::infinity();
2767c32a98SDimitry Andric #else
2867c32a98SDimitry Andric   const float huge_valf = HUGE_VALF;
2967c32a98SDimitry Andric #endif
3067c32a98SDimitry Andric 
31344a3780SDimitry Andric } // namespace llvm
32