2 Copyright (C) 2009 John Emmas
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.
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.
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.
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
29 #include <ardourext/misc.h>
30 #include <ardourext/sys/time.h>
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
38 #define PBD_IS_IN_WINDLL 0
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
50 #error "Attempting to define __declspec with an incompatible compiler !"
52 #elif !defined(PBD_API)
53 // Other compilers / platforms could be accommodated here
55 #define PBD_APICALLTYPE
57 #define GETOPT_APICALLTYPE
61 #if defined(BUILDING_GETOPT)
62 #define GETOPT_API __declspec(dllexport)
63 #define GETOPT_APICALLTYPE __cdecl
64 #elif defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__) || defined(_MINGW32__)
65 #define GETOPT_API __declspec(dllimport)
66 #define GETOPT_APICALLTYPE __cdecl
68 #error "Attempting to define __declspec with an incompatible compiler !"
76 #define PATH_MAX _MAX_PATH
81 #endif /* __cplusplus */
83 // This function is (hopefully) temporary and is placed here
84 // because 'g_usleep()' doesn't seem to work very well for glib-win32
85 void pbd_g_usleep (unsigned long microseconds);
89 #endif /* __cplusplus */
100 #define POLLRDNORM POLLIN
101 #define POLLRDBAND POLLIN
102 #define POLLWRNORM POLLOUT
103 #define POLLWRBAND POLLOUT
106 #ifdef PLATFORM_WINDOWS
109 #if defined(BUILDING_PBDEXTN)
110 #define PBDEXTN_API __declspec(dllexport)
111 #define PBDEXTN_APICALLTYPE __cdecl
112 #elif defined(COMPILER_MSVC) || defined(COMPILER_MINGW) // Probably needs Cygwin too, at some point
113 #define PBDEXTN_API __declspec(dllimport)
114 #define PBDEXTN_APICALLTYPE __cdecl
116 #error "Attempting to define __declspec with an incompatible compiler !"
118 #endif // PBDEXTN_API
120 #ifndef CYGIMPORT_API
121 #define CYGIMPORT_API __declspec(dllimport)
122 #define CYGIMPORT_APICALLTYPE __cdecl
123 #endif // CYGIMPORT_API
126 #define __THROW throw()
130 #define RTLD_DEFAULT ((void *) 0)
131 #define RTLD_NEXT ((void *) -1L)
132 #define RTLD_LAZY 0x00001
133 #define RTLD_NOW 0x00002
134 #define RTLD_BINDING_MASK 0x00003
135 #define RTLD_NOLOAD 0x00004
136 #define RTLD_GLOBAL 0x00004
137 #define RTLD_DEEPBIND 0x00008
146 #endif /* __cplusplus */
148 PBDEXTN_API int PBDEXTN_APICALLTYPE cyginit (unsigned int result);
149 PBD_API int PBD_APICALLTYPE dlclose (void *handle) __THROW;
150 PBD_API void* PBD_APICALLTYPE dlopen (const char *file_name, int mode) __THROW;
151 PBD_API void* PBD_APICALLTYPE dlsym (void *handle, const char *symbol_name) __THROW;
152 PBD_API char* PBD_APICALLTYPE dlerror () __THROW;
156 #endif /* __cplusplus */
161 #include <sys/types.h>
163 typedef int (FAR PBDEXTN_APICALLTYPE *CYGINIT_API)(unsigned int);
166 #define FILENAME_MAX (260)
171 typedef long _ssize_t;
174 typedef _ssize_t ssize_t;
176 #endif /* ! _SSIZE_T_ */
180 long d_ino; // Always zero
181 unsigned short d_reclen; // Always zero
182 unsigned short d_namlen; // Length of name in d_name
183 char d_name[FILENAME_MAX]; // File name
186 // This is an internal data structure. Do not use it
187 // except as an argument to one of the functions below.
190 // Disk transfer area for this dir
191 struct _finddata_t dd_dta;
193 // 'dirent' struct to return from dir (NOTE: this
194 // is not thread safe).
195 struct dirent dd_dir;
197 // '_findnext()' handle
200 // Current status of search:
201 // 0 = not started yet (next entry to read is first entry)
203 // Otherwise - positive (0 based) index of next entry
206 // Full path for dir with search pattern (struct will be extended)
217 typedef unsigned int nfds_t;
219 PBD_API int PBD_APICALLTYPE gettimeofday(struct timeval *__restrict tv, __timezone_ptr_t tz);
220 PBD_API ssize_t PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
221 PBD_API ssize_t PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
222 PBD_API int PBD_APICALLTYPE poll(struct pollfd *fds, nfds_t nfds, int timeout);
223 PBD_API double PBD_APICALLTYPE round(double x);
229 #endif /* __cplusplus */
231 PBD_API bool PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored");
232 PBD_API char* PBD_APICALLTYPE realpath (const char *original_path, char resolved_path[_MAX_PATH+1]);
233 PBD_API int PBD_APICALLTYPE mkstemp (char *template_name);
234 PBD_API int PBD_APICALLTYPE ntfs_link (const char *existing_filepath, const char *link_filepath);
235 PBD_API int PBD_APICALLTYPE ntfs_unlink (const char *link_filepath);
237 // These are used to replicate 'dirent.h' functionality
238 PBD_API DIR* PBD_APICALLTYPE opendir (const char *szPath);
239 PBD_API struct dirent* PBD_APICALLTYPE readdir (DIR *pDir);
240 PBD_API int PBD_APICALLTYPE closedir (DIR *pDir);
244 #endif /* __cplusplus */
248 #endif // !__CYGWIN__
249 #endif // PLATFORM_WINDOWS
250 #endif // _msvc_pbd_h_