1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 * Copyright by The HDF Group. * 3 * Copyright by the Board of Trustees of the University of Illinois. * 4 * All rights reserved. * 5 * * 6 * This file is part of HDF5. The full HDF5 copyright notice, including * 7 * terms governing use, modification, and redistribution, is contained in * 8 * the COPYING file, which can be found at the root of the source code * 9 * distribution tree, or in https://www.hdfgroup.org/licenses. * 10 * If you do not have access to either file, you may request a copy from * 11 * help@hdfgroup.org. * 12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 13 14 /* Purpose: This file is used to map HDF macros to Windows functions. This 15 * should get included H5private mappings, so as to override them. 16 * Any macro not mapped here, however, will receive a similar mapping 17 * inside H5private.h 18 * 19 */ 20 21 /* _MSC_VER = 192x VS2019 22 * _MSC_VER = 191x VS2017 23 * _MSC_VER = 1900 VS2015 24 * _MSC_VER = 1800 VS2013 25 * _MSC_VER = 1700 VS2012 26 */ 27 #ifdef H5_HAVE_WIN32_API 28 29 typedef struct _stati64 h5_stat_t; 30 typedef __int64 h5_stat_size_t; 31 32 #define HDaccess(F, M) _access(F, M) 33 #define HDchdir(S) _chdir(S) 34 #define HDclose(F) _close(F) 35 #define HDcreat(S, M) Wopen_utf8(S, O_CREAT | O_TRUNC | O_RDWR, M) 36 #define HDdup(F) _dup(F) 37 #define HDfdopen(N, S) _fdopen(N, S) 38 #define HDfileno(F) _fileno(F) 39 #define HDfstat(F, B) _fstati64(F, B) 40 #define HDisatty(F) _isatty(F) 41 42 #define HDgetcwd(S, Z) _getcwd(S, Z) 43 #define HDgetdcwd(D, S, Z) _getdcwd(D, S, Z) 44 #define HDgetdrive() _getdrive() 45 #define HDlseek(F, O, W) _lseeki64(F, O, W) 46 #define HDlstat(S, B) _lstati64(S, B) 47 #define HDmkdir(S, M) _mkdir(S) 48 #define HDnanosleep(N, O) Wnanosleep(N, O) 49 #define HDoff_t __int64 50 51 /* Note that the variadic HDopen macro is using a VC++ extension 52 * where the comma is dropped if nothing is passed to the ellipsis. 53 */ 54 #ifndef H5_HAVE_MINGW 55 #define HDopen(S, F, ...) Wopen_utf8(S, F, __VA_ARGS__) 56 #else 57 #define HDopen(S, F, ...) Wopen_utf8(S, F, ##__VA_ARGS__) 58 #endif 59 #define HDread(F, M, Z) _read(F, M, Z) 60 #define HDremove(S) Wremove_utf8(S) 61 #define HDrmdir(S) _rmdir(S) 62 #define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, (Z > 1 ? Z : 2)) 63 #define HDsleep(S) Sleep(S * 1000) 64 #define HDstat(S, B) _stati64(S, B) 65 #define HDstrcasecmp(A, B) _stricmp(A, B) 66 #define HDstrdup(S) _strdup(S) 67 #define HDstrtok_r(X, Y, Z) strtok_s(X, Y, Z) 68 #define HDtzset() _tzset() 69 #define HDunlink(S) _unlink(S) 70 #define HDwrite(F, M, Z) _write(F, M, Z) 71 72 #ifdef H5_HAVE_VISUAL_STUDIO 73 74 /* 75 * The (void*) cast just avoids a compiler warning in MSVC 76 */ 77 #define HDmemset(X, C, Z) memset((void *)(X), C, Z) 78 79 struct timezone { 80 int tz_minuteswest; 81 int tz_dsttime; 82 }; 83 84 #endif /* H5_HAVE_VISUAL_STUDIO */ 85 86 #ifdef __cplusplus 87 extern "C" { 88 #endif /* __cplusplus */ 89 H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); 90 H5_DLL int Wsetenv(const char *name, const char *value, int overwrite); 91 H5_DLL int Wflock(int fd, int operation); 92 H5_DLL char * Wgetlogin(void); 93 H5_DLL herr_t H5_expand_windows_env_vars(char **env_var); 94 H5_DLL wchar_t *H5_get_utf16_str(const char *s); 95 H5_DLL int Wopen_utf8(const char *path, int oflag, ...); 96 H5_DLL int Wremove_utf8(const char *path); 97 H5_DLL int H5_get_win32_times(H5_timevals_t *tvs); 98 #ifdef __cplusplus 99 } 100 #endif /* __cplusplus */ 101 102 #define HDgettimeofday(V, Z) Wgettimeofday(V, Z) 103 #define HDsetenv(N, V, O) Wsetenv(N, V, O) 104 #define HDflock(F, L) Wflock(F, L) 105 #define HDgetlogin() Wgetlogin() 106 107 /* Non-POSIX functions */ 108 109 #ifndef H5_HAVE_MINGW 110 #define HDftruncate(F, L) _chsize_s(F, L) 111 #define HDfseek(F, O, W) _fseeki64(F, O, W) 112 #endif /* H5_HAVE_MINGW */ 113 114 #endif /* H5_HAVE_WIN32_API */ 115