<stdlib.h>/<unistd.h>: Expose mkdtemp()'s prototype also if XSI is visible. The history of this function in the specs seems to be a bit convoluted for this function, to say the least. Even though I can't find it in either Issue 5 or 6, go with what Issue 7's HISTORY says and treat it like it was moved from XSI to base starting with Issue 7: http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdtemp.html Most importantly, this commit fixes x11/xterm which was building but segfaulting after 8eb95a5667325. Reported-by: Rimvydas Jasinskas <rimvydas.jasinskas@gmail.com>
Fix visibility of various functions in a number of headers. The following functions were moved from XSI into the base with POSIX 200809: catclose(), catgets(), catopen(), dlclose(), dlerror(), dlopen(), dlsym(), fchdir(), getpgid(), getsid(), getsubopt(), iconv(), iconv_close(), iconv_open(), lchown(), mkstemp(), nl_langinfo(), poll(), pread(), pwrite(), strdup(), strfmon(), tcgetsid(), truncate(), and waitid(). This commit adjusts our headers to reflect that, i.e. specifying _POSIX_C_SOURCE=200809 is now enough to expose their prototypes. The checking of __XSI_VISIBLE's value (ranges) for XSI functions could certainly be better (generally in our headers). Also, we don't yet have waitid(). This change was build tested with around 8000 ports (until the bulk build choked on a jdk7 memory leak (I suppose) while building textproc/fop). The glibc conformance test suite thinks this commit is correct, too.
Add support for various sysconf(3) / confstr(3) / getconf(1) constants. _SC_V7_ILP32_OFF32 _SC_V7_ILP32_OFFBIG _SC_V7_LP64_OFF64 _SC_V7_LPBIG_OFFBIG _CS_POSIX_V7_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LIBS _CS_POSIX_V7_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS
<unistd.h>: Clean up the _POSIX2_* defines (Shells and Utilities options). * Bump the _POSIX2_C_BIND, _POSIX2_FORT_RUN and _POSIX2_UPE defines to 200809. * Define _POSIX2_C_DEV, _POSIX2_LOCALEDEF and _POSIX2_SW_DEV to 200809. * Improve comments. Things I know of that we still have to do: * For 100% _POSIX2_UPE conformance we still need to implement at least sh(1)'s HISTFILE and MAILCHECK environment variables. * For 100% _POSIX2_SW_DEV conformance we still need to implement at least make(1)'s -p option.
Kernel - Implement swapoff * Generally port of the swapoff implementation from FreeBSD to DragonFly, with major modifications. Modifications to handle swapcache issues (VCHR vnodes with VM objects can have swap associations for swapcache). * Libkvm changes So there are two problems with libkvm. The first is not really swapoff-related - the new sysctl way of reporting numbers bzero'es swap_max elements in the given swap_ary array. This is in contrast to the old kvm way, which bzero'es only those elements that will be actually filled. So if we have 3 swap devices and swap_max is 16, then the sysctl code will zero out all 16 elements and fill the first 4, while the old kvm code will zero out exactly 4 elements and fill them. Since we want to keep API stable (I learned it the hard way :-) ) I think this fix can be separated out and go to master as a bugfix to the newly introduced sysctl way of reporting things. The second problem only shows up if we introduce a swapoff syscall and enforce using of the old kvm way. It was written with the assumption that swap devices can only be added, not removed - it assumes than if I have a swap device with index 3, 4 swap devices are active. This is not true with swapoff - I can swapon A, B, C and D, then swapoff B and C and here we are - I have an active swap device with index 3, but only 2 devices are active. It turned out to be easier to just rewrite it (based on sysctl way), because that assumption was rather deep and everything was based on it. Since along with sysctl way per-device swap accounting was introduced, the kvm way now uses it instead of scanning blist. Which brings us to the last change - blist scanning code is now used only for debugging purposes. getswapinfo_radix() is now called only if DUMP_TREE flag is set. Pieces that touched swap_ary entries are removed, swap_ary and swap_max are no longer passed to scanning code. After all that both ways are now working correctly with the regards to the swapoff call and the old kvm way (the behaviour is exactly the same, all boudary cases were tested, API remains the same). The only (minor) difference is that swapctl numbers are a little bit bigger than kvm way ones. Thats because kvm way subtracts dmmax (the assumption is that the first dmmax is never allocated), and sysctl way does not. I tried to fix this, but it turns out that we need to introduce a dmmax sysctl for that. So if you want I can add it, but I want to hear from you first (both on this thing and my changes to libkvm in general). * Userspace. Add swapoff & adjust manual pages. Note: Bounty project ($300) Submitted-by: Ilya Dryomov <idryomov@gmail.com>