summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/malloc.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a missing THREAD_UNLOCK() found missing by Valentin NechayevPoul-Henning Kamp2000-04-101-3/+1
| | | | | | | | | | <netch@segfault.kiev.ua> Remove allocation failure check from 'A' option, the 'X' option does this as a standalone check now. Notes: svn path=/head/; revision=59117
* Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),Jason Evans2000-01-271-9/+9
| | | | | | | | | | | | | | | | | | | | just use _foo() <-- foo(). In the case of a libpthread that doesn't do call conversion (such as linuxthreads and our upcoming libpthread), this is adequate. In the case of libc_r, we still need three names, which are now _thread_sys_foo() <-- _foo() <-- foo(). Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(), nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo(). Remove all internal libc usage of: creat(), pause(), sleep(), system(), tcdrain(), wait(), and waitpid(). Make thread cancellation fully POSIX-compliant. Suggested by: deischen Notes: svn path=/head/; revision=56698
* Add three-tier symbol naming in support of POSIX thread cancellationJason Evans2000-01-121-10/+9
| | | | | | | | | points. For library functions, the pattern is __sleep() <-- _libc_sleep() <-- sleep(). The arrows represent weak aliases. For system calls, the pattern is _read() <-- _libc_read() <-- read(). Notes: svn path=/head/; revision=55837
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50476
* Back out previous commit after discussing it with Dmitrij Tejblum.Dag-Erling Smørgrav1999-07-071-4/+0
| | | | Notes: svn path=/head/; revision=48672
* Always set errno to ENOMEM when returning 0 from malloc() or realloc().Dag-Erling Smørgrav1999-07-071-1/+5
| | | | | | | Approved by: phk Notes: svn path=/head/; revision=48670
* Disable the "Hint" option in phkmalloc as default. Recent VM systemPoul-Henning Kamp1999-03-281-2/+2
| | | | | | | | | | | | | | | changes have made this too expensive. This gains about 1.25% on worldstone on my SMP machine. Swap-less machines, for instance PicoBSDs, and machines which experience page-out trafic, check with top(1), will probably want to reenable this with: ln -s H /etc/malloc.conf Suggested by: alc (&dyson ?) Notes: svn path=/head/; revision=45091
* Delete the XXX comments that refer to spinlock recursion. The malloc/free/John Birrell1998-09-301-15/+1
| | | | | | | | | | | | realloc functions check for recursion within the malloc code itself. In a thread-safe library, the single spinlock ensures that no two threads go inside the protected code at the same time. The thread implementation is responsible for ensuring that the spinlock does in fact protect malloc. There was a window of opportunity in which this was not the case. I'll fix that with a commit RSN. Notes: svn path=/head/; revision=39802
* Use 8k pagesize on alpha, not 4k.Doug Rabson1998-09-231-1/+5
| | | | Notes: svn path=/head/; revision=39606
* Back out part of previous commit (even though it's technically correct).Alexander Langer1998-09-201-1/+17
| | | | | | | | | | | | | | Our spinlock implementation allows a particular thread to obtain a lock multiple times, but release the lock with a single unlock call. Since we're detecting recursion, we know the lock is already owned by the current thread in a previous call and must not be released in the current call. This is really far too dependent on this particular spinlock implementation, so I've added commented out calls to THREAD_UNLOCK in the appropriate places. We can activate this code when spinlock is taught to count each lock operation. Notes: svn path=/head/; revision=39501
* Correctly back out of free if a recursive call into malloc.c is detected.Alexander Langer1998-09-191-8/+7
| | | | | | | | | Set malloc_func *after* grabbing the thread lock. Noticed by: Simon Coggins <simon@oz.org> Notes: svn path=/head/; revision=39491
* preserve errno across the readlink() calls. There is no value in trashingPeter Wemm1998-06-181-1/+4
| | | | | | | errno during a successful malloc() call. Notes: svn path=/head/; revision=37048
* Add support for thread lock debug. No impact of the malloc code.John Birrell1998-06-091-4/+4
| | | | Notes: svn path=/head/; revision=36804
* Replace the threaded locking with spinlock calls for both threadedJohn Birrell1998-04-291-18/+10
| | | | | | | | | | and non-threaded programs. This makes malloc thread safe for linking with libpthread and kernel threads. Reviewed by: phk Notes: svn path=/head/; revision=35503
* Change in name of the static initializer define.John Birrell1998-04-041-2/+2
| | | | Notes: svn path=/head/; revision=35026
* NetBSD doesn't have a utrace syscall, so don't define that ifJohn Birrell1998-03-091-2/+4
| | | | | | | __NETBSD_SYSCALLS is defined. Notes: svn path=/head/; revision=34382
* Drop the use of caddr_t in conjunction with mmap(2).Alexander Langer1997-12-311-4/+4
| | | | Notes: svn path=/head/; revision=32133
* Fix recursion problem which occurs when a signal is received duringJohn Birrell1997-12-151-3/+12
| | | | | | | | | | a malloc. The signal handler creates a thread which requires a malloc... For now, the only thing to do is to block signals. When we move user pthreads to use the kernel threads, mutexes will be implemented in kernel space and then malloc can revert. Notes: svn path=/head/; revision=31722
* Another 32bits of 64bits conformance.Poul-Henning Kamp1997-08-311-2/+2
| | | | | | | | Reviewed by: phk Submitted by: jdp Notes: svn path=/head/; revision=28952
* Improvement of type independency for the bitmap.Poul-Henning Kamp1997-08-271-3/+4
| | | | | | | | | | This makes 64bit operation more likely. Reviewed by: phk Submitted by: jdp Notes: svn path=/head/; revision=28835
* Malloc option H is now default.Poul-Henning Kamp1997-08-271-2/+2
| | | | Notes: svn path=/head/; revision=28830
* Fix a minor typo. It only affects the sparc version.John Polstra1997-07-261-2/+2
| | | | Notes: svn path=/head/; revision=27698
* Have another go at the malloc-sysv initialization.Poul-Henning Kamp1997-07-021-12/+11
| | | | | | | | PR: 4002 Pointed out by: bde Notes: svn path=/head/; revision=27179
* malloc_sysv used before initialized, reported in PR4002 byPoul-Henning Kamp1997-07-011-33/+19
| | | | | | | | | | | | | | | | | | Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru> Various cleanup from Keith Bostic Reinstate calloc() as a separate funtion, in its own source/object file. leave the manpage integrated with malloc.3 and friends. Too many things were broken in this respect. PR: 4002 Reviewed by: phk Submitted by: Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru> Submitted by: Keith Bostic <bostic@bostic.com> Notes: svn path=/head/; revision=27152
* Integrate calloc with the rest of the gang.Poul-Henning Kamp1997-06-221-150/+93
| | | | | | | | | | | | | | Various portability and stylistic cleanups. Kill MALLOC_STATS & the 'D' option. Fix the 'V' option. Major overhaul of the man-page. You milage should not vary. Reviewed by: Keith Bostic <bostic@bostic.com> Submitted by: Keith Bostic <bostic@bostic.com> Notes: svn path=/head/; revision=26816
* Add yet an option, this time on how to deal with malloc(0) and realloc(ptr.0)Poul-Henning Kamp1997-06-121-5/+9
| | | | | | | Prompted by: X11 & XFree86 Notes: svn path=/head/; revision=26579
* Fix mutex initialization.John Birrell1997-06-041-6/+4
| | | | | | | | | | | | | | | | Malloc cannot use pthread_mutex_init() to initialize a mutex because the mutex initialization process does a malloc! libc_r internals skip the malloc and assign an initializer to a static structure and point the opaque type (pthread_mutex_t in this case) to that structure. This is done on the assumption that the mutex will never be destroyed. This style of initialization is only valid inside libc_r because the structure that is assigned is opaque to the user. This fix allows a simple program to get to main() again. 8-) Notes: svn path=/head/; revision=26444
* Malloc flag X makes malloc behave like the canonical xmalloc() wrapper.Poul-Henning Kamp1997-05-301-18/+56
| | | | | | | | | | Untested support for Solaris from John-Mark Gurney Reviewed by: phk Submitted by: (partially) John-Mark Gurney <gurney_j@resnet.uoregon.edu> Notes: svn path=/head/; revision=26284
* Check for overflow in size argument.Poul-Henning Kamp1997-03-181-2/+4
| | | | | | | | Tested by: Joel Maslak <j@pobox.com> Closes: PR kern/2964 Notes: svn path=/head/; revision=23981
* Revert $FreeBSD$ to $Id$Peter Wemm1997-02-221-1/+1
| | | | Notes: svn path=/head/; revision=22993
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673
* _thread_kern_sig_unblock takes an integer, not a reference.Alexander Langer1996-12-291-2/+2
| | | | | | | Submitted by: John Birrell <jb@cimlogic.com.au> Notes: svn path=/head/; revision=21000
* If you run with option Z and malloc fails, memset gets calledPoul-Henning Kamp1996-10-291-4/+6
| | | | | | | | | | with a NULL pointer (archie) Explain that minsize is also the smallest alignment. Submitted by: Archie Cobbs <archie@whistle.com> Notes: svn path=/head/; revision=19257
* Various cosmeticsPoul-Henning Kamp1996-10-261-48/+28
| | | | | | | | | Improve chances of troublefree 64bit operation. [imp] Noticed by: Warner Losh <imp@village.org> Notes: svn path=/head/; revision=19191
* malloc_pages should be static.Poul-Henning Kamp1996-10-201-187/+103
| | | | | | | | | | | | | | | | | | | Add progname to warning/error message layout. (joerg) Remove inline assembler, no speed impact, not need for the obfuscation (bde) Remove on the fly calculation of parameters, no longer critical. Make D & U flags valid even if we don't support them. Don't call imalloc until we're done initializing. Zap contents on free() if we have "Junk" set. [*] Various nitpicking. [*] As a sideeffect of this change, if you are worried about sensitive data lingering in memory, you can use the 'Junk' option now to make sure phkmalloc zaps memory when it is returned. add char * malloc_options = "J"; to your source. Obviously there is a performance impact. Notes: svn path=/head/; revision=19057
* Fix a typo.Søren Schmidt1996-09-251-2/+2
| | | | | | | Reviewed by: phk Notes: svn path=/head/; revision=18495
* A number of minor bogons and portability things from jdp.Poul-Henning Kamp1996-09-251-28/+37
| | | | | | | Submitted by: jdp Notes: svn path=/head/; revision=18493
* phkmalloc/3Poul-Henning Kamp1996-09-231-189/+232
| | | | | | | | | | | Various neat features added. More documentation in the manpage. If your machine has very little RAM, I guess that would be < 16M these days :-(, you may want to try this: ln -fs 'H<' /etc/malloc.conf check the manpage. Notes: svn path=/head/; revision=18479
* Fix a very rare error condition: The code to free VM back to the kernelPoul-Henning Kamp1996-09-171-3/+4
| | | | | | | | | | as done after a quasi-recursive call to free() had modified what we thought we knew about the last chunk of pages. This bug manifested itself when I did a "make obj" from src/usr.sbin/lpr, then make would coredump in the lpd directory. Notes: svn path=/head/; revision=18333
* Isolated all the crap for thread-safe so I can see what goes on again...Poul-Henning Kamp1996-07-031-61/+48
| | | | Notes: svn path=/head/; revision=16941
* Reviewed by: julian and (hsu?)Julian Elischer1996-01-221-3/+66
| | | | | | | | | Submitted by: John Birrel(L?) changes for threadsafe operations Notes: svn path=/head/; revision=13545
* Fix a fencepost error.Poul-Henning Kamp1996-01-051-4/+4
| | | | | | | Found by: Lars Fredriksen <fredriks@mcs.com> Notes: svn path=/head/; revision=13268
* Preallocate a small structure, so we can sbrk(2) further back.Poul-Henning Kamp1995-12-181-2/+8
| | | | | | | | Reviewed by: phk Submitted by: Kaleb Keithly <kaleb@x.org> Notes: svn path=/head/; revision=12918
* Change phkmalloc so that the page directory is now floating and allocatedPeter Wemm1995-12-111-29/+47
| | | | | | | | | | | | | | | | | | | | | | | | via mmap() up around the shared library area. Previously the directory was allocated from space from it's own memory pool. Because of the way it was being extended on processes with large malloced data segments (ie: inn) once the page directory was extended for some reason, it was not possible to lower the heap size any more to return pages to the OS. (If my understanding is correct, page directory expansion occurs at 4MB, 12MB, 20MB, 28MB, etc.) I was seeing INN allocate a large amount of short term memory, pushing it over the 28MB mark, and once it's transient demands hit 28MB, it never freed it's pages and swap space again.) I've been running this in my libc for about a month... Also, seperate MALLOC_STATS from EXTRA_SANITY.. I found it useful to call malloc_dump() from within INN from a ctlinnd command to see where the hell all the memory was going.. :-) I've left MALLOC_STATS enabled, as it has no run-time or data storage cost. Reviewed by: phk Notes: svn path=/head/; revision=12776
* Remove EXTRA_SANITY, fix a unused var.Poul-Henning Kamp1995-10-221-4/+8
| | | | Notes: svn path=/head/; revision=11665
* phkmalloc/2Poul-Henning Kamp1995-10-081-291/+353
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "zero' and 'junk' options to help find and diagnose malloc abuse. EXTRA_SANITY defaults "junk" to on. Don't dump the internal state, unless EXTRA_SANITY. General code cleanup. Error messages cleaned up a bit, more checking earlier. EXTRA_SANITY is default at this time (just in case). Performance (without EXTRA_SANITY) is better, beats gnumalloc in both time & space most of the time: # In-memory test. ./malloc 50000000 2000 8192 159.2u 1.5s 2:41.85 99.3% 5+7742k 0+0io 0pf+0w ./gnumalloc 50000000 2000 8192 272.6u 0.4s 4:35.01 99.3% 5+8533k 0+0io 0pf+0w # Swap-space test. ./malloc 500000 14000 8192 6.5u 4.1s 4:08.87 4.3% 5+49209k 0+0io 9772pf+0w ./gnumalloc 500000 14000 8192 16.2u 14.5s 15:36.14 3.2% 5+54100k 0+0io 47651pf+0w # Small items test. ./malloc 20000000 20000 2048 67.0u 0.3s 1:07.83 99.2% 5+18199k 0+0io 4pf+0w ./gnumalloc 20000000 20000 2048 66.2u 0.3s 1:07.03 99.3% 5+18107k 0+0io 0pf+0w SANITY is not an option anymore. (!!) Notes: svn path=/head/; revision=11338
* A buglet when dumping and a stylistic point from Mike.Poul-Henning Kamp1995-09-221-8/+8
| | | | | | | Submitted by: Mike Pritchard <mpp@mpp.minn.net> Notes: svn path=/head/; revision=10952
* ``phkmalloc''Poul-Henning Kamp1995-09-161-361/+1006
| | | | | | | | | | Performance is comparable to gnumalloc if you have sufficient RAM, and it screams around it if you don't. Compiled with "EXTRA_SANITY" until further notice. see malloc.3 for more details. Notes: svn path=/head/; revision=10818
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-6/+6
| | | | Notes: svn path=/head/; revision=8870
* BSD 4.4 Lite Lib SourcesRodney W. Grimes1994-05-271-0/+420
Notes: svn path=/cvs2svn/branches/unlabeled-1.1.1/; revision=1573