From 231eda090d2a379c3767a58dfa6f08070378caee Mon Sep 17 00:00:00 2001 From: Juergen Kosel Date: Tue, 13 Mar 2018 08:37:24 +0100 Subject: [PATCH] Move definition of mutex_type into own header file To avoid inconsitstant definition of "bool", the definition of mutex_type is moved into its own header file. This way, Socket.h does not need to include Thread.h. Signed-off-by: Juergen Kosel --- src/Socket.h | 4 ++-- src/Thread.h | 4 ++-- src/mutex_type.h | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/mutex_type.h diff --git a/src/Socket.h b/src/Socket.h index 8b249aaf..6add4196 100644 --- a/src/Socket.h +++ b/src/Socket.h @@ -65,7 +65,7 @@ #define ULONG size_t #endif -#include "Thread.h" /* Needed for mutex_type */ +#include "mutex_type.h" /* Needed for mutex_type */ /** socket operation completed successfully */ #define TCPSOCKET_COMPLETE 0 @@ -126,7 +126,7 @@ typedef struct void Socket_outInitialize(void); void Socket_outTerminate(void); -int Socket_getReadySocket(int more_work, struct timeval *tp,mutex_type mutex); +int Socket_getReadySocket(int more_work, struct timeval *tp, mutex_type mutex); int Socket_getch(int socket, char* c); char *Socket_getdata(int socket, size_t bytes, size_t* actual_len); int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** buffers, size_t* buflens, int* frees); diff --git a/src/Thread.h b/src/Thread.h index 995e221c..f61ca1d8 100644 --- a/src/Thread.h +++ b/src/Thread.h @@ -21,13 +21,14 @@ #if !defined(THREAD_H) #define THREAD_H +#include "mutex_type.h" /* Needed for mutex_type */ + #if defined(WIN32) || defined(WIN64) #include #define thread_type HANDLE #define thread_id_type DWORD #define thread_return_type DWORD #define thread_fn LPTHREAD_START_ROUTINE - #define mutex_type HANDLE #define cond_type HANDLE #define sem_type HANDLE #else @@ -37,7 +38,6 @@ #define thread_id_type pthread_t #define thread_return_type void* typedef thread_return_type (*thread_fn)(void*); - #define mutex_type pthread_mutex_t* typedef struct { pthread_cond_t cond; pthread_mutex_t mutex; } cond_type_struct; typedef cond_type_struct *cond_type; #if defined(OSX) diff --git a/src/mutex_type.h b/src/mutex_type.h new file mode 100644 index 00000000..97dd9985 --- /dev/null +++ b/src/mutex_type.h @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2009, 2014 IBM Corp. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + *******************************************************************************/ +#ifndef _MUTEX_TYPE_H_ +#define _MUTEX_TYPE_H_ + +#if defined(WIN32) || defined(WIN64) + #include + #define mutex_type HANDLE +#else + #include + #define mutex_type pthread_mutex_t* +#endif + +#endif /* _MUTEX_TYPE_H_ */