Commit Graph

1783 Commits

Author SHA1 Message Date
Pedro F. Giffuni
9143e6e49a Remove incorrect attributes from posix_memalign(3) declaration.
Both __alloc_align and __alloc_size can't be used when the function
returns a pointer to memory. This fixes breakage when building with
clang 3.4:

In file included from /usr/src/svn/usr.sbin/bhyve/atkbdc.c:40:
/usr/include/stdlib.h:176:6: error: '__alloc_size__' attribute only
applies to functions that return a pointer [-Werror,-Wignored-attributes]

Pointed out by:	ngie, cem
Approved by:	re (gjb)
2016-07-05 22:30:29 +00:00
Warner Losh
f24c011beb Commit the bits of nda that were missed. This should fix the build.
Approved by: re@
2016-06-10 06:04:53 +00:00
Mark Johnston
714ac00292 Implement an NSS backend for netgroups and add getnetgrent_r(3).
This support appears to have been documented in nsswitch.conf(5) for some
time. The implementation adds two NSS netgroup providers to libc. The
default, compat, provides the behaviour documented in netgroup(5), so this
change does not make any user-visible behaviour changes. A files provider
is also implemented.

innetgr(3) is implemented as an optional NSS method so that providers such
as NIS which are able to implement efficient reverse lookup can do so.
A fallback implementation is used otherwise. getnetgrent_r(3) is added for
convenience and to provide compatibility with glibc and Solaris.

With a small patch to net/nss_ldap, it's possible to specify an ldap
netgroup provider, allowing one to query nisNetgroupTriple entries.

Sponsored by:	EMC / Isilon Storage Division
2016-06-09 01:28:44 +00:00
Ed Schouten
de1d269583 Fix prototype of dbm_open().
The last argument of dbm_open() should be a mode_t according to POSIX;
not an int.

Reviewed by:	pfg, kib
Differential Revision:	https://reviews.freebsd.org/D6650
2016-05-31 18:32:57 +00:00
Ed Schouten
b240f5e262 Make strfmon_l() work without requiring the use of <xlocale.h>.
The strfmon_l() function provided by <xlocale/_monetary.h> is also part
of POSIX 2008's <monetary.h>, so it should be exposed by default.

Change the check used in <monetary.h> to be similar to the one that's
part of <wchar.h>, where we both test for __POSIX_VISIBLE and
_XLOCALE_H_.
2016-05-31 12:29:21 +00:00
Ed Schouten
2fed5061db Let dbm's datum::dptr use the right type.
According to POSIX, it should use void *, not char *. Unfortunately, the
dsize field also has the wrong type. It should be size_t. I'm not going
to change that, as that will break the ABI.

Reviewed by:	pfg
Differential Revision:	https://reviews.freebsd.org/D6647
2016-05-30 16:52:23 +00:00
Ed Schouten
7e3327be32 Add missing va_list to <wchar.h>.
It looks like va_list should always be defined when XSI is enabled. It
moved over to the POSIX base in the 2008 edition.
2016-05-30 16:26:34 +00:00
Ed Schouten
0977bd1e88 Fix the signature of the psignal() function.
POSIX 2008 added the psignal() function which has already been part of
the BSDs for a long time. The only difference is, the POSIX version uses
an 'int' for the signal number, unlike our version which uses an
'unsigned int'. Fix up the function to use an 'int'. This should not
affect the ABI.
2016-05-30 13:51:27 +00:00
Ed Schouten
07acf54b4b Add missing types and constants to <netdb.h>.
According to POSIX, the netdb.h header must also provide in_addr_t and
in_port_t. It should also provide IPPORT_RESERVED. Copy over the
necessary bits from <netinet/in.h> to achieve that.
2016-05-30 13:37:11 +00:00
Ed Schouten
611c29bab9 Add missing declaration of ino_t.
POSIX requires that <dirent.h> provides ino_t in the XSI case. In our
case, this wasn't being exposed, as d_ino is a macro that expands to
d_fileno that is an uint32_t, not an ino_t.
2016-05-30 07:50:57 +00:00
Ed Schouten
864a391104 Fix style of the libgen.h header.
- Remove unneeded declarations of removed/unimplemented features.
- Add missing tab after #define.
- Add missing ! before trailing comment.
2016-05-29 12:21:54 +00:00
Bryan Drewery
9ea89f3223 WITH_META_MODE: Disable cookie handling for include installation.
Using a cookie with meta mode causes it to *not rerun* (as normal make
does) unless the command changes or filemon-detected files change.

After all of the work done here it turns out that skipping installation
is dangerous since the install commands use <dir>/*.h.  The actual build
command is not changing but the files installed are changing by the mere
act of adding a new header into the source tree.  Thus we cannot safely
use meta mode logic here.  It must always rerun and install the headers.
The install -C flag at least prevents churning timestamps when
installing a header that was already present.

Sponsored by:	EMC / Isilon Storage Division
2016-05-21 01:31:57 +00:00
Konstantin Belousov
2a339d9e3d Add implementation of robust mutexes, hopefully close enough to the
intention of the POSIX IEEE Std 1003.1TM-2008/Cor 1-2013.

A robust mutex is guaranteed to be cleared by the system upon either
thread or process owner termination while the mutex is held.  The next
mutex locker is then notified about inconsistent mutex state and can
execute (or abandon) corrective actions.

The patch mostly consists of small changes here and there, adding
neccessary checks for the inconsistent and abandoned conditions into
existing paths.  Additionally, the thread exit handler was extended to
iterate over the userspace-maintained list of owned robust mutexes,
unlocking and marking as terminated each of them.

The list of owned robust mutexes cannot be maintained atomically
synchronous with the mutex lock state (it is possible in kernel, but
is too expensive).  Instead, for the duration of lock or unlock
operation, the current mutex is remembered in a special slot that is
also checked by the kernel at thread termination.

Kernel must be aware about the per-thread location of the heads of
robust mutex lists and the current active mutex slot.  When a thread
touches a robust mutex for the first time, a new umtx op syscall is
issued which informs about location of lists heads.

The umtx sleep queues for PP and PI mutexes are split between
non-robust and robust.

Somewhat unrelated changes in the patch:
1. Style.
2. The fix for proper tdfind() call use in umtxq_sleep_pi() for shared
   pi mutexes.
3. Removal of the userspace struct pthread_mutex m_owner field.
4. The sysctl kern.ipc.umtx_vnode_persistent is added, which controls
   the lifetime of the shared mutex associated with a vnode' page.

Reviewed by:	jilles (previous version, supposedly the objection was fixed)
Discussed with:	brooks, Martin Simmons <martin@lispworks.com> (some aspects)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2016-05-17 09:56:22 +00:00
Conrad Meyer
9183be81a7 stdio.h: Fix function-type typedef style and use _types.h __ssize_t
I'm still not sure why only Pypy runs into the error with the function
typedefs.  Fix it anyway.

Use __ssize_t instead of ssize_t for the types; it's possible for the size_t
type to not be visible if at the wrong POSIX_VISIBLE level.

A final (crossing my fingers) follow-up to r299456.

Sponsored by:	EMC / Isilon Storage Division
2016-05-12 22:13:12 +00:00
Conrad Meyer
6710d21d9f Pollute more places with off64_t and add __off64_t
Despite the private namespace, several broken ports depend on the __off64_t
name for the type.  Export it exactly the same way off_t and __off_t are
exported.

A follow-up to r299456.

Suggested by:	php56
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 21:18:17 +00:00
Conrad Meyer
877a840c08 libc: Add fopencookie(3) wrapper around funopen(3)
Reviewed by:	jhb, oshogbo
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D6282
2016-05-11 14:38:27 +00:00
Alan Somers
8907f744ff Improve performance and functionality of the bitstring(3) api
Two new functions are provided, bit_ffs_at() and bit_ffc_at(), which allow
for efficient searching of set or cleared bits starting from any bit offset
within the bit string.

Performance is improved by operating on longs instead of bytes and using
ffsl() for searches within a long. ffsl() is a compiler builtin in both
clang and gcc for most architectures, converting what was a brute force
while loop search into a couple of instructions.

All of the bitstring(3) API continues to be contained in the header file.
Some of the functions are large enough that perhaps they should be uninlined
and moved to a library, but that is beyond the scope of this commit.

sys/sys/bitstring.h:
        Convert the majority of the existing bit string implementation from
        macros to inline functions.

        Properly protect the implementation from inadvertant macro expansion
        when included in a user's program by prefixing all private
        macros/functions and local variables with '_'.

        Add bit_ffs_at() and bit_ffc_at(). Implement bit_ffs() and
        bit_ffc() in terms of their "at" counterparts.

        Provide a kernel implementation of bit_alloc(), making the full API
        usable in the kernel.

        Improve code documenation.

share/man/man3/bitstring.3:
        Add pre-exisiting API bit_ffc() to the synopsis.

        Document new APIs.

        Document the initialization state of the bit strings
        allocated/declared by bit_alloc() and bit_decl().

        Correct documentation for bitstr_size(). The original code comments
        indicate the size is in bytes, not "elements of bitstr_t". The new
        implementation follows this lead. Only hastd assumed "elements"
        rather than bytes and it has been corrected.

etc/mtree/BSD.tests.dist:
tests/sys/Makefile:
tests/sys/sys/Makefile:
tests/sys/sys/bitstring.c:
        Add tests for all existing and new functionality.

include/bitstring.h
	Include all headers needed by sys/bitstring.h

lib/libbluetooth/bluetooth.h:
usr.sbin/bluetooth/hccontrol/le.c:
        Include bitstring.h instead of sys/bitstring.h.

sbin/hastd/activemap.c:
        Correct usage of bitstr_size().

sys/dev/xen/blkback/blkback.c
        Use new bit_alloc.

sys/kern/subr_unit.c:
        Remove hard-coded assumption that sizeof(bitstr_t) is 1.  Get rid of
        unrb.busy, which caches the number of bits set in unrb.map.  When
        INVARIANTS are disabled, nothing needs to know that information.
        callapse_unr can be adapted to use bit_ffs and bit_ffc instead.
        Eliminating unrb.busy saves memory, simplifies the code, and
        provides a slight speedup when INVARIANTS are disabled.

sys/net/flowtable.c:
        Use the new kernel implementation of bit-alloc, instead of hacking
        the old libc-dependent macro.

sys/sys/param.h
        Update __FreeBSD_version to indicate availability of new API

Submitted by:   gibbs, asomers
Reviewed by:    gibbs, ngie
MFC after:      4 weeks
Sponsored by:   Spectra Logic Corp
Differential Revision:  https://reviews.freebsd.org/D6004
2016-05-04 22:34:11 +00:00
Pedro F. Giffuni
eacd600ea9 include: minor spelling fixes.
No functional change.
2016-04-30 14:43:42 +00:00
Glen Barber
0edd2576c0 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-16 02:32:12 +00:00
Bryan Drewery
94086cea27 Rework META_TARGETS so that it automatically adds META_DEPS to the targets.
This will only be done if the target is defined, so if the target is
defined after bsd.sys.mk is included then it needs to manually add
${META_DEPS} still.

Sponsored by:	EMC / Isilon Storage Division
2016-04-14 21:04:42 +00:00
Glen Barber
d60840138f MFH
Sponsored by:	The FreeBSD Foundation
2016-04-04 23:55:32 +00:00
Dimitry Andric
4ec98362ae For C++, expose long long types and functions (lldiv_t, llabs, lldiv,
etc) in stdlib.h.  These will be needed for newer versions of libc++,
which uses them for defining overloaded versions of abs() and div().

MFC after:	1 week
2016-03-23 19:17:12 +00:00
Warner Losh
1ed9c427e5 Implement suggestion by jhb@ to have _PATH_FIRMWARE instead of hard
coding it to be "/usr/share/firmware".
2016-03-23 04:18:57 +00:00
Glen Barber
538354481e MFH
Sponsored by:	The FreeBSD Foundation
2016-03-14 18:54:29 +00:00
Bryan Drewery
b7d28aff10 META_MODE: Simplify the META_COOKIE handling to use .USE/.USEBEFORE.
Extend it to other cases of meta mode cookies so they get the proper rm
cookie behavior when a .meta file detects it needs to rebuild and fails.

Sponsored by:	EMC / Isilon Storage Division
2016-03-11 23:45:28 +00:00
Bryan Drewery
f883c0ad24 DIRDEPS_BUILD: None of this is needed anymore.
This file is using stage-install, so all of the .dirdep files
are properly handled.  The cookie handling also properly
handles rebuilds with .meta files.  DESTDIR from bsd.sys.mk is also
respected for staging.  This logic came in r239572.

Sponsored by:	EMC / Isilon Storage Division
2016-03-11 23:44:56 +00:00
Bryan Drewery
588f5cb86d DIRDEPS_BUILD: Remove the cookie when target is out-of-date.
The meta file may decide the target is out of date but nothing
ensures that the *next* build will build this target if it
fails this time for some reason; it is still out-of-date
until it succeeds.

Convert the include/ cookie usage to the global versions.

Sponsored by:	EMC / Isilon Storage Division
2016-03-11 23:44:27 +00:00
Glen Barber
b655ec9752 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-06 04:13:17 +00:00
Pedro F. Giffuni
d1bd689d10 xdr: Fix xdr_rpc* defines.
The defines for xdr_rpc* in xdr.h are wrong. It could be
very well that Solaris did strip the '_t' from xdr_u_int32_t,
but Solaris has a xdr_u_int32 function, we don't have this.
So all of this defines will lead to an unresolved symbol.

This explains why we do not use these functions in FreeBSD
while they are used in Illumos/Solaris.

Obtained from:	linux libtirpc (git 7864122e61ffe4db1aa8ace89117358a1e3a391b)
MFC after:	3 weeks
2016-03-04 22:03:38 +00:00
Pedro F. Giffuni
ceb5a304ca Add sunrpc compat define for xp_sock.
SunRPC is using xp_sock in SVCXPRT, while TI-RPC is using
xp_fd. Add a compatibility define.

Illumos has something similar for the non-kernel case.

Obtained from: linux-nfs project (git 0d94036c3a0d4c24d22bf6a8c40ac6625d972c29)
2016-03-03 14:44:30 +00:00
Glen Barber
52259a98ad MFH
Sponsored by:	The FreeBSD Foundation
2016-03-02 16:14:46 +00:00
Jason Evans
df0d881d94 Update jemalloc to 4.1.0.
Add missing Symbol.map entry for __aligned_alloc.

Add weak-->strong symbol binding for
{malloc_stats_print,mallctl,mallctlnametomib,mallctlbymib} -->
{__malloc_stats_print,__mallctl,__mallctlnametomib,__mallctlbymib}.  These
bindings complete the set necessary to allow applications to replace all
malloc-related symbols.
2016-02-29 19:10:32 +00:00
Konstantin Belousov
1bdbd70599 Implement process-shared locks support for libthr.so.3, without
breaking the ABI.  Special value is stored in the lock pointer to
indicate shared lock, and offline page in the shared memory is
allocated to store the actual lock.

Reviewed by:	vangyzen (previous version)
Discussed with:	deischen, emaste, jhb, rwatson,
	Martin Simmons <martin@lispworks.com>
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2016-02-28 17:52:33 +00:00
Pedro F. Giffuni
283970e873 RPC: update the getrpcbyname() definition to include a const qualifier.
Add const qualifier making getrpcbyname() and getrpcbyname_r()
prototypes match those used in latest Sun RPC code (TI-RPC 2.3).

Obtained from:	NetBSD
2016-02-26 23:25:21 +00:00
Glen Barber
0fe0fe112f MFH
Sponsored by:	The FreeBSD Foundation
2016-02-15 21:58:52 +00:00
Konstantin Belousov
2dd7d0560a Hide ucontext_t and mcontext_t when neither POSIX nor XSI features are
enabled in the compilation environment, i.e. for ANSI C use of
#include <signal.h>.

Requested and reviewed by:	bde
Sponsored by:	The FreeBSD Foundation
MFC after:	13 days
2016-02-13 17:23:55 +00:00
Konstantin Belousov
90edf67ecf POSIX states that #include <signal.h> shall make both mcontext_t and
ucontext_t available.  Our code even has XXX comment about this.

Add a bit of compliance by moving struct __ucontext definition into
sys/_ucontext.h and including it into signal.h and sys/ucontext.h.

Several machine/ucontext.h headers were changed to use namespace-safe
types (like uint64_t->__uint64_t) to not depend on sys/types.h.
struct __stack_t from sys/signal.h is made always visible in private
namespace to satisfy sys/_ucontext.h requirements.

Apparently mips _types.h pollutes global namespace with f_register_t
type definition.  This commit does not try to fix the issue.

PR:	207079
Reported and tested by:	Ting-Wei Lan <lantw44@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2016-02-12 07:38:19 +00:00
Glen Barber
bf24694c4e Ensure include/ is properly tagged in the METALOG.
Noticed by:	des
Sponsored by:	The FreeBSD Foundation
2016-02-08 20:21:07 +00:00
Gleb Smirnoff
d519cedbad Provide new socket option TCP_CCALGOOPT, which stands for TCP congestion
control algorithm options.  The argument is variable length and is opaque
to TCP, forwarded directly to the algorithm's ctl_output method.

Provide new includes directory netinet/cc, where algorithm specific
headers can be installed.

The new API doesn't yet have any in tree consumers.

The original code written by lstewart.
Reviewed by:	rrs, emax
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D711
2016-01-22 02:07:48 +00:00
Kevin Lo
ab707ec668 - Add the definition of CHARCLASS_NAME_MAX, as per POSIX.1-2001.
- Avoid namespace pollution and move definitions of _POSIX2_CHARCLASS_NAME_MAX
  and _POSIX2_COLL_WEIGHTS_MAX into the .2001 section.
  With input from bde.

Submitted by	bde
2016-01-09 14:53:23 +00:00
Jilles Tjoelker
43d53dba8f Add sbin and /usr/local directories to _PATH_DEFPATH.
Set _PATH_DEFPATH to
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin. This is the
path in the default class in the default /etc/login.conf,
excluding ~/bin which would not be expanded properly in a string
constant.

For normal logins, _PATH_DEFPATH is overridden by /etc/login.conf,
~/.login_conf or shell startup files. _PATH_DEFPATH is still used as a
default by execlp(), execvp(), posix_spawnp() and sh if PATH is not set, and
by cron. Especially the latter is a common trap (most recently in PR
204813).

PR:		204813
Reviewed by:	secteam (delphij), alfred
2016-01-05 16:21:20 +00:00
Ed Schouten
2747eff128 Replace implementation of hsearch() by one that scales.
Traditionally the hcreate() function creates a hash table that uses
chaining, using a fixed user-provided size. The problem with this
approach is that this often either wastes memory (table too big) or
yields bad performance (table too small). For applications it may not
always be easy to estimate the right hash table size. A fixed number
only increases performance compared to a linked list by a constant
factor.

This problem can be solved easily by dynamically resizing the hash
table. If the size of the hash table is at least doubled, this has no
negative on the running time complexity. If a dynamically sized hash
table is used, we can also switch to using open addressing instead of
chaining, which has the advantage of just using a single allocation for
the entire table, instead of allocating many small objects.

Finally, a problem with the existing implementation is that its
deterministic algorithm for hashing makes it possible to come up with
fixed patterns to trigger an excessive number of collisions. We can
easily solve this by using FNV-1a as a hashing algorithm in combination
with a randomly generated offset basis.

Measurements have shown that this implementation is about 20-25% faster
than the existing implementation (even if the existing implementation is
given an excessive number of buckets). Though it allocates more memory
through malloc() than the old implementation (between 4-8 pointers per
used entry instead of 3), process memory use is similar to the old
implementation as if the estimated size was underestimated by a factor
10. This is due to the fact that malloc() needs to perform less
bookkeeping.

Reviewed by:	jilles, pfg
Obtained from:	https://github.com/NuxiNL/cloudlibc
Differential Revision:	https://reviews.freebsd.org/D4644
2015-12-27 07:50:11 +00:00
Ed Schouten
459d04a5ee Let tsearch()/tdelete() use an AVL tree.
The existing implementations of POSIX tsearch() and tdelete() don't
attempt to perform any balancing at all. Testing reveals that inserting
100k nodes into a tree sequentially takes approximately one minute on my
system.

Though most other BSDs also don't use any balanced tree internally, C
libraries like glibc and musl do provide better implementations. glibc
uses a red-black tree and musl uses an AVL tree.

Red-black trees have the advantage over AVL trees that they only require
O(1) rotations after insertion and deletion, but have the disadvantage
that the tree has a maximum depth of 2*log2(n) instead of 1.44*log2(n).
My take is that it's better to focus on having a lower maximum depth,
for the reason that in the case of tsearch() the invocation of the
comparator likely dominates the running time.

This change replaces the tsearch() and tdelete() functions by versions
that create an AVL tree. Compared to musl's implementation, this version
is different in two different ways:

- We don't keep track of heights; just balances. This is sufficient.
  This has the advantage that it reduces the number of nodes that are
  being accessed. Storing heights requires us to also access all of the
  siblings along the path.

- Don't use any recursion at all. We know that the tree cannot 2^64
  elements in size, so the height of the tree can never be larger than
  96. Use a 128-bit bitmask to keep track of the path that is computed.
  This allows us to iterate over the same path twice, meaning we can
  apply rotations from top to bottom.

Inserting 100k nodes into a tree now only takes 0.015 seconds. Insertion
seems to be twice as fast as glibc, whereas deletion has about the same
performance. Unlike glibc, it uses a fixed amount of memory.

I also experimented with both recursive and iterative bottom-up
implementations of the same algorithm. This iterative top-down version
performs similar to the recursive bottom-up version in terms of speed
and code size.

For some reason, the iterative bottom-up algorithm was actually 30%
faster for deletion, but has a quadratic memory complexity to keep track
of all the parent pointers.

Reviewed by:	jilles
Obtained from:	https://github.com/NuxiNL/cloudlibc
Differential Revision:	https://reviews.freebsd.org/D4412
2015-12-22 18:12:11 +00:00
Hajimu UMEMOTO
b1f9559ae4 addrinfo.ai_family is an address family, not a protocol family.
PR:		162434
MFC after:	1 week
2015-12-20 15:18:50 +00:00
Hajimu UMEMOTO
2cff354f1a Add AI_V4MAPPED and AI_ALL support for getaddrinfo(3).
We need to change netdb.h to make it actually enabled.

PR:		198092
MFC after:	1 week
2015-12-18 18:08:53 +00:00
Eric van Gyzen
c70540ec67 resolver: preserve binary compatibility; reduce header pollution
In r289315, I added new fields to res_state.  This broke binary
backward compatibility.  It also broke some ports (and possibly
other code) by requiring the definition of time_t and struct timespec.

Fix these problems by moving the new fields into __res_state_ext.

Suggested by:	ume
Reviewed by:	ume
MFC after:	3 days
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D4472
2015-12-14 17:21:06 +00:00
Eric van Gyzen
d7acdd2f9b resolver: fix the build of some ports, broken by r289315
r289315 required time_t and struct timespec to be defined before
including <resolv.h>.  This broke the build of net-mgmt/sx, at least.

Include <sys/timespec.h> in resolv.h to fix this with minimal pollution.

Reported by:	Raphael Kubo da Costa <rakuco>
MFC after:	3 days
Sponsored by:	Dell Inc.
2015-12-08 16:09:48 +00:00
Bryan Drewery
d32e83c26d Move obscure lib/ installation of /usr/lib/include symlink to include/.
This avoids the need for an afterinstall: hook and a check for LIBRARIES_ONLY.
It also now respects INCLUDEDIR.

This came in r249484.

Sponsored by:	EMC / Isilon Storage Division
2015-12-04 03:18:02 +00:00
Bryan Drewery
a9f9ec2435 Replace ln -s calls with INSTALL_SYMLINK
Sponsored by:	EMC / Isilon Storage Division
2015-12-04 03:17:14 +00:00
Bryan Drewery
8e8319a68d Stop building vers.c in include/ and only build the needed osreldate.h.
Because of how osreldate.h was being built with newvers.sh, which always
spat out a vers.c dependent on SVN or git, the meta mode build was
considering osreldate.h to depend on the current git or SVN index.  This
would lead to entire tree rebuilds when modifying git's index.  There's
no reason to be generating vers.c here so just skip it.

While here, in mk-osreldate.sh rename PARAM_H to proper PARAMFILE (which
newvers.sh already has a default for) and remove unneeded export.

Sponsored by:	EMC / Isilon Storage Division
2015-11-25 19:10:59 +00:00
Bryan Drewery
dbf5bd502a META MODE: Fix changing what "MACHINE=host" means when computing dirdeps for include/.
The _SKIP_BUILD is used while computing DIRDEPS.  If MACHINE=host is passed in
then this logic was replacing 'MACHINE' with a literal value of the host arch,
which then caused the dirdeps graph to be wrong since it no longer had the
literal 'host' for any of include's dependencies.

This is a NOP currently since include/ is not usually built with MACHINE=host.

Sponsored by:	EMC / Isilon Storage Division
2015-11-18 21:39:58 +00:00
Simon J. Gerraty
948f327ee4 Rename META_MODE option to DIRDEPS_BUILD
This allows META_FILES option to be renamed META_MODE.
Also add META_COOKIE_TOUCH for use in targets that can benefit
from a cookie when in meta mode.

Differential Revision:	https://reviews.freebsd.org/D4153
Reviewed by:	bdrewery
2015-11-14 03:24:48 +00:00
Baptiste Daroussin
3e4f384ed2 Merge from head r290483 2015-11-07 11:02:33 +00:00
Pedro F. Giffuni
96a8bf8fbf Rename __sentinel to __null_sentinel
GCC 5 uses a conflicting __sentinel definition in include/c++/bits/stl_algo.h

Reported by:	matteo
2015-11-05 14:55:58 +00:00
Baptiste Daroussin
3c3feed41a Merge from head 2015-11-01 21:17:38 +00:00
Andrey A. Chernov
8b63538d89 Add _flags2 per jhb@ suggestion since no room left in _flags.
Rewrite O_APPEND flag checking using new __S2OAP flag.

MFC after:      3 weeks
2015-10-28 14:40:02 +00:00
Baptiste Daroussin
031c294c1d Merge from head 2015-10-19 11:51:10 +00:00
Bryan Drewery
aa92269e46 Add more SUBDIR_PARALLEL.
MFC after:	3 weeks
Sponsored by:	EMC / Isilon Storage Division
2015-10-15 22:55:08 +00:00
Eric van Gyzen
60b27ebb25 resolver: automatically reload /etc/resolv.conf
On each resolver query, use stat(2) to see if the modification time
of /etc/resolv.conf has changed.  If so, reload the file and reinitialize
the resolver library.  However, only call stat(2) if at least two seconds
have passed since the last call to stat(2), since calling it on every
query could kill performance.

This new behavior is enabled by default.  Add a "reload-period" option
to disable it or change the period of the test.

Document this behavior and option in resolv.conf(5).

Polish the man page just enough to appease igor.

https://lists.freebsd.org/pipermail/freebsd-arch/2015-October/017342.html

Reviewed by:	kp, wblock
Discussed with:	jilles, imp, alfred
MFC after:	1 month
Relnotes:	yes
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D3867
2015-10-14 14:26:44 +00:00
Baptiste Daroussin
f5dde0166d Commit log from Dragonfly:
FreeBSD extended ctypes to include numbers (e.g. isnumber()) but never
actually implemented it.  The isnumber() function was equivalent to the
isdigit() function in every case.

Now that DragonFly's ctype source files have number definitions, the
number ctype can finally be implemented.  It's given a new flag _CTYPE_N.
The isalnum() and iswalnum() functions have been changed to use this
flag rather than the _CTYPE_D digit flag.

While isalnum(), isnumber(), and their wide equivalents now return
different values in locale cases, the ishexnumber() and iswhexnumber()
functions are unchanged.  They are still aliases for isxdigit() and
iswxdigit().

Also change ctype.h for isdigit and isxdigit to use sbistype like the
other functions.

Obtained from:	dragonfly
2015-10-13 20:43:49 +00:00
Baptiste Daroussin
becbad1f6e Merge from head 2015-10-13 19:44:36 +00:00
Bryan Drewery
c364bbdfa3 Mute this cookie as well 2015-10-03 17:28:46 +00:00
Bryan Drewery
4af9d62a19 Avoid make compatibility mode issues with creating cookies from r287844 and r287848.
Also hide the cookie creation.

Suggested by:	imp, Daniel O'Connor
2015-10-03 16:09:55 +00:00
Bryan Drewery
df884b5ca7 META_MODE: Avoid command changing in 2nd build.
If the command to be ran changes then a rebuild is caused. Checking
exists(${DESTDIR}...) from make results in this on the 2nd and
possibly subsequent builds due to staging during build.  Avoid this
by always running the existence check in the make sh command.

Sponsored by:	EMC / Isilon Storage Division
2015-09-18 21:36:29 +00:00
Bryan Drewery
9c7aaa01b3 Similar to r287844, create 'symlinks' cookie in proper place with -j and META_MODE.
Sponsored by:	EMC / Isilon Storage Division
2015-09-16 04:27:12 +00:00
Bryan Drewery
a2fdfab008 Create 'copies' cookie in proper place in META_MODE.
With -j the cookie would be created in CURDIR/sys/teken rather than OBJDIR.

Sponsored by:	EMC / Isilon Storage Division
2015-09-16 04:07:39 +00:00
Baptiste Daroussin
23a32822d2 Merge from HEAD 2015-08-25 20:14:50 +00:00
Jason Evans
30db11dd7f Use bool rather than _Bool for C++ compatibility.
Submitted by:	Nikolai Lifanov
2015-08-19 18:32:12 +00:00
Jason Evans
c13244b92e Fix minor malloc regressions.
- Use _Bool rather than bool to resolve missing type errors in malloc_np.h.
- Fix malloc manual page #include documentation.
- Add *allocm manual pages to obsolete files.

Submitted by:	jbeich
2015-08-19 00:06:46 +00:00
Jason Evans
d0e79aa362 Update jemalloc to version 4.0.0. 2015-08-18 00:21:25 +00:00
Baptiste Daroussin
764a768e16 Merge from HEAD 2015-08-09 00:15:17 +00:00
Pedro F. Giffuni
5d0bef91b7 Use the __sentinel attribute.
Start using the gcc sentinel attribute, which can be used to
mark varargs function that need a NULL pointer to mark argument
termination, like execl(3).

Relnotes:	yes
2015-07-08 16:21:10 +00:00
Mariusz Zaborski
fd10995478 Add fdclose(3) function.
This function is equivalent to fclose(3) function except that it
does not close the underlying file descriptor.
fdclose(3) is step forward to make FILE structure private.

Reviewed by:	wblock, jilles, jhb, pjd
Approved by:	pjd (mentor)
Differential Revision:	https://reviews.freebsd.org/D2697
2015-07-04 16:42:14 +00:00
Simon J. Gerraty
2ef6d5a7b9 new depends 2015-06-16 23:37:19 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
bd831db65c Misc fixes from projects/bmake
Differential Revision:       D2748
Reviewed by: brooks imp
2015-06-11 21:13:05 +00:00
Simon J. Gerraty
5b381db8cc Remove NO_OBJ
For meta mode we will want objdirs.

Differential Revision:	D2748
Reviewed by:	brooks imp
2015-06-11 04:22:17 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Baptiste Daroussin
a822b64165 Remove clause 3 and 4 from the license
Obtained from:	NetBSD
2015-05-21 08:38:25 +00:00
Pedro F. Giffuni
ee90489bc4 Make use of GCC alloc_align attribute
This lets the compiler know about the alignment of pointers returned
by aligned_alloc(3), posix_memalign(3). and contigmalloc(9)

Currently this is only supported in recent gcc but we are ready to
use it if clang implements it.

Relnotes:	yes
2015-05-15 20:43:37 +00:00
Pedro F. Giffuni
d0e9981e39 No need for result_use_check attribute in reallocf(3). 2015-05-01 20:40:48 +00:00
Baptiste Daroussin
8f0baadaa0 Move reallocarray definition to the _BSD_VISIBLE block
Add the required __alloc_size attributes

Requested by:	pfg
2015-05-01 19:14:32 +00:00
Baptiste Daroussin
450dfafb15 Import reallocarray(3) from OpenBSD
Add a manpage for it, assign the copyright to the OpenBSD project on it since it
is mostly copy/paste from OpenBSD manpage.
style(9) fixes

Differential Revision:	https://reviews.freebsd.org/D2420
Reviewed by:	kib
2015-05-01 18:32:16 +00:00
Gleb Smirnoff
772e66a6fc Move ALTQ from contrib to net/altq. The ALTQ code is for many years
discontinued by its initial authors. In FreeBSD the code was already
slightly edited during the pf(4) SMP project. It is about to be edited
more in the projects/ifnet. Moving out of contrib also allows to remove
several hacks to the make glue.

Reviewed by:	net@
2015-04-16 20:22:40 +00:00
Tijl Coosemans
1243a98e38 Remove the const qualifier from iconv(3) to comply with POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv.html

Adjust all code that calls iconv.

PR:		199099
Exp-run by:	antoine
MFC after:	2 weeks
2015-04-15 09:09:20 +00:00
Pedro F. Giffuni
153cbcd657 Make use of gcc attributes in some standard include headers.
The `nonnull' attribute specifies that some function parameters should be
non-null pointers.  This is very useful as it helps the compiler generate
warnings on suspicious code and can also enable some small optimizations.

Also start using 'alloc_size' attribute in the allocator functions.

This is an initial step to better integrate our libc with the compiler:
these attributes are fully supported by clang and they are also useful
for the static analyzer.

Note that due to some bogus internal procedure in the way gcc ports
are built they may require updating if they were built before r280801.

Relnotes:		yes
Hinted by:		Android's bionic libc
Differential Revision:	https://reviews.freebsd.org/D2107
2015-04-06 01:39:16 +00:00
Pedro F. Giffuni
4b069c8287 Clean some spaces vs tabs.
No, this file doesn't conform with KNF at all.
2015-03-29 20:20:45 +00:00
Pedro F. Giffuni
28cdb3ee15 Temporarily revert 280458.
GCC is still carries an old version of cdefs.h which doesn't
accept multiple parameters for the nonnull attribute.

Since this issue probably affects many ports in the tree
we will revert it for now until gcc gets fixed.
2015-03-25 21:53:17 +00:00
Pedro F. Giffuni
1693a59a64 Clean sparse spaces. 2015-03-25 16:54:37 +00:00
Pedro F. Giffuni
512cd1357a Introduce nonnull attributes in the signal and pthread headers.
The `nonnull' attribute specifies that some function parameters should be
non-null pointers.  This is very useful as it helps the compiler generate
warnings on suspicious code and can also enable some small optimizations.
In clang this is also useful for the static analyzer.

While we could go on defining this all over the tree, it only
makes sense to annotate a subset of critical functions.

Hinted by:		Android's bionic libc
Differential Revision:	https://reviews.freebsd.org/D2101
2015-03-24 20:33:24 +00:00
Bryan Drewery
addf340932 Correct and clarify comment for __SMBF.
MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
2015-02-11 22:39:13 +00:00
Enji Cooper
7e4a2c2814 Sort the entries by build knob, then MACHINE_ARCH like other areas of the tree
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2015-02-04 11:48:33 +00:00
Enji Cooper
b6f503dde0 Clean up more usb related files when MK_USB == no when dealing with
manpages, libraries, and binaries

MFC after: 1 week
X-MFC with: r278135
Sponsored by: EMC / Isilon Storage Division
2015-02-04 11:43:19 +00:00
Jilles Tjoelker
b90eeb5fb4 Ensure #include <semaphore.h> is sufficient for using SEM_VALUE_MAX.
Discussed with:	pluknet
2015-01-31 16:39:26 +00:00
Enji Cooper
8b77741ea7 Make install cuse headers if MK_CUSE != no
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2015-01-25 05:15:06 +00:00
Poul-Henning Kamp
c05bafc566 Deorbit the IEEE-488/GPIB support. 2014-12-25 20:15:13 +00:00
Simon J. Gerraty
c0b2d894be update dependencies 2014-11-30 18:48:57 +00:00
Enji Cooper
0341ccf227 Clean up more usb related files when MK_USB == no when dealing with
manpages, libraries, and binaries
2014-11-26 21:18:52 +00:00
Enji Cooper
046cc7b93e Account for /usr/include/protocols/r{outed,whod}.h with their respective build knobs 2014-11-26 12:54:58 +00:00
Enji Cooper
12de3059d0 Fix some accidentally inverted logic 2014-11-26 12:49:37 +00:00
Enji Cooper
466046ec0d Conditionalize a number of components in the tree
- bootparamd
- bootpd
- finger/fingerd
- ftp/ftpd
- hastctl/hastd
- iscsid, et al
- rbootd
- talk/talkd
- tcpd, et al
- tftp/tftpd

Add src.conf entries for the various components and do a best effort
at adding components to tools/build/mk/OptionalObsoleteFiles.inc
2014-11-26 08:44:05 +00:00
Simon J. Gerraty
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Rui Paulo
6bd000838c Fix the build by installing acpi_hpet.h correctly.
Submitted by:	jase
MFC after:	1 week
2014-10-24 23:25:11 +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
Rui Paulo
3149cc9df6 HPET: create /dev/hpetN as a way to access HPET from userland.
In some cases, TSC is broken and special applications might benefit
from memory mapping HPET and reading the registers to count time.
Most often the main HPET counter is 32-bit only[1], so this only gives
the application a 300 second window based on the default HPET
interval.
Other applications, such as Intel's DPDK, expect /dev/hpet to be
present and use it to count time as well.

Although we have an almost userland version of gettimeofday() which
uses rdtsc in userland, it's not always possible to use it, depending
on how broken the multi-socket hardware is.

Install the acpi_hpet.h so that applications can use the HPET register
definitions.

[1] I haven't found a system where HPET's main counter uses more than
32 bit.  There seems to be a discrepancy in the Intel documentation
(claiming it's a 64-bit counter) and the actual implementation (a
32-bit counter in a 64-bit memory area).

MFC after:	1 week
Relnotes:	yes
2014-10-24 18:39:15 +00:00
Baptiste Daroussin
7cec355b9b Fix build with rpcgen using a recent (tested with gcc 4.9.1) GNU cpp 2014-10-09 06:58:33 +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
Pedro F. Giffuni
749cd43178 unistd: drop argument names from setpgrp(3) prototype.
They are useless and don't match the style of the header.
While here adjust the comment with tabs.

Suggested by:	kevinlo
2014-09-19 18:13:56 +00:00
Pedro F. Giffuni
d9446691c8 unistd: move setpgrp(2) to the __BSD_VISIBLE section
Our setpgrp(2) differs from the specified by POSIX, which
only has one argument, and is only meant for compatibility
with BSD.

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

Pointed-out in:	openbsd-tech (2014-09-16)
MFC after:	6 weeks
2014-09-18 17:18:42 +00:00
Ed Schouten
b58aba6b66 Roll back r271012 even more aggressively.
I've looked at the GCC sources and I now understand what's going wrong.
THe C11 keywords are simply nonexistent when using C++ mode. They are
marked as C-only in the parser. This is absolutely impractical for
multiple reasons:

- The C11 keywords do not conflict with C++ naming rules. They all start
  with _[A-Z]. There is no reason to make them C-only.

- It makes it practically impossible for people to use these keywords in
  C header files and expect them to work from within C++ sources.

As I said in my previous commit message: GCC is by far the weirdest
compiler that I've ever used.
2014-09-05 05:36:32 +00:00
Ed Schouten
62b7f85d47 Leave the C11 keywords alone when we have a recent version of GCC.
As GCC also gained support for the C11 keywords over time, we can patch
up <sys/cdefs.h> to not define these anymore. This has the advantage
that error messages for static assertions are printed natively and that
_Alignas() will work with even a type outside of C11 mode.

All C11 keywords are supported with GCC 4.7 and higher, with the
exception of _Thread_local and _Generic. These are only supported as of
GCC 4.9.
2014-09-03 09:35:38 +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
Ed Schouten
49891e45d2 Add lock annotations to the header files of our threading libraries.
This change extends all of the functions present in the <pthread.h> and
<threads.h> headers to have lock annotations. This will allow Clang to
warn about the following:

- Locking a function twice,
- Unlocking a function without a mutex being locked,
- Forgetting to unlock a mutex before returning,
- Destroying or reinitializing a mutex that is currenty locked,
- Using an unlocked mutex in combination with a condition variable.

Enabling these annotations already allowed me to catch a bug in one of
our userspace tools (r270749).
2014-09-01 18:34:30 +00:00
Alexander Kabaev
7935fd6ef1 Add guards to ptrdiff_t definition in include/stddef.h
Back in 2011 obrien has added the #define macro in sys/sys/stddef.h to
guard ptrdiff_t. Add similar protection to the identical code in
include/stddef.h.

Submitted by:   Mariusz Zaborski <oshogbo@FreeBSD.org>
MFC after:      1 week
2014-08-21 15:10:10 +00:00
Simon J. Gerraty
ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +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
e3c3754c06 We don't use these files. 2014-08-09 20:03:40 +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
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
1d717f206a Revert r268826:
The current ordering of this header is a feature as it
is more consistent with POSIX.
Also adding gratuitous newlines is not elegant.

Pointed out by:	bde
2014-07-18 16:21:15 +00:00
Pedro F. Giffuni
7bd26d4567 Minor sorting to match the NetBSD header
MFC after:	3 days
Obtained from:	NetBSD
2014-07-18 02:49:41 +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
Tijl Coosemans
dd98737278 Don't install GSS-API headers when the GSSAPI option has been disabled.
Some ports assume GSS-API is supported when they find the headers.

PR:		189156
Submitted by:	Garrett Cooper <yanegomi@gmail.com>
2014-06-13 10:08:18 +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
Hans Petter Selasky
fa0f6e62c6 Initial import of character device in userspace support for FreeBSD.
The CUSE library is a wrapper for the devfs kernel functionality which
is exposed through /dev/cuse . In order to function the CUSE kernel
code must either be enabled in the kernel configuration file or loaded
separately as a module. Currently none of the committed items are
connected to the default builds, except for installing the needed
header files. The CUSE code will be connected to the default world and
kernel builds in a follow-up commit.

The CUSE module was written by Hans Petter Selasky, somewhat inspired
by similar functionality found in FUSE. The CUSE library can be used
for many purposes. Currently CUSE is used when running Linux kernel
drivers in user-space, which need to create a character device node to
communicate with its applications. CUSE has full support for almost
all devfs functionality found in the kernel:
 - kevents
 - read
 - write
 - ioctl
 - poll
 - open
 - close
 - mmap
 - private per file handle data

Requested by several people. Also see "multimedia/cuse4bsd-kmod" in
ports.
2014-05-23 08:46:28 +00:00
Simon J. Gerraty
0a117278be Actually avoid stage_includes target 2014-05-16 16:21:17 +00:00
Simon J. Gerraty
1a682d2cea We want to use stage_includes as a hook, so use NO_STAGE_INCLUDES
in include/Makefile to suppress normal behavior
2014-05-16 14:47:18 +00:00
Simon J. Gerraty
a5e980ce95 use mv -f to avoid questions 2014-05-16 14:43:24 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Jilles Tjoelker
76902266ae include: Don't expose L_cuserid in strict C standard compliance mode.
L_cuserid is supposed to be exposed only for old POSIX, or in the default
(expose everything) environment.
2014-05-11 16:34:17 +00:00
Jilles Tjoelker
448f5f73dc include: Remove checks for __BSD_VISIBLE where redundant with __XSI_VISIBLE
or __POSIX_VISIBLE.

Whenever <sys/cdefs.h> sets __BSD_VISIBLE to non-zero, it also sets
__POSIX_VISIBLE and __XSI_VISIBLE to the newest version supported.

No functional change is intended.
2014-05-11 13:48:21 +00:00
Simon J. Gerraty
cc3f4b9965 Merge from head 2014-05-08 23:54:15 +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
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Jilles Tjoelker
160c0c65d7 langinfo.h: Hide YESSTR and NOSTR in strict POSIX mode.
YESSTR and NOSTR are obsolete and are only in old SUS.
2014-04-19 12:38:01 +00:00
David Chisnall
46cdc14062 Add support for some block functions that come from OS X. These are
intended to build with any C compiler.

Reviewed by:	pfg
MFC after:	3 weeks
2014-04-02 16:07:48 +00:00
Tijl Coosemans
0a4c54d606 Rename __wchar_t so it no longer conflicts with __wchar_t from clang 3.4
-fms-extensions.

MFC after:	2 weeks
2014-04-01 14:46:11 +00:00
Gleb Smirnoff
45c203fce2 Remove AppleTalk support.
AppleTalk was a network transport protocol for Apple Macintosh devices
in 80s and then 90s. Starting with Mac OS X in 2000 the AppleTalk was
a legacy protocol and primary networking protocol is TCP/IP. The last
Mac OS X release to support AppleTalk happened in 2009. The same year
routing equipment vendors (namely Cisco) end their support.

Thus, AppleTalk won't be supported in FreeBSD 11.0-RELEASE.
2014-03-14 06:29:43 +00:00
Gleb Smirnoff
2c284d9395 Remove IPX support.
IPX was a network transport protocol in Novell's NetWare network operating
system from late 80s and then 90s. The NetWare itself switched to TCP/IP
as default transport in 1998. Later, in this century the Novell Open
Enterprise Server became successor of Novell NetWare. The last release
that claimed to still support IPX was OES 2 in 2007. Routing equipment
vendors (e.g. Cisco) discontinued support for IPX in 2011.

Thus, IPX won't be supported in FreeBSD 11.0-RELEASE.
2014-03-14 02:58:48 +00:00
Jason Evans
f921d10f48 Update jemalloc to version 3.5.0. 2014-01-23 02:47:36 +00:00
Nathan Whitehorn
0894229871 Add a new flag to /etc/ttys: onifconsole. This is equivalent to "on" if the
device is an active kernel console and "off" otherwise. This is designed to
allow serial-booting x86 systems to provide a login prompt on the serial line
by default without providing one on all systems by default.

Comments and suggestions by:	grehan, dteske, jilles
MFC after:	1 month
2014-01-20 18:15:06 +00:00
Hiroki Sato
8785398f8a Replace Sun RPC license with a 3-clause BSD license. This license change
was approved in 2010 by Wim Coekaerts, Senior Vice President, Linux and
Virtualization at Oracle Corporation.
2013-12-09 04:26:50 +00:00
Aleksandr Rybalko
4874c0802c Install teken.h for userland.
Part of VT(9) project merge.
Reviewed by:	nwhitehorn
MFC_to_10_after:	re approval

Sponsored by:	The FreeBSD Foundation
2013-12-05 22:56:37 +00:00
Hiroki Sato
44443e425f Replace Sun Industry Standards Source License for Sun RPC code with a
3-clause BSD license as specified by Oracle America, Inc. in 2010.
This license change was approved by Wim Coekaerts, Senior Vice
President, Linux and Virtualization at Oracle Corporation.
2013-11-25 19:08:38 +00:00
Hiroki Sato
2e322d3796 Replace Sun RPC license in TI-RPC library with a 3-clause BSD license,
with the explicit permission of Sun Microsystems in 2009.
2013-11-25 19:04:36 +00:00
Hiroki Sato
7c5b23111c Add ICONV_{GET,SET}_ILSEQ_INVALID iconvctl. GNU iconv returns EILSEQ
when there is an invalid character in the output codeset while it is
valid in the input.  However, POSIX requires iconv() to perform an
implementation-defined conversion on the character.  So, Citrus iconv converts
such a character to a special character which means it is invalid in the
output codeset.

This is not a problem in most cases but some software like libxml2 depends
on GNU's behavior to determine if a character is output as-is or another form
such as a character entity (&#NNN;).
2013-11-25 01:26:06 +00:00
Peter Wemm
091b8336ae Attempt to move the POSIX iconv* symbols out of runtime linker space.
FreeBSD systems usually implemented this as a third party module and
our implementation hasn't played as nicely with the old way as it could
have.

To that end:
* Rename the iconv* symbols in libc.so.7 to have a __bsd_ prefix.
* Provide .symver compatability with existing 10.x+ binaries that
  referenced the iconv symbols. All existing binaries should work.
* Like on Linux/glibc systems, add a libc_nonshared.a to the ldscript
  at /usr/lib/libc.so.
* Move the "iconv*" wrapper symbols to libc_nonshared.a

This should solve the runtime ambiguity about which symbols resolve
to where.  If you compile against the iconv in libc, your runtime
dependencies will be unambiguous.

Old 9.x libraries and binaries will always resolve against their
libiconv.so.3 like they did on 9.x.  They won't resolve against libc.

Old 10.x binaries will be satisified by the .symver helpers.

This should allow ports to selectively compile against the libiconv
port if needed and it should behave without ambiguity now.

Discussed with:	 kib
2013-11-17 22:52:17 +00:00
Peter Wemm
912ce912e1 Remove the WITH_LIBICONV_COMPAT hack that seems to do more harm than
good.  This caused libc to spoof the ports libiconv namespace and
provide a colliding libiconv.so.3 to fool rtld.  This should have
been removed some time ago.
2013-11-03 19:04:57 +00:00
Sean Bruno
b68831134f Install include files for netpfil/pf when requested by the Makefile
Reviewed by:	glebius
2013-11-01 00:32:26 +00:00
Gleb Smirnoff
75bf2db380 Move new pf includes to the pf directory. The pfvar.h remain
in net, to avoid compatibility breakage for no sake.

The future plan is to split most of non-kernel parts of
pfvar.h into pf.h, and then make pfvar.h a kernel only
include breaking compatibility.

Discussed with:		bz
2013-10-27 16:25:57 +00:00
Tijl Coosemans
23bbf7fa70 Add a dummy statement to the beginning of the pthread_cleanup_pop() macro
to allow a call of the macro to be labelled as in:

label:
  pthread_cleanup_pop();

Reviewed by:	imp
MFC after:	3 days
2013-10-22 19:53:52 +00:00
Simon J. Gerraty
3caf0790a8 Merge head@256284 2013-10-13 02:35:19 +00:00
Simon J. Gerraty
43425d65d2 In meta mode touch targets like copies so we don't needlessly repeat them. 2013-10-12 23:37:47 +00:00
Ian Lepore
98c636be78 Set proper permissions on the generated osreldate.h file; a file readable
only by root can cause install problems, especially over nfs.

Submitted by:	jilles@
Approved by:	re (gjb)
2013-09-30 21:01:04 +00:00
Dag-Erling Smørgrav
56b72efe82 Remove BIND.
Approved by:	re (gjb)
2013-09-30 17:23:45 +00:00
Ian Lepore
0210509acd Allow the path to the system source directory to be passed in to
newvers.sh.  Pass it in from include/Makefile.  If it isn't passed in,
fall back to the old logic of using dirname $0.

Using dirname $0 does not yield the path to the script if it was
sourced in from another script in another directory; you end up with
the parent script's path.  That was causing newvers.sh to look one
level below the FreeBSD src/ directory when building osreldate.h and it
may find something like a git or svn repo there that has nothing to do
with FreeBSD.

PR:		174422
Approved by:	re ()
MFC after:	2 weeks
2013-09-28 16:39:46 +00:00
Nathan Whitehorn
36ddc86874 Prevent the set -e from mk-osreldate.sh from propagating into newvers.sh.
This would cause detection of old versions of SVN to cause fatal errors
instead of being caught and handled, which would make the build fail if
the tree had been checked out with an older version of SVN (e.g. 1.6).

Discussed with:	gjb
Approved by:	re (marius)
2013-09-28 16:25:20 +00:00
Ian Lepore
dd5f1297c6 Launch the bourne shell using "sh" rather than "${SHELL}", as the latter
may come in from the environment and reflect the user's interactive shell.
Using bare "sh" is the dominant pattern in existing makefiles.

MFC this together with r255775.

Approved by:	re ()
MFC after:	2 weeks
2013-09-23 00:04:36 +00:00
Ian Lepore
16b0ad07ab Launch the shell, passing it the path to the mk-osreldate script, rather
than launching the script directly and relying on #! to launch the shell.
This avoids problems when the source is mounted with the noexec flag.

MFC this together with r255775.

Approved by:	re (kib)
MFC after:	2 weeks
2013-09-22 19:15:24 +00:00
Ian Lepore
bfe5c479c0 Create a separate script to generate osreldate.h rather than sourcing
newvers.sh into a temporary subshell with inline make rules.

Using a separate script fixes a variety of problems, including establishing
the correct dependencies in the makefiles.  It also eliminates a problem
with the way newvers.sh uses `realpath $0`, because $0 expands differently
within a script sourced into a rule in a makefile depending on the version
of make and of /bin/sh being used.  The latter can cause build breakage in a
cross-build environment, and can also make it difficult to compile 10.0 on
older pre-10.0 systems.

PR:		160646 174422
Submitted by:	Garrett Cooper <yaneurabeya@gmail.com>
Approved by:	re (gjb)
MFC after:	2 weeks
2013-09-21 22:36:07 +00:00
Sean Bruno
22e3858c24 Assume that the -f argument is /dev/gpioc0 if it is not passed.
hrs@ provided this verison of the patch and showed me where all the needed
changes were to be made outside of gpioctl.c

Approved by:	re (hrs)
MFC after:	2 weeks
2013-09-17 11:48:47 +00:00
Simon J. Gerraty
d466a5b069 Merge head 2013-09-11 18:16:18 +00:00
David Chisnall
b49c0d5878 Fix the namespace pollution caused by iconv.h including stdbool.h
This broke any C89 ports that defined bool themselves, including things
like gcc, gtk, and so on.
2013-09-06 09:46:44 +00:00
Simon J. Gerraty
d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Pawel Jakub Dawidek
50079a51bb Implement fdclosedir(3) function, which is equivalent to the closedir(3)
function, but returns directory file descriptor instead of closing it.

Submitted by:	Mariusz Zaborski <oshogbo@FreeBSD.org>
Sponsored by:	Google Summer of Code 2013
2013-08-18 20:11:34 +00:00
Jilles Tjoelker
67560dcfb5 Add dup3(), based on F_DUP2FD and F_DUP2FD_CLOEXEC fcntls.
I removed functionality not proposed for POSIX in Austin group issue #411.
A man page (my own) and test cases will follow in later commits.

PR:		176233
Submitted by:	Jukka Ukkonen
2013-08-16 13:10:30 +00:00
Peter Wemm
0ff204bbd1 The iconv in libc did two things - implement the standard APIs, the GNU
extensions and also tried to be link time compatible with ports libiconv.
This splits that functionality and enables the parts that shouldn't
interfere with the port by default.

WITH_ICONV (now on by default) - adds iconv.h, iconv_open(3) etc.
WITH_LIBICONV_COMPAT (off by default) adds the libiconv_open etc API, linker
symbols and even a stub libiconv.so.3 that are good enough to be able
to 'pkg delete -f libiconv' on a running system and reasonably expect it
to work.

I have tortured many machines over the last few days to try and reduce
the possibilities of foot-shooting as much as I can.  I've successfully
recompiled to enable and disable the libiconv_compat modes, ports that use
libiconv alongside system iconv etc.  If you don't enable the
WITH_LIBICONV_COMPAT switch, they don't share symbol space.

This is an extension of behavior on other system.  iconv(3) is a standard
libc interface and libiconv port expects to be able to run alongside it on
systems that have it.

Bumped osreldate.
2013-08-13 07:15:01 +00:00
Jilles Tjoelker
65ba8dff5f Add mkostemp() and mkostemps().
These are like mkstemp() and mkstemps() but allow passing open(2) flags like
O_CLOEXEC.
2013-08-09 17:24:23 +00:00
Jilles Tjoelker
e45e1f2730 stdlib.h: Add correct POSIX version for POSIX extensions to C. 2013-07-05 14:16:04 +00:00
Andrey A. Chernov
476d9314d6 1) POSIX requires rand(3) return values to be in the [0, RAND_MAX] range,
but ACM formula we use have internal state (and return value) in the
[1, 0x7ffffffe] range, so our RAND_MAX (0x7fffffff) is never reached
because it is off by one, zero is not reached too.

Correct both RAND_MAX and rand(3) return value, shifting last one
to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffffffd(=new RAND_MAX)]
range.

2) Add a checks for not overflowing on too big seeds. It may happens on
the machines, where sizeof(unsigned int) > 32 bits.

Reviewed by:    bde [1]
MFC after:      2 weeks
2013-07-03 21:21:54 +00:00
Peter Wemm
19dfd82d81 Replace the #define for "iconv" so it is for the function name instead of
a macro with parameters.  Remove a __DECONST hack and add consts instead
for gnu libiconv API compatability.  This makes it work with things like
devel/boost-libs that expects to use "iconv" as though it were a pointer.
2013-07-03 07:03:19 +00:00
Hiroki Sato
3fbceebb4a Fix gssapi/gssapi_krb5.h after Heimdal 1.5.1 import.
Reviewed by:	dfr
2013-06-30 07:46:22 +00:00
Davide Italiano
237abf0c56 - Trim an unused and bogus Makefile for mount_smbfs.
- Reconnect with some minor modifications, in particular now selsocket()
internals are adapted to use sbintime units after recent'ish calloutng
switch.
2013-06-28 21:00:08 +00:00
Hiroki Sato
268a55bc98 - Add vnode-backed swap space specification support. This is enabled when
device names "md" or "md[0-9]*" and a "file" option are specified in
  /etc/fstab like this:

  md    none    swap    sw,file=/swap.bin       0       0

- Add GBDE/GELI encrypted swap space specification support, which
  rc.d/encswap supported.  The /etc/fstab lines are like the following:

  /dev/ada1p1.bde       none    swap    sw      0       0
  /dev/ada1p2.eli       none    swap    sw      0       0

  .eli devices accepts aalgo, ealgo, keylen, and sectorsize as options.

  swapctl(8) can understand an encrypted device in the command line
  like this:

  # swapctl -a /dev/ada2p1.bde

- "-L" flag is added to support "late" option to defer swapon until
  rc.d/mountlate runs.

- rc.d script change:

    rc.d/encswap -> removed
    rc.d/addswap -> just display a warning message if $swapfile is defined
    rc.d/swap1 -> renamed to rc.d/swap
    rc.d/swaplate -> newly added to support "late" option

These changes alleviate a race condition between device creation/removal
and swapon/swapoff.

MFC after:	1 week
Reviewed by:	wblock (manual page)
2013-06-27 18:28:45 +00:00
Ed Schouten
06bee445d4 Move <stdatomic.h> into sys/sys/.
This will allow us to use C11 atomics in kernelspace, although it will
need to be included as <sys/stdatomic.h>.
2013-06-01 21:02:26 +00:00
Ed Schouten
636d7fea2f Fix misspelling of structure field name. 2013-05-31 20:07:26 +00:00
David Schultz
e4afa19c33 I'm happy to finally commit stephen@'s implementations of cacos,
cacosh, casin, casinh, catan, and catanh. Thanks to stephen@ and bde@
for working on these.

Submitted by:	stephen@
Reviewed by:	bde
2013-05-30 04:49:26 +00:00
Marcel Moolenaar
9dfba391d6 Make the malloc(3) family of functions weak and make their non-weak
implementations visible for use by applications. The functions $F that
are now weak symbols are:
	allocm, calloc, dallocm, free, malloc, malloc_usable_size,
	nallocm, posix_memalign, rallocm, realloc, sallocm

The non-weak implementations of $F are exported as __$F.

Submitted by:	stevek@juniper.net
Reviewed by:	jasone@, kib@
Approved by:	jasone@ (jemalloc)
Obtained from:	juniper Networks, Inc
2013-05-25 18:59:11 +00:00
Ed Schouten
e814330de1 Add C11 macros CMPLX(), CMPLXF() and CMPLXL().
Clang allows us to initialize complex numbers using an array
initializer, casted to a complex type. GCC has a builtin called
__builtin_complex().
2013-05-25 18:55:55 +00:00
Ed Schouten
74b6b2bb99 Fix <uchar.h> in for C++11.
It turns out that in C++11, char16_t and char32_t are built-in types;
language keywords. Just fix this by putting traditional _*_T_DECLARED
blocks around the definitions. We'll just predefine these in
<sys/_types.h>.

This also opens up the possibility to define char16_t in other header
files, if ever needed (e.g. if we would gain a <ctype.h> for
char16_t/char32_t).
2013-05-25 16:58:12 +00:00
Ed Schouten
553f17daf9 Add proper prerequisites for even two more headers.
Spotted by:   http://hacks.owlfolio.org/header-survey/
2013-05-21 21:50:11 +00:00
Ed Schouten
6ed0f50f78 Allow certain headers to be included more easily.
Spotted by:	http://hacks.owlfolio.org/header-survey/
2013-05-21 21:20:10 +00:00
Ed Schouten
50c77c6e8b Add <uchar.h>.
The <uchar.h> header, part of C11, adds a small number of utility
functions for 16/32-bit "universal" characters, which may or may not be
UTF-16/32. As our wchar_t is already ISO 10646, simply add light-weight
wrappers around wcrtomb() and mbrtowc().

While there, also add (non-yet-standard) _l functions, similar to the
ones we already have for the other locale-dependent functions.

Reviewed by:	theraven
2013-05-21 19:59:37 +00:00
Jilles Tjoelker
dc570d5e56 Add pipe2() system call.
The pipe2() function is similar to pipe() but allows setting FD_CLOEXEC and
O_NONBLOCK (on both sides) as part of the function.

If p points to two writable ints, pipe2(p, 0) is equivalent to pipe(p).

If the pointer is not valid, behaviour differs: pipe2() writes into the
array from the kernel like socketpair() does, while pipe() writes into the
array from an architecture-specific assembler wrapper.

Reviewed by:	kan, kib
2013-05-01 22:42:42 +00:00
Ed Schouten
5a1d14ca78 Enable improved <tgmath.h> for Clang even when not using C11.
By using __has_extension(c_generic_selections), we can explicitly test
whether we're dealing with a version of Clang that supports _Generic().
That way we can use the improved <tgmath.h> code, even when not using
-std=c11. This massively reduces the compilation time when invoking
these functions.
2013-04-27 21:18:34 +00:00
Eitan Adler
d001beb260 - sl_find does not modify 'name'
- make the prototype of sl_find match NetBSD

Reviewed by:	jilles
Approved by:	cperciva (mentor)
MFC After:	3 days
2013-04-23 13:03:03 +00:00
Simon J. Gerraty
fb0cb80846 Add stage-install.sh so we can do away with the need to have
$STAGE_OBJTOP/include for src/include.
2013-04-19 18:45:03 +00:00
Gabor Kovesdan
a2098fea6d - Correct mispellings of the word necessary
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de> (via private mail)
2013-04-17 11:42:40 +00:00
Simon J. Gerraty
69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Ed Schouten
7c99b6764e Add static/const keywords to the arrays.
This theoretically allows a compiler to optimize (parts of) the array
away if unused.

While there, make the array size implicit and use a _Static_assert() to
ensure that the definition matches up with the number of elements in the
list.
2013-04-09 16:16:34 +00:00
John Baldwin
9240031ac6 Add an implementation of open_memstream() and open_wmemstream(). These
routines provide write-only stdio FILE objects that store their data in a
dynamically allocated buffer.  They are a string builder interface somewhat
akin to a completely dynamic sbuf.

Reviewed by:	bde, jilles (earlier versions)
MFC after:	1 month
2013-02-27 19:50:46 +00:00
Simon J. Gerraty
ea7315fe66 Cleanup 2013-02-17 23:46:17 +00:00
Simon J. Gerraty
b068afb4a2 Avoid problems with read-only osreldate.h 2013-02-16 01:36:14 +00:00
Simon J. Gerraty
ddafe92543 ftpd needs telnet.h so install it regardless 2013-02-16 01:32:03 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Niclas Zeising
4e95969e06 FreeBSD uses #if __BSD_VISIBLE to hide non-standard functions, fix this.
Noticed by:	kib
Approved by:	kib
2013-02-14 19:26:58 +00:00
Niclas Zeising
d902844bbd Add strchrnul(), a GNU function similar to strchr(), except that it returns
a pointer to the end of the string, rather than NULL, if the character was
not found.

Approved by:	theraven
2013-02-13 15:46:33 +00:00
David E. O'Brien
d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
John Baldwin
0895e9c70c Install <dev/agp/agpreg.h> and <dev/pci/pcireg.h> as userland headers
in /usr/include.

MFC after:	2 weeks
2013-02-05 18:55:09 +00:00