qemu-e2k/linux-user
Daniel P. Berrange a2d96af4bb osdep: add wrappers for socket functions
The windows socket functions look identical to the normal POSIX
sockets functions, but instead of setting errno, the caller needs
to call WSAGetLastError(). QEMU has tried to deal with this
incompatibility by defining a socket_error() method that callers
must use that abstracts the difference between WSAGetLastError()
and errno.

This approach is somewhat error prone though - many callers of
the sockets functions are just using errno directly because it
is easy to forget the need use a QEMU specific wrapper. It is
not always immediately obvious that a particular function will
in fact call into Windows sockets functions, so the dev may not
even realize they need to use socket_error().

This introduces an alternative approach to portability inspired
by the way GNULIB fixes portability problems. We use a macro to
redefine the original socket function names to refer to a QEMU
wrapper function. The wrapper function calls the original Win32
sockets method and then sets errno from the WSAGetLastError()
value.

Thus all code can simply call the normal POSIX sockets APIs are
have standard errno reporting on error, even on Windows. This
makes the socket_error() method obsolete.

We also bring closesocket & ioctlsocket into this approach. Even
though they are non-standard Win32 names, we can't wrap the normal
close/ioctl methods since there's no reliable way to distinguish
between a file descriptor and HANDLE in Win32.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 17:19:07 +00:00
..
aarch64 linux-user: remove unavailable syscalls from aarch64 2016-02-23 21:25:10 +02:00
alpha linux-user: sync syscall numbers with kernel 2016-02-23 21:25:10 +02:00
arm target-arm: Add write_type argument to cpsr_write() 2016-02-26 15:09:41 +00:00
cris linux-user: sync syscall numbers with kernel 2016-02-23 21:25:10 +02:00
i386 linux-user: correct timerfd_create syscall numbers 2016-02-23 21:25:10 +02:00
m68k linux-user: correct timerfd_create syscall numbers 2016-02-23 21:25:10 +02:00
microblaze linux-user: sync syscall numbers with kernel 2016-02-23 21:25:10 +02:00
mips build: [linux-user] Rename "syscall.h" to "target_syscall.h" in target directories 2016-02-23 21:25:09 +02:00
mips64 linux-user: sync syscall numbers with kernel 2016-02-23 21:25:10 +02:00
openrisc linux-user: sync syscall numbers with kernel 2016-02-23 21:25:10 +02:00
ppc linux-user: correct timerfd_create syscall numbers 2016-02-23 21:25:10 +02:00
s390x linux-user: sync syscall numbers with kernel 2016-02-23 21:25:10 +02:00
sh4 linux-user: correct timerfd_create syscall numbers 2016-02-23 21:25:10 +02:00
sparc linux-user: correct timerfd_create syscall numbers 2016-02-23 21:25:10 +02:00
sparc64 linux-user: sync syscall numbers with kernel 2016-02-23 21:25:10 +02:00
tilegx linux-user: sync syscall numbers with kernel 2016-02-23 21:25:10 +02:00
unicore32 build: [linux-user] Rename "syscall.h" to "target_syscall.h" in target directories 2016-02-23 21:25:09 +02:00
x86_64 linux-user: correct timerfd_create syscall numbers 2016-02-23 21:25:10 +02:00
elfload.c linux-user: Clean up includes 2016-01-29 15:07:22 +00:00
errno_defs.h
flat.h
flatload.c osdep: add wrappers for socket functions 2016-03-10 17:19:07 +00:00
ioctls.h linux-user: Convert blkpg to use a special subop handler 2014-10-06 21:52:45 +03:00
linux_loop.h
linuxload.c linux-user: Clean up includes 2016-01-29 15:07:22 +00:00
m68k-sim.c linux-user: Clean up includes 2016-01-29 15:07:22 +00:00
main.c linux-user: arm: handle CPSR.E correctly in strex emulation 2016-03-04 11:30:19 +00:00
Makefile.objs linux-user: rename cpu-uname -> uname 2014-05-02 21:59:36 +03:00
mmap.c linux-user: Clean up includes 2016-01-29 15:07:22 +00:00
qemu.h build: [linux-user] Rename "syscall.h" to "target_syscall.h" in target directories 2016-02-23 21:25:09 +02:00
signal.c linux-user: arm: fix coding style for some linux-user signal functions 2016-03-04 11:30:18 +00:00
socket.h linux-user: support SO_PASSSEC setsockopt option 2014-06-29 14:19:59 +03:00
strace.c linux-user: Clean up includes 2016-01-29 15:07:22 +00:00
strace.list linux-user: add setns and unshare 2014-08-22 15:06:34 +03:00
syscall_defs.h linux-user: Add SOCKOP_sendmmsg and SOCKOP_recvmmsg socket call, wire them up. 2016-01-11 14:54:03 +02:00
syscall_types.h linux-user: Convert blkpg to use a special subop handler 2014-10-06 21:52:45 +03:00
syscall.c linux-user: add getrandom() syscall 2016-02-24 15:22:15 +02:00
target_flat.h linux-user/FLAT: allow targets to override FLAT processing 2011-02-09 10:33:54 +02:00
uaccess.c linux-user: Clean up includes 2016-01-29 15:07:22 +00:00
uname.c linux-user: Clean up includes 2016-01-29 15:07:22 +00:00
uname.h linux-user: move uname functions to uname.c 2014-05-02 21:59:36 +03:00
vm86.c linux-user: Clean up includes 2016-01-29 15:07:22 +00:00