From b5c49ff8af64a2989140381d4fac51446008a56e Mon Sep 17 00:00:00 2001 From: "ajm@google.com" Date: Mon, 1 Aug 2011 17:04:04 +0000 Subject: [PATCH] Rename all files/classes shared by Linux and Mac to Posix. Besides being a good idea in general, this lets us use the good chromium_code==1 warning settings on Mac and Windows. Straight rename except for a change to use os_posix in the gyp files. Review URL: http://webrtc-codereview.appspot.com/88011 git-svn-id: http://webrtc.googlecode.com/svn/trunk@282 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/udp_transport/source/Android.mk | 4 +- ...r_linux.cc => udp_socket_manager_posix.cc} | 106 +++++++++--------- ...ger_linux.h => udp_socket_manager_posix.h} | 22 ++-- .../source/udp_socket_manager_wrapper.cc | 4 +- ...dp_socket_linux.cc => udp_socket_posix.cc} | 42 +++---- ...{udp_socket_linux.h => udp_socket_posix.h} | 14 +-- .../source/udp_socket_wrapper.cc | 6 +- .../udp_transport/source/udp_transport.gyp | 22 ++-- src/system_wrappers/source/Android.mk | 12 +- .../source/condition_variable.cc | 8 +- ...e_linux.cc => condition_variable_posix.cc} | 26 ++--- ...ble_linux.h => condition_variable_posix.h} | 12 +- .../source/critical_section.cc | 4 +- ...ion_linux.cc => critical_section_posix.cc} | 10 +- ...ction_linux.h => critical_section_posix.h} | 14 +-- src/system_wrappers/source/event.cc | 4 +- .../source/{event_linux.cc => event_posix.cc} | 32 +++--- .../source/{event_linux.h => event_posix.h} | 14 +-- src/system_wrappers/source/rw_lock.cc | 4 +- .../{rw_lock_linux.cc => rw_lock_posix.cc} | 16 +-- .../{rw_lock_linux.h => rw_lock_posix.h} | 12 +- .../source/system_wrappers.gyp | 44 +++----- src/system_wrappers/source/thread.cc | 4 +- .../{thread_linux.cc => thread_posix.cc} | 30 ++--- .../source/{thread_linux.h => thread_posix.h} | 12 +- src/system_wrappers/source/trace_impl.cc | 4 +- .../source/{trace_linux.cc => trace_posix.cc} | 14 +-- .../source/{trace_linux.h => trace_posix.h} | 12 +- 28 files changed, 249 insertions(+), 259 deletions(-) rename src/modules/udp_transport/source/{udp_socket_manager_linux.cc => udp_socket_manager_posix.cc} (74%) rename src/modules/udp_transport/source/{udp_socket_manager_linux.h => udp_socket_manager_posix.h} (77%) rename src/modules/udp_transport/source/{udp_socket_linux.cc => udp_socket_posix.cc} (83%) rename src/modules/udp_transport/source/{udp_socket_linux.h => udp_socket_posix.h} (87%) rename src/system_wrappers/source/{condition_variable_linux.cc => condition_variable_posix.cc} (82%) rename src/system_wrappers/source/{condition_variable_linux.h => condition_variable_posix.h} (72%) rename src/system_wrappers/source/{critical_section_linux.cc => critical_section_posix.cc} (80%) rename src/system_wrappers/source/{critical_section_linux.h => critical_section_posix.h} (63%) rename src/system_wrappers/source/{event_linux.cc => event_posix.cc} (90%) rename src/system_wrappers/source/{event_linux.h => event_posix.h} (81%) rename src/system_wrappers/source/{rw_lock_linux.cc => rw_lock_posix.cc} (72%) rename src/system_wrappers/source/{rw_lock_linux.h => rw_lock_posix.h} (74%) rename src/system_wrappers/source/{thread_linux.cc => thread_posix.cc} (91%) rename src/system_wrappers/source/{thread_linux.h => thread_posix.h} (85%) rename src/system_wrappers/source/{trace_linux.cc => trace_posix.cc} (90%) rename src/system_wrappers/source/{trace_linux.h => trace_posix.h} (80%) diff --git a/src/modules/udp_transport/source/Android.mk b/src/modules/udp_transport/source/Android.mk index b1156685f6..c29fd819b7 100644 --- a/src/modules/udp_transport/source/Android.mk +++ b/src/modules/udp_transport/source/Android.mk @@ -19,8 +19,8 @@ LOCAL_GENERATED_SOURCES := LOCAL_SRC_FILES := udp_transport_impl.cc \ udp_socket_wrapper.cc \ udp_socket_manager_wrapper.cc \ - udp_socket_manager_linux.cc \ - udp_socket_linux.cc + udp_socket_manager_posix.cc \ + udp_socket_posix.cc # Flags passed to both C and C++ files. MY_CFLAGS := diff --git a/src/modules/udp_transport/source/udp_socket_manager_linux.cc b/src/modules/udp_transport/source/udp_socket_manager_posix.cc similarity index 74% rename from src/modules/udp_transport/source/udp_socket_manager_linux.cc rename to src/modules/udp_transport/source/udp_socket_manager_posix.cc index ba8f86c7bc..e913efbd22 100644 --- a/src/modules/udp_transport/source/udp_socket_manager_linux.cc +++ b/src/modules/udp_transport/source/udp_socket_manager_posix.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "udp_socket_manager_linux.h" +#include "udp_socket_manager_posix.h" #include #include @@ -17,10 +17,10 @@ #include #include "trace.h" -#include "udp_socket_linux.h" +#include "udp_socket_posix.h" namespace webrtc { -UdpSocketManagerLinux::UdpSocketManagerLinux(const WebRtc_Word32 id, +UdpSocketManagerPosix::UdpSocketManagerPosix(const WebRtc_Word32 id, WebRtc_UWord8& numOfWorkThreads) : UdpSocketManager(id, numOfWorkThreads), _id(id), @@ -36,18 +36,18 @@ UdpSocketManagerLinux::UdpSocketManagerLinux(const WebRtc_Word32 id, } for(int i = 0;i < _numberOfSocketMgr; i++) { - _socketMgr[i] = new UdpSocketManagerLinuxImpl(); + _socketMgr[i] = new UdpSocketManagerPosixImpl(); } WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::UdpSocketManagerLinux()", + "UdpSocketManagerPosix(%d)::UdpSocketManagerPosix()", _numberOfSocketMgr); } -UdpSocketManagerLinux::~UdpSocketManagerLinux() +UdpSocketManagerPosix::~UdpSocketManagerPosix() { WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::UdpSocketManagerLinux()", + "UdpSocketManagerPosix(%d)::UdpSocketManagerPosix()", _numberOfSocketMgr); for(int i = 0;i < _numberOfSocketMgr; i++) @@ -57,16 +57,16 @@ UdpSocketManagerLinux::~UdpSocketManagerLinux() delete _critSect; } -WebRtc_Word32 UdpSocketManagerLinux::ChangeUniqueId(const WebRtc_Word32 id) +WebRtc_Word32 UdpSocketManagerPosix::ChangeUniqueId(const WebRtc_Word32 id) { _id = id; return 0; } -bool UdpSocketManagerLinux::Start() +bool UdpSocketManagerPosix::Start() { WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::Start()", + "UdpSocketManagerPosix(%d)::Start()", _numberOfSocketMgr); _critSect->Enter(); @@ -81,17 +81,17 @@ bool UdpSocketManagerLinux::Start() kTraceError, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::Start() error starting socket managers", + "UdpSocketManagerPosix(%d)::Start() error starting socket managers", _numberOfSocketMgr); } _critSect->Leave(); return retVal; } -bool UdpSocketManagerLinux::Stop() +bool UdpSocketManagerPosix::Stop() { WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::Stop()",_numberOfSocketMgr); + "UdpSocketManagerPosix(%d)::Stop()",_numberOfSocketMgr); _critSect->Enter(); bool retVal = true; @@ -105,7 +105,7 @@ bool UdpSocketManagerLinux::Stop() kTraceError, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::Stop() there are still active socket\ + "UdpSocketManagerPosix(%d)::Stop() there are still active socket\ managers", _numberOfSocketMgr); } @@ -113,10 +113,10 @@ bool UdpSocketManagerLinux::Stop() return retVal; } -bool UdpSocketManagerLinux::AddSocket(UdpSocketWrapper* s) +bool UdpSocketManagerPosix::AddSocket(UdpSocketWrapper* s) { WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::AddSocket()",_numberOfSocketMgr); + "UdpSocketManagerPosix(%d)::AddSocket()",_numberOfSocketMgr); _critSect->Enter(); bool retVal = _socketMgr[_nextSocketMgrToAssign]->AddSocket(s); @@ -126,12 +126,12 @@ bool UdpSocketManagerLinux::AddSocket(UdpSocketWrapper* s) kTraceError, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::AddSocket() failed to add socket to\ + "UdpSocketManagerPosix(%d)::AddSocket() failed to add socket to\ manager", _numberOfSocketMgr); } - // Distribute sockets on UdpSocketManagerLinuxImpls in a round-robin + // Distribute sockets on UdpSocketManagerPosixImpls in a round-robin // fashion. if(_incSocketMgrNextTime == 0) { @@ -148,10 +148,10 @@ bool UdpSocketManagerLinux::AddSocket(UdpSocketWrapper* s) return retVal; } -bool UdpSocketManagerLinux::RemoveSocket(UdpSocketWrapper* s) +bool UdpSocketManagerPosix::RemoveSocket(UdpSocketWrapper* s) { WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::RemoveSocket()", + "UdpSocketManagerPosix(%d)::RemoveSocket()", _numberOfSocketMgr); _critSect->Enter(); @@ -166,7 +166,7 @@ bool UdpSocketManagerLinux::RemoveSocket(UdpSocketWrapper* s) kTraceError, kTraceTransport, _id, - "UdpSocketManagerLinux(%d)::RemoveSocket() failed to remove socket\ + "UdpSocketManagerPosix(%d)::RemoveSocket() failed to remove socket\ from manager", _numberOfSocketMgr); } @@ -175,18 +175,18 @@ bool UdpSocketManagerLinux::RemoveSocket(UdpSocketWrapper* s) } -UdpSocketManagerLinuxImpl::UdpSocketManagerLinuxImpl() +UdpSocketManagerPosixImpl::UdpSocketManagerPosixImpl() { _critSectList = CriticalSectionWrapper::CreateCriticalSection(); - _thread = ThreadWrapper::CreateThread(UdpSocketManagerLinuxImpl::Run, this, + _thread = ThreadWrapper::CreateThread(UdpSocketManagerPosixImpl::Run, this, kRealtimePriority, - "UdpSocketManagerLinuxImplThread"); + "UdpSocketManagerPosixImplThread"); FD_ZERO(&_readFds); WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, - "UdpSocketManagerLinux created"); + "UdpSocketManagerPosix created"); } -UdpSocketManagerLinuxImpl::~UdpSocketManagerLinuxImpl() +UdpSocketManagerPosixImpl::~UdpSocketManagerPosixImpl() { if(_thread != NULL) { @@ -202,7 +202,7 @@ UdpSocketManagerLinuxImpl::~UdpSocketManagerLinuxImpl() MapItem* item = _socketMap.First(); while(item) { - UdpSocketLinux* s = static_cast(item->GetItem()); + UdpSocketPosix* s = static_cast(item->GetItem()); _socketMap.Erase(item); item = _socketMap.First(); delete s; @@ -213,10 +213,10 @@ UdpSocketManagerLinuxImpl::~UdpSocketManagerLinuxImpl() } WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, - "UdpSocketManagerLinux deleted"); + "UdpSocketManagerPosix deleted"); } -bool UdpSocketManagerLinuxImpl::Start() +bool UdpSocketManagerPosixImpl::Start() { unsigned int id = 0; if (_thread == NULL) @@ -225,11 +225,11 @@ bool UdpSocketManagerLinuxImpl::Start() } WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, - "Start UdpSocketManagerLinux"); + "Start UdpSocketManagerPosix"); return _thread->Start(id); } -bool UdpSocketManagerLinuxImpl::Stop() +bool UdpSocketManagerPosixImpl::Stop() { if (_thread == NULL) { @@ -237,11 +237,11 @@ bool UdpSocketManagerLinuxImpl::Stop() } WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, - "Stop UdpSocketManagerLinux"); + "Stop UdpSocketManagerPosix"); return _thread->Stop(); } -bool UdpSocketManagerLinuxImpl::Process() +bool UdpSocketManagerPosixImpl::Process() { bool doSelect = false; // Timeout = 1 second. @@ -257,7 +257,7 @@ bool UdpSocketManagerLinuxImpl::Process() unsigned int maxFd = 0; for (it = _socketMap.First(); it != NULL; it=_socketMap.Next(it)) { - UdpSocketLinux* s = static_cast(it->GetItem()); + UdpSocketPosix* s = static_cast(it->GetItem()); doSelect = true; maxFd = maxFd > it->GetUnsignedId() ? maxFd : it->GetUnsignedId(); FD_SET(it->GetUnsignedId(), &_readFds); @@ -293,7 +293,7 @@ bool UdpSocketManagerLinuxImpl::Process() for (it = _socketMap.First(); it != NULL && num > 0; it = _socketMap.Next(it)) { - UdpSocketLinux* s = static_cast(it->GetItem()); + UdpSocketPosix* s = static_cast(it->GetItem()); if (FD_ISSET(it->GetUnsignedId(), &_readFds)) { s->HasIncoming(); @@ -303,16 +303,16 @@ bool UdpSocketManagerLinuxImpl::Process() return true; } -bool UdpSocketManagerLinuxImpl::Run(ThreadObj obj) +bool UdpSocketManagerPosixImpl::Run(ThreadObj obj) { - UdpSocketManagerLinuxImpl* mgr = - static_cast(obj); + UdpSocketManagerPosixImpl* mgr = + static_cast(obj); return mgr->Process(); } -bool UdpSocketManagerLinuxImpl::AddSocket(UdpSocketWrapper* s) +bool UdpSocketManagerPosixImpl::AddSocket(UdpSocketWrapper* s) { - UdpSocketLinux* sl = static_cast(s); + UdpSocketPosix* sl = static_cast(s); if(sl->GetFd() == INVALID_SOCKET || !(sl->GetFd() < FD_SETSIZE)) { return false; @@ -323,18 +323,18 @@ bool UdpSocketManagerLinuxImpl::AddSocket(UdpSocketWrapper* s) return true; } -bool UdpSocketManagerLinuxImpl::RemoveSocket(UdpSocketWrapper* s) +bool UdpSocketManagerPosixImpl::RemoveSocket(UdpSocketWrapper* s) { - // Put in remove list if this is the correct UdpSocketManagerLinuxImpl. + // Put in remove list if this is the correct UdpSocketManagerPosixImpl. _critSectList->Enter(); // If the socket is in the add list it's safe to remove and delete it. ListItem* addListItem = _addList.First(); while(addListItem) { - UdpSocketLinux* addSocket = (UdpSocketLinux*)addListItem->GetItem(); + UdpSocketPosix* addSocket = (UdpSocketPosix*)addListItem->GetItem(); unsigned int addFD = addSocket->GetFd(); - unsigned int removeFD = static_cast(s)->GetFd(); + unsigned int removeFD = static_cast(s)->GetFd(); if(removeFD == addFD) { _removeList.PushBack(removeFD); @@ -346,9 +346,9 @@ bool UdpSocketManagerLinuxImpl::RemoveSocket(UdpSocketWrapper* s) // Checking the socket map is safe since all Erase and Insert calls to this // map are also protected by _critSectList. - if(_socketMap.Find(static_cast(s)->GetFd()) != NULL) + if(_socketMap.Find(static_cast(s)->GetFd()) != NULL) { - _removeList.PushBack(static_cast(s)->GetFd()); + _removeList.PushBack(static_cast(s)->GetFd()); _critSectList->Leave(); return true; } @@ -356,13 +356,13 @@ bool UdpSocketManagerLinuxImpl::RemoveSocket(UdpSocketWrapper* s) return false; } -void UdpSocketManagerLinuxImpl::UpdateSocketMap() +void UdpSocketManagerPosixImpl::UpdateSocketMap() { // Remove items in remove list. _critSectList->Enter(); while(!_removeList.Empty()) { - UdpSocketLinux* deleteSocket = NULL; + UdpSocketPosix* deleteSocket = NULL; unsigned int removeFD = _removeList.First()->GetUnsignedItem(); // If the socket is in the add list it hasn't been added to the socket @@ -370,7 +370,7 @@ void UdpSocketManagerLinuxImpl::UpdateSocketMap() ListItem* addListItem = _addList.First(); while(addListItem) { - UdpSocketLinux* addSocket = (UdpSocketLinux*)addListItem->GetItem(); + UdpSocketPosix* addSocket = (UdpSocketPosix*)addListItem->GetItem(); unsigned int addFD = addSocket->GetFd(); if(removeFD == addFD) { @@ -385,8 +385,8 @@ void UdpSocketManagerLinuxImpl::UpdateSocketMap() MapItem* it = _socketMap.Find(removeFD); if(it != NULL) { - UdpSocketLinux* socket = - static_cast(it->GetItem()); + UdpSocketPosix* socket = + static_cast(it->GetItem()); if(socket) { deleteSocket = socket; @@ -404,8 +404,8 @@ void UdpSocketManagerLinuxImpl::UpdateSocketMap() // Add sockets from add list. while(!_addList.Empty()) { - UdpSocketLinux* s = - static_cast(_addList.First()->GetItem()); + UdpSocketPosix* s = + static_cast(_addList.First()->GetItem()); if(s) { _socketMap.Insert(s->GetFd(), s); diff --git a/src/modules/udp_transport/source/udp_socket_manager_linux.h b/src/modules/udp_transport/source/udp_socket_manager_posix.h similarity index 77% rename from src/modules/udp_transport/source/udp_socket_manager_linux.h rename to src/modules/udp_transport/source/udp_socket_manager_posix.h index 8cf6f5047a..11f2a4411b 100644 --- a/src/modules/udp_transport/source/udp_socket_manager_linux.h +++ b/src/modules/udp_transport/source/udp_socket_manager_posix.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_MANAGER_LINUX_H_ -#define WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_MANAGER_LINUX_H_ +#ifndef WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_MANAGER_POSIX_H_ +#define WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_MANAGER_POSIX_H_ #include #include @@ -24,14 +24,14 @@ #define MAX_NUMBER_OF_SOCKET_MANAGERS_LINUX 8 namespace webrtc { -class UdpSocketManagerLinuxImpl; +class UdpSocketManagerPosixImpl; -class UdpSocketManagerLinux : public UdpSocketManager +class UdpSocketManagerPosix : public UdpSocketManager { public: - UdpSocketManagerLinux(const WebRtc_Word32 id, + UdpSocketManagerPosix(const WebRtc_Word32 id, WebRtc_UWord8& numOfWorkThreads); - virtual ~UdpSocketManagerLinux(); + virtual ~UdpSocketManagerPosix(); virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); @@ -46,14 +46,14 @@ private: WebRtc_UWord8 _numberOfSocketMgr; WebRtc_UWord8 _incSocketMgrNextTime; WebRtc_UWord8 _nextSocketMgrToAssign; - UdpSocketManagerLinuxImpl* _socketMgr[MAX_NUMBER_OF_SOCKET_MANAGERS_LINUX]; + UdpSocketManagerPosixImpl* _socketMgr[MAX_NUMBER_OF_SOCKET_MANAGERS_LINUX]; }; -class UdpSocketManagerLinuxImpl +class UdpSocketManagerPosixImpl { public: - UdpSocketManagerLinuxImpl(); - virtual ~UdpSocketManagerLinuxImpl(); + UdpSocketManagerPosixImpl(); + virtual ~UdpSocketManagerPosixImpl(); virtual bool Start(); virtual bool Stop(); @@ -78,4 +78,4 @@ private: }; } // namespace webrtc -#endif // WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_MANAGER_LINUX_H_ +#endif // WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_MANAGER_POSIX_H_ diff --git a/src/modules/udp_transport/source/udp_socket_manager_wrapper.cc b/src/modules/udp_transport/source/udp_socket_manager_wrapper.cc index f42bca7758..4157a2ef95 100644 --- a/src/modules/udp_transport/source/udp_socket_manager_wrapper.cc +++ b/src/modules/udp_transport/source/udp_socket_manager_wrapper.cc @@ -17,7 +17,7 @@ #include "udp_socket_manager_windows.h" #include "udp_socket2_manager_windows.h" #else -#include "udp_socket_manager_linux.h" +#include "udp_socket_manager_posix.h" #endif #ifndef _WIN32 @@ -41,7 +41,7 @@ UdpSocketManager* UdpSocketManager::CreateSocketManager( new UdpSocketManagerWindows(id, numOfWorkThreads)); #endif #else - return new UdpSocketManagerLinux(id, numOfWorkThreads); + return new UdpSocketManagerPosix(id, numOfWorkThreads); #endif } diff --git a/src/modules/udp_transport/source/udp_socket_linux.cc b/src/modules/udp_transport/source/udp_socket_posix.cc similarity index 83% rename from src/modules/udp_transport/source/udp_socket_linux.cc rename to src/modules/udp_transport/source/udp_socket_posix.cc index a926d04b25..6308f9f4a8 100644 --- a/src/modules/udp_transport/source/udp_socket_linux.cc +++ b/src/modules/udp_transport/source/udp_socket_posix.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "udp_socket_linux.h" +#include "udp_socket_posix.h" #include #include @@ -24,11 +24,11 @@ #include "udp_socket_wrapper.h" namespace webrtc { -UdpSocketLinux::UdpSocketLinux(const WebRtc_Word32 id, UdpSocketManager* mgr, +UdpSocketPosix::UdpSocketPosix(const WebRtc_Word32 id, UdpSocketManager* mgr, bool ipV6Enable) { WEBRTC_TRACE(kTraceMemory, kTraceTransport, id, - "UdpSocketLinux::UdpSocketLinux()"); + "UdpSocketPosix::UdpSocketPosix()"); _wantsIncoming = false; _error = 0; @@ -60,7 +60,7 @@ UdpSocketLinux::UdpSocketLinux(const WebRtc_Word32 id, UdpSocketManager* mgr, fcntl(_socket,F_SETFD,FD_CLOEXEC); } -UdpSocketLinux::~UdpSocketLinux() +UdpSocketPosix::~UdpSocketPosix() { if(_socket != INVALID_SOCKET) { @@ -83,35 +83,35 @@ UdpSocketLinux::~UdpSocketLinux() } } -WebRtc_Word32 UdpSocketLinux::ChangeUniqueId(const WebRtc_Word32 id) +WebRtc_Word32 UdpSocketPosix::ChangeUniqueId(const WebRtc_Word32 id) { _id = id; return 0; } -bool UdpSocketLinux::SetCallback(CallbackObj obj, IncomingSocketCallback cb) +bool UdpSocketPosix::SetCallback(CallbackObj obj, IncomingSocketCallback cb) { _obj = obj; _incomingCb = cb; WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, - "UdpSocketLinux(%p)::SetCallback", this); + "UdpSocketPosix(%p)::SetCallback", this); if (_mgr->AddSocket(this)) { WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, - "UdpSocketLinux(%p)::SetCallback socket added to manager", + "UdpSocketPosix(%p)::SetCallback socket added to manager", this); return true; // socket is now ready for action } WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, - "UdpSocketLinux(%p)::SetCallback error adding me to mgr", + "UdpSocketPosix(%p)::SetCallback error adding me to mgr", this); return false; } -bool UdpSocketLinux::SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname, +bool UdpSocketPosix::SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname, const WebRtc_Word8* optval, WebRtc_Word32 optlen) { if(0 == setsockopt(_socket, level, optname, optval, optlen )) @@ -121,11 +121,11 @@ bool UdpSocketLinux::SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname, _error = errno; WEBRTC_TRACE(kTraceError, kTraceTransport, _id, - "UdpSocketLinux::SetSockopt(), error:%d", _error); + "UdpSocketPosix::SetSockopt(), error:%d", _error); return false; } -WebRtc_Word32 UdpSocketLinux::SetTOS(WebRtc_Word32 serviceType) +WebRtc_Word32 UdpSocketPosix::SetTOS(WebRtc_Word32 serviceType) { if (SetSockopt(IPPROTO_IP, IP_TOS ,(WebRtc_Word8*)&serviceType ,4) != 0) { @@ -134,7 +134,7 @@ WebRtc_Word32 UdpSocketLinux::SetTOS(WebRtc_Word32 serviceType) return 0; } -bool UdpSocketLinux::Bind(const SocketAddress& name) +bool UdpSocketPosix::Bind(const SocketAddress& name) { int size = sizeof(sockaddr); if (0 == bind(_socket, reinterpret_cast(&name),size)) @@ -143,11 +143,11 @@ bool UdpSocketLinux::Bind(const SocketAddress& name) } _error = errno; WEBRTC_TRACE(kTraceError, kTraceTransport, _id, - "UdpSocketLinux::Bind() error: %d",_error); + "UdpSocketPosix::Bind() error: %d",_error); return false; } -WebRtc_Word32 UdpSocketLinux::SendTo(const WebRtc_Word8* buf, WebRtc_Word32 len, +WebRtc_Word32 UdpSocketPosix::SendTo(const WebRtc_Word8* buf, WebRtc_Word32 len, const SocketAddress& to) { int size = sizeof(sockaddr); @@ -157,18 +157,18 @@ WebRtc_Word32 UdpSocketLinux::SendTo(const WebRtc_Word8* buf, WebRtc_Word32 len, { _error = errno; WEBRTC_TRACE(kTraceError, kTraceTransport, _id, - "UdpSocketLinux::SendTo() error: %d", _error); + "UdpSocketPosix::SendTo() error: %d", _error); } return retVal; } -bool UdpSocketLinux::ValidHandle() +bool UdpSocketPosix::ValidHandle() { return _socket != INVALID_SOCKET; } -void UdpSocketLinux::HasIncoming() +void UdpSocketPosix::HasIncoming() { char buf[2048]; int retval; @@ -209,7 +209,7 @@ void UdpSocketLinux::HasIncoming() } } -void UdpSocketLinux::CloseBlocking() +void UdpSocketPosix::CloseBlocking() { _cs->Enter(); _closeBlockingActive = true; @@ -229,7 +229,7 @@ void UdpSocketLinux::CloseBlocking() _cs->Leave(); } -void UdpSocketLinux::ReadyForDeletion() +void UdpSocketPosix::ReadyForDeletion() { _cs->Enter(); if(!_closeBlockingActive) @@ -248,7 +248,7 @@ void UdpSocketLinux::ReadyForDeletion() _cs->Leave(); } -bool UdpSocketLinux::CleanUp() +bool UdpSocketPosix::CleanUp() { _wantsIncoming = false; diff --git a/src/modules/udp_transport/source/udp_socket_linux.h b/src/modules/udp_transport/source/udp_socket_posix.h similarity index 87% rename from src/modules/udp_transport/source/udp_socket_linux.h rename to src/modules/udp_transport/source/udp_socket_posix.h index eeb72d7b76..ee76abb6fc 100644 --- a/src/modules/udp_transport/source/udp_socket_linux.h +++ b/src/modules/udp_transport/source/udp_socket_posix.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_LINUX_H_ -#define WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_LINUX_H_ +#ifndef WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_POSIX_H_ +#define WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_POSIX_H_ #include #include @@ -23,13 +23,13 @@ #define SOCKET_ERROR -1 namespace webrtc { -class UdpSocketLinux : public UdpSocketWrapper +class UdpSocketPosix : public UdpSocketWrapper { public: - UdpSocketLinux(const WebRtc_Word32 id, UdpSocketManager* mgr, + UdpSocketPosix(const WebRtc_Word32 id, UdpSocketManager* mgr, bool ipV6Enable = false); - virtual ~UdpSocketLinux(); + virtual ~UdpSocketPosix(); virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); @@ -68,7 +68,7 @@ public: bool WantsIncoming() {return _wantsIncoming;} void ReadyForDeletion(); private: - friend class UdpSocketManagerLinux; + friend class UdpSocketManagerPosix; WebRtc_Word32 _id; IncomingSocketCallback _incomingCb; @@ -88,4 +88,4 @@ private: }; } // namespace webrtc -#endif // WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_LINUX_H_ +#endif // WEBRTC_MODULES_UDP_TRANSPORT_SOURCE_UDP_SOCKET_POSIX_H_ diff --git a/src/modules/udp_transport/source/udp_socket_wrapper.cc b/src/modules/udp_transport/source/udp_socket_wrapper.cc index efe922a85e..180682be04 100644 --- a/src/modules/udp_transport/source/udp_socket_wrapper.cc +++ b/src/modules/udp_transport/source/udp_socket_wrapper.cc @@ -21,7 +21,7 @@ #include "udp_socket_windows.h" #include "udp_socket2_windows.h" #else - #include "udp_socket_linux.h" + #include "udp_socket_posix.h" #endif @@ -111,10 +111,10 @@ UdpSocketWrapper* UdpSocketWrapper::CreateSocket(const WebRtc_Word32 id, { _initiated = true; } - s = new UdpSocketLinux(id, mgr, ipV6Enable); + s = new UdpSocketPosix(id, mgr, ipV6Enable); if (s) { - UdpSocketLinux* sl = static_cast(s); + UdpSocketPosix* sl = static_cast(s); if (sl->GetFd() != INVALID_SOCKET && sl->GetFd() < FD_SETSIZE) { // ok diff --git a/src/modules/udp_transport/source/udp_transport.gyp b/src/modules/udp_transport/source/udp_transport.gyp index e193cad8fe..561f7a191e 100644 --- a/src/modules/udp_transport/source/udp_transport.gyp +++ b/src/modules/udp_transport/source/udp_transport.gyp @@ -33,11 +33,11 @@ 'udp_socket_wrapper.h', 'udp_socket_manager_wrapper.h', # PLATFORM SPECIFIC SOURCE FILES - Will be filtered below - # Linux/Mac - 'udp_socket_linux.cc', - 'udp_socket_linux.h', - 'udp_socket_manager_linux.cc', - 'udp_socket_manager_linux.h', + # Posix (Linux/Mac) + 'udp_socket_posix.cc', + 'udp_socket_posix.h', + 'udp_socket_manager_posix.cc', + 'udp_socket_manager_posix.h', # Windows 'udp_socket_manager_windows.cc', 'udp_socket_manager_windows.h', @@ -52,12 +52,12 @@ ], # source 'conditions': [ # DEFINE PLATFORM SPECIFIC SOURCE FILES - ['OS!="linux" and OS!="mac"', { + ['os_posix==0', { 'sources!': [ - 'udp_socket_linux.cc', - 'udp_socket_linux.h', - 'udp_socket_manager_linux.cc', - 'udp_socket_manager_linux.h', + 'udp_socket_posix.cc', + 'udp_socket_posix.h', + 'udp_socket_manager_posix.cc', + 'udp_socket_manager_posix.h', ], }], ['OS!="win"', { @@ -78,7 +78,7 @@ 'cflags': [ '-fno-strict-aliasing', ], - }], + }], ['OS=="mac"', { 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': '-fno-strict-aliasing', diff --git a/src/system_wrappers/source/Android.mk b/src/system_wrappers/source/Android.mk index 784421a224..1dbef6bc46 100644 --- a/src/system_wrappers/source/Android.mk +++ b/src/system_wrappers/source/Android.mk @@ -30,13 +30,13 @@ LOCAL_SRC_FILES := \ rw_lock.cc \ thread.cc \ trace_impl.cc \ - condition_variable_linux.cc \ + condition_variable_posix.cc \ cpu_linux.cc \ - critical_section_linux.cc \ - event_linux.cc \ - thread_linux.cc \ - trace_linux.cc \ - rw_lock_linux.cc + critical_section_posix.cc \ + event_posix.cc \ + thread_posix.cc \ + trace_posix.cc \ + rw_lock_posix.cc LOCAL_CFLAGS := \ $(MY_WEBRTC_COMMON_DEFS) diff --git a/src/system_wrappers/source/condition_variable.cc b/src/system_wrappers/source/condition_variable.cc index 7ca1b567e2..184a905337 100644 --- a/src/system_wrappers/source/condition_variable.cc +++ b/src/system_wrappers/source/condition_variable.cc @@ -15,12 +15,12 @@ #elif defined(WEBRTC_LINUX) #include #include "condition_variable_wrapper.h" - #include "condition_variable_linux.h" + #include "condition_variable_posix.h" #elif defined(WEBRTC_MAC) || defined(WEBRTC_MAC_INTEL) #include #include "condition_variable_wrapper.h" - #include "condition_variable_linux.h" - #endif + #include "condition_variable_posix.h" +#endif namespace webrtc { ConditionVariableWrapper* @@ -29,7 +29,7 @@ ConditionVariableWrapper::CreateConditionVariable() #if defined(_WIN32) return new ConditionVariableWindows; #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) || defined(WEBRTC_MAC_INTEL) - return ConditionVariableLinux::Create(); + return ConditionVariablePosix::Create(); #else return NULL; #endif diff --git a/src/system_wrappers/source/condition_variable_linux.cc b/src/system_wrappers/source/condition_variable_posix.cc similarity index 82% rename from src/system_wrappers/source/condition_variable_linux.cc rename to src/system_wrappers/source/condition_variable_posix.cc index 778c2cf715..48835abec1 100644 --- a/src/system_wrappers/source/condition_variable_linux.cc +++ b/src/system_wrappers/source/condition_variable_posix.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "condition_variable_linux.h" +#include "condition_variable_posix.h" #if defined(WEBRTC_LINUX) #include @@ -18,12 +18,12 @@ #include -#include "critical_section_linux.h" +#include "critical_section_posix.h" namespace webrtc { -ConditionVariableWrapper* ConditionVariableLinux::Create() +ConditionVariableWrapper* ConditionVariablePosix::Create() { - ConditionVariableLinux* ptr = new ConditionVariableLinux; + ConditionVariablePosix* ptr = new ConditionVariablePosix; if (!ptr) { return NULL; @@ -39,11 +39,11 @@ ConditionVariableWrapper* ConditionVariableLinux::Create() return ptr; } -ConditionVariableLinux::ConditionVariableLinux() +ConditionVariablePosix::ConditionVariablePosix() { } -int ConditionVariableLinux::Construct() +int ConditionVariablePosix::Construct() { int result = 0; #ifdef WEBRTC_CLOCK_TYPE_REALTIME @@ -74,21 +74,21 @@ int ConditionVariableLinux::Construct() return 0; } -ConditionVariableLinux::~ConditionVariableLinux() +ConditionVariablePosix::~ConditionVariablePosix() { pthread_cond_destroy(&_cond); } -void ConditionVariableLinux::SleepCS(CriticalSectionWrapper& critSect) +void ConditionVariablePosix::SleepCS(CriticalSectionWrapper& critSect) { - CriticalSectionLinux* cs = reinterpret_cast( + CriticalSectionPosix* cs = reinterpret_cast( &critSect); pthread_cond_wait(&_cond, &cs->_mutex); } bool -ConditionVariableLinux::SleepCS( +ConditionVariablePosix::SleepCS( CriticalSectionWrapper& critSect, unsigned long maxTimeInMS) { @@ -101,7 +101,7 @@ ConditionVariableLinux::SleepCS( const int NANOSECONDS_PER_SECOND = 1000000000; const int NANOSECONDS_PER_MILLISECOND = 1000000; - CriticalSectionLinux* cs = reinterpret_cast( + CriticalSectionPosix* cs = reinterpret_cast( &critSect); if (maxTimeInMS != INFINITE) @@ -139,12 +139,12 @@ ConditionVariableLinux::SleepCS( } } -void ConditionVariableLinux::Wake() +void ConditionVariablePosix::Wake() { pthread_cond_signal(&_cond); } -void ConditionVariableLinux::WakeAll() +void ConditionVariablePosix::WakeAll() { pthread_cond_broadcast(&_cond); } diff --git a/src/system_wrappers/source/condition_variable_linux.h b/src/system_wrappers/source/condition_variable_posix.h similarity index 72% rename from src/system_wrappers/source/condition_variable_linux.h rename to src/system_wrappers/source/condition_variable_posix.h index 0300c5b5af..c239a47f74 100644 --- a/src/system_wrappers/source/condition_variable_linux.h +++ b/src/system_wrappers/source/condition_variable_posix.h @@ -8,19 +8,19 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_LINUX_H_ -#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_LINUX_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_POSIX_H_ +#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_POSIX_H_ #include "condition_variable_wrapper.h" #include namespace webrtc { -class ConditionVariableLinux : public ConditionVariableWrapper +class ConditionVariablePosix : public ConditionVariableWrapper { public: static ConditionVariableWrapper* Create(); - ~ConditionVariableLinux(); + ~ConditionVariablePosix(); void SleepCS(CriticalSectionWrapper& critSect); bool SleepCS(CriticalSectionWrapper& critSect, unsigned long maxTimeInMS); @@ -28,7 +28,7 @@ public: void WakeAll(); private: - ConditionVariableLinux(); + ConditionVariablePosix(); int Construct(); private: @@ -36,4 +36,4 @@ private: }; } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_LINUX_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_POSIX_H_ diff --git a/src/system_wrappers/source/critical_section.cc b/src/system_wrappers/source/critical_section.cc index 213c352898..413f8896b3 100644 --- a/src/system_wrappers/source/critical_section.cc +++ b/src/system_wrappers/source/critical_section.cc @@ -12,7 +12,7 @@ #include #include "critical_section_windows.h" #else - #include "critical_section_linux.h" + #include "critical_section_posix.h" #endif namespace webrtc { @@ -21,7 +21,7 @@ CriticalSectionWrapper* CriticalSectionWrapper::CreateCriticalSection() #ifdef _WIN32 return new CriticalSectionWindows(); #else - return new CriticalSectionLinux(); + return new CriticalSectionPosix(); #endif } } // namespace webrtc diff --git a/src/system_wrappers/source/critical_section_linux.cc b/src/system_wrappers/source/critical_section_posix.cc similarity index 80% rename from src/system_wrappers/source/critical_section_linux.cc rename to src/system_wrappers/source/critical_section_posix.cc index 35e81aeac0..b499b9ffe2 100644 --- a/src/system_wrappers/source/critical_section_linux.cc +++ b/src/system_wrappers/source/critical_section_posix.cc @@ -8,10 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "critical_section_linux.h" +#include "critical_section_posix.h" namespace webrtc { -CriticalSectionLinux::CriticalSectionLinux() +CriticalSectionPosix::CriticalSectionPosix() { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); @@ -19,19 +19,19 @@ CriticalSectionLinux::CriticalSectionLinux() pthread_mutex_init(&_mutex, &attr); } -CriticalSectionLinux::~CriticalSectionLinux() +CriticalSectionPosix::~CriticalSectionPosix() { pthread_mutex_destroy(&_mutex); } void -CriticalSectionLinux::Enter() +CriticalSectionPosix::Enter() { pthread_mutex_lock(&_mutex); } void -CriticalSectionLinux::Leave() +CriticalSectionPosix::Leave() { pthread_mutex_unlock(&_mutex); } diff --git a/src/system_wrappers/source/critical_section_linux.h b/src/system_wrappers/source/critical_section_posix.h similarity index 63% rename from src/system_wrappers/source/critical_section_linux.h rename to src/system_wrappers/source/critical_section_posix.h index 5ada1cb47d..40b7dc9247 100644 --- a/src/system_wrappers/source/critical_section_linux.h +++ b/src/system_wrappers/source/critical_section_posix.h @@ -8,28 +8,28 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_LINUX_H_ -#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_LINUX_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ +#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ #include "critical_section_wrapper.h" #include namespace webrtc { -class CriticalSectionLinux : public CriticalSectionWrapper +class CriticalSectionPosix : public CriticalSectionWrapper { public: - CriticalSectionLinux(); + CriticalSectionPosix(); - virtual ~CriticalSectionLinux(); + virtual ~CriticalSectionPosix(); virtual void Enter(); virtual void Leave(); private: pthread_mutex_t _mutex; - friend class ConditionVariableLinux; + friend class ConditionVariablePosix; }; } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_LINUX_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ diff --git a/src/system_wrappers/source/event.cc b/src/system_wrappers/source/event.cc index 384b96142f..01286d868e 100644 --- a/src/system_wrappers/source/event.cc +++ b/src/system_wrappers/source/event.cc @@ -15,7 +15,7 @@ #include "event_windows.h" #else #include - #include "event_linux.h" + #include "event_posix.h" #endif namespace webrtc { @@ -24,7 +24,7 @@ EventWrapper* EventWrapper::Create() #if defined(_WIN32) return new EventWindows(); #else - return EventLinux::Create(); + return EventPosix::Create(); #endif } diff --git a/src/system_wrappers/source/event_linux.cc b/src/system_wrappers/source/event_posix.cc similarity index 90% rename from src/system_wrappers/source/event_linux.cc rename to src/system_wrappers/source/event_posix.cc index dddd31c15c..b77b9023c2 100644 --- a/src/system_wrappers/source/event_linux.cc +++ b/src/system_wrappers/source/event_posix.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "event_linux.h" +#include "event_posix.h" #include #include @@ -22,9 +22,9 @@ namespace webrtc { const long int E6 = 1000000; const long int E9 = 1000 * E6; -EventWrapper* EventLinux::Create() +EventWrapper* EventPosix::Create() { - EventLinux* ptr = new EventLinux; + EventPosix* ptr = new EventPosix; if (!ptr) { return NULL; @@ -40,7 +40,7 @@ EventWrapper* EventLinux::Create() } -EventLinux::EventLinux() +EventPosix::EventPosix() : _timerThread(0), _timerEvent(0), _periodic(false), @@ -50,7 +50,7 @@ EventLinux::EventLinux() { } -int EventLinux::Construct() +int EventPosix::Construct() { // Set start time to zero memset(&_tCreate, 0, sizeof(_tCreate)); @@ -92,14 +92,14 @@ int EventLinux::Construct() return 0; } -EventLinux::~EventLinux() +EventPosix::~EventPosix() { StopTimer(); pthread_cond_destroy(&cond); pthread_mutex_destroy(&mutex); } -bool EventLinux::Reset() +bool EventPosix::Reset() { if (0 != pthread_mutex_lock(&mutex)) { @@ -110,7 +110,7 @@ bool EventLinux::Reset() return true; } -bool EventLinux::Set() +bool EventPosix::Set() { if (0 != pthread_mutex_lock(&mutex)) { @@ -123,7 +123,7 @@ bool EventLinux::Set() return true; } -EventTypeWrapper EventLinux::Wait(unsigned long timeout) +EventTypeWrapper EventPosix::Wait(unsigned long timeout) { int retVal = 0; if (0 != pthread_mutex_lock(&mutex)) @@ -178,7 +178,7 @@ EventTypeWrapper EventLinux::Wait(unsigned long timeout) } } -EventTypeWrapper EventLinux::Wait(timespec& tPulse) +EventTypeWrapper EventPosix::Wait(timespec& tPulse) { int retVal = 0; if (0 != pthread_mutex_lock(&mutex)) @@ -205,7 +205,7 @@ EventTypeWrapper EventLinux::Wait(timespec& tPulse) } } -bool EventLinux::StartTimer(bool periodic, unsigned long time) +bool EventPosix::StartTimer(bool periodic, unsigned long time) { if (_timerThread) { @@ -223,7 +223,7 @@ bool EventLinux::StartTimer(bool periodic, unsigned long time) } // Start the timer thread - _timerEvent = static_cast(EventWrapper::Create()); + _timerEvent = static_cast(EventWrapper::Create()); const char* threadName = "WebRtc_event_timer_thread"; _timerThread = ThreadWrapper::CreateThread(Run, this, kRealtimePriority, threadName); @@ -237,12 +237,12 @@ bool EventLinux::StartTimer(bool periodic, unsigned long time) return false; } -bool EventLinux::Run(ThreadObj obj) +bool EventPosix::Run(ThreadObj obj) { - return static_cast(obj)->Process(); + return static_cast(obj)->Process(); } -bool EventLinux::Process() +bool EventPosix::Process() { if (_tCreate.tv_sec == 0) { @@ -290,7 +290,7 @@ bool EventLinux::Process() return true; } -bool EventLinux::StopTimer() +bool EventPosix::StopTimer() { if(_timerThread) { diff --git a/src/system_wrappers/source/event_linux.h b/src/system_wrappers/source/event_posix.h similarity index 81% rename from src/system_wrappers/source/event_linux.h rename to src/system_wrappers/source/event_posix.h index 17d193f2be..0e5893b399 100644 --- a/src/system_wrappers/source/event_linux.h +++ b/src/system_wrappers/source/event_posix.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_LINUX_H_ -#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_LINUX_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_POSIX_H_ +#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_POSIX_H_ #include "event_wrapper.h" @@ -25,12 +25,12 @@ enum State kDown = 2 }; -class EventLinux : public EventWrapper +class EventPosix : public EventWrapper { public: static EventWrapper* Create(); - virtual ~EventLinux(); + virtual ~EventPosix(); virtual EventTypeWrapper Wait(unsigned long maxTime); virtual bool Set(); @@ -40,7 +40,7 @@ public: virtual bool StopTimer(); private: - EventLinux(); + EventPosix(); int Construct(); static bool Run(ThreadObj obj); @@ -53,7 +53,7 @@ private: pthread_mutex_t mutex; ThreadWrapper* _timerThread; - EventLinux* _timerEvent; + EventPosix* _timerEvent; timespec _tCreate; bool _periodic; @@ -63,4 +63,4 @@ private: }; } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_LINUX_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_EVENT_POSIX_H_ diff --git a/src/system_wrappers/source/rw_lock.cc b/src/system_wrappers/source/rw_lock.cc index 922f73b7bd..156a992258 100644 --- a/src/system_wrappers/source/rw_lock.cc +++ b/src/system_wrappers/source/rw_lock.cc @@ -18,7 +18,7 @@ #include #include "rw_lock_generic.h" #else - #include "rw_lock_linux.h" + #include "rw_lock_posix.h" #endif namespace webrtc { @@ -29,7 +29,7 @@ RWLockWrapper* RWLockWrapper::CreateRWLock() #elif defined(WEBRTC_ANDROID) RWLockWrapper* lock = new RWLockWrapperGeneric(); #else - RWLockWrapper* lock = new RWLockLinux(); + RWLockWrapper* lock = new RWLockPosix(); #endif if(lock->Init() != 0) { diff --git a/src/system_wrappers/source/rw_lock_linux.cc b/src/system_wrappers/source/rw_lock_posix.cc similarity index 72% rename from src/system_wrappers/source/rw_lock_linux.cc rename to src/system_wrappers/source/rw_lock_posix.cc index 084dce8618..81a161e7f7 100644 --- a/src/system_wrappers/source/rw_lock_linux.cc +++ b/src/system_wrappers/source/rw_lock_posix.cc @@ -8,39 +8,39 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "rw_lock_linux.h" +#include "rw_lock_posix.h" namespace webrtc { -RWLockLinux::RWLockLinux() : _lock() +RWLockPosix::RWLockPosix() : _lock() { } -RWLockLinux::~RWLockLinux() +RWLockPosix::~RWLockPosix() { pthread_rwlock_destroy(&_lock); } -int RWLockLinux::Init() +int RWLockPosix::Init() { return pthread_rwlock_init(&_lock, 0); } -void RWLockLinux::AcquireLockExclusive() +void RWLockPosix::AcquireLockExclusive() { pthread_rwlock_wrlock(&_lock); } -void RWLockLinux::ReleaseLockExclusive() +void RWLockPosix::ReleaseLockExclusive() { pthread_rwlock_unlock(&_lock); } -void RWLockLinux::AcquireLockShared() +void RWLockPosix::AcquireLockShared() { pthread_rwlock_rdlock(&_lock); } -void RWLockLinux::ReleaseLockShared() +void RWLockPosix::ReleaseLockShared() { pthread_rwlock_unlock(&_lock); } diff --git a/src/system_wrappers/source/rw_lock_linux.h b/src/system_wrappers/source/rw_lock_posix.h similarity index 74% rename from src/system_wrappers/source/rw_lock_linux.h rename to src/system_wrappers/source/rw_lock_posix.h index 391ee8fe61..929bbb813d 100644 --- a/src/system_wrappers/source/rw_lock_linux.h +++ b/src/system_wrappers/source/rw_lock_posix.h @@ -8,19 +8,19 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_LINUX_H_ -#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_LINUX_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ +#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ #include "rw_lock_wrapper.h" #include namespace webrtc { -class RWLockLinux : public RWLockWrapper +class RWLockPosix : public RWLockWrapper { public: - RWLockLinux(); - virtual ~RWLockLinux(); + RWLockPosix(); + virtual ~RWLockPosix(); virtual void AcquireLockExclusive(); virtual void ReleaseLockExclusive(); @@ -36,4 +36,4 @@ private: }; } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_LINUX_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ diff --git a/src/system_wrappers/source/system_wrappers.gyp b/src/system_wrappers/source/system_wrappers.gyp index 0448941796..8a912f569b 100644 --- a/src/system_wrappers/source/system_wrappers.gyp +++ b/src/system_wrappers/source/system_wrappers.gyp @@ -43,7 +43,7 @@ 'atomic32_mac.h', 'atomic32_windows.h', 'condition_variable.cc', - 'condition_variable_linux.h', + 'condition_variable_posix.h', 'condition_variable_windows.h', 'cpu.cc', 'cpu_linux.h', @@ -51,37 +51,41 @@ 'cpu_windows.h', 'cpu_features.cc', 'critical_section.cc', - 'critical_section_linux.h', + 'critical_section_posix.h', 'critical_section_windows.h', 'event.cc', - 'event_linux.h', + 'event_posix.h', 'event_windows.h', 'file_impl.cc', 'file_impl.h', 'list_no_stl.cc', 'map.cc', 'rw_lock.cc', - 'rw_lock_linux.h', + 'rw_lock_posix.h', 'rw_lock_windows.h', 'sort.cc', 'thread.cc', - 'thread_linux.h', + 'thread_posix.h', 'thread_windows.h', 'trace_impl.cc', 'trace_impl.h', - 'trace_linux.h', + 'trace_posix.h', 'trace_windows.h', ], 'conditions': [ + ['os_posix==1', { + 'sources': [ + 'condition_variable_posix.cc', + 'critical_section_posix.cc', + 'event_posix.cc', + 'rw_lock_posix.cc', + 'thread_posix.cc', + 'trace_posix.cc', + ], + }], ['OS=="linux"', { 'sources': [ - 'condition_variable_linux.cc', 'cpu_linux.cc', - 'critical_section_linux.cc', - 'event_linux.cc', - 'thread_linux.cc', - 'trace_linux.cc', - 'rw_lock_linux.cc', ], 'link_settings': { 'libraries': [ @@ -91,32 +95,18 @@ }], ['OS=="mac"', { 'sources': [ - 'condition_variable_linux.cc', 'cpu_mac.cc', - 'critical_section_linux.cc', - 'event_linux.cc', - 'rw_lock_linux.cc', - 'thread_linux.cc', - 'trace_linux.cc', ], }], ['OS=="win"', { 'sources': [ - 'atomic32_windows.h', 'condition_variable_windows.cc', - 'condition_variable_windows.h', 'cpu_windows.cc', - 'cpu_windows.h', 'critical_section_windows.cc', - 'critical_section_windows.h', 'event_windows.cc', - 'event_windows.h', 'rw_lock_windows.cc', - 'rw_lock_windows.h', 'thread_windows.cc', - 'thread_windows.h', 'trace_windows.cc', - 'trace_windows.h', ], 'link_settings': { 'libraries': [ @@ -124,7 +114,7 @@ ], }, }], - ] # conditions + ] # conditions }, { 'target_name': 'system_wrappersTest', diff --git a/src/system_wrappers/source/thread.cc b/src/system_wrappers/source/thread.cc index a136cbaf11..ba7323d369 100644 --- a/src/system_wrappers/source/thread.cc +++ b/src/system_wrappers/source/thread.cc @@ -13,7 +13,7 @@ #if defined(_WIN32) #include "thread_windows.h" #else - #include "thread_linux.h" + #include "thread_posix.h" #endif namespace webrtc { @@ -24,7 +24,7 @@ ThreadWrapper* ThreadWrapper::CreateThread(ThreadRunFunction func, #if defined(_WIN32) return new ThreadWindows(func, obj, prio, threadName); #else - return ThreadLinux::Create(func, obj, prio, threadName); + return ThreadPosix::Create(func, obj, prio, threadName); #endif } } // namespace webrtc diff --git a/src/system_wrappers/source/thread_linux.cc b/src/system_wrappers/source/thread_posix.cc similarity index 91% rename from src/system_wrappers/source/thread_linux.cc rename to src/system_wrappers/source/thread_posix.cc index f871a1f35d..eb0e8f46a0 100644 --- a/src/system_wrappers/source/thread_linux.cc +++ b/src/system_wrappers/source/thread_posix.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "thread_linux.h" +#include "thread_posix.h" #include #include // strncpy @@ -30,7 +30,7 @@ extern "C" { static void* StartThread(void* lpParameter) { - static_cast(lpParameter)->Run(); + static_cast(lpParameter)->Run(); return 0; } } @@ -46,10 +46,10 @@ static pid_t gettid() } #endif -ThreadWrapper* ThreadLinux::Create(ThreadRunFunction func, ThreadObj obj, +ThreadWrapper* ThreadPosix::Create(ThreadRunFunction func, ThreadObj obj, ThreadPriority prio, const char* threadName) { - ThreadLinux* ptr = new ThreadLinux(func, obj, prio, threadName); + ThreadPosix* ptr = new ThreadPosix(func, obj, prio, threadName); if (!ptr) { return NULL; @@ -63,7 +63,7 @@ ThreadWrapper* ThreadLinux::Create(ThreadRunFunction func, ThreadObj obj, return ptr; } -ThreadLinux::ThreadLinux(ThreadRunFunction func, ThreadObj obj, +ThreadPosix::ThreadPosix(ThreadRunFunction func, ThreadObj obj, ThreadPriority prio, const char* threadName) : _runFunction(func), _obj(obj), @@ -83,7 +83,7 @@ ThreadLinux::ThreadLinux(ThreadRunFunction func, ThreadObj obj, } } -int ThreadLinux::Construct() +int ThreadPosix::Construct() { int result = 0; #if !defined(WEBRTC_ANDROID) @@ -108,7 +108,7 @@ int ThreadLinux::Construct() return 0; } -ThreadLinux::~ThreadLinux() +ThreadPosix::~ThreadPosix() { pthread_attr_destroy(&_attr); delete _event; @@ -118,9 +118,9 @@ ThreadLinux::~ThreadLinux() !defined(WEBRTC_MAC) && !defined(WEBRTC_MAC_INTEL) && \ !defined(MAC_DYLIB) && !defined(MAC_INTEL_DYLIB) #if HAS_THREAD_ID -bool ThreadLinux::Start(unsigned int& threadID) +bool ThreadPosix::Start(unsigned int& threadID) #else -bool ThreadLinux::Start(unsigned int& /*threadID*/) +bool ThreadPosix::Start(unsigned int& /*threadID*/) #endif { if (!_runFunction) @@ -192,7 +192,7 @@ bool ThreadLinux::Start(unsigned int& /*threadID*/) } #if (defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)) -bool ThreadLinux::SetAffinity(const int* processorNumbers, +bool ThreadPosix::SetAffinity(const int* processorNumbers, const unsigned int amountOfProcessors) { if (!processorNumbers || (amountOfProcessors == 0)) @@ -222,18 +222,18 @@ bool ThreadLinux::SetAffinity(const int* processorNumbers, // NOTE: On Mac OS X, use the Thread affinity API in // /usr/include/mach/thread_policy.h: thread_policy_set and mach_thread_self() // instead of Linux gettid() syscall. -bool ThreadLinux::SetAffinity(const int* , const unsigned int) +bool ThreadPosix::SetAffinity(const int* , const unsigned int) { return false; } #endif -void ThreadLinux::SetNotAlive() +void ThreadPosix::SetNotAlive() { _alive = false; } -bool ThreadLinux::Shutdown() +bool ThreadPosix::Shutdown() { #if !defined(WEBRTC_ANDROID) if (_thread && (0 != pthread_cancel(_thread))) @@ -247,7 +247,7 @@ bool ThreadLinux::Shutdown() #endif } -bool ThreadLinux::Stop() +bool ThreadPosix::Stop() { _alive = false; @@ -270,7 +270,7 @@ bool ThreadLinux::Stop() } } -void ThreadLinux::Run() +void ThreadPosix::Run() { _alive = true; _dead = false; diff --git a/src/system_wrappers/source/thread_linux.h b/src/system_wrappers/source/thread_posix.h similarity index 85% rename from src/system_wrappers/source/thread_linux.h rename to src/system_wrappers/source/thread_posix.h index 3e2b90806f..f664a52e70 100644 --- a/src/system_wrappers/source/thread_linux.h +++ b/src/system_wrappers/source/thread_posix.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_LINUX_H_ -#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_LINUX_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ +#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ #include "thread_wrapper.h" #include @@ -17,15 +17,15 @@ namespace webrtc { class EventWrapper; -class ThreadLinux : public ThreadWrapper +class ThreadPosix : public ThreadWrapper { public: static ThreadWrapper* Create(ThreadRunFunction func, ThreadObj obj, ThreadPriority prio, const char* threadName); - ThreadLinux(ThreadRunFunction func, ThreadObj obj, ThreadPriority prio, + ThreadPosix(ThreadRunFunction func, ThreadObj obj, ThreadPriority prio, const char* threadName); - ~ThreadLinux(); + ~ThreadPosix(); // From ThreadWrapper virtual void SetNotAlive(); @@ -66,4 +66,4 @@ private: }; } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_LINUX_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_THREAD_POSIX_H_ diff --git a/src/system_wrappers/source/trace_impl.cc b/src/system_wrappers/source/trace_impl.cc index 0a5f9db461..6a9fbab2e2 100644 --- a/src/system_wrappers/source/trace_impl.cc +++ b/src/system_wrappers/source/trace_impl.cc @@ -20,7 +20,7 @@ #include #include #include -#include "trace_linux.h" +#include "trace_posix.h" #endif // _WIN32 #define KEY_LEN_CHARS 31 @@ -199,7 +199,7 @@ Trace* TraceImpl::CreateTrace() #if defined(_WIN32) return new TraceWindows(); #else - return new TraceLinux(); + return new TracePosix(); #endif } diff --git a/src/system_wrappers/source/trace_linux.cc b/src/system_wrappers/source/trace_posix.cc similarity index 90% rename from src/system_wrappers/source/trace_linux.cc rename to src/system_wrappers/source/trace_posix.cc index cdc2138bdf..5fc60bf992 100644 --- a/src/system_wrappers/source/trace_linux.cc +++ b/src/system_wrappers/source/trace_posix.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "trace_linux.h" +#include "trace_posix.h" #include #include @@ -37,18 +37,18 @@ #define BUILDINFO BUILDDATE " " BUILDTIME " " BUILDMODE namespace webrtc { -TraceLinux::TraceLinux() +TracePosix::TracePosix() { _prevAPITickCount = time(NULL); _prevTickCount = _prevAPITickCount; } -TraceLinux::~TraceLinux() +TracePosix::~TracePosix() { StopThread(); } -WebRtc_Word32 TraceLinux::AddThreadId(char* traceMessage) const +WebRtc_Word32 TracePosix::AddThreadId(char* traceMessage) const { WebRtc_UWord64 threadId = (WebRtc_UWord64)pthread_self(); sprintf(traceMessage, "%10llu; ", threadId); @@ -56,7 +56,7 @@ WebRtc_Word32 TraceLinux::AddThreadId(char* traceMessage) const return 12; } -WebRtc_Word32 TraceLinux::AddTime(char* traceMessage, +WebRtc_Word32 TracePosix::AddTime(char* traceMessage, const TraceLevel level) const { time_t dwCurrentTimeInSeconds = time(NULL); @@ -109,14 +109,14 @@ WebRtc_Word32 TraceLinux::AddTime(char* traceMessage, return 22; } -WebRtc_Word32 TraceLinux::AddBuildInfo(char* traceMessage) const +WebRtc_Word32 TracePosix::AddBuildInfo(char* traceMessage) const { sprintf(traceMessage, "Build info: %s", BUILDINFO); // Include NULL termination (hence + 1). return strlen(traceMessage) + 1; } -WebRtc_Word32 TraceLinux::AddDateTimeInfo(char* traceMessage) const +WebRtc_Word32 TracePosix::AddDateTimeInfo(char* traceMessage) const { time_t t; time(&t); diff --git a/src/system_wrappers/source/trace_linux.h b/src/system_wrappers/source/trace_posix.h similarity index 80% rename from src/system_wrappers/source/trace_linux.h rename to src/system_wrappers/source/trace_posix.h index 6e327a0b72..099bcc874e 100644 --- a/src/system_wrappers/source/trace_linux.h +++ b/src/system_wrappers/source/trace_posix.h @@ -8,18 +8,18 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_LINUX_H_ -#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_LINUX_H_ +#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ +#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ #include "critical_section_wrapper.h" #include "trace_impl.h" namespace webrtc { -class TraceLinux : public TraceImpl +class TracePosix : public TraceImpl { public: - TraceLinux(); - virtual ~TraceLinux(); + TracePosix(); + virtual ~TracePosix(); virtual WebRtc_Word32 AddThreadId(char *traceMessage) const; virtual WebRtc_Word32 AddTime(char* traceMessage, @@ -34,4 +34,4 @@ private: }; } // namespace webrtc -#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_LINUX_H_ +#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_