Experimental HaikuOS Support (#1002)
This commit is contained in:
parent
30f06515fe
commit
6b0e38fc8f
|
@ -123,13 +123,13 @@ add_subdirectory(trantor)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC trantor)
|
target_link_libraries(${PROJECT_NAME} PUBLIC trantor)
|
||||||
|
|
||||||
if (NOT WIN32)
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
|
||||||
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
|
target_link_libraries(${PROJECT_NAME} PRIVATE network)
|
||||||
|
elseif (NOT WIN32 AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE dl)
|
target_link_libraries(${PROJECT_NAME} PRIVATE dl)
|
||||||
endif (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
|
elseif (WIN32)
|
||||||
else (NOT WIN32)
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE shlwapi)
|
target_link_libraries(${PROJECT_NAME} PRIVATE shlwapi)
|
||||||
endif (NOT WIN32)
|
endif ()
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/)
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ English | [简体中文](./README.zh-CN.md) | [繁體中文](./README.zh-TW.md)
|
||||||
### Overview
|
### Overview
|
||||||
**Drogon** is a C++14/17-based HTTP application framework. Drogon can be used to easily build various types of web application server programs using C++. **Drogon** is the name of a dragon in the American TV series "Game of Thrones" that I really like.
|
**Drogon** is a C++14/17-based HTTP application framework. Drogon can be used to easily build various types of web application server programs using C++. **Drogon** is the name of a dragon in the American TV series "Game of Thrones" that I really like.
|
||||||
|
|
||||||
Drogon is a cross-platform framework, It supports Linux, macOS, FreeBSD, OpenBSD, and Windows. Its main features are as follows:
|
Drogon is a cross-platform framework, It supports Linux, macOS, FreeBSD, OpenBSD, HaikuOS, and Windows. Its main features are as follows:
|
||||||
|
|
||||||
* Use a non-blocking I/O network lib based on epoll (kqueue under macOS/FreeBSD) to provide high-concurrency, high-performance network IO, please visit the [TFB Tests Results](https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=composite) for more details;
|
* Use a non-blocking I/O network lib based on epoll (kqueue under macOS/FreeBSD) to provide high-concurrency, high-performance network IO, please visit the [TFB Tests Results](https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=composite) for more details;
|
||||||
* Provide a completely asynchronous programming mode;
|
* Provide a completely asynchronous programming mode;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
**Drogon**是一个基于C++14/17的Http应用框架,使用Drogon可以方便的使用C++构建各种类型的Web应用服务端程序。
|
**Drogon**是一个基于C++14/17的Http应用框架,使用Drogon可以方便的使用C++构建各种类型的Web应用服务端程序。
|
||||||
本版本库是github上[Drogon工程](https://github.com/an-tao/drogon)的镜像库。**Drogon**是作者非常喜欢的美剧《权力的游戏》中的一条龙的名字(汉译作卓耿),和龙有关但并不是dragon的误写,为了不至于引起不必要的误会这里说明一下。
|
本版本库是github上[Drogon工程](https://github.com/an-tao/drogon)的镜像库。**Drogon**是作者非常喜欢的美剧《权力的游戏》中的一条龙的名字(汉译作卓耿),和龙有关但并不是dragon的误写,为了不至于引起不必要的误会这里说明一下。
|
||||||
|
|
||||||
Drogon是一个跨平台框架,它支持Linux,也支持macOS、FreeBSD,OpenBSD,和Windows。它的主要特点如下:
|
Drogon是一个跨平台框架,它支持Linux,也支持macOS、FreeBSD,OpenBSD,HaikuOS,和Windows。它的主要特点如下:
|
||||||
|
|
||||||
* 网络层使用基于epoll(macOS/FreeBSD下是kqueue)的非阻塞IO框架,提供高并发、高性能的网络IO。详细请见[TFB Tests Results](https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=composite);
|
* 网络层使用基于epoll(macOS/FreeBSD下是kqueue)的非阻塞IO框架,提供高并发、高性能的网络IO。详细请见[TFB Tests Results](https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=composite);
|
||||||
* 全异步编程模式;
|
* 全异步编程模式;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
**Drogon**是一個基於C++14/17的Http應用框架,使用Drogon可以方便的使用C++構建各種類型的Web App伺服器程式。
|
**Drogon**是一個基於C++14/17的Http應用框架,使用Drogon可以方便的使用C++構建各種類型的Web App伺服器程式。
|
||||||
本版本庫是github上[Drogon](https://github.com/an-tao/drogon)的鏡像庫。 **Drogon**是作者非常喜歡的美劇《冰與火之歌:權力遊戲》中的一條龍的名字(漢譯作卓耿),和龍有關但並不是dragon的誤寫,為了不至於引起不必要的誤會這裡說明一下。
|
本版本庫是github上[Drogon](https://github.com/an-tao/drogon)的鏡像庫。 **Drogon**是作者非常喜歡的美劇《冰與火之歌:權力遊戲》中的一條龍的名字(漢譯作卓耿),和龍有關但並不是dragon的誤寫,為了不至於引起不必要的誤會這裡說明一下。
|
||||||
|
|
||||||
Drogon是一個跨平台框架,它支援Linux,也支援macOS、FreeBSD/OpenBSD和Windows。它的主要特點如下:
|
Drogon是一個跨平台框架,它支援Linux,也支援macOS、FreeBSD/OpenBSD、HaikuOS和Windows。它的主要特點如下:
|
||||||
|
|
||||||
* 網路層使用基於epoll(macOS/FreeBSD下是kqueue)的非阻塞IO框架,提供高並發、高性能的網路IO。詳細請見[TFB Tests Results](https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=composite);
|
* 網路層使用基於epoll(macOS/FreeBSD下是kqueue)的非阻塞IO框架,提供高並發、高性能的網路IO。詳細請見[TFB Tests Results](https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=composite);
|
||||||
* 全異步程式設計;
|
* 全異步程式設計;
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
#include <drogon/plugins/AccessLogger.h>
|
#include <drogon/plugins/AccessLogger.h>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#ifndef _WIN32
|
#if !defined _WIN32 && !defined __HAIKU__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
#elif defined __HAIKU__
|
||||||
|
#include <unistd.h>
|
||||||
#else
|
#else
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#endif
|
#endif
|
||||||
|
@ -343,7 +345,7 @@ void AccessLogger::outputThreadNumber(trantor::LogStream &stream,
|
||||||
{
|
{
|
||||||
threadId_ = getthrid();
|
threadId_ = getthrid();
|
||||||
}
|
}
|
||||||
#elif defined _WIN32
|
#elif defined _WIN32 || defined __HAIKU__
|
||||||
if (threadId_ == 0)
|
if (threadId_ == 0)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
|
@ -107,7 +107,7 @@ void SharedLibManager::managerLibs()
|
||||||
void *oldHandle = nullptr;
|
void *oldHandle = nullptr;
|
||||||
if (dlMap_.find(filename) != dlMap_.end())
|
if (dlMap_.find(filename) != dlMap_.end())
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#if defined __linux__ || defined __HAIKU__
|
||||||
if (st.st_mtim.tv_sec >
|
if (st.st_mtim.tv_sec >
|
||||||
dlMap_[filename].mTime.tv_sec)
|
dlMap_[filename].mTime.tv_sec)
|
||||||
#elif defined _WIN32
|
#elif defined _WIN32
|
||||||
|
@ -168,7 +168,7 @@ void SharedLibManager::managerLibs()
|
||||||
dlStat.handle =
|
dlStat.handle =
|
||||||
compileAndLoadLib(srcFile, oldHandle);
|
compileAndLoadLib(srcFile, oldHandle);
|
||||||
}
|
}
|
||||||
#ifdef __linux__
|
#if defined __linux__ || defined __HAIKU__
|
||||||
dlStat.mTime = st.st_mtim;
|
dlStat.mTime = st.st_mtim;
|
||||||
#elif defined _WIN32
|
#elif defined _WIN32
|
||||||
dlStat.mTime.tv_sec = st.st_mtime;
|
dlStat.mTime.tv_sec = st.st_mtime;
|
||||||
|
@ -236,7 +236,7 @@ void *SharedLibManager::compileAndLoadLib(const std::string &sourceFile,
|
||||||
bool SharedLibManager::shouldCompileLib(const std::string &soFile,
|
bool SharedLibManager::shouldCompileLib(const std::string &soFile,
|
||||||
const struct stat &sourceStat)
|
const struct stat &sourceStat)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#if defined __linux__ || defined __HAIKU__
|
||||||
auto sourceModifiedTime = sourceStat.st_mtim.tv_sec;
|
auto sourceModifiedTime = sourceStat.st_mtim.tv_sec;
|
||||||
#elif defined _WIN32
|
#elif defined _WIN32
|
||||||
auto sourceModifiedTime = sourceStat.st_mtime;
|
auto sourceModifiedTime = sourceStat.st_mtime;
|
||||||
|
@ -251,7 +251,7 @@ bool SharedLibManager::shouldCompileLib(const std::string &soFile,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#if defined __linux__ || defined __HAIKU__
|
||||||
auto soModifiedTime = soStat.st_mtim.tv_sec;
|
auto soModifiedTime = soStat.st_mtim.tv_sec;
|
||||||
#elif defined _WIN32
|
#elif defined _WIN32
|
||||||
auto soModifiedTime = soStat.st_mtime;
|
auto soModifiedTime = soStat.st_mtime;
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
char *strptime(const char *s, const char *f, struct tm *tm)
|
char *strptime(const char *s, const char *f, struct tm *tm)
|
||||||
{
|
{
|
||||||
// std::get_time is defined such that its
|
// std::get_time is defined such that its
|
||||||
|
@ -79,6 +80,11 @@ time_t timegm(struct tm *tm)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
// HACK: Haiku has a timegm implementation. But it is not exposed
|
||||||
|
extern "C" time_t timegm(struct tm *tm);
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace drogon
|
namespace drogon
|
||||||
{
|
{
|
||||||
namespace utils
|
namespace utils
|
||||||
|
@ -1175,8 +1181,9 @@ static bool systemRandomBytes(void *ptr, size_t size)
|
||||||
return getentropy(ptr, size) != -1;
|
return getentropy(ptr, size) != -1;
|
||||||
#elif defined(_WIN32) // Windows
|
#elif defined(_WIN32) // Windows
|
||||||
return RtlGenRandom(ptr, size);
|
return RtlGenRandom(ptr, size);
|
||||||
#elif defined(__unix__) // fallback to /dev/urandom for other/old UNIX
|
#elif defined(__unix__) || defined(__HAIKU__)
|
||||||
static std::unique_ptr<FILE, std::function<void(FILE *)> > fptr(
|
// fallback to /dev/urandom for other/old UNIX
|
||||||
|
thread_local std::unique_ptr<FILE, std::function<void(FILE *)> > fptr(
|
||||||
fopen("/dev/urandom", "rb"), [](FILE *ptr) {
|
fopen("/dev/urandom", "rb"), [](FILE *ptr) {
|
||||||
if (ptr != nullptr)
|
if (ptr != nullptr)
|
||||||
fclose(ptr);
|
fclose(ptr);
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined __linux__ || defined __FreeBSD__ || defined __OpenBSD__ || \
|
#if defined __linux__ || defined __FreeBSD__ || defined __OpenBSD__ || \
|
||||||
defined __MINGW32__
|
defined __MINGW32__ || defined __HAIKU__
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <endian.h> // __BYTE_ORDER __LITTLE_ENDIAN
|
#include <endian.h> // __BYTE_ORDER __LITTLE_ENDIAN
|
||||||
|
|
Loading…
Reference in New Issue