dragonfly.git
15 years agosys/types.h: Add protection of typedefs
Thomas Nikolajsen [Tue, 7 Apr 2009 20:58:26 +0000 (22:58 +0200)]
sys/types.h: Add protection of typedefs

missing in 9d66746cf7a1da0544550266a1c5cb53e776aa01

15 years agopw(8): setgrent()'s return type is void.
Sascha Wildner [Tue, 7 Apr 2009 16:59:53 +0000 (18:59 +0200)]
pw(8): setgrent()'s return type is void.

15 years agonewsyslog(8): Silence warning.
Sascha Wildner [Tue, 7 Apr 2009 16:59:17 +0000 (18:59 +0200)]
newsyslog(8): Silence warning.

15 years agosh(1): Deconstify unsetvar()'s argument when passing it to change_env().
Sascha Wildner [Tue, 7 Apr 2009 16:58:08 +0000 (18:58 +0200)]
sh(1): Deconstify unsetvar()'s argument when passing it to change_env().

15 years agoInclude <string.h> instead of <strings.h> in various places.
Sascha Wildner [Tue, 7 Apr 2009 16:56:23 +0000 (18:56 +0200)]
Include <string.h> instead of <strings.h> in various places.

15 years agoAdd missing MLINKS for {getchar,putchar}_unlocked functions
Stathis Kamperis [Tue, 7 Apr 2009 11:25:40 +0000 (11:25 +0000)]
Add missing MLINKS for {getchar,putchar}_unlocked functions

15 years agoReplace all casts of NULL to something with NULL.
Sascha Wildner [Mon, 6 Apr 2009 12:52:46 +0000 (14:52 +0200)]
Replace all casts of NULL to something with NULL.

15 years ago<sys/un.h>: #include <sys/file.h> for struct file.
Sascha Wildner [Mon, 6 Apr 2009 00:19:59 +0000 (02:19 +0200)]
<sys/un.h>: #include <sys/file.h> for struct file.

15 years agoindent(1): Sync with FreeBSD and raise WARNS to 6.
Sascha Wildner [Sun, 5 Apr 2009 23:45:19 +0000 (01:45 +0200)]
indent(1): Sync with FreeBSD and raise WARNS to 6.

15 years agoGenerally use NULL instead of explicitly casting 0 to some pointer type (part2).
Sascha Wildner [Sun, 5 Apr 2009 22:52:17 +0000 (00:52 +0200)]
Generally use NULL instead of explicitly casting 0 to some pointer type (part2).

15 years agoGenerally use NULL instead of explicitly casting 0 to some pointer type.
Sascha Wildner [Sun, 5 Apr 2009 20:33:01 +0000 (22:33 +0200)]
Generally use NULL instead of explicitly casting 0 to some pointer type.

15 years agoUse NULL instead of 0 in various places.
Sascha Wildner [Sun, 5 Apr 2009 20:31:26 +0000 (22:31 +0200)]
Use NULL instead of 0 in various places.

15 years agogetnetgrent(3): Improve markup.
Sascha Wildner [Sun, 5 Apr 2009 20:28:37 +0000 (22:28 +0200)]
getnetgrent(3): Improve markup.

15 years agosys/dev/usbmisc/Makefile: Remove duplicate entry.
Sascha Wildner [Sun, 5 Apr 2009 20:09:15 +0000 (22:09 +0200)]
sys/dev/usbmisc/Makefile: Remove duplicate entry.

15 years agoBump libc's version and __DragonFly_version for recent changes made.
Peter Avalos [Mon, 23 Mar 2009 02:19:11 +0000 (16:19 -1000)]
Bump libc's version and __DragonFly_version for recent changes made.

15 years agoClean up sysconf and associated headers.
Peter Avalos [Sat, 4 Apr 2009 05:23:27 +0000 (05:23 +0000)]
Clean up sysconf and associated headers.

* Fixes for amd64.

* Implement more keys.

* Namespace cleanups for the include files.  Move definitions that are
implemented in userspace from sys/unistd.h to unistd.h.

* Try to avoid using sysctl and just provide the constants direct.

Obtained-from: FreeBSD

15 years agoFix some namespace issues with grp.h and pwd.h.
Peter Avalos [Sun, 22 Mar 2009 21:47:29 +0000 (11:47 -1000)]
Fix some namespace issues with grp.h and pwd.h.

* [1] endpwent, getpwent, setgrent, and setpwent are XSI extensions.

* Change setgrent's prototype to match SuS.

* SuS requires that gid_t be defined in grp.h and pwd.h, and uid_t be in
  pwd.h.

[1] Obtained-from: FreeBSD

15 years agoRevert "Temporary hack out reentrant user database functions."
Peter Avalos [Sun, 22 Mar 2009 21:31:06 +0000 (11:31 -1000)]
Revert "Temporary hack out reentrant user database functions."

This reverts commit 75ce8d9fc3ccabbd5bd15bcf79ab1e7da8a5b4cb.

15 years agoSync ttyname with FreeBSD:
Peter Avalos [Mon, 16 Mar 2009 02:56:50 +0000 (16:56 -1000)]
Sync ttyname with FreeBSD:

* SuS says ttyname_r should return an int, so do that.

* Use devname(3) instead of rolling our own code.

* Simplify the threaded/unthreaded stuff.

15 years agoSync times() with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 11:16:52 +0000 (01:16 -1000)]
Sync times() with FreeBSD:

* The times(3) function returns the number of CLK_TCKs since the
startup time, not since the UNIX Epoch.

* Make the returnvalue of times(3) insensitive to changes in wall-clock.

15 years agotime() C99 compliance:
Peter Avalos [Sun, 15 Mar 2009 11:09:48 +0000 (01:09 -1000)]
time() C99 compliance:

* time() always sets its return value in both places (if present),
even on error.

Obtained-from: FreeBSD

15 years agoAdd a tcgetsid() function that returns session id.
Peter Avalos [Sun, 15 Mar 2009 11:01:05 +0000 (01:01 -1000)]
Add a tcgetsid() function that returns session id.

Obtained-from: FreeBSD

15 years agoSync syslogd with FreBSD:
Peter Avalos [Sun, 15 Mar 2009 10:28:51 +0000 (00:28 -1000)]
Sync syslogd with FreBSD:

* Add a flag, -T, that tells syslogd to always replace the timestamp on
messages from the network.  This option lets us replace timestamps that
are correctly formatted but wrong.

* Allow comment to be placed at the end of a configuration line.

* Add a -8 switch to syslogd to prevent it from mangling 8-bit data.

* Open ctty in non-blocking mode to avoid hangs during open and close.

* Handle "*" as a priority properly.

* Dynamically determine length vs. hardcoding it.

* Free the previous message buffer (f_prevline) only after logging all
the messages and just before the process exit.  Also check f_prevline for
NULL before using it.

* Add the ability to log to an arbitrary udp port as well as the
standard syslog port.

* Currently, if writing out a log entry fails, we unlink that log entry
from our internal list of logfiles. So if writev(2) fails for potentially
transient errors like ENOSPC, syslogd requires a restart, even if the
filesystem has purged.  This change allows syslogd to ignore ENOSPC
space errors, so that when the filesystem is cleaned up, syslogd will
automatically start logging again without requiring the reset.
This makes syslogd(8) a bit more reliable.

* Add -C option which tells syslogd(8) to create log files if they don't
exist.

* Add cases for ENOBUFS and ENETDOWN. We need to make sure that we
catch all transient errors. This fixes situations where transient
error conditions such as network interfaces losing carrier signals
or the system running out of mbufs would result in the permanent
removal of forwarding syslog messages.

* Add -S option which allows to change the pathname of the privileged
socket /var/run/logpriv.

* Check that supplied facility is not bigger than LOG_NFACILITIES.

* Allow ':' and '%' in hostname specifications so that we can specify
IPv6 addresses and scope IDs.

* Protect against local flooder of /var/run/log. Do not loop forever in
syslog(3) if we are a priveleged program (sshd, su, etc.).

  - Make syslogd open an additional socket /var/run/logpriv, with 0600
    permissions.
  - In libc, try to use this socket.
  - Do not loop forever if we are using this socket

* Use stailqueue for sockets instead of socket buffer. Thus remove
limit for 20 sockets.

* Add possibility to specify file mode for sockets created with '-l'.

* Check that socket name in '-l' is absolute.

* Make syslog(3) thread safe.

15 years agoSimplify the return value of sysctlnametomib.
Peter Avalos [Sun, 15 Mar 2009 09:04:16 +0000 (23:04 -1000)]
Simplify the return value of sysctlnametomib.

Obtained-from: FreeBSD

15 years agoWARNS: Add a prototype for __sysctl.
Peter Avalos [Sun, 15 Mar 2009 08:58:26 +0000 (22:58 -1000)]
WARNS: Add a prototype for __sysctl.

Obtained-from: FreeBSD

15 years agoSync stringlist with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 08:06:53 +0000 (22:06 -1000)]
Sync stringlist with FreeBSD:

* Fix a few namespace issues concerning err().

* sl_add returns an int now.

* Fix some whitespace issues in stringlist.h.

15 years agoReduce setproctitle's memory footprint on libc.
Peter Avalos [Sun, 15 Mar 2009 07:45:18 +0000 (21:45 -1000)]
Reduce setproctitle's memory footprint on libc.

Obtained-from: FreeBSD

15 years agoSync setmode(3) with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 04:20:21 +0000 (18:20 -1000)]
Sync setmode(3) with FreeBSD:

* Use correct error detection of realloc failure

* strtol negative return check

* use strtol to validate string instead of rolling our own
validation code

* terminate the command sequence correctly

15 years agoSync popen(3) with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 03:32:32 +0000 (17:32 -1000)]
Sync popen(3) with FreeBSD:

* Convert popen()'s `pidlist' to a SLIST, for consistency.

* Protect pidlist with a mutex to avoid a race causing a duplicate
free() when the same pipe FILE is pclosed()'d in different threads,
and to avoid corrupting the linked list when adding or removing
items.

15 years agoSync sys/queue.h with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 06:58:33 +0000 (20:58 -1000)]
Sync sys/queue.h with FreeBSD:

* Introduce REMOVE_NEXT() macro's for SLIST and STAILQ.

* Add sanity checking for QUEUE(3) TAILQs and LISTs under
INVARIANTS.  Races may lead to list corruption, which can be
difficult to unravel in a post-mortem analysis.  These checks verify
that the prev and next pointers are consistent when inserting or
removing elements, thus catching any corruption earlier.

* Use TRASHIT to break LIST and SLIST link pointers on element removal.

* Add more _FOREACH_MUTABLEs. Note: FreeBSD and NetBSD call these _SAFE,
but _MUTABLE is a better name, so that's what we're using.

* Add a macro for SLIST traversal 'SLIST_FOREACH_PREVPTR',
this macro keeps a pointer to the previous element's next
pointer to allow for search and O(1) removal.

* Remove CIRCLEQs and replace them with TAILQs.

15 years agoinitgroups(): Remove unneeded includes and use gid_t.
Peter Avalos [Sun, 15 Mar 2009 02:43:29 +0000 (16:43 -1000)]
initgroups(): Remove unneeded includes and use gid_t.

15 years agoSync glob(3) with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 02:31:59 +0000 (16:31 -1000)]
Sync glob(3) with FreeBSD:

* Change int to size_t where appropriate.

* Don't reuse *pl to skip [], it is already used for {} parts in the
loop above.

* Add support for multibyte characters.

15 years agogetttyent(3) fixes from FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 01:40:26 +0000 (15:40 -1000)]
getttyent(3) fixes from FreeBSD:

* In getttyent(3), if /etc/ttys doesn't end in a newline, don't
freak out and keep trying to expand the buffer until realloc()
fails.

* Move initialization above point of first possible reference to
avoid overwriting ty_status values set from the 'type' field.

* Fix the NAME section making whatis(1) happy in particular.

15 years agoSync getnetgrent with FreeBSD:
Peter Avalos [Tue, 10 Mar 2009 08:30:28 +0000 (22:30 -1000)]
Sync getnetgrent with FreeBSD:

* Fix innetgr() returning false positives and negatives when reverse
netgroup matching is used.

* Remember to reset nextgrp in getnetgrent(), so that subsequent calls
to getnetgrent() doesn't return bogus information.

15 years agoSync gethostname() with FreeBSD:
Peter Avalos [Tue, 10 Mar 2009 07:54:43 +0000 (21:54 -1000)]
Sync gethostname() with FreeBSD:

* Change gethostname() to set errno to ENAMETOOLONG instead of ENOMEM
when the buffer is not long enough to hold the current host name.
POSIX does not standardize error returns for gethostname(), so it
doesn't matter which one we use, but ENAMETOOLONG is at least a little
more intuitive.

* Update prototype to match SuS (int->size_t).

15 years agoSync getcap() with FreeBSD:
Peter Avalos [Tue, 10 Mar 2009 06:27:21 +0000 (20:27 -1000)]
Sync getcap() with FreeBSD:

* Expand contractions and fix sentence breaks.

* In cgetmatch(3), return -1 if a NULL or 0-length name parameter is
  used.  This prevents lpd from hanging at boot with certain (legal)
  printcap entries.

* Sprinkle some const.

15 years agoIncrease "max" to a more reasonable maximum in getbsize.
Peter Avalos [Sat, 7 Mar 2009 08:52:26 +0000 (03:52 -0500)]
Increase "max" to a more reasonable maximum in getbsize.

Obtained-from: FreeBSD

15 years agoSync fts(3) with FreeBSD.
Peter Avalos [Fri, 27 Feb 2009 08:26:46 +0000 (03:26 -0500)]
Sync fts(3) with FreeBSD.

Here's some of the relevant commit logs from FreeBSD:

FTSENT now avoids the use of the struct hack, thereby allowing future
extensions to the structure (e.g., for extended attributes) without
rebreaking the ABI.  FTSENT now contains a pointer to the parent stream,
which fts_compar() can then take advantage of, avoiding the undefined
behavior previously warned about.  As a consequence of this change, the
prototype of the comparison function passed to fts_open() has changed
to reflect the required amount of constness for its use.  All callers
in the tree are updated to use the correct prototype.

Comparison functions can now make use of the new parent pointer to
access the new stream-specific private data pointer, which is intended
to assist creation of reentrant library routines which use fts(3)
internally.

The FTS_NOSTAT option is an optimisation that reduces the number
of stat(2) calls by keeping an eye of the number of links a directory
has. It assumes that each subdirectory will have a hard link to its
parent, to represent the ".." node, and stops calling stat(2) when
all links are accounted for in a given directory.

This assumption is really only valid for UNIX-like filesystems: A
concrete example is NTFS. The NTFS "i-node" does contain a link
count, but most/all directories have a link count between 0 and 2
inclusive. The end result is that find on an NTFS volume won't
actually traverse the entire hierarchy of the directories passed
to it. (Those with a link count of two are not traversed at all)

The fix checks the "UFSness" of the filesystem before enabling the
optimisation.

In fts_build(), if we try to chdir and fail (e.g. due to lack of search
permission), try to continue in FTS_DONTCHDIR mode.  Of course this
won't work for long paths, but we can't descend more than one pathname
component beyond the directory anyway if we lack search permission.

Our fts(3) API, as inherited from 4.4BSD, suffers from integer
fields in FTS and FTSENT structs being too narrow.  In addition,
the narrow types creep from there into fts.c.  As a result, fts(3)
consumers, e.g., find(1) or rm(1), can't handle file trees an ordinary
user can create, which can have security implications.

Fix a file descriptor leak.

15 years agoAdd getfstab(3) and setfstab(3).
Peter Avalos [Thu, 26 Feb 2009 10:47:37 +0000 (05:47 -0500)]
Add getfstab(3) and setfstab(3).

* Use PATH_FSTAB instead of hard-coded value.
* Change function name in dump(8) that was conflicting.

Obtained-from: FreeBSD

15 years agoReplace frexp(3) with MI code and add a frexpl(3) function to libm.
Peter Avalos [Thu, 26 Feb 2009 10:19:26 +0000 (05:19 -0500)]
Replace frexp(3) with MI code and add a frexpl(3) function to libm.

Obtained-from: FreeBSD

15 years agoMake FLT_ROUNDS reflect the dynamic rounding mode and use correct values for LDBL_*.
Peter Avalos [Fri, 27 Feb 2009 02:38:59 +0000 (21:38 -0500)]
Make FLT_ROUNDS reflect the dynamic rounding mode and use correct values for LDBL_*.

Obtained-from: FreeBSD

15 years agoSync fnmatch(3) with FreeBSD.
Peter Avalos [Thu, 26 Feb 2009 08:21:07 +0000 (03:21 -0500)]
Sync fnmatch(3) with FreeBSD.

* Define FNM_NOSYS iaw SUS.

* Document the missing portions of IEEE Std. 1003.2.

* Add support for multibyte characters.

15 years agoSync fmtcheck(3) with FreeBSD, teaching it some new flags and args.
Peter Avalos [Thu, 26 Feb 2009 07:32:43 +0000 (02:32 -0500)]
Sync fmtcheck(3) with FreeBSD, teaching it some new flags and args.

15 years agoAdd posix_spawn() and posix_spawnp().
Peter Avalos [Sun, 15 Feb 2009 20:46:03 +0000 (15:46 -0500)]
Add posix_spawn() and posix_spawnp().

Also add execvP() which takes the search path as an argument.

Obtained-from: FreeBSD

15 years agoAdd a few new errnos and improve documentation.
Peter Avalos [Sat, 14 Feb 2009 23:11:36 +0000 (18:11 -0500)]
Add a few new errnos and improve documentation.

Some of these aren't used, but are required by POSIX.

Obtained-from: FreeBSD

15 years agoFix a few namespace issues in err.c.
Peter Avalos [Sat, 14 Feb 2009 19:48:33 +0000 (14:48 -0500)]
Fix a few namespace issues in err.c.

While I'm here, use sysexits in examples in the manual page.

Obtained-from: FreeBSD

15 years agoSync daemon(3) with FreeBSD:
Peter Avalos [Fri, 13 Feb 2009 22:37:49 +0000 (17:37 -0500)]
Sync daemon(3) with FreeBSD:

* Prevent abnormal termination of a child daemon process when created
by a parent that is a session leader (e.g., login shell) by ignoring
SIGHUP in before calling fork(2) and then restoring SIGHUP's action
after setsid(3).

* Merge some updates and markup fixes from OpenBSD for the manual page.

15 years agoSync confstr(3) with FreeBSD:
Peter Avalos [Fri, 13 Feb 2009 21:40:06 +0000 (16:40 -0500)]
Sync confstr(3) with FreeBSD:

* Support SUS "programming environment".
* confstr() returns compile-time constants.  Don't use sysctl to get
  the value of _PATD_STDPATH when we can just get it directly.

15 years agoSync assert with FreeBSD:
Peter Avalos [Fri, 13 Feb 2009 18:43:06 +0000 (13:43 -0500)]
Sync assert with FreeBSD:

* Change __assert() function to print failing function name.

* Make the output from assert() look more like the example in the C99
standard.

15 years agoSync arc4random with FreeBSD:
Peter Avalos [Fri, 13 Feb 2009 06:15:48 +0000 (01:15 -0500)]
Sync arc4random with FreeBSD:

* Add locking.

* Automatically re-stir

* Implement _buf() and _uniform() functions.

* Eliminate the arc4_stream arg since there's only 1 that's possible.

15 years agoFix format strings and a spelling errors.
Peter Avalos [Sun, 8 Feb 2009 16:45:31 +0000 (11:45 -0500)]
Fix format strings and a spelling errors.

Obtained-from: FreeBSD

15 years agoUse pread/pwrite instead of lseek followed by read/write.
Peter Avalos [Sun, 8 Feb 2009 16:41:07 +0000 (11:41 -0500)]
Use pread/pwrite instead of lseek followed by read/write.

Obtained-from: FreeBSD

15 years agoFix a sizeof error in __bt_put.
Peter Avalos [Sun, 8 Feb 2009 16:38:00 +0000 (11:38 -0500)]
Fix a sizeof error in __bt_put.

memmove() was used on pointers to size_ts, but only
sizeof(u_int32_t) bytes where copied.

Obtained-from: FreeBSD

15 years agoWhitespace cleanup.
Peter Avalos [Sun, 8 Feb 2009 16:32:21 +0000 (11:32 -0500)]
Whitespace cleanup.

15 years agoAdd a __printflike.
Peter Avalos [Sun, 8 Feb 2009 16:29:01 +0000 (11:29 -0500)]
Add a __printflike.

Obtained-from: FreeBSD

15 years agoDon't clobber CFLAGS.
Peter Avalos [Sun, 8 Feb 2009 16:27:03 +0000 (11:27 -0500)]
Don't clobber CFLAGS.

Obtained-from: FreeBSD

15 years agoSync libc/gmon with FreeBSD:
Peter Avalos [Tue, 3 Feb 2009 14:20:30 +0000 (09:20 -0500)]
Sync libc/gmon with FreeBSD:

* asm -> __asm
* Change warnx(foo, strerror()) to warn().
* Fix some format strings.
* Mark some statements that should probably use atomic ops.

15 years agoSync lib/net with FreeBSD:
Peter Avalos [Mon, 2 Feb 2009 07:19:33 +0000 (02:19 -0500)]
Sync lib/net with FreeBSD:

* Add a byteorder.9 manual page.
* Remove the addr2ascii and ascii2addr functions.  They aren't used in
  the tree, and there's other functions that are more generic and
  appropriate.
* Fix a few style issues.
* Add and document ether_ntoa_r() and ether_aton_r() functions, which
  accept passed storage buffers rather than using static storage.
  Reimplement ether_ntoa() and ether_aton() in terms of these functions.
  These variants are thread-safe.
* Document that AI_ALL and AI_V4MAPPED flags are currently not supported.
* Add a SIOCGIFINDEX ioctl, which returns the index of a named interface.
  Use this ioctl in if_nametoindex(3) to use network aliases.
* Add restrict qualifier where needed.
* Add inet_ntoa_r() - a re-entrant function of inet_ntoa.
* Note that inet6_option_space.3 and inet6_rthdr_space.3 functions are
  deprecated in favor of inet6_opt_init.3 and inet6_rth_space.3.
* Remove NS and ISO stuff.
* Sync map_v4v6.c with BIND9.
* Instead of re-implementing hton[ls] and friends for each arch, add a
  new MI file, net/ntoh.c, which just implement them using the inline
  functions from <sys/endian.h>.
* Fix some namespace issues in <netdb.h>.

15 years agoSync libc/quad with FreeBSD:
Peter Avalos [Tue, 27 Jan 2009 20:51:36 +0000 (15:51 -0500)]
Sync libc/quad with FreeBSD:

-Remove advertising clause from copyright.

-Remove gcc 1 stuff.

-Add some prototypes in quad.h.

And, while I'm here:

-ANSI function declarations.

15 years agoSync libc/regex with FreeBSD:
Peter Avalos [Tue, 27 Jan 2009 14:17:46 +0000 (09:17 -0500)]
Sync libc/regex with FreeBSD:

-Make regular expression matching aware of multibyte characters.

-Some WARNS cleanup.

-Only stop evaluation of a back reference if the match length is
zero and the recursion level is too deep.

-Add restrict type-qualifier.

15 years agoReplace our strtod with the gdtoa package.
Peter Avalos [Mon, 19 Jan 2009 19:48:45 +0000 (14:48 -0500)]
Replace our strtod with the gdtoa package.

Obtained-from: FreeBSD

15 years agoConfigure gdtoa for DragonFly:
Peter Avalos [Mon, 19 Jan 2009 18:39:20 +0000 (13:39 -0500)]
Configure gdtoa for DragonFly:

-Protect exported symbols with leading underscores.

-Enable locale support.

-Add some missing prototypes.

-Correctly round floating-point numbers when they are printed in
non-default rounding modes.

-On platforms where long is 64 bits, make sure gdtoa doesn't use a
long when it really wants an int.

Obtained-from: FreeBSD

15 years agoAdd a <fenv.h> implementation.
Peter Avalos [Mon, 19 Jan 2009 23:44:52 +0000 (18:44 -0500)]
Add a <fenv.h> implementation.

This is slightly changed from FreeBSD's version since we aren't worried
about backward compatibility with FreeBSD 5.

Obtained-from: FreeBSD
amd64 fixes: dillon

15 years agoSync libc/stdlib with FreeBSD (ignoring jemalloc, pts, and gdtoa):
Peter Avalos [Mon, 19 Jan 2009 02:51:47 +0000 (21:51 -0500)]
Sync libc/stdlib with FreeBSD (ignoring jemalloc, pts, and gdtoa):

-Add a64l(), l64a(), and l64a_r() XSI extentions.  These functions
convert between a 32-bit integer and a radix-64 ASCII string.

-Replace some syscalls with libc version.

-Remove advertising clause.

-alloca() cannot check if the allocation is valid; mention the
consequences.

-Include some verbage about not calling exit() from functions registered
by atexit().

-Use pthread mutexes where possible instead of libc spinlocks.

-Significantly reduce the memory leak as noted in the BUGS section of
setenv(3) by tracking the size of the memory allocated instead of using
strlen() on the current value.

-Prefer setenv() instead of putenv().

-Convert *env() calls to POSIX:
-unsetenv returns an int.
-putenv takes a char * instead of const char *.
-putenv no longer makes a copy of the input string.
-errno is set appropriately.  Exceptions involve bad environ
variable and internal initialization code.  These both set errno
to EFAULT.

-Make getopt_long() more GNU compatible and sync up with OpenBSD's
version.

-POSIX clearly states that getsubopt() should be declared in <stdlib.h>
not in <unistd.h>

-Use size_t to avoid overflow when sorting arrays larger than 2 GB in
heapsort() and qsort().

-Add new implementations of insque() and remque() which conform to
IEEE Std 1003.1-2001.

-Add qsort_r() for functions that need to be reentrant.

-Improve radixsort()'s preformance when sorting strings with common
prefixes.

-Use 'uint32_t' instead of 'long' when a 32-bit integer is intended in
random(3).

-Rearrange <stdlib.h> in a more logical order based on visibility.

-Move getsubopt()'s prototype to <stdlib.h> (standards).

-Make an internal _getprogname() that is used only inside
libc. For libc, getprogname(3) is a weak symbol in case a
function of the same name is defined in userland.

15 years agoReduce lock contention for simple cases in stdtime.
Peter Avalos [Sat, 17 Jan 2009 03:37:59 +0000 (22:37 -0500)]
Reduce lock contention for simple cases in stdtime.

Normally, we are often reading local time rather than setting time zone,
replace mutex with rwlock, this should eliminate lock contention in
most cases.

Obtained-from: FreeBSD

15 years agoRemove unused source files.
Peter Avalos [Sat, 17 Jan 2009 02:46:08 +0000 (21:46 -0500)]
Remove unused source files.

15 years agoAdd the restrict qualifier to strftime(3) and strptime(3).
Peter Avalos [Sat, 17 Jan 2009 02:22:40 +0000 (21:22 -0500)]
Add the restrict qualifier to strftime(3) and strptime(3).

15 years agoAdd routines to convert time_t to/from fixed-bit fields.
Peter Avalos [Sat, 17 Jan 2009 01:55:46 +0000 (20:55 -0500)]
Add routines to convert time_t to/from fixed-bit fields.

Obtained-from: FreeBSD

15 years agoSync strptime with NetBSD:
Peter Avalos [Fri, 16 Jan 2009 23:45:43 +0000 (18:45 -0500)]
Sync strptime with NetBSD:

-A few code optimiztions.

-%y failed to subtract 1900 from tm_year

-%p (am/pm) only worked at the end of the string

-%E% was treated as %% (ie match a % character)

-Add support for %Z.

-Add %F the ISO 8601 date format which is equivalent to %Y-%m-%d.

-Add gnu extensions: %z, %g, %G, %u.

-Bring in NetBSD's strptime(3) manual page.

15 years agoRemove the timezone() function.
Peter Avalos [Fri, 16 Jan 2009 15:52:59 +0000 (10:52 -0500)]
Remove the timezone() function.

It conflicts with an XSI extension where timezone and daylight are
variables representing:

timezone:  the difference, in seconds, between Coordinated Universal
Time (UTC) and local standard time.

daylight:  set to 0 if Daylight Savings Time conversions should never be
applied for the timezone in use; otherwise, non-zero.

15 years agoUse snprintf instead of sprintf.
Peter Avalos [Fri, 16 Jan 2009 00:40:23 +0000 (19:40 -0500)]
Use snprintf instead of sprintf.

Obtained-from: NetBSD

15 years agoMake sure that %r honors the LC_TIME t_fmt_ampm.
Peter Avalos [Fri, 16 Jan 2009 00:37:18 +0000 (19:37 -0500)]
Make sure that %r honors the LC_TIME t_fmt_ampm.

Obtained-from: NetBSD

15 years agoDon't depend on lcl_mutex being a recursive mutex.
Peter Avalos [Thu, 15 Jan 2009 15:48:06 +0000 (10:48 -0500)]
Don't depend on lcl_mutex being a recursive mutex.

15 years agoSync lib/libc/string with FreeBSD:
Peter Avalos [Wed, 14 Jan 2009 21:01:28 +0000 (16:01 -0500)]
Sync lib/libc/string with FreeBSD:

-Move legacy functions to strings.h.

-A few WARNS and style cleanup.

-Add ffsl(), fls(), flsl(), ffsll(), flsll().

-Merge index.3 and rindex.3 since they are so similar.  Do the same for
strrchr().

-Add memrchr().

-Remove advertising clause from copyrights.

-Add memmem() which is basically the same as strstr().

-Add stpcpy().

-Add a SECURITY CONSIDERATIONS section to remind people about buffer
overflows, etc.

-Add restrict keyword where required.

-Add strndup().

-Correctly document the return value of strerror() and strerror_r() and
the contents of the returned buffer for unknown error codes.

-Add NLS catalogs support to strerror(), strerror_r() and strsignal().
Controlled by NLS define.

-For strl* files, use a less restrictive copyright (original author
changed it).

-strmode.3: strmode does not return 0.

-Move swab()'s prototype to unistd.h IAW SUS.

-Simplify by removing unneeded local variables and explicit
null termination is wcs* functions.

-Move wcscoll() and wcsxfrm() to string/ and do locale-sensitive
collation for single-byte locales.

-Add wcsdup().

-Remove unneeded includes.

-Reimplement wcsrchr(3) more efficiently, using a single forward scan
(like strrchr(3)) instead of scanning forwards to find the end of the
string then scanning backwards to find the character.

-Slightly optimize wcswidth().

-Tell contrib srcs that we have strndup now since some of them provide
their own static definition which will blow up a buildworld.

15 years agoImport the uuid_enc_le(), uuid_dec_le(), uuid_enc_be() and uuid_dec_be() functions...
Peter Avalos [Fri, 2 Jan 2009 02:27:24 +0000 (21:27 -0500)]
Import the uuid_enc_le(), uuid_dec_le(), uuid_enc_be() and uuid_dec_be() functions. These routines are not part of the DCE RPC API. They are provided for convenience.

Obtained-from: FreeBSD

15 years agoSync libc/yp with FreeBSD:
Peter Avalos [Fri, 2 Jan 2009 01:28:07 +0000 (20:28 -0500)]
Sync libc/yp with FreeBSD:

-Set timeout for all NIS RPC requests to 1 second.  This should reduce
the risk of NIS timing out due to packet loss.
-Protect calls with a mutex lock.

15 years agoMerge commit 'chlamydia/master'
Thomas Nikolajsen [Mon, 6 Apr 2009 21:52:47 +0000 (23:52 +0200)]
Merge commit 'chlamydia/master'

15 years agobattd update: fix some errors and improve battd.8
Thomas Nikolajsen [Mon, 6 Apr 2009 21:13:03 +0000 (23:13 +0200)]
battd update: fix some errors and improve battd.8

 - Execute once (-E) didn't work
 - Default time (-T) didn't work
 - Default percentage couldn't be turned off, now -p0 does this
 - battd couldn't start when system on AC
 - battd.8 updated: markup improved
 -  line break at end of sentence
 -  -T better documented
 -  EXAMPLE udated

15 years agoSync zoneinfo database with tzdata2009e from elsie.
Sascha Wildner [Mon, 6 Apr 2009 13:43:12 +0000 (15:43 +0200)]
Sync zoneinfo database with tzdata2009e from elsie.

asia:           8.26 -> 8.29

* Jordan has been going to DST on the last Friday in March since 2002
  and not on the last Thursday.

* Palestine started DST midnight, March 26 and will end midnight,
  September 27.

15 years agoether_input(): Remove unapplied comment
Sepherosa Ziehau [Sun, 5 Apr 2009 04:28:31 +0000 (12:28 +0800)]
ether_input(): Remove unapplied comment

15 years agovlan(4): Support IFF_PROMISC and IFF_ALLMULTI
Sepherosa Ziehau [Sun, 5 Apr 2009 04:26:58 +0000 (12:26 +0800)]
vlan(4): Support IFF_PROMISC and IFF_ALLMULTI

Obtained-from: FreeBSD

15 years agoether_input: Defer promiscous packet discarding until vlan is processed
Sepherosa Ziehau [Sun, 5 Apr 2009 03:38:23 +0000 (11:38 +0800)]
ether_input: Defer promiscous packet discarding until vlan is processed

This is the one of the precondition to make vlan/bridge work: preventing
packets from being dropped prematurely by vlan's parent interface.

15 years agoUse ETHER_IS_MULTICAST, which is more expressive.
Sepherosa Ziehau [Sun, 5 Apr 2009 02:57:27 +0000 (10:57 +0800)]
Use ETHER_IS_MULTICAST, which is more expressive.

15 years agoserializer manpage: Remove IS_SERIALIZED(), which is available only if
Sepherosa Ziehau [Sun, 5 Apr 2009 02:03:26 +0000 (10:03 +0800)]
serializer manpage: Remove IS_SERIALIZED(), which is available only if
INVARIANTS is defined and probably should not be used in any places
other than the serializer implementation itself.

15 years agombuf: Don't discount the objcache limits required by non-pkthdr mbuf
Sepherosa Ziehau [Sun, 5 Apr 2009 02:00:04 +0000 (10:00 +0800)]
mbuf: Don't discount the objcache limits required by non-pkthdr mbuf

15 years agoaltq: ifq needs protection here; not ifnet
Sepherosa Ziehau [Sat, 4 Apr 2009 08:51:40 +0000 (16:51 +0800)]
altq: ifq needs protection here; not ifnet

15 years agoumount(8): Raise WARNS to 6 and fix all warnings.
Sascha Wildner [Sat, 4 Apr 2009 20:50:59 +0000 (22:50 +0200)]
umount(8): Raise WARNS to 6 and fix all warnings.

15 years agosh(1): Fix warnings when compiling with -DNO_HISTORY.
Sascha Wildner [Sat, 4 Apr 2009 20:38:31 +0000 (22:38 +0200)]
sh(1): Fix warnings when compiling with -DNO_HISTORY.

15 years agovkernel: Comment out unused variable.
Sascha Wildner [Sat, 4 Apr 2009 20:31:06 +0000 (22:31 +0200)]
vkernel: Comment out unused variable.

15 years agoRename some log() -> dolog() to not conflict with built-in log().
Sascha Wildner [Sat, 4 Apr 2009 20:26:27 +0000 (22:26 +0200)]
Rename some log() -> dolog() to not conflict with built-in log().

While here, remove trailing whitespace.

15 years agosystat(1): Correct TCP statistics reporting
Sepherosa Ziehau [Sat, 4 Apr 2009 02:43:27 +0000 (10:43 +0800)]
systat(1): Correct TCP statistics reporting

Reported-by: ruse39 on EFnet #dragonflybsd
15 years agobridge(4): if_snd.ifq_maxlen does not need explicit setting
Sepherosa Ziehau [Sat, 4 Apr 2009 02:33:04 +0000 (10:33 +0800)]
bridge(4): if_snd.ifq_maxlen does not need explicit setting

15 years agoHAMMER - Fix extra TAILQ_REMOVE in HAMMER shutdown code.
Matthew Dillon [Sat, 4 Apr 2009 01:35:07 +0000 (18:35 -0700)]
HAMMER - Fix extra TAILQ_REMOVE in HAMMER shutdown code.

Caught-by: New assertions in sys/queue.h imported by pavalos.
15 years agoAMD64 Test Environment - add SDL support to the qemu build
Matthew Dillon [Sat, 4 Apr 2009 01:12:12 +0000 (18:12 -0700)]
AMD64 Test Environment - add SDL support to the qemu build

Qemu may now be built with SDL (X support) using the make directive
WITHSDL=YES.  A new target 'xrun' runs qemu in X mode vs curses mode.

Submitted-by: Antonio Huete
15 years agoMerge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
Matthew Dillon [Fri, 3 Apr 2009 22:12:02 +0000 (15:12 -0700)]
Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly

15 years agoAMD64 - Enhance help target for src/test/amd64 build
Matthew Dillon [Fri, 3 Apr 2009 22:10:56 +0000 (15:10 -0700)]
AMD64 - Enhance help target for src/test/amd64 build

Document all targets.  Also add a new target 'sysloader' which will
install the native 32 bit system loader in root.img in case the
64 bit one doesn't work.

15 years agoUse .Va for tunables in manual pages.
Sascha Wildner [Fri, 3 Apr 2009 18:13:15 +0000 (20:13 +0200)]
Use .Va for tunables in manual pages.

15 years agoRedo last commit. Do not require that SRCDIR be specified. Set it
Matthew Dillon [Fri, 3 Apr 2009 18:00:39 +0000 (11:00 -0700)]
Redo last commit.  Do not require that SRCDIR be specified.  Set it
to ${.CURDIR}/../.. by default (originally it was hardwired to /usr/src).

15 years agoRequire that SRCDIR be specified or exist in the environment instead of
Matthew Dillon [Fri, 3 Apr 2009 17:56:41 +0000 (10:56 -0700)]
Require that SRCDIR be specified or exist in the environment instead of
defaulting it to /usr/src.

15 years agoRevoke reimplementation - primary commit part 2/2.
Matthew Dillon [Fri, 3 Apr 2009 16:46:57 +0000 (09:46 -0700)]
Revoke reimplementation - primary commit part 2/2.

This finishes out the primary revoke changes.  Adjust the revoke code
to do a primary pass on the file pointer table and mark fps with FREVOKED,
then do a pass on the process descriptor tables to clean them out.

Add checks to dup() to silently use a dummy fp when the source fp has
been revoked.  This removes revoke/dup races.

Add unix domain in-transit tests.  If a revoked fp is in-transit then
unix-domain sockets are scanned and revoked file pointers replaced with
dummy file pointers.