History log of /freebsd-10.0-release/lib/libc/stdlib/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


255129 01-Sep-2013 jilles

system(): Restore behaviour for SIGINT and SIGQUIT.

As mentioned in r16117 and the book "Advanced Programming in the Unix
Environment" by W. Richard Stevens, we should ignore SIGINT and SIGQUIT
before forking, since it is not guaranteed that the parent process starts
running soon enough.

To avoid calling sigaction() in the vforked child, instead block SIGINT and
SIGQUIT before vfork() and keep the sigaction() to ignore after vfork(). The
FreeBSD kernel discards ignored signals, even if they are blocked;
therefore, it is not necessary to unblock SIGINT and SIGQUIT earlier.


254483 18-Aug-2013 pjd

Make example more correct (errstr is a pointer, not boolean).


254297 13-Aug-2013 peter

vfork(2) was listed as deprecated in 1994 (r1573) and was the false
reports of its impending demise were removed in 2009 (r199257).

However, in 1996 (r16117) system(3) was switched from vfork(2) to
fork(2) based partly on this. Switch back to vfork(2). This has a
dramatic effect in cases of extreme mmap use - such as excessive
abuse (500+) of shared libraries.

popen(3) has used vfork(2) for a while. vfork(2) isn't going anywhere.


253413 17-Jul-2013 avg

[fix to r253380] __setenv: be explicit about placing '=' after name

This should a regression introduced in r253380 if malloc'ed memory
happens to have '=' at the right place.

Reported by: ache
Pointyhat to: me (avg)
MFC after: 1 day
X-MFC with: r253380


253380 16-Jul-2013 avg

libc: name passed into __setenv is not necessarily NUL-terminated

That's particularly true when __setenv is called from __merge_environ.

MFC after: 4 days


252698 04-Jul-2013 ache

Style fix noted by bde@


252668 04-Jul-2013 ache

After fixing ranges restore POSIX requirement: rand() call without
srand() must be the same as srand(1); rand();
(yet one increment)


252648 03-Jul-2013 ache

In addition to prev. commit, for repeated rand_r(3) calls don't forget
to compensate back at the end incremented at the start internal
state.

MFC after: 2 weeks


252608 03-Jul-2013 ache

1) POSIX requires rand(3) return values to be in the [0, RAND_MAX] range,
but ACM formula we use have internal state (and return value) in the
[1, 0x7ffffffe] range, so our RAND_MAX (0x7fffffff) is never reached
because it is off by one, zero is not reached too.

Correct both RAND_MAX and rand(3) return value, shifting last one
to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffffffd(=new RAND_MAX)]
range.

2) Add a checks for not overflowing on too big seeds. It may happens on
the machines, where sizeof(unsigned int) > 32 bits.

Reviewed by: bde [1]
MFC after: 2 weeks


251672 13-Jun-2013 emaste

Renumber clauses to reduce diffs to other versions

NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3,
so follow suit to make comparison easier.


251069 28-May-2013 emaste

Renumber clauses to reduce diffs to other versions

NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3,
so follow suit to make comparison easier.


250991 25-May-2013 marcel

Make the malloc(3) family of functions weak and make their non-weak
implementations visible for use by applications. The functions $F that
are now weak symbols are:
allocm, calloc, dallocm, free, malloc, malloc_usable_size,
nallocm, posix_memalign, rallocm, realloc, sallocm

The non-weak implementations of $F are exported as __$F.

Submitted by: stevek@juniper.net
Reviewed by: jasone@, kib@
Approved by: jasone@ (jemalloc)
Obtained from: juniper Networks, Inc


250639 14-May-2013 hiren

Fix a typo: It should be "strtoll" and not "stroll".

PR: 178642
Reported by: Michael Galassi (michaelgalassi@gmail.com)
Approved by: sbruno (mentor)
MFC after: 1 week


249721 21-Apr-2013 joel

Add example.

PR: 177025
Submitted by: Fernando <fernando.apesteguia@gmail.com>
Reviewed by: theraven


249582 17-Apr-2013 gabor

- Correct mispellings of the word occurrence

Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail)


249035 02-Apr-2013 delphij

Replace access to /dev/random with the kernel pseudo-random number
source sysctl(KERN_ARND) and remove the fallback code.

Obtained from: OpenBSD
Reviewed by: secteam
MFC after: 1 month


248453 18-Mar-2013 kevlo

Add restrict keyword to realpath manpage.


247189 23-Feb-2013 keramida

Now that qsort(3) has a sample comparison function, point to that
example from bsearch(3) too, so that we don't have to duplicate
the example code in both places.

PR: docs/176197
Reviewed by: stefanf
Approved by: remko (mentor), gjb (mentor)
MFC after: 1 week


247051 20-Feb-2013 joel

Sort sections.


247050 20-Feb-2013 keramida

Various improvements to the qsort(3) usage example:

- Remove unused #include.
- Do not cast away const.
- Use the canonical idiom to compare two numbers.
- Use proper type for sizes, i.e. size_t instead of int.
- Correct indentation.
- Simplify printf("\n") to puts("").
- Use return instead of exit() in main().

Submitted by: Christoph Mallon, christoph.mallon at gmx.de
Approved by: gjb (mentor)
Reviewed by: stefanf
MFC after: 1 week


247014 20-Feb-2013 keramida

Add a sample program that shows how a custom comparison function and
qsort(3) can work together to sort an array of integers.

PR: docs/176197
Submitted by: Fernando, fapesteguia at opensistemas.com
Approved by: gjb (mentor)
MFC after: 1 week


241373 09-Oct-2012 eadler

Remove undefined behavior from sranddev() and
srandomdev(). This doesn't actually work
with any modern C compiler:

In particular, both clang and modern gcc
verisons silently elide any xor operation
with 'junk'.

Approved by: secteam
MFC after: 3 days


241154 03-Oct-2012 ache

Optimize prev. commit for speed.
1) Don't iterate the loop from the environment array beginning each time,
iterate it under the last place we deactivate instead.
2) Call __rebuild_environ() not on each iteration but once, only at the end
of whole loop (of course, only in case if something is changed).

MFC after: 1 week


241137 02-Oct-2012 ache

Using putenv() and later direct pointer contents modification it is possibe
to craft environment variables with similar names like that:
a=1
a=2
...
unsetenv("a") should remove them all to make later getenv("a") impossible.
Fix it to do so (this is GNU autoconf test #3 failure too).

PR: 172273
MFC after: 1 week


241046 29-Sep-2012 jilles

libc: Use O_CLOEXEC for various internal file descriptors.

This fixes a race condition where another thread may fork() before CLOEXEC
is set, unintentionally passing the descriptor to the child process.

This commit only adds O_CLOEXEC flags to open() or openat() calls where no
fcntl(fd, F_SETFD, FD_CLOEXEC) follows. The separate fcntl() call still
leaves a race window so it should be fixed later.


241031 28-Sep-2012 des

Slight stylification.


240412 12-Sep-2012 emaste

According to a clarification at http://austingroupbugs.net/view.php?id=503
ptsname may set errno, so avoid saving and restoring errno across the
function.

PR: standards/171572


240410 12-Sep-2012 emaste

Avoid mapping ENOENT to ENOTDIR for non-existent path components.

The ENOTDIR mapping was introduced in r235266 for kern/128933 based on
an interpretation of the somewhat ambiguous language in the POSIX realpath
specification. The interpretation is inconsistent with Solaris and Linux,
a regression from 9.0, and does not appear to be permitted by the
description of ENOTDIR:

20 ENOTDIR Not a directory. A component of the specified pathname
existed, but it was not a directory, when a directory was
expected.

PR: standards/171577
MFC after: 3 days


240361 11-Sep-2012 des

Add the same warning to rand48(3) as to rand(3) and random(3).

MFC after: 3 days


240111 04-Sep-2012 des

Bump dates.

Reminded by: bz@


240107 04-Sep-2012 des

Add a prominent warning about these functions' unsuitability for
cryptographic purposes, and recommend using arc4random(3) instead.


239345 17-Aug-2012 kevlo

Make 'junk' volatile so that compilers won't be tempted to optimize

Reviewed by: ache
MFC after: 3 days


238802 26-Jul-2012 pluknet

Update the 'C1x draft' reference to '.St -isoC-2011' mdoc macro.

Reviewed by: theraven
MFC after: 1 week


237591 26-Jun-2012 joel

Remove end of line whitespace.


237573 25-Jun-2012 issyl0

Add more locale-specific functions to the relevant man pages and
Makefiles:
- libc/stdtime/strftime.3
- libc/stdtime/strptime.3
- libc/stdlib/strfmon.3

Reviewed by: theraven
Approved by: gabor (mentor)


236936 11-Jun-2012 delphij

Switch from 4-clause to 2-clause BSD license. (OpenBSD r1.22)
No functional change.

Obtained from: NetBSD via OpenBSD


236618 05-Jun-2012 ache

1) Although unpublished version of standard
http://austingroupbugs.net/view.php?id=385#c713
(Resolved state) recommend this way for the current standard (called
"earlier" in the text)

"However, earlier versions of this standard did not require this, and the
same example had to be written as:

// buf was obtained by malloc(buflen)
ret = write(fd, buf, buflen);
if (ret < 0) {
int save = errno;
free(buf);
errno = save;
return ret;
}
"

from feedback I have for previous commit it seems that many people prefer
to avoid mass code change needed for current standard compliance
and prefer to track unpublished standard instead, which requires now
that free() itself must save errno, not its usage code.

So, I back out "save errno across free()" part of previous commit,
and will fill PR for changing free() isntead.

2) Remove now unused serrno.

MFC after: 1 week


236582 04-Jun-2012 ache

1) IEEE Std 1003.1-2008, "errno" section, is explicit that

"The setting of errno after a successful call to a function is
unspecified unless the description of that function specifies that
errno shall not be modified."

However, free() in IEEE Std 1003.1-2008 does not mention its interaction
with errno, so MAY modify it after successful call
(it depends on particular free() implementation, OS-specific, etc.).

So, save errno across free() calls to make code portable and
POSIX-conformant.

2) Remove unused serrno assignment.

MFC after: 1 week


235286 11-May-2012 gjb

General mdoc(7) and typo fixes.

PR: 167734
Submitted by: Nobuyuki Koganemaru (kogane!jp.freebsd.org)
MFC after: 3 days


235266 11-May-2012 kib

According to SUSv4, realpath(3) must fail if
[ENOENT] A component of file_name does not name an existing file or
file_name points to an empty string.
[ENOTDIR] A component of the path prefix is not a directory, or the
file_name argument contains at least one non- <slash> character
and ends with one or more trailing <slash> characters and the last
pathname component names an existing file that is neither a
directory nor a symbolic link to a directory.
Add checks for the listed conditions, and set errno accordingly.

Update the realpath(3) manpage to mention SUS behaviour. Remove the
requirement to include sys/param.h before stdlib.h.

PR: 128933
MFC after: 3 weeks


234370 17-Apr-2012 jasone

Import jemalloc 9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa (dev branch,
prior to 3.0.0 release) as contrib/jemalloc, and integrate it into libc.
The code being imported by this commit diverged from
lib/libc/stdlib/malloc.c in March 2010, which means that a portion of
the jemalloc 1.0.0 ChangeLog entries are relevant, as are the entries
for all subsequent releases.


233648 29-Mar-2012 eadler

Remove trailing whitespace per mdoc lint warning

Disussed with: gavin
No objection from: doc
Approved by: joel
MFC after: 3 days


229848 09-Jan-2012 ed

Add aligned_alloc(3).

The C11 folks reinvented the wheel by introducing an aligned version of
malloc(3) called aligned_alloc(3), instead of posix_memalign(3). Instead
of returning the allocation by reference, it returns the address, just
like malloc(3).

Reviewed by: jasone@


229808 08-Jan-2012 ed

Properly sort functions by name.


228885 26-Dec-2011 gjb

Add missing opening and closing brackets in getopt_long.3 and getsubopt.3
to make the examples reflect reality more closely.

MFC after: 1 week
X-MFC-After: 9.0-RELEASE


228540 15-Dec-2011 dim

Since clang does not support the tls_model attribute used in malloc.c
yet (see LLVM PR 9788), and warns about it, rub it out for now. When
clang grows support for this attribute, I will revert this again.

MFC after: 1 week


228528 15-Dec-2011 theraven

Small style(9) improvements.

Approved by: dim (mentor)


228329 07-Dec-2011 theraven

Some fixes to the man pages for [at_]quick_exit(3)

Reviewed by: pluknet
Approved by: dim (mentor)


228323 07-Dec-2011 theraven

style(9) cleanups.

Approved by: brooks (mentor)


228322 07-Dec-2011 theraven

Implement quick_exit() / at_quick_exit() from C++11 / C1x. Also add a
__noreturn macro and modify the other exiting functions to use it.

The __noreturn macro, unlike __dead2, must be used BEFORE the function.
This is in line with the C and C++ specifications that place _Noreturn (c1x)
and [[noreturn]] (C++11) in front of the functions. As with __dead2, this
macro falls back to using the GCC attribute.

Unfortunately, clang currently sets the same value for the C version macro
in C99 and C1x modes, so these functions are hidden by default. At some
point before 10.0, I need to go through the headers and clean up the C1x /
C++11 visibility.

Reviewed by: brooks (mentor)


227753 20-Nov-2011 theraven

Implement xlocale APIs from Darwin, mainly for use by libc++. This adds a
load of _l suffixed versions of various standard library functions that use
the global locale, making them take an explicit locale parameter. Also
adds support for per-thread locales. This work was funded by the FreeBSD
Foundation.

Please test any code you have that uses the C standard locale functions!

Reviewed by: das (gdtoa changes)
Approved by: dim (mentor)


227090 04-Nov-2011 ed

Fix a warning emitted by Clang.

The size passed to strlcat() must depend on the input length, not the
output length. Because the input and output buffers are equal in size,
the resulting binary does not change at all.


224201 18-Jul-2011 dim

Fix building of 32-bit compat libraries on amd64 with clang, and using
-g, by reverting r219139. The LLVM PR referenced in that revision was
fixed in the mean time, and we imported a clang snapshot soon
afterwards, so the temporary workaround of disabling clang's integrated
assembler is no longer needed.

In this particular case, using e.g. DEBUG_FLAGS=-g causes clang to
output certain directives into assembly that our version of GNU as
chokes on.

Reported by: dougb
Approved by: re (kib)


223576 26-Jun-2011 ed

Fix whitespace inconsistencies in libc in files copyrighted by me.


223369 21-Jun-2011 marius

Change sparc64 to use the initial exec TLS model, too. This avoids random
assertion failures in _malloc_thread_cleanup().


219709 17-Mar-2011 marcel

Don't add sigwait.c to MISRCS here when sigwait.c lives under ../sys and
it's already added to SRCS there.


219535 11-Mar-2011 marius

Now that TLS generally is available on sparc64 since r219534 turn on
support for it. Note that while sparc64 also supports the static TLS
model and thus tls_model("initial-exec"), using the default model
turned out to yield slightly better buildstone performance.


219377 07-Mar-2011 rstone

Correct a typo in the malloc(3) manpage. Malloc options are set in the
MALLOC_OPTIONS environment variable, not JEMALLOC_OPTIONS.

Reviewed by: jasone
Approved by: emaste (mentor)


219139 01-Mar-2011 dim

Put in a temporary workaround for ctfmerge hanging on processing
kernel.debug (or possibly other files), when WITH_CTF is active.

This is caused by a bug in clang's integrated assembler, causing malloc
to sometimes hang during initialization in statically linked executables
that use threading, such as the copy of ctfmerge that is built during
the bootstrap stage of buildworld. The bug has been submitted upstream:

http://llvm.org/bugs/show_bug.cgi?id=9352

Note that you might have to rebuild and install libc first, to get your
kernel build to finish, because the ctfmerge binary built during
bootstrap is linked with your base system's copy of libc.a, which might
already contain a bad copy of malloc.o.


217144 08-Jan-2011 kib

Fix some style(9) issues.
Do not use strlcpy() where simple assignment is enough.

Noted by: bde (long time ago)
MFC after: 1 week


214200 22-Oct-2010 bcr

Revert to r214147, errno is not clobbered as originally
thought.


214148 21-Oct-2010 bcr

Document strtonum()s behavior of setting errno to 0 when no error is found.

PR: docs/143330
Submitted by: Efstratios Karatzas (gpf dot kira at gmail dot com)
Discussed with: ru@
MFC after: 7 days


214147 21-Oct-2010 bcr

Sync with OpenBSD rev. 1.13:
strtonum does not require limits.h

Obtained from: OpenBSD
Discussed with: ru@
MFC after: 5 days


213573 08-Oct-2010 uqs

mdoc: drop redundant .Pp and .LP calls

They have no effect when coming in pairs, or before .Bl/.Bd


213477 06-Oct-2010 kib

Missed space.

Submitted by: brueffer
MFC after: 1 week


213476 06-Oct-2010 kib

Add cross-references to lrand48(3) and arc4random(3) from rand(3)
and random(3).

Submitted by: Valentin Nechayev <netch netch kiev ua>
MFC after: 1 week


212463 11-Sep-2010 brucec

Revert changes of 'assure' to 'ensure' made in r211936.

Approved by: rrs (mentor)


212405 10-Sep-2010 davidxu

Because POSIX does not allow EINTR to be returned from sigwait(),
add a wrapper for it in libc and rework the code in libthr, the
system call still can return EINTR, we keep this feature.

Discussed on: thread
Reviewed by: jilles


211936 28-Aug-2010 brucec

Fix incorrect usage of 'assure' and 'insure'.

Approved by: rrs (mentor)


211894 27-Aug-2010 kib

Do not call __pthread_cxa_finalize with invalid struct dl_phdr_info.

Reported and tested by: Fabian Keil <freebsd-listen fabiankeil de>
MFC after: 17 days


211774 24-Aug-2010 imp

Powerpc is special here. powerpc and powerpc64 use different ABIs, so
their implementations aren't in the same files. Introduce LIBC_ARCH
and use that in preference to MACHINE_CPUARCH. Tested by amd64 and
powerpc64 builds (thanks nathanw@)


211725 23-Aug-2010 imp

MFtbemd:

Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.


211706 23-Aug-2010 kib

On shared object unload, in __cxa_finalize, call and clear all installed
atexit and __cxa_atexit handlers that are either installed by unloaded
dso, or points to the functions provided by the dso.

Use _rtld_addr_phdr to locate segment information from the address of
private variable belonging to the dso, supplied by crtstuff.c. Provide
utility function __elf_phdr_match_addr to do the match of address against
dso executable segment.

Call back into libthr from __cxa_finalize using weak
__pthread_cxa_finalize symbol to remove any atfork handler which
function points into unloaded object.

The rtld needs private __pthread_cxa_finalize symbol to not require
resolution of the weak undefined symbol at initialization time. This
cannot work, since rtld is relocated before sym_zero is set up.

Idea by: kan
Reviewed by: kan (previous version)
MFC after: 3 weeks


211704 23-Aug-2010 kib

Style.

MFC after: 3 days


211416 17-Aug-2010 kib

Use aux vector to get values for SSP canary, pagesize, pagesizes array,
number of host CPUs and osreldate.

This eliminates the last sysctl(2) calls from the dynamically linked image
startup.

No objections from: kan
Tested by: marius (sparc64)
MFC after: 1 month


211397 16-Aug-2010 joel

Fix typos, spelling, formatting and mdoc mistakes found by Nobuyuki while
translating these manual pages. Minor corrections by me.

Submitted by: Nobuyuki Koganemaru <n-kogane@syd.odn.ne.jp>


210933 06-Aug-2010 joel

Fix typos and spelling mistakes.


210853 05-Aug-2010 ache

Comment out IEEE Std 1003.1-2001 conformance proclaimed too early,
see problems described in the comment to:
http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/128933


210765 02-Aug-2010 uqs

mdoc: remove unbalanced quotes


209878 10-Jul-2010 nwhitehorn

Provide 64-bit PowerPC support in libc.

Obtained from: projects/ppc64


209117 13-Jun-2010 cperciva

In threaded processes, destroy the mutex atexit_mutex when we've
finished using it. This allows the mutex's allocated memory to be
freed.

This is one sense a rather silly change, since at this point we're
less than a microsecond away from calling _exit; but fixing this
memory leak is likely to make life easier for anyone trying to
track down other memory leaks.


208027 13-May-2010 uqs

mdoc: move CAVEATS, BUGS and SECURITY CONSIDERATIONS sections to the
bottom of the manpages and order them consistently.

GNU groff doesn't care about the ordering, and doesn't even mention
CAVEATS and SECURITY CONSIDERATIONS as common sections and where to put
them.

Found by: mdocml lint run
Reviewed by: ru


207946 12-May-2010 brueffer

The previous revision actually removed the bug being hinted at, so
go ahead and remove the hint.

PR: 143944
Submitted by: Jeremy Huddleston <jeremyhu@apple.com>
MFC after: 1 week


207009 21-Apr-2010 kib

C language does not has references, it provides pointers.

Suggested by: bde
MFC after: 2 weeks


206998 21-Apr-2010 kib

Add standards section, improve wording, taking into account the handling
of NULL and changed type in declaration.

Suggested by: bde
MFC after: 2 weeks


206898 20-Apr-2010 kib

Free() is not allowed to modify errno, remove safety brackets around it [1].
Add small optimization, do not copy a string to the buffer that is
to be freed immediately after.

Noted by: jh [1]
Reviewed by: jh
MFC after: 2 weeks


206893 20-Apr-2010 kib

Slightly modernize realpath(3).

SUSv4 requires that implementation returns EINVAL if supplied path is NULL,
and ENOENT if path is empty string [1].
Bring prototype in conformance with SUSv4, adding restrict keywords.
Allow the resolved path buffer pointer be NULL, in which case realpath(3)
allocates storage with malloc().

PR: kern/121897 [1]
MFC after: 2 weeks


206622 14-Apr-2010 uqs

mdoc: order prologue macros consistently by Dd/Dt/Os

Although groff_mdoc(7) gives another impression, this is the ordering
most widely used and also required by mdocml/mandoc.

Reviewed by: ru
Approved by: philip, ed (mentors)


204636 03-Mar-2010 jh

In reallocf(3), free the memory only when size != 0. Otherwise, when the
System V compatibility option (malloc "V" flag) is in effect a zero sized
reallocf() could cause a double free.

PR: bin/141753
Submitted by: Dan Lukes


204493 28-Feb-2010 jasone

Rewrite red-black trees to do lazy balance fixup. This improves
insert/remove speed by ~30%.


203969 16-Feb-2010 marcel

Define TLS_MODEL for PowerPC as well. Since PowerPC uses variant I,
like ia64, leave it empty (default model).


203950 16-Feb-2010 marcel

Unbreak ia64: tls_model("initial-exec") is invalid, because it assumes
the static TLS model, which is fundamentally different from the dynamic
TLS model. The consequence was data corruption. Limit the attribute to
i386 and amd64.


203734 10-Feb-2010 cracauer

Fix PR
http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/143350
Empty string test gone wrong.

Testing this requires that you have a locale that has the sign string
unset but has int_n_sign_posn set (the default locale falls through to
use "()" around negative numbers which is probably another bug).

I created that setup by hand and indeed without this fix negative
numbers are put out as positive numbers (doesn't fall through to use
"-" as default indicator).

Unfixed example in nl_NL.ISO8859-1 with lc->negative_sign set to empty
string:
strfmon(buf, sizeof(buf), "%-8i", -42.0);
==>
example2: 'EUR 42,00' 'Eu 42,00'

Fixed:
example2: 'EUR 42,00-' 'Eu 42,00-'

This file and suggested fix are identical in at least freebsd-8.
Backport might be appropriate but some expert on locales should
probably have a look at us defaulting to negative numbers in
parenthesis when LC_* is default. That doesn't look right and is not
what other OSes are doing.

PR: 143350
Submitted by: Corinna Vinschen
Reviewed by: bug reporter submitted, tested by me


203329 31-Jan-2010 jasone

Fix bugs:

* Fix a race in chunk_dealloc_dss().

* Check for allocation failure before zeroing memory in base_calloc().

Merge enhancements from a divergent version of jemalloc:

* Convert thread-specific caching from magazines to an algorithm that is
more tunable, and implement incremental GC.

* Add support for medium size classes, [4KiB..32KiB], 2KiB apart by
default.

* Add dirty page tracking for pages within active small/medium object
runs. This allows malloc to track precisely which pages are in active
use, which makes dirty page purging more effective.

* Base maximum dirty page count on proportion of active memory.

* Use optional zeroing in arena_chunk_alloc() to avoid needless zeroing
of chunks. This is useful in the context of DSS allocation, since a
long-lived application may commonly recycle chunks.

* Increase the default chunk size from 1MiB to 4MiB.

Remove feature:

* Remove the dynamic rebalancing code, since thread caching reduces its
utility.


203077 27-Jan-2010 emaste

Add missing return, in a rare case where we can't allocate memory in
deallocate.

Submitted by: Ryan Stone (rysto32 at gmail dot com)
Approved by: jasone


200345 10-Dec-2009 jasone

Simplify arena_run_reg_dalloc(), and remove a bug that was due to incorrect
initialization of ssize_invs.


200340 10-Dec-2009 jasone

Fix the posix_memalign() changes in r196861 to actually return a NULL pointer
as intended.

PR: standards/138307


200198 07-Dec-2009 scf

Revert behavior change to setenv(), unsetenv() and putenv() until a more
thorough security review has been completed.


200195 07-Dec-2009 scf

Update the getenv(3) man page to reflect the recent change to the behavior
of setenv(), putenv() and unsetenv() when dealing with corrupt entries in
environ. They now output a warning and complete their task without error.

MFC after: 1 week


200191 06-Dec-2009 scf

Change the behavior of setenv(), putenv() and unsetenv() to continue parsing
instead of returning an error if a corrupt (not a "name=value" string) entry
in the environ array is detected when (re)-building the internal
environment. This should prevent applications or libraries from
experiencing issues arising from the expectation that these calls will
complete even with corrupt entries. The behavior is now as it was prior to
7.0.

Reviewed by: jilles
MFC after: 1 week


200190 06-Dec-2009 scf

Improve the comment within getenv() explaining the search order it takes to
find a variable. Include a note that it must not cause the internal
environment to be generated since malloc() depends upon getenv(). To call
malloc() would create a circular dependency.

Recommended by: green
Approved by: jilles
MFC after: 1 week


200150 05-Dec-2009 ed

Fix many "function declaration isn't a prototype" warnings in libc.

I've only fixed code that seems to be written by `us'. There are still
many warnings like this present in resolv/, rpc/, stdtime/ and yp/.


199987 01-Dec-2009 green

Temporarily revert the previous change because the linker has been
modified so that it will abort when the environment is bad.


199983 01-Dec-2009 green

Do not gratuitously fail *env(3) operations due to corrupt ('='-less)
**environ entries. This puts non-getenv(3) operations in line with
getenv(3) in that bad environ entries do not cause all operations to
fail. There is still some inconsistency in that getenv(3) in the
absence of any environment-modifying operation does not emit corrupt
environ entry warnings.

I also fixed another inconsistency in getenv(3) where updating the
global environ pointer would not be reflected in the return values.
It would have taken an intermediary setenv(3)/putenv(3)/unsetenv(3)
in order to see the change.


199264 14-Nov-2009 cperciva

Change the utrace log entry for malloc_init from (0, 0, 0) to (-1, 0, 0)
in order to distinguish it from free(NULL), which is logged as (0, 0, 0).

Reviewed by: jhb


197524 26-Sep-2009 alc

Make malloc(3) superpage aware. Specifically, if getpagesizes(3) returns
a large page size that is greater than malloc(3)'s default chunk size but
less than or equal to 4 MB, then increase the chunk size to match the large
page size.

Most often, using a chunk size that is less than the large page size is not
a problem. However, consider a long-running application that allocates and
frees significant amounts of memory. In particular, it frees enough memory
at times that some of that memory is munmap()ed. Up until the first
munmap(), a 1MB chunk size is just fine; it's not a problem for the virtual
memory system. Two adjacent 1MB chunks that are aligned on a 2MB boundary
will be promoted automatically to a superpage even though they were
allocated at different times. The trouble begins with the munmap(),
releasing a 1MB chunk will trigger the demotion of the containing superpage,
leaving behind a half-used 2MB reservation. Now comes the real problem.
Unfortunately, when the application needs to allocate more memory, and it
recycles the previously munmap()ed address range, the implementation of
mmap() won't be able to reuse the reservation. Basically, the coalescing
rules in the virtual memory system don't allow this new range to combine
with its neighbor. The effect being that superpage promotion will not
reoccur for this range of addresses until both 1MB chunks are freed at some
point in the future.

Reviewed by: jasone
MFC after: 3 weeks


196861 05-Sep-2009 kib

Handle zero size for posix_memalign. Return NULL or unique address
according to the 'V' option.

PR: standards/138307
MFC after: 1 week


196508 24-Aug-2009 ed

Our implementation of granpt(3) could be valid in the future.

When I wrote the pseudo-terminal driver for the MPSAFE TTY code, Robert
Watson and I agreed the best way to implement this, would be to let
posix_openpt() create a pseudo-terminal with proper permissions in place
and let grantpt() and unlockpt() be no-ops.

This isn't valid behaviour when looking at the spec. Because I thought
it was an elegant solution, I filed a bug report at the Austin Group
about this. In their last teleconference, they agreed on this subject.
This means that future revisions of POSIX may allow grantpt() and
unlockpt() to be no-ops if an open() on /dev/ptmx (if the implementation
has such a device) and posix_openpt() already do the right thing.

I'd rather put this in the manpage, because simply mentioning we don't
comply to any standard makes it look worse than it is. Right now we
don't, but at least we took care of it.

Approved by: re (kib)
MFC after: 3 days


194703 23-Jun-2009 ed

Simplify. We can just use .sinclude here.

Submitted by: Christoph Mallon


191789 04-May-2009 ed

Our grantpt(3) and unlockpt(3) don't comply with POSIX.


189207 01-Mar-2009 delphij

"-isoC-99" should be spelled without 'c'.


188497 11-Feb-2009 ed

Add two new routines: fdevname() and fdevname_r().

A more elegant way of obtaining a name of a character device by its file
descriptor on FreeBSD, is to use the FIODGNAME ioctl. Because a valid
file descriptor implies a file descriptor is visible in /dev, it will
always resolve a valid device name.

I'm adding a more friendly wrapper for this ioctl, called fdevname(). It
is a lot easier to use than devname() and also has better error
handling. When a device name cannot be resolved, it will just return
NULL instead of a generated device name that makes no sense.

Discussed with: kib


188305 08-Feb-2009 keramida

Fix language on atol(3) manpage. Add a COMPATIBILITY section
stating that in FreeBSD the atol() and atoll() functions affect
errno in the same way as strtol() and stroll().

PR: docs/126487
Submitted by: edwin
Reviewed by: trhodes, gabor
MFC after: 1 week


185514 01-Dec-2008 jasone

Fix a lock order reversal bug that could cause deadlock during fork(2).

Reported by: kib


185483 30-Nov-2008 jasone

Adjust an assertion to handle the case where a lock is contested, but
spinning is avoided due to running on a single-CPU system.

Reported by: stefanf


185468 30-Nov-2008 jasone

Do not spin when trying to lock on a single-CPU system.

Reported by: davidxu


184602 03-Nov-2008 jasone

Revert to preferring mmap(2) over sbrk(2) when mapping memory, due to
potential extreme contention in the kernel for multi-threaded applications
on SMP systems.

Reported by: kris


183969 17-Oct-2008 netchild

MTC r183949:
Allow to define MALLOC_PRODUCTION with a make variable instead of polluting
the global CFLAGS.

Reviewed by: jasone


183714 09-Oct-2008 peter

Clean out some empty mergeinfo records, presumably by people doing local
cp/mv operations. The full repo-relative URL should be specified for the
source in these cases.


182906 10-Sep-2008 jasone

Use PAGE_{SIZE,MASK,SHIFT} from machine/param.h rather than hard-coding
page size and using sysconf(3).

Suggested by: marcel


182809 06-Sep-2008 marcel

Unbreak ia64: pges are 8KB.


182225 27-Aug-2008 jasone

Add thread-specific caching for small size classes, based on magazines.
This caching allows for completely lock-free allocation/deallocation in the
steady state, at the expense of likely increased memory use and
fragmentation.

Reduce the default number of arenas to 2*ncpus, since thread-specific
caching typically reduces arena contention.

Modify size class spacing to include ranges of 2^n-spaced, quantum-spaced,
cacheline-spaced, and subpage-spaced size classes. The advantages are:
fewer size classes, reduced false cacheline sharing, and reduced internal
fragmentation for allocations that are slightly over 512, 1024, etc.

Increase RUN_MAX_SMALL, in order to limit fragmentation for the
subpage-spaced size classes.

Add a size-->bin lookup table for small sizes to simplify translating sizes
to size classes. Include a hard-coded constant table that is used unless
custom size class spacing is specified at run time.

Add the ability to disable tiny size classes at compile time via
MALLOC_TINY.


181915 20-Aug-2008 ed

Remove grantpt.c, which should have been deleted in the MPSAFE TTY commit.

The routines in grantpt.c have been moved to ptsname.c in the MPSAFE TTY
layer, because grantpt() is now effectively a no-op. I forgot to remove
the corresponding source file from libc.


181905 20-Aug-2008 ed

Integrate the new MPSAFE TTY layer to the FreeBSD operating system.

The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:

- Improved driver model:

The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.

If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.

- Improved hotplugging:

With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).

The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.

- Improved performance:

One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.

Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.

Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan


181733 14-Aug-2008 jasone

Move CPU_SPINWAIT into the innermost spin loop, in order to allow faster
preemption while busy-waiting.

Submitted by: Mike Schuster <schuster@adobe.com>


181732 14-Aug-2008 jasone

Re-order the terms of an expression in arena_run_reg_dalloc() to correctly
detect whether the integer division table is large enough to handle the
divisor. Before this change, the last two table elements were never used,
thus causing the slow path to be used for those divisors.


181438 08-Aug-2008 cperciva

Remove variables which are assigned values and never used thereafter.

Found by: LLVM/Clang Static Checker
Approved by: jasone


181266 03-Aug-2008 scf

Restructure and use different variables in the tests that involve
environ[0] to be more obvious that environ is not NULL before environ[0]
is tested. Although I believe the previous code worked, this change
improves code maintainability.

Reviewed by: ache
MFC after: 3 days


181150 02-Aug-2008 scf

Detect if the application has cleared the environ variable by setting
the first value (environ[0]) to NULL. This is in addition to the
current detection of environ being replaced, which includes being set to
NULL. Without this fix, the environment is not truly wiped, but appears
to be by getenv() until an *env() call is made to alter the enviroment.

This change is necessary to support those applications that use this
method for clearing environ such as Dovecot and Postfix. Applications
such as Sendmail and the base system's env replace environ (already
detected). While neither of these methods are defined by SUSv3, it is
best to support them due to historic reasons and in lieu of a clean,
defined method.

Add extra units tests for clearing environ using four different methods:
1. Set environ to NULL pointer.
2. Set environ[0] to NULL pointer.
3. Set environ to calloc()'d NULL-terminated array.
4. Set environ to static NULL-terminated array.

Noticed by: Timo Sirainen

MFC after: 3 days


180599 18-Jul-2008 jasone

Enhance arena_chunk_map_t to directly support run coalescing, and use
the chunk map instead of red-black trees where possible. Remove the
red-black trees and node objects that are obsoleted by this change. The
net result is a ~1-2% memory savings, and a substantial allocation speed
improvement.


180329 06-Jul-2008 danger

- This code was intially obtained from NetBSD, but it's missing licence
statement. Add the one from the current NetBSD version.
- Also bump a date to reflect my content changes I have done in previous
revision

Approved by: imp
MFC after: 3 days


180325 06-Jul-2008 danger

- Add description about a missing return value

PR: docs/75995
Submitted by: Tarc <tarc@po.cs.msu.su>
MFC after: 3 days


180323 06-Jul-2008 danger

- remove superfluous word
- remove contractions

MFC after: 3 days


180024 26-Jun-2008 danger

Mark the section describing return values with an appropriate section flag.

PR: docs/122818
MFC after: 3 days


179846 17-Jun-2008 ed

Don't export the unused __use_pts() routine.

The __use_pts() routine was once probably used by libutil to determine
if we are using BSD or UNIX98 style PTY device names. It doesn't seem to
be used outside grantpt.c, which means we can make it static and remove
it from the Symbol.map.

Reviewed by: cognet, kib
Approved by: philip (mentor)


179704 10-Jun-2008 jasone

In the error path through base_alloc(), release base_mtx [1].

Fix bit vector initialization for run headers.

Submitted by: [1] Mike Schuster <schuster@adobe.com>


178995 14-May-2008 jasone

Clean up cpp logic and comments.


178744 03-May-2008 jasone

Fix a comment.


178709 01-May-2008 jasone

Add a separate tree to track arena chunks that contain dirty pages.
This substantially improves worst case allocation performance, since
O(lg n) tree search can be used instead of O(n) tree iteration.

Use rb_wrap() instead of directly calling rb_*() macros.


178708 01-May-2008 jasone

Add rb_wrap(), which creates C function wrappers for most rb_*()
macros.

Add rb_foreach_next() and rb_foreach_reverse_prev(), which make it
possible to re-synchronize tree iteration after the tree has been
modified.

Rename rb_tree_new() to rb_new().


178683 29-Apr-2008 gonzo

Set QUANTUM_2POW_MIN and SIZEOF_PTR_2POW parameters for MIPS

Approved by: imp


178645 29-Apr-2008 jasone

Check for integer overflow before calling sbrk(2), since it uses a
signed increment argument, but the size is an unsigned integer.


178457 24-Apr-2008 ru

Stricter check for integer overflow.


178440 23-Apr-2008 jasone

Implement red-black trees without using parent pointers, and store the
color bit in the least significant bit of the right child pointer, in
order to reduce red-black tree linkage overhead by ~2X as compared to
sys/tree.h.

Use the new red-black tree implementation in malloc, which drops
memory usage by ~0.5 or ~1%, for 32- and 64-bit systems, respectively.


178313 19-Apr-2008 ru

Don't forget to free() currency_symbol and asciivalue when multiple
conversion specifiers for them are present.

Submitted by: Maxim Dounin <mdounin@mdounin.ru>
Obtained from: NetBSD (partially)
MFC after: 3 days


178312 19-Apr-2008 ru

Better strfmon(3) conversion specifiers sanity checking.

There were no checks for left and right precisions at all, and
a check for field width had integer overflow bug.

Reported by: Maksymilian Arciemowicz
Security: http://securityreason.com/achievement_securityalert/53
Submitted by: Maxim Dounin <mdounin@mdounin.ru>
MFC after: 3 days


178175 13-Apr-2008 delphij

Use calloc() instaed of zeroing memory ourselves.


176909 07-Mar-2008 jasone

Remove stale #include <machine/atomic.h>, which as needed by lazy
deallocation.


176632 28-Feb-2008 scf

Replace the use of warnx() with direct output to stderr using _write().
This reduces the size of a statically-linked binary by approximately 100KB
in a trivial "return (0)" test application. readelf -S was used to verify
that the .text section was reduced and that using strlen() saved a few
more bytes over using sizeof(). Since the section of code is only called
when environ is corrupt (program bug), I went with fewer bytes over fewer
cycles.

I made minor edits to the submitted patch to make the output resemble
warnx().

Submitted by: kib bz
Approved by: wes (mentor)
MFC after: 5 days


176369 17-Feb-2008 jasone

Fix a race condition in arena_ralloc() for shrinking in-place large
reallocation, when junk filling is enabled. Junk filling must occur
prior to shrinking, since any deallocated trailing pages are immediately
available for use by other threads.

Reported by: Mats Palmgren <mats.palmgren@bredband.net>


176368 17-Feb-2008 jasone

Remove support for lazy deallocation. Benchmarks across a wide range of
allocation patterns, number of CPUs, and MALLOC_OPTIONS settings indicate
that lazy deallocation has the potential to worsen throughput dramatically.
Performance degradation occurs when multiple threads try to clear the lazy
free cache simultaneously. Various experiments to avoid this bottleneck
failed to completely solve this problem, while adding yet more complexity.


176103 08-Feb-2008 jasone

Fix a bug in lazy deallocation that was introduced when
arena_dalloc_lazy_hard() was split out of arena_dalloc_lazy() in revision
1.162.

Reduce thundering herd problems in lazy deallocation by randomly varying
how many probes a thread does before taking the slow path.


176100 08-Feb-2008 jasone

Clean up manipulation of chunk page map elements to remove some tenuous
assumptions about whether bits are set at various times. This makes
adding other flags safe.

Reorganize functions in order to inline i{m,c,p,s,re}alloc(). This
allows the entire fast-path call chains for malloc() and free() to be
inlined. [1]

Suggested by: [1] Stuart Parmenter <stuart@mozilla.com>


176022 06-Feb-2008 jasone

Track dirty unused pages so that they can be purged if they exceed a
threshold, according to the 'F' MALLOC_OPTIONS flag. This obsoletes the
'H' flag.

Try to realloc() large objects in place. This substantially speeds up
incremental large reallocations in the common case.

Fix a bug in arena_ralloc() that caused relocation of sub-page objects
even if the old and new sizes were in the same size class.

Maintain trees of runs and simplify the per-chunk page map. This allows
logarithmic-time searching for sufficiently large runs in
arena_run_alloc(), whereas the previous algorithm required linear time
in the worst case.

Break various large functions into smaller sub-functions, and inline
only the functions that are in the fast path for small object
allocation/deallocation.

Remove an unnecessary check in base_pages_alloc_mmap().

Avoid integer division in choose_arena() for the NO_TLS case on
single-CPU systems.


175362 15-Jan-2008 jhb

Remove some now-unused macros.

MFC after: 1 week


175352 15-Jan-2008 jhb

Put back the openpty(3) and ptsname(3) fixes but don't disable ptsname(3)
on pts(4) devices this time. This fixes the issues while leaving pts(4)
enabled on HEAD.


175350 15-Jan-2008 cperciva

Back out last commit, since it accidentally broke pts.

The security fix will be re-committed soon, hopefully without breaking
anything.


175330 14-Jan-2008 cperciva

Fix issues which allow snooping on ptys. [08:01]

Fix an off-by-one error in inet_network(3). [08:02]

Security: FreeBSD-SA-08:01.pty
Security: FreeBSD-SA-08:02.libc


175317 14-Jan-2008 das

Changing 'r' to a size_t in the previous commit turned quicksort
into slowsort for some sequences because different parts of the
code used 'r' to store two different things, one of which was
signed. Clean things up by splitting 'r' into two variables, and
use a more meaningful name.


175259 13-Jan-2008 das

Use size_t to avoid overflow when sorting arrays larger than 2 GB.

PR: 111085
MFC after: 2 weeks


175075 03-Jan-2008 jasone

Enable both sbrk(2)- and mmap(2)-based memory acquisition methods by
default. This has the disadvantage of rendering the datasize resource
limit irrelevant, but without this change, legitimate uses of more
memory than will fit in the data segment are thwarted by default.

Fix chunk_alloc_mmap() to work correctly if initial mapping is not
chunk-aligned and mapping extension fails.


175011 31-Dec-2007 jasone

Fix a major chunk-related memory leak in chunk_dealloc_dss_record(). [1]

Clean up DSS-related locking and protect all pertinent variables with
dss_mtx (remove dss_chunks_mtx). This fixes race conditions that could
cause chunk leaks.

Reported by: [1] kris


175004 31-Dec-2007 jasone

Fix a bug related to sbrk() calls that could cause address space leaks.
This is a long-standing bug, but until recent changes it was difficult
to trigger, and even then its impact was non-catastrophic, with the
exception of revision 1.157.

Optimize chunk_alloc_mmap() to avoid the need for unmapping pages in the
common case. Thanks go to Kris Kennaway for a patch that inspired this
change.

Do not maintain a record of previously mmap'ed chunk address ranges.
The original intent was to avoid the extra system call overhead in
chunk_alloc_mmap(), which is no longer a concern. This also allows some
simplifications for the tree of unused DSS chunks.

Introduce huge_mtx and dss_chunks_mtx to replace chunks_mtx. There was
no compelling reason to use the same mutex for these disjoint purposes.

Avoid memset() for huge allocations when possible.

Maintain two trees instead of one for tracking unused DSS address
ranges. This allows scalable allocation of multi-chunk huge objects in
the DSS. Previously, multi-chunk huge allocation requests failed if the
DSS could not be extended.


174957 28-Dec-2007 jasone

Back out premature commit of previous version.


174956 28-Dec-2007 jasone

Maintain two trees instead of one (old_chunks --> old_chunks_{ad,szad}) in
order to support re-use of multi-chunk unused regions within the DSS for
huge allocations. This generalization is important to correct function
when mmap-based allocation is disabled.

Avoid zeroing re-used memory in the DSS unless it really needs to be
zeroed.


174953 28-Dec-2007 jasone

Release chunks_mtx for all paths through chunk_dealloc().

Reported by: kris


174950 27-Dec-2007 jasone

Add the 'D' and 'M' run time options, and use them to control whether
memory is acquired from the system via sbrk(2) and/or mmap(2). By default,
use sbrk(2) only, in order to support traditional use of resource limits.
Additionally, when both options are enabled, prefer the data segment to
anonymous mappings, in order to coexist better with large file mappings
in applications on 32-bit platforms. This change has the potential to
increase memory fragmentation due to the linear nature of the data
segment, but from a performance perspective this is mitigated by the use
of madvise(2). [1]

Add the ability to interpret integer prefixes in MALLOC_OPTIONS
processing. For example, MALLOC_OPTIONS=lllllllll can now be specified as
MALLOC_OPTIONS=9l.

Reported by: [1] rwatson
Design review: [1] alc, peter, rwatson


174842 21-Dec-2007 jhb

Clean up some of the pts(4) vs pty(4) stuff in grantpt(3) and friends:
- Use PTY* for all pty(4) related constants.
- Use PTMX* for all pts(4) related constants.
- Consistently use _PATH_DEV PTMX rather than "/dev/ptmx".
- Revert 1.7 and properly fix it by using the correct prefix string for
pts(4) masters.

MFC after: 3 days


174745 18-Dec-2007 jasone

Use fixed point integer math instead of floating point math when
calculating run sizes. Use of the floating point unit was a potential
pessimization to context switching for applications that do not otherwise
use floating point math. [1]

Reformat cpp macro-related comments to improve consistency.

Submitted by: das


174695 17-Dec-2007 jasone

Refactor features a bit in order to make it possible to disable lazy
deallocation and dynamic load balancing via the MALLOC_LAZY_FREE and
MALLOC_BALANCE knobs. This is a non-functional change, since these
features are still enabled when possible.

Clean up a few things that more pedantic compiler settings would cause
complaints over.


174684 16-Dec-2007 das

Implement and document nan(), nanf(), and nanl(). This commit
adds two new directories in msun: ld80 and ld128. These are for
long double functions specific to the 80-bit long double format
used on x86-derived architectures, and the 128-bit format used on
sparc64, respectively.


174565 13-Dec-2007 jhb

Update posix_openpt(3) to handle 512 ptys. This was missed in the earlier
pty(4) changes.

MFC after: 3 days


174541 11-Dec-2007 ache

Fix typo in the comment


174002 28-Nov-2007 jasone

Only zero large allocations when necessary (for calloc()).


173969 27-Nov-2007 jasone

Document the B and L MALLOC_OPTIONS.


173968 27-Nov-2007 jasone

Implement dynamic load balancing of thread-->arena mapping, based on lock
contention. The intent is to dynamically adjust to load imbalances, which
can cause severe contention.

Use pthread mutexes where possible instead of libc "spinlocks" (they aren't
actually spin locks). Conceptually, this change is meant only to support
the dynamic load balancing code by enabling the use of spin locks, but it
has the added apparent benefit of substantially improving performance due to
reduced context switches when there is moderate arena lock contention.

Proper tuning parameter configuration for this change is a finicky business,
and it is very much machine-dependent. One seemingly promising solution
would be to run a tuning program during operating system installation that
computes appropriate settings for load balancing. (The pthreads adaptive
spin locks should probably be similarly tuned.)


173966 27-Nov-2007 jasone

Implement lazy deallocation of small objects. For each arena, maintain a
vector of slots for lazily freed objects. For each deallocation, before
doing the hard work of locking the arena and deallocating, try several times
to randomly insert the object into the vector using atomic operations.

This approach is particularly effective at reducing contention for
multi-threaded applications that use the producer-consumer model, wherein
one producer thread allocates objects, then multiple consumer threads
deallocate those objects.


173965 27-Nov-2007 jasone

Avoid re-zeroing memory in calloc() when possible.


173964 27-Nov-2007 jasone

Fix stats printing of the amount of memory currently consumed by huge
allocations. [1]

Fix calculation of the number of arenas when 'n' is specified via
MALLOC_OPTIONS.

Clean up various style inconsistencies.

Obtained from: [1] NetBSD


172790 19-Oct-2007 davidxu

Remove out of date notes, the atoi code is thread-safe and async-cancel
safe.

Discussed with: desichen


172294 22-Sep-2007 scf

The precision for a string argument in a call to warnx() needs to be cast
to an int to remove the warning from using a size_t variable on 64-bit
platforms.

Submitted by: Xin LI <delphij@FreeBSD.org>
Approved by: wes
Approved by: re (kensmith)


172191 15-Sep-2007 scf

Skip rebuilding environ in setenv() only upon reuse of an active variable;
inactive variables should cause a rebuild of environ, otherwise, exec()'d
processes will be missing a variable in environ that has been unset then
set.

Submitted by: Taku Yamamoto <taku@tackymt.homeip.net>
Reviewed by: ache
Approved by: wes (mentor)
Approved by: re (kensmith)


171525 20-Jul-2007 scf

Added environ-replacement detection. For programs that "clean" (i.e., su)
or replace (i.e., zdump) the environment after a call to setenv(), putenv()
or unsetenv() has been made, a few changes were made.
- getenv() will return the value from the new environ array.
- setenv() was split into two functions: __setenv() which is most of the
previous setenv() without checks on the name and setenv() which
contains the checks before calling __setenv().
- setenv(), putenv() and unsetenv() will unset all previous values and
call __setenv() on all entries in the new environ array which in turn
adds them to the end of the envVars array. Calling __setenv() instead
of setenv() is done to avoid the temporary replacement of the '=' in a
string with a NUL byte. Some strings may be read-only data.

Added more regression checks for clearing the environment array.

Replaced gettimeofday() with getrusage() in timing regression check for
better accuracy.

Fixed an off-by-one bug in __remove_putenv() in the use of memmove(). This
went unnoticed due to the allocation of double the number of environ
entries when building envVars.

Fixed a few spelling mistakes in the comments.

Reviewed by: ache
Approved by: wes
Approved by: re (kensmith)


171195 04-Jul-2007 scf

Significantly reduce the memory leak as noted in BUGS section for
setenv(3) by tracking the size of the memory allocated instead of using
strlen() on the current value.

Convert all calls to POSIX from historic BSD API:
- unsetenv returns an int.
- putenv takes a char * instead of const char *.
- putenv no longer makes a copy of the input string.
- errno is set appropriately for POSIX. Exceptions involve bad environ
variable and internal initialization code. These both set errno to
EFAULT.

Several patches to base utilities to handle the POSIX changes from
Andrey Chernov's previous commit. A few I re-wrote to use setenv()
instead of putenv().

New regression module for tools/regression/environ to test these
functions. It also can be used to test the performance.

Bump __FreeBSD_version to 700050 due to API change.

PR: kern/99826
Approved by: wes
Approved by: re (kensmith)


170798 15-Jun-2007 jasone

Add information about the implications of using mmap(2) instead of sbrk(2).

Submitted by: bmah, jhb


170796 15-Jun-2007 jasone

Fix junk/zero filling for realloc(). Junk filling was missing in one case,
and zero filling was broken in a way that could cause memory corruption.

Update comments.


169850 22-May-2007 jon

Backout 1.5 as requested by deischen


169847 22-May-2007 jon

__cleanup() is needed for ports/devel/valgrind, export it.


169177 01-May-2007 ache

Back out all POSIXified *env() changes.

Not because I admit they are technically wrong and not because of bug
reports (I receive nothing). But because I surprisingly meets so
strong opposition and resistance so lost any desire to continue that.

Anyone who interested in POSIX can dig out what changes and how
through cvs diffs.


169146 30-Apr-2007 ache

Bump .Dd

Suggested by: Henrik Brix Andersen <henrik@brixandersen.dk>


169142 30-Apr-2007 ache

Add phrase
"so altering the argument shall change the environment."
into putenv description.


169138 30-Apr-2007 ache

Make putenv() fully conforms to Open Group specs Issue 6
(also IEEE Std 1003.1-2001)

The specs explicitly says that altering passed string
should change the environment, i.e. putenv() directly puts its arg
into environment (unlike setenv() which just copies it there).
It means that putenv() can't be implemented via setenv()
(like we have before) at all. Putenv() value lives (allows modifying)
up to the next putenv() or setenv() call.


169111 30-Apr-2007 ache

Remove special case skipping initial '=' of the setenv() value "for
compatibility with the different environment conventions" (man page).
With the standards, we don't have them different anymore and
IEEE Std 1003.1-2001 says that

"The values that the environment variables may be assigned are not
restricted except that they are considered to end with a null byte"


169109 30-Apr-2007 ache

Make setenv, putenv, getenv and unsetenv conforming to Open Group specs
Issue 6 (also IEEE Std 1003.1-2001) in following areas:
args, return, errors.

Putenv still needs rewriting because specs explicitly says that
altering passed string later should change the environment (currently we
copy the string so can't provide that).


169092 29-Apr-2007 deischen

Use C comments since we now preprocess these files with CPP.


168578 10-Apr-2007 ru

Swap "underflow"/"overflow" in the table header.

Submitted by: Ricardo Nabinger Sanchez
MFC after: 3 days


168029 29-Mar-2007 jasone

Use size_t instead of unsigned for pagesize-related values, in order to
avoid downcasting issues. In particular, this change fixes
posix_memalign(3) for alignments greater than 2^31 on LP64 systems.

Make sure that NDEBUG is always set to be compatible with MALLOC_DEBUG. [1]

Reported by: [1] Lee Hyo geol <hyogeollee@gmail.com>


168003 28-Mar-2007 jasone

Remove the run promotion/demotion machinery. Replace it with red-black
trees that track all non-full runs for each bin. Use the red-black
trees to be able to guarantee that each new allocation is placed in the
lowest address available in any non-full run. This change completes the
transition to allocating from low addresses in order to reduce the
retention of sparsely used chunks.

If the run in current use by a bin becomes empty, deallocate the run
rather than retaining it for later use. The previous behavior had the
tendency to spread empty runs across multiple chunks, thus preventing
the release of chunks that were completely unused.

Generalize base_chunk_alloc() (and rename it to base_pages_alloc()) to
handle allocation sizes larger than the chunk size, so that it is
possible to support chunk sizes that are smaller than an arena object.

Reduce the minimum chunk size from 64kB to 8kB.

Optimize tracking of addresses for deleted chunks.

Fix a statistics bug for huge allocations.


167969 28-Mar-2007 jasone

Update the IMPLEMENTATION NOTES section to reflect recent malloc
enhancements.


167967 28-Mar-2007 jasone

Add a HISTORY section.


167872 24-Mar-2007 jasone

Fix some subtle bugs for posix_memalign() having to do with integer
rounding and overflow. Carefully document what the various overflow
tests actually detect.

The bugs mostly canceled out, such that the worst possible failure
cases resulted in non-fatal over-allocations.


167853 23-Mar-2007 jasone

Fix posix_memalign() for large objects. Now that runs are extents rather
than binary buddies, the alignment guarantees are weaker, which requires
a more complex aligned allocation algorithm, similar to that used for
alignment greater than the chunk size.

Reported by: matteo


167828 23-Mar-2007 jasone

Use extents rather than binary buddies to track free pages within
chunks. This allows runs to be any multiple of the page size. The
primary advantage is that large objects are no longer constrained to be
2^n pages, which can dramatically decrease internal fragmentation for
large objects. This also allows the sizes for runs that back small
objects to be more finely tuned.

Free runs are searched for linearly using the chunk page map (with the
help of some heuristic optimizations). This changes the allocation
policy from "first best fit" to "first fit". A prototype red-black tree
implementation for tracking free runs that implemented "first best fit"
did not cause a measurable speed or memory usage difference for
realistic chunk sizes (though of course it is possible to construct
benchmarks that favor one allocation policy over another).

Refine the handling of fullness constraints for small runs to be more
tunable.

Restructure the per chunk page map to contain only two fields per entry,
rather than four. Also, increase each entry from 4 to 8 bytes, since it
allows for 32-bit integers, without increasing the number of chunk
header pages.

Relax the maximum chunk size constraint. This is of no practical
interest; it is merely fallout from the chunk page map restructuring.

Revamp statistics gathering and reporting to be faster, clearer and more
informative. Statistics gathering is fast enough now to have little
to no impact on application speed, but it still requires approximately
two extra pages of memory per arena (per process). This memory overhead
may be acceptable for most systems, but we still need to leave
statistics gathering disabled by default in RELENG branches.

Rename NO_MALLOC_EXTRAS to MALLOC_PRODUCTION in order to make its intent
clearer (i.e. it should be defined in RELENG branches).


167733 20-Mar-2007 jasone

Avoid using vsnprintf(3) unless MALLOC_STATS is defined, in order to
avoid substantial potential bloat for static binaries that do not
otherwise use any printf(3)-family functions. [1]

Rearrange arena_run_t so that the region bitmask can be minimally sized
according to constraints related to each bin's size class. Previously,
the region bitmask was the same size for all run headers, which wasted
a measurable amount of memory.

Rather than making runs for small objects as large as possible, make
runs as small as possible such that header overhead stays below a
certain bound. There are two exceptions that override the header
overhead bound:

1) If the bound is impossible to honor, it is relaxed on a
per-size-class basis. Since there is one bit of header
overhead per object (plus a constant), it is impossible to
achieve a header overhead less than or equal to 1/(# of bits
per object). For the current setting of maximum 0.5% header
overhead, this relaxation comes into play for {2, 4, 8,
16}-byte objects, for which header overhead is (on 64-bit
systems) {7.1, 4.3, 2.2, 1.2}%, respectively.

2) There is still a cap on small run size, still set to 64kB.
This comes into play for {1024, 2048}-byte objects, for which
header overhead is {1.6, 3.1}%, respectively.

In practice, this reduces the run sizes, which makes worst case
low-water memory usage due to fragmentation less bad. It also reduces
worst case high-water run fragmentation due to non-full runs, but this
is only a constant improvement (most important to small short-lived
processes).

Reduce the default chunk size from 2MB to 1MB. Benchmarks indicate that
the external fragmentation reduction makes 1MB the new sweet spot (as
small as possible without adversely affecting performance).

Reported by: [1] kientzle


166890 22-Feb-2007 jasone

Modify chunk_alloc() to prefer mmap()ed memory over sbrk()ed memory.
This has no impact unless USE_BRK is defined (32-bit platforms), in
which case user allocations are allocated via mmap() if at all possible,
in order to avoid the possibility of unreclaimable chunks in the data
segment.

Fix an obscure bug in base_alloc() that could have allowed undefined
behavior if an application were to use sbrk() in conjunction with a
USE_BRK-enabled malloc.


166375 31-Jan-2007 jasone

Fix a utrace(2)-related bug in calloc(3).

Integrate various pedantic cleanups.

Submitted by: Andrew Doran <ad@netbsd.org>


165903 09-Jan-2007 imp

Per Regents of the University of Calfornia letter, remove advertising
clause.

# If I've done so improperly on a file, please let me know.


165473 23-Dec-2006 jasone

Implement chunk allocation/deallocation hysteresis by caching one spare
chunk per arena, rather than immediately deallocating all unused chunks.
This fixes a potential performance issue when allocating/deallocating
an object of size (4kB..1MB] in a loop.

Reported by: davidxu


163262 12-Oct-2006 trhodes

Note that the value from getenv() should not be modified by applications.

PR: 60544
Reviewed by: ru


163108 07-Oct-2006 trhodes

getenv.3: Put "is" on a line with other words
getobjformat.3: "takes precedence over" is not an envrionment variable.

PR: 75545
Submitted by: n-kogane@syd.odn.ne.jp
MFC after: 3 days


162841 30-Sep-2006 ru

Revise markup in recently added manpages.


162574 23-Sep-2006 ache

Keep compatible parts in sync with OpenBSD v1.21, add some comments.
No functional changes.


162557 22-Sep-2006 ache

Remove code #ifndef'ed in prev. commit to stay in sync with OpenBSD
v1.21 which just do that.


162555 22-Sep-2006 ache

Be more GNU compatible:
don't be greedy on the GNU "::" extension when arg separated by whitespace
and POSIX_CORRECTLY is set. From POSIX point of view this is unclear
situation, so minimal assumption looks right.


162385 17-Sep-2006 ru

Markup fixes.


162163 08-Sep-2006 jasone

Change the way base allocation is done for internal malloc data
structures, in order to avoid the possibility of attempted recursive
lock acquisition for chunks_mtx.

Reported by: Slawa Olhovchenkov <slw@zxy.spb.ru>


162040 05-Sep-2006 ru

alloca() cannot check if the allocation is valid; mention the consequences.

Obtained from: OpenBSD


161831 01-Sep-2006 marcel

Enable TLS on PowerPC.


161803 01-Sep-2006 marcel

Enable TLS on ia64.


161263 13-Aug-2006 cperciva

Correctly handle the case in calloc(num, size) where
(size_t)(num * size) == 0
but both num and size are nonzero.

Reported by: Ilja van Sprundel
Approved by: jasone
Security: Integer overflow; calloc was allocating 1 byte in
response to a request for a multiple of 2^32 (or 2^64)
bytes instead of returning NULL.


161131 09-Aug-2006 marcel

Define NO_TLS on PowerPC.

See also: PR ia64/91846


160761 27-Jul-2006 jasone

Conditionally expand the size_invs lookup table in arena_run_reg_dalloc()
so that architectures with a quantum of 8 (rather than 16) work.

Restore arm's quantum to 8.

Submitted by: jmg


160751 27-Jul-2006 cognet

Use 4 as QUANTUM_2POW_MIN on arm as it is on any other architecture, to avoid
triggering an assertion later.


160736 27-Jul-2006 jasone

Fix cpp logic in arena_malloc() to adjust size when assertions are enabled,
even if stats gathering is disabled. [1]

Remove 'size' parameter from several functions that do not use it.

Reported by: [1] ache


160066 01-Jul-2006 jasone

Use some math tricks in arena_run_reg_dalloc() to avoid actual division, as
well as avoiding a switch statement. This change has no significant impact
to performance when branch prediction is successful at predicting the sizes
of objects passed to free(), but in the case that the object sizes are
semi-random, this change has the potential to prevent many branch prediction
misses, thus improving performance substantially.

Take advantage of alignment guarantees in ipalloc(), and pad object sizes to
something less than a power of two when possible. This has the potential
to substantially reduce internal fragmentation for objects allocated via
posix_memalign().

Avoid an unnecessary pow2_ceil() call in arena_ralloc().

Submitted by: djam8193ah@hotmail.com


160055 30-Jun-2006 jasone

Make the behavior of malloc(0) standards-compliant by getting rid of nil,
and instead creating a small allocation for each malloc(0) call. The
optional SysV compatibility behavior remains unchanged.

Add a couple of assertions.

Fix a couple of typos in error message strings.


159879 23-Jun-2006 keramida

twalk() expects an `action' function not a comparison function.
The text is correct in the "DESCRIPTION" section, so fix "SYNOPSIS"
to use the correct name.

PR: docs/90498
Submitted by: Vasil Dimov
MFC after: 3 days


159798 20-Jun-2006 jasone

Add a missing case for the switch statement in arena_run_reg_dalloc(). [1]

Fix a leak in chunk_dealloc(). [2]

Reported by: [1] djam8193ah@hotmail.com,
[2] Ville-Pertti Keinonen <will@exomi.com>


158774 20-May-2006 maxim

o .Xr strtonum(3).

MFC after: 1 week


158749 19-May-2006 jkim

Correct decoding a string containing '/'.

PR: 97485
Submitted by: Mikko Tyolajarvi < mbsd at pacbell dot net >


158383 10-May-2006 jasone

Increase the minimum chunk size by a power of two (32kB --> 64kB, assuming
4kB pages), in order to avoid dangerous rounding error when calculating
fullness limits during run promotion/demotion.

Convert a structure bitfield to a normal field in areana_run_t. This should
have been changed along with the other fields in revision 1.120.


158062 27-Apr-2006 jasone

Change the semantics of brk_max to dynamically deal with data segment
bounds. [1]

Modify logic for utilizing the data segment, such that it is possible to
create huge allocations there.

Shrink the data segment when deallocating a chunk, if it is at the end of
the data segment.

Rename chunk_size to csize in huge_malloc(), in order to avoid masking a
static variable of the same name. [1]

Reported by: Paul Allen <nospam@ugcs.caltech.edu>


157735 13-Apr-2006 schweikh

s/soley/solely


157539 05-Apr-2006 jasone

Add an unreachable return statement, in order to avoid a compiler warning
for non-standard optimization levels.

Reported by: Michael Zach <zach@webges.com>


157532 05-Apr-2006 jasone

Only initialize the first per-chunk page map element for free runs. This
makes run split/coalesce operations of complexity lg(n) rather than n.


157508 04-Apr-2006 jasone

Add malloc_usable_size() to the RETURN VALUES section.


157498 04-Apr-2006 jasone

Add init_lock, and use it to protect against allocator initialization
races. This isn't currently necessary for libpthread or libthr, but
without it external threads libraries like the linuxthreads port are
not safe to use.

Reported by: ganbold@micom.mng.net


157463 04-Apr-2006 jasone

Refactor per-run bitmap manipulation functions so that bitmap offsets only
have to be calculated once per allocator operation.

Make nil const.

Update various comments.

Remove/avoid division where possible.

For the one division operation that remains in the critical path, add a
switch statement that has a case for each small size class, and do division
with a constant divisor in each case. This allows the compiler to generate
optimized code that does not use hardware division [1].

Obtained from: peter [1]


157310 30-Mar-2006 jasone

Optimize runtime performance, primary using the following techniques:

* Avoid choosing an arena until it's certain that an arena is needed
for allocation.

* Convert division/multiplication to bitshifting where possible.

* Avoid accessing TLS variables in single-threaded code.

* Reduce the amount of pointer dereferencing.

* Move lock acquisition in critical paths to only protect the the code
that requires synchronization, and completely remove locking where
possible.


157236 28-Mar-2006 jasone

Add malloc_usable_size(3).

Discussed with: arch@


157162 26-Mar-2006 jasone

Allow the 'n' option to decrease the number of arenas below the default,
to as little as one arena. Also, limit the number of arenas to avoid a
potential invariant violation in base_alloc().


157161 26-Mar-2006 jasone

Add comments and reformat/rearrange code. There are no significant
functional changes in this commit.


157106 24-Mar-2006 jasone

Convert TINY_MIN_2POW from a cpp macro to tiny_min_2pow (a variable), and
determine its value at run time according to other relevant values. This
avoids the creation of runs that are incompletely utilized, as long as
pagesize isn't too large (>32kB, given the current RUN_MIN_REGS_2POW
setting).

Increase the size of several structure bitfields in arena_run_t in order
to avoid integer overflow in the case that a run's header does not overlap
with the space that is usable as application allocation regions. Given
the tiny_min_2pow change, this fix has no additional impact unless
pagesize is >32kB.

Reported by: kris


157070 24-Mar-2006 jasone

Add USE_BRK-specific code in malloc_init_hard() to allow the first
internally used chunk to start at the beginning of the heap, rather
than at a chunk-aligned address. This reduces mapped memory somewhat
for 32-bit architectures.

Add the arena_run_link_t type and use it wherever a run object is only
used as a ring 'header'. This saves approximately 40 kB of memory per
arena.

Remove an obsolete (no longer used) code path from base_alloc(), which
supported the internal allocation of objects larger than the chunk
size.

Enhance chunk_dealloc() to cache chunk addresses for all deallocated
chunks. This has no impact for most programs, but has the potential
to reduce VM map fragmentation for programs that use huge
allocations.


156902 20-Mar-2006 jasone

Separate completely full runs from runs that are merely almost full, so
that no linear searching is necessary if we resort to allocating from a
run that is known to be mostly full. There are pathological edge cases
that could have caused severely degraded performance, and this change
fixes that.


156890 19-Mar-2006 jasone

Optimize realloc() to reallocate in place if the old and new sizes are
close enough to each other that reallocation would allocate a new region
of the same size. This improves the performance of repeated incremental
reallocations by up to three orders of magnitude. [1]

Fix arena_new() to properly constrain run size if a small chunk size was
specified during runtime configuration.

Suggested by: se [1]


156800 17-Mar-2006 jasone

Modify allocation policy, in order to avoid excessive fragmentation for
allocation patterns that involve a relatively even mixture of many
different size classes.

Reduce the chunk size from 16 MB to 2 MB. Since chunks are now carved up
using an address-ordered first best fit policy, VM map fragmentation is
much less likely, which makes smaller chunks not as much of a risk. This
reduces the virtual memory size of most applications.

Remove redzones, since program buffer overruns are no longer as likely to
corrupt malloc data structures.

Remove the C MALLOC_OPTIONS flag, and add H and S.


156741 15-Mar-2006 ru

Add a non-optional newline after ".Bx".


156739 15-Mar-2006 andre

Revert previous changes as we do support the .Ox macro for OpenBSD.

Pointed out by: ceri, ru, delphij


156716 14-Mar-2006 ache

POSIXed strtoll() (and ours one too) can set errno to EINVAL, so check
it first.

Approved by: andre


156708 14-Mar-2006 andre

Fix HISTORY and point to OpenBSD.


156707 14-Mar-2006 andre

Import of OpenBSD's strtonum(3) which is a nicer version of strtoll(3)
providing proper error checking and other improvements.

Obtained from: OpenBSD
Requested by: flz (to port Open[BGP|OSPF]D)
MFC after: 3 days


156613 13-Mar-2006 deischen

Add each directory's symbol map file to SYM_MAPS.


156608 13-Mar-2006 deischen

Add symbol maps and initial symbol version definitions to libc.

Reviewed by: davidxu


156043 26-Feb-2006 wkoszek

Fix typo in manual page reference.

Approved by: cognet (mentor)
MFC after: 3 days


155593 13-Feb-2006 kan

Remove extra slash from pty slave device name returned by ptsname.


155272 04-Feb-2006 jasone

Fix calculation of the number of arenas to use on multi-processor systems.


155181 01-Feb-2006 joel

Expand contractions.


154965 29-Jan-2006 cognet

If the sysctl kern.pts.enable doesn't exist, check that /dev/ptmx is there,
and if so, use the pts system.

Suggested by: rwatson


154890 27-Jan-2006 jasone

Remove unwarranted uses of 'goto'.


154887 27-Jan-2006 jasone

Add NO_MALLOC_EXTRAS, so that various extra features that can cause
performance degradation can be disabled via something like the following
in /etc/malloc.conf:

CFLAGS+=-DNO_MALLOC_EXTRAS

Suggested by: deischen


154886 27-Jan-2006 jasone

Fix the type of a statistics counter (unsigned --> unsigned long).


154882 27-Jan-2006 jasone

Clean up statistics gathering and printing.


154853 26-Jan-2006 jasone

Optimize arena_bin_pop() to reduce the number of separator operations.
Remove the block of code that tries to use delayed regions in LIFO order,
since from a policy perspective, it conflicts with LRU caching of newly
coalesced regions in arena_undelay(). There are numerous policy
alternatives, and it isn't readily obvious which (if any) is superior;
this change at least has the virtue of being consistent with policy.


154836 26-Jan-2006 cognet

ptsname() bits for pts.


154798 25-Jan-2006 jasone

Remove a redundant variable assignment in arena_reg_frag_alloc().


154797 25-Jan-2006 jasone

If no coalesced exact-fit small regions are available, but delayed exact-
fit regions are available, use the delayed regions in LIFO order, in order
to increase locality of reference. We might expect this to cause delayed
regions to be removed from the delay ring buffer more often (since we're
now re-using more recently buffered regions), but numerous tests indicate
that the overall impact on memory usage tends to be good (reduced
fragmentation).

Re-work arena_frag_reg_alloc() so that when large free regions are
exhausted, it uses small regions in a way that favors contiguous allocation
of sequentially allocated small regions. Use arena_frag_reg_alloc() in
this capacity, rather than directly attempting over-fitting of small
requests when no large regions are available.

Remove the bin overfit statistic, since it is no longer relevant due to
the arena_frag_reg_alloc() changes.

Do not specify arena_frag_reg_alloc() as an inline function. It is too
large to benefit much from being inlined, and it is also called in two
places, only one of which is in the critical path (the other call bloated
arena_reg_alloc()).

Call arena_coalesce() for a region before caching it with
arena_mru_cache().

Add assertions that detect the attempted caching of adjacent free regions,
so that we notice this problem when it is first created, rather than in
arena_coalesce(), when it's too late to know how the problem arose.

Reported by: Hans Blancke


154700 23-Jan-2006 jasone

Make the 'C' and 'c' malloc options consistent with other options; 'C'
doubles the cache size, and 'c' halves the cache size.


154699 23-Jan-2006 jasone

In arena_chunk_reg_alloc(), try to avoid touching the last page in the
chunk during initialization, in order to avoid physically backing the
page unless data are allocated there.


154562 20-Jan-2006 jasone

Use uintptr_t rather than size_t when casting pointers to integers. Also,
fix the few remaining casting style(9) errors that remained after the
functional change.

Reported by: jmallett


154557 19-Jan-2006 jasone

Revert addtion of assertions in revision 1.99. These assertions cause
problems in cases where regions are faked up for the purposes of red-black
tree searches, since those faked region headers reside on the stack, rather
than in a malloc chunk.


154556 19-Jan-2006 jasone

Add assertions that detect some forms of region separator corruption.


154555 19-Jan-2006 jasone

Remove loops in arena_coalesce(). They are no longer necessary, now that
internal allocation does not rely on recursive arena use (base_arena was
removed in revision 1.95).


154549 19-Jan-2006 jasone

Make all internal variables and functions static.

Reported by: ache


154546 19-Jan-2006 jasone

Return NULL if there is an OOM error during initialization, rather than
allowing the error to be fatal.

Move a label in order to make sure to properly handle errors in malloc(0).

Reported by: Alastair D'Silva, Saneto Takanori


154421 16-Jan-2006 jasone

Add a separate simple internal base allocator and remove base_arena, so that
there is never any need to recursively call the main allocation functions.

Remove recursive spinlock support, since it is no longer needed.

Allow chunks to be as small as the page size.

Correctly propagate OOM errors from arena_new().


154415 16-Jan-2006 marcel

Define NO_TLS on ia64. The dynamic TLS implementation on ia64 is
broken for non-threaded shared processes in that __tls_get_addr()
assumes the thread pointer is always initialized. This is not the
case. When arenas_map is referenced in choose_arena() and it is
defined as a thread-local variable, it will result in a SIGSEGV.

PR: ia64/91846 (describes the TLS/ia64 bug).


154306 13-Jan-2006 jasone

Replace malloc(), calloc(), posix_memalign(), realloc(), and free() with
a scalable concurrent allocator implementation.

Reviewed by: current@
Approved by: phk, markm (mentor)


154263 12-Jan-2006 jasone

Fix a bitwise logic error in posix_memalign().

Reported by: glebius


154248 12-Jan-2006 jasone

In preparation for a new malloc implementation:

* Add posix_memalign().

* Move calloc() from calloc.c to malloc.c. Add a calloc() implementation in
rtld-elf in order to make the loader happy (even though calloc() isn't
used in rtld-elf).

* Add _malloc_prefork() and _malloc_postfork(), and use them instead of
directly manipulating __malloc_lock.

Approved by: phk, markm (mentor)


153707 24-Dec-2005 trhodes

Add a64l(), l64a(), and l64a_r() XSI extentions. These functions convert
between a 32-bit integer and a radix-64 ASCII string. The l64a_r() function
is a NetBSD addition.

PR: 51209 (based on submission, but very different)
Reviewed by: bde, ru


152734 23-Nov-2005 ru

Fix prototype.


150065 12-Sep-2005 stefanf

Include a couple of headers to ensure consistency between the prototype and
the function definition.


150040 12-Sep-2005 stefanf

Move the declaration of __cleanup to libc_private.h as it is used in both
stdio/ and stdlib/. Don't define __cleanup twice.


147811 07-Jul-2005 marcus

Fix ptsname(3) by converting it to use devname(3) to obtain the name of
a tty device instead of the legacy minor number approach. This is known to
fix gnome-vfs' sftp module as well as kio_sftp and kdesu on -CURRENT.

Thanks to scottl for the snprintf() approach idea.

Reviewed by: phk
Tested by: pav
mich
Approved by: re (scottl)


143137 04-Mar-2005 green

Do not require the pty(4) majors to be anything in particular.


142668 27-Feb-2005 delphij

Remove the check about whether MALLOC_EXTRA_SANITY is defined,
surrounding the undef'ing it. It does not seem necessary to
undef some symbol that is not exist, and gcc does not complain
about whether a symbol is exist before #undef'ing it out.

Spotted by: mingyanguo via ChinaUnix.net forum
Reviewed by: phk


140613 22-Jan-2005 ache

Especially mention that setting errno to EINVAL in "no conversion" case
is not portable.

Asked by: joerg


140577 21-Jan-2005 ache

Whitespace/style tweaking of prev. commit.

Noted by: bde


140536 21-Jan-2005 ache

POSIX says that 0[xX] prefix is _optional_ even in base 16 case, make it
really so.

"If the value of base is 16, the characters 0x or 0X may optionally
precede the sequence of letters and digits, following the sign if
present."

Found by: joerg


140505 20-Jan-2005 ru

Sort sections.


140262 14-Jan-2005 ru

Markup fixes.


140098 12-Jan-2005 brian

Fix some signed/unsigned comparisons. Fix prototypes while I'm here.

PR: 28890
Submitted by: matthias.andree at web dot de
MFC after: 7 days


137535 10-Nov-2004 imp

sranddev() is not magic pixie dust. While it gives a good random
seed, the random number generator rand(3) still sucks and is unlikely
sufficient for crypto use. Correct what appears to be a cut and paste
error from the srandomdev() man page.

Submitted by: Ben Mesander


134020 19-Aug-2004 alfred

Reword recent addition about memory moving.

Requested by: keramida

Bump .Dd

Requested by: ru


133985 18-Aug-2004 alfred

Clarify that realloc and reallocf may move the memory allocation.


132910 31-Jul-2004 imp

Use #include <unistd.h> rather than the explicit externs in the
example. The externs haven't been needed in about 10 years, so
there's no reason to have them other than for hysterical raisins. And
the California Rasins haven't been around for a long time...


131754 07-Jul-2004 ru

mdoc(7) fixes.


131728 06-Jul-2004 hmp

Move the return value information about the getenv(3) library function
under the RETURN VALUES section so it is consistent with others.

Cleanup the return value text for getenv(3) a little while I am here.

PR: docs/58033
MFC after: 3 days


131710 06-Jul-2004 ache

Keep it sync with OpenBSD:
An optional argument cannot start with '-', even if permutation is
disabled.

Obtained from: OpenBSD getopt_long.c v1.17


131594 04-Jul-2004 ru

Sort SEE ALSO references (in dictionary order, ignoring case).


131575 04-Jul-2004 stefanf

Consistently use __inline instead of __inline__ as the former is an empty macro
in <sys/cdefs.h> for compilers without support for inline.


131539 03-Jul-2004 ru

Eliminate double whitespace.


131504 02-Jul-2004 ru

Mechanically kill hard sentence breaks.


129200 14-May-2004 cognet

Define malloc_pageshift and malloc_minsize for arm.


129151 12-May-2004 ru

Link radixsort(3) to sradixsort(3), make the latter appear in
the whatis(1) output.


127734 01-Apr-2004 ache

Simplify one condition in prev. commit:
short_too already assumes FLAG_LONGONLY


127733 01-Apr-2004 ache

Fix parsing of ambiguous options, whole loop must be processed


126727 07-Mar-2004 phk

Rearrange (centralize) initialization of mallocs internals to always be
done before the first call, even if this is a malloc(0) call.

PR: 62859


126697 06-Mar-2004 ache

Merge some fixes from NetBSD's getopt.3 v1.31:
cleanup, add more sections, better explanation, declaration


126696 06-Mar-2004 ache

Merge some fixes from NetBSD's getopt.c v1.26:
cleanups, handling 'ls -l-', handling '--*'

Note this is in the same time back out of our v1.3
"Don't print an error message if the bad option is '?'"
because it directly violates POSIX.


126693 06-Mar-2004 ache

Fix typo, was 'W'; instead of `W;'


126692 06-Mar-2004 ache

Make GNU-compatible following case:
single '-' in command line and '-' (non-first) in options


126535 03-Mar-2004 ache

Make return code in noarg case GNU-compatible


126518 03-Mar-2004 ache

Be more GNU-compatible in diagnostics


126452 01-Mar-2004 ache

Improve GNU compatibility in several places, use internal GNU_COMPATIBLE
define for it.
Don't catch POSIXLY_CORRECT env. into static variable, it can be changed
on the fly by program.
Use P1003.2 standartized illoptchar[]


126440 01-Mar-2004 ache

Comment out things related to getopt() replacement we not use


126439 01-Mar-2004 ache

Change "-"-started options when POSIX_CORRECTLY is set handling
in favour of GNU instead of NetBSD, because configure's use us and
expect GNU.


126438 01-Mar-2004 ache

Change "-"-started options when POSIX_CORRECTLY is set handling
in favour of GNU instead of NetBSD, because configure's use us and
expect GNU.


126189 24-Feb-2004 ache

Add getopt_long_only() from OpenBSD and other OpenBSD cleanups

PR: 63173
Submitted by: Marius Strobl <marius@alchemy.franken.de>


126143 23-Feb-2004 ache

Add optarg, optind, opterr, optopt, optreset to SYNOPSYS


126139 23-Feb-2004 ache

POSIX clearly states that getsubopt() should be declared in <stdlib.h>
not in <unistd.h>


126138 23-Feb-2004 ache

Remove unneccessary <unistd.h>


126061 21-Feb-2004 phk

Remove the triplicity in the public functions by vectoring them all
through a realloc like function.

Make the malloc_active variable a local static to this new function.

Don't warn about recursion more than once per base call.

constify malloc_func.


126060 21-Feb-2004 phk

Move the check for sensitive processes to the point where the exception
has been hit, this makes it cover more cases.

Call the message function directly rather than fiddle with flag-saving
when we find an unknown character in our options.

The 'A' flag should not trigger on legal out of memory conditions.


126039 20-Feb-2004 ru

Unbreak the upgrade path from 4.9 after removal of GNU getopt and
<gnuregex.h>.


125668 10-Feb-2004 cperciva

style cleanup: Remove duplicate $FreeBSD$ tags.

These files had tags after the copyright notice,
inside the comment block (incorrect, removed),
and outside the comment block (correct).

Approved by: rwatson (mentor)


124738 20-Jan-2004 das

Use 'uint32_t' instead of 'long' when a 32-bit integer is intended.
This results in no functional change, aside from fixing a data
corruption bug on LP64 platforms. The code here could still use a
significant amount of cleanup.

PR: 56502
Submitted by: hrs (earlier version)


123674 19-Dec-2003 kan

Implement __cxa_atexit/__cxa_finalize as specified by the cross-vendor
ó++ ABI document at http://www.codesourcery.com/cxx-abi/abi.html#dso-dtor

The ABI was initially defined for ia64, but GCC3 and Intel compilers
have adopted it on other platforms.

This is the patch from PR bin/59552 with a number of changes by
me.

PR: bin/59552
Submitted by: Bradley T Hughes (bhughes at trolltech dot com)


123673 19-Dec-2003 kan

Implement __cxa_atexit/__cxa_finalize as specified by the cross-vendor
C++ ABI document at http://www.codesourcery.com/cxx-abi/abi.html#dso-dtor

The ABI was initially defined for ia64, but GCC3 and Intel compilers
have adopted it on other platforms.

This is the patch from PR bin/59552 with a number of changes by
me.

PR: bin/59552
Submitted by: Bradley T Hughes (bhughes at trolltech dot com)


123031 28-Nov-2003 marcel

Do not adjust to the pagesize at runtime. Besides for the one-time
initialization overhead, there's a problem in that we never call
imalloc() and thus malloc_init() for zero-sized allocations. As a
result, malloc(0) returns NULL when it's the first or only malloc in
the program. Any non-zero allocation will initialize the malloc code
with the side-effect that subsequent zero-sized allocations return a
non-NULL pointer. This is because the pointer we return for zero-
sized allocations is calculated from malloc_pageshift, which needs
to be initialized at runtime on ia64.

The result of the inconsistent behaviour described above is that
configure scripts failed the test for a GNU compatible malloc. This
resulted in a lot of broken ports.

Other, even simpler, solutions were possible as well:
1. initialize malloc_pageshift with some non-zero value (say 13 for
8KB pages) and keep the runtime adjustment.
2. Stop using malloc_pageshift to calculate ZEROSIZEPTR.

Removal of the runtime adjustment was chosen because then ia64 is the
same as any other platform. It is not to say that using a page size
obtained at runtime is bad per se. It's that there's currently a high
level of gratuity for its existence and the moment it causes problems
is the moment you need to get rid of it. Hence, it's not unthinkable
that this commit is (partially) reverted some time in the future when
we do have a good reason for it and a good way to achieve it.

Approved by: re@ (rwatson)
Reported by: kris (portmgr@) -- may the ports be with you


122458 11-Nov-2003 kientzle

Improve the performance of radixsort() when
sorting strings with common prefixes by noting
when all the strings land in just one bin.

Testing shows significant speedups (on the order of
30%) on strings with common prefixes and no slowdowns on any
of my test cases.

Submitted by: Markus Bjartveit Kruger <markusk@pvv.ntnu.no>
PR: 58860
Approved by: gordon (mentor)


122069 04-Nov-2003 deischen

Externalize malloc's spinlock so that a thread library can take
it around an application's fork() call. Our new thread libraries
(libthr, libpthread) can now have threads running while another
thread calls fork(). In this case, it is possible for malloc
to be left in an inconsistent state in the child. Our thread
libraries, libpthread in particular, need to use malloc internally
after a fork (in the child).

Reviewed by: davidxu


121667 29-Oct-2003 tjr

Remove incomplete support for running FreeBSD userland on old NetBSD kernels
lacking the issetugid() and utrace() syscalls.


121639 28-Oct-2003 peter

Don peril sensitive (ie: bikeshed sensitive) sunglasses and quietly
send strhash(3) off to sleep with the fishes. Nothing in our tree uses it.
It has no documentation. It is nonstandard and in spite of the filename
strhash.c and strhash.h, it lives in application namespace by providing
compulsory global symbols hash_create()/hash_destroy()/hash_search()/
hash_traverse()/hash_purge()/hash_stats() regardless of whether you
#include <strhash.h> or not. If it turns out that there is a huge
application for this after all, I can repocopy it somewhere safer and
we can revive it elsewhere. But please, not in libc!


121518 25-Oct-2003 phk

Consistently cast to (u_char *) when filling with junk.


121500 25-Oct-2003 phk

Style changes. Inching closer to convergence with OpenBSD.


120598 30-Sep-2003 tjr

Cite the published version of "Engineering a Sort Function" instead of
an email address. Spell McIlroy correctly.


120524 27-Sep-2003 phk

More style fixes to improve diffability with OpenBSD.

Pull 'A' evilness for realloc(3) from OpenBSD.


120520 27-Sep-2003 phk

Style changes to improve diffability against OpenBSD version.


120054 14-Sep-2003 ru

Get rid of duplicates.


119964 10-Sep-2003 ru

mdoc(7): Properly mark C headers.


119893 08-Sep-2003 ru

mdoc(7): Use the new feature of the .In macro.


118988 16-Aug-2003 davidxu

Replace some syscalls with libc version, this makes abort work better with
libkse. Tested under libc_r, libkse, libthr.

Reviewed by: deischen


118731 10-Aug-2003 ache

For type 0 rng lower initial drop to 50, it is enough to hide linearity
Reorganize historic #ifdef section


118248 31-Jul-2003 das

Cross-reference arc4random(3).


118153 29-Jul-2003 phk

Minor constification.


117007 28-Jun-2003 ru

mdoc(7) fix: Use the normal AT&T macro (.At) rather than its
internal string in the macro context.


116843 25-Jun-2003 obrien

mdoc police


116834 25-Jun-2003 obrien

Be more specific in BUGS.
Submitted by: ru

Add history.


115631 01-Jun-2003 ru

Assorted mdoc(7) fixes.


115610 01-Jun-2003 phk

Clarify the code a bit.

Submitted by: Nadav Eiron <nadav@TheEirons.org>


115571 31-May-2003 schweikh

Fix grammar bogons.

MFC after: 3 days


115362 28-May-2003 fjoe

Fix stripping last path component when only one path component left.

PR: 52686
MFC after: 1 day


115225 22-May-2003 ru

Assorted mdoc(7) fixes.

Approved by: re (blanket)


114443 01-May-2003 nectar

Back out the `hiding' of strlcpy and strlcat. Several people
vocally objected to this safety belt.


114321 30-Apr-2003 peter

Tell malloc.c that AMD64 uses the same pagesize as i386.


114256 29-Apr-2003 nectar

`Hide' strlcpy and strlcat (using the namespace.h / __weak_reference
technique) so that we don't wind up calling into an application's
version if the application defines them.

Inspired by: qpopper's interfering and buggy version of strlcpy


113105 05-Apr-2003 tjr

MFp4: Link strtof.3 and strtold.3 to strtod.3.


112823 29-Mar-2003 fjoe

BDE'ify


112820 29-Mar-2003 fjoe

fix truncation check and buffer overflow check


112743 28-Mar-2003 fjoe

- MAXPATHLEN -> PATH_MAX (pass correct buffer size to readlink as well)

Requested by: bde


112726 27-Mar-2003 fjoe

Make realpath() thread-safe. New implementation does not use chdir(2) at all.

Submitted by: Constantin S. Svintsoff <kostik (at) iclub.nsu.ru>


112427 20-Mar-2003 ache

According to C99 decimal_point can't be empty


112257 15-Mar-2003 das

The gdtoa import apparently hasn't caused anything or anyone to
explode, so nix the old strtod() / dtoa(). This change is part
of the gdtoa patches reviewed on standards@.


112164 12-Mar-2003 das

Document strtof() and strtold(). Update vendor license.

Reviewed by: bde (briefly), mike (mentor), obrien


112163 12-Mar-2003 das

Replace our ancient dtoa/strtod implementation with the gdtoa
package, a more recent, generalized set of routines. Among the
changes:
- Declare strtof() and strtold() in stdlib.h.
- Add glue to libc to support these routines for all kinds
of ``long double''.
- Update printf() to reflect the fact that dtoa works slightly
differently now.

As soon as I see that nothing has blown up, I will kill
src/lib/libc/stdlib/strtod.c. Soon printf() will be able
to use the new routines to output long doubles without loss
of precision, but numerous bugs in the existing code must
be addressed first.

Reviewed by: bde (briefly), mike (mentor), obrien


112143 12-Mar-2003 dwmalone

Document the fact that hdestory calls free on the keys added with
hsearch(.., ENTER). Make the example reflect this.

PR: 49951
Submitted by: Peter Jeremy <peterjeremy@optushome.com.au>


111503 25-Feb-2003 robert

Fix typo.


111261 22-Feb-2003 johan

Use strlcpy instead of strncpy.

Submitted by: imp
Reviewed by: silence on -audit


111026 17-Feb-2003 ache

Back out "drop first N values" method of removing monotonically increased
seed->first value correlation. It breaks rand_r()... Other possible methods
like shuffling inside aray will breaks rand_r() too, because it assumes
only one word state, i.e. nothing extra can be added after seed assignment
in srand().

BTW, for old formulae seed->first value correlation is not so monotonically
increased as with other Linear Congruential Generators of this type only
becase arithmetic overflow happens. But overflow affects distribution
and lower bits very badly, as many articles says, such type of overflow
not improves PRNG.

So, monotonically increased seed->first value correlation problem remains...


110421 05-Feb-2003 ache

Since we drop NSHUFF values now, set default seed to what it becomes
after srand(1)


110321 04-Feb-2003 ache

For rand(3) and random(3) TYPE_0 drop NSHUFF values right after srand{om}()
to remove part of seed -> 1st value correlation. Correlation still remains
because of algorithm limits. Note that old algorithm have even stronger
correlation, especially in the lower bits area, but not eye-visible, as
current one.


110280 03-Feb-2003 ache

Park & Miller PRNG can be safely initialized with any value but 0 and stuck
at 0 as designed. Its BSD adaptation tries to fight it by mapping 0 to
2147483647 after calculation, but this method not works since 2147483647
seed returns to 0 again on the next interation. Instead of after calculation
mapping, map 0 to another value _before_ calculation, so it never stucks.


110236 02-Feb-2003 ache

For some combinations of variable sizes and RAND_MAX value rand_r()
may store less amount bits for seed, than available. Fix it.


110103 30-Jan-2003 phk

Catch some cases where asking for ridiculously large allocations could
result in a segfault. Instead just return NULL.


109803 24-Jan-2003 mike

Add an MLINK malloc.conf(5) -> malloc(3).


109754 23-Jan-2003 phk

For "sensitive" processes, we always set the 'A' flag which causes abort()
to be called on first sight of trouble.

"sensitive" is somewhat arbitrarily defined as "setuid, setgid, uid == root
or gid == wheel".

The 'A' option carries no performance penalty.

It is not possible to override this setting: fix the program instead.

Absentmindedly nodded OK to by: various


109331 15-Jan-2003 johan

realpath(3) should use PATH_MAX instead of MAXPATHLEN according to POSIX.

This also reverts the PATH_MAX -> MAXPATHLEN part of
rev 1.3 of src/bin/realpath/realpath.c

Requested by: imp
Reviewed by: imp, bde


108776 06-Jan-2003 tjr

strfmon(3) does not correctly handle multibyte characters in the
format string.


108694 05-Jan-2003 tjr

No need to include <assert.h> here.


108646 04-Jan-2003 tjr

Fix three warnings:
o #include <stdio.h> to make sprintf()'s prototype visible.
o Remove unused variable: sbuf.
o Don't use assignment as truth value.


108644 04-Jan-2003 tjr

style(9): return type on separate line from function name.


108625 03-Jan-2003 tjr

Add missing #include "namespace.h".


108624 03-Jan-2003 tjr

Remove unused variable: ntmp.


108623 03-Jan-2003 tjr

#include <string.h> for strcmp()'s prototype.


108574 02-Jan-2003 jmallett

Implement POSIX grantpt(3) functionality, and add a pt_chown utility (akin
to Solaris, it is in /usr/libexec) to perform the handing over of tty nodes
to the user being granted the pty.

Submitted by: Ryan Younce <ryany@pobox.com>
Reviewed by: security-officer@, standards@, mike@


108533 01-Jan-2003 schweikh

Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.


108257 24-Dec-2002 ru

mdoc(7) police: Deal with self-xrefs.


108113 20-Dec-2002 trhodes

Document what really occurs when we obtain an error.

PR: 43357
Submitted by: David Schultz <dschultz@uclink.Berkeley.EDU>


108087 19-Dec-2002 ru

mdoc(7) police: "The .Fa argument.".


108040 18-Dec-2002 ru

mdoc(7) police: Fixed abuses of the .Ar and .Em macros.


108037 18-Dec-2002 ru

mdoc(7) police: "The .Fn function".


107826 13-Dec-2002 ru

mdoc(7) police: sort xrefs in SEE ALSO.


107788 12-Dec-2002 ru

Uniformly refer to a file system as "file system".

Approved by: re


107705 09-Dec-2002 ru

mdoc(7) police: overhaul.

Approved by: re


107704 09-Dec-2002 ru

mdoc(7) police: nits.

Approved by: re


107619 04-Dec-2002 ru

Consistently mark std(in|out|err) with .Dv, because that's how they
are marked up in stdio(3), and because they are defined expressions
of type "FILE *".

Approved by: re


107391 29-Nov-2002 ru

mdoc(7) police: sweep.


107387 29-Nov-2002 ru

mdoc(7) police: formatting nits.

Approved by: re


107052 18-Nov-2002 ru

libc_r wasn't so tied to libc for 22 months.


106918 14-Nov-2002 robert

Define `Sudden_Underflow' when compiling for the Alpha
architecture, mainly to avoid getting a SIGFPE signal sent
when calling strtod(3) with certain input.

The SIGFPE has been sent because the code was not aware that
a Gradual Underflow is handled in software via traps on the
Alpha architecture, but is not implemented in our Alpha kernel
layer.

With `Sudden_Underflow' defined, strtod(3) should not depend
on Gradual Underflow and adjust its calculations accordingly,
which means that other, more subtle errors than the sending of
SIGFPE could be solved by this.

Discussed with: bde
PR: alpha/12623
PR: alpha/17032
PR: alpha/43567
MFC after: 7 days


105299 16-Oct-2002 alfred

de-__P()


105250 16-Oct-2002 robert

- Remove the lsearch() and lfind() functions and their manpage from
the compatibility library libcompat.
- Add new implementations of lsearch() and lfind() which conform to
IEEE Std 1003.1-2001 to libc. Add a new manual page for them and
add them to the makefile.
- Add function prototypes for lsearch() and lfind() to the search.h
header.


105246 16-Oct-2002 robert

Remove unneeded $FreeBSD$ tags.


105245 16-Oct-2002 robert

- Remove the old insque() and remque() functions and their manual
page from the compatibility library.
- Add new implementations of insque() and remque() which conform to
IEEE Std 1003.1-2001 to libc. Add a new manual page for them and
connect them to the build.
- Add the prototypes of insque() and remque() to the search.h
header.


104963 12-Oct-2002 tjr

Fix a typo causing incorrect formatting for negative values in some locales
(at least the French ones), a memory leak upon successful termination, a
pointer arithmetic error causing heap corruption, and an off-by-one bug
causing incorrect amounts of padding at the right of the value.


104946 11-Oct-2002 tjr

Save errno around calls to free(); at least some code paths clobber it
and we are not interested in any errors it may report.


104945 11-Oct-2002 tjr

Document the kind of format string strfmon() expects. Sync the Errors
section with reality.


104944 11-Oct-2002 tjr

Use the new struct lconv members to determine how to format international
monetary values.


104943 11-Oct-2002 tjr

Non-negative amounts should not have an extra space in front of them
when the `(' flag is used.


104942 11-Oct-2002 tjr

"Left precision" and "right precision" are not flags, but separate parts
of the format string that appear after the field width.


104751 10-Oct-2002 tjr

Add cross-references to wide character versions of these functions.


104400 03-Oct-2002 mike

Add missing const qualifier in tfind().


104128 29-Sep-2002 eric

Add getopt_long(3).

Obtained from: NetBSD
Sponsored by: Apple


103668 20-Sep-2002 mike

Add restrict type-qualifier.


103165 10-Sep-2002 wollman

Implement C99's _Exit() interface.
Implement a version of qsort that provides a thunk to the comparison function.

Update manual pages.


103036 06-Sep-2002 wollman

Include some verbage about not calling exit() from functions registered
by atexit().


103012 06-Sep-2002 tjr

Style: One space between "restrict" qualifier and "*".


102229 21-Aug-2002 phk

s/EDOFUS/EDOOFUS/

Persuaded by: Google


101912 15-Aug-2002 robert

- Add the 'restrict' qualifier to the function prototypes and
definitions of the functions that convert strings to numbers
and are defined by IEEE Std 1003-1.2001.
- Use ANSI-C function definitions for all of the functions
mentioned above plus strtouq and strtoq.
- Update the prototypes in the manual pages.


101882 14-Aug-2002 robert

- Add the 'restrict' qualifier to match the IEEE Std 1003.1-2001
prototype of the tdelete(3) function.
- Remove duplicated space.
- Use an ANSI-C function definition for tdelete(3).
- Update the manual page.


101812 13-Aug-2002 dwmalone

Use a union to access the words of a double as this is less likely
to cause bugs when gcc is more aggressively optimising things.

There are still problems with dtoa mentioned in the PR - maybe
Dan could suggest a patch.

PR: 40209
Submitted by: Dan Lukes <dan@obluda.cz>
Approved by: bde
MFC after: 2 weeks


101568 09-Aug-2002 phk

Make sure we set errno sensibly in case of failure.

Spotted by: ache


101291 04-Aug-2002 ache

Nonexistent SIZE_MAX -> SIZE_T_MAX


101290 04-Aug-2002 tjr

Signal an error instead of giving the caller less memory than they asked
for when num * size would cause integer overflow.

MFC after: 1 week


99735 10-Jul-2002 wollman

Fix some comments.


98907 27-Jun-2002 deischen

Remove improper use of <namespace.h>


97967 06-Jun-2002 keramida

Clarify the bit about realloc() and its `ptr' argument a bit.
Hopefully, now it is more clear that the memory referenced by the
ptr argument of realloc(ptr,size) is freed and only the return value
of realloc() points to a valid memory area upon successful completion.

Submitted by: Martin Faxer <gmh003532@brfmasthugget.se>


97639 30-May-2002 phk

Const poison.

Partially submitted by: wollman


97467 29-May-2002 ru

mdoc(7) police: nit.


97407 28-May-2002 alfred

Assume __STDC__, remove non-__STDC__ code.

Submitted by: keramida


97330 27-May-2002 dd

Remove spurious period.


97044 21-May-2002 benno

Let this code know about PowerPC.


96350 10-May-2002 peter

Avoid casting a different sized integer to a pointer on LP64 systems.


95377 24-Apr-2002 phk

Constify _malloc_options.


93399 29-Mar-2002 markm

Do not use __progname directly (except in [gs]etprogname(3)).
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.


92991 22-Mar-2002 obrien

Fix the style of the SCM ID's.
I believe have made all of libc .h's as consistent as possible.


92986 22-Mar-2002 obrien

Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.


92941 22-Mar-2002 obrien

Remove multi-line __P() usage.


92905 21-Mar-2002 obrien

Remove __P() usage.


92889 21-Mar-2002 obrien

Remove 'register' keyword.


91697 05-Mar-2002 tegge

When multiple threads call atexit at the same time, some operations must
be serialized. A mutex is used to protect the critical regions.

sbrk() and brk() are not thread safe. Replace use of sbrk() with
a call to malloc to avoid race when one thread calls atexit
while another thread calls malloc.

Reviewed by: deischen


91161 23-Feb-2002 jake

Add ifdefs for sparc64.


89585 20-Jan-2002 yar

Minor typo fix: uquad_t -> u_quad_t.


89139 09-Jan-2002 ru

mdoc(7) police: add missing markup bits for ``errno''.


88681 30-Dec-2001 ache

Back out errno preserving


88472 25-Dec-2001 ache

Add "except the handling of errors" into "equivalent to" paragraph.

Pointed by: bde
Inspired by: POSIX


88469 25-Dec-2001 ache

Preserve errno.

According to C99:
"The functions atof, atoi, atol, and atoll need not
affect the value of the integer expression errno on an
error. If the value of the result cannot be represented,
the behavior is undefined."


87872 14-Dec-2001 phantom

* cleanup comments and defines

Reviewed by: bde


87738 12-Dec-2001 ru

mdoc(7) police: fix markup, bump document date.


87737 12-Dec-2001 ru

mdoc(7) police: kill HSBs, add missing comma.


87736 12-Dec-2001 ru

mdoc(7) police: fix markup.


87659 11-Dec-2001 phantom

Add my e-mail to copyrights


87501 07-Dec-2001 phantom

Get rid of unused anymore file! Alpha works fine with our strtod() now.


87494 07-Dec-2001 ache

Return 'c' back to signed due to potential comparison problems
Use simpler test for valid ranges

Submitted by: bde


87225 02-Dec-2001 peter

Use the merged strtod.c everywhere. This has been tested on alpha and
ia64.


87196 02-Dec-2001 ache

Make it works for non ASCII compatible encodings too.
The only assumption left is that 'A'..'Z' 'a'..'z' both are contiguous


87123 30-Nov-2001 phantom

Merge NetBSD's changes from netbsd_strtod.c in preparation of
removing it from our source tree in order to have one version
of strtod() for all arches. netbsd_strtod.c still left in source
tree until alpha folks make sure that our native strtod() works
as well as NetBSD's one.

Reviewed by: peter, bde (some time ago)


87078 29-Nov-2001 ache

Back out national digits support, POSIX explicetely disallows it:

The definition of character class digit requires that only ten characters
-the ones defining digits- can be specified; alternate digits (for
example, Hindi or Kanji) cannot be specified here. However, the encoding
may vary if an implementation supports more than one encoding.

The definition of character class xdigit requires that the characters
included in character class digit are included here also and allows for
different symbols for the hexadecimal digits 10 through 15.


87042 28-Nov-2001 ache

Don't ever assume that isdigit() is always subset of isxdigit()


87040 28-Nov-2001 ache

Fix typo


87038 28-Nov-2001 ache

Use stricter tests to disallow national digits > 9
Optimize national digits code a bit


87029 28-Nov-2001 ache

Allow national (non-ASCII) digits


87027 28-Nov-2001 fenner

Implement strtoimax() and strtoumax()


87026 28-Nov-2001 fenner

Also mention "long long" in synopsis.


87023 28-Nov-2001 fenner

Base 36 is allowed.


87020 28-Nov-2001 ache

Put back base > 35 check. If someone dislike it, plese discuss it with
standards group first.


87017 28-Nov-2001 ache

Add atoll(3) to conform POSIX and C99


87016 28-Nov-2001 ache

Understand national (non-ASCII) digits now
Allow bases >=36 again
Misc cleanup


86845 24-Nov-2001 keramida

Be more explicit about the fact that realloc() might return a
different pointer than the one passed to it.

PR: docs/31925
Submitted by: Andrew <andrew@ugh.net.au>


86737 21-Nov-2001 ru

mdoc(7) police: fixed typos and minor markup nits.


86488 17-Nov-2001 phk

If 'VX' is given, realloc(foo,0) will bail, it shouldn't.

PR: 29376
Submitted by: Farooq Mela <fmela0@sm.socccd.cc.ca.us>


86466 16-Nov-2001 phk

Correctly call THREAD_UNLOCK() if the recursive call trap is sprung.

Pointed out by: knu


86368 15-Nov-2001 mike

o Implement imaxabs(), imaxdiv(), llabs(), lldiv().
o Update abs(3), div(3), labs(3), ldiv(3) to reflect standards
conformance and add additional references.

Reviewed by: bde, wollman


86063 05-Nov-2001 dd

malloc and calloc do not free memory.

PR: 31365
Submitted by: SUZUKI Koichi <koich@cac.co.jp>


86043 04-Nov-2001 peter

Make strtod.c work on Alpha as well. strtod.c has got locale support,
the netbsd_strtod.c file we have does not. More still should be done
here, but this works happily on my Alpha. I have not (yet?) changed
the Makefile.inc to use this.


86033 04-Nov-2001 peter

Slightly closer to netbsd_strtod.c:
s/IEEE_8087/IEEE_LITTLE_ENDIAN/
s/IEEE_MC68k/IEEE_BIG_ENDIAN/


85869 02-Nov-2001 phk

phkmalloc->evilchecks++;

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>


85752 30-Oct-2001 markm

Add a long-overdue nail to the deprecated /dev/urandom interface
by asking some things that need unpredictable numbers to read
/dev/random instead.


84591 06-Oct-2001 dfr

Make this work on ia64. I have no idea why it works on alpha - it
shouldn't.


84417 03-Oct-2001 alfred

Avoid getting stuck in system(3) when the internal call to wait4()
is interrupted by saving the pid.

The old code would assign the return value to pid which would trash
it, to fix the problem save a copy of the pid to be used as the
paramter to wait4().

Submitted by: Toshihiko ARAI <toshi@jp.FreeBSD.org>


84298 01-Oct-2001 ru

mdoc(7) police: don't split author names in the AUTHORS section.


84280 01-Oct-2001 ru

mdoc(7) police: s/atof/atoi/


83982 26-Sep-2001 asmodai

Add ERRORS section.
Mention thread safety and async-cancel safety status [not].
Add standards compliancy references.
Note strtol() is preferred over atoi().

MFC after: 2 weeks


83973 26-Sep-2001 asmodai

Be explicit about the POSIX version it conforms to [in this case 1990].
Put the error comment under the more appropriate ERRORS section.


83967 26-Sep-2001 asmodai

Change standards compliancy order so that C and POSIX are grouped.


83559 17-Sep-2001 mike

style(9)

Silence from: phantom


83328 11-Sep-2001 ru

mdoc(7) police: changed pure POSIX text; added missing markup bits.


83256 09-Sep-2001 asmodai

Add more standards which we conform to.
Note our implementation is not thread nor async-cancel safe.
Explicitely note atof() does not check nor report errors.
Note that strtod() should be used instead.


83254 09-Sep-2001 asmodai

Detail thread-safe and async-cancel-safe status.
Also add C99 conformity status plus clarification that C99 leaves the
flushing of unwritten data, closure of open streams, and removal of
temporary files to the implementation.


83206 07-Sep-2001 asmodai

Move to using .In instead of .Fd #include <> for include mark-up.

Inspired by comment from: dd


83205 07-Sep-2001 phantom

reconnect strfmon.c to build list


83203 07-Sep-2001 asmodai

Fix some mdoc nits caused by my knowledge not being too up-to-date on
mdocNG.

Submitted by: dd


83202 07-Sep-2001 dfr

Port to ia64, taking into account the fact that pagesizes may be variable.


83194 07-Sep-2001 asmodai

Add strfmon.3 to the fray.
This is a first cut, but enough to help people interested in using it
further than before.
More text coming to illustrate use and provide more details.

Based on standards' text.


83139 06-Sep-2001 phantom

correctly wrap macros with { }


83137 06-Sep-2001 obrien

strfmon(3) is not ready to go live.


83104 05-Sep-2001 phantom

Add strfmon(3) implementation. It still contains few XXX's because I lost
my last version of this work due to HDD crash, but this version cleanly
passed all POSIX and SuSv2 tests. I am working on testing scripts which
should test this implementation against all locales and surely more fixes
will come soon.

Reviewed by: ache, silence at -audit & -developers


83024 04-Sep-2001 ache

Portability fix: use unsigned cast to guaranteed positive part of expression
in case {L}LONG_MAX > abs({L}LONG_MIN). Non-functional change - we don't
have any such platforms.


82995 04-Sep-2001 ache

Remove rcsids and unneded include


82982 04-Sep-2001 ache

'acc' is not initialized in one hypotetical case, fix it


82975 04-Sep-2001 ache

Locale *is* used in strto*l*(), at least for isspace(), so remove
'locale not used' statement from comments and BUGS section of manpage.

strtol(): fix non-portable 'cutoff' calculation using the same method as
in strtoll().

Cleanup 'cutoff' calculation, remove unneded casts. Misc. cleanup to
make all functions looks the same.

Implement EINVAL reaction per POSIX, document it in manpage, corresponding
POSIX example quotes here:

------------------------------------------------
If the subject sequence is empty or does not have the expected form, no
conversion is performed; the value of str is stored in the object pointed
to by endptr, provided that endptr is not a null pointer.

If no conversion could be performed, 0 shall be returned and errno may be
set to [EINVAL].

[EINVAL] The value of base is not supported.

Since 0, {LONG_MIN} or {LLONG_MIN}, and {LONG_MAX} or {LLONG_MAX} are
returned on error and are also valid returns on success, an application
wishing to check for error situations should set errno to 0, then call
strtol( ) or strtoll ( ), then check errno.
-----------------------------------------------------


82642 31-Aug-2001 ru

Use ``.Rv -std'' wherever possible.

Submitted by: yar


81746 16-Aug-2001 jkoshy

If the string specifying the allowed options starts with a leading `:',
`getopt(3)' should not print a warning for missing argument values.

PR: bin/29625
Reviewed by: mikeh
MFC after: 1 week


81447 10-Aug-2001 ru

Fixed style bugs (dot `.' at the end of error and warning messages).

Noticed by: bde


81446 10-Aug-2001 ru

Markup nits: use diagnostic type lists for error and warning messages.

Backout previous revision. We should not expand plain text xrefs if
they appear in the literal text, e.g. in the error or warning message
of the library function. (Submitted by: bde)

Moved "out of memory" from warning to errors section.


81352 09-Aug-2001 yar

Use the ``.Rv -std'' mdoc(7) macro in appropriate cases.

Reviewed by: ru


81285 08-Aug-2001 ru

mdoc(7) police: expand plain text xrefs.


80743 31-Jul-2001 mp

Only pull in the MD files if they exist. This allows for progressive
implementation and compilation when bringing up a new architecture.


79754 15-Jul-2001 dd

Remove whitespace at EOL.


79531 10-Jul-2001 ru

mdoc(7) police: removed HISTORY info from the .Os call.


79461 09-Jul-2001 ru

mdoc(7) police: eliminate -ww warnings.


79454 09-Jul-2001 dd

mdoc(7) police: remove extraneous .Pp before and/or after .Sh.


79200 04-Jul-2001 ru

mdoc(7) police: mark NULL with .Dv.


78727 24-Jun-2001 dd

mdoc(7) police: the BUGS section should go after HISTORY and AUTHORS.


78726 24-Jun-2001 dd

The fact that phk wrote this is not a bug!


78706 24-Jun-2001 dd

Reword a sentence to make it proper English.


77851 07-Jun-2001 dd

urandom(4) -> random(4) in comments.

PR: 27858
Submitted by: Yoshihiro Koya <Yoshihiro.Koya@math.yokohama-cu.ac.jp>
Reviewed by: md5(1)
Approved by: markm


77850 07-Jun-2001 dd

urandom(4) -> random(4)

PR: 27858
Submitted by: Yoshihiro Koya <Yoshihiro.Koya@math.yokohama-cu.ac.jp>
Approved by: markm


76613 15-May-2001 ru

Add new, from scratch implementation of hsearch() et al that actually works.

Obtained from: NetBSD
MFC after: 1 month


76061 27-Apr-2001 ru

Grammar nit.


75864 23-Apr-2001 ache

Add sranddev.3 to MLINKS


75863 23-Apr-2001 ache

Add #include "un-namespace.h"


75862 23-Apr-2001 ache

srand*dev() fallback code: change ^getpid() to ^(getpid() << 16) to allow
change of high word part too to produce more interesting seed distribution.


75845 23-Apr-2001 ache

Add sranddev() since srand() is not vary much with seed, typical time


74870 27-Mar-2001 ru

MAN[1-9] -> MAN.


74268 15-Mar-2001 dd

Make tdelete(3), tfind(3), and twalk(3) links to tsearch(3).

Approved by: nik


73234 28-Feb-2001 obrien

Merge in strtoul.3 rev 1.11 mdoc(7) police changes:
.Nd line broken in rev 1.10
use .Bx for ``BSD''


73222 28-Feb-2001 ru

mdoc(7) police: fix the .Nd line broken in previous revision.

Noticed by: bde

Use .Bx for ``BSD''.


73156 27-Feb-2001 ache

Use formula with better random distribution for rand()

Even better formula from random() could not be intetgrated because rand_r()
supposed to store its state in the single variable (but table needed for
random() algorithm integration).


73155 27-Feb-2001 obrien

I accidently deleted an include when I added the $FreeBSD$ so I could
check in my changes.


73152 27-Feb-2001 obrien

Impliment the ISO-C99 strto[u]ll()
and rewrite strto[u]q() in terms of it.


73088 26-Feb-2001 ru

.St -ansiC -> .St -isoC


73021 25-Feb-2001 tegge

Update unused __dtoa prototypes to match reality.


72523 15-Feb-2001 tegge

Remove freelists managed by Balloc/Bfree.
Change __dtoa to not free the string it allocated the previous time it was
called. The caller now frees the string after usage if appropiate.

PR: 15070
Reviewed by: deischen


72401 12-Feb-2001 ru

"Cross references in the SEE ALSO section should be sorted by section
number, and then placed in alphabetical order and comma separated.",
mdoc.samples(7) said.


72400 12-Feb-2001 ru

mmap(3) -> mmap(2).


72369 11-Feb-2001 nik

Include mmap(2) in the list of memory allocation functions.

Reviewed by: hackers


72368 11-Feb-2001 nik

.Xr to mmap.


72313 10-Feb-2001 ru

mdoc(7) police: mark LC_NUMERIC with .Dv.


72301 10-Feb-2001 ache

Note that decimal point taken from locale


72288 10-Feb-2001 ache

Note the fact that decimal point taken from locale (according to SUSv2)


72287 10-Feb-2001 ache

Use decimap_point from localeconv() instead of hardcoded '.'

Obtained from: inspired by NetBSD strtod


72254 09-Feb-2001 tegge

Backout previous commit. Use of spinlocks was not approved.
PR: 15070


72179 08-Feb-2001 tegge

Protect freelists managed by Balloc/Bfree with a spinlock.
Change __dtoa to not free the string it allocated the previous time it was
called. The caller now frees the string after usage if appropiate.

PR: 15070


72126 07-Feb-2001 ru

mdoc(7) police: Change -filled displays (which just happen
to be the same as -ragged in the current implementation) to
-ragged. With mdocNG, -filled displays produce the correct
output, formatted and justified to both margins.


72047 05-Feb-2001 bde

Fixed C error(s) in synopsis. Many were hiding under mdoc errors.


71987 04-Feb-2001 phk

Remove a sizeof(void *) == sizeof(int) assumption.

Submitted by: Loren James Rittle <rittle@latour.rsch.comm.mot.com>


71895 01-Feb-2001 ru

mdoc(7) police: split punctuation characters + misc fixes.


71579 24-Jan-2001 deischen

Remove _THREAD_SAFE and make libc thread-safe by default by
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


71097 16-Jan-2001 ru

Prepare for mdoc(7)NG.


70974 12-Jan-2001 ru

mdoc(7) police: Ft/Vt now accept punctuation-type arguments.


70482 29-Dec-2000 ru

Fixed typo not fixed in previous revision.


70481 29-Dec-2000 ru

Prepare for mdoc(7)NG.


70015 14-Dec-2000 ru

mdoc(7) police: removed history info from the .Os FreeBSD call.


69793 09-Dec-2000 obrien

Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.


69329 28-Nov-2000 mph

The parameter that contains valid options is "optstring", not "optarg".


69201 26-Nov-2000 phk

Make it possible to override the function which writes messages to
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.


69051 22-Nov-2000 ru

mdoc(7) police: Er macro usage cleanup.


68854 17-Nov-2000 ru

mdoc(7) police: use certified section headers wherever possible.


68716 14-Nov-2000 ru

Use Fx macro wherever possible.


68395 06-Nov-2000 ru

Fixed typos.


67876 29-Oct-2000 eivind

Back out previous commit (MLINK malloc.conf.5 -> malloc.3).
This did not work correctly with whatis(1).

Issue brought up by: mpp


67864 29-Oct-2000 eivind

Add link malloc.conf.5 -> malloc.3


66105 20-Sep-2000 brian

Oops, un-spam this file - the last commit was an accident.

Pointed out by: phk


66101 20-Sep-2000 brian

Only realloc() environ if we're sure that we know where it came from.

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*


65421 04-Sep-2000 imp

Don't print an error message if the bad option is '?'. This has been
in my tree for a long time. bde reviewed this once upon a time and
said it was OK, iirc. This also obviates the need to put ? in the
optstring argument to preclude the extra warning message which some
people think confuses users. When I made my getopt cleanups of a long
time ago, this was the compromise reached. I just neglected to commit
it until now.


62847 09-Jul-2000 phk

Turn malloc options "AJ" on by default.

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.


62321 01-Jul-2000 alfred

bring in binary search tree code.

Obtained from: NetBSD


60258 09-May-2000 sheldonh

Fix miscellaneous mdoc macro argument limit infringements.

PR: 18465
Reported by: Kazu TAKAMUNE <takamune@avrl.mei.co.jp>


60075 06-May-2000 phantom

Use `Er' variable to define first column width in ERRORS section.


60015 05-May-2000 mpp

Minor mdoc cleanup.

PR: docs/13218


59460 21-Apr-2000 phantom

Introduce ".Lb" macro to libc manpages.

More libraries manpages updates following.


59117 10-Apr-2000 phk

Add a missing THREAD_UNLOCK() found missing by Valentin Nechayev
<netch@segfault.kiev.ua>

Remove allocation failure check from 'A' option, the 'X' option does
this as a standalone check now.


58633 26-Mar-2000 charnier

Spelling, fprintf -> err, remove unneeded variable declaration


58126 16-Mar-2000 jasone

Take care to avoid having "strong" and "weak" symbols of the same name in
libc_r.


56880 29-Jan-2000 chris

Merge from RELENG_3 (oops):

resolved_name -> resolved_path
resolvedname -> resolved_path


56698 27-Jan-2000 jasone

Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),
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


56676 27-Jan-2000 ru

o Back out rev 1.4 - reallocf() failure clobbers existing `environ'.
o Do not override `environ' if realloc() fails, leave it intact.
o Set `alloced' only when memory is actually allocated.

PR: bin/5604 (2nd part)
Reviewed by: bde


56652 26-Jan-2000 archie

Document the memory leak that is inherent in FreeBSD's semantics
for getenv()/putenv().

PR: 10341 5604


55837 12-Jan-2000 jasone

Add three-tier symbol naming in support of POSIX thread cancellation
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().


55490 06-Jan-2000 hoek

Make example for handling "-##" work and comply with style(9). Still
doesn't handle nastier corner cases such as "-j3 -33" correctly. <shrug>

PR: docs/12994 (James Howard <howardjp@wam.umd.edu>)


55186 28-Dec-1999 hoek

Add history: The reallocf() function first appeared in FreeBSD-3.0.

See imp's 199808201619.KAA20970@harmony.village.org in freebsd-hackers (the
reallocf.c cvs history mistakenly refers to freebsd-current).


55032 23-Dec-1999 bde

Fixed missing installation of a link to rand_r.3.


55006 22-Dec-1999 sheldonh

Document the current behaviour with respect to the handling of errno.

Approved by: phk


54713 17-Dec-1999 jkh

Fix handling of trailing :'s to match what other OSes do (spit out
a diagnostis).

Submitted by: Guy Harris <gharris@flashcom.net>


54274 07-Dec-1999 chris

Add a cross-reference to fabs(3) man page.

PR: docs/15337
Submitted by: Bruce A. Mah <bmah@ca.sandia.gov>


53168 15-Nov-1999 kris

Typo

Obtained from: OpenBSD


53111 12-Nov-1999 peter

Go to a bit more trouble to make it absolutely clear that malloc(3)
does not zero the allocated memory.


51667 25-Sep-1999 chris

Change .Fn to .Xr on a couple of lines where abort(3) is referenced.


50967 05-Sep-1999 peter

Tidy up $Log$ debris.


50488 28-Aug-1999 peter

$Header$ -> $FreeBSD$


50476 28-Aug-1999 peter

$Id$ -> $FreeBSD$


49828 15-Aug-1999 mpp

Various man page cleanup:

- Sort xrefs
- FreeBSD.ORG -> FreeBSD.org
- Be consistent with section names as outlines in mdoc(7)
- Other misc mdoc cleanup.

PR: doc/13144
Submitted by: Alexy M. Zelkin <phantom@cris.net>


49744 14-Aug-1999 chris

Fix .Xr line for `getpagesize'


49358 01-Aug-1999 hoek

Mention that EXIT_SUCCESS and EXIT_FAILURE are preferred over
sysexits.h-values as exit codes for portable programs.


48794 12-Jul-1999 nik

Add $Id$, to make it simpler for members of the translation teams to
track.

The $Id$ line is normally at the bottom of the main comment block in the
man page, separated from the rest of the manpage by an empty comment,
like so;

.\" $Id$
.\"

If the immediately preceding comment is a @(#) format ID marker than the
the $Id$ will line up underneath it with no intervening blank lines.
Otherwise, an additional blank line is inserted.

Approved by: bde


48672 07-Jul-1999 des

Back out previous commit after discussing it with Dmitrij Tejblum.


48670 07-Jul-1999 des

Always set errno to ENOMEM when returning 0 from malloc() or realloc().

Approved by: phk


47474 24-May-1999 wes

Added Posix rand_r function.


45091 28-Mar-1999 phk

Disable the "Hint" option in phkmalloc as default. Recent VM system
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 ?)


44388 02-Mar-1999 ghelmer

Correct synopsys: getsubopt is declared in unistd.h, not stdlib.h.

PR: docs/9376


43937 12-Feb-1999 ache

fix tabs lost apparently in copy&paste


43265 27-Jan-1999 jkoshy

Clarify format of exit status code. Note when a return code of -1 can
be expected.

PR: docs/9701
Submitted by: Marc van Kempen <marc@bowtie.nl>


40901 04-Nov-1998 rnordier

Include mergesort() in description of errors.


40900 04-Nov-1998 rnordier

Drop unused labels.


40896 04-Nov-1998 rnordier

Handle a zero elements argument.

PR: 8566
Submitted by: Archie Cobbs <archie@whistle.com>


39802 30-Sep-1998 jb

Delete the XXX comments that refer to spinlock recursion. The malloc/free/
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.


39606 23-Sep-1998 dfr

Use 8k pagesize on alpha, not 4k.


39501 20-Sep-1998 alex

Back out part of previous commit (even though it's technically correct).
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.


39491 19-Sep-1998 alex

Correctly back out of free if a recursive call into malloc.c is detected.
Set malloc_func *after* grabbing the thread lock.

Noticed by: Simon Coggins <simon@oz.org>


39327 16-Sep-1998 imp

Replace memory leaking instances of realloc with non-leaking reallocf.
In some cases replace if (a == null) a = malloc(x); else a =
realloc(a, x); with simple reallocf(a, x). Per ANSI-C, this is
guaranteed to be the same thing.

I've been running these on my system here w/o ill effects for some
time. However, the CTM-express is at part 6 of 34 for the CAM
changes, so I've not been able to do a build world with the CAM in the
tree with these changes. Shouldn't impact anything, but...


39325 16-Sep-1998 imp

o Don't reference non-existant function freealloc.
o Properly order things

Pointed out by: bde


39322 16-Sep-1998 imp

Fix style problems noted by Bruce:
o No copyright on reallocf.
o Order makefile list correctly.
o indent reallocf properly.


39191 14-Sep-1998 imp

Add reallocf to the library. This function is simliar to realloc, but
when it returns NULL to indicate failure, it will also free the memory
that was passed to it, if that was non-null.

This does not change the semantics of realloc.

A second commit will be done to commit the conversion of those places in
the code that can safely use this to avoid memory leaks when confronted
with low memory situations.

Beaten-to-death-but-finally-approved-in: -current


37048 18-Jun-1998 peter

preserve errno across the readlink() calls. There is no value in trashing
errno during a successful malloc() call.


36804 09-Jun-1998 jb

Add support for thread lock debug. No impact of the malloc code.


35837 08-May-1998 jb

This is a hack to workaround source that is coded to use long variables
but also assumes that they are 32-bits. This is one place where I don't
think it is appropriate to change 'long' to 'int'. I don't see why the
code couldn't be fixed so that using natural long variables does the
right thing. It's spaggetti code so it'll take some effort. Obviously
NetBSD thought so too because they change 'long' to 'int32_t' etc
and left it at that. As a temporary measure FreeBSD/Alpha can use the
NetBSD code and put this on the list of things to fix.


35726 04-May-1998 rnordier

Fix a few nits in quoted code fragments and elsewhere.


35503 29-Apr-1998 jb

Replace the threaded locking with spinlock calls for both threaded
and non-threaded programs. This makes malloc thread safe for linking
with libpthread and kernel threads.

Reviewed by: phk


35502 29-Apr-1998 jb

Reference an external variable in threaded programs so that the
autoinitialiser gets linked in and therefore called before main().


35501 29-Apr-1998 jb

Use signal() in both the threaded and non-threaded cases.


35358 20-Apr-1998 dima

indent


35128 11-Apr-1998 phk

Remove a nolonger implented "BUGS" description.
PR: 6240
Reviewed by: phk
Submitted by: Niall Smart rotel@indigo.ie


35125 11-Apr-1998 jb

Add a global variable called __isthreaded that can be tested throughout
libc to determine if locking is required. This is needed in libc
for use with kernel threads, but until a thread is created, we don't
really want to bother locking things. The variable was added here
because the crt code calls exit(main()) so all programs will get the
variable.


35026 04-Apr-1998 jb

Change in name of the static initializer define.


34669 19-Mar-1998 charnier

.Sh AUTHOR -> .Sh AUTHORS. Use .An/.Aq


34382 09-Mar-1998 jb

NetBSD doesn't have a utrace syscall, so don't define that if
__NETBSD_SYSCALLS is defined.


33669 20-Feb-1998 jb

Change MACHINE references to MACHINE_ARCH.


32133 31-Dec-1997 alex

Drop the use of caddr_t in conjunction with mmap(2).


31722 15-Dec-1997 jb

Fix recursion problem which occurs when a signal is received during
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.


30624 21-Oct-1997 bde

Sorted lists.


30484 16-Oct-1997 bde

Handle machine-dependent (stdlib) sources more automatically.

This fixes bugs in the manual handling. abs.[cS] was handled too
specially and the wrong (.c) variant for each of div.[cS], labs.[cS]
and ldiv.[cS] was added to SRCS. This caused the .c variant to be
used if `depend' was made and the .S version to be used otherwise.


30447 15-Oct-1997 bde

Removed the subdirectory paths from the definitions of MAN[1-9]. They
were a workaround for limitations in bsd.man.mk that were fixed about
2 years ago.


29563 18-Sep-1997 charnier

environmental -> environment.


28952 31-Aug-1997 phk

Another 32bits of 64bits conformance.

Reviewed by: phk
Submitted by: jdp


28835 27-Aug-1997 phk

Improvement of type independency for the bitmap.
This makes 64bit operation more likely.

Reviewed by: phk
Submitted by: jdp


28830 27-Aug-1997 phk

Malloc option H is now default.


28640 23-Aug-1997 steve

Get rid of integer overflow warning.

PR: misc/3575
Submitted by: Bruce Evans <bde@zeta.org.au>


27698 26-Jul-1997 jdp

Fix a minor typo. It only affects the sparc version.


27449 16-Jul-1997 phk

realpath() should break on looped symlinks.

PR: 3911
Reviewed by: phk
Submitted by: Shigio Yamaguchi <shigio@wafu.netgate.net>


27369 13-Jul-1997 peter

kill the undead


27181 03-Jul-1997 bde

This commit was generated by cvs2svn to compensate for changes in r27180,
which included commits to RCS files with non-trunk default branches.


27179 02-Jul-1997 phk

Have another go at the malloc-sysv initialization.

PR: 4002
Pointed out by: bde


27152 01-Jul-1997 phk

malloc_sysv used before initialized, reported in PR4002 by
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>


26826 23-Jun-1997 steve

Show the real revision date and not the date that this
manpage is being viewed.


26816 22-Jun-1997 phk

Integrate calloc with the rest of the gang.
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>


26665 15-Jun-1997 ache

srandomdev: use stack junk value in the fallback code too


26624 14-Jun-1997 ache

Instead of copying fallback code over and over in each program,
implement (better) falback code inside srandomdev() itself.
Change return type from int to void (binary compatibility surprisely
achieved). Userland code will be changed soon.


26579 12-Jun-1997 phk

Add yet an option, this time on how to deal with malloc(0) and realloc(ptr.0)

Prompted by: X11 & XFree86


26444 04-Jun-1997 jb

Fix mutex initialization.

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-)


26284 30-May-1997 phk

Malloc flag X makes malloc behave like the canonical xmalloc() wrapper.

Untested support for Solaris from John-Mark Gurney

Reviewed by: phk
Submitted by: (partially) John-Mark Gurney <gurney_j@resnet.uoregon.edu>


25401 03-May-1997 jb

Changed all paths to be relative to src/lib instead of src/lib/libc
so that all these makefiles can be used to build libc_r too.

Added .if ${LIB} == "c" tests to restrict man page builds to libc
to avoid needlessly building them with libc_r too.

Split libc Makefile into Makefile and Makefile.inc to allow the
libc_r Makefile to include Makefile.inc too.


25145 25-Apr-1997 max

Typo.
PR: #3178
Submitted by: Josh Gilliam <soil@quick.net>


25028 19-Apr-1997 bde

Fixed #include and/or prototype bugs in synopsis.


24880 13-Apr-1997 bde

Fixed missing consts in synopsis.


24390 29-Mar-1997 ache

Remove orand* code as promised for the next release


24155 23-Mar-1997 ache

Add srandomdev.3 link


24154 23-Mar-1997 ache

Fix urandom reference in the comment


24153 23-Mar-1997 ache

Add srandomdev() description


24151 23-Mar-1997 ache

Add srandomdev() function (use "/dev/urandom" now)

Submitted by: wollman & me (add type casts and remove unneded loop)


24125 22-Mar-1997 mpp

Remove an extra comma.


24094 21-Mar-1997 mpp

Use the .Tn macro for generic FreeBSD references. Other minor cleanup.


23981 18-Mar-1997 phk

Check for overflow in size argument.

Tested by: Joel Maslak <j@pobox.com>
Closes: PR kern/2964


23969 17-Mar-1997 ache

Fix arg types to match Lite2


23833 13-Mar-1997 peter

Part 2 of a failed commit (cvs broke). Original message:
Back out a dubious Lite2 change to "optimise" getcwd() to look at $PWD
because it's potentially dangerous (think: symlink races). Move
realpath() back to it's original location, and remove getcwd_physical()
by renaming it back to getcwd() and zapping the original getcwd wrapper.

Noticed by: bde

The following commits already happened but the log message got lost:

Modified Files:
gen/Makefile.inc gen/getcwd.c stdlib/Makefile.inc
Removed Files:
gen/realpath.3


23832 13-Mar-1997 peter

Back out a dubious Lite2 change to "optimise" getcwd() to look at $PWD
because it's potentially dangerous (think: symlink races). Move
realpath() back to it's original location, and remove getcwd_physical()
by renaming it back to getcwd() and zapping the original getcwd wrapper.

Noticed by: bde


23662 11-Mar-1997 peter

Merge Lite2 changes


23661 11-Mar-1997 peter

merge from Lite2 - realpath() now shares a lot of code with getcwd()
and is now in the same file.


23659 11-Mar-1997 peter

This commit was generated by cvs2svn to compensate for changes in r23658,
which included commits to RCS files with non-trunk default branches.


22993 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


21907 20-Jan-1997 wosch

Sort cross references.


21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

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.


21000 29-Dec-1996 alex

_thread_kern_sig_unblock takes an integer, not a reference.

Submitted by: John Birrell <jb@cimlogic.com.au>


20888 23-Dec-1996 wosch

comma typos


19257 29-Oct-1996 phk

If you run with option Z and malloc fails, memset gets called
with a NULL pointer (archie)
Explain that minsize is also the smallest alignment.

Submitted by: Archie Cobbs <archie@whistle.com>


19196 26-Oct-1996 alex

Note that streams are now flushed on abort.

Change standards section to reflect POSIX 1003.1-1990 conformance.


19191 26-Oct-1996 phk

Various cosmetics
Improve chances of troublefree 64bit operation. [imp]

Noticed by: Warner Losh <imp@village.org>


19189 26-Oct-1996 alex

POSIX requires stdio buffers be flushed on abort.

Obtained from: OpenBSD, Thorsten Lockert <tholo@OpenBSD.ORG>


19057 20-Oct-1996 phk

malloc_pages should be static.
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.


18832 09-Oct-1996 ache

Improve seeding, the random sequence did not vary match
with the seed. Old variant will be available via libcompat soon.


18516 27-Sep-1996 phk

Don't use malloc, pessimize to use sbrk.
fix sbrk manpage while we're at it.


18495 25-Sep-1996 sos

Fix a typo.
Reviewed by: phk


18493 25-Sep-1996 phk

A number of minor bogons and portability things from jdp.

Submitted by: jdp


18480 23-Sep-1996 wosch

add missing comma(s) in .Xr macros


18479 23-Sep-1996 phk

phkmalloc/3
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.


18333 17-Sep-1996 phk

Fix a very rare error condition: The code to free VM back to the kernel
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.


17971 31-Aug-1996 bde

Don't depend in the kernel on the gcc feature of doing arithmetic on
pointers of type `void *'. Warn about this in future.


17782 22-Aug-1996 mpp

Correctly use .Fn instead of .Nm to reference function names
in a bunch of man pages.

Use the correct .Bx (BSD UNIX) or .At (AT&T UNIX) macros
instead of explicitly specifying the version in the text
in a bunch of man pages.


17780 22-Aug-1996 mpp

Update a bunch of man pages to use .Fn instead
of .Nm when referencing funciton names.


17748 21-Aug-1996 mpp

Correctly document when getopt returns EOF and '?', and some other
minor cleanup.


17141 12-Jul-1996 jkh

General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>


16941 03-Jul-1996 phk

Isolated all the crap for thread-safe so I can see what goes on again...


16228 08-Jun-1996 jraynard

Oops, replace a rather important line that was lost in transit 8-(


16117 05-Jun-1996 jraynard

Submitted by: (based on code in "Advanced Programming in the Unix Environment"
by W.Richard Ste vens. EINTR handling suggested by bde@freebsd.org).

Code cleanup:

1. Add missing return type.
2. Replace 'union wait' by int.
3. Use Posix-style signal handling instead of signal().
4. Use fork() instead of deprecated vfork().
5. Block signals before fork()'ing, instead of after.
6. Return -1 if fork() fails, instead of 0.
7. Add EINTR handling for waitpid() call.

Also add claim of Posix conformance to man page.


15874 23-May-1996 mpp

Fixed various problems: typos, grammer, missing include files
wrong function type declarations, and wrong argument type
declarations.


15312 19-Apr-1996 bde

Don't include <sys/types.h> when it isn't used.

This commit covers most of the ANSI library functions. Many others only
need <sys/types.h> because they use u_xxx.


14964 31-Mar-1996 joerg

Xref sysexits(3).


14855 27-Mar-1996 mpp

Added missing section numbers to a bunch of .Xr macros, or
converted them into .Fn macros where appropriate. Also fixed
up some minor formatting problems.


14101 15-Feb-1996 mpp

Fixed a bunch of man page cross references that were
in the main text of various man pages.

Thanks to Warner Losh for adding an option to manck to allow
it to scan the entire man page looking for bogus xrefs, instead
of just checking the SEE ALSO section.


14038 11-Feb-1996 mpp

Correct a bunch of man page cross references and generally
try and silence "manck".

ncurses, rpc, and some of the gnu stuff are still a big mess, however.


13750 30-Jan-1996 mpp

Fix even more spelling errors in some more man pages.


13545 22-Jan-1996 julian

Reviewed by: julian and (hsu?)
Submitted by: John Birrel(L?)

changes for threadsafe operations


13413 13-Jan-1996 jkh

Return pointer to new hash node when search inserts it (e.g. there
was some datum given).


13268 05-Jan-1996 phk

Fix a fencepost error.
Found by: Lars Fredriksen <fredriks@mcs.com>


13123 30-Dec-1995 peter

This commit was generated by cvs2svn to compensate for changes in r13122,
which included commits to RCS files with non-trunk default branches.


13030 26-Dec-1995 bde

Added prototypes.


12918 18-Dec-1995 phk

Preallocate a small structure, so we can sbrk(2) further back.
Reviewed by: phk
Submitted by: Kaleb Keithly <kaleb@x.org>


12776 11-Dec-1995 peter

Change phkmalloc so that the page directory is now floating and allocated
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


11668 22-Oct-1995 phk

Mino cleanup, #includes & unused vars.


11665 22-Oct-1995 phk

Remove EXTRA_SANITY, fix a unused var.


11549 17-Oct-1995 dg

Doubled the performance of getenv()/__findenv() by rewriting it to not
use strncmp()..


11338 08-Oct-1995 phk

phkmalloc/2
"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. (!!)


10952 22-Sep-1995 phk

A buglet when dumping and a stylistic point from Mike.

Submitted by: Mike Pritchard <mpp@mpp.minn.net>


10818 16-Sep-1995 phk

``phkmalloc''
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.


9846 01-Aug-1995 ache

Make strtod conforms manpage, use isspace to skip initial whitespaces
instead of hardcoded whitespaces


9845 01-Aug-1995 ache

Similar changes like in strtol, all this family is VERY broken
in 8bit environment (isalpha at the end of digits)


9843 01-Aug-1995 ache

strtol and atoi VERY broken in 8bit chars locale, i.e. if you pass something
like 38400<any 8bit char, isalpha> it not detect this stuff and
produce very big number instead. Fixed by operating with unsigned char
and checking for isascii. (secure/telnetd hits by it f.e.)


8870 30-May-1995 rgrimes

Remove trailing whitespace.


7435 28-Mar-1995 jkh

Fix a missing _hash() to prevent namespace pollution with the db/hash routines.
Grrr. If the dbhash routines weren't grossly overengineered I wouldn't
even need to do this! :-(

Also now export the hash_stats routine. Manpage coming RSN - I promise.


7394 26-Mar-1995 ache

Hash 8bit chars without sign extension


7388 26-Mar-1995 jkh

Add the strhash family of routines. They provide a number of features
that the db/hash functions don't, and they're much simpler to use for
low-overhead string hashing.


6700 25-Feb-1995 bde

Don't attempt to lstat() the POSIXLY invalid empty pathname.

realpath() still accepts "" as an arg and converts it to a canonical
pathname for the current directory.


2504 05-Sep-1994 bde

u_int -> unsigned int, so that we don't have to include <sys/types.h>
or depend on <stdio.h> bogusly including it.


1849 05-Aug-1994 wollman

First crack at making libc work with the new make macros. It compiles on
my machine, and a simple static (genassym) and shared (sysctl) executable
both work. Still to be done: RPCand YP merge.


1574 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1573,
which included commits to RCS files with non-trunk default branches.


1573 27-May-1994 rgrimes

BSD 4.4 Lite Lib Sources