| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Add __cxa_thread_atexit(3) API implementation.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Let l64a() properly null terminate its result.
Though the buffer used by l64a() is initialized with null bytes,
repetetive calls may end up having trailing garbage of previous
invocations because we don't end up terminating the string.
Instead of importing NetBSD's fix, use this opportunity to simplify this
function dramatically, for example by just storing the Base64 character
set in a string. There is also no need to do the bitmasking, as we can
just use the proper integer type from <stdint.h>.
|
|
|
|
|
|
| |
Don't use fixup for C99 and up, the compiler result is already correct.
Suggested by: bde
|
|
|
|
|
| |
Reflect error indication according to POSIX and what those functions
currently do.
|
|
|
|
|
|
|
|
|
|
|
|
| |
1) Unifdef USE_WEAK_SEEDING since it is too obsolete to support and makes
reading hard.
2) Instead of doing range transformation in each and every function here,
do it single time directly in do_rand(). One "mod" operation overhead is not
a big deal, but the code looks nicer and possible future functions additions
or PRNG change do not miss range transformations neither have unneeded ones.
3) Use POSIX argument types for visible functions (cosmetic).
|
|
|
|
|
| |
can't be merged without conflicts and require merging of other versions
too and I don't want to go deep in that unmerged commits chain.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1) Unifdef USE_WEAK_SEEDING it is too obsolete to support and makes reading
harder.
2) ACM paper require seed to be in [1, 2^31-2] range, so use the same range
shifting as already done for rand(3). Also protect srandomdev() + TYPE_0 case
(non default) from negative seeds.
3) Don't check for valid "type" range in setstate(), it is always valid as
calculated. Instead add a check that rear pointer not exceeed end pointer.
MFC: r300965
Micro optimize: C standard guarantees that right shift for unsigned value
fills left bits with zero, and we have exact 32bit unsigned value
(uint32_t), so there is no reason to add "& 0x7fffffff" here.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1) POSIX prohibits printing errors to stderr here and require
returning NULL:
"Upon successful completion, initstate() and setstate() shall return a
pointer to the previous state array; otherwise, a null pointer shall
be returned.
Although some implementations of random() have written messages to
standard error, such implementations do not conform to POSIX.1-2008."
2) Move error detections earlier to prevent state modifying.
|
|
|
|
| |
Fix markup on "\n" in printf so it renders correctly.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
tdelete(3): don't delete the node we are about to return.
The original change, from NetBSD, was bogus; introduced a memory
leak and and broke POSIX. By reverting we actually match NetBSD's
latest revision.
This is a direct commit to 10 since this function was rewritten
in 11-current.
Reported by: Markiyan Kushnir
Obtained from: NetBSD (CVS rev. 1.7, 1.8)
|
|
|
|
|
|
|
|
|
|
| |
Switch libc from using _sig{procmask,action,suspend} symbols, which
are aliases for the syscall stubs and are plt-interposed, to the
libc-private aliases of internally interposed sigprocmask() etc.
MFC r287300:
Use libthr interposed functions instead of syscalls, in posix_spawn()'
child.
|
|
|
|
|
|
|
| |
tdelete(3): don't delete the node we are about to return.
CID: 272528
Obtained from: NetBSD (CVS rev. 1.4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(or loading a dso linked to libthr.so into process which was not
linked against threading library).
MFC r276630:
Remove interposing, fix malloc, reinstall signal handlers wrappers on
libthr load.
MFC r276681:
Avoid calling internal libc function through PLT or accessing data
though GOT.
MFC r277032:
Reduce the size of the interposing table and amount of
cancellation-handling code in the libthr.
MFC note:
r276646 ("do not erronously export 'openat' symbol from rtld") is not
applicable to stable/10 yet, since PATHFDS support was not merged.
|
|
|
|
|
|
| |
Fix quick_exit(3) manual page to match reality - the status was missing.
Sponsored by: The FreeBSD Foundation
|
|
|
|
|
|
| |
Minor style tweaks.
Obtained from: OpenBSD (CVS rev. 1.7)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix hdestroy() compliance issue.
The hcreate(3) implementation and related functions we inherited
from NetBSD used to free() the key value, something that is not
supported by the standard implementation.
This would cause a segmentation fault when attempting to run
the examples from the opengroup and linux manpages.
There is no need to bump the __FreeBSD_version as we have
always claimed XPG4.2 compliance but if some reference is
required, the bump for r269484 can be used.
Reference:
http://bugs.dragonflybsd.org/issues/1398
|
|
|
|
|
|
|
|
| |
libc/stdlib: Minor cleanups to code originating in NetBSD
Mostly ANSIfication and typos.
Obtained from: NetBSD
|
|
|
|
|
|
|
|
| |
strfmon: reduce unnecessary snprintf.
No need for the snprintf/asprintf dance; use fixed width formats.
Obtained from: NetBSD (CVS rev. 1.8)
|
| |
|
|
|
|
|
| |
Merge intermediate OpenBSD v1.25 changes (almost identical to ours)
to reduce diff and bump OpenBSD patch level to v1.26.
|
|
|
|
|
|
|
|
|
|
|
|
| |
getopt(3): recognize option:: as GNU extension for "optional options".
Also ANSIfy a function declaration.
While here update the OpenBSD patch level in getopt_long.c as we
already have the corresponding change.
Obtained from: NetBSD
MFC after: 2 weeks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
non-directories.
If realpath() is called on pathnames like "/dev/null/." or "/dev/null/..",
it should fail with [ENOTDIR]. Pathnames like "/dev/null/" already failed as
they should.
Also, put the check for non-directories after lstatting the previous
component instead of when the empty component (consecutive or trailing
slashes) is detected, saving an lstat() call and some lines of code.
PR: 82980
|
|
|
|
|
|
| |
Do not force to run atexit handlers, which text comes from a dso owning
the handle passed to __cxa_finalize() but which are registered by other
dso, when the process is inside exit(3).
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
That's particularly true when __setenv is called from __merge_environ.
MFC after: 4 days
|
| |
|
|
|
|
|
| |
srand() must be the same as srand(1); rand();
(yet one increment)
|
|
|
|
|
|
|
| |
to compensate back at the end incremented at the start internal
state.
MFC after: 2 weeks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3,
so follow suit to make comparison easier.
|
|
|
|
|
| |
NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3,
so follow suit to make comparison easier.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
PR: 178642
Reported by: Michael Galassi (michaelgalassi@gmail.com)
Approved by: sbruno (mentor)
MFC after: 1 week
|
|
|
|
|
|
| |
PR: 177025
Submitted by: Fernando <fernando.apesteguia@gmail.com>
Reviewed by: theraven
|
|
|
|
| |
Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail)
|
|
|
|
|
|
|
|
| |
source sysctl(KERN_ARND) and remove the fallback code.
Obtained from: OpenBSD
Reviewed by: secteam
MFC after: 1 month
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
ptsname may set errno, so avoid saving and restoring errno across the
function.
PR: standards/171572
|