Ardour  9.0-pre0-582-g084a23a80d
msvc_pbd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013-2019 John Emmas <john@creativepost.co.uk>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 #ifndef _msvc_pbd_h_
19 #define _msvc_pbd_h_
20 
21 #ifdef PBD_IS_IN_WIN_STATIC_LIB // #define if your project uses libpbd (under Windows) as a static library
22 #undef LIBPBD_DLL
23 #define PBD_IS_IN_WINDLL 0
24 #endif
25 
26 #include <pbd/libpbd_visibility.h>
27 
28 #ifndef COMPILER_MSVC
29 #include <sys/time.h>
30 #else
31 #include <ardourext/misc.h>
32 #include <ardourext/sys/time.h>
33 #endif
34 
35 #if !defined(PBD_IS_IN_WINDLL)
36  #if defined(COMPILER_MSVC) || defined(COMPILER_MINGW)
37  // If you need '__declspec' compatibility, add extra compilers to the above as necessary
38  #define PBD_IS_IN_WINDLL 1
39  #else
40  #define PBD_IS_IN_WINDLL 0
41  #endif
42 #endif
43 
44 #if PBD_IS_IN_WINDLL && !defined(PBD_APICALLTYPE)
45  #if defined(BUILDING_PBD)
46  #define PBD_APICALLTYPE __cdecl
47  #elif defined(COMPILER_MSVC) || defined(COMPILER_MINGW) // Probably needs Cygwin too, at some point
48  #define PBD_APICALLTYPE __cdecl
49  #else
50  #error "Attempting to define __declspec with an incompatible compiler !"
51  #endif
52 #elif !defined(PBD_APICALLTYPE)
53  // Other compilers / platforms could be accommodated here
54  #define PBD_APICALLTYPE
55 #ifndef GETOPT_API
56  #define GETOPT_API
57  #define GETOPT_APICALLTYPE
58 #endif
59 #endif
60 
61 #ifndef GETOPT_API
62  #if defined(BUILDING_GETOPT)
63  #define GETOPT_API __declspec(dllexport)
64  #define GETOPT_APICALLTYPE __cdecl
65  #elif defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) || defined(_MINGW32__)
66  #define GETOPT_API __declspec(dllimport)
67  #define GETOPT_APICALLTYPE __cdecl
68  #else
69  #error "Attempting to define __declspec with an incompatible compiler !"
70  #endif
71 #endif // GETOPT_API
72 
73 #ifndef _MAX_PATH
74 #define _MAX_PATH 260
75 #endif
76 #ifndef PATH_MAX
77 #define PATH_MAX _MAX_PATH
78 #endif
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif /* __cplusplus */
83 
84 #ifdef __cplusplus
85 } /* extern "C" */
86 #endif /* __cplusplus */
87 
88 #ifdef PLATFORM_WINDOWS
89 
90 #ifndef PBDEXTN_API
91  #if defined(BUILDING_PBDEXTN)
92  #define PBDEXTN_API __declspec(dllexport)
93  #define PBDEXTN_APICALLTYPE __cdecl
94  #elif defined(COMPILER_MSVC) || defined(COMPILER_MINGW) // Probably needs Cygwin too, at some point
95  #define PBDEXTN_API __declspec(dllimport)
96  #define PBDEXTN_APICALLTYPE __cdecl
97  #else
98  #error "Attempting to define __declspec with an incompatible compiler !"
99  #endif
100 #endif // PBDEXTN_API
101 
102 #ifndef CYGIMPORT_API
103  #define CYGIMPORT_API __declspec(dllimport)
104  #define CYGIMPORT_APICALLTYPE __cdecl
105 #endif // CYGIMPORT_API
106 
107 #ifndef __THROW
108 #define __THROW throw()
109 #endif
110 
111 #ifndef RTLD_DEFAULT
112 #define RTLD_DEFAULT ((void *) 0)
113 #define RTLD_NEXT ((void *) -1L)
114 #define RTLD_LAZY 0x00001
115 #define RTLD_NOW 0x00002
116 #define RTLD_BINDING_MASK 0x00003
117 #define RTLD_NOLOAD 0x00004
118 #define RTLD_GLOBAL 0x00004
119 #define RTLD_DEEPBIND 0x00008
120 #endif
121 
122 #ifndef OPEN_MAX
123 #define OPEN_MAX (32)
124 #endif
125 
126 #ifdef __cplusplus
127 extern "C" {
128 #endif /* __cplusplus */
129 
130 PBDEXTN_API int PBDEXTN_APICALLTYPE cyginit (unsigned int result);
131 LIBPBD_API int PBD_APICALLTYPE dlclose (void *handle) __THROW;
132 LIBPBD_API void* PBD_APICALLTYPE dlopen (const char *file_name, int mode) __THROW;
133 LIBPBD_API void* PBD_APICALLTYPE dlsym (void *handle, const char *symbol_name) __THROW;
134 LIBPBD_API char* PBD_APICALLTYPE dlerror () __THROW;
135 
136 #ifdef __cplusplus
137 } /* extern "C" */
138 #endif /* __cplusplus */
139 
140 #ifndef __CYGWIN__
141 /* For whatever reason, Ardour's 'libevoral' refuses to build as a DLL if we include both 'rpc.h' */
142 /* and 'WinSock2.h'. It doesn't seem to matter which order we #include them. Given that we can't */
143 /* edit 'rpc.h' or 'WinSock2.h', just make sure we don't #include them when building libevoral. */
144 #if !defined(BUILDING_EVORAL) && !defined(BUILDING_QMDSP) && !defined(BUILDING_VAMPPLUGINS)
145 #include <rpc.h>
146 typedef int (FAR PBDEXTN_APICALLTYPE *CYGINIT_API)(unsigned int);
147 #endif
148 #include <io.h>
149 #include <sys/types.h>
150 
151 #ifndef FILENAME_MAX
152 #define FILENAME_MAX (260)
153 #endif
154 
155 #ifndef _SSIZE_T_
156 #define _SSIZE_T_
157 
158 #ifdef SSIZE_T
159 typedef SSIZE_T _ssize_t;
160 #elif _MSC_VER < 1800
161 typedef long _ssize_t;
162 #else
163 #include <basetsd.h>
164 typedef LONG_PTR _ssize_t; // AFAICT - LONG_PTR is equivalent to 'long' in Win32 and '__int64' in Win64 !!
165 #endif
166 
167 #ifndef _NO_OLDNAMES
168 typedef _ssize_t ssize_t;
169 #endif
170 
171 #endif /* ! _SSIZE_T_ */
172 
173 typedef unsigned int nfds_t;
174 
175 #ifdef __cplusplus
176 extern "C" {
177 #endif /* __cplusplus */
178 
179 LIBPBD_API int __cdecl gettimeofday(struct timeval *__restrict tv, __timezone_ptr_t tz) __THROW;
180 LIBPBD_API ssize_t PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
181 LIBPBD_API ssize_t PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
182 
183 #if defined(_MSC_VER) && (_MSC_VER < 1800)
184 LIBPBD_API double PBD_APICALLTYPE log1p(double x);
185 LIBPBD_API double PBD_APICALLTYPE round(double x);
186 LIBPBD_API double PBD_APICALLTYPE expm1(double x);
187 LIBPBD_API float PBD_APICALLTYPE exp2f(float x);
188 LIBPBD_API float PBD_APICALLTYPE roundf(float x);
189 #endif
190 
191 #if defined(_MSC_VER) && (_MSC_VER < 1900)
192 LIBPBD_API double PBD_APICALLTYPE log2 (double x);
193 LIBPBD_API double PBD_APICALLTYPE trunc(double x);
194 #endif
195 
196 namespace PBD {
197 
198 #if defined(_MSC_VER) && (_MSC_VER < 1900)
199 LIBPBD_API char* PBD_APICALLTYPE realpath (const char *original_path, char resolved_path[_MAX_PATH+1]);
200 LIBPBD_API int PBD_APICALLTYPE mkstemp (char *template_name);
201 
202 /* JE - 30-01-2021 (AFAICT these ones aren't needed any more) */
203 LIBPBD_API bool PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored");
204 LIBPBD_API int PBD_APICALLTYPE ntfs_link (const char *existing_filepath, const char *link_filepath);
205 LIBPBD_API int PBD_APICALLTYPE ntfs_unlink (const char *link_filepath);
206 #endif
207 
208 } // namespace PBD */
209 
210 struct dirent
211 {
212  long d_ino; // Always zero
213  unsigned short d_reclen; // Always zero
214  unsigned short d_namlen; // Length of name in d_name
215  char d_name[FILENAME_MAX]; // File name
216 };
217 
218 // This is an internal data structure. Do not use it
219 // except as an argument to one of the functions below.
220 typedef struct
221 {
222  // Disk transfer area for this dir
223  struct _finddata_t dd_dta;
224 
225  // 'dirent' struct to return from dir (NOTE: this
226  // is not thread safe).
227  struct dirent dd_dir;
228 
229  // '_findnext()' handle
230  intptr_t dd_handle;
231 
232  // Current status of search:
233  // 0 = not started yet (next entry to read is first entry)
234  // -1 = off the end
235  // Otherwise - positive (0 based) index of next entry
236  int dd_stat;
237 
238  // Full path for dir with search pattern (struct will be extended)
239  char dd_name[1];
240 } DIR;
241 
242 namespace PBD {
243 
244 // These are used to replicate 'dirent.h' functionality
245 LIBPBD_API DIR* PBD_APICALLTYPE opendir (const char *szPath);
246 LIBPBD_API struct dirent* PBD_APICALLTYPE readdir (DIR *pDir);
247 LIBPBD_API int PBD_APICALLTYPE closedir (DIR *pDir);
248 
249 } // namespace PBD */
250 
251 #ifdef __cplusplus
252 } /* extern "C" */
253 #endif /* __cplusplus */
254 
255 #endif // !__CYGWIN__
256 #endif // PLATFORM_WINDOWS
257 #endif // _msvc_pbd_h_
#define LIBPBD_API
#define PBD_APICALLTYPE
Definition: msvc_pbd.h:54
#define _MAX_PATH
Definition: msvc_pbd.h:74
const char * revision
Definition: axis_view.h:42