summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/malloc.c
Commit message (Collapse)AuthorAgeFilesLines
* s/EDOFUS/EDOOFUS/phk2002-08-211-3/+3
| | | | Persuaded by: Google
* Make sure we set errno sensibly in case of failure.phk2002-08-091-0/+7
| | | | Spotted by: ache
* Const poison.phk2002-05-301-3/+5
| | | | Partially submitted by: wollman
* Avoid casting a different sized integer to a pointer on LP64 systems.peter2002-05-101-1/+1
|
* Constify _malloc_options.phk2002-04-241-1/+1
|
* Do not use __progname directly (except in [gs]etprogname(3)).markm2002-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.
* Fix the style of the SCM ID's.obrien2002-03-221-2/+3
| | | | I believe have made all of libc .c's as consistent as possible.
* Remove __P() usage.obrien2002-03-211-1/+1
|
* Remove 'register' keyword.obrien2002-03-211-1/+1
|
* Add ifdefs for sparc64.jake2002-02-231-0/+4
|
* If 'VX' is given, realloc(foo,0) will bail, it shouldn't.phk2001-11-171-2/+5
| | | | | PR: 29376 Submitted by: Farooq Mela <fmela0@sm.socccd.cc.ca.us>
* Correctly call THREAD_UNLOCK() if the recursive call trap is sprung.phk2001-11-161-0/+2
| | | | Pointed out by: knu
* phkmalloc->evilchecks++;phk2001-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>
* Port to ia64, taking into account the fact that pagesizes may be variable.dfr2001-09-071-0/+11
|
* Fixed style bugs (dot `.' at the end of error and warning messages).ru2001-08-101-22/+22
| | | | Noticed by: bde
* Remove a sizeof(void *) == sizeof(int) assumption.phk2001-02-041-7/+7
| | | | Submitted by: Loren James Rittle <rittle@latour.rsch.comm.mot.com>
* Remove _THREAD_SAFE and make libc thread-safe by default bydeischen2001-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
* Add `_PATH_DEVZERO'.obrien2000-12-091-1/+2
| | | | Use _PATH_* where where possible.
* Make it possible to override the function which writes messages tophk2000-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.
* Oops, un-spam this file - the last commit was an accident.brian2000-09-201-1/+0
| | | | Pointed out by: phk
* Only realloc() environ if we're sure that we know where it came from.brian2000-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*
* Turn malloc options "AJ" on by default.phk2000-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.
* Add a missing THREAD_UNLOCK() found missing by Valentin Nechayevphk2000-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.
* Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),jasone2000-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
* Add three-tier symbol naming in support of POSIX thread cancellationjasone2000-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().
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Back out previous commit after discussing it with Dmitrij Tejblum.des1999-07-071-4/+0
|
* Always set errno to ENOMEM when returning 0 from malloc() or realloc().des1999-07-071-1/+5
| | | | Approved by: phk
* Disable the "Hint" option in phkmalloc as default. Recent VM systemphk1999-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 ?)
* Delete the XXX comments that refer to spinlock recursion. The malloc/free/jb1998-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.
* Use 8k pagesize on alpha, not 4k.dfr1998-09-231-1/+5
|
* Back out part of previous commit (even though it's technically correct).alex1998-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.
* Correctly back out of free if a recursive call into malloc.c is detected.alex1998-09-191-8/+7
| | | | | | Set malloc_func *after* grabbing the thread lock. Noticed by: Simon Coggins <simon@oz.org>
* preserve errno across the readlink() calls. There is no value in trashingpeter1998-06-181-1/+4
| | | | errno during a successful malloc() call.
* Add support for thread lock debug. No impact of the malloc code.jb1998-06-091-4/+4
|
* Replace the threaded locking with spinlock calls for both threadedjb1998-04-291-18/+10
| | | | | | | and non-threaded programs. This makes malloc thread safe for linking with libpthread and kernel threads. Reviewed by: phk
* Change in name of the static initializer define.jb1998-04-041-2/+2
|
* NetBSD doesn't have a utrace syscall, so don't define that ifjb1998-03-091-2/+4
| | | | __NETBSD_SYSCALLS is defined.
* Drop the use of caddr_t in conjunction with mmap(2).alex1997-12-311-4/+4
|
* Fix recursion problem which occurs when a signal is received duringjb1997-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.
* Another 32bits of 64bits conformance.phk1997-08-311-2/+2
| | | | | Reviewed by: phk Submitted by: jdp
* Improvement of type independency for the bitmap.phk1997-08-271-3/+4
| | | | | | | This makes 64bit operation more likely. Reviewed by: phk Submitted by: jdp
* Malloc option H is now default.phk1997-08-271-2/+2
|
* Fix a minor typo. It only affects the sparc version.jdp1997-07-261-2/+2
|
* Have another go at the malloc-sysv initialization.phk1997-07-021-12/+11
| | | | | PR: 4002 Pointed out by: bde
* malloc_sysv used before initialized, reported in PR4002 byphk1997-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>
* Integrate calloc with the rest of the gang.phk1997-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>
* Add yet an option, this time on how to deal with malloc(0) and realloc(ptr.0)phk1997-06-121-5/+9
| | | | Prompted by: X11 & XFree86
* Fix mutex initialization.jb1997-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-)
* Malloc flag X makes malloc behave like the canonical xmalloc() wrapper.phk1997-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>
OpenPOWER on IntegriCloud