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
This commit is contained in:
ajm@google.com 2011-08-01 17:04:04 +00:00
parent b29d940db7
commit b5c49ff8af
28 changed files with 249 additions and 259 deletions

View File

@ -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 :=

View File

@ -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 <strings.h>
#include <sys/time.h>
@ -17,10 +17,10 @@
#include <unistd.h>
#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<UdpSocketLinux*>(item->GetItem());
UdpSocketPosix* s = static_cast<UdpSocketPosix*>(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<UdpSocketLinux*>(it->GetItem());
UdpSocketPosix* s = static_cast<UdpSocketPosix*>(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<UdpSocketLinux*>(it->GetItem());
UdpSocketPosix* s = static_cast<UdpSocketPosix*>(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<UdpSocketManagerLinuxImpl*>(obj);
UdpSocketManagerPosixImpl* mgr =
static_cast<UdpSocketManagerPosixImpl*>(obj);
return mgr->Process();
}
bool UdpSocketManagerLinuxImpl::AddSocket(UdpSocketWrapper* s)
bool UdpSocketManagerPosixImpl::AddSocket(UdpSocketWrapper* s)
{
UdpSocketLinux* sl = static_cast<UdpSocketLinux*>(s);
UdpSocketPosix* sl = static_cast<UdpSocketPosix*>(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<UdpSocketLinux*>(s)->GetFd();
unsigned int removeFD = static_cast<UdpSocketPosix*>(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<UdpSocketLinux*>(s)->GetFd()) != NULL)
if(_socketMap.Find(static_cast<UdpSocketPosix*>(s)->GetFd()) != NULL)
{
_removeList.PushBack(static_cast<UdpSocketLinux*>(s)->GetFd());
_removeList.PushBack(static_cast<UdpSocketPosix*>(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<UdpSocketLinux*>(it->GetItem());
UdpSocketPosix* socket =
static_cast<UdpSocketPosix*>(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<UdpSocketLinux*>(_addList.First()->GetItem());
UdpSocketPosix* s =
static_cast<UdpSocketPosix*>(_addList.First()->GetItem());
if(s)
{
_socketMap.Insert(s->GetFd(), s);

View File

@ -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 <sys/types.h>
#include <unistd.h>
@ -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_

View File

@ -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
}

View File

@ -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 <errno.h>
#include <fcntl.h>
@ -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<const sockaddr*>(&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;

View File

@ -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 <arpa/inet.h>
#include <netinet/in.h>
@ -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_

View File

@ -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<UdpSocketLinux*>(s);
UdpSocketPosix* sl = static_cast<UdpSocketPosix*>(s);
if (sl->GetFd() != INVALID_SOCKET && sl->GetFd() < FD_SETSIZE)
{
// ok

View File

@ -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',

View File

@ -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)

View File

@ -15,12 +15,12 @@
#elif defined(WEBRTC_LINUX)
#include <pthread.h>
#include "condition_variable_wrapper.h"
#include "condition_variable_linux.h"
#include "condition_variable_posix.h"
#elif defined(WEBRTC_MAC) || defined(WEBRTC_MAC_INTEL)
#include <pthread.h>
#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

View File

@ -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 <ctime>
@ -18,12 +18,12 @@
#include <errno.h>
#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<CriticalSectionLinux*>(
CriticalSectionPosix* cs = reinterpret_cast<CriticalSectionPosix*>(
&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<CriticalSectionLinux*>(
CriticalSectionPosix* cs = reinterpret_cast<CriticalSectionPosix*>(
&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);
}

View File

@ -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 <pthread.h>
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_

View File

@ -12,7 +12,7 @@
#include <windows.h>
#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

View File

@ -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);
}

View File

@ -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 <pthread.h>
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_

View File

@ -15,7 +15,7 @@
#include "event_windows.h"
#else
#include <pthread.h>
#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
}

View File

@ -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 <errno.h>
#include <pthread.h>
@ -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<EventLinux*>(EventWrapper::Create());
_timerEvent = static_cast<EventPosix*>(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<EventLinux*>(obj)->Process();
return static_cast<EventPosix*>(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)
{

View File

@ -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_

View File

@ -18,7 +18,7 @@
#include <stdlib.h>
#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)
{

View File

@ -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);
}

View File

@ -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 <pthread.h>
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_

View File

@ -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',

View File

@ -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

View File

@ -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 <errno.h>
#include <string.h> // strncpy
@ -30,7 +30,7 @@ extern "C"
{
static void* StartThread(void* lpParameter)
{
static_cast<ThreadLinux*>(lpParameter)->Run();
static_cast<ThreadPosix*>(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;

View File

@ -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 <pthread.h>
@ -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_

View File

@ -20,7 +20,7 @@
#include <stdio.h>
#include <time.h>
#include <stdarg.h>
#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
}

View File

@ -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 <cassert>
#include <stdarg.h>
@ -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);

View File

@ -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_