summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/include/os_windows.h
blob: 49dbc6948959226ff7a895323f8a49023ba982eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*-
 * Copyright (c) 2014-2015 MongoDB, Inc.
 * Copyright (c) 2008-2014 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
 */

/*
 * Define WT threading and concurrency primitives
 * Assumes Windows 7+/2008 R2+
 */
typedef CONDITION_VARIABLE	wt_cond_t;
typedef CRITICAL_SECTION	wt_mutex_t;
typedef HANDLE			wt_thread_t;

/* Timespec is a POSIX structure not defined in Windows */
struct timespec {
	time_t tv_sec;		/* seconds */
	long   tv_nsec;		/* nanoseconds */
};

#define	strncasecmp _strnicmp

/*
 * Windows Portability stuff
 * These are POSIX types which Windows lacks
 * Eventually WiredTiger will migrate away from these types
 */
typedef uint32_t	u_int;
typedef unsigned char	u_char;
typedef unsigned long	u_long;

/* <= VS 2013 is not C99 compat */
#if _MSC_VER < 1900
#define	snprintf _wt_snprintf

_Check_return_opt_ int __cdecl _wt_snprintf(
    _Out_writes_(_MaxCount) char * _DstBuf,
    _In_ size_t _MaxCount,
    _In_z_ _Printf_format_string_ const char * _Format, ...);
#endif

/*
 * Windows does have ssize_t
 * Python headers declare also though so we need to guard it
 */
#ifndef HAVE_SSIZE_T
typedef int ssize_t;
#endif

/*
 * Provide a custom version of vsnprintf that returns the
 * needed buffer length instead of -1 on truncation
 */
#define	vsnprintf _wt_vsnprintf

_Check_return_opt_ int __cdecl _wt_vsnprintf(
    _Out_writes_(_MaxCount) char * _DstBuf,
    _In_ size_t _MaxCount,
    _In_z_ _Printf_format_string_ const char * _Format,
    va_list _ArgList);

/* Provide a custom version of localtime_r */
struct tm *localtime_r(const time_t* timer, struct tm* result);