1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-04 23:35:36 -08:00
Commit Graph

78 Commits

Author SHA1 Message Date
guenther
dfc5f6fe81 mkostemp(3) and reallocarray(3) are in POSIX-2024:
adjust #include visibility and update the reallocarray(3) manpage

ok millert@
2024-08-03 20:09:24 +00:00
millert
1aa88f2b27 Add mkdtemps(3), like mkdtemp(3) but with a suffix.
OK deraadt@ tb@
2024-03-01 21:30:40 +00:00
otto
e03a31515f Inroduce malloc_conceal() and calloc_conceal(). Similar to their
counterparts but return memory in pages marked MAP_CONCEAL and on
free() freezero() is actually called.
2019-05-10 15:03:24 +00:00
otto
acb3f83f5f Introducing malloc_usable_size() was a mistake. While some other
libs have it, it is a function that is considered harmful, so:

Delete malloc_usable_size(). It is a function that blurs the line
between malloc managed memory and application managed memory and
exposes some of the internal workings of malloc.  If an application
relies on that, it is likely to break using another implementation
of malloc.  If you want usable size x, just allocate x bytes. ok
deraadt@ and other devs
2018-11-21 06:57:04 +00:00
otto
f5c5425b42 Implement malloc_usable_size(); ok millert@ deraadt@ and jmc@ for the man page 2018-11-18 16:15:18 +00:00
otto
7a9442eb01 Implement C11's aligned_alloc(3). ok guenther@ 2018-11-05 08:23:40 +00:00
schwarze
3a628b46e7 New POSIX xlocale implementation written from scratch.
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.

With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.
2017-09-05 03:16:13 +00:00
tom
c1664c6851 arc4random_buf should be bounded buffer, not bounded string
ok millert@
2017-05-11 11:52:18 +00:00
millert
6a20801c60 Add bounded attribute to freezero(). OK tom@ 2017-05-10 21:48:29 +00:00
otto
c0e0c2a5d0 Introducing freezero(3) a version of free that guarantees the process
no longer has access to the content of a memmory object. It does
this by either clearing (if the object memory remains cached) or
by calling munmap(2). ok millert@, deraadt@, guenther@
2017-04-10 05:45:02 +00:00
otto
14537fffc1 Introducing recallocarray(3), a blend of calloc(3) and reallocarray(3)
with the added feature that released memory is cleared. Much input from various
developers. ok deraadt@ tom@
2017-03-06 18:50:28 +00:00
fcambus
7742623a4c Remove duplicated includes in stdlib.h and termios.h
OK guenther@
2016-09-20 21:10:22 +00:00
millert
6ecde746de Move the 10 (!) defintions of NULL to their own mini header file and
update the NULL definition for C++11.  OK deraadt@ guenther@ kettenis@
2016-09-09 18:12:37 +00:00
millert
8fb4bdfc76 The first argument to devname(3) should be dev_t, not int.
The man page was already correct.
2015-07-14 19:05:11 +00:00
tedu
e58af03110 add restrict to strtol like functions. ok guenther 2015-02-08 02:58:50 +00:00
tedu
af4f502b8b we don't have an alloca() symbol anywhere in libc, don't prototype it.
instead, #define to __builtin_alloca. if that doesn't work, you're hosed.
from an old discussion about the perils of alloca. (don't use alloca!)
2015-01-15 19:55:58 +00:00
deraadt
f7510a6ece Change rand(), random(), drand48(), lrand48(), mrand48(), and srand48()
to returning strong random by default, source from arc4random(3).
Parameters to the seeding functions are ignored, and the subsystems remain
in strong random mode.  If you wish the standardized deterministic mode,
call srand_deterministic(), srandom_determistic(), srand48_deterministic(),
seed48_deterministic() or lcong48_deterministic() instead.
The re-entrant functions rand_r(), erand48(), nrand48(), jrand48() are
unaffected by this change and remain in deterministic mode (for now).

Verified as a good roadmap forward by auditing 8800 pieces of software.
Roughly 60 pieces of software will need adaptation to request the
deterministic mode.

Violates POSIX and C89, which violate best practice in this century.
ok guenther tedu millert
2014-12-08 21:45:19 +00:00
tedu
80dc78aa39 header changes for recent libc changes:
add siphash
delete setkey, encrypt, cfree
2014-12-08 20:39:56 +00:00
guenther
ed42a740c1 Add additional userland interfaces for setting close-on-exec on fds
when creating them: mkostemp(), mkostemps(), the 'e' mode letter for
fopen(), freopen(), fdopen(), and popen().  The close-on-exec flag will
be cleared by the action created by posix_spawn_file_actions_adddup2().

Also, add support for the C11 'x' mode letter for fopen() and freopen(),
setting O_EXCL when possibly creating files.

Note: this requires kernel support for pipe2() and dup3()!

ok millert@
2014-08-31 02:21:18 +00:00
beck
e5388d055a Clean up after arc4random u_int32_t uint32_t change
ok jsing@
2014-07-09 16:57:49 +00:00
tedu
7e25e286a3 change mallocarray to reallocarray. useful in a few more situations.
malloc can, as always, be emulated via realloc(NULL).
ok deraadt
2014-04-22 14:26:26 +00:00
deraadt
e1603b917b Introducing: void *mallocarray(size_t nmemb, size_t size);
Like calloc(), except without the cleared-memory gaurantee
ok beck guenther, discussed for more than a year...
2014-04-21 13:17:32 +00:00
martynas
0ad647d636 Annotate a few more bounded functions: realpath(3) needs a buffer
of size at least PATH_MAX.  pread(2), pwrite(2) and readlinkat(2)
also take the buffer and the bound.  OK theo.
2013-12-28 01:51:53 +00:00
millert
9a476230f2 Fix typo; 200809 not 20080 for __POSIX_VISIBLE. Noticed by jca@ 2013-12-13 20:48:39 +00:00
millert
6290d6dbce The getopt() prototype and externs don't belong in stdlib.h. Berkeley
moved them to unistd.h to match POSIX in 1995 but we never did.
The exception to this is getsubopt() which POSIX says should be in
stdlib.h.  The non-standard suboptarg extern remains in the BSD-only
section of stdlib.h.  Neither getsubopt() nor suboptarg belong in
unistd.h or getopt.h.  They were only there to allow us to protect
all the getopt() bits from being multiply defined.  OK guenther@
2013-11-22 21:32:49 +00:00
deraadt
e1968c998b Remove arc4random_stir() and arc4random_addrandom(), which none should
be using directly.  Well, a few rare people cloned it upstream and it
will take a bit of time for them to learn.
ok various
2013-10-21 20:33:23 +00:00
ajacoutot
c88a5da8d0 Add getprogname() and setprogname() to ease slackers^porters' work.
Man page adapted from FreeBSD and NetBSD.

Bump libc minor now (there will be more upcoming changes).

input from tedu@
get it in deraadt@
2013-05-31 20:59:23 +00:00
millert
8d2ec7ea7a Simple emulation of POSIX pty APIs posix_openpt(), ptsname(),
grantpt() and unlockpt() using /dev/ptm.  Man pages from FreeBSD.
OK kettenis@ deraadt@ beck@ ajacoutot@ naddy@
2012-12-03 20:08:33 +00:00
guenther
b10cd18816 Improve standards conformance: ecvt(), fcvt(), gcvt(), mktemp(), ttyslot(),
and valloc() are not in the current version, while posix_memalign() mkstemp(),
and mkdtemp() are, and setstate()'s argument has lost a bogus 'const'.

ok millert@ jmc@ espie@ kettenis@; ports build testing by naddy@
2012-06-01 01:01:57 +00:00
jsg
c4ff7bee63 As pointed out by Richard Guenther our definition
of NULL was incorrect for c++ compilers that aren't
gcc (or pretend to be gcc like clang).

ok miod@
2011-07-03 18:51:01 +00:00
miod
0c2a5da7f0 Define NULL as a void * instead of a long integer, as required by Single Unix.
Kernel and bootblocks still use the old 0L value until all the NULL abuses
in the code are fixed.
2011-04-06 11:39:42 +00:00
tedu
243f393511 add posix_madvise, posix_memalign, strndup, and strnlen. mostly from
brad and millert, with hints from guenther, jmc, and otto I think.
ok previous.
2010-05-18 22:24:54 +00:00
millert
471b62eeaa Make putenv(), setenv() and unsetenv() standards compliant. The
standard explicitly disallows passing setenv a name with a '=' in
it but historic BSD behavior is to allow this but to ignore the '='
and anything after it.
2009-06-03 15:52:16 +00:00
martynas
7b36286a70 - replace dtoa w/ David's gdtoa, version 2008-03-15
- provide proper dtoa locks
- use the real strtof implementation
- add strtold, __hdtoa, __hldtoa
- add %a/%A support
- don't lose precision in printf, don't round to double anymore
- implement extended-precision versions of libc functions: fpclassify,
isnan, isinf, signbit, isnormal, isfinite, now that the ieee.h is
fixed
- separate vax versions of strtof, and __hdtoa
- add complex math support.  added functions: cacos, casin, catan,
ccos, csin, ctan, cacosh, casinh, catanh, ccosh, csinh, ctanh, cexp,
clog, cabs, cpow, csqrt, carg, cimag, conj, cproj, creal, cacosf,
casinf, catanf, ccosf, csinf, ctanf, cacoshf, casinhf, catanhf,
ccoshf, csinhf, ctanhf, cexpf, clogf, cabsf, cpowf, csqrtf, cargf,
cimagf, conjf, cprojf, crealf
- add fdim, fmax, fmin
- add log2. (adapted implementation e_log.c.  could be more acruate
& faster, but it's good enough for now)
- remove wrappers & cruft in libm, supposed to work-around mistakes
in SVID, etc.;  use ieee versions.  fixes issues in python 2.6 for
djm@
- make _digittoint static
- proper definitions for i386, and amd64 in ieee.h
- sh, powerpc don't really have extended-precision
- add missing definitions for mips64 (quad), m{6,8}k (96-bit) float.h
for LDBL_*
- merge lead to frac for m{6,8}k, for gdtoa to work properly
- add FRAC*BITS & EXT_TO_ARRAY32 definitions in ieee.h, for hdtoa&ldtoa
to use
- add EXT_IMPLICIT_NBIT definition, which indicates implicit
normalization bit
- add regression tests for libc: fpclassify and printf
- arith.h & gd_qnan.h definitions
- update ieee.h: hppa doesn't have quad-precision, hppa64 does
- add missing prototypes to gdtoaimp
- on 64-bit platforms make sure gdtoa doesn't use a long when it
really wants an int
- etc., what i may have forgotten...
- bump libm major, due to removed&changed symbols
- no libc bump, since this is riding on djm's libc major crank from
a day ago

discussed with / requested by / testing theo, sthen@, djm@, jsg@,
merdely@, jsing@, tedu@, brad@, jakemsr@, and others.
looks good to millert@
parts of the diff ok kettenis@

this commit does not include:
- man page changes
2008-09-07 20:36:06 +00:00
otto
67821f6d28 remove recalloc; sloppy me; ok deraadt@ 2008-06-24 06:01:33 +00:00
ragge
57d1d82645 Remove obsolete (and erroneous) #if statement that caused all compilers
except for gcc to get the wrong prototype.  Ok millert@
2008-06-20 15:21:06 +00:00
landry
8f9e5b6355 Add strtof() to libc, some ports seem to like it. Currently it's a simple
call to strtod() with bounding check.
Discussed with pyr@ and otto@

ok otto@ deraadt@
2008-06-13 21:04:24 +00:00
otto
f7b5bfc7f0 diff from djm@ committed at his request:
introduce two new APIs for requesting strong random numbers:

arc4random_buf() - fill an arbitrary memory range with random numbers

arc4random_uniform() - return a uniformly distributed random number
below
a specified upper bound, avoiding the bias that comes from a naive
"arc4random() % upper_bound" construction.

these mirror similarly-named functions in the kernel;
lots of discussion deraadt@ mcbride@
2008-03-16 19:47:43 +00:00
millert
dce89cbd3f add recaloc(3) 2007-09-03 14:37:02 +00:00
djm
2994e40d19 add lldiv prototype; ok deraadt@ 2006-09-17 16:48:04 +00:00
deraadt
699654e463 after we changed mode_t to be an int, the devname() man page was
updated but the function itself never was; ok millert
2006-03-31 00:41:20 +00:00
millert
aa522acb77 Add lldiv(), imaxabs(), imaxdiv(), strtoimax() and strtoumax() 2006-01-13 17:58:09 +00:00
millert
c916d9484c Adapt things to use __type_t instead of _BSD_TYPE_T_
Add new sys/_types.h header
Include machine/_types.h or sys/_types.h where applicable
2006-01-06 18:53:04 +00:00
millert
52a0e6034e First step in include files overhaul. Use __FOO_VISIBLE (as defined
in sys/cdefs.h) instead of _FOO_SOURCE.  Also fix several namespace
pollution issues, including the byte order defines.  OK deraadt@
2005-12-13 00:35:22 +00:00
millert
06a573cfdc mktemp(3) et al. go in stdlib.h, not unistd.h. While there be more
explicit about mktemp(3) in the man page.
2005-05-27 17:45:56 +00:00
espie
561d433d11 major abi changes:
* introduce the mbstate_t typedef.
impacts gnu libiconv, which has already been taken care of.

* Prepare for mb stuff to really exist, replace macro MB_CUR_MAX with
an external variable __mb_cur_max (impacts libX11 and various ports).

* use mbstate in all the mb <-> wchar functions with state.
* add a stub iswctype function allowing some ports to compile.

bash and gdiff are missing wcscoll, and need to be told there's no i18n
until this is fixed.

Discussed and matthieu, otto, millert, kettenis, deraadt.

Major libc bump
2005-05-11 18:44:12 +00:00
millert
09085d3058 Update strtonum() protor 2004-08-03 19:59:42 +00:00
tedu
7d327e3ff7 strtonum prototype 2004-05-03 19:16:36 +00:00
millert
5f37d0e7de Add _Exit(3) as per C99. Discussed with espie@ some time ago. 2004-05-03 17:21:13 +00:00
millert
251550ccf3 Prototype llabs(3). Forgotten commit gathering bit rot in my tree... 2004-01-21 19:50:39 +00:00