@@ -6411,7 +6411,15 @@ argument list, like this:
6411
6411
6412
6412
On threaded perls not operating with thread-safe functionality, this macro uses
6413
6413
a mutex to force a critical section. Therefore the matching RESTORE should be
6414
- close by, and guaranteed to be called.
6414
+ close by, and guaranteed to be called; see L</WITH_LC_NUMERIC_SET_TO_NEEDED>
6415
+ for a more contained way to ensure that.
6416
+
6417
+ =for apidoc Am|void|STORE_LC_NUMERIC_SET_TO_NEEDED_IN|bool in_lc_numeric
6418
+
6419
+ Same as L</STORE_LC_NUMERIC_SET_TO_NEEDED_IN> with in_lc_numeric provided
6420
+ as the precalculated value of C<IN_LC(LC_NUMERIC)>. It is the caller's
6421
+ responsibility to ensure that the status of C<PL_compiling> and C<PL_hints>
6422
+ cannot have changed since the precalculation.
6415
6423
6416
6424
=for apidoc Am|void|RESTORE_LC_NUMERIC
6417
6425
@@ -6455,6 +6463,13 @@ is equivalent to:
6455
6463
#endif
6456
6464
}
6457
6465
6466
+ =for apidoc Am|void|WITH_LC_NUMERIC_SET_TO_NEEDED_IN|bool in_lc_numeric
6467
+
6468
+ Same as L</WITH_LC_NUMERIC_SET_TO_NEEDED> with in_lc_numeric provided
6469
+ as the precalculated value of C<IN_LC(LC_NUMERIC)>. It is the caller's
6470
+ responsibility to ensure that the status of C<PL_compiling> and C<PL_hints>
6471
+ cannot have changed since the precalculation.
6472
+
6458
6473
=cut
6459
6474
6460
6475
*/
@@ -6482,12 +6497,13 @@ is equivalent to:
6482
6497
# define DECLARATION_FOR_LC_NUMERIC_MANIPULATION \
6483
6498
void (*_restore_LC_NUMERIC_function)(pTHX) = NULL
6484
6499
6485
- # define STORE_LC_NUMERIC_SET_TO_NEEDED () \
6500
+ # define STORE_LC_NUMERIC_SET_TO_NEEDED_IN ( in ) \
6486
6501
STMT_START { \
6502
+ bool _in_lc_numeric = (in); \
6487
6503
LC_NUMERIC_LOCK ( \
6488
- ( ( IN_LC (LC_NUMERIC) && _NOT_IN_NUMERIC_UNDERLYING) \
6489
- || (! IN_LC (LC_NUMERIC) && _NOT_IN_NUMERIC_STANDARD)));\
6490
- if (IN_LC (LC_NUMERIC)) { \
6504
+ ( ( _in_lc_numeric && _NOT_IN_NUMERIC_UNDERLYING) \
6505
+ || (! _in_lc_numeric && _NOT_IN_NUMERIC_STANDARD))); \
6506
+ if (_in_lc_numeric) { \
6491
6507
if (_NOT_IN_NUMERIC_UNDERLYING) { \
6492
6508
Perl_set_numeric_underlying (aTHX); \
6493
6509
_restore_LC_NUMERIC_function \
@@ -6503,6 +6519,9 @@ is equivalent to:
6503
6519
} \
6504
6520
} STMT_END
6505
6521
6522
+ # define STORE_LC_NUMERIC_SET_TO_NEEDED () \
6523
+ STORE_LC_NUMERIC_SET_TO_NEEDED_IN (IN_LC (LC_NUMERIC))
6524
+
6506
6525
# define RESTORE_LC_NUMERIC () \
6507
6526
STMT_START { \
6508
6527
if (_restore_LC_NUMERIC_function) { \
@@ -6577,14 +6596,17 @@ is equivalent to:
6577
6596
__FILE__, __LINE__, PL_numeric_standard)); \
6578
6597
} STMT_END
6579
6598
6580
- # define WITH_LC_NUMERIC_SET_TO_NEEDED ( block ) \
6599
+ # define WITH_LC_NUMERIC_SET_TO_NEEDED_IN ( in_lc_numeric, block ) \
6581
6600
STMT_START { \
6582
6601
DECLARATION_FOR_LC_NUMERIC_MANIPULATION; \
6583
- STORE_LC_NUMERIC_SET_TO_NEEDED (); \
6602
+ STORE_LC_NUMERIC_SET_TO_NEEDED_IN (in_lc_numeric); \
6584
6603
block; \
6585
6604
RESTORE_LC_NUMERIC (); \
6586
6605
} STMT_END;
6587
6606
6607
+ # define WITH_LC_NUMERIC_SET_TO_NEEDED (block ) \
6608
+ WITH_LC_NUMERIC_SET_TO_NEEDED_IN (IN_LC (LC_NUMERIC), block)
6609
+
6588
6610
#else /* !USE_LOCALE_NUMERIC */
6589
6611
6590
6612
# define SET_NUMERIC_STANDARD ()
@@ -6593,10 +6615,13 @@ is equivalent to:
6593
6615
# define DECLARATION_FOR_LC_NUMERIC_MANIPULATION
6594
6616
# define STORE_LC_NUMERIC_SET_STANDARD ()
6595
6617
# define STORE_LC_NUMERIC_FORCE_TO_UNDERLYING ()
6618
+ # define STORE_LC_NUMERIC_SET_TO_NEEDED_IN (in_lc_numeric )
6596
6619
# define STORE_LC_NUMERIC_SET_TO_NEEDED ()
6597
6620
# define RESTORE_LC_NUMERIC ()
6598
6621
# define LOCK_LC_NUMERIC_STANDARD ()
6599
6622
# define UNLOCK_LC_NUMERIC_STANDARD ()
6623
+ # define WITH_LC_NUMERIC_SET_TO_NEEDED_IN (in_lc_numeric, block ) \
6624
+ STMT_START { block; } STMT_END
6600
6625
# define WITH_LC_NUMERIC_SET_TO_NEEDED (block ) \
6601
6626
STMT_START { block; } STMT_END
6602
6627
0 commit comments