2010-06-10 13:42:16 +04:00
|
|
|
/*
|
|
|
|
* win32 specific declarations
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2008 Fabrice Bellard
|
|
|
|
* Copyright (c) 2010 Jes Sorensen <Jes.Sorensen@redhat.com>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QEMU_OS_WIN32_H
|
|
|
|
#define QEMU_OS_WIN32_H
|
|
|
|
|
2011-03-27 13:04:57 +04:00
|
|
|
#include <winsock2.h>
|
2016-02-09 17:16:57 +03:00
|
|
|
#include <windows.h>
|
2016-03-07 23:25:19 +03:00
|
|
|
#include <ws2tcpip.h>
|
2023-02-21 15:47:51 +03:00
|
|
|
#include "qemu/typedefs.h"
|
2011-03-27 13:04:57 +04:00
|
|
|
|
2022-08-02 10:51:58 +03:00
|
|
|
#ifdef HAVE_AFUNIX_H
|
|
|
|
#include <afunix.h>
|
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* Fallback definitions of things we need in afunix.h, if not available from
|
|
|
|
* the used Windows SDK or MinGW headers.
|
|
|
|
*/
|
|
|
|
#define UNIX_PATH_MAX 108
|
|
|
|
|
|
|
|
typedef struct sockaddr_un {
|
|
|
|
ADDRESS_FAMILY sun_family;
|
|
|
|
char sun_path[UNIX_PATH_MAX];
|
|
|
|
} SOCKADDR_UN, *PSOCKADDR_UN;
|
|
|
|
|
|
|
|
#define SIO_AF_UNIX_GETPEERPID _WSAIOR(IOC_VENDOR, 256)
|
|
|
|
#endif
|
|
|
|
|
2021-04-16 16:55:41 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-02-21 18:30:04 +03:00
|
|
|
#if defined(__aarch64__)
|
|
|
|
/*
|
|
|
|
* On windows-arm64, setjmp is available in only one variant, and longjmp always
|
|
|
|
* does stack unwinding. This crash with generated code.
|
|
|
|
* Thus, we use another implementation of setjmp (not windows one), coming from
|
|
|
|
* mingw, which never performs stack unwinding.
|
|
|
|
*/
|
|
|
|
#undef setjmp
|
|
|
|
#undef longjmp
|
|
|
|
/*
|
|
|
|
* These functions are not declared in setjmp.h because __aarch64__ defines
|
|
|
|
* setjmp to _setjmpex instead. However, they are still defined in libmingwex.a,
|
|
|
|
* which gets linked automatically.
|
|
|
|
*/
|
2023-03-20 16:21:29 +03:00
|
|
|
int __mingw_setjmp(jmp_buf);
|
|
|
|
void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);
|
2023-02-21 18:30:04 +03:00
|
|
|
#define setjmp(env) __mingw_setjmp(env)
|
|
|
|
#define longjmp(env, val) __mingw_longjmp(env, val)
|
|
|
|
#elif defined(_WIN64)
|
|
|
|
/*
|
|
|
|
* On windows-x64, setjmp is implemented by _setjmp which needs a second parameter.
|
2012-04-12 23:13:28 +04:00
|
|
|
* If this parameter is NULL, longjump does no stack unwinding.
|
|
|
|
* That is what we need for QEMU. Passing the value of register rsp (default)
|
2023-02-21 18:30:04 +03:00
|
|
|
* lets longjmp try a stack unwinding which will crash with generated code.
|
|
|
|
*/
|
2012-04-12 23:13:28 +04:00
|
|
|
# undef setjmp
|
|
|
|
# define setjmp(env) _setjmp(env, NULL)
|
2023-02-21 18:30:04 +03:00
|
|
|
#endif /* __aarch64__ */
|
2013-02-20 19:21:09 +04:00
|
|
|
/* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify
|
|
|
|
* "longjmp and don't touch the signal masks". Since we know that the
|
|
|
|
* savemask parameter will always be zero we can safely define these
|
|
|
|
* in terms of setjmp/longjmp on Win32.
|
|
|
|
*/
|
|
|
|
#define sigjmp_buf jmp_buf
|
|
|
|
#define sigsetjmp(env, savemask) setjmp(env)
|
|
|
|
#define siglongjmp(env, val) longjmp(env, val)
|
2012-04-12 23:13:28 +04:00
|
|
|
|
2012-09-23 00:26:19 +04:00
|
|
|
/* Missing POSIX functions. Don't use MinGW-w64 macros. */
|
win32: Simplify gmtime_r detection not depends on if _POSIX_C_SOURCE are defined on msys2/mingw
We remove the CONFIG_LOCALTIME_R detection option in configure, and move the check
existence of gmtime_r from configure into C header and source directly by using macro
`_POSIX_THREAD_SAFE_FUNCTIONS`.
Before this patch, the configure script are always assume the compiler doesn't define
_POSIX_C_SOURCE macro at all, but that's not true, because thirdparty library such
as ncursesw may define -D_POSIX_C_SOURCE in it's pkg-config file. And that C Flags will
added -D_POSIX_C_SOURCE into each QEMU_CFLAGS. And that's causing the following compiling error:
n file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
from ../softmmu/main.c:25:
C:/work/xemu/qemu/include/sysemu/os-win32.h:53:12: error: redundant redeclaration of 'gmtime_r' [-Werror=redundant-decls]
53 | struct tm *gmtime_r(const time_t *timep, struct tm *result);
| ^~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
from ../softmmu/main.c:25:
C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:284:36: note: previous definition of 'gmtime_r' was here
284 | __forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
| ^~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
from ../softmmu/main.c:25:
C:/work/xemu/qemu/include/sysemu/os-win32.h:55:12: error: redundant redeclaration of 'localtime_r' [-Werror=redundant-decls]
55 | struct tm *localtime_r(const time_t *timep, struct tm *result);
| ^~~~~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
from ../softmmu/main.c:25:
C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:281:36: note: previous definition of 'localtime_r' was here
281 | __forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
| ^~~~~~~~~~~
Compiling C object libcommon.fa.p/hw_gpio_zaurus.c.obj
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
from ../hw/i2c/smbus_slave.c:16:
C:/work/xemu/qemu/include/sysemu/os-win32.h:53:12: error: redundant redeclaration of 'gmtime_r' [-Werror=redundant-decls]
53 | struct tm *gmtime_r(const time_t *timep, struct tm *result);
| ^~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
from ../hw/i2c/smbus_slave.c:16:
C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:284:36: note: previous definition of 'gmtime_r' was here
284 | __forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
| ^~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
from ../hw/i2c/smbus_slave.c:16:
C:/work/xemu/qemu/include/sysemu/os-win32.h:55:12: error: redundant redeclaration of 'localtime_r' [-Werror=redundant-decls]
55 | struct tm *localtime_r(const time_t *timep, struct tm *result);
| ^~~~~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
from ../hw/i2c/smbus_slave.c:16:
C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:281:36: note: previous definition of 'localtime_r' was here
281 | __forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
| ^~~~~~~~~~~
Compiling C object libcommon.fa.p/hw_dma_xilinx_axidma.c.obj
After this patch, whenever ncursesw or other thirdparty libraries tried to define or not
define _POSIX_C_SOURCE, the source will building properly. Because now, we don't make any
assumption if _POSIX_C_SOURCE are defined. We solely relied on if the macro `_POSIX_THREAD_SAFE_FUNCTIONS`
are defined in msys2/mingw header.
The _POSIX_THREAD_SAFE_FUNCTIONS are defined in mingw header like this:
```
#if defined(_POSIX_C_SOURCE) && !defined(_POSIX_THREAD_SAFE_FUNCTIONS)
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
#endif
#ifdef _POSIX_THREAD_SAFE_FUNCTIONS
__forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
return localtime_s(_Tm, _Time) ? NULL : _Tm;
}
__forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
return gmtime_s(_Tm, _Time) ? NULL : _Tm;
}
__forceinline char *__CRTDECL ctime_r(const time_t *_Time, char *_Str) {
return ctime_s(_Str, 0x7fffffff, _Time) ? NULL : _Str;
}
__forceinline char *__CRTDECL asctime_r(const struct tm *_Tm, char * _Str) {
return asctime_s(_Str, 0x7fffffff, _Tm) ? NULL : _Str;
}
#endif
```
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20201012234348.1427-5-luoyonggang@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-10-13 02:43:47 +03:00
|
|
|
#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
|
2012-09-23 00:26:19 +04:00
|
|
|
#undef gmtime_r
|
|
|
|
struct tm *gmtime_r(const time_t *timep, struct tm *result);
|
|
|
|
#undef localtime_r
|
|
|
|
struct tm *localtime_r(const time_t *timep, struct tm *result);
|
win32: Simplify gmtime_r detection not depends on if _POSIX_C_SOURCE are defined on msys2/mingw
We remove the CONFIG_LOCALTIME_R detection option in configure, and move the check
existence of gmtime_r from configure into C header and source directly by using macro
`_POSIX_THREAD_SAFE_FUNCTIONS`.
Before this patch, the configure script are always assume the compiler doesn't define
_POSIX_C_SOURCE macro at all, but that's not true, because thirdparty library such
as ncursesw may define -D_POSIX_C_SOURCE in it's pkg-config file. And that C Flags will
added -D_POSIX_C_SOURCE into each QEMU_CFLAGS. And that's causing the following compiling error:
n file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
from ../softmmu/main.c:25:
C:/work/xemu/qemu/include/sysemu/os-win32.h:53:12: error: redundant redeclaration of 'gmtime_r' [-Werror=redundant-decls]
53 | struct tm *gmtime_r(const time_t *timep, struct tm *result);
| ^~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
from ../softmmu/main.c:25:
C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:284:36: note: previous definition of 'gmtime_r' was here
284 | __forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
| ^~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
from ../softmmu/main.c:25:
C:/work/xemu/qemu/include/sysemu/os-win32.h:55:12: error: redundant redeclaration of 'localtime_r' [-Werror=redundant-decls]
55 | struct tm *localtime_r(const time_t *timep, struct tm *result);
| ^~~~~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
from ../softmmu/main.c:25:
C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:281:36: note: previous definition of 'localtime_r' was here
281 | __forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
| ^~~~~~~~~~~
Compiling C object libcommon.fa.p/hw_gpio_zaurus.c.obj
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
from ../hw/i2c/smbus_slave.c:16:
C:/work/xemu/qemu/include/sysemu/os-win32.h:53:12: error: redundant redeclaration of 'gmtime_r' [-Werror=redundant-decls]
53 | struct tm *gmtime_r(const time_t *timep, struct tm *result);
| ^~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
from ../hw/i2c/smbus_slave.c:16:
C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:284:36: note: previous definition of 'gmtime_r' was here
284 | __forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
| ^~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:119,
from ../hw/i2c/smbus_slave.c:16:
C:/work/xemu/qemu/include/sysemu/os-win32.h:55:12: error: redundant redeclaration of 'localtime_r' [-Werror=redundant-decls]
55 | struct tm *localtime_r(const time_t *timep, struct tm *result);
| ^~~~~~~~~~~
In file included from C:/work/xemu/qemu/include/qemu/osdep.h:94,
from ../hw/i2c/smbus_slave.c:16:
C:/CI-Tools/msys64/mingw64/x86_64-w64-mingw32/include/time.h:281:36: note: previous definition of 'localtime_r' was here
281 | __forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
| ^~~~~~~~~~~
Compiling C object libcommon.fa.p/hw_dma_xilinx_axidma.c.obj
After this patch, whenever ncursesw or other thirdparty libraries tried to define or not
define _POSIX_C_SOURCE, the source will building properly. Because now, we don't make any
assumption if _POSIX_C_SOURCE are defined. We solely relied on if the macro `_POSIX_THREAD_SAFE_FUNCTIONS`
are defined in msys2/mingw header.
The _POSIX_THREAD_SAFE_FUNCTIONS are defined in mingw header like this:
```
#if defined(_POSIX_C_SOURCE) && !defined(_POSIX_THREAD_SAFE_FUNCTIONS)
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
#endif
#ifdef _POSIX_THREAD_SAFE_FUNCTIONS
__forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
return localtime_s(_Tm, _Time) ? NULL : _Tm;
}
__forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
return gmtime_s(_Tm, _Time) ? NULL : _Tm;
}
__forceinline char *__CRTDECL ctime_r(const time_t *_Time, char *_Str) {
return ctime_s(_Str, 0x7fffffff, _Time) ? NULL : _Str;
}
__forceinline char *__CRTDECL asctime_r(const struct tm *_Tm, char * _Str) {
return asctime_s(_Str, 0x7fffffff, _Tm) ? NULL : _Str;
}
#endif
```
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20201012234348.1427-5-luoyonggang@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-10-13 02:43:47 +03:00
|
|
|
#endif /* _POSIX_THREAD_SAFE_FUNCTIONS */
|
2012-09-23 00:26:19 +04:00
|
|
|
|
2010-06-10 13:42:22 +04:00
|
|
|
static inline void os_setup_signal_handling(void) {}
|
2010-06-10 13:42:28 +04:00
|
|
|
static inline void os_daemonize(void) {}
|
|
|
|
static inline void os_setup_post(void) {}
|
2010-06-10 13:42:31 +04:00
|
|
|
static inline void os_set_proc_name(const char *dummy) {}
|
2022-03-23 18:57:37 +03:00
|
|
|
void os_set_line_buffering(void);
|
|
|
|
void os_setup_early_signal_handling(void);
|
2010-06-10 13:42:22 +04:00
|
|
|
|
2015-11-14 22:25:44 +03:00
|
|
|
int getpagesize(void);
|
2014-05-14 13:43:21 +04:00
|
|
|
|
2010-06-25 00:41:33 +04:00
|
|
|
#if !defined(EPROTONOSUPPORT)
|
|
|
|
# define EPROTONOSUPPORT EINVAL
|
|
|
|
#endif
|
|
|
|
|
2022-03-03 19:48:11 +03:00
|
|
|
static inline int os_set_daemonize(bool d)
|
|
|
|
{
|
|
|
|
if (d) {
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-14 20:15:41 +04:00
|
|
|
static inline bool is_daemonized(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-19 18:42:06 +04:00
|
|
|
static inline int os_mlock(void)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2023-12-18 13:13:40 +03:00
|
|
|
static inline void os_setup_limits(void)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-19 18:20:19 +03:00
|
|
|
#define fsync _commit
|
|
|
|
|
|
|
|
#if !defined(lseek)
|
|
|
|
# define lseek _lseeki64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int qemu_ftruncate64(int, int64_t);
|
|
|
|
|
|
|
|
#if !defined(ftruncate)
|
|
|
|
# define ftruncate qemu_ftruncate64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline char *realpath(const char *path, char *resolved_path)
|
|
|
|
{
|
|
|
|
_fullpath(resolved_path, path, _MAX_PATH);
|
|
|
|
return resolved_path;
|
|
|
|
}
|
|
|
|
|
2022-04-17 21:30:06 +03:00
|
|
|
/*
|
|
|
|
* Older versions of MinGW do not import _lock_file and _unlock_file properly.
|
|
|
|
* This was fixed for v6.0.0 with commit b48e3ac8969d.
|
2016-09-23 01:17:10 +03:00
|
|
|
*/
|
|
|
|
static inline void qemu_flockfile(FILE *f)
|
|
|
|
{
|
2022-04-17 21:30:06 +03:00
|
|
|
#ifdef HAVE__LOCK_FILE
|
|
|
|
_lock_file(f);
|
|
|
|
#endif
|
2016-09-23 01:17:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void qemu_funlockfile(FILE *f)
|
|
|
|
{
|
2022-04-17 21:30:06 +03:00
|
|
|
#ifdef HAVE__LOCK_FILE
|
|
|
|
_unlock_file(f);
|
|
|
|
#endif
|
2016-09-23 01:17:10 +03:00
|
|
|
}
|
2016-03-07 23:25:19 +03:00
|
|
|
|
2023-02-21 15:47:51 +03:00
|
|
|
/* Helper for WSAEventSelect, to report errors */
|
win32: avoid mixing SOCKET and file descriptor space
Until now, a win32 SOCKET handle is often cast to an int file
descriptor, as this is what other OS use for sockets. When necessary,
QEMU eventually queries whether it's a socket with the help of
fd_is_socket(). However, there is no guarantee of conflict between the
fd and SOCKET space. Such conflict would have surprising consequences,
we shouldn't mix them.
Also, it is often forgotten that SOCKET must be closed with
closesocket(), and not close().
Instead, let's make the win32 socket wrapper functions return and take a
file descriptor, and let util/ wrappers do the fd/SOCKET conversion as
necessary. A bit of adaptation is necessary in io/ as well.
Unfortunately, we can't drop closesocket() usage, despite
_open_osfhandle() documentation claiming transfer of ownership, testing
shows bad behaviour if you forget to call closesocket().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20230221124802.4103554-15-marcandre.lureau@redhat.com>
2023-02-21 15:47:59 +03:00
|
|
|
bool qemu_socket_select(int sockfd, WSAEVENT hEventObject,
|
2023-02-21 15:47:51 +03:00
|
|
|
long lNetworkEvents, Error **errp);
|
|
|
|
|
win32: avoid mixing SOCKET and file descriptor space
Until now, a win32 SOCKET handle is often cast to an int file
descriptor, as this is what other OS use for sockets. When necessary,
QEMU eventually queries whether it's a socket with the help of
fd_is_socket(). However, there is no guarantee of conflict between the
fd and SOCKET space. Such conflict would have surprising consequences,
we shouldn't mix them.
Also, it is often forgotten that SOCKET must be closed with
closesocket(), and not close().
Instead, let's make the win32 socket wrapper functions return and take a
file descriptor, and let util/ wrappers do the fd/SOCKET conversion as
necessary. A bit of adaptation is necessary in io/ as well.
Unfortunately, we can't drop closesocket() usage, despite
_open_osfhandle() documentation claiming transfer of ownership, testing
shows bad behaviour if you forget to call closesocket().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20230221124802.4103554-15-marcandre.lureau@redhat.com>
2023-02-21 15:47:59 +03:00
|
|
|
bool qemu_socket_unselect(int sockfd, Error **errp);
|
2023-02-21 15:47:52 +03:00
|
|
|
|
2023-03-20 16:36:41 +03:00
|
|
|
/* We wrap all the sockets functions so that we can set errno based on
|
|
|
|
* WSAGetLastError(), and use file-descriptors instead of SOCKET.
|
2016-03-07 23:25:19 +03:00
|
|
|
*/
|
|
|
|
|
2023-03-20 16:36:41 +03:00
|
|
|
/*
|
|
|
|
* qemu_close_socket_osfhandle:
|
|
|
|
* @fd: a file descriptor associated with a SOCKET
|
|
|
|
*
|
|
|
|
* Close only the C run-time file descriptor, leave the SOCKET opened.
|
|
|
|
*
|
|
|
|
* Returns zero on success. On error, -1 is returned, and errno is set to
|
|
|
|
* indicate the error.
|
|
|
|
*/
|
|
|
|
int qemu_close_socket_osfhandle(int fd);
|
|
|
|
|
2023-02-21 15:48:01 +03:00
|
|
|
#undef close
|
|
|
|
#define close qemu_close_wrap
|
|
|
|
int qemu_close_wrap(int fd);
|
|
|
|
|
2016-03-07 23:25:19 +03:00
|
|
|
#undef connect
|
|
|
|
#define connect qemu_connect_wrap
|
|
|
|
int qemu_connect_wrap(int sockfd, const struct sockaddr *addr,
|
|
|
|
socklen_t addrlen);
|
|
|
|
|
|
|
|
#undef listen
|
|
|
|
#define listen qemu_listen_wrap
|
|
|
|
int qemu_listen_wrap(int sockfd, int backlog);
|
|
|
|
|
|
|
|
#undef bind
|
|
|
|
#define bind qemu_bind_wrap
|
|
|
|
int qemu_bind_wrap(int sockfd, const struct sockaddr *addr,
|
|
|
|
socklen_t addrlen);
|
|
|
|
|
|
|
|
#undef socket
|
|
|
|
#define socket qemu_socket_wrap
|
|
|
|
int qemu_socket_wrap(int domain, int type, int protocol);
|
|
|
|
|
|
|
|
#undef accept
|
|
|
|
#define accept qemu_accept_wrap
|
|
|
|
int qemu_accept_wrap(int sockfd, struct sockaddr *addr,
|
|
|
|
socklen_t *addrlen);
|
|
|
|
|
|
|
|
#undef shutdown
|
|
|
|
#define shutdown qemu_shutdown_wrap
|
|
|
|
int qemu_shutdown_wrap(int sockfd, int how);
|
|
|
|
|
|
|
|
#undef ioctlsocket
|
|
|
|
#define ioctlsocket qemu_ioctlsocket_wrap
|
|
|
|
int qemu_ioctlsocket_wrap(int fd, int req, void *val);
|
|
|
|
|
|
|
|
#undef getsockopt
|
|
|
|
#define getsockopt qemu_getsockopt_wrap
|
|
|
|
int qemu_getsockopt_wrap(int sockfd, int level, int optname,
|
|
|
|
void *optval, socklen_t *optlen);
|
|
|
|
|
|
|
|
#undef setsockopt
|
|
|
|
#define setsockopt qemu_setsockopt_wrap
|
|
|
|
int qemu_setsockopt_wrap(int sockfd, int level, int optname,
|
|
|
|
const void *optval, socklen_t optlen);
|
|
|
|
|
|
|
|
#undef getpeername
|
|
|
|
#define getpeername qemu_getpeername_wrap
|
|
|
|
int qemu_getpeername_wrap(int sockfd, struct sockaddr *addr,
|
|
|
|
socklen_t *addrlen);
|
|
|
|
|
|
|
|
#undef getsockname
|
|
|
|
#define getsockname qemu_getsockname_wrap
|
|
|
|
int qemu_getsockname_wrap(int sockfd, struct sockaddr *addr,
|
|
|
|
socklen_t *addrlen);
|
|
|
|
|
|
|
|
#undef send
|
|
|
|
#define send qemu_send_wrap
|
|
|
|
ssize_t qemu_send_wrap(int sockfd, const void *buf, size_t len, int flags);
|
|
|
|
|
|
|
|
#undef sendto
|
|
|
|
#define sendto qemu_sendto_wrap
|
|
|
|
ssize_t qemu_sendto_wrap(int sockfd, const void *buf, size_t len, int flags,
|
|
|
|
const struct sockaddr *addr, socklen_t addrlen);
|
|
|
|
|
|
|
|
#undef recv
|
|
|
|
#define recv qemu_recv_wrap
|
|
|
|
ssize_t qemu_recv_wrap(int sockfd, void *buf, size_t len, int flags);
|
|
|
|
|
|
|
|
#undef recvfrom
|
|
|
|
#define recvfrom qemu_recvfrom_wrap
|
|
|
|
ssize_t qemu_recvfrom_wrap(int sockfd, void *buf, size_t len, int flags,
|
|
|
|
struct sockaddr *addr, socklen_t *addrlen);
|
|
|
|
|
2023-05-15 16:24:40 +03:00
|
|
|
EXCEPTION_DISPOSITION
|
|
|
|
win32_close_exception_handler(struct _EXCEPTION_RECORD*, void*,
|
|
|
|
struct _CONTEXT*, void*);
|
|
|
|
|
2023-06-06 14:56:46 +03:00
|
|
|
void *qemu_win32_map_alloc(size_t size, HANDLE *h, Error **errp);
|
|
|
|
void qemu_win32_map_free(void *ptr, HANDLE h, Error **errp);
|
|
|
|
|
2021-04-16 16:55:41 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-06-10 13:42:16 +04:00
|
|
|
#endif
|