aboutsummaryrefslogtreecommitdiff
path: root/lib/portability.h
AgeCommit message (Collapse)Author
2018-10-04Make it possible to build the AOSP .config against glibc.Elliott Hughes
It's possible that we should just pull setprop back out of toybox to live with getprop in system/core/, but this lets us build the same toybox configuration for device and host in AOSP. (Longer term we'd like to use host bionic, but if we enable this we can start experimenting on the tobyox side before the bionic side is finished.)
2018-09-15Fix glibc build after 013876f067a11ebfcf47789921b376e7bf3bf5b8.Elliott Hughes
/usr/include/unistd.h:626:15: error: conflicting types for 'confstr'
2018-09-08Tweaks to make building with Android NDK's llvm happier.Rob Landley
2018-07-04Add xgetrandom() with probe for new system call (else open/read /dev/{,u}random)Rob Landley
2018-01-01Cleanup logger.c, and move the facilitynames/prioritynames SYSLOG_NAMESRob Landley
stuff syslog.h does into lib.c and portability.h
2017-05-21Cleaup chrtRob Landley
2017-05-08Remove old uClibc compatibility glue. It's been 5 years since the last release.Rob Landley
See http://lists.busybox.net/pipermail/buildroot/2016-December/180102.html for a full post-mortem on the project.
2017-04-30Android NDK doesn't have cutils/sched_policy.h so add a probed config symbol.Rob Landley
2017-02-20Fix dmesg -c and -C.Elliott Hughes
I never use these, so I didn't notice I'd broken them until someone who does bringup complained. The "one weird trick" with SEEK_DATA is documented at the URL we already point to. SEEK_DATA was added in Linux 3.1 (2011) and isn't available in glibc 2.19 (2014), so I've added that to "portability.h" for the benefit of Ubuntu 14.04. Also make -c and -C mutually exclusive. Also fix some of the formatting I introduced earlier. (A clang-format file would help prevent these mistakes...)
2016-05-04Simplify ps android scheduling policy fetch slightly.Rob Landley
2016-04-30Add a ps "PCY" field for Android scheduling policy.Elliott Hughes
2016-04-08Redefining basename_r to mean something random seems popular (bionic and freebsdRob Landley
both did it) so use getbasename instead.
2016-03-01The last-ever release of uClibc didn't #define MS_RELATIME.Rob Landley
2016-02-18RLIMIT_RTTIME was added to the kernel in 2008, you can't expect uClibc to ↵Rob Landley
have noticed yet.
2016-02-09Add ulimit.Rob Landley
This isn't a shell builtin, it uses prlimit to target any pid (without -P it defaults to $PPID, so acts like historical ulimit by default).
2016-01-05Add error_msg_raw() and friends, replace error_msg("%s", s) uses, enable formatRob Landley
checking, and fix up format checking complaints. Added out(type, value) function to stat to avoid a zillion printf typecasts.
2015-08-30Add portability.h glue to let uptime build without TOYBOX_UTMPX.Rob Landley
2015-07-11Fix 32-bit bionic toybox build.Elliott Hughes
https://android-review.googlesource.com/159035/
2015-05-18More ls -Z upgrading. Move TOYBOX_SELINUX and TOYBOX_SMACK support fromRob Landley
portability.h to new lib/lsm.h. Update ls.c to use it. Fix "ls . toys" (two directories when one is . or ..), which was filtering out the . as something we shouldn't recurse into even though it was explicitly listed on the command line. For some reason "ls -Z . toys" is still segfaulting though (but "ls -Z ." isn't), need to figure out why...
2015-05-08Move not-curses code into interstingtimes.cRob Landley
2015-05-03Move a prototype to the start of portability.h (suggested by Elliott Hughes)Rob Landley
2015-05-01Portability bits for the recent ls smack changes.Rob Landley
2015-04-17Link against libattr and libsmack.Xavier Roche
2015-04-15Put SELINUX in a a menu, and add config option for SMACK.Rob Landley
2015-03-01Only switch on printf format warnings for error_exit() and friends when ↵Rob Landley
TOYBOX_DEBUG enabled. One again gcc manages to be incompetent about producing warnings. For example, in bzcat we error_exit() with a message that's an error code fed into an array of string constants, and apparently dereferencing an array of string literals doesn't give you a string literal according to -Wformat-security. Not breaking the code to humor the compiler here, the compiler is wrong.
2015-03-01let the compiler check format stringsElliott Hughes
i'll be AFK for a week, so here's the patch i've been using this evening to find other format string mistakes. BSD uses __printflike and takes two arguments instead of hard-coding (1,2), but i figured that as long as you don't need the generality you'd prefer not to have it. and it's easy enough to retrofit if we ever do have a formatting function that takes other arguments.
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...