From: Oliver Kurth Date: Thu, 8 Feb 2018 00:39:25 +0000 (-0800) Subject: Common header file changes not applicable to open-vm-tools. X-Git-Tag: stable-10.3.0~126 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7be0019e01c7d473deffb8b8646fce1dff22e11a;p=thirdparty%2Fopen-vm-tools.git Common header file changes not applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/include/safetime.h b/open-vm-tools/lib/include/safetime.h index fca72bc73..fd56da2b3 100644 --- a/open-vm-tools/lib/include/safetime.h +++ b/open-vm-tools/lib/include/safetime.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2004-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2004-2018 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -24,20 +24,8 @@ * temporary until we switch to a newer version of * Visual Studio that uses the 64-bit verisions by default. * - * In Windows, the user is allowed to set the time past the - * 32-bit overflow date (in 2038), which can cause crashes - * and security problems. In Linux, the time can't be set - * to overflow, so we do nothing. - * - * NB: We do not know if one can set the time past 2038 in - * 64-bit versions of Linux, and, if so, what happens when - * one does. This requires further investigation sometime - * in the future. - * - * The stat types and functions must be defined manually, - * since they contain time_ts, and we can't use the macro - * trick, since the struct stat and the function stat have - * the same 32 bit name (but different 64 bit names). + * NB: We have switched; existence of this header is temporary + * until include sites can be updated. * */ @@ -46,135 +34,12 @@ #ifdef _WIN32 -#undef FMTTIME -#define FMTTIME FMT64"d" - -#if (_MSC_VER < 1400) - -#if (defined(_STAT_DEFINED) || defined(_INC_TIME) || defined(_INC_TYPES)) -#error Use safetime.h instead of time.h, stat.h, and types.h -#endif - -#define _STAT_DEFINED - -#include -#include -#include - -#define time_t __time64_t -#define time(a) _time64(a) -#define localtime(a) _localtime64((a)) - -#define _ctime(a) _ctime64((a)) -#define ctime(a) _ctime64((a)) - -#define _ftime(a) _ftime64((a)) -#define ftime(a) _ftime64((a)) -#define _timeb __timeb64 - -#define _gmtime(a) _gmtime64((a)) -#define gmtime(a) _gmtime64((a)) - -#define _mktime(a) _mktime64((a)) -#define mktime(a) _mktime64((a)) - -#define _utime(a,b) _utime64((a),(b)) -#define utime(a,b) _utime64((a),(b)) -#define _utimbuf __utimbuf64 -#define utimbuf __utimbuf64 - -#define _wctime(a) _wctime64((a),(b)) -#define wctime(a) _wctime64((a),(b)) - -#define _futime(a,b) _futime64((a),(b)) -#define futime(a,b) _futime64((a),(b)) - -#define _wutime(a,b) _wutime64((a),(b)) -#define wutime(a,b) _wutime64((a),(b)) - -#include - -#ifdef _MSC_VER -#pragma pack(push,8) -#endif - -struct _stat { - _dev_t st_dev; - _ino_t st_ino; - unsigned short st_mode; - short st_nlink; - short st_uid; - short st_gid; - _dev_t st_rdev; - __int64 st_size; - __time64_t st_atime; - __time64_t st_mtime; - __time64_t st_ctime; - }; - -struct stat { - _dev_t st_dev; - _ino_t st_ino; - unsigned short st_mode; - short st_nlink; - short st_uid; - short st_gid; - _dev_t st_rdev; - __int64 st_size; - __time64_t st_atime; - __time64_t st_mtime; - __time64_t st_ctime; - }; - -struct __stat64 { - _dev_t st_dev; - _ino_t st_ino; - unsigned short st_mode; - short st_nlink; - short st_uid; - short st_gid; - _dev_t st_rdev; - __int64 st_size; - __time64_t st_atime; - __time64_t st_mtime; - __time64_t st_ctime; - }; - -#ifdef _MSC_VER -#pragma pack(pop) -#endif - -#include - -#define stat(a,b) _stat64((a),(struct __stat64*)(b)) -#define _stat(a,b) _stat64((a),(struct __stat64*)(b)) - -#define fstat(a,b) _fstat64((a),(struct __stat64*)(b)) -#define _fstat(a,b) _fstat64((a),(struct __stat64*)(b)) - -#define wstat(a,b) _wstat64((a),(struct __stat64*)(b)) -#define _wstat(a,b) _wstat64((a),(struct __stat64*)(b)) - -#else /* (_MSC_VER < 1400) */ - -/* - * Starting with VC80, we can pick between 32-bit and 64-bit time_t - * by defining or not defining _USE_32BIT_TIME_T. Don't define it. - */ - #include #include #include #include #include -/* Make sure that the headers didn't revert to 32-bit. */ -#ifdef _USE_32BIT_TIME_T -#error Refusing to use 32-bit time_t in safetime.h -#endif - -#endif /* (_MSC_VER < 1400) */ - #else #include diff --git a/open-vm-tools/lib/include/vm_basic_types.h b/open-vm-tools/lib/include/vm_basic_types.h index d59bc8f06..d27f5f8c7 100644 --- a/open-vm-tools/lib/include/vm_basic_types.h +++ b/open-vm-tools/lib/include/vm_basic_types.h @@ -777,6 +777,14 @@ typedef void * UserVA; #error "gcc version is too old to compile assembly, need gcc-3.3 or better" #endif +/* + * Similarly, we require a compiler that is at least vc80 (vs2005). + * Enforce this here. + */ +#if defined _MSC_VER && _MSC_VER < 1400 +#error "cl.exe version is too old, need vc80 or better" +#endif + /* * Consider the following reasons functions are inlined: @@ -1108,33 +1116,6 @@ typedef void * UserVA; # define FMTMODE "o" #endif -/* - * Format modifier for printing time_t. Most platforms define a time_t to be - * a long int, but on FreeBSD (as of 5.0, it seems), the time_t is a signed - * size quantity. Refer to the definition of FMTSZ to see why we need silly - * preprocessor arithmetic. - * Use this like this: printf("The mode is %" FMTTIME ".\n", time); - */ -#if defined(__FreeBSD__) && (__FreeBSD__ + 0) && ((__FreeBSD__ + 0) >= 5) -# define FMTTIME FMTSZ"d" -#else -# if defined(_MSC_VER) -# ifndef _SAFETIME_H_ -# if (_MSC_VER < 1400) || defined(_USE_32BIT_TIME_T) -# define FMTTIME "ld" -# else -# define FMTTIME FMT64"d" -# endif -# else -# ifndef FMTTIME -# error "safetime.h did not define FMTTIME" -# endif -# endif -# else -# define FMTTIME "ld" -# endif -#endif - #ifdef __APPLE__ /* * Format specifier for all these annoying types such as {S,U}Int32