Embedding compat32 calls is basically the inverse of a dualmode library. Instead of renaming largefile64 functions into a new call with a "64" suffix one would continue the normal compilation process where the normal functions are compiled in largefile64 mode - additionally one does add a second series of functions using the traditional "long" instead of "off_t". These should be given a suffix of "32" to differentiate them from the other calls.
The actual advantage over a dualmode library is in the fact that the library header files do not really need #ifdefs. It is just required that any function with a "off_t" arguments gets a sister call with "long" arguments in the same place. This looks like so..
extern off64_t myseek(int fd, off64_t seek, int whence); extern long myseek32(int fd, long seek, int whence);
The standard implementation of the myseek32 would be a wrapper around the largefile64 variant. On a 64bit system it happens that both "long" and "off64_t" are the same size, so we try to ask the compiler to detect the situation and "remove unreachable code" (which modern C compilers can actually do). Essentially the code template looks like so...
#ifndef EOVERFLOW #define EOVERFLOW EFBIG #endif long myseek32(MYFILE * fp, long offset, int whence) { if (sizeof(off64_t) == sizeof(long)) { return myseek(fp, offset, whence); /* << largefile64 */ } else { off64_t off = myseek(fp, offset, whence); if (off >= 0) { register long off32 = off; if (off32 == off) return off32; errno = EOVERFLOW; } return -1; } }