/* stat/lstat/fstat */
#ifdef WIN32
-#include <sys/stat.h>
+# include <sys/stat.h>
# ifndef UNDER_CE
struct _stati64;
-#define stat _stati64
-#define fstat _fstati64
+# define stat _stati64
+# define fstat _fstati64
#endif
/* You should otherwise use vlc_stat and vlc_lstat. */
* OS-specific headers and thread types
*****************************************************************************/
#if defined( WIN32 ) || defined( UNDER_CE )
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
+/* WIN32_LEAN_AND_MEAN is needed to be able to include winsock2.h because else,
+ * windows.h will also include winsock.h and declarations will conflict */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
#endif
#include "vlc_mtime.h"
# endif
# endif
-# if defined( _MSC_VER ) && !defined( __WXMSW__ )
+# if defined( _MSC_VER )
# if !defined( _OFF_T_DEFINED )
typedef __int64 off_t;
# define _OFF_T_DEFINED
VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t );
-VLC_API void * vlc_memalign( void **base, size_t alignment, size_t size ) VLC_USED;
+/* Aligned memory allocator */
+#ifdef WIN32
+# include <malloc.h>
+# define vlc_memalign(align, size) (__mingw_aligned_malloc(size, align))
+# define vlc_free(base) (__mingw_aligned_free(base))
+#else
+static inline void *vlc_memalign(size_t align, size_t size)
+{
+ void *base;
+ if (unlikely(posix_memalign(&base, align, size)))
+ base = NULL;
+ return base;
+}
+# define vlc_free(base) free(base)
+#endif
VLC_API void vlc_tdestroy( void *, void (*)(void *) );