Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fea89d3

Browse files
committedFeb 5, 2025·
druntime: redirect dual-ABI functions on glibc to IEEE128 version ...
... if IEEE long double ABI is selected
1 parent 6d6e170 commit fea89d3

File tree

3 files changed

+219
-0
lines changed

3 files changed

+219
-0
lines changed
 

‎druntime/src/core/stdc/math.d

+184
Original file line numberDiff line numberDiff line change
@@ -4285,195 +4285,223 @@ else
42854285
///
42864286
float acosf(float x);
42874287
///
4288+
pragma(mangle, __acosl_mangle)
42884289
real acosl(real x);
42894290

42904291
///
42914292
double asin(double x);
42924293
///
42934294
float asinf(float x);
42944295
///
4296+
pragma(mangle, __asinl_mangle)
42954297
real asinl(real x);
42964298

42974299
///
42984300
pure double atan(double x);
42994301
///
43004302
pure float atanf(float x);
43014303
///
4304+
pragma(mangle, __atanl_mangle)
43024305
pure real atanl(real x);
43034306

43044307
///
43054308
double atan2(double y, double x);
43064309
///
43074310
float atan2f(float y, float x);
43084311
///
4312+
pragma(mangle, __atan2l_mangle)
43094313
real atan2l(real y, real x);
43104314

43114315
///
43124316
pure double cos(double x);
43134317
///
43144318
pure float cosf(float x);
43154319
///
4320+
pragma(mangle, __cosl_mangle)
43164321
pure real cosl(real x);
43174322

43184323
///
43194324
pure double sin(double x);
43204325
///
43214326
pure float sinf(float x);
43224327
///
4328+
pragma(mangle, __sinl_mangle)
43234329
pure real sinl(real x);
43244330

43254331
///
43264332
pure double tan(double x);
43274333
///
43284334
pure float tanf(float x);
43294335
///
4336+
pragma(mangle, __tanl_mangle)
43304337
pure real tanl(real x);
43314338

43324339
///
43334340
double acosh(double x);
43344341
///
43354342
float acoshf(float x);
43364343
///
4344+
pragma(mangle, __acoshl_mangle)
43374345
real acoshl(real x);
43384346

43394347
///
43404348
pure double asinh(double x);
43414349
///
43424350
pure float asinhf(float x);
43434351
///
4352+
pragma(mangle, __asinhl_mangle)
43444353
pure real asinhl(real x);
43454354

43464355
///
43474356
double atanh(double x);
43484357
///
43494358
float atanhf(float x);
43504359
///
4360+
pragma(mangle, __atanhl_mangle)
43514361
real atanhl(real x);
43524362

43534363
///
43544364
double cosh(double x);
43554365
///
43564366
float coshf(float x);
43574367
///
4368+
pragma(mangle, __coshl_mangle)
43584369
real coshl(real x);
43594370

43604371
///
43614372
double sinh(double x);
43624373
///
43634374
float sinhf(float x);
43644375
///
4376+
pragma(mangle, __sinhl_mangle)
43654377
real sinhl(real x);
43664378

43674379
///
43684380
pure double tanh(double x);
43694381
///
43704382
pure float tanhf(float x);
43714383
///
4384+
pragma(mangle, __tanhl_mangle)
43724385
pure real tanhl(real x);
43734386

43744387
///
43754388
double exp(double x);
43764389
///
43774390
float expf(float x);
43784391
///
4392+
pragma(mangle, __expl_mangle)
43794393
real expl(real x);
43804394

43814395
///
43824396
double exp2(double x);
43834397
///
43844398
float exp2f(float x);
43854399
///
4400+
pragma(mangle, __exp2l_mangle)
43864401
real exp2l(real x);
43874402

43884403
///
43894404
double expm1(double x);
43904405
///
43914406
float expm1f(float x);
43924407
///
4408+
pragma(mangle, __expm1l_mangle)
43934409
real expm1l(real x);
43944410

43954411
///
43964412
pure double frexp(double value, int* exp);
43974413
///
43984414
pure float frexpf(float value, int* exp);
43994415
///
4416+
pragma(mangle, __frexpl_mangle)
44004417
pure real frexpl(real value, int* exp);
44014418

44024419
///
44034420
int ilogb(double x);
44044421
///
44054422
int ilogbf(float x);
44064423
///
4424+
pragma(mangle, __ilogbl_mangle)
44074425
int ilogbl(real x);
44084426

44094427
///
44104428
double ldexp(double x, int exp);
44114429
///
44124430
float ldexpf(float x, int exp);
44134431
///
4432+
pragma(mangle, __ldexpl_mangle)
44144433
real ldexpl(real x, int exp);
44154434

44164435
///
44174436
double log(double x);
44184437
///
44194438
float logf(float x);
44204439
///
4440+
pragma(mangle, __logl_mangle)
44214441
real logl(real x);
44224442

44234443
///
44244444
double log10(double x);
44254445
///
44264446
float log10f(float x);
44274447
///
4448+
pragma(mangle, __log10l_mangle)
44284449
real log10l(real x);
44294450

44304451
///
44314452
double log1p(double x);
44324453
///
44334454
float log1pf(float x);
44344455
///
4456+
pragma(mangle, __log1pl_mangle)
44354457
real log1pl(real x);
44364458

44374459
///
44384460
double log2(double x);
44394461
///
44404462
float log2f(float x);
44414463
///
4464+
pragma(mangle, __log2l_mangle)
44424465
real log2l(real x);
44434466

44444467
///
44454468
double logb(double x);
44464469
///
44474470
float logbf(float x);
44484471
///
4472+
pragma(mangle, __logbl_mangle)
44494473
real logbl(real x);
44504474

44514475
///
44524476
pure double modf(double value, double* iptr);
44534477
///
44544478
pure float modff(float value, float* iptr);
44554479
///
4480+
pragma(mangle, __modfl_mangle)
44564481
pure real modfl(real value, real *iptr);
44574482

44584483
///
44594484
double scalbn(double x, int n);
44604485
///
44614486
float scalbnf(float x, int n);
44624487
///
4488+
pragma(mangle, __scalbnl_mangle)
44634489
real scalbnl(real x, int n);
44644490

44654491
///
44664492
double scalbln(double x, c_long n);
44674493
///
44684494
float scalblnf(float x, c_long n);
44694495
///
4496+
pragma(mangle, __scalblnl_mangle)
44704497
real scalblnl(real x, c_long n);
44714498

44724499
///
44734500
pure double cbrt(double x);
44744501
///
44754502
pure float cbrtf(float x);
44764503
///
4504+
pragma(mangle, __cbrtl_mangle)
44774505
pure real cbrtl(real x);
44784506

44794507
///
@@ -4486,6 +4514,7 @@ else
44864514
///
44874515
pure float fabsf(float x);
44884516
///
4517+
pragma(mangle, __fabsl_mangle)
44894518
pure real fabsl(real x);
44904519
}
44914520

@@ -4494,194 +4523,349 @@ else
44944523
///
44954524
float hypotf(float x, float y);
44964525
///
4526+
pragma(mangle, __hypotl_mangle)
44974527
real hypotl(real x, real y);
44984528

44994529
///
45004530
double pow(double x, double y);
45014531
///
45024532
float powf(float x, float y);
45034533
///
4534+
pragma(mangle, __powl_mangle)
45044535
real powl(real x, real y);
45054536

45064537
///
45074538
double sqrt(double x);
45084539
///
45094540
float sqrtf(float x);
45104541
///
4542+
pragma(mangle, __sqrtl_mangle)
45114543
real sqrtl(real x);
45124544

45134545
///
45144546
pure double erf(double x);
45154547
///
45164548
pure float erff(float x);
45174549
///
4550+
pragma(mangle, __erfl_mangle)
45184551
pure real erfl(real x);
45194552

45204553
///
45214554
double erfc(double x);
45224555
///
45234556
float erfcf(float x);
45244557
///
4558+
pragma(mangle, __erfcl_mangle)
45254559
real erfcl(real x);
45264560

45274561
///
45284562
double lgamma(double x);
45294563
///
45304564
float lgammaf(float x);
45314565
///
4566+
pragma(mangle, __lgammal_mangle)
45324567
real lgammal(real x);
45334568

45344569
///
45354570
double tgamma(double x);
45364571
///
45374572
float tgammaf(float x);
45384573
///
4574+
pragma(mangle, __tgammal_mangle)
45394575
real tgammal(real x);
45404576

45414577
///
45424578
pure double ceil(double x);
45434579
///
45444580
pure float ceilf(float x);
45454581
///
4582+
pragma(mangle, __ceill_mangle)
45464583
pure real ceill(real x);
45474584

45484585
///
45494586
pure double floor(double x);
45504587
///
45514588
pure float floorf(float x);
45524589
///
4590+
pragma(mangle, __floorl_mangle)
45534591
pure real floorl(real x);
45544592

45554593
///
45564594
pure double nearbyint(double x);
45574595
///
45584596
pure float nearbyintf(float x);
45594597
///
4598+
pragma(mangle, __nearbyintl_mangle)
45604599
pure real nearbyintl(real x);
45614600

45624601
///
45634602
pure double rint(double x);
45644603
///
45654604
pure float rintf(float x);
45664605
///
4606+
pragma(mangle, __rintl_mangle)
45674607
pure real rintl(real x);
45684608

45694609
///
45704610
c_long lrint(double x);
45714611
///
45724612
c_long lrintf(float x);
45734613
///
4614+
pragma(mangle, __lrintl_mangle)
45744615
c_long lrintl(real x);
45754616

45764617
///
45774618
long llrint(double x);
45784619
///
45794620
long llrintf(float x);
45804621
///
4622+
pragma(mangle, __llrintl_mangle)
45814623
long llrintl(real x);
45824624

45834625
///
45844626
pure double round(double x);
45854627
///
45864628
pure float roundf(float x);
45874629
///
4630+
pragma(mangle, __roundl_mangle)
45884631
pure real roundl(real x);
45894632

45904633
///
45914634
c_long lround(double x);
45924635
///
45934636
c_long lroundf(float x);
45944637
///
4638+
pragma(mangle, __lroundl_mangle)
45954639
c_long lroundl(real x);
45964640

45974641
///
45984642
long llround(double x);
45994643
///
46004644
long llroundf(float x);
46014645
///
4646+
pragma(mangle, __llroundl_mangle)
46024647
long llroundl(real x);
46034648

46044649
///
46054650
pure double trunc(double x);
46064651
///
46074652
pure float truncf(float x);
46084653
///
4654+
pragma(mangle, __truncl_mangle)
46094655
pure real truncl(real x);
46104656

46114657
///
46124658
double fmod(double x, double y);
46134659
///
46144660
float fmodf(float x, float y);
46154661
///
4662+
pragma(mangle, __fmodl_mangle)
46164663
real fmodl(real x, real y);
46174664

46184665
///
46194666
double remainder(double x, double y);
46204667
///
46214668
float remainderf(float x, float y);
46224669
///
4670+
pragma(mangle, __remainderl_mangle)
46234671
real remainderl(real x, real y);
46244672

46254673
///
46264674
double remquo(double x, double y, int* quo);
46274675
///
46284676
float remquof(float x, float y, int* quo);
46294677
///
4678+
pragma(mangle, __remquol_mangle)
46304679
real remquol(real x, real y, int* quo);
46314680

46324681
///
46334682
pure double copysign(double x, double y);
46344683
///
46354684
pure float copysignf(float x, float y);
46364685
///
4686+
pragma(mangle, __copysignl_mangle)
46374687
pure real copysignl(real x, real y);
46384688

46394689
///
46404690
pure double nan(char* tagp);
46414691
///
46424692
pure float nanf(char* tagp);
46434693
///
4694+
pragma(mangle, __nanl_mangle)
46444695
pure real nanl(char* tagp);
46454696

46464697
///
46474698
double nextafter(double x, double y);
46484699
///
46494700
float nextafterf(float x, float y);
46504701
///
4702+
pragma(mangle, __nextafterl_mangle)
46514703
real nextafterl(real x, real y);
46524704

46534705
///
4706+
pragma(mangle, __nexttoward_mangle)
46544707
double nexttoward(double x, real y);
46554708
///
4709+
pragma(mangle, __nexttowardf_mangle)
46564710
float nexttowardf(float x, real y);
46574711
///
4712+
pragma(mangle, __nexttowardl_mangle)
46584713
real nexttowardl(real x, real y);
46594714

46604715
///
46614716
double fdim(double x, double y);
46624717
///
46634718
float fdimf(float x, float y);
46644719
///
4720+
pragma(mangle, __fdiml_mangle)
46654721
real fdiml(real x, real y);
46664722

46674723
///
46684724
pure double fmax(double x, double y);
46694725
///
46704726
pure float fmaxf(float x, float y);
46714727
///
4728+
pragma(mangle, __fmaxl_mangle)
46724729
pure real fmaxl(real x, real y);
46734730

46744731
///
46754732
pure double fmin(double x, double y);
46764733
///
46774734
pure float fminf(float x, float y);
46784735
///
4736+
pragma(mangle, __fminl_mangle)
46794737
pure real fminl(real x, real y);
46804738

46814739
///
46824740
pure double fma(double x, double y, double z);
46834741
///
46844742
pure float fmaf(float x, float y, float z);
46854743
///
4744+
pragma(mangle, __fmal_mangle)
46864745
pure real fmal(real x, real y, real z);
4746+
4747+
version (D_PPCUseIEEE128)
4748+
{
4749+
enum __acoshl_mangle = "__acoshieee128";
4750+
enum __acosl_mangle = "__acosieee128";
4751+
enum __asinhl_mangle = "__asinhieee128";
4752+
enum __asinl_mangle = "__asinieee128";
4753+
enum __atan2l_mangle = "__atan2ieee128";
4754+
enum __atanhl_mangle = "__atanhieee128";
4755+
enum __atanl_mangle = "__atanieee128";
4756+
enum __cbrtl_mangle = "__cbrtieee128";
4757+
enum __ceill_mangle = "__ceilieee128";
4758+
enum __copysignl_mangle = "__copysignieee128";
4759+
enum __coshl_mangle = "__coshieee128";
4760+
enum __cosl_mangle = "__cosieee128";
4761+
enum __erfcl_mangle = "__erfcieee128";
4762+
enum __erfl_mangle = "__erfieee128";
4763+
enum __exp2l_mangle = "__exp2ieee128";
4764+
enum __expl_mangle = "__expieee128";
4765+
enum __expm1l_mangle = "__expm1ieee128";
4766+
enum __fabsl_mangle = "__fabsieee128";
4767+
enum __fdiml_mangle = "__fdimieee128";
4768+
enum __floorl_mangle = "__floorieee128";
4769+
enum __fmal_mangle = "__fmaieee128";
4770+
enum __fmaxl_mangle = "__fmaxieee128";
4771+
enum __fminl_mangle = "__fminieee128";
4772+
enum __fmodl_mangle = "__fmodieee128";
4773+
enum __frexpl_mangle = "__frexpieee128";
4774+
enum __hypotl_mangle = "__hypotieee128";
4775+
enum __ilogbl_mangle = "__ilogbieee128";
4776+
enum __ldexpl_mangle = "__ldexpieee128";
4777+
enum __lgammal_mangle = "__lgammaieee128";
4778+
enum __llrintl_mangle = "__llrintieee128";
4779+
enum __llroundl_mangle = "__llroundieee128";
4780+
enum __log10l_mangle = "__log10ieee128";
4781+
enum __log1pl_mangle = "__log1pieee128";
4782+
enum __log2l_mangle = "__log2ieee128";
4783+
enum __logbl_mangle = "__logbieee128";
4784+
enum __logl_mangle = "__logieee128";
4785+
enum __lrintl_mangle = "__lrintieee128";
4786+
enum __lroundl_mangle = "__lroundieee128";
4787+
enum __modfl_mangle = "__modfieee128";
4788+
enum __nanl_mangle = "__nanieee128";
4789+
enum __nearbyintl_mangle = "__nearbyintieee128";
4790+
enum __nextafterl_mangle = "__nextafterieee128";
4791+
enum __nexttoward_mangle = "__nexttoward_to_ieee128";
4792+
enum __nexttowardf_mangle = "__nexttowardf_to_ieee128";
4793+
enum __nexttowardl_mangle = "__nexttowardieee128";
4794+
enum __powl_mangle = "__powieee128";
4795+
enum __remainderl_mangle = "__remainderieee128";
4796+
enum __remquol_mangle = "__remquoieee128";
4797+
enum __rintl_mangle = "__rintieee128";
4798+
enum __roundl_mangle = "__roundieee128";
4799+
enum __scalblnl_mangle = "__scalblnieee128";
4800+
enum __scalbnl_mangle = "__scalbnieee128";
4801+
enum __sinhl_mangle = "__sinhieee128";
4802+
enum __sinl_mangle = "__sinieee128";
4803+
enum __sqrtl_mangle = "__sqrtieee128";
4804+
enum __tanhl_mangle = "__tanhieee128";
4805+
enum __tanl_mangle = "__tanieee128";
4806+
enum __tgammal_mangle = "__tgammaieee128";
4807+
enum __truncl_mangle = "__truncieee128";
4808+
}
4809+
else
4810+
{
4811+
enum __acoshl_mangle = "acoshl";
4812+
enum __acosl_mangle = "acosl";
4813+
enum __asinhl_mangle = "asinhl";
4814+
enum __asinl_mangle = "asinl";
4815+
enum __atan2l_mangle = "atan2l";
4816+
enum __atanhl_mangle = "atanhl";
4817+
enum __atanl_mangle = "atanl";
4818+
enum __cbrtl_mangle = "cbrtl";
4819+
enum __ceill_mangle = "ceill";
4820+
enum __copysignl_mangle = "copysignl";
4821+
enum __coshl_mangle = "coshl";
4822+
enum __cosl_mangle = "cosl";
4823+
enum __erfcl_mangle = "erfcl";
4824+
enum __erfl_mangle = "erfl";
4825+
enum __exp2l_mangle = "exp2l";
4826+
enum __expl_mangle = "expl";
4827+
enum __expm1l_mangle = "expm1l";
4828+
enum __fabsl_mangle = "fabsl";
4829+
enum __fdiml_mangle = "fdiml";
4830+
enum __floorl_mangle = "floorl";
4831+
enum __fmal_mangle = "fmal";
4832+
enum __fmaxl_mangle = "fmaxl";
4833+
enum __fminl_mangle = "fminl";
4834+
enum __fmodl_mangle = "fmodl";
4835+
enum __frexpl_mangle = "frexpl";
4836+
enum __hypotl_mangle = "hypotl";
4837+
enum __ilogbl_mangle = "ilogbl";
4838+
enum __ldexpl_mangle = "ldexpl";
4839+
enum __lgammal_mangle = "lgammal";
4840+
enum __llrintl_mangle = "llrintl";
4841+
enum __llroundl_mangle = "llroundl";
4842+
enum __log10l_mangle = "log10l";
4843+
enum __log1pl_mangle = "log1pl";
4844+
enum __log2l_mangle = "log2l";
4845+
enum __logbl_mangle = "logbl";
4846+
enum __logl_mangle = "logl";
4847+
enum __lrintl_mangle = "lrintl";
4848+
enum __lroundl_mangle = "lroundl";
4849+
enum __modfl_mangle = "modfl";
4850+
enum __nanl_mangle = "nanl";
4851+
enum __nearbyintl_mangle = "nearbyintl";
4852+
enum __nextafterl_mangle = "nextafterl";
4853+
enum __nexttoward_mangle = "nexttoward";
4854+
enum __nexttowardf_mangle = "nexttowardf";
4855+
enum __nexttowardl_mangle = "nexttowardl";
4856+
enum __powl_mangle = "powl";
4857+
enum __remainderl_mangle = "remainderl";
4858+
enum __remquol_mangle = "remquol";
4859+
enum __rintl_mangle = "rintl";
4860+
enum __roundl_mangle = "roundl";
4861+
enum __scalblnl_mangle = "scalblnl";
4862+
enum __scalbnl_mangle = "scalbnl";
4863+
enum __sinhl_mangle = "sinhl";
4864+
enum __sinl_mangle = "sinl";
4865+
enum __sqrtl_mangle = "sqrtl";
4866+
enum __tanhl_mangle = "tanhl";
4867+
enum __tanl_mangle = "tanl";
4868+
enum __tgammal_mangle = "tgammal";
4869+
enum __truncl_mangle = "truncl";
4870+
}
46874871
}

‎druntime/src/core/stdc/stdio.d

+25
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,7 @@ else version (CRuntime_Glibc)
13051305
{
13061306
///
13071307
pragma(printf)
1308+
pragma(mangle, __fprintf_mangle)
13081309
int fprintf(FILE* stream, scope const char* format, scope const ...);
13091310
///
13101311
pragma(scanf)
@@ -1313,6 +1314,7 @@ else version (CRuntime_Glibc)
13131314
alias fscanf = __isoc99_fscanf;
13141315
///
13151316
pragma(printf)
1317+
pragma(mangle, __sprintf_mangle)
13161318
int sprintf(scope char* s, scope const char* format, scope const ...);
13171319
///
13181320
pragma(scanf)
@@ -1321,6 +1323,7 @@ else version (CRuntime_Glibc)
13211323
alias sscanf = __isoc99_sscanf;
13221324
///
13231325
pragma(printf)
1326+
pragma(mangle, __vfprintf_mangle)
13241327
int vfprintf(FILE* stream, scope const char* format, va_list arg);
13251328
///
13261329
pragma(scanf)
@@ -1329,6 +1332,7 @@ else version (CRuntime_Glibc)
13291332
alias vfscanf = __isoc99_vfscanf;
13301333
///
13311334
pragma(printf)
1335+
pragma(mangle, __vsprintf_mangle)
13321336
int vsprintf(scope char* s, scope const char* format, va_list arg);
13331337
///
13341338
pragma(scanf)
@@ -1337,6 +1341,7 @@ else version (CRuntime_Glibc)
13371341
alias vsscanf = __isoc99_vsscanf;
13381342
///
13391343
pragma(printf)
1344+
pragma(mangle, __vprintf_mangle)
13401345
int vprintf(scope const char* format, va_list arg);
13411346
///
13421347
pragma(scanf)
@@ -1345,12 +1350,32 @@ else version (CRuntime_Glibc)
13451350
alias vscanf = __isoc99_vscanf;
13461351
///
13471352
pragma(printf)
1353+
pragma(mangle, __printf_mangle)
13481354
int printf(scope const char* format, scope const ...);
13491355
///
13501356
pragma(scanf)
13511357
int __isoc99_scanf(scope const char* format, scope ...);
13521358
///
13531359
alias scanf = __isoc99_scanf;
1360+
1361+
version (D_PPCUseIEEE128)
1362+
{
1363+
enum __fprintf_mangle = "__fprintfieee128";
1364+
enum __printf_mangle = "__printfieee128";
1365+
enum __sprintf_mangle = "__sprintfieee128";
1366+
enum __vfprintf_mangle = "__vfprintfieee128";
1367+
enum __vprintf_mangle = "__vprintfieee128";
1368+
enum __vsprintf_mangle = "__vsprintfieee128";
1369+
}
1370+
else
1371+
{
1372+
enum __fprintf_mangle = "fprintf";
1373+
enum __printf_mangle = "printf";
1374+
enum __sprintf_mangle = "sprintf";
1375+
enum __vfprintf_mangle = "vfprintf";
1376+
enum __vprintf_mangle = "vprintf";
1377+
enum __vsprintf_mangle = "vsprintf";
1378+
}
13541379
}
13551380
else
13561381
{

‎druntime/src/core/stdc/stdlib.d

+10
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,17 @@ version (CRuntime_Microsoft)
148148
else
149149
{
150150
/// Added to Bionic since Lollipop.
151+
pragma(mangle, __strtold_mangle)
151152
real strtold(scope inout(char)* nptr, scope inout(char)** endptr);
153+
154+
version (D_PPCUseIEEE128)
155+
{
156+
enum __strtold_mangle = "__strtoieee128";
157+
}
158+
else
159+
{
160+
enum __strtold_mangle = "strtold";
161+
}
152162
}
153163

154164
// No unsafe pointer manipulation.

0 commit comments

Comments
 (0)
Please sign in to comment.