Skip to content

Commit

Permalink
Interim.
Browse files Browse the repository at this point in the history
  • Loading branch information
gvansickle committed Oct 22, 2016
1 parent dc674aa commit 8b5ddb0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ PKG_CHECK_MODULES([PCRE], [libpcre >= 8.21],
],
[AC_MSG_WARN([Unable to find libpcre: $PCRE_PKG_ERRORS])])

PKG_CHECK_MODULES([PCRE2], [libpcre2-8 >= 10.0],
PKG_CHECK_MODULES([PCRE2], [libpcre2-8 >= 10.20],
[
# Found it. Remember to add $PCRE2_LIBS, $PCRE2_CFLAGS, and $PCRE2_CPPFLAGS to the appropriate automake vars.
AC_SUBST([HAVE_LIBPCRE2], [yes])
Expand Down
4 changes: 2 additions & 2 deletions src/Globber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void Globber::RunSubdirScan(sync_queue<std::string> &dir_queue, int thread_index
if(ftsent->fts_level == FTS_ROOTLEVEL)
{
// We're doing the directory traversal multithreaded, so we have to detect cycles ourselves.
if(HasDirBeenVisited(dev_ino_pair(ftsent->fts_dev, ftsent->fts_ino).m_val))
if(HasDirBeenVisited(dev_ino_pair(ftsent->fts_dev, ftsent->fts_ino)))
{
// Found cycle.
WARN() << "\'" << ftsent->fts_path << "\': recursive directory loop";
Expand All @@ -327,7 +327,7 @@ void Globber::RunSubdirScan(sync_queue<std::string> &dir_queue, int thread_index
if(num_dirs_found_this_loop == 0)
{
// We're doing the directory traversal multithreaded, so we have to detect cycles ourselves.
if(HasDirBeenVisited(dev_ino_pair(ftsent->fts_dev, ftsent->fts_ino).m_val))
if(HasDirBeenVisited(dev_ino_pair(ftsent->fts_dev, ftsent->fts_ino)))
{
// Found cycle.
WARN() << "\'" << ftsent->fts_path << "\': recursive directory loop";
Expand Down
4 changes: 2 additions & 2 deletions src/Globber.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class Globber
sync_queue<FileID>& m_out_queue;

std::mutex m_dir_mutex;
std::set<dev_ino_pair_type> m_dir_has_been_visited;
bool HasDirBeenVisited(dev_ino_pair_type di) { std::unique_lock<std::mutex> lock(m_dir_mutex); return !m_dir_has_been_visited.insert(di).second; };
std::set<dev_ino_pair> m_dir_has_been_visited;
bool HasDirBeenVisited(dev_ino_pair di) { std::unique_lock<std::mutex> lock(m_dir_mutex); return !m_dir_has_been_visited.insert(di).second; };

DirectoryTraversalStats m_traversal_stats;
};
Expand Down
11 changes: 10 additions & 1 deletion src/libext/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <string.h>
#include <cstdlib> // For free().
#include <string>
#include <type_traits>

#include "integer.hpp"
#include "../Logger.h"
Expand Down Expand Up @@ -69,14 +70,22 @@ inline int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags)
#endif
/// @}

using dev_ino_pair_type = std::conditional<
sizeof(__int128) < (sizeof(dev_t)+sizeof(ino_t)),
/*static_assert(false, "uintmax_t not big enough.")*/ int,
uint_t<(sizeof(dev_t)+sizeof(ino_t))*8>::fast
>::type;

using dev_ino_pair_type = uint_t<(sizeof(dev_t)+sizeof(ino_t))*8>::fast;
///static_assert(sizeof(dev_ino_pair_type) != 128/8, "ERROR");

struct dev_ino_pair
{
dev_ino_pair() = default;
dev_ino_pair(dev_t d, ino_t i) noexcept { m_val = d, m_val <<= sizeof(ino_t)*8, m_val |= i; };

constexpr bool operator<(const dev_ino_pair& other) const { return m_val < other.m_val; };

private:
dev_ino_pair_type m_val { 0 };
};

Expand Down
1 change: 1 addition & 0 deletions src/libext/integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct uint_t
using fast = typename uint_t<NumBits+1>::fast;
};
template<> struct uint_t<128> { using fast = unsigned __int128; };
//template<> struct uint_t<128> { using fast = __m128i; }; ///< @todo Use something like this for platforms without a builtin 128-bit type.
template<> struct uint_t<64> { using fast = uint_fast64_t; };
template<> struct uint_t<32> { using fast = uint_fast32_t; };

Expand Down

0 comments on commit 8b5ddb0

Please sign in to comment.