summaryrefslogtreecommitdiff
path: root/malloc.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Removed vestigal support for Tenon Intersystems MachTen Unix layer for MacOS ↵Jesse Vincent2009-08-031-3/+3
| | | | | | Classic. Perl hasn't supported MachTen since 5.6.
* Remove the port to MiNT. It's a dead platform that hasn't had any love ↵Jesse Vincent2009-08-031-4/+4
| | | | since 5.005
* PATCH: Large omnibus patch to clean up the JRRT quotesTom Christiansen2008-11-021-1/+3
| | | | | | Message-ID: <25940.1225611819@chthon> Date: Sun, 02 Nov 2008 01:43:39 -0600 p4raw-id: //depot/perl@34698
* Make C++ compilers happy #5: jump to 'do_write' crossedMarcus Holland-Moritz2008-10-251-4/+4
| | | | | | | initialization in dTHX. Plus some consting, which also makes C++ happier. p4raw-id: //depot/perl@34579
* Fix malloc.c warningJerry D. Hedden2008-06-231-1/+1
| | | | | | From: "Jerry D. Hedden" <jdhedden@cpan.org> Message-ID: <1ff86f510806230641x37afed4bla697e381b3ba9d6d@mail.gmail.com> p4raw-id: //depot/perl@34078
* Re: [perl #46381] "Out of memory ... sbrk()" on FreeBSD-6.x for v.5.8.x but ↵Slaven Rezic2008-06-211-0/+2
| | | | | | | not v.5.6.x Message-ID: <874pgd6hxs.fsf@biokovo-amd64.herceg.de> p4raw-id: //depot/perl@34076
* Silence warning introduced by #32703 when building with MYMALLOCSteve Hay2008-03-061-1/+1
| | | p4raw-id: //depot/perl@33450
* [perl #46957] [PATCH] make Devel::Peek::mstat always availablesrezic@cpan.org2008-03-031-0/+4
| | | | | | From: srezic@cpan.org (via RT) <perlbug-followup@perl.org> Message-ID: <rt-3.6.HEAD-4732-1193510037-297.46957-75-0@perl.org> p4raw-id: //depot/perl@33414
* Add Perl_malloc_good_size to malloc.c. (A routine that rounds up the Nicholas Clark2008-02-271-16/+34
| | | | | | passed in request to the size that will actually be allocated. It's the same interface as Darwin already provides with malloc_good_size().) p4raw-id: //depot/perl@33389
* assert() that every NN argument is not NULL. Otherwise we have theNicholas Clark2008-02-121-0/+7
| | | | | | | | | | | | ability to create landmines that will explode under someone in the future when they upgrade their compiler to one with better optimisation. We've already done this at least twice. (Yes, some of the assertions are after code that would already have SEGVd because it already deferences a pointer, but they are put in to make it easier to automate checking that each and every case is covered.) Add a tool, checkARGS_ASSERT.pl, to check that every case is covered. p4raw-id: //depot/perl@33291
* Purge all use of Nullch in non-dual life modules.Nicholas Clark2008-01-231-3/+0
| | | | | Exterminate! Exterminate! Exterminate! p4raw-id: //depot/perl@33052