From 3b7d3190a16c41ebbb0bd18941f03059e95149ca Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Tue, 28 Apr 2015 09:30:45 +0300 Subject: [PATCH] Fix build with newer uclibc versions uClibc master branch, as well as uclibc-ng add eventfd_{read,write} definitions. Instead of testing for __UCLIBC__, have cmake explicitly check for the existence of eventfd_read and save the result in WITH_EVENTFD_READ_WRITE. Fixes build errors like: .../winpr/libwinpr/synch/event.c:120:12: error: static declaration of 'eventfd_read' follows non-static declaration static int eventfd_read(int fd, eventfd_t* value) ^ In file included from .../winpr/libwinpr/synch/event.c:39:0: .../usr/include/sys/eventfd.h:37:12: note: previous declaration of 'eventfd_read' was here extern int eventfd_read (int __fd, eventfd_t *__value); ^ .../winpr/libwinpr/synch/event.c:125:12: error: static declaration of 'eventfd_write' follows non-static declaration static int eventfd_write(int fd, eventfd_t value) ^ In file included from .../winpr/libwinpr/synch/event.c:39:0: .../usr/include/sys/eventfd.h:40:12: note: previous declaration of 'eventfd_write' was here extern int eventfd_write (int __fd, eventfd_t __value); --- CMakeLists.txt | 3 +++ config.h.in | 1 + winpr/libwinpr/comm/comm.c | 2 +- winpr/libwinpr/comm/comm.h | 3 ++- winpr/libwinpr/synch/event.c | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0acd44ea..db2170f9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -451,6 +451,9 @@ endif() if(UNIX OR CYGWIN) check_include_files(sys/eventfd.h HAVE_AIO_H) check_include_files(sys/eventfd.h HAVE_EVENTFD_H) + if (HAVE_EVENTFD_H) + check_symbol_exists(eventfd_read sys/eventfd.h WITH_EVENTFD_READ_WRITE) + endif() check_include_files(sys/timerfd.h HAVE_TIMERFD_H) check_include_files(poll.h HAVE_POLL_H) set(X11_FEATURE_TYPE "RECOMMENDED") diff --git a/config.h.in b/config.h.in index 82c75ee9a..e7b34c12e 100644 --- a/config.h.in +++ b/config.h.in @@ -45,6 +45,7 @@ #cmakedefine WITH_JPEG #cmakedefine WITH_WIN8 #cmakedefine WITH_RDPSND_DSOUND +#cmakedefine WITH_EVENTFD_READ_WRITE #cmakedefine WITH_FFMPEG #cmakedefine WITH_GSTREAMER_1_0 diff --git a/winpr/libwinpr/comm/comm.c b/winpr/libwinpr/comm/comm.c index 878ee04a0..5058be1be 100644 --- a/winpr/libwinpr/comm/comm.c +++ b/winpr/libwinpr/comm/comm.c @@ -1535,7 +1535,7 @@ BOOL CommCloseHandle(HANDLE handle) return TRUE; } -#ifdef __UCLIBC__ +#ifndef WITH_EVENTFD_READ_WRITE int eventfd_read(int fd, eventfd_t* value) { return (read(fd, value, sizeof(*value)) == sizeof(*value)) ? 0 : -1; diff --git a/winpr/libwinpr/comm/comm.h b/winpr/libwinpr/comm/comm.h index 772e62803..02b334377 100644 --- a/winpr/libwinpr/comm/comm.h +++ b/winpr/libwinpr/comm/comm.h @@ -29,6 +29,7 @@ #include #include "../handle/handle.h" +#include "config.h" struct winpr_comm { @@ -97,7 +98,7 @@ void CommLog_Print(int wlog_level, char *fmt, ...); BOOL CommIsHandled(HANDLE handle); BOOL CommCloseHandle(HANDLE handle); -#ifdef __UCLIBC__ +#ifndef WITH_EVENTFD_READ_WRITE int eventfd_read(int fd, eventfd_t* value); int eventfd_write(int fd, eventfd_t value); #endif diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c index 51c15b207..6b6176535 100644 --- a/winpr/libwinpr/synch/event.c +++ b/winpr/libwinpr/synch/event.c @@ -183,7 +183,7 @@ HANDLE OpenEventA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName) } #ifdef HAVE_EVENTFD_H -#if defined(__UCLIBC__) +#if !defined(WITH_EVENTFD_READ_WRITE) static int eventfd_read(int fd, eventfd_t* value) { return (read(fd, value, sizeof(*value)) == sizeof(*value)) ? 0 : -1;