Mercurial > hg > orthanc
annotate Resources/Patches/glog-visual-studio-port.h @ 1068:f54a9c6fea5d
documentation of plugin sdk
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 28 Jul 2014 11:34:01 +0200 |
parents | f25c79497739 |
children | 929bf8c2123d |
rev | line source |
---|---|
1059
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /* Copyright (c) 2008, Google Inc. |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * All rights reserved. |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Redistribution and use in source and binary forms, with or without |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * modification, are permitted provided that the following conditions are |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * met: |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * * Redistributions of source code must retain the above copyright |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * notice, this list of conditions and the following disclaimer. |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * * Redistributions in binary form must reproduce the above |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * copyright notice, this list of conditions and the following disclaimer |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * in the documentation and/or other materials provided with the |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * distribution. |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * * Neither the name of Google Inc. nor the names of its |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * contributors may be used to endorse or promote products derived from |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * this software without specific prior written permission. |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 * --- |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 * Author: Craig Silverstein |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 * Copied from google-perftools and modified by Shinichiro Hamaji |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 * |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 * These are some portability typedefs and defines to make it a bit |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 * easier to compile this code under VC++. |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 * |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 * Several of these are taken from glib: |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 * http://developer.gnome.org/doc/API/glib/glib-windows-compatability-functions.html |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 #ifndef CTEMPLATE_WINDOWS_PORT_H_ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 #define CTEMPLATE_WINDOWS_PORT_H_ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 #include "config.h" |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 #ifdef _WIN32 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 #define WIN32_LEAN_AND_MEAN /* We always want minimal includes */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 #include <windows.h> |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 #include <winsock.h> /* for gethostname */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 #include <io.h> /* because we so often use open/close/etc */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 #include <direct.h> /* for _getcwd() */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 #include <process.h> /* for _getpid() */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 #include <stdio.h> /* read in vsnprintf decl. before redifining it */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 #include <stdarg.h> /* template_dictionary.cc uses va_copy */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 #include <string.h> /* for _strnicmp(), strerror_s() */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 #include <time.h> /* for localtime_s() */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 /* Note: the C++ #includes are all together at the bottom. This file is |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 * used by both C and C++ code, so we put all the C++ together. |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 /* 4244: otherwise we get problems when substracting two size_t's to an int |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 * 4251: it's complaining about a private struct I've chosen not to dllexport |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 * 4355: we use this in a constructor, but we do it safely |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 * 4715: for some reason VC++ stopped realizing you can't return after abort() |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 * 4800: we know we're casting ints/char*'s to bools, and we're ok with that |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror() |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 #pragma warning(disable:4244 4251 4355 4715 4800 4996) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 /* file I/O */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 #define PATH_MAX 1024 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 #define access _access |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 #define getcwd _getcwd |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 #define open _open |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 #define read _read |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 #define write _write |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 #define lseek _lseek |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 #define close _close |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 #define popen _popen |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 #define pclose _pclose |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 #define R_OK 04 /* read-only (for access()) */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 #ifndef __MINGW32__ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2 }; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 #endif |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 #define S_IRUSR S_IREAD |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 #define S_IWUSR S_IWRITE |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 /* Not quite as lightweight as a hard-link, but more than good enough for us. */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 #define link(oldpath, newpath) CopyFileA(oldpath, newpath, false) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 #define strcasecmp _stricmp |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 #define strncasecmp _strnicmp |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 /* In windows-land, hash<> is called hash_compare<> (from xhash.h) */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 #if _MSC_VER < 1700 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 #define hash hash_compare |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 #endif |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 /* Sleep is in ms, on windows */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 #define sleep(secs) Sleep((secs) * 1000) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 /* We can't just use _vsnprintf and _snprintf as drop-in-replacements, |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 * because they don't always NUL-terminate. :-( We also can't use the |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 * name vsnprintf, since windows defines that (but not snprintf (!)). |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 extern int snprintf(char *str, size_t size, |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 const char *format, ...); |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 extern int safe_vsnprintf(char *str, size_t size, |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 const char *format, va_list ap); |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 #define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 #define va_copy(dst, src) (dst) = (src) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 /* Windows doesn't support specifying the number of buckets as a |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 * hash_map constructor arg, so we leave this blank. |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 #define CTEMPLATE_SMALL_HASHTABLE |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 #define DEFAULT_TEMPLATE_ROOTDIR ".." |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 // ----------------------------------- SYSTEM/PROCESS |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 typedef int pid_t; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 #define getpid _getpid |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 // ----------------------------------- THREADS |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 typedef DWORD pthread_t; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 typedef DWORD pthread_key_t; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 typedef LONG pthread_once_t; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 enum { PTHREAD_ONCE_INIT = 0 }; // important that this be 0! for SpinLock |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 #define pthread_self GetCurrentThreadId |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 #define pthread_equal(pthread_t_1, pthread_t_2) ((pthread_t_1)==(pthread_t_2)) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 #if defined(__MINGW32__) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 inline int localtime_s(tm * _tm, const time_t * time) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 { |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 tm * posix_local_time_struct = localtime(time); |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 if (posix_local_time_struct == NULL) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 { |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 return 1; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 } |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 *_tm = *posix_local_time_struct; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 return 0; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 } |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 inline char* strerror_s(char* buf, size_t buflen, int errnum) |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 { |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 const char* str = strerror(errnum); |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 return strncpy(buf, str, buflen - 1); |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 #endif |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 inline struct tm* localtime_r(const time_t* timep, struct tm* result) { |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 localtime_s(result, timep); |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 return result; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 } |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 inline char* strerror_r(int errnum, char* buf, size_t buflen) { |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 strerror_s(buf, buflen, errnum); |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 return buf; |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 } |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 #ifndef __cplusplus |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 /* I don't see how to get inlining for C code in MSVC. Ah well. */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 #define inline |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 #endif |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 #endif /* _WIN32 */ |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
f25c79497739
patch glog for visual studio >= 11.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 #endif /* CTEMPLATE_WINDOWS_PORT_H_ */ |