From: Oliver Kurth Date: Mon, 26 Feb 2018 20:29:06 +0000 (-0800) Subject: vm_basic_types.h: scrub FMTxx specifiers X-Git-Tag: stable-10.3.0~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3af8139cfcb4578dd9d7cd9a85301ed808775eb4;p=thirdparty%2Fopen-vm-tools.git vm_basic_types.h: scrub FMTxx specifiers Reduce the amount of magic in vm_basic_types.h... nowadays, any system we support (including Tools) DEFINITELY supports C99-style specifiers, with two exceptions: pre-vs2015 MSVC, and pre-10.13 macOS kernels. Rip out all the pre-C99 junk. Add a few comments explaining exactly what the caveats here are. --- diff --git a/open-vm-tools/lib/include/vm_basic_types.h b/open-vm-tools/lib/include/vm_basic_types.h index d27f5f8c7..a92e0f92a 100644 --- a/open-vm-tools/lib/include/vm_basic_types.h +++ b/open-vm-tools/lib/include/vm_basic_types.h @@ -372,6 +372,7 @@ typedef int64 VmTimeVirtualClock; /* Virtual Clock kept in CPU cycles */ */ #ifdef _MSC_VER + /* MSVC added C99-compatible formatting in vs2015. */ #define FMT64 "I64" #ifdef VM_X86_64 #define FMTSZ "I64" @@ -383,53 +384,29 @@ typedef int64 VmTimeVirtualClock; /* Virtual Clock kept in CPU cycles */ #define FMTH "I" #endif #elif defined __APPLE__ - /* Mac OS hosts use the same formatters for 32- and 64-bit. */ - #define FMT64 "ll" + /* macOS hosts use the same formatters for 32- and 64-bit. */ + #define FMT64 "ll" #if KERNEL - #define FMTSZ "l" + /* macOS osfmk/kern added 'z' length specifier in 10.13 */ + #define FMTSZ "l" #else - #define FMTSZ "z" - #endif - #define FMTPD "l" - #define FMTH "" -#elif __GNUC__ - #define FMTH "" - #if defined(sun) - #if defined(VM_X86_64) || defined(VM_ARM_64) - #define FMTSZ "l" - #define FMTPD "l" - #else - #define FMTSZ "" - #define FMTPD "" - #endif - #elif defined(__linux__) || \ - (defined(__FreeBSD__) && (__FreeBSD__ + 0))\ - || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \ - || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \ - || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L) - /* BSD, Linux */ - #define FMTSZ "z" - - #if defined(VM_X86_64) || defined(VM_ARM_64) - #define FMTPD "l" - #else - #define FMTPD "" - #endif - #else - /* Systems with a pre-C99 libc */ - #define FMTSZ "Z" - #if defined(VM_X86_64) || defined(VM_ARM_64) - #define FMTPD "l" - #else - #define FMTPD "" - #endif + #define FMTSZ "z" #endif + #define FMTPD "l" + #define FMTH "" +#elif defined __GNUC__ + /* + * Every POSIX system we target has C99-compatible printf + * (supports 'z' for size_t and 'll' for long long). + */ + #define FMTH "" + #define FMTSZ "z" #if defined(VM_X86_64) || defined(VM_ARM_64) - #define FMT64 "l" - #elif defined(sun) || defined(__FreeBSD__) || defined(__ANDROID__) - #define FMT64 "ll" + #define FMT64 "l" + #define FMTPD "l" #else - #define FMT64 "L" + #define FMT64 "ll" + #define FMTPD "" #endif #else #error - Need compiler define for FMT64 and FMTSZ