This continues the process started in #23592 to change names with
leading underscores to be legal C. See that p.r. or
4bb3572f7a1c1f3944b7f58b22b6e7a9ef5faba6 for extensive discussion.
This commit simply moves the leading underscore to be trailing
There are a bunch of functions that are passed pointers to two positions
in a string. These commits allow you to declare these in embed.fnc, and
have an assert like (s < e) generated that is automatically placed in
the PERL_ARGS_ASSERT for the function. Many entries in embed.fnc are
changed to use this new capability.
This is extended for functions where it should instead be assert(s <= e)
and assert(s <= cur)
Generally, a pointer to a string upper bound actually is to one beyond
the actual final byte in the string. This is sanctioned by the C
Standard, and allows you to just subtract the lower bound from it to get
its length, without having to add 1.
But some functions are written to tolerate the upper bound pointer being
set to the actual final byte. The EPTRQ constraint in embed.fnc is used
for those; the assertion becomes 'l <= u' instead of strictly less-than.
This commit is the first to use this type of constraint, and it applies
it only to those functions whose documentation or behavior clearly
indicate this is expected.
I removed now redundant asserts that were in the functions, and now are
included in the ARGS_ASSERT macros
There's a dozen-ish ones where that isn't true. And they need to be
investigated further before deciding their disposition.
This is the first use of the new MPTR constraint that is used to
generate an assertion that a pointer is somewhere in the middle of a
string.
I removed now redundant asserts that were in the functions, and now are
included in the ARGS_ASSERT macros
I went through the declarations in embed.fnc and added PTR constraints
for all the ones that looked to have pointers to the beginning and end
of a string. I then ran the test suite, and reverted any that had
problems.
Then I looked at the code for each one remaining to see if it was
equipped to handle the case where the end == the beginning, and removed
those.
This is the result. Testing in the field may reveal others that the
test suite missed; we can fix those as they occur.
I removed now redundant asserts that were in the functions, and now are
included in the ARGS_ASSERT macros
This:
* reorders some comments to make more sense
* makes minor clarifications
* removes comments that no longer make sense
* adds comments about moving ARGS_ASSERT macros to the top of their
functions when the code around them gets changed anyway.
Historically the asserts had to be placed after any declarations
because of limitations in the C89 Standard that have been removed in C99
which we are now following.
Placing the assertions at the function beginning is clearer, and stops
any issues with the code below it using a variable prior to its
assertion.
`newSV_type(SVt_PVOBJ)` does the following initialization:
* `ObjectMAXFIELD(sv) = -1;`
* `ObjectFIELDS(sv) = NULL;`
This commit makes two changes to `Perl_newSVobject` reflecting that:
1. There's no need for `Perl_newSVobject` to set either of these fields
if `fieldcount` is zero, so that line is coverted into a DEBUGGING
assert()` and one added for `ObjectMAXFIELD(sv)` for completeness.
2. When `fieldcount` is non-zero, setting `ObjectMAXFIELD(sv)` prior to
the `Newx()` is more likely to result in the compiler realising that
it only needs to do one `ObjectMAXFIELD(sv)` STORE rather than two.
These functions do the same thing, differing in details. Consolidation
makes perlapi more compact, and makes it easier for the reader to see
the similarities and differences between the functions.
Note that the cryptic sentence "It correctly handles the UTF8 flag" in
the sv_streq entry has been removed. It turns out that meant that the
code looks at the UTF8ness of each SV, except when 'use bytes' is in
effect.
It's better to reuse the standard croak test infrastructure, than put
lots of ad-hoc uses of `eval` and assertions on the value of `$@`
afterwards in the regular signatures.t file.
This allows a test file to begin with a common pragma line or other
setup code and avoid having to repeat that setup across every individual
test block in the file.
This final line of output is often repeated across many tests, but its
exact details aren't overly interesting from a testing perspective. It's
easier just to ignore it in the output and then not have to rely on
testing it all the time.
'uni' commonly is short for Unicode. Here, it was short for 'unary',
which I found highly confusing.
This also changes the name of a formal parameter to also not be 'uni'
when 'unary' is meant.
Change it from being an array length, to being a pointer to the ending
position of the array. This makes this function consistent with most of
the others in this file.
It allows us to usually use C_ARRAY_END() to wrap the parameter, which
simplifies some expressions,
Change it from being an array length, to being a pointer to the ending
position of the array. This makes this function consistent with most of
the others in this file.
It allows us to usually use C_ARRAY_END() to wrap the parameter, which
simplifies some expressions,
This commit removes the existing END blocks that vary depending on the
type of timer being used, and replaces them with a single END block that
always exists, and simply calls watchdog(0). This already cancels
whatever watchdogs are in place, doing nothing if none are.
Spotted by Tony Cook
Even though a test file should clear every timer before exit, this makes
sure it happens.
This enhances the code to work on cases like:
watchdog(5);
sleep 4;
watchdog(10);
sleep 8;
Prior to this commit, you had to explicitly cancel an existing watchdog
before setting a new one.
As a result of this commit, all possible wathdog variables get undef'd
early. This makes later undef calls redundant, so they are removed.
Suggested by Tony Cook
Only one type of watchdog timer supposedly can exist. But I can see the
possibility that a temporary glitch in the system caused a fallback type
to be used. This commit simply makes sure that when cancelling,
anything out there gets cancelled, instead of assuming there's just one
possibility.
The fallback method of setting a watchdog timer is to use alarm().
Prior to this commit, the code presumed that if it wasn't one of the
other possibilities, it must be this one. This is a valid assumption
currently, but future commits will change that. Prepare for them with
this commit.
Prior to this commit, the code gave up immediately if it tried
unsuccessfully to use a watchdog thread. But the alarm method is still
available. Drop down to try it.
In the thread documentation, I noticed that unsafe signals preclude
killing threads with a signal. But this is the normal method for
clearing a watchdog timer under threads. I doubt that people are
compiling with PERL_OLD_SIGNALS these days, so I didn't check for that,
but it's easy enough to check for the environment variable that does the
same thing at runtime.