aboutsummaryrefslogtreecommitdiff
path: root/lib/portability.h
AgeCommit message (Collapse)Author
2015-02-06Alright, the Android guys agree with the musl guys: ↵Rob Landley
faccessat(AT_SYMLINK_NOFOLLOW) is not supported.
2015-01-18Lift the basename/libgen.h shenanigans back out of portability.c and make it ↵Rob Landley
a static inline in portability.h, and prototype dirname() while we're at it.
2015-01-18fix non-glibc basename(3) usageElliott Hughes
I considered a #else on the big #ifdef __GLIBC__ above, but that seemed harder to follow.
2015-01-16Move pty.h back to toys.h (under LSB 4.1 headers).Rob Landley
2015-01-16AOSP master has <pty.h> and builds netcat/nc.Elliott Hughes
2015-01-16id.c #ifdefectomy. (ifdefs belong in headers, not in C code.)Rob Landley
2015-01-16This patch adds a TOYBOX_SELINUX configuration option to control bothElliott Hughes
the SELinux commands (such as chcon) and the SELinux-specific options to regular commands (such as ls -Z). This lets us #include <selinux/selinux.h> in portability.h. I've also fixed chcon to insist on being given the a context argument. This patch also adds -Z to id and fixes id's regular output (-G should be separated by spaces, non-G output should be separated by commas, and you don't want a double comma where the egid is omitted from the list of groups).
2014-12-31When you include the posix header libgen.h, glibc #defines basename to some ↵Rob Landley
random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
2014-12-04Work with buildroot's extensively patched uClibc, and for nommu support move ↵Rob Landley
xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
2014-11-22As long as Android's going to require fortify, fixup the warnings it generates.Rob Landley
2014-11-21A patch against your current ToT that builds in AOSP master.Elliott Hughes
2014-11-21Patch from Elliott Hughes for Android/bionic build.Rob Landley
2014-11-19Fixups for the android/bionic build probes patch.Rob Landley
The CFG_* symbols are always defined so if() can use them as compile-time constants, so don't if defined() them. Doing USE_BLAH() around variable definitions opens up the same potential for config-dependent build breaks as #ifdefs do, just make the whole command depend on the symbol for now, factor out the utmpx infrastructure later. The PTY probe was always failing because it used NULL without #including the header that defines it. Substitute 0 instead.
2014-11-19probe for getspnam(), forkpty(), utmpx, replace sethostname()Isaac Dunham
Android is missing all of these; we need to probe for some so we have a config symbol to depend on. sethostname() is easily replaced. We got termios.h via pty.h; now it's not included in configure-step tools, so we need termios.h to generate globals.
2014-10-02Workaround for musl's faccessat bug (the rm -r "error: is a directory" thing).0.5.0Rob Landley
The Linux man page says I can use AT_SYMLINK_NOFOLLOW. It works in glibc, uclibc, and klibc, but musl returns -EINVAL any time you pass in that flag and the maintainer says that's not a bug and insists the man page and those other libraries all change to match musl's behavior. Toybox uses it to avoid scheduling unnecessary metadata writes for things we're about to delete (have to chmod unreadable directories so we can descend into them to delete their contents, the chmod happens before we descend so the disk I/O has plenty of time to be scheduled) because the extra writes wear out SSD faster. It's just an optimization and I don't really care if it works _well_ (the fchmodat call _also_ takes AT_SYMLINK_NOFOLLOW so that's covered), but musl's behavior uniquely makes the check always error and thus breaks normal "rm -r". Yes this workaround is checking #ifdef __MUSL__ which the library does not supply (because its code is perfect and will thus never need to be worked around). You can CFLAGS=-D__MUSL__ if you don't echo "#define __MUSL__" >> include/features.h when installing the library.
2014-09-20Tweak portability.h for uClibc version in buildroot defconfig.Rob Landley
I've been locally patching uClibc to not violate posix-2008 (you don't need to define a GNU macro to get a posix function), but uClibc is obsolete and moribund (development peaked in 2006, last bugfix release was over 2 years ago), and the largest remaining user (buildroot) doesn't bother to apply such a patch. Since even buildroot is slowly migrating to musl-libc, just do the portability tweak for what the last release of the old thing actually did.
2014-09-06Work around uClibc brain-damage.Rob Landley
2014-08-12Patches to commands for issues reported from static analysis tool.Ashwini Sharma
portability.h.patch - it is for O_CLOEXEC, as compiler complained of it. Makefile.patch - for cleaning generated/*.o files and libopts.dat file [Fixup to uniq.c from Rob.]
2014-07-20Add utf8 support to ls -C.Rob Landley
Use wcwidth() instead of strlen(), and extend the -q substitution to also whiteout nonprintable characters that are nonparseable utf8 snippets.
2014-05-06Use compiler built-in macros to determine if argument parsing can use double ↵Rob Landley
or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
2014-04-15Probes for O_NOFOLLOW that compile and run something aren't compatible with ↵Rob Landley
cross compiling, so just #define it to 0 if it's not in fcntl.h where posix-2008 says.
2014-03-29Group headers by standard (POSIX or LSB) or function (internationalization, ↵Rob Landley
networking). Move headers standards ignore (but which have been there >15 years) to lib/portability.h. Fold xregcomp into lib since it's posix.
2014-01-28Two changes to shut up GCC:Isaac Dunham
* __GLIBC__ was checked unconditionally; this made for a very messy build on musl. * int fd in chvt is always initialized; GCC 3.4 does not recognize this.
2013-12-19Only define MNT_DETACH for old glibc, portability.h included _before_ ↵Rob Landley
sys/mount.h...
2013-12-19Regression test against Ancient Build Environment (Ubuntu 8.04), fixup bit-rot.Rob Landley
2013-03-11Compile time probe to fish O_NOFOLLOW out of linux headers when fcntl ↵0.4.4Rob Landley
doesn't conform to posix-2008.
2013-03-09O_NOFOLLOW is specified by posix-2008 and varies by target, don't try to ↵Rob Landley
supply them for broken headers.
2013-02-24Comment updates and a policy statement about avoiding #define GNU_dammitRob Landley
2013-02-04More support for old (~2008) build environments, move the #ifdef checks for ↵Rob Landley
symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
2013-01-15Work around more random uClibc-specific breakage.Rob Landley
2012-12-01Fix ancient glibc workaround to force fstatat64Rob Landley
2012-11-26The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some ↵Rob Landley
other stuff. Fix it up in portability.h.
2012-11-16More touch cleanup to use generic infrastructure: use getdate() from libc, ↵Rob Landley
use flag macros, option parsing can collect argument strings in global block, use existing perror_* macros.
2012-11-13Older versions of glibc predated posix-2008. They still provide most of what ↵0.4.1Rob Landley
we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
2012-06-16More header fiddling: crypt.h is silly, SUSv4 requires crypt() to be ↵Rob Landley
prototyped in unistd.h. The fact glibc refuses to do so without a wacky #define is a glibc bug, treat it as such.
2012-03-19Remove "feature test macros", replace non-portable fdprintf() with standard ↵Rob Landley
fprintf().
2012-03-16Implement Apple and Android versions of getline(), getdelim(), and clearenv().Georgi Chorbadzhiyski
2012-03-07Consolidate headers.Rob Landley
2010-01-06Shut up even MORE gcc/glibc spurious warnings.Rob Landley
2007-11-15Add noreturn mark to [p]error_exit(), suggested by Charlie Shepherd.Rob Landley
2007-02-13MacOS X has a defective sed with no -r.Rob Landley
2007-02-03Teach build to build only the toys/*.c selected in .config, and teachRob Landley
CFG_TOYSH_DEBUG to shut up the spurious "gcc can't tell that this is never actually used uninitialized because gcc is stupid" warnings.
2007-01-18Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, whichRob Landley
shouldn't be a problem if we register signal handlers with sigaction(SA_RESTART) Straighten out count and len (I generally consistently use "count" for the current progress and "len" for the total, but this time I got them backwards for some reason and don't want to confuse myself in future.)
2007-01-14Add start of mke2fs/gene2fs, and some other stuff I've been working on.Rob Landley