Commit Graph

1656 Commits

Author SHA1 Message Date
kamil 6245abaafa Import wcsnlen(3) to libc
The wcsnlen(3) function conforms to POSIX.1-2008 and is an addition to the
ISO C standard.

size_t wcsnlen(const wchar_t *s, size_t maxlen);

The wcsnlen(3) function computes the number of wide-characters in a wide-
-string to which s points, not including NULL terminating wide-character
code and checking no more than maxlen wide-characters. This function never
examines wide-characters beyond a wide-string of maxlen size.


This function is a safer version of wcslen(3):

size_t wcslen(const wchar_t *s);


Update STANDARDS section of wmemchr(3) describing wide-character functions.
2016-10-15 14:21:59 +00:00
christos 12b4355e4e add strchrnull 2016-10-12 20:01:22 +00:00
kamil 7f4b5eb156 Add timespec_get(3) in <time.h> and enable unconditionally struct timespec
These changes conforms to the C11 standard
References:
 - 7.27.1/3 Components of time (struct timespec)
 - 7.27.2.5 The timespec_get function

According to ISO/IEC 9899:201x (draft) <time.h> defines the timespec
structure and declares the timespec_get(3) function with TIME_UTC
definition.

According to a C++17 standard draft <ctime> offers the same interface in
the std:: namespace.

The timespec_get function modifies the timespec object pointed by ts
to hold the current calendar time in the given base. The standard notes
only the TIME_UTC base with implementation defined value, set it to 1
as zero is reserved for error handling. Once operation was successful this
function returns passed base, otherwise exits with zero.

The timespec struct was already part of the POSIX standard in <time.h>.

Enable this interface unconditionally in the header to allow to use it
in a code prior C11 and C++17 as an extension.

Review notes from <christos>
2016-10-04 09:41:40 +00:00
kamil ba27f5b7d6 Add static_assert macro definition in <assert.h>
This declaration conforms to the C11 standard
Reference: ISO/IEC 9899:201x 7.2 Diagnostics <assert.h>

_Static_assert performs compile-time assertion checking.

According to ISO/IEC 9899:201x (draft) 7.2 Diagnostics <assert.h> defines
the static_assert macro which expands to _Static_assert. It's not
conditionalized by NDEBUG like the assert macro.

According to ISO/IEC N3242=11-0012 (C++1x) the <cassert> header shall
define only the assert macro, but not static_assert as it's already part
of the C++11 language.

Allow to define static_assert in C++ prior the C++11 standard. It might be
broken but a nonstandard C++ compiler might support C11-like _Static_assert
feature. Note that it's fatal for g++ 5.4, but it works for clang++ 3.8.1.

Approved by <joerg>.
2016-10-03 12:08:39 +00:00
kamil 7db6ba3b08 Import <stdalign.h>
This header conforms to the C11 standard
Reference: ISO/IEC 9899:201x 7.15 Alignment <stdalign.h>

According to ISO/IEC 9899:201x (draft) 7.15 Alignment <stdalign.h> defines
four macros:
 - alignas which expands to _Alignas
 - alignof which expands to _Alignof
 - __alignas_is_defined and __alignof_is_defined which both expand to 1

The _Alignas declaration appears as one of the type specifiers to modify
the alignment requirement of the object being declared.

The _Alignof operator is used to query the alignment requirement of its
operand type.

ISO/IEC N3242=11-0012 (C++1x) and ISO/IEC N3797 (C++1y) both note a header
<cstdalign> which defines only __alignas_is_defined and shall not define
the alignas macro. It misses the alignof case as it's probably based on an
older C1x draft, which defined only alignas. Assume that this is a bug in
the standard and treat alignof the same way as alignas in C++11.

Allow to define alignas and alignof in C++ prior the C++11 standard. It
might be broken but a nonstandard C++ compiler might support C11-like
_Alignas and _Alignof. Note that it's fatal for g++(1) v.5.4.
2016-10-02 17:19:00 +00:00
kamil 7798b8a775 Import <stdnoreturn.h>
This header conforms to the C11 standard
Reference: ISO/IEC 9899:201x 7.23 _Noreturn <stdnoreturn.h>

According to ISO/IEC 9899:201x (draft) <stdnoreturn.> defines the
noreturn macro which expands to _Noreturn.

The _Noreturn keyword appears in a function declaration and specifies
that the function does not return by reaching the end of the function
body.

Design choices:
 - don't implicitly break C++ code including this header with #error
   C++11 offers [[noreturn]] which conflicts with C11 _Noreturn

 - don't check for __STDC_VERSION__, everybody is free to reuse it with
   a nonstandard compiler not conforming to C11 but supporting _Noreturn

   gcc(1) and clang(1) support _Noreturn in -std=c99 and older standards

   this follows <stdbool.h> choice for not checking for C99

 - follow <stdbool.h> and declare the __noreturn_is_defined guard

 - use a standard header guard (_STDNORETURN_H_), similar to <stdbool.h>

Reviewed by <pgoyette> and <joerg>
2016-10-02 13:09:24 +00:00
christos 2b55b3112e remove mpool_getf 2016-09-24 21:18:09 +00:00
christos 0ac50079c4 sync with mit/kerberos db 2016-09-24 20:11:43 +00:00
roy 9fed1c5a9e Add ifa_addrflags to ifaddrs (forgot to commit this file, thanks Ryo!) 2016-09-21 13:32:27 +00:00
christos 40cfe4c8d2 add sh 2016-08-25 12:12:59 +00:00
christos 6aac56bef8 add alpha 2016-08-23 09:59:46 +00:00
christos c10c4abe0f Realtime signal support from GSoC 2016, Charles Cui. 2016-08-04 06:43:43 +00:00
njoly d1b4525986 According to Opengroup online specifications[1], _POSIX_CPUTIME and
_POSIX_THREAD_CPUTIME options should be present in unistd.h not
limits.h. Move them with other options.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html
2016-07-21 16:01:58 +00:00
christos d32f1d2f0f add hmac(3) 2016-07-01 22:42:01 +00:00
christos 4fda2f64e1 define block length 2016-07-01 16:42:46 +00:00
dholland ae3b3bcc2b PR 51287 Ralf Nolden: posix_fallocate belongs in <fcntl.h> 2016-06-30 15:29:20 +00:00
kamil e3d1905862 Use generic types in the profil(2) function prototype (<unistd.h>) 2016-06-18 14:39:15 +00:00
christos ea2913a0a2 GSoC 2016: Charles Cui: Add timer related macros
_POSIX_CPUTIME
    _POSIX_THREAD_CPUTIME
    _POSIX_DELAYTIMER_MAX
2016-06-10 23:29:20 +00:00
christos 0196f35dd1 GSoC 2016: Charles Cui: add SEM_NSEMS_MAX 2016-06-10 23:24:33 +00:00
joerg 5d45063308 Go back to just using normal visibility for the locale symbols. Without
an actual specifier like dllimport, protected visibility is unusable.
2016-04-29 16:26:48 +00:00
dholland 521eaa499b Define SEM_VALUE_MAX in only one place.
Adding a whole extra header file just for this is not the optimal
solution... but stuffing it in with anything else exposes things that
otherwise wouldn't be.

Nothing in userland should use <sys/semaphore.h> directly, and if some
foolish third-party software should decide to do so anyway in spite of
the instructions to the contrary I will ruthlessly break it later when
the big kernel includes cleanup finally happens.

Reported by Kamil Rytarowski, and, as it turns out, also by Klaus
Heinz in 2008.
2016-04-24 19:48:29 +00:00
christos ac892fb52b add clock_cpugetclockid{2,} 2016-04-23 23:10:10 +00:00
roy 6b9006e83c Implement pidfile_lock, pidfile_read and pidfile_clean.
Discussed on tech-net@, ok core@.
2016-04-10 19:05:50 +00:00
christos 618262a97a use foo - 0 instead of testing for defined(foo); from joerg@ 2016-03-20 16:26:06 +00:00
christos c07b0c6505 PR/50983: David Shao: Protect stddef;
also make the pointer void *.
2016-03-20 14:11:49 +00:00
christos 143f5307f7 disable dso protected for clang now, so that packages can be built.
(again this is the binutils warning about copy relocations on protected objects)
2016-03-17 17:36:32 +00:00
christos 8aeecea358 more casting fixes 2016-03-17 02:25:32 +00:00
christos ede51e408c gcc 5, my patience is waning. 2016-03-17 00:42:49 +00:00
christos 66e7b2616e appease gcc-5 |= #$@#% 2016-03-17 00:15:27 +00:00
mrg b298dc9162 add max_align_t. C11 defines this and GCC 5.3 really wants it.
XXX: language laywers, please feel free to fix this as necessary.
2016-03-17 00:03:38 +00:00
leot 2a4b16ea45 strndup() is part of XSI from The Open Group Base Specification Issue 7 and had
a similar history of stpcpy(), stpncpy() and strnlen().
Make it visible under XOPEN_SOURCE>=700 too (not just _NETBSD_SOURCE).

ok dholland@
2016-03-10 18:53:48 +00:00
christos 53a91c7008 - GC pts_fired, and fix the comment about MAX_TIMERS
- Bump MAX_TIMERS to 36 so that we have 32 POSIX user timers which is the
  minimum required.
2016-03-08 05:02:55 +00:00
christos 25f8e5a66f undo protected symbol hack. 2016-03-08 03:58:31 +00:00
christos 68cdf08b32 We only have 28 timers available. 2016-02-26 17:10:23 +00:00
christos 5641580370 Add relatime. 2016-02-21 22:45:25 +00:00
christos 8bdedb49af disable dso protected to work around binutils bug 2016-01-29 15:18:33 +00:00
dholland b030061971 Needs sys/select.h for fd_set; fails only when _POSIX_SOURCE is defined,
because then something else doesn't include it. (I guess.)
2016-01-23 02:36:57 +00:00
dholland 89050ca13e unsigned -> unsigned int in previous change to accomodate C++ boneheadedness. 2016-01-23 02:34:09 +00:00
dholland 398f572480 Apparently a recent round of vandalism by the C++ standards committee
includes disallowing the standard and historic type name "unsigned". Add
a gratuitous "int" to recent changes.

C++ is really a blight on the world.
2016-01-23 01:26:14 +00:00
dholland 29f79e71d2 u_int -> unsigned, u_long -> unsigned long, etc. 2016-01-23 01:05:30 +00:00
dholland e7633a3426 Needs sys/cdefs.h for __BEGIN_DECLS. Also add time.h to get time_t,
rather than doing the machine/ansi.h #ifdef dance, as it doesn't matter
much what symbols utmp.h exposes. This could be tightened later when we
manage to do enough include cleanup to make such dances less expensive
to maintain.
2016-01-22 23:59:44 +00:00
dholland b43a55ad4d Uses BEGIN_DECLS and needs sys/cdefs.h. 2016-01-22 23:23:13 +00:00
dholland e94e0027be Include <rpc/rpc.h> so XDR is defined. 2016-01-22 23:22:56 +00:00
dholland ff993d476d Needs sys/types.h for mode_t, off_t, ssize_t, and others. 2016-01-22 23:15:58 +00:00
dholland d151926dfa Needs stdint.h. 2016-01-22 23:15:42 +00:00
dholland 8724a4945a Erm, fix previous.
(also, as this protocol is externally defined it probably should use its
own constant and not either of these system-defined hostname lengths...)
2016-01-22 23:13:20 +00:00
dholland a8c9c98e22 These all need stdint.h.
Also, dumprestore.h needs ufs/ufs/dinode.h; in talkd.h use unsigned
char instead of u_char; and in timed.h include limits.h and use
_POSIX_HOST_NAME_MAX instead of MAXHOSTNAMELEN as the latter would
require sys/param.h.
2016-01-22 23:11:50 +00:00
dholland 33adcbb57f Needs stddef.h for size_t. 2016-01-22 22:27:01 +00:00
dholland 433257163a Has __BEGIN_DECLS, needs sys/types.h. 2016-01-22 22:26:45 +00:00
dholland 888c134026 u_char, u_int, u_long -> unsigned char, unsigned, unsigned long
This makes these headers work without _NETBSD_SOURCE.
2016-01-22 21:55:57 +00:00