Commit Graph

814 Commits

Author SHA1 Message Date
uwe b4852c3567 getopt_long(3): "index" is an argument, not a field. 2022-01-04 19:36:16 +00:00
uwe 868269f7b0 getopt_long(3): use NULL, not 0, for flag in the example. 2022-01-04 19:32:16 +00:00
uwe f139c7cd08 ptsname(3): fix equivalence example
The buffer is static, don't make it appear that we are returning a
pointer to a local variable.
2022-01-02 03:46:40 +00:00
rillig a1de340f77 jemalloc.3: fix malformed CVS Id 2021-12-05 14:25:04 +00:00
msaitoh 73b5f8505b s/supress/suppress/ 2021-12-05 08:09:30 +00:00
kre f3643917bc Add "--" 'options end' parameter to the sh -c call that runs the
command, so that the command cannot appear to be more options
(which always then fails, as there would be no arg for "-c" to
treat as the command string in that case).

For the full (LONG) explanation, see:
   http://mail-index.netbsd.org/current-users/2021/10/29/msg041629.html
2021-10-29 19:27:06 +00:00
nia 99f42ade26 reallocarr does not set errno. 2021-10-29 11:03:46 +00:00
nia 1aca51f7f5 radixsort(3): use reallocarr instead of malloc(x * y) 2021-10-29 10:29:51 +00:00
christos cd15afc9e3 Remove lint workarounds 2021-08-30 13:12:16 +00:00
andvar fbe76588ee fix typos in "environment" word. 2021-08-12 20:53:18 +00:00
christos c510facea2 Instead of compiling files with -fcommon, create an include file and declare
the 3 symbols that need to be common using an attribute. Put all the 3 symbol
definitions in libc in one place (initfini.c). Reviewed by joerg@
2021-04-20 21:42:31 +00:00
christos 02b62279a7 arrange for tools build 2021-02-26 19:25:12 +00:00
riastradh 14efb762fe Correct floating-point terminology.
Might want to harmonize the printf(3) and wprintf(3) descriptions of
`%a'.
2021-02-16 14:44:25 +00:00
joerg 8409cf4a20 Hook up proper fork lock handling for malloc:
- lock all relevant mutexes just before fork
- unlock all mutexes just after fork in the parent
- full reinit non-spinlocks in the child
This is not using the normal pthread_atfork interface to ensure order of
operation, malloc is used as implementation detail too often.
2020-05-15 14:37:21 +00:00
mrg e6631f7240 turn off TLS for mips on old jemalloc. it doesn't work. 2020-05-03 07:32:54 +00:00
rin 1d3b363c69 Use __mc68010__ to distinguish m68000 (sun2) from other m68k ports;
__mc68000__ is defined both for m68000 and m68k.
2020-04-22 08:48:12 +00:00
rin 45df14becf Fix previous for libhack, where _REENTRANT is not defined;
arenas_map_key is used only when NO_TLS && _REENTRANT.
2020-04-22 08:45:06 +00:00
joerg 880ddc3f7b Switch to using TLS in old jemalloc for everywhere but VAX and sun2. 2020-04-21 22:22:55 +00:00
kamil 21056e8a10 Change the previous cast from unsigned int to unsigned long
This code produces the same result and is consistent with the previous
lines. Only the least significant 16 bites (unsigned short) are meaningful.
2020-02-23 09:53:42 +00:00
kamil 6aee95b41f Avoid undefined behavior in the rand48(3) implementation
Instead of implicid promotion to signed int,
explicitly cast the arguments to unsigned int.

_rand48.c:53:27, signed integer overflow:
58989 * 58970 cannot be represented in type 'int'

_rand48.c:53:38, signed integer overflow:
-2093025904 + -1496809120 cannot be represented in type 'int'

_rand48.c:53:57, signed integer overflow:
57068 * 42787 cannot be represented in type 'int'

New and old code produce the same code as tested with:

#include <stdio.h>
#include <stdlib.h>

#define COUNT 1000 * 1000

int
main(void)
{
	FILE *fp;
        int i;

        fp = fopen("numbers.txt", "w+");
	if (!fp)
		abort();

        for(i = 0; i < COUNT; i++) {
                fprintf(fp, "%f\n", drand48());
                fprintf(fp, "%ld\n", lrand48());
                fprintf(fp, "%ld\n", mrand48());
        }

        fclose(fp);

        return 0;
}
2020-02-22 14:07:57 +00:00
kamil 57225a2ce5 Reorder words to fix grammar
Noted by <leot>
2020-02-22 13:20:21 +00:00
kamil 756b86e872 rand48: Document that short integers are unsigned 2020-02-22 11:56:13 +00:00
kamil 2bddf73745 Improve readability of __dorand48()
Break long lines into shorter instructions per line.

No Functional Change.
2020-02-22 11:24:47 +00:00
kamil e1278de2f9 Avoid NULL pointer arithmetics on environ
_env.c:260:9, pointer expression with base 0 overflowed to 0
_env.c:260:9, load of null pointer of type 'char *'
2020-02-22 10:05:12 +00:00
joerg 174eb28ace Fix atfork malloc handling to include all the locks in old jemalloc. 2020-01-13 19:14:37 +00:00
joerg 2de10fd665 Fix aarch64 definition in old jemalloc
There is no platform-specific reason for avoiding TLS. The tiny
allocations should be aligned the same as small allocations for ABI
reasons.
2020-01-13 19:14:02 +00:00
nros fe9bbf72d9 Fix manpage due to updated aligned_alloc behavior
Since aligned_alloc does not demand that size is to be multiple of alignment
anymore, don't make that claim in the man page.
2019-12-06 16:19:32 +00:00
sevan 7356612ea6 Document history
https://www.bell-labs.com/usr/dmr/www/man21.pdf
2019-09-01 19:37:21 +00:00
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