Commit Graph

1764 Commits

Author SHA1 Message Date
nia 984ee458fe scandir(3) and alphasort(3) are part of POSIX-2008, so don't require
_NETBSD_SOURCE to use them.
2022-12-28 11:51:21 +00:00
wiz dd8db24513 put reallocarray() in the public namespace
reallocarray() will be part of the next POSIX release, see
https://austingroupbugs.net/view.php?id=1218

adapt an errno value to match POSIX expectations

As discussed on tech-userlevel
2022-10-28 09:43:58 +00:00
jschauma db13085398 correct tm_sec range to be [0-60]
The previous range introduced in time.h rev1.14 was supposed to account
for a mystical "double leap second", which ultimately never could exist
and was a mistaken interpretation from an early ISO C standard whereby
the possibility of two leap seconds within a year was erroneously
interpreted to mean that two leap seconds could occur at once.
2022-10-23 15:43:40 +00:00
nia c68ac3ce9c Remove hacky gcc2-specific alloca definition. 2022-10-05 12:09:07 +00:00
christos 5dd94c5e95 Add sincos{,f,l} from FreeBSD 2022-08-27 08:31:58 +00:00
christos 55b9c1e826 whitespace changes from tzcode2022a->tzcode2022b 2022-08-16 09:03:04 +00:00
wiz b3d52618d0 sched.h: keep __clone() visible under _NETBSD_SOURCE 2022-08-01 15:16:05 +00:00
wiz d7c5f8bdef sched.h: format comment to follow KNF
requested by thorpej@
2022-08-01 14:34:01 +00:00
wiz da31975915 sched.h: Linux documents clone and __clone as only available
when_GNU_SOURCE is defined - follow suit.

Ok martin@
2022-08-01 14:19:40 +00:00
riastradh 2b5e567d9c libc: Reintroduce getentropy.
This was introduced two years ago when the getrandom/getentropy API
question was still open, and removed because the discussion was
ongoing.  Now getentropy is more widely adopted and soon to be in
POSIX.  So reintroduce the symbol into libc since we'll be keeping it
anyway.  Discussion of details of the semantics, as interpreted by
NetBSD, is ongoing, but the symbol needs to get in before the
netbsd-10 branch.  The draft POSIX text is
(https://www.opengroup.org/austin/docs/austin_1110.pdf):

    SYNOPSIS
        #include <unistd.h>

        int getentropy(void *buffer, size_t length);

    DESCRIPTION
        The getentropy() function shall write length bytes of data
        starting at the location pointed to by buffer. The output
        shall be unpredictable high quality random data, generated by
        a cryptographically secure pseudo-random number
        generator. The maximum permitted value for the length
        argument is given by the {GETENTROPY_MAX} symbolic constant
        defined in <limits.h>.

    RETURN VALUES
        Upon successful completion, getentropy() shall return 0;
        otherwise, -1 shall be retunred and errno set to indicate the
        error.

    ERRORS
        The getentropy() function shall fail if:

        [EINVAL]        The value of length is greater than
                        {GETENTROPY_MAX}.

        The getentropy() function may fail if:

        [ENOSYS]        The system does not provide the necessary
                        source of entropy.

    RATIONALE
        The getentropy() function is not a cancellation point.

Minor changes from the previous introduction of getentropy into libc:

- Return EINVAL, not EIO, on buflen > 256.
- Define GETENTROPY_MAX in limits.h.

The declaration of getentropy in unistd.h and definition of
GETENTROPY_MAX in limits.h are currently conditional on
_NETBSD_SOURCE.  When the next revision of POSIX is finalized, we can
expose them also under _POSIX_C_SOURCE > 20yymmL as usual -- and this
can be done as a pullup without breaking existing compiled programs.
2022-05-31 13:42:58 +00:00
andvar 09fb17927e fix various typos in comments, mainly origional->original,
extened->extended, incomming->incoming.
2022-05-28 21:14:56 +00:00
andvar 9f981eec2a s/appropiate/appropriate/ in comments and readme file. 2022-05-20 21:31:24 +00:00
gutteridge 003e1c9a2d nameser_compat.h: simplify logic to determine byte order
There's really no need for all the complex #ifdefs present and, on top
of that, it didn't even work correctly for all NetBSD architectures.
Simply use endian.h and drop the rest. (Since there is no upstream for
this code anymore, there's no concern about complicating future merges,
either. This change is also consistent with what FreeBSD and OpenBSD
did years ago.)

Addresses PR toolchain/53880 (reported by maya@, originally encountered
by me on macppc when building a package that pulls in nameser_compat.h
before nameser.h by necessity -- necessity, that is, on another OS).
2022-04-21 04:03:54 +00:00
uwe 4dd5a4c03f err.h: dead once is dead enough
Per joerg's advice keep the __dead in front position as it is where
_Noreturn would go.
2022-01-06 00:16:47 +00:00
nros 3c1a792c55 Make fdopendir visible according to POSIX.1 spec. 2021-12-30 16:20:19 +00:00
andvar 6012d766dc fix various typos in comments and log messages. 2021-12-08 20:50:01 +00:00
christos 1c05296632 Commit the userland portion of the posix_spawn_chdir project by Piyush Sachdeva 2021-11-07 14:34:30 +00:00
christos 686d735712 Expose sigaltstack, stack_t and friends to Posix Issue 5 (200809L) References:
https://man7.org/linux/man-pages/man2/sigaltstack.2.html
https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaltstack.html
2021-11-02 20:12:25 +00:00
thorpej 02edde8aa3 Version the sigaction(2) libc wrapper. The new version uses the "siginfo"
trampoline exclusively, thus relegating "sigcontext"-style handlers (which
have not been documented for many years now) to the dustbin of the compat
library.
2021-11-01 05:53:45 +00:00
andvar 279d5541d3 fix typos in comments. 2021-10-15 22:32:28 +00:00
christos 292aad7505 Change the default for ACLs to be posix1e instead of nfsv4 to match FreeBSD.
Requested by chuq.
2021-09-18 03:05:19 +00:00
rillig f64856e518 stdio.h: remove outdated comment for vscanf
When these functions where added to stdio.h 1.72 on 2008-08-04, the
conditional included _NETBSD_SOURCE.

The additional condition was removed in stdio.h 1.99 from 2020-03-20,
but the comment was not updated.
2021-09-11 20:05:33 +00:00
rillig 0a201ba3c7 stdio.h: sync comment for struct __sFILE with reality
In stdio.h 1.1 from 1993-03-21, the struct had a member named _ub for
the ungetc buffer.  That member was repurposed in stdio.h 1.42 from
2001-12-07 in order to support wide characters.

Remove the reference to the 'WARNING above' since there is no such
warning and even when this comment was added in stdio.h 1.20 from
1998-02-02, there was none.
2021-09-11 19:05:06 +00:00
rillig fb6d4a2598 stdio.h: remove outdated comment about fpos_t
The 'fairly grotesque' from 1994-04-03 referred to the conditional
definition of the type fpos_t, using two different integer types that
both happened to be 64-bit.

When stdio was changed on 2012-01-22 to keep track of the mbstate, the
conditional type definition was removed and the comment no longer made
sense.
2021-09-11 18:38:25 +00:00
rillig 16f5958b18 stdio.h: fix typo in comment 2021-09-11 16:58:38 +00:00
rillig d27ba004df stdio.h: fix typo in comment 2021-09-11 08:34:24 +00:00
andvar f9faf20aef fix typos in comments, mainly s/extention/extension/ and s/sufficent/sufficient/ 2021-09-03 21:54:58 +00:00
gutteridge 41918f4298 utmpx.h: fix comment missed in r. 1.10 _NETBSD_SOURCE changes 2021-08-15 00:36:11 +00:00
andvar 6584ea569e fix various typos in compatibility, mainly in comments. 2021-08-09 20:49:08 +00:00
christos d9a86489f0 PR/56250: Michael Forney: mkstemp/mkdtemp not declared with
_POSIX_C_SOURCE=200809L
2021-07-03 14:07:13 +00:00
christos e2325e1f91 Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
2021-06-19 13:56:34 +00:00
christos f07a94a30a Default to check-names for safety. 2021-04-30 16:07:49 +00:00
christos cc8bab3745 - Replace REG_ENOSYS (unused) with REG_ILLSEQ.
- Add REG_GNU
2021-02-23 17:14:42 +00:00
kre 5cea56c875 Correct typo in previous. 2020-12-04 23:04:58 +00:00
christos fe1e39fb82 Add __null_sentinel 2020-12-04 20:39:10 +00:00
is 84206f8865 Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).
2020-11-18 12:49:52 +00:00
christos 3c56a67128 - remove bitypes.h fossil
- define u_{char,short,int,long} if we don't have _NETBSD_SOURCE defined
  so that this compiles (and resolv.h since it includes this). This is
  the simplest solution. Others:
  - always define them (bad, pollutes namespace)
  - create <sys/utypes.h> (bad, overkill)
  - change them to unsigned {char, short, int long} (bad, too disruptive)
2020-10-10 19:51:48 +00:00
christos c53d404f5e add set_rpc_maxgrouplist(3) 2020-10-03 18:30:39 +00:00
nia 796e3f7c10 remove getentropy bits 2020-09-22 21:37:47 +00:00
kamil 2ec95d7ade Remove duplicate word in a comment 2020-09-22 01:52:16 +00:00
kamil f3656ffa1a Upgrade the SVR4 RTLD r_debug protocol to version 1
Changes:
 - Add a new field r_ldbase in the r_debug struct.
 - Set r_version to 1.

This harmonizes the support with OpenBSD and Linux.
FreeBSD uses version 0 (or no version).
Solaris uses version 2 that is not implemented elsewhere and relies on
SVR4 specific design and interfaces.

Update the code comments as r_debug and link_map is used by other software
than GDB, namely: sanitizers, rump, LLDB.
2020-09-21 16:08:57 +00:00
kamil acc2f1f4bd Refine the documentation of r_debug
Obtained from OpenBSD link.h r.1.15.
2020-09-21 02:20:27 +00:00
mrg 032acb9ed8 make the 2nd argument to __memmove_chk() const 2020-09-05 13:37:59 +00:00
gutteridge 68466549b9 nameser_compat.h: correct preprocessor error syntax 2020-06-28 02:16:19 +00:00
nia dfa7a1ca44 Remove bogus tests for 64-bit i386 and SuperH 2020-06-04 11:21:16 +00:00
joerg 5262cf8ca3 Avoid depending on namespace pollution in stdlib.h. 2020-05-26 21:49:29 +00:00
christos 9aa2a9c323 Add ACL support for FFS. From FreeBSD. 2020-05-16 18:31:45 +00:00
joerg f11532c6b3 Remove trailing whitespace 2020-05-13 14:00:58 +00:00
nia 5e1fba1a1e Add getentropy() to libc - a simple wrapper to access the kernel CSPRNG.
Posted to tech-userlevel@ a week ago and reviewed by riastradh@.

GETENTROPY(3)		   Library Functions Manual		 GETENTROPY(3)

NAME
     getentropy - fill a buffer with high quality random data

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <unistd.h>

     int
     getentropy(void *buf, size_t buflen);

DESCRIPTION
     The getentropy() function fills a buffer with high quality random data,
     suitable for seeding cryptographically secure psuedorandom number
     generators.

     getentropy() is only intended for seeding random number generators and is
     not intended for use by regular code which simply needs secure random
     data.  For this purpose, please use arc4random(3).

     The maximum value for buflen is 256 bytes.

IMPLEMENTATION NOTES
     getentropy() reads from the sysctl(7) variable kern.arandom.

RETURN VALUES
     The getentropy() function returns 0 on success, and -1 if an error
     occurred.

ERRORS
     getentropy() will succeed unless:

     [EFAULT]		The buf argument points to an invalid memory address.

     [EIO]		Too many bytes were requested.

SEE ALSO
     arc4random(3), rnd(4)

STANDARDS
     The getentropy() function is non-standard.

HISTORY
     The getentropy() function first appeared in OpenBSD 5.6, then in
     FreeBSD 12.0, and NetBSD 10.
2020-05-06 16:17:36 +00:00
kamil 3e0acd5a41 Remove the static_assert() fallback for pre-C11 and pre-C++11
C++ without real static_assert() can be incompatible with the C fallback
as presented in openjdk.

A pre-C11 compiler can be picky on the implementation.
2020-04-17 15:22:34 +00:00