Home | History | Annotate | Download | only in compat
History log of /src/tools/compat/compat_defs.h
RevisionDateAuthorComments
 1.127  18-Sep-2025  christos add vsyslog decl check
 1.126  18-Sep-2025  christos Add more functions needed by mandoc
 1.125  05-May-2025  christos Add roundup2() used by ctf
 1.124  02-Mar-2025  riastradh libc: New _r variants of heapsort, mergesort, qsort.

Also kheapsort_r for kernel/standalone use.

These variants allow the caller to pass a cookie through to the
comparison function, e.g. if you want to sort an array of indices
into a buffer.

qsort_r is new in POSIX.1-2024; the others are obvious analogues of
our nonstandard extensions for heapsort and mergesort.

PR lib/58931: qsort_r() missing
 1.123  31-Oct-2024  kre Include shquote() in configure tests
 1.122  21-Jul-2023  lukem branches: 1.122.2;
tools/compat/compat_defs.h: improve NAME_MAX compat

Move the NAME_MAX workaround to the <limits.h> section,
and don't assume that _XOPEN_NAME_MAX is available.
 1.121  08-Jul-2023  palle Add support for missing NAME_MAX when building on Solaris hosts
 1.120  30-May-2021  cjep branches: 1.120.4;
PR port-amiga/56188

Include a prototype for __nbcompat_heapsort. The tools for amiga now
build on Darwin where one Amiga specific tool uses heapsort.

Despite being a one-liner, ./build.sh -m amiga tools was tested on
NetBSD, Darwin, FreeBSD & Linux with the change.

Discussed various options with jdc & thorpej. Perhaps in the future
we could look at using qsort instead of heapsort as qsort is
standardised and more likely to be available. We could then remove
heapsort from the compatibility library.
 1.119  24-May-2021  uwe Fix typo in pathname in a comment.
 1.118  25-Feb-2021  christos branches: 1.118.2;
Add reallocarray; this is used by the new regex code and we don't want to
convert it to reallocarr so the code is kept similar with the original from
FreeBSD.
 1.117  23-Feb-2021  rin Fix copy-paste error for heapsort(3), so that it is declared appropriately.
 1.116  19-Jun-2019  kamil Add more SunOS types to tools/compat

Add fallback defintions of: uchar_t, ushort_t, uint_t, ulong_t.

Needed by the libctf code on Ubuntu 16.x.
 1.115  19-Jun-2019  kamil Add sys/uio.h & enum uio_seg, enum uio_rw to tools/compat

This is needed for bootstrapping the tools on Ubuntu 16.x.
 1.114  30-Aug-2018  christos deal with getsubopt and strncasecmp (needed by mdocml)
 1.113  11-Aug-2018  christos Add strcasecmp
 1.112  13-Jun-2018  maya branches: 1.112.2;
Revert my previous config test inclusion for u_longlong_t.

Fixing this differently by avoiding the need for the definition.
It also caused a problem in OS X, as I neglected to include a correct header
 1.111  12-Jun-2018  christos Move the typedefs before the header inclusions (except <features.h>) and
explain why.
 1.110  11-Jun-2018  maya Add configure check and fallback definition for u_longlong_t

Should help linux tools compilation of dtrace tools, and not
affect NetBSD.

From Chuck Zmudzinski in current-users, with light modification
by myself.
 1.109  03-Oct-2017  christos branches: 1.109.2;
fix fpurge declaration
 1.108  02-Oct-2017  christos handle __fpurge being declared in <stdio_ext.h>
 1.107  07-Jan-2017  christos branches: 1.107.6;
adjust for SSP (MacOS/X)
 1.106  07-Jan-2017  christos need ctype.h
 1.105  07-Jan-2017  christos Check for declarations, not the existance of functions since some are
visible only when _NETBSD_SOURCE is defined. This avoids || defined(__NetBSD__)
hacks.
 1.104  19-Oct-2016  christos try to fix missing decls
 1.103  21-Sep-2015  pooka branches: 1.103.2;
Add more compat defs for code compiled for !NetBSD targets.

At least GNU Hurd lacks MAXHOSTNAMELEN/MAXPATHLEN/PATH_MAX, so make sure
those have some arbitrary semi-sane values.

from Robert Millan in PR misc/50166, with some modifications from myself
 1.102  26-Jul-2015  kamil Add reallocarr(3) to tools/compat

This should unbreak libutil(3) creation on systems withot reallocarr(3).
 1.101  16-Jan-2015  christos strto{i,u}
 1.100  24-Dec-2014  christos add __UNVOLATILE
 1.99  24-Sep-2014  christos put O_CLOEXEC definition here.
 1.98  01-Sep-2014  apb Copy definitions of __type_min(t), __type_max(t), and some related macros,
from <sys/cdefs.h>, for use when building tools.
 1.97  06-Jun-2014  christos branches: 1.97.2;
Deal with errc/warnc
 1.96  19-Apr-2014  apb Clarify the NetBSD-specific and Linux-specific code at the top of
compat_defs.h:

* Explain why _NETBSD_SOURCE should not be defined on NetBSD.
* Move NetBSD-specific block to the top of the file.
* Improve comment about Linux <feature.h>.
* Move #undef _POSIX_SOURCE and #undef _POSIX_C_SOURCE to the
Linux-specific block instead of a place that would affect all
non-NetBSD platforms. This makes the code match the comment.

This will need to be re-visited if other platforms also need
#undef _POSIX_SOURCE or #undef _POSIX_C_SOURCE. At present, I suspect
that they are needed only for Linux.
 1.95  09-Jan-2014  apb branches: 1.95.2;
fix prototype for strnlen.
 1.94  09-Jan-2014  apb Declare and define strnlen if necessary.
 1.93  24-Oct-2013  apb Define __USE for use during a tools build.
 1.92  18-Aug-2013  joerg Support __format_arg.
 1.91  06-Aug-2013  apb declare snptintb_m() and snprintb() if HAVE_SNPRINTB is not defined.
 1.90  20-Jul-2013  christos revert socklen_t to int (from dh)
 1.89  19-Jul-2013  christos PR/48063: Justin Cormack: incorrect definition of socklen_t
 1.88  05-Mar-2013  christos branches: 1.88.4;
add dprintf
 1.87  17-Feb-2013  christos cygwin defines u_quad_t in <rpc/types.h>, so include this to the headers
we include and test by default.
 1.86  04-Jun-2012  joerg branches: 1.86.2;
Make Alan Barrett happy and add ().
 1.85  03-Jun-2012  joerg Add __predict_true / __predict_false definitions.
 1.84  02-Jun-2012  joerg Don't depend on __P.
 1.83  21-Jan-2012  tsutsui branches: 1.83.2;
Always redefine DEV_BSIZE=512.
All references of DEV_BSIZE in tools are to manipulate target
(i.e. NetBSD's) file images (in installboot(8) and makefs(8) etc.) and
no host's DEV_BSIZE is required for the moment. Closes PR toolchain/42574.
 1.82  03-Nov-2011  joerg Add getline(3) compat glue.
 1.81  05-Sep-2011  jdc branches: 1.81.2;
Add PDP_ENDIAN definition, required for makefs (v7fs).
 1.80  27-Aug-2011  joerg Ensure __printflike exists.
 1.79  17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.78  10-Jan-2011  apb Define PRI[diouxX]8. We previously did this only for
16- and 32-bit type, but now PRIu8 is needed for tools/disklabel.

Also define SCN[diouxX]{8,16,32}, the scanf counterparts
to the PRI[diouxX]{8,16,32} macros.

Tested via "build.sh tools" on a system whose native definitions
or the PRI* and SCN* mcros was disabled.
 1.77  14-Jan-2010  christos undef and redefine instead of checking if it is define, from joerg
 1.76  14-Jan-2010  christos provide __arraycount for those that don't have it.
 1.75  11-Nov-2009  tron Revert most of revision 1.73:
We cannot user_from_uid(3) or group_from_gid(3) unless the system
also supports pwcache_userdb(3) and pwcache_groupdb(3). The build will
use the hosts password and user database otherwise. Switch back to the
old behaviour to only the native functions if they are all present.
This fixes cross builds under Mac OS X and FreeBSD.

Fix based on problem analysis provided by Akihiko Hayashi.
 1.74  06-Nov-2009  joerg Define __RCSID and __COPYRIGHT as structure, so that the following
semicolon is consumed.
 1.73  02-Oct-2009  christos split all the password and group translation functions into individual
ifdefs instead of having a large one.
 1.72  24-Feb-2009  sketch Make 'build.sh tools' work with the Sun Studio compiler, although bugs in
some of the generated tools still prevent building a full release using them.
 1.71  03-Feb-2009  dbj branches: 1.71.2;
avoid including grp.h
 1.70  18-Jan-2009  apb Use hex instead of decimal in #if FOO_MAX == 0xffff.... tests, and
append "U" to make the constants unsigned.
 1.69  18-Jan-2009  apb Provide definitions for PRI{d,i,o,u,x,X}{16,32,64}. Many tools
already use [u]int{16,32,64}_t types, and a few already had their own
#ifndef/#define/#endif code for a few of these macros. A future commit
will remove that now-redundant code in the affected tools.
 1.68  06-Jan-2009  agc Apply part of the patch from Julio M. Merino Vidal in

http://mail-index.netbsd.org/source-changes/2009/01/05/msg214884.html

to make the toolchain cross-build on Mac OS X. Nozaki-san has addressed
the other issues.
 1.67  20-Oct-2008  apb branches: 1.67.2;
The tools/compat versions of mkstemp() and mkdtemp() need to call the
internal function that's usually named "__gettemp". However in a cross
build, "__gettemp" is in a namespace reserved for the host system, so we
can't use that. Use "__nbcompat_gettemp" instead, following the example
of several other functions or macros in tools/compat. Previously, this
was handled by using the name "gettemp", but that conflicts with the
local gettemp() function in dist/nawk.
 1.66  20-Oct-2008  dogcow Define __USE_ISOC99 for linux, making the isblank() proto appear.
This is probably not the Right Thing, but it seems to not break anything.
 1.65  30-Oct-2007  tls Try to address mess with user_from_uid and friends by ensuring we always
get our versions if any of the functions aren't present on the host system.

Still assumes if the functions are all there, they work like ours, which
may be a problem too.
 1.64  19-Oct-2007  christos I am now convinced of the error of my ways, and I am checking for all the
decls mtree is using.
 1.63  18-Oct-2007  christos Move linux block up higher as it was before. noted by apb
 1.62  18-Oct-2007  christos - define the NetBSD options before including any files
- add the _NETBSD_TOOLS define to make more symbols visible
- user_from_uid and group_from_gid are renamed only if we don't have them
 1.61  28-Sep-2007  lukem Add raise_default_signal().
 1.60  07-Aug-2007  apb branches: 1.60.2;
Provide definitions for {be,le}{16,32,64}{enc,dec} if necessary.
This is adapted from the very detailed fix provided by
Giles Lean in PR bin/36678.

Only one simplified implementation is provided, instead of the
two implementations conditional on __GNUC_PREREQ__(2,95) that are
provided in NetBSD's <sys/endian.h>. The use of memcpy instead of
__builtin__memcpy, and the absence of __inline or __unused, should make
it independent of GCC.
 1.59  03-Jul-2007  nakayama Add strndup(3) to libnbcompat, since estrndup(3) added into efun.c calls it.
 1.58  09-Jan-2007  ginsbach Fix tools build, binstall/xinstall, for systems without id_t, e.g.
MacOS X 10.3.9. This should better match the NetBSD definition of id_t
in sys/sys/types.h.
 1.57  12-Oct-2006  christos branches: 1.57.2; 1.57.4;
kill __unused
 1.56  09-Oct-2006  christos sideways check for error functions.
 1.55  07-Oct-2006  apb Add definitions for strmode. This was missing from the
patch in PR 31232.
 1.54  29-Sep-2006  apb Use ${HOST_SH} instead of the host system's /bin/sh wherever possible:

* _PATH_BSHELL from the host's <paths.h> might be broken, so override it
with our PATH_BSHELL, which is derived from HOST_SH.
 1.53  20-Aug-2006  thorpej Also check for DIR.__dd_fd. tools/compat now builds on the WWDC developer
preview version of Mac OS X "Leopard".
 1.52  14-Feb-2006  dyoung Two changes to facilitate building tools on Darwin:

1. #undef d_fileno, which is set by Darwin's <dirent.h>,
and which clashes with d_fileno in NetBSD headers.

2. Install the sys/ufs/ header files in nbinclude/ in order
to override Darwin's own, incompatible header files.
 1.51  11-Feb-2006  wiz Define prototypes for strsuftoll and strsuftollx if the one for
strsuftoll was not found by configure. Second part of nbmakefs build
on 3.0.
 1.50  10-Feb-2006  wiz Adapt for bswap* changes in configure.ac.
 1.49  09-Feb-2006  dogcow change #include <sys/endian.h> => #include <machine/endian.h> so that
it's (more) consistent in the tree; this, along with changing tools/compat's
autoconf detection from AC_CHECK_FUNCS to AC_CHECK_DECLS makes the vast
majority of htobe16 and friends' redefinition errors bite the dust.
Tested with -current and FreeBSD.
 1.48  14-Sep-2005  tron Make cross compiling NetBSD under Linux work again. Problem noted by
R. Huvendiek on "current-users" mailing list.
 1.47  27-Aug-2005  uwe UINT8_MAX and UINT16_MAX are needed for disklabel.
 1.46  22-Aug-2005  tron Define "_PATH_VI" if necessary to make cross-building work again under
Solaris (and potentially other platforms) after "disklabel" has been
added to the hosts tools.
 1.45  11-Dec-2004  jmc Provide a definition for __UNCONST since there's no guarentee our sys/cdefs.h
gets pulled in
 1.44  28-Nov-2004  jmc Add heapsort to libnbcompat
 1.43  23-Jun-2004  tron Define "_ISOC99_SOURCE" when building under NetBSD to get the prototypes
for strtoll() and strtoull(). This fixes PR toolchain/26021.
 1.42  22-Jun-2004  jmc Redo the last commit. _NETBSD_SOURCE should never be used/referenced anymore.
So, don't wrap definitions in it, and instead check for it and #error out
if it somehow leaks into scope.

Tested a complete build to sets on x86 from a clean source tree.
 1.41  21-Jun-2004  christos - Wrap around #if !_NETBSD_SOURCE the definitions of u_{long,int,short,char}
- Protect dirfd() macro so that we don't re-define it.

These changes make my build proceed further.

The problem is that automatically generated files, might include system
files before they include anything else (for example our yacc skeleton
includes <stdlib.h> before it does anything else). This foils the scheme
of defining _POSIX_SOURCE and friends so that _NETBSD_SOURCE does not
get defined; in fact, we include many files with _NETBSD_SOURCE defined,
enough to cause confusion in compat_defs.h which tries to re-define things.
 1.40  21-Jun-2004  jmc On NetBSD boxes make sure and provide prototypes for strtouq since quad_t gets
exposed all the time, but routines which use it do not. Otherwise callers
of strtouq will lose.
XXX: Need to come back through here and clean up the configure tests better
for this
 1.39  20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.38  18-Jun-2004  thorpej Oops, missed a spot where we need to handle group_from_gid() separately.
 1.37  18-Jun-2004  thorpej Handle group_from_gid() on its own.
 1.36  14-Jun-2004  jmc Before sucking in stdlib.h check if this is NetBSD. If so, explicitly make
sure to use _POSIX_C_SOURCE and undef _NETBSD_SOURCE so the myriad of NetBSD
extentions don't get pulled into scope (and likely conflict at some point
with branched code trying to build on -current due to drift). Fixes PR#25533

XXX: The entire process here is just wacky and the entire cross tools process
needed to be reviewed to build clean w. just _POSIX_C_SOURCE or the equiv
set on NetBSD hosts or this will lose again somewhere..
 1.35  18-May-2004  sjg Apply patch from OGAWA Takaya to fix FreeBSD hosted builds.
The trick is to force use of the NetBSD versions of user_from_{uid,gid}().

PR: 24843
 1.34  24-Apr-2004  matt Add a compat definition of __packed.
 1.33  23-Apr-2004  christos more constification suggested by kleink.
 1.32  23-Apr-2004  christos adjust to constification of cget*()
 1.31  27-Oct-2003  lukem branches: 1.31.2;
Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.30  27-Aug-2003  uwe If SIZE_MAX is not defined, but SIZE_T_MAX is defined (e.g. FreeBSD),
define SIZE_MAX as SIZE_T_MAX.
 1.29  27-Jul-2003  lukem If HAVE_SYS_ENDIAN_H, pull in <sys/endian.h>. Fixes build.sh on FreeBSD 5.1.
Fix from Grant Beattie <grant@>
 1.28  18-Jul-2003  fredb As discussed briefly on tech-toolchain, AIX doesn't have "u_long",
so add a check for that. Partial fix for PR toolchain/22177.
 1.27  03-Jun-2003  uwe Add atoll(3) to libnbcompat. We need it when building target's gcc
for a 64-bit target on a 32-bit host.

NB: There seems to be a bug in either gcc itself or the way we import
it, b/c the incorrect #define HAVE_ATOLL is picked from (e.g. for
sparc64) gnu/usr.bin/gcc/arch/sparc64/auto-host.h - so when gen*
auxilary (host) programs are built in gnu/usr.bin/gcc/backend, they
incorrectly pick-up target's HAVE_ATOLL.

For now providing atoll(3) in libnbcompat is a simple and sufficient
workaround.
 1.26  13-Mar-2003  thorpej Check for sys/socket.h and socklen_t.
 1.25  31-Jan-2003  uwe Avoid cgetcap &co prototypes conflicting with those provided by the host.
With this change we can cross-compile on FreeBSD 4.x.
 1.24  27-Jan-2003  uwe Provide __SCCSID() needed by pwd_mkdb.
 1.23  29-Nov-2002  lukem replace missing strsuftoll(3)
 1.22  20-Oct-2002  christos PR/18733: Jed Davis: define _PATH_DEFTAPE; pax needs it.
 1.21  08-Oct-2002  lukem Implement replacements for lchflags(), lchmod(), and lchown(),
which first lstat(2) the target and return EINVAL if it's a symlink,
and then call ch{flags,mod,own} as appropriate.
Removes the need for hokey code inside the tools themselves...
 1.20  06-Oct-2002  lukem Provide strtoll() in libnbcompat.
Should fix relevant build issue on HP-UX and MacOS X hosts.
 1.19  30-Sep-2002  lukem Fix from Giles Lean:
HP-UX has MAP_ANONYMOUS but not MAP_ANON
 1.18  14-Sep-2002  thorpej * Check for mkstemp() and mkdtemp(), and build them into libnbcompat
if necessary.
* mktemp is now a host-tool, so nuke the lame script (which isn't even
properly installed during the tools bootstrap).
 1.17  13-Sep-2002  bjh21 Add __restrict to the set of tokens we #define away: our glob.h uses it.
 1.16  03-Jul-2002  pooka Fine-grain checking somewhat:
* check for user_from_uid() in addition to pwcache_userdb()
* check for svis() in addition to vis()
 1.15  24-Apr-2002  bjh21 branches: 1.15.2;
Rather than hardcoding two possible locations of the POSIX shell (for
Solaris and everything else), set _PATH_BSHELL to the first occurrence of
"sh" on the path. This should be rather more portable.
 1.14  23-Apr-2002  bjh21 Add test for alloca() and <alloca.h>, since Sun Workshop C 5.0 needs this.
 1.13  22-Apr-2002  bjh21 <stdint.h> belongs before <sys/endian.h>.
 1.12  22-Apr-2002  bjh21 Define __CONCAT if the host doesn't.
 1.11  22-Apr-2002  lukem add UINT32_MAX if it's not defined
 1.10  18-Apr-2002  bjh21 Add a stub issetugid() for platforms that don't have it. For now, we assume
that no host program will be installed set-id, so the stub function always
returns 0.
 1.9  04-Apr-2002  bjh21 Add htobe16() and friends, #ifndef HAVE_SYS_ENDIAN_H.
 1.8  04-Apr-2002  bjh21 Replace a spurious hard space (\xa0) with a normal one.
 1.7  07-Mar-2002  tv Need DEV_BSIZE and roundup() for makefs on non-NetBSD hosts.
 1.6  26-Feb-2002  tv Add some more bits of host compatibility.
 1.5  06-Feb-2002  lukem remove btodb() hack now that makefs doesn't need it anymore.
the #define was wrong anyway; it was x<<9 instead of x>>9
 1.4  31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.3  29-Jan-2002  tv Make almost all tools compile and run properly on non-NetBSD hosts. (In
particular, most tools now run correctly on Solaris 7.)
 1.2  24-Jan-2002  lukem - Replace pwcache(3) if necessary (pwcache_userdb(3) is checked for).
Tested on -current and 1.5.3.
- Wrap some long lines.
 1.1  22-Jan-2002  thorpej Split compat definitions into a separate file so that autoconf
doesn't comment out #undef's that we want to keep.
 1.15.2.6  23-Jul-2004  tron Apply patch (request by dbj in ticket 1723):
Fix building the netbsd-1-6 branch under Darwin/MacOS.
 1.15.2.5  22-Jun-2004  tron Pull up revision 1.40 (requested by jmc in ticket #1717):
On NetBSD boxes make sure and provide prototypes for strtouq since quad_t gets
exposed all the time, but routines which use it do not. Otherwise callers
of strtouq will lose.
XXX: Need to come back through here and clean up the configure tests better
for this
 1.15.2.4  16-Jun-2004  jmc Add some define's to null out RCSID/COPYRIGHT/etc. Also add _PATH_DEFTAPE.
Fixes issues from PR#24481
 1.15.2.3  14-Jun-2004  tron Pull up revision 1.36 (requested by jmc in ticket #1711):
Before sucking in stdlib.h check if this is NetBSD. If so, explicitly make
sure to use _POSIX_C_SOURCE and undef _NETBSD_SOURCE so the myriad of NetBSD
extentions don't get pulled into scope (and likely conflict at some point
with branched code trying to build on -current due to drift). Fixes PR#25533
XXX: The entire process here is just wacky and the entire cross tools process
needed to be reviewed to build clean w. just _POSIX_C_SOURCE or the equiv
set on NetBSD hosts or this will lose again somewhere..
 1.15.2.2  30-Nov-2002  he Pull up revision 1.18 (requested by thorpej in ticket #807):
o Check for mkstemp() and mkdtemp(), and build them into
libcompat if necessary.
o mktemp is now a host-tool, so remove the now obsoleted
script.
 1.15.2.1  03-Nov-2002  he Pull up revision 1.17 (requested by thorpej in ticket #802):
Add __restrict to the set of tokens we #define away: our
glob.h uses it.
 1.31.2.5  23-Jun-2004  jmc branches: 1.31.2.5.2;
Pullup rev 1.43 (requested by tron in ticket #539)

Define "_ISOC99_SOURCE" when building under NetBSD to get the prototypes
for strtoll() and strtoull()
 1.31.2.4  22-Jun-2004  tron Apply patch (requested by jmc in ticket #538):
Fix build problems caused by changes for ticket #527.
 1.31.2.3  22-Jun-2004  tron Pull up revision 1.40 (requested by jmc in ticket #527):
On NetBSD boxes make sure and provide prototypes for strtouq since quad_t gets
exposed all the time, but routines which use it do not. Otherwise callers
of strtouq will lose.
XXX: Need to come back through here and clean up the configure tests better
for this
 1.31.2.2  22-Jun-2004  tron Pull up revision 1.39 via patch (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.31.2.1  14-Jun-2004  tron Pull up revision 1.36 (requested by jmc in ticket #495):
Before sucking in stdlib.h check if this is NetBSD. If so, explicitly make
sure to use _POSIX_C_SOURCE and undef _NETBSD_SOURCE so the myriad of NetBSD
extentions don't get pulled into scope (and likely conflict at some point
with branched code trying to build on -current due to drift). Fixes PR#25533
XXX: The entire process here is just wacky and the entire cross tools process
needed to be reviewed to build clean w. just _POSIX_C_SOURCE or the equiv
set on NetBSD hosts or this will lose again somewhere..
 1.31.2.5.2.1  06-Apr-2005  he Pull up revision 1.44 (requested by jmc in ticket #1026):
Convert remaining host tools for amiga to correct cross tools.
Now allows complete amiga builds on non-NetBSD and non-BSD hosts.
 1.57.4.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.57.2.2  14-Feb-2009  snj Apply patch (requested by adrianp in ticket #1278):
Fix build on netbsd-5 amd64 hosts.
 1.57.2.1  30-Aug-2007  pavel branches: 1.57.2.1.2;
Pull up following revision(s) (requested by apb in ticket #827):
tools/compat/Makefile: revision 1.50
tools/compat/compat_defs.h: revision 1.60
tools/compat/configure.ac: revision 1.62-1.64
More detailed instructions for what to do when editing configure.ac.
In particular, discourage the use of non-tools versions of
autoconf and autoheader.
Provide definitions for {be,le}{16,32,64}{enc,dec} if necessary.
This is adapted from the very detailed fix provided by
Giles Lean in PR bin/36678.
Only one simplified implementation is provided, instead of the
two implementations conditional on __GNUC_PREREQ__(2,95) that are
provided in NetBSD's <sys/endian.h>. The use of memcpy instead of
__builtin__memcpy, and the absence of __inline or __unused, should make
it independent of GCC.
Update the instructions to say that regen should be done again
to pick up changed RCS IDs.
 1.57.2.1.2.1  14-Feb-2009  snj Apply patch (requested by adrianp in ticket #1278):
Fix build on netbsd-5 amd64 hosts.
 1.60.2.1  06-Nov-2007  matt sync with HEAD
 1.67.2.2  07-Jan-2010  snj Apply patch (requested by tron in ticket #1202):
Don't include grp.h Fixes cross-build under Mac OS X 10.6.
 1.67.2.1  15-Jan-2009  snj branches: 1.67.2.1.2; 1.67.2.1.4;
Pull up following revision(s) (requested by jmcneill in ticket #270):
tools/compat/compat_defs.h: revision 1.68
Apply part of the patch from Julio M. Merino Vidal in
http://mail-index.netbsd.org/source-changes/2009/01/05/msg214884.html
to make the toolchain cross-build on Mac OS X. Nozaki-san has addressed
the other issues.
 1.67.2.1.4.1  21-Apr-2010  matt sync to netbsd-5
 1.67.2.1.2.1  07-Jan-2010  snj Apply patch (requested by tron in ticket #1202):
Don't include grp.h Fixes cross-build under Mac OS X 10.6.
 1.71.2.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.81.2.4  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.81.2.3  30-Oct-2012  yamt sync with head
 1.81.2.2  17-Apr-2012  yamt sync with head
 1.81.2.1  10-Nov-2011  yamt sync with head
 1.83.2.1  23-Jun-2012  riz Pull up following revision(s) (requested by joerg in ticket #328):
lib/libc/gen/devname.c: revision 1.22
distrib/sparc64/instfs/dot.profile: revision 1.7
distrib/i386/cdroms/install.sh: revision 1.3
tests/lib/libcurses/director/director.c: revision 1.10
lib/libc/include/reentrant.h: revision 1.15
distrib/amd64/cdroms/install.sh: revision 1.3
tests/include/t_paths.c: revision 1.12
share/man/man7/hier.7: revision 1.101
etc/rc.d/sysdb: revision 1.24
include/stdlib.h: revision 1.99
tests/lib/libcurses/Makefile: revision 1.3
distrib/sparc64/cdroms/installcd/install.sh: revision 1.3
distrib/i386/cdroms/Makefile.cdrom: revision 1.27
lib/libc/gen/ttyname.c: revision 1.25
usr.bin/tic/Makefile: revision 1.2
tools/compat/Makefile: revision 1.57
lib/libterminfo/compile.c: revision 1.7
lib/libc/gen/ttyname.c: revision 1.26
lib/libterminfo/compile.c: revision 1.8
tools/compat/Makefile: revision 1.59
tools/compat/cdbw.h: revision 1.1
distrib/i386/installimage/install.sh: revision 1.2
lib/libc/include/namespace.h: revision 1.154
usr.bin/tic/tic.c: revision 1.13
usr.bin/tic/tic.c: revision 1.14
usr.bin/tic/tic.c: revision 1.15
distrib/sets/lists/base/mi: revision 1.996
usr.bin/tic/tic.c: revision 1.16
usr.sbin/dev_mkdb/dev_mkdb.8: revision 1.13
usr.bin/tic/tic.c: revision 1.17
usr.bin/tic/tic.c: revision 1.18
tools/compat/cdbr.h: revision 1.1
distrib/sparc64/instfs/list: revision 1.25
usr.bin/tic/tic.c: revision 1.19
lib/libc/cdb/cdbw.c: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.5
share/terminfo/Makefile: revision 1.3
usr.sbin/dev_mkdb/dev_mkdb.c: revision 1.29
usr.sbin/dev_mkdb/Makefile: revision 1.8
lib/libc/gen/ttyname.3: revision 1.23
lib/libc/gen/ttyname.3: revision 1.24
lib/libc/cdb/cdbr.c: revision 1.3
include/cdbw.h: revision 1.2
distrib/sparc64/cdroms/installcd/Makefile: revision 1.15
lib/libc/gen/devname.3: revision 1.12
tools/compat/compat_defs.h: revision 1.85
tools/compat/compat_defs.h: revision 1.86
lib/libterminfo/term_private.h: revision 1.10
lib/libterminfo/term.c: revision 1.14
usr.bin/tic/tic.1: revision 1.10
lib/libterminfo/term.c: revision 1.15
lib/libterminfo/Makefile.hash: revision 1.5
lib/libterminfo/term.c: revision 1.16
distrib/amd64/installimage/install.sh: revision 1.2
share/man/man5/rc.conf.5: revision 1.152
distrib/sets/lists/tests/mi: revision 1.472
distrib/amd64/cdroms/Makefile.cdrom: revision 1.7
include/paths.h: revision 1.41
bin/ps/ps.1: revision 1.101
lib/libterminfo/terminfo.5.in: revision 1.16
usr.bin/tic/tic.c: revision 1.20
lib/libterminfo/terminfo.5.in: revision 1.17
Prefer __printflike.
Use queue(3)
Replace linear lookup with hash table, reducing runtime by 60%.
Use e* from util.h.
One more strdup -> estrdup.
Maintain nalias and nterm on the fly.
Add void for ttyslot prototype.
Use memcmp in place of strncmp, since length is known to no longer than
either of the arguments.
Fix a number of memory leaks. Keep final loop of the cleanup in tic(1)
under #ifdef __VALGRIND__ though.
Add __predict_true / __predict_false definitions.
Add a special seeder for cdbw_output that gives stable results.
Hook up cdbw(3) for the tool build.
Prototype for cdbw_stable_seeder.
Provide a usable thr_once for !_REENTRANT
Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
Switch terminfo(3) to cdb(5).
Fix typos.
Make Alan Barrett happy and add ().
Add cdbr(3) support to tools/compat.
Bump date for previous.
Relax consistency to make it possible to match valid entries.
Prefix devname's buffer with /dev/ as ttyname is supposed to return the
full path. Reported by Dave Huang.
 1.86.2.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.86.2.2  23-Jun-2013  tls resync from head
 1.86.2.1  25-Feb-2013  tls resync with head
 1.88.4.1  23-Jul-2013  riastradh sync with HEAD
 1.95.2.1  10-Aug-2014  tls Rebase.
 1.97.2.2  22-Apr-2015  snj Pull up following revision(s) (requested by roy in ticket #648):
common/lib/libc/stdlib/_strtoi.h: revisions 1.1, 1.2
common/lib/libc/stdlib/strtoi.c: revision 1.1
common/lib/libc/stdlib/strtou.c: revision 1.1
distrib/sets/lists/base/ad.aarch64: patch
distrib/sets/lists/base/ad.arm: patch
distrib/sets/lists/base/ad.mips: patch
distrib/sets/lists/base/ad.powerpc: patch
distrib/sets/lists/base/md.amd64: patch
distrib/sets/lists/base/md.sparc64: patch
distrib/sets/lists/base/shl.mi: patch
distrib/sets/lists/comp/mi: revision 1.1939
distrib/sets/lists/debug/ad.aarch64: patch
distrib/sets/lists/debug/ad.arm: patch
distrib/sets/lists/debug/ad.mips: patch
distrib/sets/lists/debug/ad.powerpc: patch
distrib/sets/lists/debug/md.amd64: patch
distrib/sets/lists/debug/md.sparc64: patch
distrib/sets/lists/debug/shl.mi: patch
include/inttypes.h: revision 1.11
lib/libc/shlib_version: patch
lib/libc/stdlib/Makefile.inc: revision 1.84
lib/libc/stdlib/strtol.3: revisions 1.27-1.31
lib/libc/stdlib/strtoul.3: revisions 1.26-1.29
sys/lib/libkern/Makefile.libkern: revision 1.37
sys/lib/libkern/libkern.h: revision 1.117
tools/compat/Makefile: revision 1.73
tools/compat/compat_defs.h: revision 1.101
tools/compat/configure.ac: revision 1.83
tools/compat/configure: revision 1.82
tools/compat/nbtool_config.h.in: revision 1.36
add strto{i,u} from Kamil Rytarowski as discussed in tech-userlevel.
--
strtoi and strtou additions
--
strtoi and strtou for the kernel
--
strtoi and strtou additions
--
strtoi and strtou man pages
--
strto{i,u}
--
regen
--
Remove trailing whitespace.
--
match variable names with man page (Kamil Rytarowski)
--
cleanups from (Kamil Rytarowski)
--
add strtoi strtou (Kamil Rytarowski)
--
PR/49640: Kamil Rytarowski: Improve error printing
--
Use existing month for Dd.
 1.97.2.1  12-Nov-2014  snj Pull up following revision(s) (requested by martin in ticket #216):
share/man/man9/todr.9: revision 1.17
sys/arch/sh3/dev/rtc.c: revision 1.9
sys/dev/clock_subr.c: revision 1.17-1.22
sys/dev/clock_subr.h: revision 1.22
sys/fs/msdosfs/msdosfs_conv.c: revision 1.10
tools/compat/compat_defs.h: revision 1.98
tools/compat/dev/clock_subr.h: revision 1.1-1.2
usr.sbin/makefs/msdos/Makefile.inc: revision 1.6
clock_secs_to_ymdhms(9) takes seconds as a time_t, not int.
--
Make this compile- and usable from userland as well.
--
Add a slightly stripped down version of sys/dev/clock/clock_subr.h to make
this code available for tools.
--
Reformulate an overflow test so it can be used in tool builds (i.e. does
not depend on netbsd specific macros).
--
Make msdosfs time conversion use the y/m/d/h/m/s conversion functions
from clock_subr.c and compile that into the userland (and tools)
makefs as well.
--
Copy definitions of __type_min(t), __type_max(t), and some related macros,
from <sys/cdefs.h>, for use when building tools.
--
Revert previous; test secs > __type_max(time_t) again, now
that __type_max is available in tools/compat/compat_defs.h.
--
If HAVE_NBTOOL_CONFIG_H is set, then include "nbtool_config.h",
because this file is compiled as part of tools/makefs.
--
Counting leap years was fine while we had 32bit time_t - but now it
is not a good idea for dates far away in the future.
For dates in the year 2000 or later, use arithmetic instead (since the
repeating periods are well aligned). Should fix PR 49144.
--
Avoid overflowing the "year" value by making the field uint64_t. Adapt
arguments and local variables accordingly.
This now fixes PR 49144 for real.
--
Adapt formats for debug printfs to clock_subr type changes.
 1.103.2.3  20-Mar-2017  pgoyette Sync with HEAD
 1.103.2.2  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.103.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.107.6.2  21-Dec-2017  snj revert ticket 435
 1.107.6.1  21-Dec-2017  snj Pull up following revision(s) (requested by sevan in ticket #435):
tools/compat/compat_defs.h: 1.108
tools/compat/configure: 1.87-1.88
tools/compat/configure.ac: 1.88-1.89
tools/compat/fpurge.c: 1.2
tools/compat/nbtool_config.h.in: 1.41-1.42
handle __fpurge being declared in <stdio_ext.h>
--
regen
--
Add asnprintf() to the AC_CHECK_DECLS list.
Resolves conflict when cross compiling on Cygwin the provided implementation
does not get picked up.
Closes PR toolchain/52797
--
regen
 1.109.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.109.2.1  25-Jun-2018  pgoyette Sync with HEAD
 1.112.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.112.2.1  10-Jun-2019  christos Sync with HEAD
 1.118.2.1  31-May-2021  cjep sync with head
 1.120.4.1  17-Nov-2024  martin Pull up following revision(s) (requested by kre in ticket #1004):

tools/compat/configure: revision 1.106
lib/libc/string/__strsignal.c: revision 1.26
tools/compat/configure.ac: revision 1.108
tools/compat/nbtool_config.h.in: revision 1.57
usr.bin/elf2aout/elf2aout.c: revision 1.24
tools/compat/Makefile: revision 1.93
sys/arch/macppc/stand/fixcoff/fixcoff.c: revision 1.13
tools/compat/compat_defs.h: revision 1.123

Include <arpa/inet.h> for htonl() (From Jan-Benedict Glaw)
Probably this should be using htobe32() instead of htonl()
(and so <endian.h> rather than <arpa/inet.h>) as there is
no sign of any network anywhere near here. But that's for
another day, and to be done by someone who can test it.

Portability fixes from Jan-Benedict Glaw
The args to help() and usage() need to be const char *
and main() should be declared as returning int.

Add shquote to libnbcompat
Include shquote() in configure tests
Regen for added shquote()

Stop attempting to return a (char*) in place of (const char *)
This removes a cast that was added in 1994, when __strsignal()
returned a char * to convert the const char * element of sys_siglist
into a type that matched.

It should have been removed when __strsignal() was changed to
return const char * in 1998. But wasn't.

This should fix an inane warning (treated as an error) from a
compile stupid enough to allow a natural char * (as in char buf[N])
to be returned as a result (which is, of course, fine), but complains
about returning (char *) applied to a (const char *).
 1.122.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed