From 852bf452b695b36a2e270d84151958a3329566ca Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Wed, 9 Oct 2019 17:00:32 -0700 Subject: [PATCH] Freebsd (#117) * add file * CMake freebsd fix --- CMakeLists.txt | 4 +++- ixwebsocket/freebsd/IXSetThreadName_freebsd.cpp | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ixwebsocket/freebsd/IXSetThreadName_freebsd.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 19093ac6..03b3834d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,9 @@ if (APPLE) list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/apple/IXSetThreadName_apple.cpp) elseif (WIN32) list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/windows/IXSetThreadName_windows.cpp) -else() +elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/freebsd/IXSetThreadName_freebsd.cpp) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/linux/IXSetThreadName_linux.cpp) list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSelectInterruptEventFd.cpp) list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSelectInterruptEventFd.h) diff --git a/ixwebsocket/freebsd/IXSetThreadName_freebsd.cpp b/ixwebsocket/freebsd/IXSetThreadName_freebsd.cpp new file mode 100644 index 00000000..9047e2c0 --- /dev/null +++ b/ixwebsocket/freebsd/IXSetThreadName_freebsd.cpp @@ -0,0 +1,16 @@ +/* + * IXSetThreadName_freebsd.cpp + * Author: Benjamin Sergeant + * Copyright (c) 2019 Machine Zone, Inc. All rights reserved. + */ +#include "../IXSetThreadName.h" +#include +#include + +namespace ix +{ + void setThreadName(const std::string& name) + { + pthread_set_name_np(pthread_self(), name.substr(0, 15).c_str()); + } +} // namespace ix