| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It turns out that in order to make this work or assert if it won't, it
needs to be more complicated. The problem has to do with signed and
unsigned operands. It now special cases where the item being checked to
be in the range is a char, and casts that to a U8. Otherwise, there is
a problem when that is a negative signed type and the range is above the
int_max for that type. An assert is added to detect this rare event
(not rare for chars, hence the special case). The use of sizeof() for
this case means that it will be resolved at compile time and not
generate extra code. I did an experiment, and gcc even under -O0
compiled away the sizeof() clause.
As an example of why this is needed, suppose we have a signed char,
-127, and we want to see if it is in the range 128-130, expressed as
ints. Without casting that -127 to an unsigned char, it would subtract
128 from -127, yield -255, which when cast to an unsigned int would be
wrong. But casting the -127 to U8 first yields 129, and gives the
correct result. The same issue could happen wih ints if the range is
above INT_MAX, but that is a much rarer case, and this macro asserts
against it.
|
|
|
|
|
| |
These should be parenthesized to prevent issues when called with an
expression.
|
|
|
|
| |
the latter is faster, having only one conditional.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It turns out that on ASCII platforms, several of the character classes
are expressible as a single range, and using the new inRANGE macro saves
some instructions each time versus the array lookup still done for these
on EBCDIC platforms. Here is a sample benchmark
Key:
Ir Instruction read
Dr Data read
Dw Data write
COND conditional branches
IND indirect branches
The numbers represent raw counts per loop iteration.
isDIGIT_A('5')
blead hack Ratio %
----- ----- -------
Ir 358.0 355.0 100.8
Dr 123.0 121.0 101.7
Dw 57.0 57.0 100.0
COND 51.0 50.0 102.0
IND 7.0 7.0 100.0
The differences are small, but these macros are executed ubiquitously
|
|
|
|
|
|
|
| |
The macro verified that its input was in the range '1' to '9' by using a
subtraction and a single conditional. This commit generalizes this
non-obvious method of avoiding a conditional, and moves it to handy.h so
it can be used in other places.
|
|
|
|
|
|
| |
These override the normal handling of UTF-8 locale case changing.
They aren't actually called yet, until later in this series of commits.
|
| |
|
|
|
|
| |
Vertically align the ternary colon with the question mark above it.
|
|
|
|
|
| |
This change is to allow these macros to be called without having to do
casting in the call.
|
|
|
|
| |
Prior to this commit, it returned TRUE if the input was 0.
|
|
|
|
|
| |
This is in preparation for it to be used outside of the file which
previously defined it.
|
|
|
|
| |
This allows us to remove a comment in regcomp.c
|
|
|
|
|
|
|
|
|
|
|
|
| |
This warning was introduced in db54010671d6c27faf667d658073743b14cd9b58.
and is about comparing signed and unsigned results. This commit casts
both operands to ptrdiff_t which is likely the widest signed type
available on the platform. This can fail if the one of the operands is
greater than PTRDIFF_MAX. But lots of other things can fail in that
case as well. As the reply from Tomasz Konojacki in the thread starting
with http://nntp.perl.org/group/perl.perl5.porters/251541 points out,
compilers are now assuming that no object is larger than PTRDIFF_MAX,
and if they can assume that, so can we.
|
|
|
|
|
|
|
|
|
| |
The pod for this has gotten screwed up over the releases, with a section
entitled SV-Body Allocation containing a bunch of SV manipulation
functions, and another section with that name containing still more with
no real rhyme or reason as to why one would be in one vs the other. And
one function was in both places. This commit consolidates all these
into one section entitled "SV Manipulation Functions"
|
| |
|
|
|
|
|
| |
These were for when some of the Posix character classes were implemented
as swashes, which is no longer the case, so these can be removed.
|
|
|
|
| |
This is now obsolete as a result of the last few commits.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
MSVC due to a bug doesn't merge identicals between .o'es or discard these
vars and their contents.
MEM_WRAP_CHECK_2 has never been used outside of core according to cpan grep
MEM_WRAP_CHECK_2 was removed on the "have PERL_MALLOC_WRAP" branch in
commit fabdb6c0879 "pre-likely cleanup" without explination, probably bc
it was unused. But MEM_WRAP_CHECK_2 was still left on the "no
PERL_MALLOC_WRAP" branch, so remove it from the "no" side for tidyness
since it was a mistake to leave it there if it was removed from the "yes"
side of the #ifdef.
Add MEM_WRAP_CHECK_s API, letter "s" means argument is string or static.
This lets us get rid of the "%s" argument passed to Perl_croak_nocontext at
a couple call sites since we fully control the next and only argument and
its guaranteed to be a string literal. This allows merging of 2
"Out of memory during array extend" c strings by linker now.
Also change the 2 op.h messages into macros which become string literals
at their call sites instead of "read char * from a global char **" which
was going on before.
VC 2003 32b perl527.dll section size before
.text name
DE503 virtual size
.rdata name
4B621 virtual size
after
.text name
DE503 virtual size
.rdata name
4B5D1 virtual size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Due to some MSVC bug or perl's not using MS specific CC options that I've
never figured out, MSVC does not remove unreferenced by a single .obj or
combine identical, static const data vars. MSVC funcs get removed &
combined correctly. Since for var swash_property_names removing it from
.objs that dont need it is very easy, do it. It saves some memory space.
Perhaps some other platforms/OSes/CCs have similar problems removing
unreferenced symbols from final binaries so this patch would help on those
CCs too.
regexec.c stopped using swash_property_names in commit 2a16ac9277 in 5.19.8
"regexec.c: Use compiled-in POSIX definitions"
regcomp.c stopped using swash_property_names in commit bcb875216f in 5.19.8
"regcomp.c: Rmv code for delayed 'til runtime POSIX defns"
with MSVC 2008 64, before
miniperl.exe disk file size 1761KB .rdata virtual size 0xBC354 bytes
perl527.dll disk file size 2040KB .rdata virtual size 0xC9421 bytes
after this commit
miniperl.exe disk file size 1761KB .rdata virtual size 0xBC2C4 bytes
perl527.dll disk file size 2040KB .rdata virtual size 0xC9381 bytes
~144 bytes saved by removing unused copies of swash_property_names array.
There are other cases of large duplicate static const data vars still in
the perl527.dll binary but this patch covers a very simple case.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These are useful if you know you have a variable with a restricted range,
and so could fit in a byte or 16 bits, but speed is more important.
These C99 typedefs allows you to specify the minimal size you need, and
allows the compiler to substitute a wider type if it is faster.
This commit adds typedefs spelled the same as the C99 ones, but upper
cased. On non-C99 compilers, it just uses 'int' behind the scenes,
which should be safe.
These are currently restricted to core to be sure these aren't a bad
idea before they are made public.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On systems that don't have them, this emulates
U?INT(16|32)_C
U?INTMAX_C
and the typedefs
u?intmax_t
Since, these are typedefs that can't be tested for if they exist, this
creates PERL_U?INTMAX_T typedefs instead, setting them to the standard
values in stdint.h if it is available.
In addition, it moves the pre-existing emulation of U?INT64_C from
handy.h to perl.h. This is because there was duplicate-ish logic in the
two files, and the handy.h version appears to be better thought out.
It converts the couple of places in core that were using the other
deleted logic to instead use the C99 names.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Because HAS_QUAD is not defined outside the perl core, this macro was
not getting defined properly for 64-bit systems. This means, for
example, that someone using this to cast could end up with the wrong
answer. For example isASCII(2**32) would yield true, because the high
bit would get dropped by the cast, making the value appear to be zero.
This unfortunately creates a warning message in the compile that
WIDEST_UTYPE is redefined, as the definition of that is defective in
PPPort. It should only define it if it wasn't previously defined, and
it is wrongly using the 32 bit version. This is added impetus to get
PPPort fixed
|
|
|
|
|
|
|
|
|
|
|
|
| |
The ones corresponding to shorter sizes, like I32, are available
everywhere. There is no reason to restrict just the 64 variety.
This fixes the bug in the definition for INT64_C and UINT64_C which
caused these to not be defined outside core on some platforms, such as
Windows.
See commit 3edba68397e487b39cca6e7fc0b75ab4a2f6a341 for more
explanation
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These are steadily being used in more and more macros that are
available to extensions as well as core, but the use of Perl's
home-grown versions (for when we don't get them from stdint.h)
has depended on the definition of HAS_QUAD. However, HAS_QUAD
is explicitly turned off in perl.h when PERL_CORE is not defined,
and has warnings about widespread breakage if that undef were to
be removed (referring to RT #119753). So extensions that use
macros that in turn use INT64_C or UINT64_C were failing to
build.
So in order to know that 64-bit integers are available without
using the HAS_QUAD macro that was intended for just that purpose,
use QUADKIND as a way of saying "We know we had HAS_QUAD before
you hid it from us." Ugh.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
When giving a function-style prototype for a macro taking a literal string
parameter, put a string literal in place of a type for that parameter.
This goofy appearance makes it obvious that this isn't really a function,
and clues the reader in that the parameter can't actually be an arbitrary
expression of the right type. Also change the nonsensical "NUL-terminated
literal string" to "literal string" to describe these parameters.
Fixes [perl #116286].
|
|
|
|
| |
This reverts commit 004073bac990d90244eb463f435c52d4040b36df.
|
| |
|
| |
|
|
|
|
|
|
|
| |
Also:
- factor out common expression
- remove redundant double parens
- add spaces to expression
|
|
|
|
|
| |
This adds a description of the naming conventions to be used for any new
string comparison macros.
|
|
|
|
| |
Until we decide these weren't a bad idea
|
|
|
|
| |
For consistency
|
|
|
|
| |
All uses of these private macros have been replaced by other calls.
|
|
|
|
| |
This corresponds to memBEGINPs
|
|
|
|
|
|
| |
This macro is like memBEGINs(), but the 'P' signifies we want a proper
substring, meaning that the 2nd string parameter must not be the entire
first parameter.
|
|
|
|
|
|
|
|
|
| |
memBEGINs() is like strBEGINs(), but can be used for buffers without
trailing NULs. It can also be used when there is a trailing NUL, and
the length is known, as it should be somewhat faster, only having to
check for one ending condition.
Same for memENDs vs strENDs
|
|
|
|
|
|
|
|
|
|
| |
The original names are confusing.
See thread beginning with
http://nntp.perl.org/group/perl.perl5.porters/244335
The two macros are mapped into just that one, complementing the result
for the few cases where strNEs was used.
|
|
|
|
|
| |
This guarantees the expected precedence no matter what the context it is
called in.
|
| |
|
| |
|
|
|
|
|
|
|
| |
"Sane" means that it works correctly on bytes with their high bit set, as
C89 also requires.
We therefore no longer need to probe for and/or use BSD bcmp().
|
|
|
|
| |
This means we also never need to consider using BSD bzero().
|
|
|
|
|
| |
At least for now, we retain the StructCopy() macro, but its definition
always just uses struct assignment.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In f14cf363205 we added asserts to our memory macros (Copy(), Zero() etc)
to ensure that the target is non-null. These asserts throw warnings like
perl.c: In function ‘Perl_eval_sv’:
perl.c:2976:264: warning: the address of ‘myop’ will always evaluate
as ‘true’ [-Waddress]
Zero(&myop, 1, UNOP);
which is annoying. This patch changes how these asserts are coded so
we avoid the warning. Thanks to Zefram for the fix.
|
|
|
|
| |
ALign some things vertically for easier reading
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These functions depend on C library functions which have undefined
behaviour when passed NULL pointers, even when passed a zero 'n' value.
Some compilers use this information, ie. assume the pointers are
non-NULL when optimizing any following code, so we do need to
prevent such unguarded calls.
My initial thought was to add conditionals to each macro to skip the
call to the library function when n is zero, but this adds a cost to
every use of these macros, even when the n value is always true.
So instead I added asserts() which will give us a much more visible
indicator of such broken code and revealed the pp_caller and Glob.xs
issues also patched here.
|