exec: Avoid lstrcpyn on windows and just use snprintf()
[jimtcl.git] / jim-win32compat.h
blobedd29c383a3306fa29692c2d783b0d9b673a8b71
1 #ifndef JIM_WIN32COMPAT_H
2 #define JIM_WIN32COMPAT_H
4 /* Compatibility for Windows (mingw and msvc, not cygwin */
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 /* Note that at this point we don't yet have access to jimautoconf.h */
11 #if defined(_WIN32) || defined(WIN32)
13 #define HAVE_DLOPEN
14 void *dlopen(const char *path, int mode);
15 int dlclose(void *handle);
16 void *dlsym(void *handle, const char *symbol);
17 char *dlerror(void);
19 /* MinGW MS CRT always uses three digits after 'e' */
20 #if defined(__MINGW32__)
21 #define JIM_SPRINTF_DOUBLE_NEEDS_FIX
22 #endif
24 #ifdef _MSC_VER
25 /* These are msvc vs gcc */
27 #if _MSC_VER >= 1000
28 #pragma warning(disable:4146)
29 #endif
31 #include <limits.h>
32 #define jim_wide _int64
33 #ifndef LLONG_MAX
34 #define LLONG_MAX 9223372036854775807I64
35 #endif
36 #ifndef LLONG_MIN
37 #define LLONG_MIN (-LLONG_MAX - 1I64)
38 #endif
39 #define JIM_WIDE_MIN LLONG_MIN
40 #define JIM_WIDE_MAX LLONG_MAX
41 #define JIM_WIDE_MODIFIER "I64d"
42 #define strcasecmp _stricmp
43 #define strtoull _strtoui64
44 #define snprintf _snprintf
46 #include <io.h>
48 struct timeval {
49 long tv_sec;
50 long tv_usec;
53 int gettimeofday(struct timeval *tv, void *unused);
55 #define HAVE_OPENDIR
56 struct dirent {
57 char *d_name;
60 typedef struct DIR {
61 long handle; /* -1 for failed rewind */
62 struct _finddata_t info;
63 struct dirent result; /* d_name null iff first time */
64 char *name; /* null-terminated char string */
65 } DIR;
67 DIR *opendir(const char *name);
68 int closedir(DIR *dir);
69 struct dirent *readdir(DIR *dir);
71 #elif defined(__MINGW32__)
73 #include <stdlib.h>
74 #define strtod __strtod
76 #endif
78 #endif /* WIN32 */
80 #ifdef __cplusplus
82 #endif
84 #endif