diff --git a/.clang-format b/.clang-format index c1f4d5a..45866af 100644 --- a/.clang-format +++ b/.clang-format @@ -43,7 +43,7 @@ BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeColon BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true -ColumnLimit: 88 +ColumnLimit: 120 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 92beefa..53281e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ target_include_directories(logaddexp $ ) target_link_libraries(logaddexp INTERFACE $<$:m>) +target_compile_features(logaddexp INTERFACE c_std_11) install(TARGETS logaddexp EXPORT logaddexp-targets) install(DIRECTORY include/ DESTINATION include) diff --git a/include/logaddexp/logaddexp.h b/include/logaddexp/logaddexp.h index 7d2f725..b62e4eb 100644 --- a/include/logaddexp/logaddexp.h +++ b/include/logaddexp/logaddexp.h @@ -184,21 +184,12 @@ inline static double logaddexpss(double x, double y, double sx, double sy, doubl { return logaddexpgd(x, y, sx, sy, sign); } +#define logaddexp(x, y) _Generic(x, float : logaddexpf((x), (y)), double : logaddexpd((x), (y))) -#define logaddexp(a, b) \ - ((sizeof(a) == sizeof(float) && sizeof(b) == sizeof(float)) ? logaddexpf(a, b) \ - : logaddexpd(a, b)) - -#define logaddexps(x, y, sx, sy) \ - ((sizeof(x) == sizeof(float) && sizeof(y) == sizeof(float) && \ - sizeof(sx) == sizeof(float) && sizeof(sy) == sizeof(float)) \ - ? logaddexpsf(x, y, sx, sy) \ - : logaddexpsd(x, y, sx, sy)) - -#define logaddexpg(x, y, sx, sy, sign) \ - ((sizeof(x) == sizeof(float) && sizeof(y) == sizeof(float) && \ - sizeof(sx) == sizeof(float) && sizeof(sy) == sizeof(float)) \ - ? logaddexpgf(x, y, sx, sy, sign) \ - : logaddexpgd(x, y, sx, sy, sign)) +#define logaddexps(x, y, sx, sy) \ + _Generic(x, float : logaddexpsf((x), (y), (sx), (sy)), double : logaddexpsd((x), (y), (sx), (sy))) + +#define logaddexpg(x, y, sx, sy, sign) \ + _Generic(x, float : logaddexpgf((x), (y), (sx), (sy), (sign)), double : logaddexpgd((x), (y), (sx), (sy), (sign))) #endif diff --git a/test/logaddexp.c b/test/logaddexp.c index 08e494c..ef0a525 100644 --- a/test/logaddexp.c +++ b/test/logaddexp.c @@ -75,7 +75,7 @@ int test_logaddexp_nan(void) if (!isnan(logaddexp(NAN, 0))) return 1; - if (!isnan(logaddexp(0, NAN))) + if (!isnan(logaddexp(0., NAN))) return 1; if (!isnan(logaddexp(NAN, NAN)))