@@ -384,7 +384,6 @@ Perl_xxx(aTHX_ ...) form for any API calls where it's used.
384
384
=cut
385
385
*/
386
386
387
-
388
387
#define STR_WITH_LEN (s ) ("" s ""), (sizeof(s)-1)
389
388
390
389
/* STR_WITH_LEN() shortcuts */
@@ -421,6 +420,45 @@ Perl_xxx(aTHX_ ...) form for any API calls where it's used.
421
420
#define get_cvs (str , flags ) \
422
421
Perl_get_cvn_flags(aTHX_ STR_WITH_LEN(str), (flags))
423
422
423
+ /* internal helpers */
424
+ #define PERL_RVS_TO_DECIMAL_ (r ,v ,s ) (((r)*1000000)+((v)*1000)+(s))
425
+ #define PERL_DECIMAL_VERSION_ \
426
+ PERL_RVS_TO_DECIMAL_(PERL_REVISION, PERL_VERSION, PERL_SUBVERSION)
427
+
428
+ /*
429
+ =for apidoc AmR|bool|PERL_VERSION_EQ|const int r|const int v|const int s
430
+
431
+ Returns whether or not the perl currently executing has the specified
432
+ relationship to the perl given by the parameters. For example,
433
+
434
+ #if PERL_VERSION_GT(5,24,2)
435
+ code that will only be compiled on perls after v5.24.2
436
+ #else
437
+ fallback code
438
+ #endif
439
+
440
+ Note that this is usable in making compile-time decisions
441
+
442
+ The possible comparisons are C<PERL_VERSION_EQ>, C<PERL_VERSION_NE>,
443
+ C<PERL_VERSION_GE>, C<PERL_VERSION_GT>, C<PERL_VERSION_LE>, and
444
+ C<PERL_VERSION_LT>.
445
+
446
+ =for apidoc AmRh|bool|PERL_VERSION_NE|const int r|const int v|const int s
447
+ =for apidoc AmRh|bool|PERL_VERSION_GE|const int r|const int v|const int s
448
+ =for apidoc AmRh|bool|PERL_VERSION_GT|const int r|const int v|const int s
449
+ =for apidoc AmRh|bool|PERL_VERSION_LE|const int r|const int v|const int s
450
+ =for apidoc AmRh|bool|PERL_VERSION_LT|const int r|const int v|const int s
451
+
452
+ =cut
453
+ */
454
+
455
+ # define PERL_VERSION_EQ (r ,v ,s ) (PERL_DECIMAL_VERSION_ == PERL_RVS_TO_DECIMAL_(r,v,s))
456
+ # define PERL_VERSION_NE (r ,v ,s ) (! PERL_VERSION_EQ(r,v,s))
457
+ # define PERL_VERSION_LT (r ,v ,s ) (PERL_DECIMAL_VERSION_ < PERL_RVS_TO_DECIMAL_(r,v,s))
458
+ # define PERL_VERSION_LE (r ,v ,s ) (PERL_DECIMAL_VERSION_ <= PERL_RVS_TO_DECIMAL_(r,v,s))
459
+ # define PERL_VERSION_GT (r ,v ,s ) (! PERL_VERSION_LE(r,v,s))
460
+ # define PERL_VERSION_GE (r ,v ,s ) (! PERL_VERSION_LT(r,v,s))
461
+
424
462
/*
425
463
=head1 Miscellaneous Functions
426
464
0 commit comments