Skip to content

Commit 97c021c

Browse files
committed
Time::HiRes.xs shorten multiple very long croak("unimplemented") strings
-strings "Time::HiRes::clock", "Time::HiRes::clock_nanosleep", etc will be inside HiRes.dll.so no matter what, b/c BOOT: and newXS_flags() requires them no matter what -type NV_DIE is an un-invasive LOC-wise quick fix to get rid of the tons of EU::PXS injected dXSTARG; statements which execute Perl_sv_newmortal() right before executing croak("%s(): unimplemented in this platform","Time::HiRes::clock"); The retval types could be changed to void, or SV* instead to eliminate the Perl_sv_newmortal() before croak() calls. But for some hysterical raisens, Time::HiRes.xs is confusing Perl_warn() with Perl_croak() in dozens of places. Fixing that is out of scope for this patch.
1 parent ba5e04c commit 97c021c

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

dist/Time-HiRes/HiRes.xs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
# undef ITIMER_REALPROF
9090
#endif
9191

92+
/* special type used by croak("unimplemented") XSUBs to neutralize */
93+
typedef NV NV_DIE; /* unused dXSTARG/sv_newmortal() calls */
94+
9295
#ifndef TIME_HIRES_CLOCKID_T
9396
typedef int clockid_t;
9497
#endif
@@ -1010,12 +1013,12 @@ nanosleep(nsec)
10101013

10111014
# else /* #if defined(TIME_HIRES_NANOSLEEP) */
10121015

1013-
NV
1016+
NV_DIE
10141017
nanosleep(nsec)
10151018
NV nsec
10161019
CODE:
10171020
PERL_UNUSED_ARG(nsec);
1018-
croak("Time::HiRes::nanosleep(): unimplemented in this platform");
1021+
croak("%s(): unimplemented in this platform", "Time::HiRes::nanosleep");
10191022
RETVAL = 0.0;
10201023
OUTPUT:
10211024
RETVAL
@@ -1066,12 +1069,12 @@ sleep(...)
10661069

10671070
#else /* #if defined(HAS_USLEEP) && defined(HAS_GETTIMEOFDAY) */
10681071

1069-
NV
1072+
NV_DIE
10701073
usleep(useconds)
10711074
NV useconds
10721075
CODE:
10731076
PERL_UNUSED_ARG(useconds);
1074-
croak("Time::HiRes::usleep(): unimplemented in this platform");
1077+
croak("%s(): unimplemented in this platform", "Time::HiRes::usleep");
10751078
RETVAL = 0.0;
10761079
OUTPUT:
10771080
RETVAL
@@ -1169,19 +1172,19 @@ ualarm(useconds,interval=0)
11691172
CODE:
11701173
PERL_UNUSED_ARG(useconds);
11711174
PERL_UNUSED_ARG(interval);
1172-
croak("Time::HiRes::ualarm(): unimplemented in this platform");
1175+
croak("%s(): unimplemented in this platform", "Time::HiRes::ualarm");
11731176
RETVAL = -1;
11741177
OUTPUT:
11751178
RETVAL
11761179

1177-
NV
1180+
NV_DIE
11781181
alarm(seconds,interval=0)
11791182
NV seconds
11801183
NV interval
11811184
CODE:
11821185
PERL_UNUSED_ARG(seconds);
11831186
PERL_UNUSED_ARG(interval);
1184-
croak("Time::HiRes::alarm(): unimplemented in this platform");
1187+
croak("%s(): unimplemented in this platform", "Time::HiRes::alarm");
11851188
RETVAL = 0.0;
11861189
OUTPUT:
11871190
RETVAL
@@ -1338,10 +1341,10 @@ PROTOTYPE: $$@
13381341
tot++;
13391342
}
13401343
} else {
1341-
croak("futimens unimplemented in this platform");
1344+
croak("%s unimplemented in this platform", "futimens");
13421345
}
13431346
# else /* HAS_FUTIMENS */
1344-
croak("futimens unimplemented in this platform");
1347+
croak("%s unimplemented in this platform", "futimens");
13451348
# endif /* HAS_FUTIMENS */
13461349
}
13471350
}
@@ -1356,10 +1359,10 @@ PROTOTYPE: $$@
13561359
tot++;
13571360
}
13581361
} else {
1359-
croak("utimensat unimplemented in this platform");
1362+
croak("%s unimplemented in this platform", "utimensat");
13601363
}
13611364
# else /* HAS_UTIMENSAT */
1362-
croak("utimensat unimplemented in this platform");
1365+
croak("%s unimplemented in this platform", "utimensat");
13631366
# endif /* HAS_UTIMENSAT */
13641367
}
13651368
} /* while items */
@@ -1373,7 +1376,7 @@ PROTOTYPE: $$@
13731376
I32
13741377
utime(accessed, modified, ...)
13751378
CODE:
1376-
croak("Time::HiRes::utime(): unimplemented in this platform");
1379+
croak("%s(): unimplemented in this platform", "Time::HiRes::utime");
13771380
RETVAL = 0;
13781381
OUTPUT:
13791382
RETVAL
@@ -1401,12 +1404,12 @@ clock_gettime(clock_id = CLOCK_REALTIME)
14011404

14021405
#else /* if defined(TIME_HIRES_CLOCK_GETTIME) */
14031406

1404-
NV
1407+
NV_DIE
14051408
clock_gettime(clock_id = 0)
14061409
clockid_t clock_id
14071410
CODE:
14081411
PERL_UNUSED_ARG(clock_id);
1409-
croak("Time::HiRes::clock_gettime(): unimplemented in this platform");
1412+
croak("%s(): unimplemented in this platform", "Time::HiRes::clock_gettime");
14101413
RETVAL = 0.0;
14111414
OUTPUT:
14121415
RETVAL
@@ -1434,12 +1437,12 @@ clock_getres(clock_id = CLOCK_REALTIME)
14341437

14351438
#else /* if defined(TIME_HIRES_CLOCK_GETRES) */
14361439

1437-
NV
1440+
NV_DIE
14381441
clock_getres(clock_id = 0)
14391442
clockid_t clock_id
14401443
CODE:
14411444
PERL_UNUSED_ARG(clock_id);
1442-
croak("Time::HiRes::clock_getres(): unimplemented in this platform");
1445+
croak("%s(): unimplemented in this platform", "Time::HiRes::clock_getres");
14431446
RETVAL = 0.0;
14441447
OUTPUT:
14451448
RETVAL
@@ -1470,7 +1473,7 @@ clock_nanosleep(clock_id, nsec, flags = 0)
14701473

14711474
#else /* if defined(TIME_HIRES_CLOCK_NANOSLEEP) && defined(TIMER_ABSTIME) */
14721475

1473-
NV
1476+
NV_DIE
14741477
clock_nanosleep(clock_id, nsec, flags = 0)
14751478
clockid_t clock_id
14761479
NV nsec
@@ -1479,7 +1482,7 @@ clock_nanosleep(clock_id, nsec, flags = 0)
14791482
PERL_UNUSED_ARG(clock_id);
14801483
PERL_UNUSED_ARG(nsec);
14811484
PERL_UNUSED_ARG(flags);
1482-
croak("Time::HiRes::clock_nanosleep(): unimplemented in this platform");
1485+
croak("%s(): unimplemented in this platform", "Time::HiRes::clock_nanosleep");
14831486
RETVAL = 0.0;
14841487
OUTPUT:
14851488
RETVAL
@@ -1501,10 +1504,10 @@ clock()
15011504

15021505
#else /* if defined(TIME_HIRES_CLOCK) && defined(CLOCKS_PER_SEC) */
15031506

1504-
NV
1507+
NV_DIE
15051508
clock()
15061509
CODE:
1507-
croak("Time::HiRes::clock(): unimplemented in this platform");
1510+
croak("%s(): unimplemented in this platform", "Time::HiRes::clock");
15081511
RETVAL = 0.0;
15091512
OUTPUT:
15101513
RETVAL

dist/Time-HiRes/typemap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ clockid_t T_IV
3333
IV T_IV
3434
UV T_UV
3535
NV T_NV
36+
NV_DIE T_NV_DIE
3637
I32 T_IV
3738
I16 T_IV
3839
I8 T_IV
@@ -238,6 +239,8 @@ T_FLOAT
238239
sv_setnv($arg, (double)$var);
239240
T_NV
240241
sv_setnv($arg, (NV)$var);
242+
T_NV_DIE
243+
croak_xs_usage(cv, "T_NV_DIE");
241244
T_DOUBLE
242245
sv_setnv($arg, (double)$var);
243246
T_PV

0 commit comments

Comments
 (0)