Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
NIANIANKNIA committed Aug 5, 2023
2 parents 4cff11f + 2b4d37e commit eef2332
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
14 changes: 10 additions & 4 deletions NIAHttpBOT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ set(CMAKE_BUILD_TYPE Release)

project(${PROJECT})

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(AVX2_FLAG /arch:AVX2)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(AVX2_FLAG -mavx2)
endif()

check_cxx_compiler_flag("/arch:AVX2" COMPILER_SUPPORTS_AVX2)
if(COMPILER_SUPPORTS_AVX2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
check_cxx_compiler_flag("${AVX2_FLAG}" SUPPORTS_AVX2)
if(SUPPORTS_AVX2)
message("use AVX2 (\"${AVX2_FLAG}\")")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AVX2_FLAG}")
endif()

aux_source_directory(./src/ SOURCE)
Expand Down
7 changes: 6 additions & 1 deletion NIAHttpBOT/src/CFG_Parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ class parser{
match = _mm256_cmpeq_epi8(chunk, tars);
int mask = _mm256_movemask_epi8(match);
while (mask != 0) {
int index = _tzcnt_u32(mask); //__builtin_ctz(mask);
int index =
#ifdef WIN32
_tzcnt_u32(mask);
#else
__builtin_ctz(mask);
#endif
ret.push_back(i+(unsigned)index), mask &= ~(1<<index);
}
}
Expand Down
7 changes: 6 additions & 1 deletion NIAHttpBOT/src/I18Nize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ inline std::vector<int> findEqualSigns(const std::string& str, char tar='=') {
match = _mm256_cmpeq_epi8(chunk, tars);
int mask = _mm256_movemask_epi8(match);
while (mask != 0) {
int index = _tzcnt_u32(mask); //__builtin_ctz(mask);
int index =
#ifdef WIN32
_tzcnt_u32(mask);
#else
__builtin_ctz(mask);
#endif
ret.push_back(i+(unsigned)index), mask &= ~(1<<index);
}
}
Expand Down
9 changes: 8 additions & 1 deletion NIAHttpBOT/src/NIAHttpBOT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ bool UseCmd = false;
void GetTime() {
time_t timep; tm p;
char time_buffer[80];
time(&timep), localtime_s(&p, &timep);
time(&timep);
#ifdef WIN32
localtime_s(&p, &timep);
#else
localtime_r(&timep, &p);
#endif
strftime(time_buffer, sizeof(time_buffer), "[%Y/%m/%d %H:%M:%S] ", &p);
std::cout << "\x1b[35m" << time_buffer << "\x1b[0m";
}
Expand All @@ -49,7 +54,9 @@ int main() {


system("title NIAHttpBOT V1.3.2");
#ifdef WIN32
SetConsoleOutputCP(65001);
#endif
std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);

std::cout<<"\x1b[36m"<<R"(
Expand Down

0 comments on commit eef2332

Please sign in to comment.