Commit Graph

59 Commits

Author SHA1 Message Date
christos 794a9d5044 use getpagesize(3). 2017-01-13 04:18:54 +00:00
christos 8212adb6e3 Avoid sysconf: __sysconf -> sysctlgetmibinfo -> strtoimax -> locale, etc. 2017-01-12 02:00:42 +00:00
christos 227c2c0795 make this smaller. 2017-01-12 01:02:09 +00:00
christos 9a513d9643 make more descriptors that we open as close-on-exec 2014-09-18 13:58:20 +00:00
dholland 2d1469952b typo in comment, from Abhinav Upadhyay in PR 47385 2012-12-30 21:23:20 +00:00
christos 713ea1897d cleanup saving and restoring errno, and make it similar. 2011-05-18 01:59:39 +00:00
christos 1ff5a5dfd6 don't let readlink trash errno.; 2011-05-13 23:11:00 +00:00
christos ed13fe5855 fix posix_memalign; we are not going to support alignments > pagesize in
this implementation.
2008-02-03 22:56:53 +00:00
macallan f53566168d make this compile again 2007-12-12 17:56:10 +00:00
christos b831a8ada2 move decls for _malloc_{pre,post}fork() to extern.h 2007-12-04 17:45:07 +00:00
christos f6cecc05cf Sync phk malloc.c with the latest one from FreeBSD. This gives us the
same api as jemalloc by:

    - adding posix_memalign()
    - moving calloc in the same file
    - renaming malloc_options -> _malloc_options
2007-11-28 21:55:14 +00:00
christos 3d98aa3f4b fix spelling of accidentally; from Zapher 2006-11-24 19:37:02 +00:00
elad 25c47f2333 PR/34602: sushant: Bug in malloc implementation contains dead code in
free_pages()

Applied patch from Mindaugas <unex at linija org> (in #NetBSD-code), thanks
2006-10-08 16:25:15 +00:00
perry 46359204cf __inline__ -> inline 2005-12-24 21:42:02 +00:00
christos 03256c6e55 WARNS=4 2005-11-29 03:11:58 +00:00
lukem 88c3eadbfa Add missing __RCSID() 2005-06-12 05:21:25 +00:00
junyoung e3ac3a4d0c Style fixes to reduce diff size against the FreeBSD version, notably:
- Use NULL where appropriate.
 - No need to pull in stdint.h.
 - Get rid of "register" keywords in the hope that the compiler will
   do a better job for us. :-)
 - Every message ends with a period.
 - MMAP() macro is supposed to return MAP_FAILED rather than -1 if it
   fails.
 - De-__P.
2003-10-05 04:49:46 +00:00
itojun 6f4e912af4 call malloc_init() on first call to free/realloc, to make malloc.conf to
take effect.  in response to PR 22223
2003-07-23 08:15:02 +00:00
thorpej 3fdac2b8c5 Merge the nathanw_sa branch. 2003-01-18 10:52:16 +00:00
chris 5e606f5b98 Add a couple of missing THREAD_UNLOCK's, for the error exit path.
No functional change on Mainline, however SA branch probably needs this.
2002-12-09 14:14:59 +00:00
thorpej 1289029f10 Fix signed/unsigned comparison warnings. 2002-11-11 17:56:11 +00:00
christos b2126f94bb More fixes:
1. use uintptr_t instead of u_long
2. check for overflow in map_pages and malloc_pages
3. bring in fixes from FreeBSD [int -> size_t, and a missing THREAD_UNLOCK]
4. rewrite map_pages to use sbrk() only to grow memory (avoids extra syscall
   and elides bug in brk(2) that ross is fixing)
5. restore the break point to its original value if the mmap(2) for the page
   directory or the alignment sbrk breaks.

reviewed by: chuq and ross
tested by: make build and reboot
Now memtest nearly works; unfortunately there is no way currently to lower
the break point as we free, so memtest keeps trying to reduce memory when
mlock() fails and that does not work.
2001-05-06 04:48:41 +00:00
christos fa27739cb4 PR/12810: Chris ?: malloc core-dumps when given large number as the argument.
This is because integer overflow occurs in the computation of the size of
the page directory array. We now detect that, and return ENOMEM.
2001-05-03 15:35:12 +00:00
cgd 6b25d77513 convert from __progname to getprogname() 2001-02-19 22:22:16 +00:00
jdolecek 75ee9a37dd we now have utrace, support it here 2001-01-05 22:29:28 +00:00
christos bebeeecd5b fix sbrk casts 2000-12-20 20:56:01 +00:00
christos 6b283a58bd avoid losing precision warnings 2000-07-06 03:13:22 +00:00
simonb ecce47356a Disable malloc's hints to the kernel - now that the madvise() syscall
actually does something, this can be expensive.  From discussion on
current-users.

Note that the man page is already correct - we imported malloc.c from
FreeBSD before they made the same change but malloc.3 after...
2000-05-20 15:13:31 +00:00
enami d76da5f70c Fix the bug introduced in rev 1.28 and actually caused failure on alpha;
In the function malloc_make_chunks, don't define the local variable ``l'',
which is used to hold the actual size of pginfo, as size_t.  Define it as
a signed integer as before.  We expect it to become zero or negative value,
and we know that it is much smaller than pagesize and it is small enough to
fit in signed interger.
2000-04-07 15:15:08 +00:00
enami 07fd543922 Backout the previous backing out. 2000-04-07 14:56:13 +00:00
thorpej 62c7591543 Back out the previous 2 revs. The delint'ing of this file caused
something to break horribly on the Alpha.
2000-01-31 22:56:14 +00:00
mycroft 8102096d08 Delint. 2000-01-23 00:49:41 +00:00
mycroft 03ec2c38fe Partially delint, and a few microoptimizations. 2000-01-23 00:38:43 +00:00
kleink 9e00e84f98 Restore the behaviour of not setting errno to ENOMEM when allocating 0
units of storage and returning a null pointer in System V mode; this was
broken by the `fix' in rev. 1.24.  Also, as it is stated in ISO C that
such operation does not constitute an allocation failure, do not abort()
even if the `X' option is set.

Amusingly enough the SVID, Fourth Edition, specifies the `unique pointer'
return behaviour for this kind of allocation, so this is kind of mis-named.
1999-09-10 10:38:06 +00:00
kleink 5f3726439e Need "namespace.h". 1999-08-22 12:54:02 +00:00
thorpej 602452569d Make sure errno is set to ENOMEM if we return NULL. 1999-07-08 22:18:06 +00:00
thorpej 4d36288136 index -> ldx (and similar in some related variable names). Avoids a lint
warning.
1999-07-05 22:14:38 +00:00
thorpej 55fcfba6fe Oops, back out 1.21. Christos and I apparently stepped on each other. 1999-07-05 22:12:20 +00:00
christos 06b51a1a11 s/index/idx/
s/EXTRA_SANITY/MALLOC_EXTRA_SANITY/
const poisoning
use sysconf to get the pagesize
1999-07-05 21:55:46 +00:00
thorpej 3cedf1e346 Compute page size related parameters at run-time. 1999-07-05 21:49:05 +00:00
thorpej b2146da05a EXTRA_SANITY -> MALLOC_EXTRA_SANITY, consistently. 1999-07-05 21:08:38 +00:00
thorpej f759ceb8bf Only define MADV_FREE do MADV_DONTNEED if it's not already defined
by <sys/mman.h>.
1999-07-04 03:12:47 +00:00
tls e89d5d52c5 The 'new malloc' (phk's malloc, from FreeBSD) is now our only malloc. 1999-06-26 04:44:36 +00:00
kleink fd13be3c46 Protect access of state with a mutex. Miscellaneous notes:
* still needs an implementation-independent ("reentrant.h") method for
disabling cancellation,
* break a leg to leave realloc() `storage compaction' as was for non-reentrant
code,
* use of stdio in assertion code is unsafe.
1999-01-29 08:11:36 +00:00
christos 33edc15a8c delint 1998-11-15 17:13:51 +00:00
perry 69d1215a28 make memcpy into memmove in some cases 1998-08-26 00:29:29 +00:00
perry a843f0f8a5 bzero->memset, bcopy->memcpy, bcmp->memcmp 1998-08-10 02:43:08 +00:00
perry c8bafd6265 remove obsolete register declarations 1998-02-03 18:38:12 +00:00
perry 5f8a6c06f3 update to lite-2 1998-01-30 23:37:40 +00:00
jtc 43fa6fe319 If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore.  The library will use those
names internally.  Weak aliases are used to provide the original names
to the API.

This is only the first part of this change.  It is most of the functions
which are implemented in C for all NetBSD ports.  Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
1997-07-21 14:06:24 +00:00