Skip to content

Commit 24b7396

Browse files
committed
[CF] Apply missing includes and cleanups.
Here we apply a few cursory cleanups for porting purposes. These changes are as follows: * move a TARGET_OS_CYGWIN block: it was nested under TARGET_OS_MAC, which is probably not intended. * include sys/socket.h for TARGET_OS_BSD: which should be provided. * include netinet/in.h for !TARGET_OS_WIN32: which is required for struct sockaddr_in; from memory, this is included transitively on Linux, but not elsewhere. * use TARGET_OS_BSD instead of TARGET_OS_UNIX: TARGET_OS_UNIX appears no longer used; TARGET_OS_BSD is a synonym for __unix__ anyway. * disuse pthread_setname_np for TARGET_OS_BSD: this doesn't appear in the FreeBSD manuals, it's not available on OpenBSD, so let's just disuse it.
1 parent c2ac394 commit 24b7396

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

CoreFoundation/RunLoop.subproj/CFSocket.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -942,14 +942,15 @@ Boolean __CFSocketGetBytesAvailable(CFSocketRef s, CFIndex* ctBytesAvailable) {
942942
#include <sys/un.h>
943943
#include <libc.h>
944944
#include <dlfcn.h>
945-
#if TARGET_OS_CYGWIN
946-
#include <sys/socket.h>
947945
#endif
946+
#if TARGET_OS_CYGWIN || TARGET_OS_BSD
947+
#include <sys/socket.h>
948948
#endif
949949
#if TARGET_OS_WIN32
950950
#include <WinSock2.h>
951951
#else
952952
#include <arpa/inet.h>
953+
#include <netinet/in.h>
953954
#endif
954955
#if !TARGET_OS_WIN32
955956
#include <sys/ioctl.h>
@@ -1117,7 +1118,7 @@ static void __cfSocketLogWithSocket(CFSocketRef s, const char* function, int lin
11171118
#endif
11181119

11191120

1120-
#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_UNIX
1121+
#if TARGET_OS_MAC || TARGET_OS_LINUX || TARGET_OS_BSD
11211122
#define INVALID_SOCKET (CFSocketNativeHandle)(-1)
11221123
#define closesocket(a) close((a))
11231124
#define ioctlsocket(a,b,c) ioctl((a),(b),(c))
@@ -2174,10 +2175,9 @@ manageSelectError()
21742175

21752176
static void *__CFSocketManager(void * arg)
21762177
{
2177-
#if (TARGET_OS_LINUX && !TARGET_OS_CYGWIN) || TARGET_OS_BSD
2178+
#if TARGET_OS_LINUX && !TARGET_OS_CYGWIN
21782179
pthread_setname_np(pthread_self(), "com.apple.CFSocket.private");
2179-
#elif TARGET_OS_CYGWIN
2180-
#else
2180+
#elif !TARGET_OS_CYGWIN && !TARGET_OS_BSD
21812181
pthread_setname_np("com.apple.CFSocket.private");
21822182
#endif
21832183
SInt32 nrfds, maxnrfds, fdentries = 1;

0 commit comments

Comments
 (0)