aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/jemalloc/src/log.c
diff options
context:
space:
mode:
authorbugaevskiy <bugaevskiy@yandex-team.ru>2022-02-10 16:46:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:17 +0300
commita6e0145a095c7bb3770d6e07aee301de5c73f96e (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/jemalloc/src/log.c
parentc7f68570483e493f4ddaf946de7b3a420ee621b0 (diff)
downloadydb-a6e0145a095c7bb3770d6e07aee301de5c73f96e.tar.gz
Restoring authorship annotation for <bugaevskiy@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/jemalloc/src/log.c')
-rw-r--r--contrib/libs/jemalloc/src/log.c156
1 files changed, 78 insertions, 78 deletions
diff --git a/contrib/libs/jemalloc/src/log.c b/contrib/libs/jemalloc/src/log.c
index 36262b76fc..778902fb9b 100644
--- a/contrib/libs/jemalloc/src/log.c
+++ b/contrib/libs/jemalloc/src/log.c
@@ -1,78 +1,78 @@
-#include "jemalloc/internal/jemalloc_preamble.h"
-#include "jemalloc/internal/jemalloc_internal_includes.h"
-
-#include "jemalloc/internal/log.h"
-
-char log_var_names[JEMALLOC_LOG_VAR_BUFSIZE];
-atomic_b_t log_init_done = ATOMIC_INIT(false);
-
-/*
- * Returns true if we were able to pick out a segment. Fills in r_segment_end
- * with a pointer to the first character after the end of the string.
- */
-static const char *
-log_var_extract_segment(const char* segment_begin) {
- const char *end;
- for (end = segment_begin; *end != '\0' && *end != '|'; end++) {
- }
- return end;
-}
-
-static bool
-log_var_matches_segment(const char *segment_begin, const char *segment_end,
- const char *log_var_begin, const char *log_var_end) {
- assert(segment_begin <= segment_end);
- assert(log_var_begin < log_var_end);
-
- ptrdiff_t segment_len = segment_end - segment_begin;
- ptrdiff_t log_var_len = log_var_end - log_var_begin;
- /* The special '.' segment matches everything. */
- if (segment_len == 1 && *segment_begin == '.') {
- return true;
- }
- if (segment_len == log_var_len) {
- return strncmp(segment_begin, log_var_begin, segment_len) == 0;
- } else if (segment_len < log_var_len) {
- return strncmp(segment_begin, log_var_begin, segment_len) == 0
- && log_var_begin[segment_len] == '.';
- } else {
- return false;
- }
-}
-
-unsigned
-log_var_update_state(log_var_t *log_var) {
- const char *log_var_begin = log_var->name;
- const char *log_var_end = log_var->name + strlen(log_var->name);
-
- /* Pointer to one before the beginning of the current segment. */
- const char *segment_begin = log_var_names;
-
- /*
- * If log_init done is false, we haven't parsed the malloc conf yet. To
- * avoid log-spew, we default to not displaying anything.
- */
- if (!atomic_load_b(&log_init_done, ATOMIC_ACQUIRE)) {
- return LOG_INITIALIZED_NOT_ENABLED;
- }
-
- while (true) {
- const char *segment_end = log_var_extract_segment(
- segment_begin);
- assert(segment_end < log_var_names + JEMALLOC_LOG_VAR_BUFSIZE);
- if (log_var_matches_segment(segment_begin, segment_end,
- log_var_begin, log_var_end)) {
- atomic_store_u(&log_var->state, LOG_ENABLED,
- ATOMIC_RELAXED);
- return LOG_ENABLED;
- }
- if (*segment_end == '\0') {
- /* Hit the end of the segment string with no match. */
- atomic_store_u(&log_var->state,
- LOG_INITIALIZED_NOT_ENABLED, ATOMIC_RELAXED);
- return LOG_INITIALIZED_NOT_ENABLED;
- }
- /* Otherwise, skip the delimiter and continue. */
- segment_begin = segment_end + 1;
- }
-}
+#include "jemalloc/internal/jemalloc_preamble.h"
+#include "jemalloc/internal/jemalloc_internal_includes.h"
+
+#include "jemalloc/internal/log.h"
+
+char log_var_names[JEMALLOC_LOG_VAR_BUFSIZE];
+atomic_b_t log_init_done = ATOMIC_INIT(false);
+
+/*
+ * Returns true if we were able to pick out a segment. Fills in r_segment_end
+ * with a pointer to the first character after the end of the string.
+ */
+static const char *
+log_var_extract_segment(const char* segment_begin) {
+ const char *end;
+ for (end = segment_begin; *end != '\0' && *end != '|'; end++) {
+ }
+ return end;
+}
+
+static bool
+log_var_matches_segment(const char *segment_begin, const char *segment_end,
+ const char *log_var_begin, const char *log_var_end) {
+ assert(segment_begin <= segment_end);
+ assert(log_var_begin < log_var_end);
+
+ ptrdiff_t segment_len = segment_end - segment_begin;
+ ptrdiff_t log_var_len = log_var_end - log_var_begin;
+ /* The special '.' segment matches everything. */
+ if (segment_len == 1 && *segment_begin == '.') {
+ return true;
+ }
+ if (segment_len == log_var_len) {
+ return strncmp(segment_begin, log_var_begin, segment_len) == 0;
+ } else if (segment_len < log_var_len) {
+ return strncmp(segment_begin, log_var_begin, segment_len) == 0
+ && log_var_begin[segment_len] == '.';
+ } else {
+ return false;
+ }
+}
+
+unsigned
+log_var_update_state(log_var_t *log_var) {
+ const char *log_var_begin = log_var->name;
+ const char *log_var_end = log_var->name + strlen(log_var->name);
+
+ /* Pointer to one before the beginning of the current segment. */
+ const char *segment_begin = log_var_names;
+
+ /*
+ * If log_init done is false, we haven't parsed the malloc conf yet. To
+ * avoid log-spew, we default to not displaying anything.
+ */
+ if (!atomic_load_b(&log_init_done, ATOMIC_ACQUIRE)) {
+ return LOG_INITIALIZED_NOT_ENABLED;
+ }
+
+ while (true) {
+ const char *segment_end = log_var_extract_segment(
+ segment_begin);
+ assert(segment_end < log_var_names + JEMALLOC_LOG_VAR_BUFSIZE);
+ if (log_var_matches_segment(segment_begin, segment_end,
+ log_var_begin, log_var_end)) {
+ atomic_store_u(&log_var->state, LOG_ENABLED,
+ ATOMIC_RELAXED);
+ return LOG_ENABLED;
+ }
+ if (*segment_end == '\0') {
+ /* Hit the end of the segment string with no match. */
+ atomic_store_u(&log_var->state,
+ LOG_INITIALIZED_NOT_ENABLED, ATOMIC_RELAXED);
+ return LOG_INITIALIZED_NOT_ENABLED;
+ }
+ /* Otherwise, skip the delimiter and continue. */
+ segment_begin = segment_end + 1;
+ }
+}