Correct a typo in 'msvc_pbd.h'
[ardour.git] / libs / pbd / pbd / msvc_pbd.h
1 /*
2     Copyright (C) 2009 John Emmas
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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19 #ifndef _msvc_pbd_h_
20 #define _msvc_pbd_h_
21
22 #ifdef  PBD_IS_IN_WIN_STATIC_LIB  // #define if your project uses libpbd (under Windows) as a static library
23 #define PBD_IS_IN_WINDLL 0
24 #endif
25
26 #ifndef COMPILER_MSVC
27 #include <sys/time.h>
28 #else
29 #include <ardourext/misc.h>
30 #include <ardourext/sys/time.h>
31 #endif
32
33 #if !defined(PBD_IS_IN_WINDLL)
34         #if defined(COMPILER_MSVC) || defined(COMPILER_MINGW)
35         // If you need '__declspec' compatibility, add extra compilers to the above as necessary
36                 #define PBD_IS_IN_WINDLL 1
37         #else
38                 #define PBD_IS_IN_WINDLL 0
39         #endif
40 #endif
41
42 #if PBD_IS_IN_WINDLL && !defined(PBD_API)
43         #if defined(BUILDING_PBD)
44                 #define PBD_API __declspec(dllexport)
45                 #define PBD_APICALLTYPE __stdcall
46         #elif defined(COMPILER_MSVC) || defined(COMPILER_MINGW) // Probably needs Cygwin too, at some point
47                 #define PBD_API __declspec(dllimport)
48                 #define PBD_APICALLTYPE __stdcall
49         #else
50                 #error "Attempting to define __declspec with an incompatible compiler !"
51         #endif
52 #elif !defined(PBD_API)
53         // Other compilers / platforms could be accommodated here
54         #define PBD_API
55         #define PBD_APICALLTYPE
56 #endif
57
58 #ifndef _MAX_PATH
59 #define _MAX_PATH  260
60 #endif
61 #ifndef  PATH_MAX
62 #define  PATH_MAX _MAX_PATH
63 #endif
64
65 #ifdef __cplusplus
66 extern "C" {
67 #endif  /* __cplusplus */
68
69 // This function is (hopefully) temporary and is placed here
70 // because 'g_usleep()' doesn't seem to work very well for glib-win32
71 void    pbd_g_usleep (unsigned long microseconds);
72
73 #ifdef __cplusplus
74 }               /* extern "C" */
75 #endif  /* __cplusplus */
76
77 #ifndef POLLIN
78 #define POLLIN                          1
79 #define POLLPRI                         2
80 #define POLLOUT                         4
81 #define POLLERR                         8
82 #define POLLHUP                         16
83 #define POLLNVAL                        32
84 #define NPOLLFILE                       64
85
86 #define POLLRDNORM                      POLLIN
87 #define POLLRDBAND                      POLLIN
88 #define POLLWRNORM                      POLLOUT
89 #define POLLWRBAND                      POLLOUT
90 #endif
91
92 #ifdef PLATFORM_WINDOWS
93
94 #ifndef PBDEXTN_API
95         #if defined(BUILDING_PBDEXTN)
96                 #define PBDEXTN_API __declspec(dllexport)
97                 #define PBDEXTN_APICALLTYPE __cdecl
98         #elif defined(COMPILER_MSVC) || defined(COMPILER_MINGW) // Probably needs Cygwin too, at some point
99                 #define PBDEXTN_API __declspec(dllimport)
100                 #define PBDEXTN_APICALLTYPE __cdecl
101         #else
102                 #error "Attempting to define __declspec with an incompatible compiler !"
103         #endif
104 #endif  // PBDEXTN_API
105
106 #ifndef CYGIMPORT_API
107                 #define CYGIMPORT_API __declspec(dllimport)
108                 #define CYGIMPORT_APICALLTYPE __cdecl
109 #endif  // CYGIMPORT_API
110
111 #ifndef __THROW
112 #define __THROW throw()
113 #endif
114
115 #ifndef RTLD_DEFAULT
116 #define RTLD_DEFAULT       ((void *) 0)
117 #define RTLD_NEXT          ((void *) -1L)
118 #define RTLD_LAZY          0x00001
119 #define RTLD_NOW           0x00002
120 #define RTLD_BINDING_MASK  0x00003
121 #define RTLD_NOLOAD        0x00004
122 #define RTLD_GLOBAL        0x00004
123 #define RTLD_DEEPBIND      0x00008
124 #endif
125
126 #ifndef OPEN_MAX
127 #define OPEN_MAX                        32
128 #endif
129
130 #ifdef __cplusplus
131 extern "C" {
132 #endif  /* __cplusplus */
133
134 PBDEXTN_API int         PBDEXTN_APICALLTYPE cyginit (unsigned int result);
135 PBD_API     int         PBD_APICALLTYPE     dlclose (void *handle) __THROW;
136 PBD_API     void*       PBD_APICALLTYPE     dlopen  (const char *file_name, int mode) __THROW;
137 PBD_API     void*       PBD_APICALLTYPE     dlsym   (void *handle, const char *symbol_name) __THROW;
138 PBD_API     char*       PBD_APICALLTYPE     dlerror () __THROW;
139
140 #ifdef __cplusplus
141 }               /* extern "C" */
142 #endif  /* __cplusplus */
143
144 #ifndef __CYGWIN__
145 #include <rpc.h>
146 #include <io.h>
147 #include <sys/types.h>
148
149 typedef int (FAR PBDEXTN_APICALLTYPE *CYGINIT_API)(unsigned int);
150
151 #ifndef FILENAME_MAX
152 #define FILENAME_MAX (260)
153 #endif
154
155 #ifndef _SSIZE_T_
156 #define _SSIZE_T_
157 typedef long _ssize_t;
158
159 #ifndef _NO_OLDNAMES
160 typedef _ssize_t ssize_t;
161 #endif
162 #endif /* ! _SSIZE_T_ */
163
164 struct dirent
165 {
166         long                    d_ino;                            // Always zero
167         unsigned short  d_reclen;                         // Always zero
168         unsigned short  d_namlen;                         // Length of name in d_name
169         char                    d_name[FILENAME_MAX]; // File name
170 };
171
172 // This is an internal data structure. Do not use it
173 // except as an argument to one of the functions below.
174 typedef struct
175 {
176         // Disk transfer area for this dir
177         struct _finddata_t      dd_dta;
178
179         // 'dirent' struct to return from dir (NOTE: this
180         // is not thread safe).
181         struct dirent           dd_dir;
182
183         // '_findnext()' handle
184         long                            dd_handle;
185
186         // Current status of search:
187         //  0 = not started yet (next entry to read is first entry)
188         // -1 = off the end
189         //  Otherwise - positive (0 based) index of next entry
190         int                                     dd_stat;
191
192         // Full path for dir with search pattern (struct will be extended)
193         char                            dd_name[1];
194 } DIR;
195
196 struct pollfd
197 {
198         int fd;
199         short events;
200         short revents;
201 };
202
203 typedef unsigned int nfds_t;
204
205 PBD_API int                             PBD_APICALLTYPE gettimeofday(struct timeval *__restrict tv, __timezone_ptr_t tz);
206 PBD_API ssize_t                 PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
207 PBD_API ssize_t                 PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
208 PBD_API int                             PBD_APICALLTYPE poll(struct pollfd *fds, nfds_t nfds, int timeout);
209
210 namespace PBD {
211
212 #ifdef __cplusplus
213 extern "C" {
214 #endif  /* __cplusplus */
215
216 PBD_API bool                    PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored");
217 PBD_API char*                   PBD_APICALLTYPE realpath    (const char *original_path, char resolved_path[_MAX_PATH+1]);
218 PBD_API int                             PBD_APICALLTYPE mkstemp     (char *template_name);
219 PBD_API int                             PBD_APICALLTYPE ntfs_link   (const char *existing_filepath, const char *link_filepath);
220 PBD_API int                             PBD_APICALLTYPE ntfs_unlink (const char *link_filepath);
221
222 // These are used to replicate 'dirent.h' functionality
223 PBD_API DIR*                    PBD_APICALLTYPE opendir  (const char *szPath);
224 PBD_API struct dirent*  PBD_APICALLTYPE readdir  (DIR *pDir);
225 PBD_API int                             PBD_APICALLTYPE closedir (DIR *pDir);
226
227 #ifdef __cplusplus
228 }               /* extern "C" */
229 #endif  /* __cplusplus */
230
231 }  // namespace PBD
232
233 #endif  // !__CYGWIN__
234 #endif  // PLATFORM_WINDOWS
235 #endif  // _msvc_pbd_h_