summaryrefslogtreecommitdiff
path: root/handy.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove obsolete variablesKarl Williamson2018-03-311-13/+7
| | | | | 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.
* Remove no longer used constant and #if checks.Karl Williamson2018-03-311-25/+0
| | | | This is now obsolete as a result of the last few commits.
* rmv/de-dup static const char array "strings"Daniel Dragan2018-03-071-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* remove unreferenced copies of char * swash_property_names[]Daniel Dragan2018-02-271-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* handy.h: Add commentKarl Williamson2018-01-171-0/+1
|
* Emulate C99 int_fast8_t, etc typedefsKarl Williamson2017-12-181-0/+20
| | | | | | | | | | | | | | 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.
* Emulate some C99 macros and typedefsKarl Williamson2017-12-081-49/+0
| | | | | | | | | | | | | | | | | | | | | | 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.
* handy.h: Fix definition of WIDEST_UTYPE for non-coreKarl Williamson2017-12-071-5/+3
| | | | | | | | | | | | | | 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
* handy.h: Make U64, I64 available outside coreKarl Williamson2017-12-071-1/+1
| | | | | | | | | | | | 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
* remove stray NULLOK/NN from apidoc directivesZefram2017-12-061-1/+1
|
* Try harder to define INT64_C and UINT64_C.Craig A. Berry2017-11-301-1/+7
| | | | | | | | | | | | | | | | | 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.
* handy.h: add a comment about perl_assert_ptr()Yves Orton2017-11-161-0/+3
|
* better document macros taking literal stringsZefram2017-11-121-31/+31
| | | | | | | | | | 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].
* Revert "Simplify _MEM_WRAP_NEEDS_RUNTIME_CHECK()"Lukas Mai2017-11-111-1/+2
| | | | This reverts commit 004073bac990d90244eb463f435c52d4040b36df.
* fix MEM_SIZE_MAX definitionLukas Mai2017-11-111-1/+1
|
* handy.h: Clarify commentKarl Williamson2017-11-091-2/+3
|
* PERL_STRLEN_ROUNDUP: parenthesize macro parameterLukas Mai2017-11-081-2/+3
| | | | | | | Also: - factor out common expression - remove redundant double parens - add spaces to expression
* handy.h: Add commentsKarl Williamson2017-11-061-0/+45
| | | | | This adds a description of the naming conventions to be used for any new string comparison macros.
* Make new macros privateKarl Williamson2017-11-061-2/+6
| | | | Until we decide these weren't a bad idea
* handy.h: Make uniform the defns of strFOO, memFOOKarl Williamson2017-11-061-6/+6
| | | | For consistency
* Remove _memEQs, _memNEsKarl Williamson2017-11-061-6/+0
| | | | All uses of these private macros have been replaced by other calls.
* Add memENDPs and use it in coreKarl Williamson2017-11-061-0/+3
| | | | This corresponds to memBEGINPs
* Add memBEGINPs() to core and use itKarl Williamson2017-11-061-0/+3
| | | | | | 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.
* Add memBEGINs(), memENDs() and use them in APItestKarl Williamson2017-11-061-0/+7
| | | | | | | | | 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
* Rename strEQs to strBEGINs; remove strNEsKarl Williamson2017-11-061-7/+1
| | | | | | | | | | 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.
* handy.h: Add parens around macro expansionKarl Williamson2017-10-241-1/+1
| | | | | This guarantees the expected precedence no matter what the context it is called in.
* Rely on C89 NULLAaron Crane2017-10-211-7/+0
|
* handy.h: simplify cpp conditionalsAaron Crane2017-10-211-25/+17
|
* Assume we have sane C89 memcmp()Aaron Crane2017-10-211-7/+2
| | | | | | | "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().
* Assume we have C89 memset()Aaron Crane2017-10-211-5/+0
| | | | This means we also never need to consider using BSD bzero().
* Remove USE_STRUCT_COPY in favour of C89 struct assignmentAaron Crane2017-10-211-4/+0
| | | | | At least for now, we retain the StructCopy() macro, but its definition always just uses struct assignment.
* avoid 'the address of ... will always evaluate as ...' warns in mem macrosYves Orton2017-09-131-7/+10
| | | | | | | | | | | | | 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.
* handy.h: White space onlyKarl Williamson2017-09-091-4/+4
| | | | ALign some things vertically for easier reading
* (perl #131746) avoid undefined behaviour in Copy() etcTony Cook2017-09-041-7/+7
| | | | | | | | | | | | | | | | | 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.
* Use new paradigm for hdr file double inclusion guardKarl Williamson2017-06-021-3/+3
| | | | | | | | | | We changed to use symbols not likely to be used by non-Perl code that could conflict, and which have trailing underbars, so they don't look like a regular Perl #define. See https://rt.perl.org/Ticket/Display.html?id=131110 There are many more header files which are not guarded.
* handy.h: Guard controversial macro nameKarl Williamson2017-02-191-0/+5
| | | | | This is so their use cannot spread easily until we have sorted things out in 5.27
* There's an objection to fatalizing jumping into a construct.Abigail2017-01-161-0/+2
| | | | | | | | This reverts commit 84b32f52b10f9912b40ef378cd0b01f4aff80630. This reverts commit d30393aaade31b605724846a30a10dd1e96cd181. We need more debate on this one; either we should undeprecate it, or settle on an end-of-life version.
* Remove the deprecate() macro from handy.h.Abigail2017-01-161-2/+0
| | | | | | | Since we now require each deprecation message to come with a version in which the feature will disappear, and we have reworked the existing uses of this macro, there doesn't seem to be a need for this one anymore.
* Setting ${^ENCODE} will be fatal by 5.28.Abigail2017-01-161-0/+3
| | | | | Hence, we adapted the warning, to mention the version in which it will become a fatal error.
* Time limit the deprecation of :unique and :locked.Abigail2017-01-161-0/+3
| | | | | | | | | | | | | | | | The :unique and :locked attributes have had no effect since 5.8.8 and 5.005 respectively. They were deprecated in 5.12. They are now scheduled to be deleted in 5.28. There are two places the deprecation warning can be issued: in lib/attributes.pm, and in toke.c. The warnings were phrased differently, but since we're changing the warning anyway (as we added the version of Perl in which the attributes will disappear), we've used the same phrasing for this warning, regardless of where it is generated: Attribute "locked" is deprecated, and will disappear in Perl 5.28 Attribute "unique" is deprecated, and will disappear in Perl 5.28
* handy.h: Add missing right paren in macroKarl Williamson2016-12-291-1/+1
| | | | This only affected EBCDIC builds, causing syntax errors.
* Fix tiny POD typoAaron Crane2016-12-291-1/+1
|
* Deprecate toFOO_utf8()Karl Williamson2016-12-231-8/+36
| | | | Now that there are _safe versions, deprecate the unsafe ones.
* Convert core to use toFOO_utf8_safe()Karl Williamson2016-12-231-9/+9
|
* Add toFOO_utf8_safe() macrosKarl Williamson2016-12-231-16/+66
|
* For character case changing, create macros and useKarl Williamson2016-12-231-0/+6
| | | | | This creates several macros that future commits will use to provide a layer between the caller and the function.
* perlapi: Italicize some C<text> that isn't as-isKarl Williamson2016-12-231-18/+18
| | | | | This text appears in the middle of C<>, but is meant to be substituted for, instead of being typed in as-is.
* handy.h: White-space, comment onlyKarl Williamson2016-12-231-7/+10
|
* Deprecate isFOO_utf8() macrosKarl Williamson2016-12-231-83/+68
| | | | | | These macros are being replaced by a safe version; they now generate a deprecation message at each call site upon the first use there in each program run.
* Add isFOO_utf8_safe() macrosKarl Williamson2016-12-231-54/+237
| | | | | | | | | | | | | | | | The original API does not check that we aren't reading beyond the end of a buffer, apparently assuming that we could keep malformed UTF-8 out by use of gatekeepers, but that is currently impossible. This commit adds "safe" macros for determining if a UTF-8 sequence represents an alphabetic, a digit, etc. Each new macro has an extra parameter pointing to the end of the sequence, so that looking beyond the input string can be avoided. The macros aren't currently completely safe, as they don't test that there is at least a single valid byte in the input, except by an assertion in DEBUGGING builds. This is because typically they are called in code that makes that assumption, and frequently tests the current byte for one thing or another.