From: <sba...@us...> - 2024-07-06 06:25:30
|
This is an automated email from the git hooks/post-receive-user script. sbaldovi pushed a commit to branch master in repository fuse. View the commit online: https://sourceforge.net/p/fuse-emulator/fuse/ci/52da9153ee12199b4e60589be97ced31892695c0/ commit 52da9153ee12199b4e60589be97ced31892695c0 Author: ZXGuesser <ali...@zx...> AuthorDate: Sun Jun 30 10:46:31 2024 +0100 move FIONREAD probe to compat function --- compat.h | 1 + compat/unix/socket.c | 10 ++++++++++ compat/win32/socket.c | 6 ++++++ peripherals/ttx2000s.c | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/compat.h b/compat.h index 0d142805..a3aae044 100644 --- a/compat.h +++ b/compat.h @@ -202,6 +202,7 @@ void compat_socket_networking_init( void ); void compat_socket_networking_end( void ); int compat_socket_blocking_mode( compat_socket_t fd, int blocking ); +int compat_socket_get_fionread( compat_socket_t fd, u_long *bytes ); int compat_socket_close( compat_socket_t fd ); int compat_socket_get_error( void ); const char *compat_socket_get_strerror( void ); diff --git a/compat/unix/socket.c b/compat/unix/socket.c index f182a0d5..c57554c9 100644 --- a/compat/unix/socket.c +++ b/compat/unix/socket.c @@ -27,6 +27,7 @@ #include <string.h> #include <unistd.h> #include <fcntl.h> +#include <sys/ioctl.h> #include "compat.h" #include "fuse.h" @@ -62,6 +63,15 @@ compat_socket_blocking_mode( compat_socket_t fd, int blocking ) return ( fcntl( fd, F_SETFL, flags ) != 0 ); } +int +compat_socket_get_fionread( compat_socket_t fd, u_long *bytes) +{ + int b; + int err = ioctl( fd, FIONREAD, &b ); + *bytes = b; + return ( err ); +} + int compat_socket_close( compat_socket_t fd ) { diff --git a/compat/win32/socket.c b/compat/win32/socket.c index 013cc82d..e88151ce 100644 --- a/compat/win32/socket.c +++ b/compat/win32/socket.c @@ -45,6 +45,12 @@ compat_socket_blocking_mode( compat_socket_t fd, int blocking ) return ( ioctlsocket( fd, FIONBIO, &mode ) ); } +int +compat_socket_get_fionread( compat_socket_t fd, u_long *bytes) +{ + return ( ioctlsocket( fd, FIONREAD, bytes ) ); +} + int compat_socket_close( compat_socket_t fd ) { diff --git a/peripherals/ttx2000s.c b/peripherals/ttx2000s.c index 36344aba..27916e8d 100644 --- a/peripherals/ttx2000s.c +++ b/peripherals/ttx2000s.c @@ -354,7 +354,7 @@ ttx2000s_field_event( libspectrum_dword last_tstates GCC_UNUSED, int event, if( teletext_socket != compat_socket_invalid && ttx2000s_connected ) { u_long n; /* try to determine the amount of data available in socket read buffer */ - if( ioctlsocket( teletext_socket, FIONREAD, &n ) == -1) { + if( compat_socket_get_fionread( teletext_socket, &n ) == -1) { ui_error( UI_ERROR_ERROR, "ttx2000s: FIONREAD failed with errno %d: %s\n", errno, compat_socket_get_strerror() ); |