From: Serge Petrenko <sergepetrenko@tarantool.org>
To: v.shpilevoy@tarantool.org, gorcunov@gmail.com, sergos@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH 1/2] util: move cmp_i64 from xlog.c to util.h
Date: Sun, 5 Jul 2020 00:55:48 +0300 [thread overview]
Message-ID: <f460603b1b812092252b4292e58237ad427c83ca.1593899478.git.sergepetrenko@tarantool.org> (raw)
In-Reply-To: <cover.1593899478.git.sergepetrenko@tarantool.org>
The comparator will be needed in other files too, e.g. box.cc
Prerequisite #4849
---
src/box/xlog.c | 10 +---------
src/trivia/util.h | 11 +++++++++++
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/box/xlog.c b/src/box/xlog.c
index b5b082a20..05f8c2e29 100644
--- a/src/box/xlog.c
+++ b/src/box/xlog.c
@@ -46,6 +46,7 @@
#include "xrow.h"
#include "iproto_constants.h"
#include "errinj.h"
+#include "trivia/util.h"
/*
* FALLOC_FL_KEEP_SIZE flag has existed since fallocate() was
@@ -475,15 +476,6 @@ xdir_open_cursor(struct xdir *dir, int64_t signature,
return 0;
}
-static int
-cmp_i64(const void *_a, const void *_b)
-{
- const int64_t *a = (const int64_t *) _a, *b = (const int64_t *) _b;
- if (*a == *b)
- return 0;
- return (*a > *b) ? 1 : -1;
-}
-
/**
* Scan (or rescan) a directory with snapshot or write ahead logs.
* Read all files matching a pattern from the directory -
diff --git a/src/trivia/util.h b/src/trivia/util.h
index 29c7f0194..b344af303 100644
--- a/src/trivia/util.h
+++ b/src/trivia/util.h
@@ -534,6 +534,17 @@ double_compare_int64(double lhs, int64_t rhs, int k)
return double_compare_nint64(lhs, rhs, k);
}
+/**
+ * Compare two operands as int64_t.
+ * Needed for qsort.
+ */
+static inline int
+cmp_i64(const void *_a, const void *_b)
+{
+ const int64_t *a = (const int64_t *) _a, *b = (const int64_t *) _b;
+ return COMPARE_RESULT(*a, *b);
+}
+
/**
* Put the current thread in sleep for the given number of
* seconds.
--
2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2020-07-04 21:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-04 21:55 [Tarantool-patches] [PATCH 0/2] introduce actions on leader election Serge Petrenko
2020-07-04 21:55 ` Serge Petrenko [this message]
2020-07-04 21:55 ` [Tarantool-patches] [PATCH 2/2] box: introduce a cfg handle to become syncro leader Serge Petrenko
2020-07-04 23:03 ` Vladislav Shpilevoy
2020-07-04 23:18 ` Vladislav Shpilevoy
2020-07-05 11:09 ` Serge Petrenko
2020-07-09 22:03 ` Leonid Vasiliev
2020-07-20 21:13 ` Vladislav Shpilevoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f460603b1b812092252b4292e58237ad427c83ca.1593899478.git.sergepetrenko@tarantool.org \
--to=sergepetrenko@tarantool.org \
--cc=gorcunov@gmail.com \
--cc=sergos@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 1/2] util: move cmp_i64 from xlog.c to util.h' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox