aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lfalloc/lf_allocX64.h
diff options
context:
space:
mode:
authorasorotsky <asorotsky@yandex-team.ru>2022-02-10 16:47:33 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:33 +0300
commiteb540cc7a103419462d0cc870ca403966e2194c6 (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/lfalloc/lf_allocX64.h
parent80f0a6b4102e3b2c89f23935c7690409033ea24c (diff)
downloadydb-eb540cc7a103419462d0cc870ca403966e2194c6.tar.gz
Restoring authorship annotation for <asorotsky@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/lfalloc/lf_allocX64.h')
-rw-r--r--library/cpp/lfalloc/lf_allocX64.h100
1 files changed, 50 insertions, 50 deletions
diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h
index 70f3758ebf..fd2a906d6f 100644
--- a/library/cpp/lfalloc/lf_allocX64.h
+++ b/library/cpp/lfalloc/lf_allocX64.h
@@ -1089,7 +1089,7 @@ struct TLocalPerTagAllocCounter {
};
static const int DBG_ALLOC_MAX_TAG = 1000;
-static const int DBG_ALLOC_ALIGNED_TAG = 0xF0000000;
+static const int DBG_ALLOC_ALIGNED_TAG = 0xF0000000;
static const int DBG_ALLOC_NUM_SIZES = 30;
static TPerTagAllocCounter GlobalPerTagAllocCounters[DBG_ALLOC_MAX_TAG][DBG_ALLOC_NUM_SIZES];
@@ -1307,25 +1307,25 @@ static void AllocThreadInfo() {
#if defined(LFALLOC_DBG)
struct TAllocHeader {
- uint64_t Size;
+ uint64_t Size;
int Tag;
int Cookie;
};
-// should be power of 2
-static_assert(sizeof(TAllocHeader) == 16);
-
+// should be power of 2
+static_assert(sizeof(TAllocHeader) == 16);
+
static inline void* GetAllocPtr(TAllocHeader* p) {
return p + 1;
}
static inline TAllocHeader* GetAllocHeader(void* p) {
- auto* header = ((TAllocHeader*)p) - 1;
- if (header->Tag == DBG_ALLOC_ALIGNED_TAG) {
- return (TAllocHeader*)header->Size;
- }
-
- return header;
+ auto* header = ((TAllocHeader*)p) - 1;
+ if (header->Tag == DBG_ALLOC_ALIGNED_TAG) {
+ return (TAllocHeader*)header->Size;
+ }
+
+ return header;
}
PERTHREAD int AllocationTag;
@@ -1882,45 +1882,45 @@ static Y_FORCE_INLINE int LFPosixMemalign(void** memptr, size_t alignment, size_
} else if (bigsize < 2 * alignment) {
bigsize = 2 * alignment;
}
-#if defined(LFALLOC_DBG)
- if (alignment > sizeof(TAllocHeader)) {
- bigsize += alignment;
- }
-#endif
-
+#if defined(LFALLOC_DBG)
+ if (alignment > sizeof(TAllocHeader)) {
+ bigsize += alignment;
+ }
+#endif
+
*memptr = LFAlloc(bigsize);
-
-#if defined(LFALLOC_DBG)
- if (alignment > sizeof(TAllocHeader)) {
- // memptr isn't aligned due to alloc header
- const auto* header = GetAllocHeader(*memptr);
- *memptr = (void*)((const char*) (*memptr) + alignment - sizeof(TAllocHeader));
-
- // make fake header to retrieve original header ptr on dealloc
- auto* next = GetAllocHeader(*memptr);
- next->Tag = DBG_ALLOC_ALIGNED_TAG;
- next->Size = (uint64_t)header;
- next->Cookie = 0;
- }
-#endif
-
- Y_ASSERT_NOBT((intptr_t)*memptr % alignment == 0);
+
+#if defined(LFALLOC_DBG)
+ if (alignment > sizeof(TAllocHeader)) {
+ // memptr isn't aligned due to alloc header
+ const auto* header = GetAllocHeader(*memptr);
+ *memptr = (void*)((const char*) (*memptr) + alignment - sizeof(TAllocHeader));
+
+ // make fake header to retrieve original header ptr on dealloc
+ auto* next = GetAllocHeader(*memptr);
+ next->Tag = DBG_ALLOC_ALIGNED_TAG;
+ next->Size = (uint64_t)header;
+ next->Cookie = 0;
+ }
+#endif
+
+ Y_ASSERT_NOBT((intptr_t)*memptr % alignment == 0);
return 0;
}
-
-static Y_FORCE_INLINE void* LFVAlloc(size_t size) {
- const size_t pg = N_PAGE_SIZE;
- void* p = nullptr;
-
-#if defined(LFALLOC_DBG)
- LFPosixMemalign(&p, pg, size);
-#else
- size_t bigsize = (size + pg - 1) & (~(pg - 1));
- p = LFAlloc(bigsize);
-#endif
-
- Y_ASSERT_NOBT((intptr_t)p % N_PAGE_SIZE == 0);
- return p;
-}
-
-#endif
+
+static Y_FORCE_INLINE void* LFVAlloc(size_t size) {
+ const size_t pg = N_PAGE_SIZE;
+ void* p = nullptr;
+
+#if defined(LFALLOC_DBG)
+ LFPosixMemalign(&p, pg, size);
+#else
+ size_t bigsize = (size + pg - 1) & (~(pg - 1));
+ p = LFAlloc(bigsize);
+#endif
+
+ Y_ASSERT_NOBT((intptr_t)p % N_PAGE_SIZE == 0);
+ return p;
+}
+
+#endif