xwin: move winsock specific errno checks into ossock

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2026-02-10 11:11:01 +01:00
committed by Enrico Weigelt
parent 08f7471c66
commit 14f03de002
6 changed files with 36 additions and 25 deletions

View File

@@ -23,12 +23,14 @@ xwin_clipboard = static_library(
srcs_xwinclip = [
'xwinclip.c',
'debug.c',
'../../../os/ossock.c',
]
executable(
'xwinclip',
srcs_xwinclip,
dependencies: dependency('xcb'),
include_directories: inc,
link_with: xwin_clipboard,
link_args: ['-lgdi32', '-lpthread'],
install: true,

View File

@@ -32,8 +32,6 @@
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#else
#define HAS_WINSOCK 1
#endif
#include <assert.h>
@@ -42,17 +40,13 @@
#include <pthread.h>
#include <sys/param.h> // for MAX() macro
#ifdef HAS_WINSOCK
#include <X11/Xwinsock.h>
#else
#include <errno.h>
#endif
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xfixes.h>
#include "os/ossock.h"
#include "winclipboard.h"
#include "internal.h"
@@ -119,7 +113,6 @@ winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info)
int iMaxDescriptor;
xcb_connection_t *conn;
xcb_window_t iWindow = XCB_NONE;
int iSelectError;
BOOL fShutdown = FALSE;
ClipboardConversionData data;
int screen;
@@ -291,18 +284,8 @@ winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info)
#endif
);
#ifndef HAS_WINSOCK
iSelectError = errno;
#else
iSelectError = WSAGetLastError();
#endif
if (iReturn < 0) {
#ifndef HAS_WINSOCK
if (iSelectError == EINTR)
#else
if (iSelectError == WSAEINTR)
#endif
if (ossock_eintr(ossock_errno()))
continue;
ErrorF("winClipboardProc - Call to select () failed: %d. "

View File

@@ -389,8 +389,6 @@ endif
xwin_data = configuration_data()
xwin_data.set_quoted('DEFAULT_LOGDIR', log_dir)
xwin_data.set('HAS_WINSOCK', host_machine.system() == 'windows' ? '1' : false,
description: 'Use Windows sockets')
xwin_data.set('HAS_DEVWINDOWS', host_machine.system() == 'cygwin' ? '1' : false,
description: 'Has /dev/windows for signaling new win32 messages')
xwin_data.set('RELOCATE_PROJECTROOT', host_machine.system() == 'windows' ? '1' : false,

View File

@@ -10,9 +10,6 @@
#include <dix-config.h>
/* Winsock networking */
#mesondefine HAS_WINSOCK
/* Cygwin has /dev/windows for signaling new win32 messages */
#mesondefine HAS_DEVWINDOWS

View File

@@ -5,6 +5,7 @@
#include <dix-config.h>
#include <unistd.h>
#include <stdbool.h>
#ifdef WIN32
#include <X11/Xwinsock.h>
@@ -55,3 +56,21 @@ int ossock_wouldblock(int err)
return ((err == EAGAIN) || (err == EWOULDBLOCK));
#endif
}
bool ossock_eintr(int err)
{
#ifdef WIN32
return (err == WSAEINTR);
#else
return (err == EINTR);
#endif
}
int ossock_errno(void)
{
#ifdef WIN32
return WSAGetLastError();
#else
return errno;
#endif
}

View File

@@ -6,6 +6,7 @@
#define _XSERVER_OS_OSSOCK_H_
#include <errno.h>
#include <stdbool.h>
/*
* os specific initialization of the socket layer
@@ -27,4 +28,15 @@ int ossock_close(int fd);
*/
int ossock_wouldblock(int err);
/*
* os specific check for errno indicating operation interrupted
*/
bool ossock_eintr(int err);
/*
* os specific retrieval of last socket operation error
* on Unix: errno, on Win32: GetWSALastError()
*/
int ossock_errno(void);
#endif /* _XSERVER_OS_OSSOCK_H_ */