aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/re2
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2023-02-16 12:30:27 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2023-02-16 12:30:27 +0300
commit2d466cb51cdcc7a2de1685144bc5c2a6794d825e (patch)
tree4734b1ddfd4208c004f5caa9f07cd04ea65a8f60 /contrib/libs/re2
parenta550b15e307f7b41ef2cca24df4a4fd80efdbbc6 (diff)
downloadydb-2d466cb51cdcc7a2de1685144bc5c2a6794d825e.tar.gz
Update contrib/libs/re2 to 2023-02-01
Diffstat (limited to 'contrib/libs/re2')
-rw-r--r--contrib/libs/re2/CMakeLists.darwin.txt1
-rw-r--r--contrib/libs/re2/CMakeLists.linux-aarch64.txt1
-rw-r--r--contrib/libs/re2/CMakeLists.linux.txt1
-rw-r--r--contrib/libs/re2/re2/bitmap256.cc44
-rw-r--r--contrib/libs/re2/re2/bitmap256.h31
-rw-r--r--contrib/libs/re2/util/mutex.h20
-rw-r--r--contrib/libs/re2/util/pcre.h2
7 files changed, 66 insertions, 34 deletions
diff --git a/contrib/libs/re2/CMakeLists.darwin.txt b/contrib/libs/re2/CMakeLists.darwin.txt
index 99a1b72429..c511f1b1ce 100644
--- a/contrib/libs/re2/CMakeLists.darwin.txt
+++ b/contrib/libs/re2/CMakeLists.darwin.txt
@@ -22,6 +22,7 @@ target_link_libraries(contrib-libs-re2 PUBLIC
yutil
)
target_sources(contrib-libs-re2 PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitstate.cc
${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/compile.cc
${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/dfa.cc
diff --git a/contrib/libs/re2/CMakeLists.linux-aarch64.txt b/contrib/libs/re2/CMakeLists.linux-aarch64.txt
index 6b24e0df4b..006e3d8ab5 100644
--- a/contrib/libs/re2/CMakeLists.linux-aarch64.txt
+++ b/contrib/libs/re2/CMakeLists.linux-aarch64.txt
@@ -23,6 +23,7 @@ target_link_libraries(contrib-libs-re2 PUBLIC
yutil
)
target_sources(contrib-libs-re2 PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitstate.cc
${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/compile.cc
${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/dfa.cc
diff --git a/contrib/libs/re2/CMakeLists.linux.txt b/contrib/libs/re2/CMakeLists.linux.txt
index 6b24e0df4b..006e3d8ab5 100644
--- a/contrib/libs/re2/CMakeLists.linux.txt
+++ b/contrib/libs/re2/CMakeLists.linux.txt
@@ -23,6 +23,7 @@ target_link_libraries(contrib-libs-re2 PUBLIC
yutil
)
target_sources(contrib-libs-re2 PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitstate.cc
${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/compile.cc
${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/dfa.cc
diff --git a/contrib/libs/re2/re2/bitmap256.cc b/contrib/libs/re2/re2/bitmap256.cc
new file mode 100644
index 0000000000..150990926f
--- /dev/null
+++ b/contrib/libs/re2/re2/bitmap256.cc
@@ -0,0 +1,44 @@
+// Copyright 2023 The RE2 Authors. All Rights Reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "re2/bitmap256.h"
+
+#include <stdint.h>
+
+#include "util/util.h"
+#include "util/logging.h"
+
+namespace re2 {
+
+int Bitmap256::FindNextSetBit(int c) const {
+ DCHECK_GE(c, 0);
+ DCHECK_LE(c, 255);
+
+ // Check the word that contains the bit. Mask out any lower bits.
+ int i = c / 64;
+ uint64_t word = words_[i] & (~uint64_t{0} << (c % 64));
+ if (word != 0)
+ return (i * 64) + FindLSBSet(word);
+
+ // Check any following words.
+ i++;
+ switch (i) {
+ case 1:
+ if (words_[1] != 0)
+ return (1 * 64) + FindLSBSet(words_[1]);
+ FALLTHROUGH_INTENDED;
+ case 2:
+ if (words_[2] != 0)
+ return (2 * 64) + FindLSBSet(words_[2]);
+ FALLTHROUGH_INTENDED;
+ case 3:
+ if (words_[3] != 0)
+ return (3 * 64) + FindLSBSet(words_[3]);
+ FALLTHROUGH_INTENDED;
+ default:
+ return -1;
+ }
+}
+
+} // namespace re2
diff --git a/contrib/libs/re2/re2/bitmap256.h b/contrib/libs/re2/re2/bitmap256.h
index 4899379e4d..293b31d85f 100644
--- a/contrib/libs/re2/re2/bitmap256.h
+++ b/contrib/libs/re2/re2/bitmap256.h
@@ -11,7 +11,6 @@
#include <stdint.h>
#include <string.h>
-#include "util/util.h"
#include "util/logging.h"
namespace re2 {
@@ -82,36 +81,6 @@ class Bitmap256 {
uint64_t words_[4];
};
-int Bitmap256::FindNextSetBit(int c) const {
- DCHECK_GE(c, 0);
- DCHECK_LE(c, 255);
-
- // Check the word that contains the bit. Mask out any lower bits.
- int i = c / 64;
- uint64_t word = words_[i] & (~uint64_t{0} << (c % 64));
- if (word != 0)
- return (i * 64) + FindLSBSet(word);
-
- // Check any following words.
- i++;
- switch (i) {
- case 1:
- if (words_[1] != 0)
- return (1 * 64) + FindLSBSet(words_[1]);
- FALLTHROUGH_INTENDED;
- case 2:
- if (words_[2] != 0)
- return (2 * 64) + FindLSBSet(words_[2]);
- FALLTHROUGH_INTENDED;
- case 3:
- if (words_[3] != 0)
- return (3 * 64) + FindLSBSet(words_[3]);
- FALLTHROUGH_INTENDED;
- default:
- return -1;
- }
-}
-
} // namespace re2
#endif // RE2_BITMAP256_H_
diff --git a/contrib/libs/re2/util/mutex.h b/contrib/libs/re2/util/mutex.h
index 4b6772ae22..57c573205d 100644
--- a/contrib/libs/re2/util/mutex.h
+++ b/contrib/libs/re2/util/mutex.h
@@ -10,6 +10,10 @@
* You should assume the locks are *not* re-entrant.
*/
+#ifdef RE2_NO_THREADS
+#include <assert.h>
+#define MUTEX_IS_LOCK_COUNTER
+#else
#ifdef _WIN32
// Requires Windows Vista or Windows Server 2008 at minimum.
#include <windows.h>
@@ -25,8 +29,11 @@
#define MUTEX_IS_PTHREAD_RWLOCK
#endif
#endif
+#endif
-#if defined(MUTEX_IS_WIN32_SRWLOCK)
+#if defined(MUTEX_IS_LOCK_COUNTER)
+typedef int MutexType;
+#elif defined(MUTEX_IS_WIN32_SRWLOCK)
typedef SRWLOCK MutexType;
#elif defined(MUTEX_IS_PTHREAD_RWLOCK)
#include <pthread.h>
@@ -64,7 +71,16 @@ class Mutex {
Mutex& operator=(const Mutex&) = delete;
};
-#if defined(MUTEX_IS_WIN32_SRWLOCK)
+#if defined(MUTEX_IS_LOCK_COUNTER)
+
+Mutex::Mutex() : mutex_(0) { }
+Mutex::~Mutex() { assert(mutex_ == 0); }
+void Mutex::Lock() { assert(--mutex_ == -1); }
+void Mutex::Unlock() { assert(mutex_++ == -1); }
+void Mutex::ReaderLock() { assert(++mutex_ > 0); }
+void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
+
+#elif defined(MUTEX_IS_WIN32_SRWLOCK)
Mutex::Mutex() : mutex_(SRWLOCK_INIT) { }
Mutex::~Mutex() { }
diff --git a/contrib/libs/re2/util/pcre.h b/contrib/libs/re2/util/pcre.h
index 896b0bdf89..f0a7180384 100644
--- a/contrib/libs/re2/util/pcre.h
+++ b/contrib/libs/re2/util/pcre.h
@@ -500,7 +500,7 @@ class PCRE {
bool report_errors_; // Silences error logging if false
int match_limit_; // Limit on execution resources
int stack_limit_; // Limit on stack resources (bytes)
- mutable int32_t hit_limit_; // Hit limit during execution (bool)
+ mutable int hit_limit_; // Hit limit during execution (bool)
PCRE(const PCRE&) = delete;
PCRE& operator=(const PCRE&) = delete;