Commit Graph

7641 Commits

Author SHA1 Message Date
Craig Rodrigues
9cebfb86a7 Clarify text to be consistent with nanosleep(2),
since sleep(3) is implemented in terms of nanosleep(2).

This is similar to the sleep(3) man page for Darwin.
2015-01-08 01:27:43 +00:00
Justin Hibbits
85eda151ff Avoid use of register variables. Clang 3.5 treats this as undefined behavior,
and bad things happen.

MFC after:	1 week
2015-01-06 03:50:43 +00:00
Konstantin Belousov
1a744fefc2 Avoid calling internal libc function through PLT or accessing data
though GOT, by staticizing and hiding.  Add setter for
__error_selector to hide it as well.

Suggested and reviewed by:	jilles
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-01-05 01:06:54 +00:00
Joel Dahl
f636caf195 mdoc: paragraph improvements. 2015-01-04 12:49:24 +00:00
Konstantin Belousov
8495e8b1e9 Fix known issues which blow up the process after dlopen("libthr.so")
(or loading a dso linked to libthr.so into process which was not
linked against threading library).

- Remove libthr interposers of the libc functions, including
  __error(). Instead, functions calls are indirected through the
  interposing table, similar to how pthread stubs in libc are already
  done.  Libc by default points either to syscall trampolines or to
  existing libc implementations.  On libthr load, libthr rewrites the
  pointers to the cancellable implementations already in libthr.  The
  interposition table is separate from pthreads stubs indirection
  table to not pull pthreads stubs into static binaries.

- Postpone the malloc(3) internal mutexes initialization until libthr
  is loaded.  This avoids recursion between calloc(3) and static
  pthread_mutex_t initialization.

- Reinstall signal handlers with wrapper on libthr load.  The
  _rtld_is_dlopened(3) is used to avoid useless calls to sigaction(2)
  when libthr is statically referenced from the main binary.

In the process, fix openat(2), swapcontext(2) and setcontext(2)
interposing.  The libc symbols were exported at different versions
than libthr interposers.  Export both libc and libthr versions from
libc now, with default set to the higher version from libthr.

Remove unused and disconnected swapcontext(3) userspace implementation
from libc/gen.

No objections from:	deischen
Tested by:	pho, antoine (exp-run) (previous versions)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-01-03 18:38:46 +00:00
Konstantin Belousov
0e521992a4 Add rtld private interface for dso to detect dynamic loading
vs. static linking.

Tested by:	pho, antoine (exp-run)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-01-03 18:09:53 +00:00
Jilles Tjoelker
d79f904ad2 Link lib/libc/c063 tests to the build.
Some files lack required #include <sys/stat.h>. The #ifdef is per ngie's
request; the includes are clearly necessary for struct stat.

The faccessat test fails because it tries to use AT_SYMLINK_NOFOLLOW with
faccessat(), which is not specified by POSIX.1-2008.

Differential Revision:	https://reviews.freebsd.org/D1411
Reviewed by:	ngie
2015-01-02 22:49:05 +00:00
Enji Cooper
97e4ab0905 Don't install h_raw if dealing with clang 3.5.0+ to unbreak the tests2 Jenkins
job

The h_raw application doesn't do proper bounds checking without the option
being supplied via the build, which means that it doesn't throw signals and
fail as expected

PR: 196430
X-MFC with: r276479
2015-01-02 05:40:02 +00:00
Joel Dahl
f7e00d4bbd mdoc: remove EOL whitespace. 2014-12-29 13:50:59 +00:00
Enji Cooper
70cf851cc5 Build/install lib/libc/tests/hash/t_sha2 if MK_OPENSSL == yes
Reported by: Beeblebrox <zaphod@berentweb.com>
2014-12-27 20:48:36 +00:00
Joel Dahl
4990a1c050 mdoc: improvements to SEE ALSO. 2014-12-27 08:31:52 +00:00
Christian Brueffer
0aee91e1fb Various mdoc fixes and a few EOL whitespace removals.
Found with:	mandoc -Tlint
2014-12-21 12:36:36 +00:00
Xin LI
cfbebadc60 Plug a memory leak.
Obtained from:	DragonFlyBSD (commit 5119ece)
MFC after:	2 weeks
2014-12-19 06:48:47 +00:00
Michael Tuexen
2b8a4d8033 Initilize the msg_flags field consistently in all code paths.
Reported by:	Coverity
CID:		1018726
2014-12-17 07:47:25 +00:00
Bryan Drewery
4bb90cbe18 Bump Dd for r275846
MFC after:	3 weeks
2014-12-17 01:36:00 +00:00
Kirk McKusick
27ae6f4af7 Add some additional clarification and fix a few gammer nits.
Reviewed by: kib
MFC after:   3 weeks
2014-12-17 01:32:27 +00:00
Konstantin Belousov
19eaed5353 Markup fixes for kqueue(2), no content changes.
Reviewed by:	brueffer (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2014-12-15 14:58:10 +00:00
Jun Kuriyama
d38b156d2e Fix incorrect type of "invalids" argument in __iconv() prototype. 2014-12-15 14:36:04 +00:00
Konstantin Belousov
237623b028 Add a facility for non-init process to declare itself the reaper of
the orphaned descendants.  Base of the API is modelled after the same
feature from the DragonFlyBSD.

Requested by:	bapt
Reviewed by:	jilles (previous version)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
2014-12-15 12:01:42 +00:00
Edward Tomasz Napierala
c6033229fc Fix quick_exit(3) manual page to match reality - the status was missing.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-12-13 21:13:28 +00:00
Michael Tuexen
0d958bd47a Fix a typo reported by Lennart Grahl.
MFC after: 3 days
2014-12-10 14:50:57 +00:00
Xin LI
805288c2f0 In r268924 __fflush was modified so that when write(2) was not successful,
_p and _w are adjusted to account for the partial write (if any).

However, _p and _w should not be unconditionally adjusted and should only
be changed when we actually wrote some bytes, or the accumulated accounting
error will eventually result in a heap buffer overflow.

Reported by:	adrian and alfred (Norse Corporation)
Security:	FreeBSD-SA-14:27.stdio
Security:	CVE-2014-8611
2014-12-10 08:18:22 +00:00
Andrew Turner
a215cdfdb0 Switch to the ARM unified assembly language as the clang integrated as only
supports it. Binutils supports it when the ".syntax unified" directive
is set.

Sponsored by:	ABT Systems Ltd
2014-11-29 15:56:52 +00:00
Ed Maste
d4287c3092 ANSIfy b64_pton 2014-11-27 02:15:35 +00:00
Xin LI
52e05d9a24 Reinstitate send() after syslogd restarts.
In r228193 the test of CONNPRIV have been moved to before the _usleep
and send in vsyslog().  When syslogd restarts, this would prevent the
message being logged after the disconnect/connect dance for
scenario #1.

PR:		194751
Submitted by:	Peter Creath <pjcreath+freebsd gmail com>
Reviewed By:	glebius
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D1227
2014-11-25 20:59:22 +00:00
Ed Maste
333cabbec5 Fix b64_pton output buffer overrun test for exact-sized buffer
b64_pton would sometimes erroneously fail to decode a base64 string into
a precisely sized buffer. The overflow check was a little too greedy.

Reported by:	Ted Unangst on freebsd-hackers@
Reviewed by:	loos, trasz
Obtained from:	OpenBSD
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1218
2014-11-25 18:39:37 +00:00
Sergey Kandaurov
ac071896d1 Fix ifa_data description.
PR:		176583
Discussed with:	glebius
MFC after:	1 week
Sponsored by:	Nginx, Inc.
2014-11-25 15:09:34 +00:00
Baptiste Daroussin
6b129086dc Convert libraries to use LIBADD
While here reduce a bit overlinking
2014-11-25 11:07:26 +00:00
Dag-Erling Smørgrav
83804ea074 The fallback flag in nsdispatch prevents the fallback implementation of
getgroupmembership() from invoking the correct backend in the compat case.
Replace it with a nesting depth counter so it only blocks one level (the
first is the group -> group_compat translation, the second is the actual
backend).  This is one of two bugs that break getgrouplist() in the compat
case, the second being that the backend's own getgroupmembership() method
is ignored.  Unfortunately, that is not easily fixable without a redesign
of our nss implementation (which is also needed to implement the +@group
syntax in /etc/passwd).

PR:		190055
MFC after:	1 week
2014-11-25 09:47:15 +00:00
Ed Maste
294246bb7d Revert r274772: it is not valid on MIPS
Reported by:	sbruno
2014-11-25 03:50:31 +00:00
Dimitry Andric
519195e820 For now, disable using -fsanitize=bounds for the libc ssp tests, when
using clang 3.5.0, until the runtime support (via compiler-rt) is added.
Otherwise, this would lead to link errors about missing support
libraries.
2014-11-24 20:07:09 +00:00
Baptiste Daroussin
2c900f1907 Ta is only allowed with Bl -column not in Bl -item 2014-11-23 23:35:16 +00:00
Joel Dahl
d4d112e34a Misc mdoc fixes:
- Remove superfluous paragraph macros.
- Remove/fix empty or incorrect macros.
- Sort sections into conventional order.
- Terminate quoted strings properly.
- Remove EOL whitespace.
2014-11-23 21:00:00 +00:00
Brooks Davis
1e7bf26b33 Add FPU support for MIPS setjmp(3)/longjmp(3).
This change saves/restores the callee-saved MIPS floating point
registers as documented by the o32/n32/n64 spec ("MIPSpro N32
ABI Handbook", Table 2-1) for the _setjmp(3), _longjmp(3),
setjmp(3) and longjmp(3) C library functions.  This is only
included when the C library is built with hardware floating point
support (or when "SOFTFLOAT" is not defined).

Submitted by:	sson
MFC after:	1 month
Sponsored by:	DARPA, AFRL
2014-11-21 20:02:06 +00:00
Ed Maste
688fd61ae8 Use canonical __PIC__ flag
It is automatically set when -fPIC is passed to the compiler.

Reviewed by:	dim, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1179
2014-11-21 02:05:48 +00:00
Edward Tomasz Napierala
c07b9c32f0 Remove acl_size.c; apparently it was never used.
PR:		194398
Submitted by:	ngie@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-11-19 19:43:39 +00:00
Simon J. Gerraty
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Enji Cooper
53cecec82e Convert tools/regression/lib/libc/stdio/test-fpclassify into an ATF testcase and
Rename as lib/libc/stdio/fpclassify2_test

Sponsored by: EMC / Isilon Storage Division
2014-11-16 20:29:57 +00:00
Enji Cooper
41a3b1244b Convert tools/regression/lib/libc/stdio/test-fmemopen into an ATF testcase and
rename as lib/libc/stdio/fmemopen2_test

Sponsored by: EMC / Isilon Storage Division
2014-11-16 19:57:47 +00:00
Enji Cooper
37074d966d Convert tools/regression/lib/libc/gen/test-arc4random into an ATF testcase and
rename as lib/libc/gen/arc4random_test

Sponsored by: EMC / Isilon Storage Division
2014-11-16 07:55:28 +00:00
Dmitry Chagin
186d9c3473 Add the ppoll() system call.
Export kern_poll() needed by an upcoming Linuxulator change.

Differential Revision:	https://reviews.freebsd.org/D1133
Reviewed by:	kib, wblock
MFC after:	1 month
2014-11-13 05:26:14 +00:00
Alexander V. Chernikov
603eaf792b Renove faith(4) and faithd(8) from base. It looks like industry
have chosen different (and more traditional) stateless/statuful
NAT64 as translation mechanism. Last non-trivial commits to both
faith(4) and faithd(8) happened more than 12 years ago, so I assume
it is time to drop RFC3142 in FreeBSD.

No objections from:	net@
2014-11-09 21:33:01 +00:00
Enji Cooper
2f1217877e Add reachover Makefiles for contrib/netbsd-tests/lib/libc; this adds approximately
500 new testcases

Various TODOs have been sprinkled around the Makefiles for items that even need
to be ported (missing features), testcases have issues with building/linking, or
issues at runtime.

A variant of this code has been tested extensively on amd64 and i386
10-STABLE/11-CURRENT for several months without issue. It builds on other
architectures, but the code will remain off until I have prove it works on
virtual hardware or real hardware on other architectures

In collaboration with: pho, Casey Peel <casey.peel@isilon.com>
Sponsored by: EMC / Isilon Storage Division
2014-11-04 00:56:25 +00:00
Dag-Erling Smørgrav
4b52e0d84f <sys/param.h> is a superset of <sys/types.h> and must always come
first.  Coincidentally, today is the 11th anniversary of this man
page's (and this bug's) first appearance in FreeBSD.

MFC after:	3 days
2014-11-01 09:10:21 +00:00
Edward Tomasz Napierala
62bf353355 Update acl(3) to expand on NFSv4 ACL support.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-30 10:56:38 +00:00
Edward Tomasz Napierala
02c55812ad Make it clear that ACL flags are NFSv4-only.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-30 10:49:50 +00:00
Kevin Lo
dbf11b2466 Fix prototypes. 2014-10-28 02:05:57 +00:00
Mark Johnston
20cc9ac42f getgrouplist(3) was reimplemented in terms of getgrent_r(3) in r174547, so
this bug is no longer valid.

MFC after:	3 days
2014-10-27 04:09:23 +00:00
Brooks Davis
052260fe0a Use the __DECONST macro rather than hand rolling the same thing.
Sponsored by:	DARPA, AFRL
2014-10-24 23:25:44 +00:00
Brooks Davis
e7254647bf Remove an unused variable that would be better spelled __func__.
Sponsored by:	DARPA, AFRL
2014-10-24 23:24:47 +00:00
Mark Johnston
f53b045631 Eliminate conf_lock and instead rely on the NSS write lock to protect
NSS configuration state.

As a side effect, this fixes a race condition which can occur if multiple
threads call nsdispatch(3) concurrently before nsswitch.conf has been
parsed. Previously, the thread holding conf_lock could cause other threads
to return from nss_configure() before nsswitch.conf had been parsed, forcing
them to fall back to the default sources for their NSS methods.

Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D994
MFC after:		1 month
Sponsored by:		EMC / Isilon Storage Division
2014-10-24 20:29:14 +00:00
John Baldwin
53e1ffbbce The current POSIX semaphore implementation stores the _has_waiters flag
in a separate word from the _count.  This does not permit both items to
be updated atomically in a portable manner.  As a result, sem_post()
must always perform a system call to safely clear _has_waiters.

This change removes the _has_waiters field and instead uses the high bit
of _count as the _has_waiters flag.  A new umtx object type (_usem2) and
two new umtx operations are added (SEM_WAIT2 and SEM_WAKE2) to implement
these semantics.  The older operations are still supported under the
COMPAT_FREEBSD9/10 options.  The POSIX semaphore API in libc has
been updated to use the new implementation.  Note that the new
implementation is not compatible with the previous implementation.
However, this only affects static binaries (which cannot be helped by
symbol versioning).  Binaries using a dynamic libc will continue to work
fine.  SEM_MAGIC has been bumped so that mismatched binaries will error
rather than corrupting a shared semaphore.  In addition, a padding field
has been added to sem_t so that it remains the same size.

Differential Revision:	https://reviews.freebsd.org/D961
Reported by:	adrian
Reviewed by:	kib, jilles (earlier version)
Sponsored by:	Norse
2014-10-24 20:02:44 +00:00
John Baldwin
15096da3f4 Don't reference sem(4) from the POSIX semaphore pages. POSIX semaphores
were reimplemented using umtx in FreeBSD 9 and no longer use sem(4).
2014-10-24 19:55:49 +00:00
Xin LI
d427f43c25 Remove duplicated code.
Suggested by:	jmg
2014-10-16 22:04:07 +00:00
Gavin Atkinson
ff8d5270bc Slightly improve grammar in EAGAIN description.
PR:		176806
Submitted by:	Jeremy Chadwick
MFC after:	3 days
2014-10-15 23:39:47 +00:00
Andrew Turner
cb8bcafa71 Add support for the __aeabi_c*cmp* functions. These are similar to the
existing functions with the exception they use the condition flags to
store the result.

Differential Revision:	https://reviews.freebsd.org/D872
Silence from:	current@ and numerics@
MFC after:	1 week
2014-10-14 14:27:51 +00:00
Xin LI
b888b86e6f accept(2) may and can return EAGAIN, document it.
MFC after:	1 week
2014-10-10 03:05:55 +00:00
Ed Maste
a6897b9320 Update dl_iterate_phdr(3) to follow r272842
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
2014-10-09 22:58:33 +00:00
Andrey A. Chernov
097c578c1e 1) Fix the case we have less arguments for format string than we expected.
2) Return error on unsupported format specs.
(both according to POSIX)

PR:     93197
2014-10-07 06:34:05 +00:00
Andrey A. Chernov
e15d3f3c09 Back out timegm error check from r272562.
POSIX treats negative time_t as undefined (i.e. may be valid too,
depends on system's policy we don't have) and we don't set EOVERFLOW
in mktime/timegm as POSIX requires to surely distinguish -1 return
as valid negative time from -1 as error return.
2014-10-07 06:02:08 +00:00
Xin LI
af1360206c Add MLINK for explicit_bzero(3) and bump .Dd date.
MFC after:	2 weeks
2014-10-07 04:59:11 +00:00
Xin LI
78b59024b5 Add explicit_bzero(3) and its kernel counterpart.
Obtained from:	OpenBSD
MFC after:	2 weeks
2014-10-07 04:54:11 +00:00
Andrey A. Chernov
420bc6cee4 1) For %Z format, understand "UTC" name too.
2) Return NULL if timegm() fails, because it means we can convert
what we have in GMT to local time needed.
2014-10-05 07:29:50 +00:00
Pedro F. Giffuni
79ec4cf466 Minor doc format fix.
Submitted by:	Yonghyeon PYUN
2014-10-04 18:00:15 +00:00
Pedro F. Giffuni
27d6eee170 strptime(3): Update manpage for %U and %W.
%U and %W were implemented as part of r272273 so take them
out of the BUGS section and mention them in the SYNOPSIS.

MFC after:	1 month
2014-10-02 18:52:29 +00:00
Pedro F. Giffuni
eff6f4441a strptime: %s format fix.
Almost never needed in real life because %s is tends to be
only one format spec.
1) Return code of gmtime_r() is checked.
2) All flags are set.

Submitted by:	ache
MFC after:	3 weeks
2014-10-02 18:33:58 +00:00
Pedro F. Giffuni
1a6804c649 strptime: fix bug introduced in r272273.
Reported by:	portmgr (antoine)
Fix by:		Andrey Chernov, David Carlier
PR:		137307 (follow up)
2014-10-01 22:18:07 +00:00
Andrew Turner
eabf853d8d Clean up detection of hard-float ABIs. As with big-endian in r272368 we
can check against arm*hf*.
2014-10-01 16:08:19 +00:00
Baptiste Daroussin
ad9bbe9854 Ensure that every ENTRY(foo) has a matching END(foo).
It allows to build with newer binutils

Differential Revision:	https://reviews.freebsd.org/D877
Reviewed by:	jhibbits
2014-10-01 15:00:21 +00:00
Andrew Turner
6d4766c1b8 Remove MK_ARM_EABI, the armeb issues have been fixed. The code to support
the oabi is still in the tree, but it is expected this will be removed
as developers work on surrounding code.

With this commit the ARM EABI is the only supported supported ABI by
FreeBSD on ARMa 32-bit processors.

X-MFC after:	never
Relnotes:	yes
Differential Revision: https://reviews.freebsd.org/D876
2014-10-01 08:26:51 +00:00
Bryan Drewery
c1efb88730 Document [EPERM] for UNIX sockets.
MFC after:	2 weeks
2014-09-30 00:06:53 +00:00
Pedro F. Giffuni
2e46558755 Add strptime(3) support for %U and %W (take 2)
Add support for the missing POSIX-2001 %U and %W features: the
existing FreeBSD strptime code recognizes both directives and
validates that the week number lies in the permitted range,
but then simply discards the value.

Initial support for the feature was written by Paul Green.
David Carlier added the initial handling of tm_wday/tm_yday.
Major credit goes to Andrey Chernov for detecting much of the
brokenness, and rewriting/cleaning most of the code, making it
much more robust.

Tested independently with the strptime test from the GNU C
library.

PR:		137307
MFC after:	1 month
Relnotes:	yes
2014-09-28 21:20:20 +00:00
Pedro F. Giffuni
c1cd488caf Revert r272122
The patch still needs to be more robust and it broke the
build on MIPS so revert it for now while all the issues
are fixed.

Reported by:	ache, davide
PR:		137307
2014-09-25 23:04:37 +00:00
Pedro F. Giffuni
ce1d331eee Add strptime(3) support for %U and %W
Add support for the missing POSIX-2001 %U and %W features: the
existing  FreeBSD strptime code recognizes both directives and
validates that the week number lies in the permitted range,
but then simply discards the value.

Initial support for the feature was written by Paul Green with
important fixes by Andrey Chernov. Additional support for
handling tm_wday/tm_yday was written by David Carlier.

PR:		137307
MFC after:	1 month
2014-09-25 18:52:17 +00:00
Will Andrews
76479f1d3f Fix incremental builds involving non-root users with read-only source files.
Makefiles should not assume that source files can be overwritten.  This is the
common case for Perforce source trees.

This is a followup commit to r211243 in the same vein.

MFC after:	1 month
Sponsored by:	Spectra Logic
MFSpectraBSD:	r1036319 on 2014/01/29, r1046711 on 2014/03/06
2014-09-18 14:41:57 +00:00
Bryan Drewery
7eccb93c02 Explicitly set MAP_PRIVATE to avoid [EINVAL] after r271635.
X-MFC-With:	r271635
Reviewed by:	jhb
2014-09-17 20:26:27 +00:00
John Baldwin
7a9f047ba7 - Remove mention of MAP_INHERIT. It hasn't been implemented for thirteen
years.
- Remove mention of unimplemented MAP_SWAP.  There are no future plans to
  implement it.

Submitted by:	alc (2)
2014-09-17 19:45:34 +00:00
Enji Cooper
2bcdab32c3 Bump .Dd for the content change done to access(2) in r271655
PR: 181155
Sponsored by: EMC / Isilon Storage Division
2014-09-16 00:59:08 +00:00
Enji Cooper
257597a434 Validate the mode argument in access, eaccess, and faccessat for optional
POSIX compliance and to improve compatibility with Linux and NetBSD

The issue was identified with lib/libc/sys/t_access:access_inval from
NetBSD

Update the manpage accordingly

PR: 181155
Reviewed by: jilles (code), jmmv (code), wblock (manpage), wollman (code)
MFC after: 4 weeks
Phabric: D678 (code), D786 (manpage)
Sponsored by: EMC / Isilon Storage Division
2014-09-16 00:56:47 +00:00
John-Mark Gurney
e2cc4003e2 document mqueuefs is required for mq_open... 2014-09-15 22:32:35 +00:00
John Baldwin
5fd3f8b3b6 Add stricter checking of some mmap() arguments:
- Fail with EINVAL if an invalid protection mask is passed to mmap().
- Fail with EINVAL if an unknown flag is passed to mmap().
- Fail with EINVAL if both MAP_PRIVATE and MAP_SHARED are passed to mmap().
- Require one of either MAP_PRIVATE or MAP_SHARED for non-anonymous
  mappings.

Reviewed by:	alc, kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D698
2014-09-15 17:20:13 +00:00
Joel Dahl
cfaa96f327 Minor mdoc nit. 2014-09-09 14:34:54 +00:00
Andrew Turner
954c837259 Add the fp{get,set}{mask,round} functions to the public symbols in the map.
These are only exported for armv6hf as the soft-float ABIs have these in
the softfloat Symbol.map file.
2014-09-05 18:11:36 +00:00
Pedro F. Giffuni
9908eab82e libc/locale: Remove a wrong comma.
This only had some effect when debugging.

Obtained from:	DragonflyBSD
MFC after:	3 days
2014-09-04 17:36:21 +00:00
John Baldwin
c3d1e48a6b Always seek back to the beginning of a regular directory, even if the
previous seek location was 0.  Without this, readdir() would see
dd_loc of zero and call getdirentries() which would start reading
entries at the current seek location of the directory ignoring the
first batch of entries.  Also, rewinddir() should always seek so that
it reads the directory from the beginning to get updated entries.

PR:		192935
Reported by:	iron@mail.ua
MFC after:	3 days
2014-09-03 19:01:34 +00:00
Pedro F. Giffuni
f4189cd649 Add bsearch_b to the libc map and the stdlib header.
bsearch_b is the Apple blocks enabled version of bsearch(3).
This was added to libc in Revision 264042 but the commit
missed the declaration required to make use of it.

While here move some other block-related functions to the
BSD_VISIBLE block as these are non-standard.

Phabric:	D638
Reviewed by:	theraven, wollman
2014-09-01 22:25:42 +00:00
Ian Lepore
f2e71517e0 In ARM asm code, ensure that every ENTRY(foo) has a matching END(foo).
The EABI unwind info requires a .fnend for every .fnstart, and newer
binutils will complain about seeing two .fnstart in a row.  This change
allows newer tools to compile our code.

Reported by:	bapt
Reviewed by:	imp
2014-08-31 17:21:51 +00:00
Enji Cooper
3303bfc042 Fix "make checkdpadd" for lib/libc when MK_SSP != no
Add LIBSSP_NONSHARED to bsd.libnames.mk and append LIBSSP_NONSHARED to DPADD in
lib/libc when MK_SSP != no

Approved by: rpaulo (mentor)
MFC after: 3 days
Phabric: D675 (as part of a larger diff)
PR: 192728
2014-08-25 06:10:03 +00:00
Pedro F. Giffuni
6804aa1b68 Add missing break.
CID:	603368
2014-08-20 14:58:25 +00:00
Simon J. Gerraty
ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Warner Losh
161fedb9cc From https://sourceware.org/ml/newlib/2014/msg00113.html
By Richard Earnshaw at ARM
>
>GCC has for a number of years provides a set of pre-defined macros for
>use with determining the ISA and features of the target during
>pre-processing.  However, the design was always somewhat cumbersome in
>that each new architecture revision created a new define and then
>removed the previous one.  This meant that it was necessary to keep
>updating the support code simply to recognise a new architecture being
>added.
>
>The ACLE specification (ARM C Language Extentions)
>(http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.set.swdev/index.html)
>provides a much more suitable interface and GCC has supported this
>since gcc-4.8.
>
>This patch makes use of the ACLE pre-defines to map to the internal
>feature definitions.  To support older versions of GCC a compatibility
>header is provided that maps the traditional pre-defines onto the new
>ACLE ones.

Stop using __FreeBSD_ARCH_armv6__ and switch to __ARM_ARCH >= 6 in the
couple of places in tree. clang already implements ACLE. Add a define
that says we implement version 1.1, even though the implementation
isn't quite complete.
2014-08-14 04:20:13 +00:00
Michael Tuexen
f0396ad15e Add support for the SCTP_PR_STREAM_STATUS and SCTP_PR_ASSOC_STATUS
socket options. This includes managing the correspoing stat counters.
Add the SCTP_DETAILED_STR_STATS kernel option to control per policy
counters on every stream. The default is off and only an aggregated
counter is available. This is sufficient for the RTCWeb usecase.

MFC after: 1 week
2014-08-13 15:50:16 +00:00
Sergey Kandaurov
196d2103e6 Fixed ENOMEM description.
MFC after:	1 week
Sponsored by:	Nginx, Inc.
2014-08-13 14:49:51 +00:00
Pedro F. Giffuni
ef01caf5cb Minor style tweaks.
Obtained from:	OpenBSD (CVS rev. 1.7)
MFC after:	3 days
2014-08-13 03:44:30 +00:00
Hajimu UMEMOTO
c397297cfe Fix broken pointer overflow check ns_name_unpack()
Many compilers may optimize away the overflow check `msg + l < msg',
where `msg' is a pointer and `l' is an integer, because pointer
overflow is undefined behavior in C.

Use a safe precondition test `l >= eom - msg' instead.

Reference:
https://android-review.googlesource.com/#/c/50570/

Requested by:	pfg
Obtained from:	NetBSD (CVS rev. 1.10)
2014-08-12 13:09:32 +00:00
Hajimu UMEMOTO
e45764721a Update our stub resolver to final version of libbind.
Obtained from:	ISC
2014-08-12 12:36:06 +00:00
Hajimu UMEMOTO
6f79a95b36 Bring the md5 functions into libc for internal use only.
It is required to support ID randomization for our stub
resolver.
2014-08-12 12:25:56 +00:00
Michael Tuexen
c79bec9c75 Add support for the SCTP_AUTH_SUPPORTED and SCTP_ASCONF_SUPPORTED
socket options. Add also a sysctl to control the support of ASCONF.

MFC after: 1 week
2014-08-12 11:30:16 +00:00
Hajimu UMEMOTO
08d41c70c1 We don't use these files. 2014-08-10 15:21:26 +00:00
Pedro F. Giffuni
905dd80f80 Const-ify character string
Obtained from:  Apple Inc. (Libc 997.90.3)
MFC after:	3 days
2014-08-07 22:14:37 +00:00
Pedro F. Giffuni
a46361116a Fix broken pointer overflow check ns_name_unpack()
Many compilers may optimize away the overflow check `msg + l < msg',
where `msg' is a pointer and `l' is an integer, because pointer
overflow is undefined behavior in C.

Use a safe precondition test `l >= eom - msg' instead.

Reference:
https://android-review.googlesource.com/#/c/50570/

Obtained from:	NetBSD (CVS rev. 1.10)
MFC after:	3 weeks
2014-08-07 16:40:24 +00:00
Pedro F. Giffuni
046c3635cd Bring final version of libbind:
From
http://www.isc.org/downloads/libbind/

The libbind functions have been separated from the BIND suite as of BIND
9.6.0. Originally from older versions of BIND, they have been continually
maintained and improved but not installed by default with BIND 9. This
standard resolver library contains the same historical functions and
headers included with many Unix operating systems. In fact, most
implementations are based on the same original code.

At present, NetBSD maintains libbind code, now known as "netresolv".
2014-08-05 23:16:31 +00:00
John-Mark Gurney
8029eb754a fix misordering...
Obtained from:	gjb
MFC after:	1 week
2014-08-04 21:12:38 +00:00
John-Mark Gurney
9c0b8e489d add xrefs for the other functions...
There should be more text in this page talking about each of these links,
but at least people know about them now...

MFC after:	1 week
2014-08-04 20:58:59 +00:00
Michael Tuexen
317e00ef86 Add support for the SCTP_RECONFIG_SUPPORTED and the corresponding
sysctl controlling the negotiation of the RE-CONFIG extension.

MFC after: 3 days
2014-08-04 20:07:35 +00:00
Michael Tuexen
cb9b8e6f7d Add support for the SCTP_PKTDROP_SUPPORTED socket option and
the corresponding sysctl variable.
The default is off, since the specification is not an RFC yet.

MFC after: 1 week
2014-08-03 18:12:55 +00:00
Michael Tuexen
caea98793f Add SCTP socket option SCTP_NRSACK_SUPPORTED to control the
NRSACK extension. The default will still be off, since it
it not an RFC (yet).
Changing the sysctl name will be in a separate commit.

MFC after: 1 week
2014-08-03 14:10:10 +00:00
Michael Tuexen
dd973b0e15 Add support for the SCTP_PR_SUPPORTED socket option as specified in
http://tools.ietf.org/html/draft-ietf-tsvwg-sctp-prpolicies
Add also a sysctl controlling the default of the end-points.

MFC after: 1 week
2014-08-02 21:36:40 +00:00
Michael Tuexen
f342355a0e Cleanup the ECN configuration handling and provide an SCTP socket
option for controlling ECN on future associations and get the
status on current associations.
A simialar pattern will be used for controlling SCTP extensions in
upcoming commits.
2014-08-02 17:35:13 +00:00
Nick Hibma
500e59c62d Fix the example: free the memory that was allocated by getline(). 2014-07-31 08:28:42 +00:00
John Baldwin
18ae4fcc47 If telldir() is called immediately after a call to seekdir(), POSIX
requires the return value of telldir() to equal the value passed to
seekdir().  The current seekdir code with SINGLEUSE enabled breaks
this case as each call to telldir() allocates a new cookie.  Instead,
remove the SINGLEUSE code and change telldir() to look for an existing
cookie for the directory's current location rather than always creating
a new cookie.

CR:		https://phabric.freebsd.org/D490
PR:		121656
Reviewed by:	jilles
MFC after:	1 week
2014-07-29 00:16:33 +00:00
Pedro F. Giffuni
e66c50c738 strftime() xlocale cleanups.
Replace fprintf_l with fputs when output is unformatted.
Use locale_t in _conv() since it was using sprintf (now sprintf_l)
Use locale_t on _yconv() sinci it calls _conv()

Obtained from:	Apple Inc. (Libc 997.90.3)
CR:		D482
Reviewed by:	theraven
MFC after:	1 week
2014-07-26 14:24:13 +00:00
Andrey A. Chernov
7922e2bb77 In the "Too many open files" edge cases don't try to preserve old
number for non-std* descriptors, but close old file and retry.

Obtained from:  inspired by Apple's change from pfg@
MFC after:      2 weeks
2014-07-26 08:41:03 +00:00
John Baldwin
0708297e43 POSIX says that passing a location returned by telldir() to seekdir()
after an intervening call to rewinddir() is undefined, so reclaim any
pending telldir() cookies in the directory when rewinddir() is called.

CR:		D459
Reviewed by:	jilles
MFC after:	1 week
2014-07-24 20:44:30 +00:00
Pedro F. Giffuni
86727cc9c6 Avoid possible cast degradation.
For consistency with r268985 for fputs.c, assign iov_len
first, avoiding the cast to uio_resid (int in stdio)
from degrading the value.

We currently don't support lengths higher than INT_MAX so
this change is little more than cosmetic.

MFC after:	3 days
2014-07-22 23:29:54 +00:00
Andrey A. Chernov
ecf84bf00a For "a"-mode files and rewind/fseek + fwrite combination return meaningful
value now, like Apple does, but avoid their __sflush physical write
performance degradation as much as possible.
2014-07-22 22:49:37 +00:00
Andrey A. Chernov
4099894921 Back the whole change out until I figure out how to obtain O_APPEND,
it can't be used in this field at all.
2014-07-22 20:13:46 +00:00
Andrey A. Chernov
44575f7350 Checking for __SAPP alone is not enough because it is emulated O_APPEND
only, so works for only special fdopen() case. Add real O_APPEND too.
2014-07-22 19:55:25 +00:00
Pedro F. Giffuni
a333236e63 Revert r268984:
Check for __SAPP flag before calling sflush.   This avoids
performance degradation compared to the previous approach.

Submitted by:	ache
MFC after:	2 weeks
2014-07-22 18:37:59 +00:00
Pedro F. Giffuni
6393bfdac8 Mostly cosmetic cleanups.
In fputs() avoid implcit casting on iov.iov_len.

MFC after:	3 days
2014-07-22 16:39:11 +00:00
Pedro F. Giffuni
4a4e32a81d ftello: return 1 when seeking offset on an append stream.
Obtained from:	Apple Inc. (Libc 997.90.3)
Phabric:	D442
MFC after:	2 weeks
2014-07-22 16:19:01 +00:00
Pedro F. Giffuni
c03225695d rewind: always clear error indicator.
Required by POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/functions/rewind.html

Obtained from:	Apple Inc. (Libc 997.90.3)
MFC after:	1 week
2014-07-22 16:10:56 +00:00
Pedro F. Giffuni
e19f362e28 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.  NetBSD
has added non-standard calls to provide the previous
behaviour but hdestroy is not very commonly used so at this
time it seems excessive to bring those to FreeBSD.

Bump the __FreeBSD_version as this is an ABI change.

Reference:
http://bugs.dragonflybsd.org/issues/1398

MFC after:	2 weeks
2014-07-21 15:44:59 +00:00
Pedro F. Giffuni
47ccc0c84f Update license.
NetBSD has removed the advertisement clause from this file.

Obtained from:	NetBSD (CVS rev. 1,8)
2014-07-21 15:26:52 +00:00
Pedro F. Giffuni
9823a90c79 Add re-entrant versions of the hash functions based on the GNU api.
While testing this I found a conformance issue in hdestroy()
that will be fixed in a subsequent commit.

Obtained from:	NetBSD (hcreate.c, CVS Rev. 1.7)
2014-07-21 15:22:48 +00:00
Pedro F. Giffuni
450ead8668 Adjust errno on failed prepwrite.
Obtained from:	Apple Inc. (Libc 997.90.3)
Phabric:	D442
MFC after:	1 week
2014-07-20 21:24:29 +00:00
Pedro F. Giffuni
7ebc2c26a2 Const-ify a character string.
Obtained from:	Apple Inc. (Libc 997.90.3)
MFC after:	3 days
2014-07-20 20:29:28 +00:00
Pedro F. Giffuni
120d6dd50d Use a correct errno in freopen.
Use EBADF instead of EINVAL when working around incorrect O_ACCMODE.

Phabric:	D442
Obtained from:	Apple Inc. (Libc 997.90.3)
Reviewed by:	jilles
MFC after:	1 week
2014-07-20 20:14:15 +00:00
Pedro F. Giffuni
05c9304f58 Update fflush(3) to return success on a read-only stream.
This has small changes to what Apple uses for compliance
with SUSv3. The changes cause no secondary effects in the
gnulib tests (we pass them).

Obtained from:	Apple Inc. (Libc 997.90.3 with changes)
Reviewed by:	bde
Phabric:	D440
2014-07-20 20:05:39 +00:00
Ian Lepore
677a88cec2 Add dl_unwind_find_exidx() for ARM EABI, required for C++ exception
handling.  For statically linked apps this uses the __exidx_start/end
symbols set up by the linker.  For dynamically linked apps it finds the
shared object that contains the given address and returns the location and
size of the exidx section in that shared object.

The dl_unwind_find_exidx() name is used by other BSD projects and Android,
and is mentioned in clang 3.5 comments as "the BSD interface" for finding
exidx data.  GCC (in libgcc_s) expects the exact same API and functionality
to be provided by a function named __gnu_Unwind_Find_exidx(), so we provide
that with an alias ("strong reference").

Reviewed by:	kib@
MFC after:	1 week
2014-07-19 22:13:27 +00:00
Pedro F. Giffuni
65227e53ce Clean r268867.
Proposed by:	bde
2014-07-19 14:34:06 +00:00
Pedro F. Giffuni
bef4f148b1 Use unsigned optlen in getsourcefilter()
Sizes can not be negative and the functions that use it
expect an unsigned value anyways.

Obtained from:	Apple (Libc-997.90.3)
MFC after:	1 week
2014-07-19 01:53:52 +00:00
Jilles Tjoelker
becf520163 ttyname(3): Fix EBADF/ENOTTY error descriptions.
Also, make sure to document the return values and errors for all three
functions in the man page.

PR:		191931
MFC after:	1 week
2014-07-18 21:29:59 +00:00
Baptiste Daroussin
42e62eca52 Extend kqueue's EVFILT_TIMER by adding precision unit flags support
Define the precision macros as bits sets to conform with XNU equivalent.
Test fflags passed for EVFILT_TIMER and return EINVAL in case an invalid flag
is passed.

Phabric:	https://phabric.freebsd.org/D421
Reviewed by:	kib
2014-07-18 14:27:04 +00:00
Pedro F. Giffuni
8a29851f80 libc/stdlib: Minor cleanups to code originating in NetBSD
Mostly ANSIfication and typos.

Obtained from:	NetBSD
MFC after:	5 days
2014-07-15 03:28:37 +00:00
Kevin Lo
92511d108b Document that listen(2) can fail with EDESTADDRREQ. 2014-07-15 02:21:51 +00:00
Pedro F. Giffuni
dad64c978f libc/gen: small updates to code originating at OpenBSD
arc4random.c
- CVS rev. 1.22
Change arc4random_uniform() to calculate ``2**32 % upper_bound'' as
``-upper_bound % upper_bound''. Simplifies the code and makes it the
same on both ILP32 and LP64 architectures, and also slightly faster on
LP64 architectures by using a 32-bit remainder instead of a 64-bit
remainder.
- CVS rev. 1.23
Spacing

readpassphrase.c
-CVS rev. v 1.24
most obvious unsigned char casts for ctype

Obtained from:	OpenBSD
MFC after:	5 days
2014-07-15 02:21:35 +00:00
Julio Merino
b32cce1f82 Make generation of nslexer.c more robust.
Ensure that lex errors fail the build instead of being silently ignored
due to the piped call.  Also postpone the update of the nslexer.c file
until we are sure we have generated it properly.

These changes fix some very obscure build failures I encountered while
building FreeBSD within a chroot that did not have devfs mounted. The
specific errors looked like:

.../libc.so.7: undefined reference to `_nsyyerror'
.../libc.so.7: undefined reference to `_nsyyin'
.../libc.so.7: undefined reference to `_nsyylex'
.../libc.so.7: undefined reference to `_nsyylineno'
.../libc.so.7: undefined reference to `_nsyytext'

and were caused due to a mangled nslexer.c being linked into libc.
2014-07-14 13:53:10 +00:00
Pedro F. Giffuni
0c02957978 strfmon: reduce unnecessary snprintf.
No need for the snprintf/asprintf dance; use fixed width formats.

Obtained from:	NetBSD (CVS rev. 1.8)
MFC after:	1 week
2014-07-12 15:19:30 +00:00
John Baldwin
9f72c0322c Fix some edge cases with rewinddir():
- In the unionfs case, opendir() and fdopendir() read the directory's full
  contents and cache it.  This cache is not refreshed when rewinddir() is
  called, so rewinddir() will not notice updates to a directory.  Fix this
  by splitting the code to fetch a directory's contents out of
  __opendir_common() into a new _filldir() function and call this from
  rewinddir() when operating on a unionfs directory.
- If rewinddir() is called on a directory opened with fdopendir() before
  any directory entries are fetched, rewinddir() will not adjust the seek
  location of the backing file descriptor.  If the file descriptor passed
  to fdopendir() had a non-zero offset, the rewinddir() will not rewind to
  the beginning.  Fix this by always seeking back to 0 in rewinddir().
  This means the dd_rewind hack can also be removed.

While here, add missing locking to rewinddir().

CR:   	    	https://phabric.freebsd.org/D312
Reviewed by:	jilles
MFC after:	1 week
2014-07-11 16:16:26 +00:00
Konstantin Belousov
a028ee5c9f Implement sysconf(_SC_GETGR_R_SIZE_MAX) and sysconf(_SC_GETPW_R_SIZE_MAX).
Reported by:	Dmitry Sivachenko <trtrmitya@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-07-09 19:12:18 +00:00
Mark Johnston
d3fe75eb62 Fix a typo.
MFC after:	3 days
2014-07-09 01:33:35 +00:00
Sergey Kandaurov
74ba624bf0 [mdoc] Fix previous change. 2014-07-08 12:19:34 +00:00
Marcel Moolenaar
e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00
Pedro F. Giffuni
0716c0ff7a minor perf enhancement for UTF-8
Reduce some duplicate code.

Reference:
https://www.illumos.org/issues/628

Obtained from:	Illumos
MFC after:	1 week
2014-07-04 22:39:39 +00:00
Pedro F. Giffuni
f54192cc18 getopt(3): clarify GNU instead of NetBSD.
The manpage and the code for r267745 came from NetBSD but the
option is inspired on GNU.

Reported by:	Ben Kaduk
MFC after:	3 days
2014-07-04 21:06:48 +00:00
Konstantin Belousov
c22de76166 Note that most errors are possible for all syscalls from utimes(2)
family.  Minor wording corrections.

Based on the suggestions by bde.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-07-03 11:19:16 +00:00
Pedro F. Giffuni
6e28368366 regex(3): Add support for \< and \> word delimiters
Solaris and other OSs have support for \< and \> as word
delimiters in utilities like sed(1). These are useful to
have for general compatiblity with Solaris but should be
avoided for portability with other systems, including the
traditional BSDs.

Bump __FreeBSD_version as this is likely to affect some
userland utilities.

Reference:
https://www.illumos.org/issues/516

PR:		bin/153257
Obtained from:	Illumos
MFC after:	1 month
2014-06-30 20:54:25 +00:00
Hajimu UMEMOTO
5d9d18f283 Fix build with WITHOUT_INET6.
Spotted by:	bf
MFC after:	1 week
2014-06-26 14:24:31 +00:00
Hajimu UMEMOTO
17f53388d6 - Exclude loopback address rather than loopback interface.
- style(9)

TODO: When AI_ADDRCONFIG is specified, getaddrinfo() can
be quite slow for system with many interfaces.  We should
have some kernel sysctls to report IPv4/IPv6 status.

Spotted by:	melifaro
MFC after:	1 week
2014-06-26 12:12:18 +00:00
Sergey Kandaurov
521aa90cb8 Document EINVAL as per POSIX.
This also follows r124335-r124336, r225827.

PR:		191382
MFC after:	1 week
Sponsored by:	Nginx, Inc.
2014-06-26 10:21:00 +00:00
Garrett Wollman
775a76844f Catch up with many years of changes:
o Document PF_LOCAL as being an alias for PF_UNIX
o Document POSIX standardization of this interface using AF_*
  constants rather than PF_* constants, and note the three particular
  families which POSIX standardizes.
o Note anticipated POSIX standardization of SOCK_CLOEXEC.
o Delete from listing protocol families that FreeBSD doesn't support
  (in some cases, like PF_PUP, has never supported).
o Add to listing some current protocol families that have been
  introduced in the last decade or so.
o Document the correspondence of PF_* and AF_* constants.

We should probably change the documentation to make the AF_* constants
primary, but this commit does not do so.

Reviewed by:	kevlo@
MFC after:	1 month
2014-06-24 20:23:18 +00:00
Joel Dahl
df2d82e003 mdoc: remove superfluous paragraph macros. 2014-06-23 18:40:21 +00:00
Hajimu UMEMOTO
290789099b Exclude IPv4 address from doing longest match.
It prevented DNS based load balancing.

MFC after:	1 week
2014-06-23 15:43:27 +00:00
Baptiste Daroussin
8fbf3d50e3 use .Mt to mark up email addresses consistently (part4)
PR:		191174
Submitted by:	Franco Fichtner  <franco at lastsummer.de>
2014-06-23 08:25:03 +00:00
Andrey A. Chernov
298207c39a Merge intermediate OpenBSD v1.25 changes (almost identical to ours)
to reduce diff and bump OpenBSD patch level to v1.26.

MFC after:      2 weeks
2014-06-22 21:54:57 +00:00
Pedro F. Giffuni
6aa225165f 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
2014-06-22 20:13:57 +00:00
Pedro F. Giffuni
0279beeb0e Revert r267675:
The code doesn't really benefit of using reallocf() in this case.
Also, the realloc() results being assigned temporary variable which
makes blind replacement with reallocf() mostly useless.

Pointed out by:		stefanf, bde
2014-06-21 01:43:56 +00:00
Pedro F. Giffuni
eb0fb866de regex: Make use of reallocf().
Use of reallocf is useful in libraries as we are not certain the
application will exit after NULL.

This somewhat reduces portability but if since you are building
this as part of libc it is likely you have our non-standard
reallocf(3) already.

Reviewed by:	ache
MFC after:	5 days
2014-06-20 15:29:09 +00:00
Hajimu UMEMOTO
cfaa2a0955 Use SOCK_CLOEXEC.
MFC after:	1 week
2014-06-19 11:49:36 +00:00
Konstantin Belousov
11c42bcc54 Add MAP_EXCL flag for mmap(2). It should be combined with MAP_FIXED,
and prevents the request from deleting existing mappings in the
region, failing instead.

Reviewed by:	alc
Discussed with:	jhb
Tested by:	markj, pho (previous version, as part of the bigger patch)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-06-19 05:00:39 +00:00
Konstantin Belousov
8efb419829 The time come to remove the wrapper, most likely, but tidy up it code
instead for now.  Remove spurious blank line, use C89 definition, wrap
long line.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-06-19 04:55:00 +00:00
Pedro F. Giffuni
cd9dcb0307 strptime: add support for %t and %n
Posix strptime() requires support for %t and %n, which were added
to the illumos port.  Curiously we were skipping white spaces by
default in most other cases making %t meaningless.

We now skip spaces in the case of the %e specifier as strftime(3)
explicitly adds a space for the single digit case.

Reference:
http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html

Obtained from:	Illumos (Rev. a11c1571b6942161b0186d0588609448066892c2)
MFC after:	3 weeks
2014-06-18 23:34:48 +00:00
Warren Block
a9e1cffd28 Fix syntax error.
PR:		191131
Submitted by:	dan.mcgregor@usask.ca
MFC after:	1 week
2014-06-18 18:31:35 +00:00
Hajimu UMEMOTO
6f63a1142c Retooling addrconfig() to exclude addresses on loopback interfaces
when looking for configured addresses.
This change is based upon the code from the submitter, and made
following changes:
- Exclude addresses assigned on interfaces which are down, like NetBSD
  does.
- Exclude addresses assigned on interfaces which are ifdisabled.

PR:		190824
Submitted by:	Justin McOmie
MFC after:	1 week
2014-06-18 18:07:19 +00:00
Pedro F. Giffuni
3624c75218 stdtime: style(9) fixes.
Obtained from:	illumos
MFC after:	5 days
2014-06-18 02:36:21 +00:00
Pedro F. Giffuni
0413bfcac9 Update license to strptime(3) implementation.
Our strptime(3) implementation was the base for the illumos
implementation and after contacting the author, Kevin Rudy
stated the code is under a 2-Clause BSD License [1]

After reviewing our local changes to the file in question,
the FreeBSD Foundation has agreed that their contributions
to this file are not required to carry clause 3 or 4 so
the file can be relicensed as in Illumos [2].

References:

[1] https://www.illumos.org/issues/357
[2] Illumos Revision:		13222:02526851ba75

Approved:	core (jhb)
Approved:	FreeBSD Foundation (emaste)
MFC after:	4 days
2014-06-16 14:55:09 +00:00
Tijl Coosemans
cdd0ebc93b iconv_open: initialise ci_ilseq_invalid field of _citrus_iconv_shared
struct after allocation with malloc.

iconvlist: reduce a memory leak by copying strings only once.
2014-06-13 08:36:10 +00:00
Tijl Coosemans
3fc3c30a27 Replace malloc+memset with calloc. 2014-06-13 08:28:51 +00:00
Jilles Tjoelker
078cb49070 siglongjmp(): Preserve floating point exception flags on i386 and amd64.
Per POSIX, siglongjmp() shall be equivalent to longjmp() except that it must
match sigsetjmp() instead of setjmp() and except for the effect on the
signal mask. Therefore, it should preserve the floating point exception
flags.

This was fixed for longjmp() and _longjmp() in r180080 and r180081 for amd64
and i386 respectively.
2014-06-09 21:35:36 +00:00
Pietro Cerutti
4c524a4287 - Return NULL and set errno to EINVAL if size is 0 (as required by POSIX).
Update the manpage to reflect this change.
- Always set the current position to the first null-byte when opening in append
mode. This makes the implementation compatible with glibc's. Update the test
suite.

Reported by:	pho
Approved by:	cognet
2014-06-02 13:48:57 +00:00
Benjamin Kaduk
245d93279b Minor mdoc fix
Submitted by:	hrs
Approved by:	hrs (mentor, implicit)
2014-05-30 02:16:28 +00:00
Pedro F. Giffuni
1bb07edbd4 Fix strcasecmp_l() and strncasecmp_l() POSIX 2008 compliance.
POSIX.1-2008 specifies that those two functions should be declared by
including <strings.h>, not <string.h> (the latter only has strcoll_l()
and strxfrm_l()):

http://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html

Obtained from:	DragonFlyBSD
Reviewed by:	theraven
MFC after:	2 weeks
2014-05-30 01:09:07 +00:00
Sergey Kandaurov
1d8b56e9a0 mdoc: add missing paragraph macro. 2014-05-29 13:35:13 +00:00
Allan Jude
647efa79a1 Emphasis on 'do not' and 'complement' in the strcspn(3)
Replace literal parentheses with .Po/.Pc

Approved by:	wblock (mentor)
2014-05-27 04:30:56 +00:00
Allan Jude
5538d7a1fc Merge strcspn.3 into strspn.3 and clarify the explaination of what they do
Detach strcspn.3 from the build
Add strcspn.3 to MLINKS do it will be symlinked to strspn.3

Approved by:	eadler (mentor), bcr (mentor)
2014-05-25 18:40:32 +00:00
Benjamin Kaduk
6953d7db5c Correct documentation of the limit on how much memory can be mlock()ed
vm.max_wired is a system-wide limit, not per-process.  Reword the
section to make this more clear.

PR:		docs/189214
Submitted by:	Lawrence Chen (original text)
Approved by:	hrs (mentor)
2014-05-17 03:05:52 +00:00
Konstantin Belousov
ca5e4fe970 Invalidate the cache for the named posix semaphore when opened and
actual file storing the semaphore object is different from the file
created on the first open.  Store the file st_dev and st_ino members
of the struct stat in the semaphore structure on open, and compare
them with the attributes of the opened file to detect unlink and
re-creation.

This fixes an issue of sem_unlink(3) failing to flush the named entry
in the semaphore list for the current or remote process, making
sem_unlink(3) not correctly operating if the unlinked semaphore is
still opened.

Reported by:	Joris Giovannangeli <joris@giovannangeli.fr>
PR:	standards/189353
Reviewed by:	jilles (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-05-10 19:08:07 +00:00
Konstantin Belousov
9b6224b70f Style.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-05-10 18:59:09 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
cc3f4b9965 Merge from head 2014-05-08 23:54:15 +00:00
Peter Holm
e103f5b1c0 msync(2) must return ENOMEM and not EINVAL when the address is outside the
allowed range or when one or more pages are not mapped. This according to
The Open Group Base Specifications Issue 7.

Discussed with:	 attilio, Bruce Evans
Reviewed by:	 alc, Garrett Cooper
Reported by:	 ATF
MFC after:	 2 weeks
Sponsored by:	EMC / Isilon storage division
2014-05-07 08:38:02 +00:00
Warner Losh
c6063d0da8 Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.
2014-05-06 04:22:01 +00:00
Pedro F. Giffuni
e234ddef95 Revert r265367:
Use of calloc instead of malloc in regex (from OpenBSD).

In this case the change makes no sense since we are using realloc() later.

Reported by:	ache
2014-05-05 18:04:57 +00:00
Pedro F. Giffuni
9d12ca17b5 regex: Use calloc instead of malloc.
Mostly to reduce differences with OpenBSD.

Obtained from:	OpenBSD (CVS rev. 1.17)
MFC after:	3 days
2014-05-05 16:41:15 +00:00
Christian Brueffer
1a2ac459a9 Properly free resources in case of error.
CID:		1007032
Found with:	Coverity Prevent(tm)
MFC after:	2 weeks
2014-05-02 20:41:09 +00:00
Pedro F. Giffuni
eab20bceca regex: Remove some unreachable breaks.
This is based on a much bigger cleanup done in Illumos.

Reference:
https://www.illumos.org/issues/2077

MFC after:	1 week
2014-05-01 23:34:14 +00:00
Pedro F. Giffuni
0f5132cd25 citrus: Avoid invalid code points.
From the OpenBSD log:
The UTF-8 decoder should not accept byte sequences which decode to unicode
code positions U+D800 to U+DFFF (UTF-16 surrogates), U+FFFE, and U+FFFF.

http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
http://unicode.org/faq/utf_bom.html#utf8-4

Reported by:	Stefan Sperling
Obtained from:	OpenBSD
MFC after:	5 days
2014-05-01 01:42:48 +00:00
Pedro F. Giffuni
97ecaa8907 citrus: Avoid invalid code points.
From the OpenBSD log:
The UTF-8 decoder should not accept byte sequences which decode to unicode
code positions U+D800 to U+DFFF (UTF-16 surrogates), U+FFFE, and U+FFFF.

http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
http://unicode.org/faq/utf_bom.html#utf8-4

Reported by:	Stefan Sperling
Obtained from:	OpenBSD
MFC after:	5 days
2014-04-29 15:25:57 +00:00
Andrew Turner
8258fd68ef Set the new floating point exception mask correctly
Submitted by:	Keith White <kwhite@site.uottawa.ca>
2014-04-28 18:54:12 +00:00
Simon J. Gerraty
9d2ab4a62d Merge head 2014-04-27 08:13:43 +00:00
Jilles Tjoelker
93a65e1b5f libc/stdio: Fail fdopen() on an execute-only fd.
An execute-only fd (opened with O_EXEC) allows neither read() nor write()
and is therefore incompatible with all stdio modes. Therefore, the [EINVAL]
error applies.

Also adjust the similar check in freopen() with a NULL path, even though
this checks an fd which is already from a FILE.
2014-04-21 17:40:23 +00:00
Andrew Turner
3f5730095b Rename the fp{get,set}* files so they no longer conflict with the softfloat
version of these files. Keep them within this directory so they can be used
to implement the armv6 version of these functions.
2014-04-21 09:43:22 +00:00
Andrew Turner
8772ff83ee Add the deprecated fp{get,set}* functions, a few ports use them. 2014-04-20 14:58:14 +00:00
Christian Brueffer
fb50471ca9 Correct sorting. 2014-04-15 16:31:23 +00:00
Christian Brueffer
e27a4d582f Mention Capsicum.
MFC after:	1 week
2014-04-15 16:29:21 +00:00
Jilles Tjoelker
310c8f3c99 realpath(): Properly fail "." or ".." components after 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:		kern/82980
MFC after:	2 weeks
2014-04-13 19:48:28 +00:00
Ed Schouten
f56cfe8d61 Fix table alignment. EVFILT_PROCDESC is longer than the existing filters. 2014-04-07 18:17:31 +00:00
Ed Schouten
38219d6acd Implement kqueue(2) for procdesc(4).
kqueue(2) already supports EVFILT_PROC. Add an EVFILT_PROCDESC that
behaves the same, but operates on a procdesc(4) instead. Only implement
NOTE_EXIT for now. The nice thing about NOTE_EXIT is that it also
returns the exit status of the process, meaning that we can now obtain
this value, even if pdwait4(2) is still unimplemented.

Notes:

- Simply reuse EVFILT_NETDEV for EVFILT_PROCDESC. As both of these will
  be used on totally different descriptor types, this should not clash.

- Let procdesc_kqops_event() reuse the same structure as filt_proc().
  The only difference is that procdesc_kqops_event() should also be able
  to deal with the case where the process was already terminated after
  registration. Simply test this when hint == 0.

- Fix some style(9) issues in filt_proc() to keep it consistent with the
  newly added procdesc_kqops_event().

- Save the exit status of the process in pd->pd_xstat, as we cannot pick
  up the proctree_lock from within procdesc_kqops_event().

Discussed on:	arch@
Reviewed by:	kib@
2014-04-07 18:10:49 +00:00
Kevin Lo
e06e816f67 Add support for UDP-Lite protocol (RFC 3828) to IPv4 and IPv6 stacks.
Tested with vlc and a test suite [1].

[1] http://www.erg.abdn.ac.uk/~gerrit/udp-lite/files/udplite_linux.tar.gz

Reviewed by:	jhb, glebius, adrian
2014-04-07 01:53:03 +00:00