Remove the MSVC 'poll()' emulation now that Ardour's stopped using poll()
[ardour.git] / libs / pbd / pbd / msvc_pbd.h
index 628ed56e6fe9ea1b85d7044626e10853eebc3ba8..97ac72ff27419a775580682531e08055fc667f06 100644 (file)
 #define _msvc_pbd_h_
 
 #ifdef  PBD_IS_IN_WIN_STATIC_LIB  // #define if your project uses libpbd (under Windows) as a static library
+#undef  LIBPBD_DLL
 #define PBD_IS_IN_WINDLL 0
 #endif
 
+#include <pbd/libpbd_visibility.h>
+
 #ifndef COMPILER_MSVC
 #include <sys/time.h>
 #else
        #endif
 #endif
 
-#if PBD_IS_IN_WINDLL && !defined(PBD_API)
+#if PBD_IS_IN_WINDLL && !defined(PBD_APICALLTYPE)
        #if defined(BUILDING_PBD)
-               #define PBD_API __declspec(dllexport)
-               #define PBD_APICALLTYPE __stdcall
+               #define PBD_APICALLTYPE __cdecl
        #elif defined(COMPILER_MSVC) || defined(COMPILER_MINGW) // Probably needs Cygwin too, at some point
-               #define PBD_API __declspec(dllimport)
-               #define PBD_APICALLTYPE __stdcall
+               #define PBD_APICALLTYPE __cdecl
        #else
                #error "Attempting to define __declspec with an incompatible compiler !"
        #endif
-#elif !defined(PBD_API)
+#elif !defined(PBD_APICALLTYPE)
        // Other compilers / platforms could be accommodated here
-       #define PBD_API
        #define PBD_APICALLTYPE
+#ifndef GETOPT_API
        #define GETOPT_API
        #define GETOPT_APICALLTYPE
 #endif
+#endif
 
 #ifndef GETOPT_API
        #if defined(BUILDING_GETOPT)
 extern "C" {
 #endif /* __cplusplus */
 
-// This function is (hopefully) temporary and is placed here
-// because 'g_usleep()' doesn't seem to work very well for glib-win32
-// JE -  let's see if we can do without this now! void    pbd_g_usleep (unsigned long microseconds);
-
 #ifdef __cplusplus
 }              /* extern "C" */
 #endif /* __cplusplus */
 
-#ifndef POLLIN
-#define POLLIN                         1
-#define POLLPRI                                2
-#define POLLOUT                                4
-#define POLLERR                                8
-#define POLLHUP                                16
-#define POLLNVAL                       32
-#define NPOLLFILE                      64
-
-#define POLLRDNORM                     POLLIN
-#define POLLRDBAND                     POLLIN
-#define POLLWRNORM                     POLLOUT
-#define POLLWRBAND                     POLLOUT
-#endif
-
 #ifdef PLATFORM_WINDOWS
 
 #ifndef PBDEXTN_API
@@ -145,23 +128,27 @@ extern "C" {
 extern "C" {
 #endif /* __cplusplus */
 
-PBDEXTN_API int                PBDEXTN_APICALLTYPE cyginit (unsigned int result);
-PBD_API     int        PBD_APICALLTYPE     dlclose (void *handle) __THROW;
-PBD_API     void*      PBD_APICALLTYPE     dlopen  (const char *file_name, int mode) __THROW;
-PBD_API     void*      PBD_APICALLTYPE     dlsym   (void *handle, const char *symbol_name) __THROW;
-PBD_API     char*      PBD_APICALLTYPE     dlerror () __THROW;
+PBDEXTN_API       int          PBDEXTN_APICALLTYPE cyginit (unsigned int result);
+LIBPBD_API     int             PBD_APICALLTYPE     dlclose (void *handle) __THROW;
+LIBPBD_API     void*   PBD_APICALLTYPE     dlopen  (const char *file_name, int mode) __THROW;
+LIBPBD_API     void*   PBD_APICALLTYPE     dlsym   (void *handle, const char *symbol_name) __THROW;
+LIBPBD_API     char*   PBD_APICALLTYPE     dlerror () __THROW;
 
 #ifdef __cplusplus
 }              /* extern "C" */
 #endif /* __cplusplus */
 
 #ifndef __CYGWIN__
+/* For whatever reason, Ardour's 'libevoral' refuses to build as a DLL if we include both 'rpc.h' */
+/* and 'WinSock2.h'. It doesn't seem to matter which order we #include them. Given that we can't  */
+/* edit 'rpc.h' or 'WinSock2.h', just make sure we don't #include them when building libevoral.   */
+#ifndef BUILDING_EVORAL
 #include <rpc.h>
+typedef int (FAR PBDEXTN_APICALLTYPE *CYGINIT_API)(unsigned int);
+#endif
 #include <io.h>
 #include <sys/types.h>
 
-typedef int (FAR PBDEXTN_APICALLTYPE *CYGINIT_API)(unsigned int);
-
 #ifndef FILENAME_MAX
 #define FILENAME_MAX (260)
 #endif
@@ -207,44 +194,47 @@ typedef struct
        char                            dd_name[1];
 } DIR;
 
-struct pollfd
-{
-       int fd;
-       short events;
-       short revents;
-};
-
 typedef unsigned int nfds_t;
 
-PBD_API int                            PBD_APICALLTYPE gettimeofday(struct timeval *__restrict tv, __timezone_ptr_t tz);
-PBD_API ssize_t                        PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
-PBD_API ssize_t                        PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
-PBD_API int                            PBD_APICALLTYPE poll(struct pollfd *fds, nfds_t nfds, int timeout);
-PBD_API double                 PBD_APICALLTYPE round(double x);
-
-namespace PBD {
-
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-PBD_API bool                   PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored");
-PBD_API char*                  PBD_APICALLTYPE realpath    (const char *original_path, char resolved_path[_MAX_PATH+1]);
-PBD_API int                            PBD_APICALLTYPE mkstemp     (char *template_name);
-PBD_API int                            PBD_APICALLTYPE ntfs_link   (const char *existing_filepath, const char *link_filepath);
-PBD_API int                            PBD_APICALLTYPE ntfs_unlink (const char *link_filepath);
+LIBPBD_API int                         __cdecl         gettimeofday(struct timeval *__restrict tv, __timezone_ptr_t tz);
+LIBPBD_API ssize_t                     PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
+LIBPBD_API ssize_t                     PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
+
+#if defined(_MSC_VER) && (_MSC_VER < 1800)
+LIBPBD_API double                      PBD_APICALLTYPE expm1(double x);
+LIBPBD_API double                      PBD_APICALLTYPE log1p(double x);
+LIBPBD_API double                      PBD_APICALLTYPE round(double x);
+LIBPBD_API float                       PBD_APICALLTYPE roundf(float x);
+#endif
+
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+LIBPBD_API double                      PBD_APICALLTYPE log2 (double x);
+LIBPBD_API double                      PBD_APICALLTYPE trunc(double x);
+#endif
+
+namespace PBD {
+
+LIBPBD_API bool                        PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored");
+LIBPBD_API char*                       PBD_APICALLTYPE realpath    (const char *original_path, char resolved_path[_MAX_PATH+1]);
+LIBPBD_API int                         PBD_APICALLTYPE mkstemp     (char *template_name);
+LIBPBD_API int                         PBD_APICALLTYPE ntfs_link   (const char *existing_filepath, const char *link_filepath);
+LIBPBD_API int                         PBD_APICALLTYPE ntfs_unlink (const char *link_filepath);
 
 // These are used to replicate 'dirent.h' functionality
-PBD_API DIR*                   PBD_APICALLTYPE opendir  (const char *szPath);
-PBD_API struct dirent* PBD_APICALLTYPE readdir  (DIR *pDir);
-PBD_API int                            PBD_APICALLTYPE closedir (DIR *pDir);
+LIBPBD_API DIR*                                PBD_APICALLTYPE opendir  (const char *szPath);
+LIBPBD_API struct dirent*      PBD_APICALLTYPE readdir  (DIR *pDir);
+LIBPBD_API int                         PBD_APICALLTYPE closedir (DIR *pDir);
+
+}  // namespace PBD
 
 #ifdef __cplusplus
 }              /* extern "C" */
 #endif /* __cplusplus */
 
-}  // namespace PBD
-
 #endif  // !__CYGWIN__
 #endif  // PLATFORM_WINDOWS
 #endif  // _msvc_pbd_h_