diff options
author | Sadie Powell <sadie@witchery.services> | 2024-02-29 19:07:18 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-02-29 19:11:37 +0000 |
commit | 190c37a68b2de16ff173decbfba85bf4f0dd730d (patch) | |
tree | 5b36deb0047cbdebb21dbb5222c1f6b60f3f39a4 | |
parent | a67bef2deeeb010d5d7b8f6e898c76c36c33701a (diff) |
Rework some platform compatibility code.
-rw-r--r-- | include/sysconf.h.cmake | 4 | ||||
-rw-r--r-- | src/init.cpp | 3 | ||||
-rw-r--r-- | src/main.cpp | 5 | ||||
-rw-r--r-- | src/socketengines/select.cpp | 7 |
4 files changed, 7 insertions, 12 deletions
diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake index b8182cc58..8c1a35e72 100644 --- a/include/sysconf.h.cmake +++ b/include/sysconf.h.cmake @@ -29,10 +29,6 @@ #ifdef _WIN32 # define popen _popen # define pclose _pclose -# ifdef _MSC_VER -# define PATH_MAX MAX_PATH -# endif -# define sleep(x) Sleep(x * 1000) #endif #if defined __GNUC__ diff --git a/src/init.cpp b/src/init.cpp index be896ad63..4d8594a9d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -28,6 +28,7 @@ #include <pwd.h> #include <sys/types.h> #endif +#include <thread> Anope::string Anope::ConfigDir = "conf", Anope::DataDir = "data", Anope::ModuleDir = "lib", Anope::LocaleDir = "locale", Anope::LogDir = "logs"; @@ -513,7 +514,7 @@ bool Anope::Init(int ac, char **av) std::cerr << "WARNING: You are currently running Anope as the root superuser. Anope does not" << std::endl; std::cerr << " require root privileges to run, and it is discouraged that you run Anope" << std::endl; std::cerr << " as the root superuser." << std::endl; - sleep(3); + std::this_thread::sleep_for(std::chrono::seconds(3)); } } diff --git a/src/main.cpp b/src/main.cpp index 4fd433ce1..97099b234 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -84,13 +84,13 @@ void Anope::SaveDatabases() */ static Anope::string GetFullProgDir(const Anope::string &argv0) { - char buffer[PATH_MAX]; #ifdef _WIN32 /* Windows has specific API calls to get the EXE path that never fail. * For once, Windows has something of use, compared to the POSIX code * for this, this is positively neato. */ - if (GetModuleFileName(NULL, buffer, PATH_MAX)) + char buffer[MAX_PATH]; + if (GetModuleFileName(NULL, buffer, MAX_PATH)) { Anope::string fullpath = buffer; Anope::string::size_type n = fullpath.rfind("\\"); @@ -99,6 +99,7 @@ static Anope::string GetFullProgDir(const Anope::string &argv0) } #else // Get the current working directory + char buffer[PATH_MAX]; if (getcwd(buffer, PATH_MAX)) { Anope::string remainder = argv0; diff --git a/src/socketengines/select.cpp b/src/socketengines/select.cpp index 9a8582e5d..61ff54560 100644 --- a/src/socketengines/select.cpp +++ b/src/socketengines/select.cpp @@ -16,10 +16,7 @@ #include "logger.h" #include "config.h" -#ifdef _AIX -# undef FD_ZERO -# define FD_ZERO(p) memset((p), 0, sizeof(*(p))) -#endif /* _AIX */ +#include <thread> static int MaxFD; static unsigned FDCount; @@ -97,7 +94,7 @@ void SocketEngine::Process() */ if (FDCount == 0) { - sleep(tval.tv_sec); + std::this_thread::sleep_for(std::chrono::seconds(tval.tv_sec)); return; } #endif |