Commit Graph

786 Commits

Author SHA1 Message Date
christos 15c525fbc5 fix compilation for non _REENTRANT 2019-03-28 15:05:03 +00:00
christos b4744953f9 Hook for jemalloc 2019-03-04 17:30:33 +00:00
christos dda6d8cae4 fix grammar. 2018-12-09 20:29:53 +00:00
kamil cae5584ffc Correct handling of minval > maxval in strtonum(3)
The original implementation in OpenBSD returns "invalid" and avoids reading
the input string. The replaced behavior was interpreting the input string
ignoring the invalid arguments.
2018-12-06 06:29:56 +00:00
christos 48875230b6 Allow being compiled as a tool. 2018-08-30 12:06:06 +00:00
martin 7dba0fd9ed PR standards/53525: move getsubopt to stdlib.h 2018-08-15 10:49:47 +00:00
maya 726d0d156a it's C18, not C17. 2018-07-27 15:15:30 +00:00
maya b91e8b8ee6 Claim C17 (although I'm unsure), add a note about C11's requirements. 2018-07-27 14:34:44 +00:00
maya 8d702a64ca C17 conformance: aligned_alloc's size doesn't need to be a multiple of
alignment any more.

Thanks Joseph Myers for the heads up.
2018-07-27 13:08:47 +00:00
kamil f34d1bdd0f Avoid undefined behavior in left bit shift in jemalloc(3)
Change the type of shifted value to unsigned to prevent altering the
signedness bit.

jemalloc.c:1707:14, left shift of 1 by 31 places cannot be represented in type 'int'
jemalloc.c:1724:15, left shift of 1 by 31 places cannot be represented in type 'int'
jemalloc.c:1840:28, left shift of 1 by 31 places cannot be represented in type 'int'

Detected with micro-UBSan in the user mode.
2018-07-25 20:05:35 +00:00
eadler 8ddc25ac24 libc: remove explicit cast NULL in atoi
There isn't any reason to cast NULL so just remove it. A similar change
was already made in DragonFly and FreeBSD (by me).

ok fly@
2018-06-13 09:38:32 +00:00
joerg 5b49b507f5 Simplify to avoid pointless null pointer arithmetic. 2018-05-23 21:21:27 +00:00
pgoyette 2829446e9d Fix typos, as reported by Eitan Adler. Update dates. 2018-02-07 11:16:05 +00:00
kamil b4e223d109 Revert namespacing of atoi(3)
Sanitizers can handle recursive interceptions in some / most cases, if they
will cause damage the problem will be not workaroundable without libc
changes - I will be back to it.

Keep namespace of asctime() as this can be a cancellation point according
to POSIX. Right now it's not implemented on NetBSD. Defer it for later.

Keep weak symbols and namespace for wait6(2) as this could be a
cancellation point as well. Defer this for later.

Sanitizers's [recursive] interceptors are a hack and moving one way or
another can cause new sets of problems. Recursive ones can be useful and
cause problems (on Linux there are known with with signal handlers).

Sponsored by <The NetBSD Foundation>
2018-01-07 15:28:33 +00:00
snj 9d37d7200a add strfmon_l man page links 2018-01-05 20:51:13 +00:00
kamil 763ed9e584 Register new weak symbol in libc for internal usage: atoi
The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

Add atoi to namespace.h.

Register a new __weak_alias() entry for atoi() in atoi.c.

atoi() is used internally in getrpcent(), rresvport_af(), ftok(), err(),
__llvm_profile_write_file(), llvm_gcda_start_file(), citrus_iconv_open(),
getprotoent_r(), __rpc_uaddr2taddr_af(), __res_nopt_rdata() and
servent_parseline().

This revision switches the internal usage to the internal symbol.

Sponsored by <The NetBSD Foundation>
2018-01-05 20:30:51 +00:00
kamil c5b83981a9 Add bunch of missing includes of namespace.h in libc
The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

This change eliminates usage of the global changes of the following symbols:
 - strlcat -> _strlcat
 - sysconf -> __sysconf
 - closedir -> _closedir
 - fparseln -> _fparseln
 - kill -> _kill
 - mkstemp -> _mkstemp
 - reallocarr -> _reallocarr
 - strcasecmp -> _strcasecmp
 - strncasecmp -> _strncasecmp
 - strptime -> _strptime
 - strtok_r -> _strtok_r
 - sysctl -> _sysctl
 - dlopen -> __dlopen
 - dlclose -> __dlclose
 - dlsym -> __dlsym

Sponsored by <The NetBSD Foundation>
2018-01-04 20:57:28 +00:00
kre 7fec48294c Fix obvious typo (cut&pasto or whatever) - there's only one value that
specifies the number of digits after the decimal point (oh, sorry, the
"radix character") the other specifies the number before...

While here, add a little more info on the effects of using the #n value.
2017-12-07 22:19:17 +00:00
mrg be18dbc420 normalise some indentation. NFC. 2017-12-01 22:47:06 +00:00
maya a1f7eefb77 use calloc rather than malloc + memset 0 2017-11-27 23:54:28 +00:00
christos 91729e7f3d Fix various bugs with strfmon:
- Avoid out of bounds access for the currency_symbol[3] when the symbol
  is shorter (as it happens with the C locale where it is empty)
- Don't compare pointers to NUL, it is not helpful.
- Make the default sep_by_space 1 as suggested in:
      https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_node/libc_111.html
- Use the correct number of bytes for memmove(3)

XXX: pullup-8
2017-11-27 22:43:07 +00:00
skrll f9ef5aa297 The HPPA architectures (1.1 and 2.0) both define quadruple-word (128-bit)
floating point types.  Adjust alignment to match.
2017-11-16 13:54:00 +00:00
joerg 27ef7ea778 Assert that __cxa_atexit is not used with NULL as DSO. Don't use
__cxa_atexit directly from atexit, they have different behavior.
2017-11-06 14:26:03 +00:00
kamil 3720ea4f1f Revert previous on demand.
Rationale:

The DSO handle is a required part of the (external) __cxa_atexit interface.
The atexit mapping is an implementation detail and not part of the public
interface. Doing it directly creates UB as it involves casting function
pointers between incompatible types.

  -- Joerg
2017-11-02 19:39:33 +00:00
kamil 5919a1817c Correct handling of __cxa_atexit(a,b,NULL) in libc
In the NetBSD implementation and suggested by Itanium C++ ABI, we wrap
the atexit(x) call as __cxa_atexit(x,NULL,NULL).

__cxa_atexit() is an internal function for the usage of C++.

Correct a bug that __cxa_atexit(x,y,NULL) is handled in the same way as
atexit(x) (which is simplified to __cxa_atexit(x,NULL,NULL).

This misbehavior has been detected in the Thread Sanitizer port to NetBSD.

Patch reviewed by <christos>

Sponsored by <The NetBSD Foundation>
2017-11-02 18:37:14 +00:00
abhinav 3996dac127 Add malloc.conf to the NAME section
Remove Pp before Bd at few places
2017-10-25 17:09:47 +00:00
christos 96a83291ba remove recallocarray 2017-10-07 21:15:48 +00:00
christos b7ac88e3e2 add recallocarray 2017-10-07 19:38:35 +00:00
kamil 043717d197 Correct the documentatin of ptsname_r(3)
This function returns "int" not "char *": errno on failure, 0 on success.
2017-09-09 12:28:19 +00:00
wiz 3384507177 Typo fix. 2017-08-16 17:41:36 +00:00
joerg 29f5b623d9 Add missing strfmon_l. Noticed by Bruno Haible. Add test case. 2017-08-16 13:53:19 +00:00
ginsbach bc29482829 PR lib/50316: Gracefully handle a zero number of members argument.
Taken from FreeBSD (which fixed this same issue long ago).

XXX: pullup-8
XXX: pullup-7
XXX: pullup-6
2017-08-12 01:10:04 +00:00
joerg 6138a69002 Drop TLS variant checks, emutls is enough for VAX and Sun2. 2017-07-14 19:24:52 +00:00
joerg e5678be828 Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.

If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.

Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
2017-07-11 15:21:31 +00:00
wiz 01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
christos 3ccc6b27b8 remove accidental __strong_alias additions, noticed by coypu. 2017-05-19 19:55:16 +00:00
christos 0a20cdb1cf use strerror_r_ss() 2017-05-19 19:51:10 +00:00
christos 1997642fee The BSD qsort() performs tail recursion elimination on the second
side of the array being partitioned to save on stack space.  Greater
savings can be gained by choosing recursion for the smaller side
of the partition and eliminating recursion for the larger side.
This also results in a small but measurable performance gain.
(From OpenBSD)
2017-05-19 19:48:19 +00:00
abhinav 06ea77a20c Clean up the NAME section.
The entries in the NAME section of these man pages have man pages of their
own, so it doesn't make sense to have their names here, instead they
should be just described in the body (similar to what we do in math(3) man page).

This also helps whatis(1) and apropos(1), as otherwise you would see multiple
results with the same name in the output, while there is actually only one page
with that name.

Good example is:

$ apropos -n 2 -M realloc
realloc (3)       general memory allocation operations
realloc (3)       general purpose memory allocation functions

The first line is there because memory(3) man page had realloc in its
NAME section. This commit will fix this issue.

ok wiz@
2017-04-26 07:40:09 +00:00
christos 4251f87df7 PR/51958: Ngie Cooper: ESRCH error description in hcreate(3) contains typo
for action
2017-02-07 22:25:25 +00:00
christos 794a9d5044 use getpagesize(3). 2017-01-13 04:18:54 +00:00
christos 8212adb6e3 Avoid sysconf: __sysconf -> sysctlgetmibinfo -> strtoimax -> locale, etc. 2017-01-12 02:00:42 +00:00
christos 227c2c0795 make this smaller. 2017-01-12 01:02:09 +00:00
abhinav adaa892a13 Fix typo 2016-12-17 06:17:16 +00:00
riastradh 263e13aeed Use the keywords `underflow' and `overflow' in ERANGE summary. 2016-11-07 21:52:36 +00:00
riastradh 95f4e015a9 Fix phrasing about `out-of-band' and `sentinel value'.
Either an out-of-band channel, or an in-band sentinel value, could
indicate an error, but an out-of-band sentinel value is a silly
proposition.

Noted by uwe@.
2016-11-07 21:51:42 +00:00
riastradh 2d9978a06e Update strtoul(3) example to reflect clarifications in strtol(3). 2016-11-05 20:57:31 +00:00
riastradh 02eab895ae Bump date for previous. 2016-11-04 20:19:58 +00:00
riastradh 59495a850c Tidy up the second example too. 2016-11-04 20:18:23 +00:00
riastradh 105424da40 Simplify error condition case.
Add assertions to reflect its implications.
2016-11-04 20:16:18 +00:00