Skip to content

Instantly share code, notes, and snippets.

@ohga
Created November 27, 2017 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohga/7696b3a1b46d25b980480710408567f8 to your computer and use it in GitHub Desktop.
Save ohga/7696b3a1b46d25b980480710408567f8 to your computer and use it in GitHub Desktop.
diff --git a/yomita/yomita/src/CMakeLists.txt b/yomita/yomita/src/CMakeLists.txt
index dcabe64..5be634a 100644
--- a/yomita/yomita/src/CMakeLists.txt
+++ b/yomita/yomita/src/CMakeLists.txt
@@ -8,11 +8,11 @@ if(NOT DEFINED target)
set(target "avx2")
endif()
if(target STREQUAL avx2)
- add_definitions("-DNDEBUG -DHAVE_BMI2 -DHAVE_SSE4 -mbmi2 -mavx2 -march=corei7-avx")
+ add_definitions("-DNDEBUG -DHAVE_BMI2 -DHAVE_SSE4 -mbmi2 -mavx2 -march=corei7-avx -fno-threadsafe-statics")
elseif(target STREQUAL sse42)
add_definitions("-DNDEBUG -DHAVE_SSE42 -msse4.2 -march=corei7")
elseif(target STREQUAL learn)
- add_definitions("-DHAVE_BMI2 -DLEARN -DHAVE_SSE4 -mbmi2 -mavx2 -march=corei7-avx")
+ add_definitions("-DHAVE_BMI2 -DLEARN -DHAVE_SSE4 -mbmi2 -mavx2 -march=corei7-avx -fno-threadsafe-statics")
elseif(target STREQUAL learn-sse42)
add_definitions("-DHAVE_SSE42 -DLEARN -mbmi2 -mavx2 -march=corei7-avx")
elseif(DEFINED target)
@@ -71,5 +71,5 @@ set(sources
usioption.cpp
)
add_executable(Yomita-by-clang ${sources})
-target_link_libraries(Yomita-by-clang stdc++fs pthread)
+target_link_libraries(Yomita-by-clang -static pthread)
diff --git a/yomita/yomita/src/common.cpp b/yomita/yomita/src/common.cpp
index 9f8f6d1..e01a504 100644
--- a/yomita/yomita/src/common.cpp
+++ b/yomita/yomita/src/common.cpp
@@ -30,7 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
#ifdef _MSC_VER
#include <windows.h>
-#endif
extern "C"
{
@@ -40,6 +39,7 @@ extern "C"
typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
}
#endif
+#endif
#include <vector>
#include <fstream>
diff --git a/yomita/yomita/src/usioption.cpp b/yomita/yomita/src/usioption.cpp
index c15d8ba..4858210 100644
--- a/yomita/yomita/src/usioption.cpp
+++ b/yomita/yomita/src/usioption.cpp
@@ -29,9 +29,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <filesystem>
#else
+
+#ifndef __MINGW64__ // とりあえず。。
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem ;
+#else
+#include <sys/types.h>
+#include <dirent.h>
+#include <sys/stat.h>
+
+#endif
+
#endif
@@ -46,6 +55,28 @@ std::vector<std::string> evalFiles()
{
std::vector<std::string> filenames;
+#ifdef __MINGW64__ // とりあえず。。
+ DIR *dir;
+ struct dirent *pp;
+
+ if ((dir = opendir(evalDir().c_str())) == NULL) {
+ filenames.push_back("none");
+ return filenames;
+ }
+ while ((pp = readdir(dir)) != NULL) {
+ struct stat ss;
+ if ((stat(pp->d_name, &ss)) != 0) {
+ continue;
+ }
+
+ if ((ss.st_mode & S_IFMT) == S_IFREG) {
+ filenames.push_back(path(evalDir(), pp->d_name));
+ }
+ }
+ closedir(dir);
+
+#else
+
#ifdef _MSC_VER
for (std::tr2::sys::directory_iterator it(evalDir());
it != std::tr2::sys::directory_iterator(); ++it)
@@ -67,6 +98,7 @@ std::vector<std::string> evalFiles()
#endif
filenames.push_back(path(evalDir(), target.filename().string()));
}
+#endif
if (filenames.empty())
filenames.push_back("none");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment