summaryrefslogtreecommitdiff
path: root/util/coding.h
diff options
context:
space:
mode:
authorPeter Dillinger <peterd@fb.com>2022-10-26 12:08:20 -0700
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>2022-10-26 12:08:20 -0700
commit7fff38b1fe6d3acde97b40b428835a57d0cf73fb (patch)
treec263a39841f3c2f5af6f9d5b73b2b8da739ce348 /util/coding.h
parent5f915b447ddcd68c9af424ca9bf4b247d85bcca8 (diff)
clang-format cache/ and util/ directories (#10867)
Summary: This is purely the result of running `clang-format -i` on files, except some files have been excluded for manual intervention in a separate PR Pull Request resolved: https://github.com/facebook/rocksdb/pull/10867 Test Plan: `make check`, `make check-headers`, `make format` Reviewed By: jay-zhuang Differential Revision: D40682086 Pulled By: pdillinger fbshipit-source-id: 8673d978553ab99b516da7fb63ba0b82523337f8
Diffstat (limited to 'util/coding.h')
-rw-r--r--util/coding.h32
1 files changed, 17 insertions, 15 deletions
diff --git a/util/coding.h b/util/coding.h
index 72f63bc6b..3168fd2fd 100644
--- a/util/coding.h
+++ b/util/coding.h
@@ -25,7 +25,7 @@
// Some processors does not allow unaligned access to memory
#if defined(__sparc)
- #define PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED
+#define PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED
#endif
namespace ROCKSDB_NAMESPACE {
@@ -82,8 +82,10 @@ inline int64_t zigzagToI64(uint64_t n) {
// in *v and return a pointer just past the parsed value, or return
// nullptr on error. These routines only look at bytes in the range
// [p..limit-1]
-extern const char* GetVarint32Ptr(const char* p,const char* limit, uint32_t* v);
-extern const char* GetVarint64Ptr(const char* p,const char* limit, uint64_t* v);
+extern const char* GetVarint32Ptr(const char* p, const char* limit,
+ uint32_t* v);
+extern const char* GetVarint64Ptr(const char* p, const char* limit,
+ uint64_t* v);
inline const char* GetVarsignedint64Ptr(const char* p, const char* limit,
int64_t* value) {
uint64_t u = 0;
@@ -102,11 +104,9 @@ extern char* EncodeVarint32(char* dst, uint32_t value);
extern char* EncodeVarint64(char* dst, uint64_t value);
// Internal routine for use by fallback path of GetVarint32Ptr
-extern const char* GetVarint32PtrFallback(const char* p,
- const char* limit,
+extern const char* GetVarint32PtrFallback(const char* p, const char* limit,
uint32_t* value);
-inline const char* GetVarint32Ptr(const char* p,
- const char* limit,
+inline const char* GetVarint32Ptr(const char* p, const char* limit,
uint32_t* value) {
if (p < limit) {
uint32_t result = *(reinterpret_cast<const unsigned char*>(p));
@@ -133,7 +133,7 @@ inline void PutFixed16(std::string* dst, uint16_t value) {
inline void PutFixed32(std::string* dst, uint32_t value) {
if (port::kLittleEndian) {
dst->append(const_cast<const char*>(reinterpret_cast<char*>(&value)),
- sizeof(value));
+ sizeof(value));
} else {
char buf[sizeof(value)];
EncodeFixed32(buf, value);
@@ -144,7 +144,7 @@ inline void PutFixed32(std::string* dst, uint32_t value) {
inline void PutFixed64(std::string* dst, uint64_t value) {
if (port::kLittleEndian) {
dst->append(const_cast<const char*>(reinterpret_cast<char*>(&value)),
- sizeof(value));
+ sizeof(value));
} else {
char buf[sizeof(value)];
EncodeFixed64(buf, value);
@@ -350,7 +350,7 @@ inline Slice GetSliceUntil(Slice* slice, char delimiter) {
return ret;
}
-template<class T>
+template <class T>
#ifdef ROCKSDB_UBSAN_RUN
#if defined(__clang__)
__attribute__((__no_sanitize__("alignment")))
@@ -358,16 +358,17 @@ __attribute__((__no_sanitize__("alignment")))
__attribute__((__no_sanitize_undefined__))
#endif
#endif
-inline void PutUnaligned(T *memory, const T &value) {
+inline void
+PutUnaligned(T* memory, const T& value) {
#if defined(PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED)
- char *nonAlignedMemory = reinterpret_cast<char*>(memory);
+ char* nonAlignedMemory = reinterpret_cast<char*>(memory);
memcpy(nonAlignedMemory, reinterpret_cast<const char*>(&value), sizeof(T));
#else
*memory = value;
#endif
}
-template<class T>
+template <class T>
#ifdef ROCKSDB_UBSAN_RUN
#if defined(__clang__)
__attribute__((__no_sanitize__("alignment")))
@@ -375,9 +376,10 @@ __attribute__((__no_sanitize__("alignment")))
__attribute__((__no_sanitize_undefined__))
#endif
#endif
-inline void GetUnaligned(const T *memory, T *value) {
+inline void
+GetUnaligned(const T* memory, T* value) {
#if defined(PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED)
- char *nonAlignedMemory = reinterpret_cast<char*>(value);
+ char* nonAlignedMemory = reinterpret_cast<char*>(value);
memcpy(nonAlignedMemory, reinterpret_cast<const char*>(memory), sizeof(T));
#else
*value = *memory;