1# 2# This file and its contents are supplied under the terms of the 3# Common Development and Distribution License ("CDDL"), version 1.0. 4# You may only use this file in accordance with the terms of version 5# 1.0 of the CDDL. 6# 7# A full copy of the text of the CDDL should have accompanied this 8# source. A copy of the CDDL is also available via the Internet at 9# http://www.illumos.org/license/CDDL. 10# 11 12# 13# Copyright 2026 Gordon W. Ross 14# 15 16# 17# Design notes for <cmath> test cases 18# 19# <cmath> must provide all math functions in the "std::" namespace. The 20# global "::" namespace gets only the double form of those functions. 21# Reference: https://en.cppreference.com/cpp/header/cmath 22# 23# C90 functions available in std:: since C++98. 24# C99 functions (acosh, exp2, log2, round, trunc, hypot, fma, etc.) 25# required in std:: since C++11. 26# 27 28# 29# Types - must be in std:: since C++11 30# 31type | std::float_t | cmath | CXX11+ 32type | std::double_t | cmath | CXX11+ 33 34# 35# C90 double functions - must be in std:: since C++98 36# 37func | std::acos | double | double | cmath | CXX98+ 38func | std::asin | double | double | cmath | CXX98+ 39func | std::atan | double | double | cmath | CXX98+ 40func | std::atan2 | double | double; double | cmath | CXX98+ 41func | std::ceil | double | double | cmath | CXX98+ 42func | std::cos | double | double | cmath | CXX98+ 43func | std::cosh | double | double | cmath | CXX98+ 44func | std::exp | double | double | cmath | CXX98+ 45func | std::fabs | double | double | cmath | CXX98+ 46func | std::floor | double | double | cmath | CXX98+ 47func | std::fmod | double | double; double | cmath | CXX98+ 48func | std::frexp | double | double; int * | cmath | CXX98+ 49func | std::ldexp | double | double; int | cmath | CXX98+ 50func | std::log | double | double | cmath | CXX98+ 51func | std::log10 | double | double | cmath | CXX98+ 52func | std::modf | double | double; double * | cmath | CXX98+ 53func | std::pow | double | double; double | cmath | CXX98+ 54func | std::sin | double | double | cmath | CXX98+ 55func | std::sinh | double | double | cmath | CXX98+ 56func | std::sqrt | double | double | cmath | CXX98+ 57func | std::tan | double | double | cmath | CXX98+ 58func | std::tanh | double | double | cmath | CXX98+ 59func | std::abs | double | double | cmath | CXX98+ 60 61# 62# C90 float named overloads - must be in std:: since C++98 63# 64func | std::acosf | float | float | cmath | CXX98+ 65func | std::asinf | float | float | cmath | CXX98+ 66func | std::atanf | float | float | cmath | CXX98+ 67func | std::atan2f | float | float; float | cmath | CXX98+ 68func | std::ceilf | float | float | cmath | CXX98+ 69func | std::cosf | float | float | cmath | CXX98+ 70func | std::coshf | float | float | cmath | CXX98+ 71func | std::expf | float | float | cmath | CXX98+ 72func | std::fabsf | float | float | cmath | CXX98+ 73func | std::floorf | float | float | cmath | CXX98+ 74func | std::fmodf | float | float; float | cmath | CXX98+ 75func | std::frexpf | float | float; int * | cmath | CXX98+ 76func | std::ldexpf | float | float; int | cmath | CXX98+ 77func | std::logf | float | float | cmath | CXX98+ 78func | std::log10f | float | float | cmath | CXX98+ 79func | std::modff | float | float; float * | cmath | CXX98+ 80func | std::powf | float | float; float | cmath | CXX98+ 81func | std::sinf | float | float | cmath | CXX98+ 82func | std::sinhf | float | float | cmath | CXX98+ 83func | std::sqrtf | float | float | cmath | CXX98+ 84func | std::tanf | float | float | cmath | CXX98+ 85func | std::tanhf | float | float | cmath | CXX98+ 86 87# 88# C90 long double named overloads - must be in std:: since C++98 89# 90func | std::acosl | long double | long double | cmath | CXX98+ 91func | std::asinl | long double | long double | cmath | CXX98+ 92func | std::atanl | long double | long double | cmath | CXX98+ 93func | std::atan2l | long double |\ 94 long double; long double |\ 95 cmath | CXX98+ 96func | std::ceill | long double | long double | cmath | CXX98+ 97func | std::cosl | long double | long double | cmath | CXX98+ 98func | std::coshl | long double | long double | cmath | CXX98+ 99func | std::expl | long double | long double | cmath | CXX98+ 100func | std::fabsl | long double | long double | cmath | CXX98+ 101func | std::floorl | long double | long double | cmath | CXX98+ 102func | std::fmodl | long double |\ 103 long double; long double |\ 104 cmath | CXX98+ 105func | std::frexpl | long double | long double; int * | cmath | CXX98+ 106func | std::ldexpl | long double | long double; int | cmath | CXX98+ 107func | std::logl | long double | long double | cmath | CXX98+ 108func | std::log10l | long double | long double | cmath | CXX98+ 109func | std::modfl | long double |\ 110 long double; long double * |\ 111 cmath | CXX98+ 112func | std::powl | long double |\ 113 long double; long double |\ 114 cmath | CXX98+ 115func | std::sinl | long double | long double | cmath | CXX98+ 116func | std::sinhl | long double | long double | cmath | CXX98+ 117func | std::sqrtl | long double | long double | cmath | CXX98+ 118func | std::tanl | long double | long double | cmath | CXX98+ 119func | std::tanhl | long double | long double | cmath | CXX98+ 120 121# 122# C90 float functions - must be in std:: since C++98 123# 124func | std::acos | float | float | cmath | CXX98+ 125func | std::asin | float | float | cmath | CXX98+ 126func | std::atan | float | float | cmath | CXX98+ 127func | std::atan2 | float | float; float | cmath | CXX98+ 128func | std::ceil | float | float | cmath | CXX98+ 129func | std::cos | float | float | cmath | CXX98+ 130func | std::cosh | float | float | cmath | CXX98+ 131func | std::exp | float | float | cmath | CXX98+ 132func | std::fabs | float | float | cmath | CXX98+ 133func | std::floor | float | float | cmath | CXX98+ 134func | std::fmod | float | float; float | cmath | CXX98+ 135func | std::frexp | float | float; int * | cmath | CXX98+ 136func | std::ldexp | float | float; int | cmath | CXX98+ 137func | std::log | float | float | cmath | CXX98+ 138func | std::log10 | float | float | cmath | CXX98+ 139func | std::modf | float | float; float * | cmath | CXX98+ 140func | std::pow | float | float; float | cmath | CXX98+ 141func | std::sin | float | float | cmath | CXX98+ 142func | std::sinh | float | float | cmath | CXX98+ 143func | std::sqrt | float | float | cmath | CXX98+ 144func | std::tan | float | float | cmath | CXX98+ 145func | std::tanh | float | float | cmath | CXX98+ 146 147# 148# C90 long double functions - must be in std:: since C++98 149# 150func | std::acos | long double | long double | cmath | CXX98+ 151func | std::asin | long double | long double | cmath | CXX98+ 152func | std::atan | long double | long double | cmath | CXX98+ 153func | std::atan2 | long double |\ 154 long double; long double |\ 155 cmath | CXX98+ 156func | std::ceil | long double | long double | cmath | CXX98+ 157func | std::cos | long double | long double | cmath | CXX98+ 158func | std::cosh | long double | long double | cmath | CXX98+ 159func | std::exp | long double | long double | cmath | CXX98+ 160func | std::fabs | long double | long double | cmath | CXX98+ 161func | std::floor | long double | long double | cmath | CXX98+ 162func | std::fmod | long double |\ 163 long double; long double |\ 164 cmath | CXX98+ 165func | std::frexp | long double | long double; int * | cmath | CXX98+ 166func | std::ldexp | long double | long double; int | cmath | CXX98+ 167func | std::log | long double | long double | cmath | CXX98+ 168func | std::log10 | long double | long double | cmath | CXX98+ 169func | std::modf | long double |\ 170 long double; long double * |\ 171 cmath | CXX98+ 172func | std::pow | long double |\ 173 long double; long double |\ 174 cmath | CXX98+ 175func | std::sin | long double | long double | cmath | CXX98+ 176func | std::sinh | long double | long double | cmath | CXX98+ 177func | std::sqrt | long double | long double | cmath | CXX98+ 178func | std::tan | long double | long double | cmath | CXX98+ 179func | std::tanh | long double | long double | cmath | CXX98+ 180 181# 182# C99 double functions - available in std:: since C++11. 183# On illumos, <cmath> also exposes these in C++98 via CXX_C99+ 184# (using -D_STDC_C99), but we test for what the standard requires. 185# 186func | std::acosh | double | double | cmath | CXX11+ 187func | std::asinh | double | double | cmath | CXX11+ 188func | std::atanh | double | double | cmath | CXX11+ 189func | std::cbrt | double | double | cmath | CXX11+ 190func | std::exp2 | double | double | cmath | CXX11+ 191func | std::expm1 | double | double | cmath | CXX11+ 192func | std::log1p | double | double | cmath | CXX11+ 193func | std::log2 | double | double | cmath | CXX11+ 194func | std::logb | double | double | cmath | CXX11+ 195func | std::scalbn | double | double; int | cmath | CXX11+ 196func | std::scalbln | double | double; long int | cmath | CXX11+ 197func | std::ilogb | int | double | cmath | CXX11+ 198func | std::hypot | double | double; double | cmath | CXX11+ 199func | std::fma | double | double; double; double | cmath | CXX11+ 200func | std::fmax | double | double; double | cmath | CXX11+ 201func | std::fmin | double | double; double | cmath | CXX11+ 202func | std::fdim | double | double; double | cmath | CXX11+ 203func | std::nearbyint | double | double | cmath | CXX11+ 204func | std::rint | double | double | cmath | CXX11+ 205func | std::lrint | long int | double | cmath | CXX11+ 206func | std::llrint | long long | double | cmath | CXX11+ 207func | std::round | double | double | cmath | CXX11+ 208func | std::lround | long int | double | cmath | CXX11+ 209func | std::llround | long long | double | cmath | CXX11+ 210func | std::trunc | double | double | cmath | CXX11+ 211func | std::remainder | double | double; double | cmath | CXX11+ 212func | std::remquo | double | double; double; int * | cmath | CXX11+ 213func | std::copysign | double | double; double | cmath | CXX11+ 214func | std::nan | double | const char * | cmath | CXX11+ 215func | std::nextafter | double | double; double | cmath | CXX11+ 216func | std::nexttoward | double | double; long double | cmath | CXX11+ 217func | std::erf | double | double | cmath | CXX11+ 218func | std::erfc | double | double | cmath | CXX11+ 219func | std::lgamma | double | double | cmath | CXX11+ 220func | std::tgamma | double | double | cmath | CXX11+ 221 222# 223# C99 float named overloads - available in std:: since C++11 224# (also available in C++98 via CXX_C99+ on illumos) 225# 226func | std::acoshf | float | float | cmath | CXX11+ 227func | std::asinhf | float | float | cmath | CXX11+ 228func | std::atanhf | float | float | cmath | CXX11+ 229func | std::cbrtf | float | float | cmath | CXX11+ 230func | std::exp2f | float | float | cmath | CXX11+ 231func | std::expm1f | float | float | cmath | CXX11+ 232func | std::log1pf | float | float | cmath | CXX11+ 233func | std::log2f | float | float | cmath | CXX11+ 234func | std::logbf | float | float | cmath | CXX11+ 235func | std::scalbnf | float | float; int | cmath | CXX11+ 236func | std::scalblnf | float | float; long int | cmath | CXX11+ 237func | std::ilogbf | int | float | cmath | CXX11+ 238func | std::hypotf | float | float; float | cmath | CXX11+ 239func | std::fmaf | float | float; float; float | cmath | CXX11+ 240func | std::fmaxf | float | float; float | cmath | CXX11+ 241func | std::fminf | float | float; float | cmath | CXX11+ 242func | std::fdimf | float | float; float | cmath | CXX11+ 243func | std::nearbyintf | float | float | cmath | CXX11+ 244func | std::rintf | float | float | cmath | CXX11+ 245func | std::lrintf | long int | float | cmath | CXX11+ 246func | std::llrintf | long long | float | cmath | CXX11+ 247func | std::roundf | float | float | cmath | CXX11+ 248func | std::lroundf | long int | float | cmath | CXX11+ 249func | std::llroundf | long long | float | cmath | CXX11+ 250func | std::truncf | float | float | cmath | CXX11+ 251func | std::remainderf | float | float; float | cmath | CXX11+ 252func | std::remquof | float | float; float; int * | cmath | CXX11+ 253func | std::copysignf | float | float; float | cmath | CXX11+ 254func | std::nanf | float | const char * | cmath | CXX11+ 255func | std::nextafterf | float | float; float | cmath | CXX11+ 256func | std::nexttowardf | float | float; long double | cmath | CXX11+ 257func | std::erff | float | float | cmath | CXX11+ 258func | std::erfcf | float | float | cmath | CXX11+ 259func | std::lgammaf | float | float | cmath | CXX11+ 260func | std::tgammaf | float | float | cmath | CXX11+ 261 262# 263# C99 long double named overloads - available in std:: since C++11 264# (also available in C++98 via CXX_C99+ on illumos) 265# 266func | std::acoshl | long double | long double | cmath | CXX11+ 267func | std::asinhl | long double | long double | cmath | CXX11+ 268func | std::atanhl | long double | long double | cmath | CXX11+ 269func | std::cbrtl | long double | long double | cmath | CXX11+ 270func | std::exp2l | long double | long double | cmath | CXX11+ 271func | std::expm1l | long double | long double | cmath | CXX11+ 272func | std::log1pl | long double | long double | cmath | CXX11+ 273func | std::log2l | long double | long double | cmath | CXX11+ 274func | std::logbl | long double | long double | cmath | CXX11+ 275func | std::scalbnl | long double | long double; int | cmath | CXX11+ 276func | std::scalblnl | long double | long double; long int | cmath | CXX11+ 277func | std::ilogbl | int | long double | cmath | CXX11+ 278func | std::hypotl | long double |\ 279 long double; long double |\ 280 cmath | CXX11+ 281func | std::fmal | long double |\ 282 long double; long double; long double |\ 283 cmath | CXX11+ 284func | std::fmaxl | long double |\ 285 long double; long double |\ 286 cmath | CXX11+ 287func | std::fminl | long double |\ 288 long double; long double |\ 289 cmath | CXX11+ 290func | std::fdiml | long double |\ 291 long double; long double |\ 292 cmath | CXX11+ 293func | std::nearbyintl | long double | long double | cmath | CXX11+ 294func | std::rintl | long double | long double | cmath | CXX11+ 295func | std::lrintl | long int | long double | cmath | CXX11+ 296func | std::llrintl | long long | long double | cmath | CXX11+ 297func | std::roundl | long double | long double | cmath | CXX11+ 298func | std::lroundl | long int | long double | cmath | CXX11+ 299func | std::llroundl | long long | long double | cmath | CXX11+ 300func | std::truncl | long double | long double | cmath | CXX11+ 301func | std::remainderl | long double |\ 302 long double; long double |\ 303 cmath | CXX11+ 304func | std::remquol | long double |\ 305 long double; long double; int * |\ 306 cmath | CXX11+ 307func | std::copysignl | long double |\ 308 long double; long double |\ 309 cmath | CXX11+ 310func | std::nanl | long double | const char * | cmath | CXX11+ 311func | std::nextafterl | long double |\ 312 long double; long double |\ 313 cmath | CXX11+ 314func | std::nexttowardl | long double |\ 315 long double; long double |\ 316 cmath | CXX11+ 317func | std::erfl | long double | long double | cmath | CXX11+ 318func | std::erfcl | long double | long double | cmath | CXX11+ 319func | std::lgammal | long double | long double | cmath | CXX11+ 320func | std::tgammal | long double | long double | cmath | CXX11+ 321 322# 323# Regression test for 15209: log(int) must not be ambiguous. Before 324# 15209, math_iso.h pulled logf/logl into :: via using-declarations, 325# making log(int) ambiguous between float and double overloads. 326# Integer arguments must resolve to the double overload unambiguously. 327# This section also adds test cases representing problems seen when 328# building third-party packages via pkgsrc.org including failures 329# due to ambiguity with abs() in cstdlib. 330# 331func | log | double | int | cmath | CXX98+ 332func | log | double | long int | cmath | CXX98+ 333func | log | double | unsigned long | cmath | CXX98+ 334func | log10 | double | int | cmath | CXX98+ 335func | fabs | double | int | cmath | CXX98+ 336func | floor | double | int | cmath | CXX98+ 337func | sqrt | double | int | cmath | CXX98+ 338func | sqrt | double | long int | cmath | CXX98+ 339func | sqrt | double | unsigned int | cmath | CXX98+ 340func | sqrt | double | unsigned long | cmath | CXX98+ 341func | pow | double | int; int | cmath | CXX98+ 342func | pow | double | double; long double | cmath | CXX98+ 343func | atan2 | double | int; int | cmath | CXX98+ 344func | abs | double | double | cmath | CXX11+ 345func | abs | int | int | cmath | CXX11+ 346func | abs | long | long int | cmath | CXX11+ 347 348# 349# C++11 classification functions - must be in std:: since C++11 350# 351func | std::fpclassify | int | double | cmath | CXX11+ 352func | std::fpclassify | int | float | cmath | CXX11+ 353func | std::fpclassify | int | long double | cmath | CXX11+ 354func | std::isfinite | bool | double | cmath | CXX11+ 355func | std::isfinite | bool | float | cmath | CXX11+ 356func | std::isfinite | bool | long double | cmath | CXX11+ 357func | std::isinf | bool | double | cmath | CXX11+ 358func | std::isinf | bool | float | cmath | CXX11+ 359func | std::isinf | bool | long double | cmath | CXX11+ 360func | std::isnan | bool | double | cmath | CXX11+ 361func | std::isnan | bool | float | cmath | CXX11+ 362func | std::isnan | bool | long double | cmath | CXX11+ 363func | std::isnormal | bool | double | cmath | CXX11+ 364func | std::isnormal | bool | float | cmath | CXX11+ 365func | std::isnormal | bool | long double | cmath | CXX11+ 366func | std::signbit | bool | double | cmath | CXX11+ 367func | std::signbit | bool | float | cmath | CXX11+ 368func | std::signbit | bool | long double | cmath | CXX11+ 369 370# 371# C++11 comparison functions - must be in std:: since C++11 372# 373func | std::isgreater | bool | double; double | cmath | CXX11+ 374func | std::isgreater | bool | float; float | cmath | CXX11+ 375func | std::isgreater | bool | long double; long double | cmath | CXX11+ 376func | std::isgreaterequal | bool | double; double | cmath | CXX11+ 377func | std::isgreaterequal | bool | float; float | cmath | CXX11+ 378func | std::isgreaterequal | bool | long double; long double | cmath | CXX11+ 379func | std::isless | bool | double; double | cmath | CXX11+ 380func | std::isless | bool | float; float | cmath | CXX11+ 381func | std::isless | bool | long double; long double | cmath | CXX11+ 382func | std::islessequal | bool | double; double | cmath | CXX11+ 383func | std::islessequal | bool | float; float | cmath | CXX11+ 384func | std::islessequal | bool | long double; long double | cmath | CXX11+ 385func | std::islessgreater | bool | double; double | cmath | CXX11+ 386func | std::islessgreater | bool | float; float | cmath | CXX11+ 387func | std::islessgreater | bool | long double; long double | cmath | CXX11+ 388func | std::isunordered | bool | double; double | cmath | CXX11+ 389func | std::isunordered | bool | float; float | cmath | CXX11+ 390func | std::isunordered | bool | long double; long double | cmath | CXX11+ 391