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 files COPYING and Copyright.html. COPYING can be found at the root * 9 * of the source code distribution tree; Copyright.html can be found at the * 10 * root level of an installed copy of the electronic HDF5 document set and * 11 * is linked from the top-level documents page. It can also be found at * 12 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 * access to either file, you may request a copy from help@hdfgroup.org. * 14 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 16 /* Programmer: Scott Wegner 17 * June 3, 2008 18 * 19 * Purpose: This file is used to map HDF macros to Windows functions. This 20 * should get included H5private mappings, so as to override them. 21 * Any macro not mapped here, however, will receive a similar mapping 22 * inside H5private.h 23 * 24 */ 25 26 #ifdef H5_HAVE_WIN32_API 27 28 typedef struct _stati64 h5_stat_t; 29 typedef __int64 h5_stat_size_t; 30 31 #define HDaccess(F,M) _access(F,M) 32 #define HDchdir(S) _chdir(S) 33 #define HDclose(F) _close(F) 34 #define HDdup(F) _dup(F) 35 #define HDfdopen(N,S) _fdopen(N,S) 36 #define HDfileno(F) _fileno(F) 37 #define HDfstat(F,B) _fstati64(F,B) 38 #define HDisatty(F) _isatty(F) 39 #define HDgetcwd(S,Z) _getcwd(S,Z) 40 #define HDgetdcwd(D,S,Z) _getdcwd(D,S,Z) 41 #define HDgetdrive() _getdrive() 42 #define HDlseek(F,O,W) _lseeki64(F,O,W) 43 #define HDlstat(S,B) _lstati64(S,B) 44 #define HDmkdir(S,M) _mkdir(S) 45 #define HDoff_t __int64 46 /* _O_BINARY must be set in Windows to avoid CR-LF <-> LF EOL 47 * transformations when performing I/O. 48 */ 49 #define HDopen(S,F,M) _open(S,F|_O_BINARY,M) 50 #define HDread(F,M,Z) _read(F,M,Z) 51 #define HDrmdir(S) _rmdir(S) 52 #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) 53 #define HDsleep(S) Sleep(S*1000) 54 #define HDstat(S,B) _stati64(S,B) 55 #define HDstrcasecmp(A,B) _stricmp(A,B) 56 #define HDstrtoull(S,R,N) _strtoui64(S,R,N) 57 #define HDstrdup(S) _strdup(S) 58 #define HDtzset() _tzset() 59 #define HDunlink(S) _unlink(S) 60 #define HDwrite(F,M,Z) _write(F,M,Z) 61 62 #ifdef H5_HAVE_VISUAL_STUDIO 63 /* 64 * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO 65 */ 66 #define HDmemset(X,C,Z) memset((void*)(X),C,Z) 67 68 struct timezone { 69 int tz_minuteswest; 70 int tz_dsttime; 71 }; 72 73 #ifdef __cplusplus 74 extern "C" { 75 #endif /* __cplusplus */ 76 H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); 77 H5_DLL char* Wgetlogin(void); 78 H5_DLL int HDsnprintf(char* str, size_t size, const char* format, ...); 79 H5_DLL int HDvsnprintf(char* str, size_t size, const char* format, va_list ap); 80 #ifdef __cplusplus 81 } 82 #endif /* __cplusplus */ 83 #define HDgettimeofday(V,Z) Wgettimeofday(V,Z) 84 #define HDgetlogin() Wgetlogin() 85 #define HDsnprintf HDsnprintf 86 #define HDvsnprintf HDvsnprintf 87 #endif /* H5_HAVE_VISUAL_STUDIO */ 88 89 /* Non-POSIX functions */ 90 91 /* Don't use actual pthread_self on Windows because the return 92 * type cannot be cast as a ulong like other systems. */ 93 #define HDpthread_self_ulong() ((unsigned long)GetCurrentThreadId()) 94 95 #ifndef H5_HAVE_MINGW 96 #define HDftruncate(F,L) _chsize_s(F,L) 97 #define HDfseek(F,O,W) _fseeki64(F,O,W) 98 #endif 99 #endif /* H5_HAVE_WIN32_API */ 100