add illumos support (#1501)

This commit is contained in:
Joshua M. Clulow 2021-04-29 06:40:08 -07:00 committed by GitHub
parent 75e593fd51
commit ed291840d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 4 deletions

View File

@ -5,6 +5,8 @@ function(td_set_up_compiler)
set(CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE)
include(illumos)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(GCC 1)
set(GCC 1 PARENT_SCOPE)
@ -58,7 +60,9 @@ function(td_set_up_compiler)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL")
if (NOT ILLUMOS)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL")
endif()
endif()
if (WIN32 OR CYGWIN)
@ -81,6 +85,12 @@ function(td_set_up_compiler)
add_definitions(-D_FILE_OFFSET_BITS=64)
endif()
if (ILLUMOS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lnsl -lsocket")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lnsl -lsocket")
add_definitions(-DTD_ILLUMOS=1)
endif()
include(AddCXXCompilerFlag)
if (NOT MSVC)
add_cxx_compiler_flag("-Wall")

11
CMake/illumos.cmake Normal file
View File

@ -0,0 +1,11 @@
if (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
#
# Determine if the host is running an illumos distribution:
#
execute_process(COMMAND /usr/bin/uname -o OUTPUT_VARIABLE UNAME_O
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (UNAME_O STREQUAL "illumos")
set(ILLUMOS 1)
endif()
endif()

View File

@ -26,6 +26,8 @@ if (POLICY CMP0060)
cmake_policy(SET CMP0060 NEW)
endif()
include(illumos)
include(PreventInSourceBuild)
prevent_in_source_build()

View File

@ -19,7 +19,7 @@ TDLib (Telegram Database library) is a cross-platform library for building [Tele
`TDLib` has many advantages. Notably `TDLib` is:
* **Cross-platform**: `TDLib` can be used on Android, iOS, Windows, macOS, Linux, FreeBSD, OpenBSD, NetBSD, Windows Phone, WebAssembly, watchOS, tvOS, Tizen, Cygwin. It should also work on other *nix systems with or without minimal effort.
* **Cross-platform**: `TDLib` can be used on Android, iOS, Windows, macOS, Linux, FreeBSD, OpenBSD, NetBSD, illumos, Windows Phone, WebAssembly, watchOS, tvOS, Tizen, Cygwin. It should also work on other *nix systems with or without minimal effort.
* **Multilanguage**: `TDLib` can be easily used with any programming language that is able to execute C functions. Additionally it already has native Java (using `JNI`) bindings and .NET (using `C++/CLI` and `C++/CX`) bindings.
* **Easy to use**: `TDLib` takes care of all network implementation details, encryption and local data storage.
* **High-performance**: in the [Telegram Bot API](https://core.telegram.org/bots/api), each `TDLib` instance handles more than 24000 active bots simultaneously.

View File

@ -17,7 +17,7 @@
#endif
#if defined(__linux__) || defined(__CYGWIN__)
#if defined(__linux__) || defined(__CYGWIN__) || defined(__sun)
# include <endian.h>

View File

@ -34,6 +34,9 @@
#elif TD_WINDOWS
#define TD_POLL_WINEVENT 1
#define TD_EVENTFD_WINDOWS 1
#elif TD_ILLUMOS
#define TD_POLL_EPOLL 1
#define TD_EVENTFD_LINUX 1
#else
#error "Poll's implementation is not defined"
#endif

View File

@ -53,6 +53,7 @@
#define TD_CYGWIN 1
#elif defined(__EMSCRIPTEN__)
#define TD_EMSCRIPTEN 1
#elif defined(TD_ILLUMOS)
#elif defined(__unix__) // all unices not caught above
#warning "Probably unsupported Unix platform. Feel free to try to compile"
#define TD_CYGWIN 1

View File

@ -194,7 +194,7 @@ Slice get_operating_system_version() {
}
#endif
utsname name;
struct utsname name;
int err = uname(&name);
if (err == 0) {
auto os_name = trim(PSTRING() << Slice(name.sysname, std::strlen(name.sysname)) << " "