On 29 March 2016 at 23:54, Rob Landley <[email protected]> wrote: > > There are also a number of places where we know what the Linux > information is, and use that. For example, in ifconfig: > > // Is this an SIOCSI entry? > if ((off|0xff) == 0x89ff) {
Yes, I suspect tools like ifconfig and ps would need completely separate implementations for non-Linux systems, but I believe many of the will have no portability troubles. At first I'd be happy to just avoid building the Linux-specific ones. > Why is expecting /usr/bin/env to be at a specific absolute path less > constraining than expecting bash to be at a specific absolute path? > > I've never understood that one... Because /usr/bin/env is universally available on relevant UNIX-like systems (POSIX requires it), and /bin/bash is not. >> Another error shows up in a few spots due to conflicts between a >> couple of toybox functions and libc: >> >> ./lib/lib.h:204:7: error: conflicting types for 'strnstr' >> char *strnstr(char *line, char *str); >> ./lib/lib.h:289:7: error: conflicting types for 'basename_r' >> char *basename_r(char *name); > > In neither case did you say what the conflicting definition was. What > header they came from, how they're defining those prototypes... strnstr is: /usr/include/string.h:char *strnstr(const char *, const char *, size_t) __pure; It originated in FreeBSD, but it hasn't been adopted widely elsewhere as I thought (OS X has it though). It examines not more than the given number of characters in the search string. basename_r is: /usr/include/libgen.h:char *basename_r(const char *, char *); Where a buffer is passed in to store the result. I see bionic implements a similar basename_r but they sensibly pass a size_t for the buffer length as well; FreeBSD just requires that the provided buffer is at least MAXPATHLEN bytes. > That said, we have lib/portability.c and lib/portability.h to paper over > that sort of issue. Thanks, I'll see what's being done for other systems already. _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
