summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/malloc.c
Commit message (Collapse)AuthorAgeFilesLines
* Const poison.Poul-Henning Kamp2002-05-301-3/+5
| | | | | | | Partially submitted by: wollman Notes: svn path=/head/; revision=97639
* Avoid casting a different sized integer to a pointer on LP64 systems.Peter Wemm2002-05-101-1/+1
| | | | Notes: svn path=/head/; revision=96350
* Constify _malloc_options.Poul-Henning Kamp2002-04-241-1/+1
| | | | Notes: svn path=/head/; revision=95377
* Do not use __progname directly (except in [gs]etprogname(3)).Mark Murray2002-03-291-4/+2
| | | | | | | | | Also, make an internal _getprogname() that is used only inside libc. For libc, getprogname(3) is a weak symbol in case a function of the same name is defined in userland. Notes: svn path=/head/; revision=93399
* Fix the style of the SCM ID's.David E. O'Brien2002-03-221-2/+3
| | | | | | | I believe have made all of libc .c's as consistent as possible. Notes: svn path=/head/; revision=92986
* Remove __P() usage.David E. O'Brien2002-03-211-1/+1
| | | | Notes: svn path=/head/; revision=92905
* Remove 'register' keyword.David E. O'Brien2002-03-211-1/+1
| | | | Notes: svn path=/head/; revision=92889
* Add ifdefs for sparc64.Jake Burkholder2002-02-231-0/+4
| | | | Notes: svn path=/head/; revision=91161
* If 'VX' is given, realloc(foo,0) will bail, it shouldn't.Poul-Henning Kamp2001-11-171-2/+5
| | | | | | | | PR: 29376 Submitted by: Farooq Mela <fmela0@sm.socccd.cc.ca.us> Notes: svn path=/head/; revision=86488
* Correctly call THREAD_UNLOCK() if the recursive call trap is sprung.Poul-Henning Kamp2001-11-161-0/+2
| | | | | | | Pointed out by: knu Notes: svn path=/head/; revision=86466
* phkmalloc->evilchecks++;Poul-Henning Kamp2001-11-021-3/+13
| | | | | | | | | | | If zero bytes are allocated, return pointer to the middle of page-zero (which is protected) so that the program will crash if it dereferences this illgotten pointer. Inspired & Urged by: Theo de Raadt <deraadt@cvs.openbsd.org> Notes: svn path=/head/; revision=85869
* Port to ia64, taking into account the fact that pagesizes may be variable.Doug Rabson2001-09-071-0/+11
| | | | Notes: svn path=/head/; revision=83202
* Fixed style bugs (dot `.' at the end of error and warning messages).Ruslan Ermilov2001-08-101-22/+22
| | | | | | | Noticed by: bde Notes: svn path=/head/; revision=81447
* Remove a sizeof(void *) == sizeof(int) assumption.Poul-Henning Kamp2001-02-041-7/+7
| | | | | | | Submitted by: Loren James Rittle <rittle@latour.rsch.comm.mot.com> Notes: svn path=/head/; revision=71987
* Remove _THREAD_SAFE and make libc thread-safe by default byDaniel Eischen2001-01-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch Notes: svn path=/head/; revision=71579
* Add `_PATH_DEVZERO'.David E. O'Brien2000-12-091-1/+2
| | | | | | | Use _PATH_* where where possible. Notes: svn path=/head/; revision=69793
* Make it possible to override the function which writes messages toPoul-Henning Kamp2000-11-261-12/+18
| | | | | | | | | | stderr in case of warnings and errors. Rename malloc_options to have a leading underscore, I belive I have been told that is more correct namespace wise. Notes: svn path=/head/; revision=69201
* Oops, un-spam this file - the last commit was an accident.Brian Somers2000-09-201-1/+0
| | | | | | | Pointed out by: phk Notes: svn path=/head/; revision=66105
* Only realloc() environ if we're sure that we know where it came from.Brian Somers2000-09-201-0/+1
| | | | | | | | | The recent problems with sshd were due to sshd reassigning `environ' when setenv() thinks it owns it. setenv() subsequently realloc()s the new version of environ and *boom* Notes: svn path=/head/; revision=66101
* Turn malloc options "AJ" on by default.Poul-Henning Kamp2000-07-091-2/+2
| | | | | | | | | | | These will be turned off again as we approach 5.0-RELEASE. If you benchmark things, make sure to ln -sf j /etc/malloc.conf to see "true" performance. Notes: svn path=/head/; revision=62847
* 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