Commit Graph

451 Commits

Author SHA1 Message Date
Giorgos Keramidas
f2572d955f 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>
2002-06-06 22:11:19 +00:00
Poul-Henning Kamp
ff84d98ac2 Const poison.
Partially submitted by:	wollman
2002-05-30 21:59:16 +00:00
Ruslan Ermilov
74784e8141 mdoc(7) police: nit. 2002-05-29 15:44:34 +00:00
Alfred Perlstein
a82bbc730e Assume __STDC__, remove non-__STDC__ code.
Submitted by: keramida
2002-05-28 17:03:12 +00:00
Dima Dorfman
f500ce59aa Remove spurious period. 2002-05-27 03:45:27 +00:00
Benno Rice
56c18ed0ed Let this code know about PowerPC. 2002-05-21 03:40:42 +00:00
Peter Wemm
9269daa2fb Avoid casting a different sized integer to a pointer on LP64 systems. 2002-05-10 12:50:59 +00:00
Poul-Henning Kamp
9908ed2b1e Constify _malloc_options. 2002-04-24 16:49:36 +00:00
Mark Murray
4cd0119367 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.
2002-03-29 22:43:43 +00:00
David E. O'Brien
1114a754ed Fix the style of the SCM ID's.
I believe have made all of libc .h's as consistent as possible.
2002-03-22 23:42:05 +00:00
David E. O'Brien
333fc21e3c Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.
2002-03-22 21:53:29 +00:00
David E. O'Brien
1372519b15 Remove multi-line __P() usage. 2002-03-22 09:22:15 +00:00
David E. O'Brien
c05ac53b8b Remove __P() usage. 2002-03-21 22:49:10 +00:00
David E. O'Brien
8fb3f3f682 Remove 'register' keyword. 2002-03-21 18:49:23 +00:00
Tor Egge
df140f7277 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
2002-03-05 17:34:37 +00:00
Jake Burkholder
dfca860bfc Add ifdefs for sparc64. 2002-02-23 19:05:26 +00:00
Yaroslav Tykhiy
b454be098e Minor typo fix: uquad_t -> u_quad_t. 2002-01-20 16:50:29 +00:00
Ruslan Ermilov
58c0fdd850 mdoc(7) police: add missing markup bits for ``errno''. 2002-01-09 14:03:54 +00:00
Andrey A. Chernov
f7388e0d38 Back out errno preserving 2001-12-30 03:34:46 +00:00
Andrey A. Chernov
98b870fa7b Add "except the handling of errors" into "equivalent to" paragraph.
Pointed by:	bde
Inspired by:	POSIX
2001-12-25 08:43:35 +00:00
Andrey A. Chernov
b12990ca58 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."
2001-12-25 04:10:50 +00:00
Alexey Zelkin
e578c6f17c * cleanup comments and defines
Reviewed by:	bde
2001-12-14 11:36:37 +00:00
Ruslan Ermilov
f7475de715 mdoc(7) police: fix markup, bump document date. 2001-12-12 14:53:51 +00:00
Ruslan Ermilov
f0cc88ffed mdoc(7) police: kill HSBs, add missing comma. 2001-12-12 14:41:53 +00:00
Ruslan Ermilov
9a05e59078 mdoc(7) police: fix markup. 2001-12-12 14:40:09 +00:00
Alexey Zelkin
52d6b43026 Add my e-mail to copyrights 2001-12-11 16:00:47 +00:00
Alexey Zelkin
a94da0a9f3 Get rid of unused anymore file! Alpha works fine with our strtod() now. 2001-12-07 17:19:09 +00:00
Andrey A. Chernov
f34b139cda Return 'c' back to signed due to potential comparison problems
Use simpler test for valid ranges

Submitted by:	bde
2001-12-07 16:33:47 +00:00
Peter Wemm
6464bbfa03 Use the merged strtod.c everywhere. This has been tested on alpha and
ia64.
2001-12-02 18:27:40 +00:00
Andrey A. Chernov
4bd71a3c89 Make it works for non ASCII compatible encodings too.
The only assumption left is that 'A'..'Z' 'a'..'z' both are contiguous
2001-12-02 09:15:54 +00:00
Alexey Zelkin
4a57e677c7 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)
2001-11-30 12:48:30 +00:00
Andrey A. Chernov
2209d8a27c 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.
2001-11-29 03:03:55 +00:00
Andrey A. Chernov
87c25490c8 Don't ever assume that isdigit() is always subset of isxdigit() 2001-11-28 06:06:27 +00:00
Andrey A. Chernov
7bbd0c8b5b Fix typo 2001-11-28 05:43:24 +00:00
Andrey A. Chernov
76604b47c1 Use stricter tests to disallow national digits > 9
Optimize national digits code a bit
2001-11-28 05:39:21 +00:00
Andrey A. Chernov
01a0db1367 Allow national (non-ASCII) digits 2001-11-28 03:57:12 +00:00
Bill Fenner
9c5cbc30e7 Implement strtoimax() and strtoumax() 2001-11-28 03:37:06 +00:00
Bill Fenner
3b175d881c Also mention "long long" in synopsis. 2001-11-28 03:36:05 +00:00
Bill Fenner
b9004c1158 Base 36 is allowed. 2001-11-28 02:35:35 +00:00
Andrey A. Chernov
649ffc6d4b Put back base > 35 check. If someone dislike it, plese discuss it with
standards group first.
2001-11-28 02:17:22 +00:00
Andrey A. Chernov
59d01330c4 Add atoll(3) to conform POSIX and C99 2001-11-28 01:22:08 +00:00
Andrey A. Chernov
7e302fc7a2 Understand national (non-ASCII) digits now
Allow bases >=36 again
Misc cleanup
2001-11-28 00:48:11 +00:00
Giorgos Keramidas
fe1b3cedf9 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>
2001-11-24 03:05:40 +00:00
Ruslan Ermilov
b18f229930 mdoc(7) police: fixed typos and minor markup nits. 2001-11-21 16:19:50 +00:00
Poul-Henning Kamp
7224d02a0d If 'VX' is given, realloc(foo,0) will bail, it shouldn't.
PR:		29376
Submitted by:	Farooq Mela <fmela0@sm.socccd.cc.ca.us>
2001-11-17 10:57:04 +00:00
Poul-Henning Kamp
4b9a9ef10b Correctly call THREAD_UNLOCK() if the recursive call trap is sprung.
Pointed out by:		knu
2001-11-16 18:15:33 +00:00
Mike Barcroft
7a4a63270f 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
2001-11-15 02:05:03 +00:00
Dima Dorfman
8b642e3004 malloc and calloc do not free memory.
PR:		31365
Submitted by:	SUZUKI Koichi <koich@cac.co.jp>
2001-11-05 00:39:27 +00:00
Peter Wemm
b1f214cf5f 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.
2001-11-04 21:30:12 +00:00
Peter Wemm
f29f85e083 Slightly closer to netbsd_strtod.c:
s/IEEE_8087/IEEE_LITTLE_ENDIAN/
s/IEEE_MC68k/IEEE_BIG_ENDIAN/
2001-11-04 18:04:00 +00:00
Poul-Henning Kamp
0f400b2861 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>
2001-11-02 11:32:28 +00:00
Mark Murray
724641c6f4 Add a long-overdue nail to the deprecated /dev/urandom interface
by asking some things that need unpredictable numbers to read
/dev/random instead.
2001-10-30 21:26:50 +00:00
Doug Rabson
a4ddd40c34 Make this work on ia64. I have no idea why it works on alpha - it
shouldn't.
2001-10-06 15:58:54 +00:00
Alfred Perlstein
9c2ccf2741 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>
2001-10-03 11:01:39 +00:00
Ruslan Ermilov
2677aa4b68 mdoc(7) police: don't split author names in the AUTHORS section. 2001-10-01 13:50:03 +00:00
Ruslan Ermilov
ae0d2bed3e mdoc(7) police: s/atof/atoi/ 2001-10-01 12:44:24 +00:00
Jeroen Ruigrok van der Werven
54045486e0 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
2001-09-26 20:22:44 +00:00
Jeroen Ruigrok van der Werven
5578cfa2fa Be explicit about the POSIX version it conforms to [in this case 1990].
Put the error comment under the more appropriate ERRORS section.
2001-09-26 20:10:10 +00:00
Jeroen Ruigrok van der Werven
99e8131545 Change standards compliancy order so that C and POSIX are grouped. 2001-09-26 19:42:39 +00:00
Mike Barcroft
a5aecc7707 style(9)
Silence from:	phantom
2001-09-17 00:23:19 +00:00
Ruslan Ermilov
8fc5ce4d99 mdoc(7) police: changed pure POSIX text; added missing markup bits. 2001-09-11 09:39:23 +00:00
Jeroen Ruigrok van der Werven
49c65386a5 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.
2001-09-09 21:09:53 +00:00
Jeroen Ruigrok van der Werven
e348b8ea25 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.
2001-09-09 18:52:00 +00:00
Jeroen Ruigrok van der Werven
8aefde0607 Move to using .In instead of .Fd #include <> for include mark-up.
Inspired by comment from:	dd
2001-09-07 14:46:36 +00:00
Alexey Zelkin
84b4fdf912 reconnect strfmon.c to build list 2001-09-07 13:03:16 +00:00
Jeroen Ruigrok van der Werven
fbded4984e Fix some mdoc nits caused by my knowledge not being too up-to-date on
mdocNG.

Submitted by:	dd
2001-09-07 12:38:10 +00:00
Doug Rabson
8e37b82334 Port to ia64, taking into account the fact that pagesizes may be variable. 2001-09-07 12:32:43 +00:00
Jeroen Ruigrok van der Werven
8c9893a371 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.
2001-09-07 09:55:28 +00:00
Alexey Zelkin
f6a9e03fe5 correctly wrap macros with { } 2001-09-06 09:26:28 +00:00
David E. O'Brien
19372e6db7 strfmon(3) is not ready to go live. 2001-09-06 08:58:42 +00:00
Alexey Zelkin
9d430a5991 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
2001-09-05 18:50:02 +00:00
Andrey A. Chernov
2505b3ed25 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.
2001-09-04 21:28:01 +00:00
Andrey A. Chernov
f8ade0e68e Remove rcsids and unneded include 2001-09-04 17:41:20 +00:00
Andrey A. Chernov
f4fc08f367 'acc' is not initialized in one hypotetical case, fix it 2001-09-04 17:12:15 +00:00
Andrey A. Chernov
4e6b157062 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.
-----------------------------------------------------
2001-09-04 16:39:11 +00:00
Ruslan Ermilov
d6002fef6f Use ``.Rv -std'' wherever possible.
Submitted by:	yar
2001-08-31 09:57:38 +00:00
Joseph Koshy
2f46ebcdb7 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
2001-08-16 03:27:03 +00:00
Ruslan Ermilov
b3ebbab8d3 Fixed style bugs (dot `.' at the end of error and warning messages).
Noticed by:	bde
2001-08-10 11:46:37 +00:00
Ruslan Ermilov
a9bef12a45 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.
2001-08-10 11:41:55 +00:00
Yaroslav Tykhiy
b1250632c5 Use the ``.Rv -std'' mdoc(7) macro in appropriate cases.
Reviewed by:	ru
2001-08-09 13:32:13 +00:00
Ruslan Ermilov
6575e6daae mdoc(7) police: expand plain text xrefs. 2001-08-08 11:48:28 +00:00
Mark Peek
545d32087b Only pull in the MD files if they exist. This allows for progressive
implementation and compilation when bringing up a new architecture.
2001-07-31 16:34:52 +00:00
Dima Dorfman
7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Ruslan Ermilov
a307d59838 mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 13:41:46 +00:00
Ruslan Ermilov
e25e8ab41c mdoc(7) police: eliminate -ww warnings. 2001-07-09 15:54:36 +00:00
Dima Dorfman
70d51341bf mdoc(7) police: remove extraneous .Pp before and/or after .Sh. 2001-07-09 09:54:33 +00:00
Ruslan Ermilov
62205fee40 mdoc(7) police: mark NULL with .Dv. 2001-07-04 12:04:25 +00:00
Dima Dorfman
44fe68c421 mdoc(7) police: the BUGS section should go after HISTORY and AUTHORS. 2001-06-24 20:58:20 +00:00
Dima Dorfman
17011fc056 The fact that phk wrote this is not a bug! 2001-06-24 20:56:39 +00:00
Dima Dorfman
acaa9950a4 Reword a sentence to make it proper English. 2001-06-24 18:11:42 +00:00
Dima Dorfman
a7d81577d6 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
2001-06-07 02:32:18 +00:00
Dima Dorfman
df49b8e2ab urandom(4) -> random(4)
PR:		27858
Submitted by:	Yoshihiro Koya <Yoshihiro.Koya@math.yokohama-cu.ac.jp>
Approved by:	markm
2001-06-07 02:31:03 +00:00
Ruslan Ermilov
ec7d12549c Add new, from scratch implementation of hsearch() et al that actually works.
Obtained from:	NetBSD
MFC after:	1 month
2001-05-15 07:08:20 +00:00
Ruslan Ermilov
7ab50d97ea Grammar nit. 2001-04-27 08:16:57 +00:00
Andrey A. Chernov
74825256ef Add sranddev.3 to MLINKS 2001-04-23 11:11:00 +00:00
Andrey A. Chernov
4890ae810e Add #include "un-namespace.h" 2001-04-23 10:38:26 +00:00
Andrey A. Chernov
848422bb7d srand*dev() fallback code: change ^getpid() to ^(getpid() << 16) to allow
change of high word part too to produce more interesting seed distribution.
2001-04-23 10:14:28 +00:00
Andrey A. Chernov
7708205cb7 Add sranddev() since srand() is not vary much with seed, typical time 2001-04-23 02:29:10 +00:00
Ruslan Ermilov
4a558355e5 MAN[1-9] -> MAN. 2001-03-27 17:27:19 +00:00
Dima Dorfman
681b009b93 Make tdelete(3), tfind(3), and twalk(3) links to tsearch(3).
Approved by:	nik
2001-03-15 01:53:17 +00:00
David E. O'Brien
083745b549 Merge in strtoul.3 rev 1.11 mdoc(7) police changes:
.Nd line broken in rev 1.10
	use .Bx for ``BSD''
2001-02-28 17:46:56 +00:00
Ruslan Ermilov
0b01af0991 mdoc(7) police: fix the .Nd line broken in previous revision.
Noticed by:	bde

Use .Bx for ``BSD''.
2001-02-28 12:54:16 +00:00
Andrey A. Chernov
cbcf73f998 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).
2001-02-27 14:42:19 +00:00
David E. O'Brien
3bdced7c3c I accidently deleted an include when I added the $FreeBSD$ so I could
check in my changes.
2001-02-27 14:30:42 +00:00
David E. O'Brien
4c0440cb86 Impliment the ISO-C99 strto[u]ll()
and rewrite strto[u]q() in terms of it.
2001-02-27 13:33:07 +00:00
Ruslan Ermilov
588a200ce1 .St -ansiC -> .St -isoC 2001-02-26 13:23:47 +00:00
Tor Egge
3275de7ca5 Update unused __dtoa prototypes to match reality. 2001-02-25 08:51:41 +00:00
Tor Egge
2ffc61ba9c 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
2001-02-15 22:12:50 +00:00
Ruslan Ermilov
1a0c34f25e "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.
2001-02-12 08:30:22 +00:00
Ruslan Ermilov
9a801ec807 mmap(3) -> mmap(2). 2001-02-12 08:27:06 +00:00
Nik Clayton
59b58b1622 Include mmap(2) in the list of memory allocation functions.
Reviewed by:	hackers
2001-02-11 19:28:36 +00:00
Nik Clayton
38f2cd4aa4 .Xr to mmap. 2001-02-11 18:53:50 +00:00
Ruslan Ermilov
429d919c70 mdoc(7) police: mark LC_NUMERIC with .Dv. 2001-02-10 10:26:52 +00:00
Andrey A. Chernov
2b2075b191 Note that decimal point taken from locale 2001-02-10 06:42:32 +00:00
Andrey A. Chernov
05a6e1e59b Note the fact that decimal point taken from locale (according to SUSv2) 2001-02-10 05:16:41 +00:00
Andrey A. Chernov
b0e3ccc057 Use decimap_point from localeconv() instead of hardcoded '.'
Obtained from:	inspired by NetBSD strtod
2001-02-10 05:05:09 +00:00
Tor Egge
d7e56cc908 Backout previous commit. Use of spinlocks was not approved.
PR:		15070
2001-02-09 20:31:48 +00:00
Tor Egge
1d538861ff 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
2001-02-08 20:22:28 +00:00
Ruslan Ermilov
46eea498da 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.
2001-02-07 13:45:30 +00:00
Bruce Evans
75d5d29ef0 Fixed C error(s) in synopsis. Many were hiding under mdoc errors. 2001-02-05 15:19:56 +00:00
Poul-Henning Kamp
95ba77bff8 Remove a sizeof(void *) == sizeof(int) assumption.
Submitted by:	Loren James Rittle <rittle@latour.rsch.comm.mot.com>
2001-02-04 10:06:24 +00:00
Ruslan Ermilov
d0353b836e mdoc(7) police: split punctuation characters + misc fixes. 2001-02-01 16:38:02 +00:00
Daniel Eischen
d201fe46e3 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
2001-01-24 13:01:12 +00:00
Ruslan Ermilov
32f6256a49 Prepare for mdoc(7)NG. 2001-01-16 09:08:22 +00:00
Ruslan Ermilov
b77b3c00be mdoc(7) police: Ft/Vt now accept punctuation-type arguments. 2001-01-12 15:46:56 +00:00
Ruslan Ermilov
672062062d Fixed typo not fixed in previous revision. 2000-12-29 14:36:05 +00:00
Ruslan Ermilov
4263595653 Prepare for mdoc(7)NG. 2000-12-29 14:08:20 +00:00
Ruslan Ermilov
ed40311694 mdoc(7) police: removed history info from the .Os FreeBSD call. 2000-12-14 11:52:05 +00:00
David E. O'Brien
1a37aa566b Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.
2000-12-09 09:35:55 +00:00
Matthew Hunt
fecae3493c The parameter that contains valid options is "optstring", not "optarg". 2000-11-28 22:06:17 +00:00
Poul-Henning Kamp
798c1fd885 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.
2000-11-26 10:30:18 +00:00
Ruslan Ermilov
c23155a43a mdoc(7) police: Er macro usage cleanup. 2000-11-22 16:02:00 +00:00
Ruslan Ermilov
251c176f41 mdoc(7) police: use certified section headers wherever possible. 2000-11-17 11:44:16 +00:00
Ruslan Ermilov
b5c508fba3 Use Fx macro wherever possible. 2000-11-14 11:20:58 +00:00
Ruslan Ermilov
a72b09f0aa Fixed typos. 2000-11-06 15:46:57 +00:00
Eivind Eklund
e68aef6429 Back out previous commit (MLINK malloc.conf.5 -> malloc.3).
This did not work correctly with whatis(1).

Issue brought up by:	mpp
2000-10-29 13:20:24 +00:00
Eivind Eklund
8b746a4d67 Add link malloc.conf.5 -> malloc.3 2000-10-29 09:59:35 +00:00
Brian Somers
f241969910 Oops, un-spam this file - the last commit was an accident.
Pointed out by: phk
2000-09-20 06:16:23 +00:00
Brian Somers
b1daa1b9db 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*
2000-09-20 03:05:37 +00:00
Warner Losh
e9d918edb6 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.
2000-09-04 03:49:22 +00:00
Poul-Henning Kamp
832505d0c9 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.
2000-07-09 13:10:18 +00:00
Alfred Perlstein
64566a3e2a bring in binary search tree code.
Obtained from: NetBSD
2000-07-01 06:55:11 +00:00
Sheldon Hearn
f167d7fb3e Fix miscellaneous mdoc macro argument limit infringements.
PR:		18465
Reported by:	Kazu TAKAMUNE <takamune@avrl.mei.co.jp>
2000-05-09 14:02:06 +00:00
Alexey Zelkin
274b6244d3 Use `Er' variable to define first column width in ERRORS section. 2000-05-06 12:00:11 +00:00
Mike Pritchard
751f44657e Minor mdoc cleanup.
PR:		docs/13218
2000-05-05 02:21:45 +00:00
Alexey Zelkin
25bb73e063 Introduce ".Lb" macro to libc manpages.
More libraries manpages updates following.
2000-04-21 09:42:15 +00:00
Poul-Henning Kamp
aad4b9d1e8 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.
2000-04-10 09:24:44 +00:00
Philippe Charnier
f25c63af03 Spelling, fprintf -> err, remove unneeded variable declaration 2000-03-26 15:18:12 +00:00
Jason Evans
b479399f73 Take care to avoid having "strong" and "weak" symbols of the same name in
libc_r.
2000-03-16 02:14:41 +00:00
Chris Costello
cfc2d91b25 Merge from RELENG_3 (oops):
resolved_name	-> resolved_path
    resolvedname	-> resolved_path
2000-01-29 19:43:25 +00:00
Jason Evans
9233c4d942 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
2000-01-27 23:07:25 +00:00
Ruslan Ermilov
7e20508477 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
2000-01-27 16:12:03 +00:00
Archie Cobbs
5059d6a601 Document the memory leak that is inherent in FreeBSD's semantics
for getenv()/putenv().

PR:	10341 5604
2000-01-26 22:10:56 +00:00
Jason Evans
929273386f 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().
2000-01-12 09:23:48 +00:00
Tim Vanderhoek
838fb327f2 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>)
2000-01-06 01:25:15 +00:00
Tim Vanderhoek
e99fd39264 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).
1999-12-28 15:14:59 +00:00
Bruce Evans
fb59427e5c Fixed missing installation of a link to rand_r.3. 1999-12-23 16:00:50 +00:00
Sheldon Hearn
b3c5295256 Document the current behaviour with respect to the handling of errno.
Approved by:	phk
1999-12-22 17:04:46 +00:00
Jordan K. Hubbard
f8d7aff7a0 Fix handling of trailing :'s to match what other OSes do (spit out
a diagnostis).

Submitted by:	Guy Harris <gharris@flashcom.net>
1999-12-17 01:52:15 +00:00
Chris Costello
a70b5c6a96 Add a cross-reference to fabs(3) man page.
PR:		docs/15337
Submitted by:	Bruce A. Mah <bmah@ca.sandia.gov>
1999-12-07 23:09:58 +00:00
Kris Kennaway
a8b4fa4aaf Typo
Obtained from:	OpenBSD
1999-11-15 03:13:23 +00:00
Peter Wemm
0d052386ba Go to a bit more trouble to make it absolutely clear that malloc(3)
does not zero the allocated memory.
1999-11-12 16:41:21 +00:00
Chris Costello
0df0b5481f Change .Fn to .Xr on a couple of lines where abort(3) is referenced. 1999-09-25 22:42:12 +00:00
Peter Wemm
b60a120f4b Tidy up $Log$ debris. 1999-09-05 17:42:45 +00:00
Peter Wemm
a1a4f1a0d8 $Header$ -> $FreeBSD$ 1999-08-28 05:11:36 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Mike Pritchard
74804d58a0 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>
1999-08-15 09:51:25 +00:00
Chris Costello
a251398eea Fix .Xr line for `getpagesize' 1999-08-14 07:33:15 +00:00
Tim Vanderhoek
cc5aedfb1a Mention that EXIT_SUCCESS and EXIT_FAILURE are preferred over
sysexits.h-values as exit codes for portable programs.
1999-08-01 20:46:45 +00:00
Nik Clayton
fbc400a67a 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
1999-07-12 20:50:10 +00:00
Dag-Erling Smørgrav
65b97b034e Back out previous commit after discussing it with Dmitrij Tejblum. 1999-07-07 21:01:20 +00:00
Dag-Erling Smørgrav
c58b5cffa1 Always set errno to ENOMEM when returning 0 from malloc() or realloc().
Approved by:	phk
1999-07-07 19:54:08 +00:00
Wes Peters
b7edcd43b5 Added Posix rand_r function. 1999-05-24 23:30:14 +00:00
Poul-Henning Kamp
5b26e84968 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 ?)
1999-03-28 14:16:05 +00:00
Guy Helmer
6e062fe1b7 Correct synopsys: getsubopt is declared in unistd.h, not stdlib.h.
PR:		docs/9376
1999-03-02 02:35:57 +00:00
Andrey A. Chernov
be92e0e6cd fix tabs lost apparently in copy&paste 1999-02-12 19:45:53 +00:00
Joseph Koshy
221188c6cb 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>
1999-01-27 03:54:09 +00:00
Robert Nordier
8d2c3c32bd Include mergesort() in description of errors. 1998-11-04 09:27:03 +00:00
Robert Nordier
df5a1b840e Drop unused labels. 1998-11-04 09:22:07 +00:00
Robert Nordier
7fb5f2bae4 Handle a zero elements argument.
PR:		8566
Submitted by:	Archie Cobbs <archie@whistle.com>
1998-11-04 08:55:34 +00:00
John Birrell
a0aa389007 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.
1998-09-30 06:13:59 +00:00
Doug Rabson
cea1d019fe Use 8k pagesize on alpha, not 4k. 1998-09-23 21:26:04 +00:00
Alexander Langer
d988805a1f 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.
1998-09-20 01:07:50 +00:00
Alexander Langer
366248e086 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>
1998-09-19 20:55:36 +00:00
Warner Losh
e8420087b0 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...
1998-09-16 04:17:47 +00:00
Warner Losh
e70c6df958 o Don't reference non-existant function freealloc.
o Properly order things

Pointed out by: bde
1998-09-16 04:07:31 +00:00
Warner Losh
9a5722f2e8 Fix style problems noted by Bruce:
o No copyright on reallocf.
	o Order makefile list correctly.
	o indent reallocf properly.
1998-09-16 03:16:06 +00:00
Warner Losh
94ad719cf4 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
1998-09-14 20:34:34 +00:00
Peter Wemm
2f92c56cc3 preserve errno across the readlink() calls. There is no value in trashing
errno during a successful malloc() call.
1998-06-18 09:13:16 +00:00
John Birrell
3d853e107e Add support for thread lock debug. No impact of the malloc code. 1998-06-09 08:30:32 +00:00
John Birrell
184fcab826 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.
1998-05-08 05:41:57 +00:00
Robert Nordier
a55fccb456 Fix a few nits in quoted code fragments and elsewhere. 1998-05-04 23:16:50 +00:00
John Birrell
72b42edfd4 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
1998-04-29 09:10:58 +00:00
John Birrell
96c76d66db Reference an external variable in threaded programs so that the
autoinitialiser gets linked in and therefore called before main().
1998-04-29 09:08:43 +00:00
John Birrell
7317e6b1fd Use signal() in both the threaded and non-threaded cases. 1998-04-29 09:06:13 +00:00
Dima Ruban
b4d829b84f indent 1998-04-20 22:13:50 +00:00
Poul-Henning Kamp
af3c7c8d85 Remove a nolonger implented "BUGS" description.
PR:		6240
Reviewed by:	phk
Submitted by:	Niall Smart rotel@indigo.ie
1998-04-11 07:37:44 +00:00
John Birrell
f901bc2795 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.
1998-04-11 07:02:58 +00:00
John Birrell
5a2f1fed77 Change in name of the static initializer define. 1998-04-04 11:03:07 +00:00
Philippe Charnier
a5941fc2aa .Sh AUTHOR -> .Sh AUTHORS. Use .An/.Aq 1998-03-19 07:34:22 +00:00