summaryrefslogtreecommitdiff
path: root/malloc.c
Commit message (Collapse)AuthorAgeFilesLines
* Correct typos as per GH 20435James E Keenan2022-12-291-1/+1
| | | | | | | | | | | | | | | | | | | In GH 20435 many typos in our C code were corrected. However, this pull request was not applied to blead and developed merge conflicts. I extracted diffs for the individual modified files and applied them with 'git apply', excepting four files where patch conflicts were reported. Those files were: handy.h locale.c regcomp.c toke.c We can handle these in a subsequent commit. Also, had to run these two programs to keep 'make test_porting' happy: $ ./perl -Ilib regen/uconfig_h.pl $ ./perl -Ilib regen/regcomp.pl regnodes.h
* perlapi: Mark internal and better document some memory fcnsKarl Williamson2022-05-181-4/+27
| | | | | | | | | Perl_(([cm]|re)alloc|mfree) should not be used by the public; instead there are macros that these implement. The *alloc functions weren't documented, because of an erroneous assumption; erroneous because all require the Perl_ preface to call them.
* perlapi: Document dump_mstatsKarl Williamson2022-05-121-6/+14
|
* replace all instances of PERL_IMPLICIT_CONTEXT with MULTIPLICITYTomasz Konojacki2021-06-091-2/+2
| | | | | | | | | | | | Since the removal of PERL_OBJECT (acfe0abcedaf592fb4b9cb69ce3468308ae99d91) PERL_IMPLICIT_CONTEXT and MULTIPLICITY have been synonymous and they're being used interchangeably. To simplify the code, this commit replaces all instances of PERL_IMPLICIT_CONTEXT with MULTIPLICITY. PERL_IMPLICIT_CONTEXT will stay defined for compatibility with XS modules.
* style: Detabify indentation of the C code maintained by the core.Michael G. Schwern2021-01-171-885/+885
| | | | | | | | | | | This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
* autodoc.pl: Specify scn for single-purpose filesKarl Williamson2020-11-061-1/+0
| | | | | | | | Many of the files in perl are for one thing only, and hence their embedded documentation will be for that one thing. By creating a hash here of them, those files don't have to worry about what section that documentation goes under, and so it can be completely changed without affecting them.
* Reorganize perlapiKarl Williamson2020-09-041-0/+1
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* Fixes typo from d223e1ea9ae864c0e563187f1e76240ef1acad87Ryan Voots2020-07-221-1/+1
| | | | | | | | | | | | | | | This breaks in malloc.c when configured using the Perl malloc implementation i.e. -Dusemymalloc End result is this when linking: /usr/bin/ld: malloc.o: in function `Perl_mfree': malloc.c:(.text+0x98): undefined reference to `nBITMASK' /usr/bin/ld: malloc.c:(.text+0xb9): undefined reference to `nBITMASK' /usr/bin/ld: malloc.c:(.text+0xd3): undefined reference to `nBITMASK' /usr/bin/ld: malloc.c:(.text+0x138): undefined reference to `nBITMASK' /usr/bin/ld: malloc.o: in function `Perl_malloced_size': malloc.c:(.text+0x1fc): undefined reference to `nBITMASK' /usr/bin/ld: malloc.o:malloc.c:(.text+0x328): more undefined references to `nBITMASK' follow
* Remove use of dVAR in coreDagfinn Ilmari Mannsåker2020-07-201-6/+0
| | | | | It only does anything under PERL_GLOBAL_STRUCT, which is gone. Keep the dNOOP defintion for CPAN back-compat
* handy.h: Create nBIT_MASK(n) macroKarl Williamson2020-07-171-2/+2
| | | | | This encapsulates a common paradigm, making sure that it is done correctly for the platform's size.
* malloc.c: Fix compiler warnings/errorKarl Williamson2020-03-091-7/+10
| | | | This needed a const to compile, and there were warnings as well.
* malloc.c: Use isDIGIT macro instead of hand-rolling itKarl Williamson2019-11-111-1/+1
| | | | The macro is more efficient
* Note that [cm]alloc, realloc are documentedKarl Williamson2019-09-021-0/+9
| | | | As they are really Unix calls
* PATCH: [perl #134126] -Dusemymalloc, -DusethreadsKarl Williamson2019-05-241-0/+1
| | | | | This was due to a missing declaration for thread context needed to output a message.
* malloc.c: Move variable declaration used in -DDEBUGGING above code, #134071Ryan Voots2019-04-291-4/+3
|
* malloc.c: Limit malloc size to PTRDIFF_MAXKarl Williamson2019-02-161-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without doing this, it is possible that the behavior is undefined when subtracting two pointers that point to the same object. See thread beginning at http://nntp.perl.org/group/perl.perl5.porters/251541 In particular this from Tomasz Konojacki C11 says: > When two pointers are subtracted, both shall point to elements of the > same array object, or one past the last element of the array object; > the result is the difference of the subscripts of the two array > elements. The size of the result is implementation-defined, and its > type (a signed integer type) is ptrdiff_t defined in the <stddef.h> > header. If the result is not representable in an object of that type, > the behavior is undefined. There are many ways to interpret this passage, but according to (most?) C compilers developers, it means that no object can be larger than PTRDIFF_MAX. For example, gcc's optimizer assummes that strlen() will never return anything larger than PTRDIFF_MAX [1]. There's also a blogpost[2] on this topic, which IMO is a very interesting read. If gcc and clang can assume that all objects won't be larger than PTRDIFF_MAX, so can we. Also, in practice, ssize_t and ptrdiff_t on most (all?) platforms are defined as exactly the same type. BTW, the fact that compilers assume that objects can't be larger than PTRDIFF_MAX has very dangerous implications on 32-bit platforms. Is it possible to create string longer than PTRDIFF_MAX on 32-bit perls?. It shouldn't be allowed. [1] - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78153 [2] - https://trust-in-soft.com/objects-larger-than-ptrdiff_max-bytes/
* in malloc, compute memory sizes in size_tZefram2017-12-011-6/+6
| | | | | | | | Some size computations were using the wrong data type, in particular getting a signed 32-bit type where unsigned 64-bit is required on LP64 systems. That resulted in truncation and in sign extension during later conversion to the correct type, either way producing bogus sizes. Fix by casting everything to size_t suitably early. Fixes [perl #119829].
* malloc.c: Fix typo in commentKarl Williamson2017-11-091-1/+1
|
* malloc.c: simplify cpp conditionalsAaron Crane2017-10-211-3/+1
|
* malloc.c: don't redefine START_EXTERN_C from perl.hAaron Crane2017-10-211-16/+0
|
* Change white space to avoid C++ deprecation warningKarl Williamson2016-11-181-14/+24
| | | | | | | | | | | | | | | | | | | | | | C++11 requires space between the end of a string literal and a macro, so that a feature can unambiguously be added to the language. Starting in g++ 6.2, the compiler emits a warning when there isn't a space (presumably so that future versions can support C++11). Unfortunately there are many such instances in the perl core. This commit fixes those, including those in ext/, but individual commits will be used for the other modules, those in dist/ and cpan/. This commit also inserts space at the end of a macro before a string literal, even though that is not deprecated, and removes useless "" literals following a macro (instead of inserting a blank). The result is easier to read, making the macro stand out, and be clearer as to the intention. Code and modules included with the Perl core need to be compilable using C++. This is so that perl can be embedded in C++ programs. (Actually, only the hdr files need to be so compilable, but it would be hard to test that just the hdrs are compilable.) So we need to accommodate changes to the C++ language.
* Give a better error if malloc.c is used without MYMALLOCJarkko Hietaniemi2015-08-101-0/+4
| | | | | | | | | | | | | | | The build will die already on errors because of the missing ASSERT macros (plus get warnings on the implicit declarations, i.e. missing prototypes), but better to give a clear error. FWIW, looking at hints/*, only HP-UX of the even remotely common/current systems seems to use Perl's malloc anymore, and then only if perlio is NOT being used. (Other platforms that seemingly use Perl's malloc include ancient SysVs like SCO 2.3.4, NCR Tower, Tektronix' UTek V, then Unicos and Unicos/mk of Cray, and NEC's SUPER-UX.) (OS/2 still probably does use it, given all the work ilyaz used to pour on it.)
* Replace common Emacs file-local variables with dir-localsDagfinn Ilmari Mannsåker2015-03-221-6/+0
| | | | | | | | | | | | | | | | An empty cpan/.dir-locals.el stops Emacs using the core defaults for code imported from CPAN. Committer's work: To keep t/porting/cmp_version.t and t/porting/utils.t happy, $VERSION needed to be incremented in many files, including throughout dist/PathTools. perldelta entry for module updates. Add two Emacs control files to MANIFEST; re-sort MANIFEST. For: RT #124119.
* [perl #123814] replace grok_atou with grok_atoUVHugo van der Sanden2015-03-091-2/+2
| | | | | | | | | | | | Some questions and loose ends: XXX gv.c:S_gv_magicalize - why are we using SSize_t for paren? XXX mg.c:Perl_magic_set - need appopriate error handling for $) XXX regcomp.c:S_reg - need to check if we do the right thing if parno was not grokked Perl_get_debug_opts should probably return something unsigned; not sure if that's something we can change.
* Corrections to spelling and grammatical errors.Lajos Veres2015-01-281-1/+1
| | | | Extracted from patch submitted by Lajos Veres in RT #123693.
* make more use of NOT_REACHEDLukas Mai2014-11-291-1/+1
| | | | In particular, remove all instances of 'assert(0);'.
* Use grok_atou instead of atoi.Jarkko Hietaniemi2014-07-221-2/+2
| | | | | Remaining atoi() uses include at least: ext/DynaLoader/dl_aix.xs, os2/os2.c, vms/vms.c
* Revert "/* NOTREACHED */ belongs *before* the unreachable."Jarkko Hietaniemi2014-06-191-2/+1
| | | | | | This reverts commit 148f39b7de6eae9ddd59e0b0aff691d6abea7aca. (Still needs more work, but wanted to see how well this passed with Jenkins.)
* /* NOTREACHED */ belongs *before* the unreachable.Jarkko Hietaniemi2014-06-191-1/+2
| | | | | | Definitely not *after* it. It marks the start of the unreachable, not the first unrechable line. And if they are in that order, it looks better to linebreak after the lint hint.
* Added several missing PERL_UNUSED_RESULT()Brian Fraser2014-06-131-1/+1
|
* Removed set_emergency_buffer from malloc.cBrian Fraser2014-06-131-18/+0
| | | | This was added in 2003, but never used.
* Removed NeXT supportBrian Fraser2014-06-111-1/+1
|
* Remove HAS_64K_LIMITBrian Fraser2013-09-211-10/+1
| | | | | | This was only defined for MSDOS if not using DJGPP. We've long since dropped support for that, so this define and related code can go.
* add adjust_size_and_find_bucket to embed.fncLukas Mai2013-08-111-5/+9
|
* Function name typo in malloc.cSergey Alekseev2013-08-101-3/+3
| | | | | | Error was also spotted by mauke. For: RT #119213
* Remove "register" declarationsKarl Williamson2012-11-241-3/+3
| | | | | | | This finishes the removal of register declarations started by eb578fdb5569b91c28466a4d1939e381ff6ceaf4. It neglected the ones in function parameter declarations, and didn't include things in dist, ext, and lib, which this does include
* Restore mymalloc build with ithreadsSteve Hay2012-09-211-0/+1
| | | | Broken by commit 7cd83f6573.
* Out of memory message should not allocate memory.Craig A. Berry2012-09-081-23/+20
| | | | | | | | | | | | This fixes [perl #40595]. When Perl_malloc reports an out of memory error, it should not make calls to PerlIO functions that may turn around and allocate memory using Perl_malloc. A simple write() should be ok, though. Inspired by S_write_no_mem() from util.c. Also replaces the local write2 function, which did the same thing slightly differently. Under -DDEBUGGING, there are other calls to PerlIO_printf that are also likely unsafe, but that problem is not addressed here.
* Omnibus removal of register declarationsKarl Williamson2012-08-181-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes most register declarations in C code (and accompanying documentation) in the Perl core. Retained are those in the ext directory, Configure, and those that are associated with assembly language. See: http://stackoverflow.com/questions/314994/whats-a-good-example-of-register-variable-usage-in-c which says, in part: There is no good example of register usage when using modern compilers (read: last 10+ years) because it almost never does any good and can do some bad. When you use register, you are telling the compiler "I know how to optimize my code better than you do" which is almost never the case. One of three things can happen when you use register: The compiler ignores it, this is most likely. In this case the only harm is that you cannot take the address of the variable in the code. The compiler honors your request and as a result the code runs slower. The compiler honors your request and the code runs faster, this is the least likely scenario. Even if one compiler produces better code when you use register, there is no reason to believe another will do the same. If you have some critical code that the compiler is not optimizing well enough your best bet is probably to use assembler for that part anyway but of course do the appropriate profiling to verify the generated code is really a problem first.
* Remove code for supporting 80286 based systems.Nicholas Clark2012-07-281-14/+2
| | | | | | | | The 80286 was released two years before Perl 1, but the support code was added with Perl 3. The chip hasn't been produced for more than 15 years - even the 80386 hasn't been manufactured since 2007. Most of the other memory model code was removed by commit 5869b1f143426909 in Sep 2000, so support for 16 bit systems is long dead.
* Remove dead code related to the Atari ST port of perl 4.0 patchlevel 19Nicholas Clark2012-07-281-5/+3
| | | | | The subdirectory containing the port specific files was purged when 5.000 was released, but changes made to other files were not removed.
* fix compile warnings in malloc.c [perl #75340]Jesse Luehrs2012-07-031-2/+2
|
* Use assertions for /* NOT REACHED */Father Chrysostomos2012-06-151-1/+1
| | | | to make sure it really is never reached.
* update the editor hints for spaces, not tabsRicardo Signes2012-05-291-2/+2
| | | | | This updates the editor hints in our files for Emacs and vim to request that tabs be inserted as spaces.
* Remove "support" for using malloc.c outside the perl core distribution.Nicholas Clark2011-12-091-224/+20
| | | | | | | | | | | | | | It only ever worked properly in 5.005. Commit d720c4410d3a0730 from June 1998 is the first known version of malloc.c that would compile stand alone, without needing a config.h Commit 5bbd1ef51ee0ebfa from December 1998 will not compile by default, but will if one provides suitable definitions of simple macros on the command line. Commit 427181846486e3aa from September 1999 will not compile with command line flags alone. 12 years later, no-one has reported problems, so it's safe to remove this.
* Remove commented-out "support" for perl's malloc with x2p.Nicholas Clark2011-12-091-5/+2
| | | | | | | | | | In 1998 commit 30e2e4257067d5f8 stated temporarily disable perl malloc for a2p until we clean up conflicting malloc() declarations everywhere and nothing has changed since. 13 years later, no-one has reported problems, so it's safe to remove it.
* Convert some files from Latin-1 to UTF-8Keith Thompson2011-09-071-1/+1
|
* Remove WITH_THR() and WITH_THX(), which are not used.Nicholas Clark2011-09-041-1/+0
| | | | | | | | | | | | grep.cpan.me and Google's codesearch find no use of WITH_THR or WITH_THX. WITH_THX() was added in June 1999 in cea2e8a9dd23747f, and the last user eliminated with 0b250b9ef0d5134f in August 1999. WITH_THX() was used again for DEBUG_CX() in 1c98cc53150c4860, and eliminated in d9f81b50694a810f. WITH_THR() was added in 1997 in 0f15f207c55ce70f. Use everywhere except DEBUG_SCOPE() was eliminated in 2006 in 11206fddaf7ef068. WITH_THR() was removed from DEBUG_SCOPE() in d9f81b50694a810f.
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-4/+4
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81904] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81904 > Signed-off-by: Abigail <abigail@abigail.be>
* Add Perl_ck_warner_d(), which combines Perl_ckwarn_d() and Perl_warner().Nicholas Clark2009-10-121-14/+14
| | | | | Replace ckWARN_d{,2,3,4}() && Perl_warner() with it, which trades reduced code size for 1 more function call if warnings are not enabled.