Browse Source

windows: use the native read/write/etc calls

When compiling with the GDK the POSIX variants are defined but not available
for linking. We can just the Windows variants that are always available.

Do the proper redirection in our custom unistd.h used with the Platform SDK.
pull/144/head
Steve Lhomme 4 years ago
parent
commit
105babe317
  1. 6
      compat/readv.c
  2. 11
      compat/windows/unistd.h
  3. 6
      compat/writev.c
  4. 6
      src/win32/filesystem.c

6
compat/readv.c

@ -26,11 +26,7 @@
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
# include <io.h>
#else
# include <unistd.h>
#endif
#include <unistd.h>
ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
{

11
compat/windows/unistd.h

@ -29,5 +29,16 @@
// _getpid() exists but it returns an int, not a pid_t
typedef int pid_t;
// redirect missing functions from the GDK
#define strdup(s) _strdup(s)
#define read(fd, dst, count) _read(fd, dst, count)
#define write(fd, src, count) _write(fd, src, count)
#define close(fd) _close(fd)
#define dup(fd) _dup(fd)
#define dup2(fd, f2) _dup2(fd,f2)
#define setmode(fd, m) _setmode(fd,m)
#define fdopen(a, b) _fdopen(a, b)
#endif // WINSDK_UNISTD_H__

6
compat/writev.c

@ -26,11 +26,7 @@
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
# include <io.h>
#else
# include <unistd.h>
#endif
#include <unistd.h>
ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
{

6
src/win32/filesystem.c

@ -37,17 +37,13 @@
#include <fcntl.h>
#include <winsock2.h>
#include <direct.h>
#include <unistd.h>
#include <vlc_common.h>
#include <vlc_charset.h>
#include <vlc_fs.h>
#include "libvlc.h" /* vlc_mkdir */
#ifdef _MSC_VER
# define __STDC__ 1
# include <io.h> /* _pipe */
#endif
#ifndef NTDDI_WIN10_RS3
#define NTDDI_WIN10_RS3 0x0A000004
#endif

Loading…
Cancel
Save