Skip to content

Commit

Permalink
Reenable support for long double
Browse files Browse the repository at this point in the history
  • Loading branch information
joanaxcruz authored and blapie committed Jun 5, 2024
1 parent 906604d commit 904bfa4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/common/misc.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Naoki Shibata and contributors 2010 - 2023.
// Copyright Naoki Shibata and contributors 2010 - 2024.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -158,6 +158,10 @@
#define stringify(s) stringify_(s)
#define stringify_(s) #s

#if !defined(SLEEF_GENHEADER)
typedef long double longdouble;
#endif

#if !defined(Sleef_double2_DEFINED) && !defined(SLEEF_GENHEADER)
#define Sleef_double2_DEFINED
typedef struct {
Expand All @@ -172,7 +176,12 @@ typedef struct {
} Sleef_float2;
#endif

//
#if !defined(Sleef_longdouble2_DEFINED) && !defined(SLEEF_GENHEADER)
#define Sleef_longdouble2_DEFINED
typedef struct {
long double x, y;
} Sleef_longdouble2;
#endif

#if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER)

Expand Down
6 changes: 5 additions & 1 deletion src/libm-tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,11 @@ endif()

if(LIB_MPFR AND NOT MINGW)
# Build tester2 scalar
foreach(P dp sp)
set(PRECISIONS dp sp)
if(COMPILER_SUPPORTS_LONG_DOUBLE)
list(APPEND PRECISIONS ld)
endif()
foreach(P ${PRECISIONS})
set(T "tester2${P}")
add_executable(${T} tester2${P}.c testerutil.c)
target_compile_definitions(${T} PRIVATE USEMPFR=1 ${COMMON_TARGET_DEFINITIONS})
Expand Down
3 changes: 2 additions & 1 deletion src/libm-tester/tester2ld.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#endif

#include "sleef.h"
#include "testerutil.h"

#define DORENAME
#include "rename.h"
Expand All @@ -41,7 +42,7 @@
#define POSITIVE_INFINITY INFINITY
#define NEGATIVE_INFINITY (-INFINITY)

int isnumberl(long double x) { return x != INFINITYl && x != -INFINITYl && x == x; }
int isnumberl(long double x) { return x != SLEEF_INFINITYl && x != -SLEEF_INFINITYl && x == x; }
int isPlusZerol(long double x) { return x == 0 && copysignl(1, x) == 1; }
int isMinusZerol(long double x) { return x == 0 && copysignl(1, x) == -1; }

Expand Down
4 changes: 4 additions & 0 deletions src/libm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ endif()

# Original sleef sources
set(STANDARD_SOURCES rempitab.c)
# Check for different precision support and add sources accordingly
if(COMPILER_SUPPORTS_LONG_DOUBLE)
list(APPEND STANDARD_SOURCES sleefld.c)
endif()

add_library(${TARGET_LIBSLEEF} ${STANDARD_SOURCES})
add_dependencies(${TARGET_LIBSLEEF} ${TARGET_HEADERS})
Expand Down
12 changes: 11 additions & 1 deletion src/libm/sleeflibm_header.h.org.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Naoki Shibata and contributors 2010 - 2023.
// Copyright Naoki Shibata and contributors 2010 - 2024.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -157,6 +157,13 @@ typedef struct {
} Sleef_float2;
#endif

#ifndef Sleef_longdouble2_DEFINED
#define Sleef_longdouble2_DEFINED
typedef struct {
long double x, y;
} Sleef_longdouble2;
#endif

#ifdef __cplusplus
extern "C"
{
Expand Down Expand Up @@ -316,3 +323,6 @@ SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_lgammaf_u10(float)
SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_tgammaf_u10(float);
SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_erff_u10(float);
SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_erfcf_u15(float);

SLEEF_IMPORT SLEEF_CONST Sleef_longdouble2 Sleef_sincospil_u05(long double);
SLEEF_IMPORT SLEEF_CONST Sleef_longdouble2 Sleef_sincospil_u35(long double);

0 comments on commit 904bfa4

Please sign in to comment.