summaryrefslogtreecommitdiff
path: root/sal/rtl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2017-07-22 22:07:41 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2017-07-22 22:47:03 +1000
commite29ee03d1aff5fd8ff2a2af01f49bc036e612f6e (patch)
treeaad8aaaf134678b0f3030e5436804bf71a228b9c /sal/rtl
parent2ee84fe096f9bfaf141a1cad57f1103be688c744 (diff)
rtl: remove comment cruft from alloc files
Change-Id: Ibac120af6879739091aacefef5c773649e222f85
Diffstat (limited to 'sal/rtl')
-rw-r--r--sal/rtl/alloc_arena.cxx353
-rw-r--r--sal/rtl/alloc_cache.cxx383
-rw-r--r--sal/rtl/alloc_cache.hxx38
-rw-r--r--sal/rtl/alloc_global.cxx71
-rw-r--r--sal/rtl/alloc_impl.hxx36
5 files changed, 250 insertions, 631 deletions
diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx
index a0b16d57ec83..0e4aed5e2a31 100644
--- a/sal/rtl/alloc_arena.cxx
+++ b/sal/rtl/alloc_arena.cxx
@@ -27,15 +27,9 @@
#include <string.h>
#include <stdio.h>
-/* ================================================================= *
- *
- * arena internals.
- *
- * ================================================================= */
-
-/** g_arena_list
- * @internal
- */
+/**
+ @internal
+*/
struct rtl_arena_list_st
{
rtl_memory_lock_type m_lock;
@@ -44,51 +38,40 @@ struct rtl_arena_list_st
static rtl_arena_list_st g_arena_list;
-/** gp_arena_arena
- * provided for arena_type allocations, and hash_table resizing.
- *
- * @internal
- */
+/**
+ provided for arena_type allocations, and hash_table resizing.
+
+ @internal
+*/
static rtl_arena_type * gp_arena_arena = nullptr;
-/** gp_machdep_arena
- *
- * Low level virtual memory (pseudo) arena
- * (platform dependent implementation)
- *
- * @internal
+/**
+ Low level virtual memory (pseudo) arena
+ (platform dependent implementation)
+
+ @internal
*/
static rtl_arena_type * gp_machdep_arena = nullptr;
-/** gp_default_arena
- */
rtl_arena_type * gp_default_arena = nullptr;
namespace
{
-void *
-SAL_CALL rtl_machdep_alloc (
+void * SAL_CALL rtl_machdep_alloc(
rtl_arena_type * pArena,
sal_Size * pSize
);
-void
-SAL_CALL rtl_machdep_free (
+void SAL_CALL rtl_machdep_free(
rtl_arena_type * pArena,
void * pAddr,
sal_Size nSize
);
-sal_Size
-rtl_machdep_pagesize();
-
-/* ================================================================= */
+sal_Size rtl_machdep_pagesize();
-/** rtl_arena_segment_constructor()
- */
-int
-rtl_arena_segment_constructor (void * obj)
+int rtl_arena_segment_constructor(void * obj)
{
rtl_arena_segment_type * segment = static_cast<rtl_arena_segment_type*>(obj);
@@ -98,10 +81,7 @@ rtl_arena_segment_constructor (void * obj)
return 1;
}
-/** rtl_arena_segment_destructor()
- */
-void
-rtl_arena_segment_destructor (void * obj)
+void rtl_arena_segment_destructor(void * obj)
{
rtl_arena_segment_type * segment = static_cast< rtl_arena_segment_type * >(
obj);
@@ -110,16 +90,10 @@ rtl_arena_segment_destructor (void * obj)
(void) segment; // avoid warnings
}
-/* ================================================================= */
-
-/** rtl_arena_segment_populate()
- *
- * @precond arena->m_lock acquired.
+/**
+ @precond arena->m_lock acquired.
*/
-bool
-rtl_arena_segment_populate (
- rtl_arena_type * arena
-)
+bool rtl_arena_segment_populate(rtl_arena_type * arena)
{
rtl_arena_segment_type *span;
sal_Size size = rtl_machdep_pagesize();
@@ -152,14 +126,12 @@ rtl_arena_segment_populate (
return (span != nullptr);
}
-/** rtl_arena_segment_get()
- *
- * @precond arena->m_lock acquired.
- * @precond (*ppSegment == 0)
- */
-inline void
-rtl_arena_segment_get (
- rtl_arena_type * arena,
+/**
+ @precond arena->m_lock acquired.
+ @precond (*ppSegment == 0)
+*/
+inline void rtl_arena_segment_get(
+ rtl_arena_type * arena,
rtl_arena_segment_type ** ppSegment
)
{
@@ -175,14 +147,12 @@ rtl_arena_segment_get (
}
}
-/** rtl_arena_segment_put()
- *
- * @precond arena->m_lock acquired.
- * @postcond (*ppSegment == 0)
+/**
+ @precond arena->m_lock acquired.
+ @postcond (*ppSegment == 0)
*/
-inline void
-rtl_arena_segment_put (
- rtl_arena_type * arena,
+inline void rtl_arena_segment_put(
+ rtl_arena_type * arena,
rtl_arena_segment_type ** ppSegment
)
{
@@ -205,13 +175,11 @@ rtl_arena_segment_put (
(*ppSegment) = nullptr;
}
-/** rtl_arena_freelist_insert()
- *
- * @precond arena->m_lock acquired.
- */
-inline void
-rtl_arena_freelist_insert (
- rtl_arena_type * arena,
+/**
+ @precond arena->m_lock acquired.
+*/
+inline void rtl_arena_freelist_insert (
+ rtl_arena_type * arena,
rtl_arena_segment_type * segment
)
{
@@ -224,13 +192,11 @@ rtl_arena_freelist_insert (
arena->m_freelist_bitmap |= head->m_size;
}
-/** rtl_arena_freelist_remove()
- *
- * @precond arena->m_lock acquired.
- */
-inline void
-rtl_arena_freelist_remove (
- rtl_arena_type * arena,
+/**
+ @precond arena->m_lock acquired.
+*/
+inline void rtl_arena_freelist_remove(
+ rtl_arena_type * arena,
rtl_arena_segment_type * segment
)
{
@@ -246,24 +212,18 @@ rtl_arena_freelist_remove (
QUEUE_REMOVE_NAMED(segment, f);
}
-/* ================================================================= */
-
-/** RTL_ARENA_HASH_INDEX()
- */
#define RTL_ARENA_HASH_INDEX_IMPL(a, s, q, m) \
((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m))
#define RTL_ARENA_HASH_INDEX(arena, addr) \
RTL_ARENA_HASH_INDEX_IMPL((addr), (arena)->m_hash_shift, (arena)->m_quantum_shift, ((arena)->m_hash_size - 1))
-/** rtl_arena_hash_rescale()
- *
- * @precond arena->m_lock released.
- */
-void
-rtl_arena_hash_rescale (
+/**
+ @precond arena->m_lock released.
+*/
+void rtl_arena_hash_rescale(
rtl_arena_type * arena,
- sal_Size new_size
+ sal_Size new_size
)
{
assert(new_size != 0);
@@ -286,15 +246,6 @@ rtl_arena_hash_rescale (
old_table = arena->m_hash_table;
old_size = arena->m_hash_size;
- // SAL_INFO(
- // "sal.rtl",
- // "rtl_arena_hash_rescale(" << arena->m_name << "): nseg: "
- // << (arena->m_stats.m_alloc - arena->m_stats.m_free) << " (ave: "
- // << ((arena->m_stats.m_alloc - arena->m_stats.m_free)
- // >> arena->m_hash_shift)
- // << "), frees: " << arena->m_stats.m_free << " [old_size: "
- // << old_size << ", new_size: " << new_size << ']');
-
arena->m_hash_table = new_table;
arena->m_hash_size = new_size;
arena->m_hash_shift = highbit(arena->m_hash_size) - 1;
@@ -327,12 +278,11 @@ rtl_arena_hash_rescale (
}
}
-/** rtl_arena_hash_insert()
- * ...and update stats.
- */
-inline void
-rtl_arena_hash_insert (
- rtl_arena_type * arena,
+/**
+ Insert arena hash, and update stats.
+*/
+inline void rtl_arena_hash_insert(
+ rtl_arena_type * arena,
rtl_arena_segment_type * segment
)
{
@@ -347,14 +297,13 @@ rtl_arena_hash_insert (
arena->m_stats.m_mem_alloc += segment->m_size;
}
-/** rtl_arena_hash_remove()
- * ...and update stats.
- */
-rtl_arena_segment_type *
-rtl_arena_hash_remove (
+/**
+ Remove arena hash, and update stats.
+*/
+rtl_arena_segment_type * rtl_arena_hash_remove(
rtl_arena_type * arena,
- sal_uIntPtr addr,
- sal_Size size
+ sal_uIntPtr addr,
+ sal_Size size
)
{
rtl_arena_segment_type *segment, **segpp;
@@ -408,18 +357,15 @@ rtl_arena_hash_remove (
return segment;
}
-/* ================================================================= */
+/**
+ allocate (and remove) segment from freelist
-/** rtl_arena_segment_alloc()
- * allocate (and remove) segment from freelist
- *
- * @precond arena->m_lock acquired
- * @precond (*ppSegment == 0)
- */
-bool
-rtl_arena_segment_alloc (
- rtl_arena_type * arena,
- sal_Size size,
+ @precond arena->m_lock acquired
+ @precond (*ppSegment == 0)
+*/
+bool rtl_arena_segment_alloc(
+ rtl_arena_type * arena,
+ sal_Size size,
rtl_arena_segment_type ** ppSegment
)
{
@@ -471,16 +417,15 @@ dequeue_and_leave:
return (*ppSegment != nullptr);
}
-/** rtl_arena_segment_create()
- * import new (span) segment from source arena
- *
- * @precond arena->m_lock acquired
- * @precond (*ppSegment == 0)
- */
-int
-rtl_arena_segment_create (
- rtl_arena_type * arena,
- sal_Size size,
+/**
+ import new (span) segment from source arena
+
+ @precond arena->m_lock acquired
+ @precond (*ppSegment == 0)
+*/
+int rtl_arena_segment_create(
+ rtl_arena_type * arena,
+ sal_Size size,
rtl_arena_segment_type ** ppSegment
)
{
@@ -526,15 +471,14 @@ rtl_arena_segment_create (
return 0;
}
-/** rtl_arena_segment_coalesce()
- * mark as free and join with adjacent free segment(s)
- *
- * @precond arena->m_lock acquired
- * @precond segment marked 'used'
- */
-void
-rtl_arena_segment_coalesce (
- rtl_arena_type * arena,
+/**
+ mark as free and join with adjacent free segment(s)
+
+ @precond arena->m_lock acquired
+ @precond segment marked 'used'
+*/
+void rtl_arena_segment_coalesce(
+ rtl_arena_type * arena,
rtl_arena_segment_type * segment
)
{
@@ -580,12 +524,7 @@ rtl_arena_segment_coalesce (
}
}
-/* ================================================================= */
-
-/** rtl_arena_constructor()
- */
-void
-rtl_arena_constructor (void * obj)
+void rtl_arena_constructor(void * obj)
{
rtl_arena_type * arena = static_cast<rtl_arena_type*>(obj);
rtl_arena_segment_type * head;
@@ -623,10 +562,7 @@ rtl_arena_constructor (void * obj)
arena->m_hash_shift = highbit(arena->m_hash_size) - 1;
}
-/** rtl_arena_destructor()
- */
-void
-rtl_arena_destructor (void * obj)
+void rtl_arena_destructor(void * obj)
{
rtl_arena_type * arena = static_cast<rtl_arena_type*>(obj);
rtl_arena_segment_type * head;
@@ -663,21 +599,16 @@ rtl_arena_destructor (void * obj)
assert(arena->m_hash_shift == highbit(arena->m_hash_size) - 1);
}
-/* ================================================================= */
-
-/** rtl_arena_activate()
- */
#if defined __GNUC__ && __GNUC__ >= 7
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
#endif
-rtl_arena_type *
-rtl_arena_activate (
- rtl_arena_type * arena,
- const char * name,
- sal_Size quantum,
- sal_Size quantum_cache_max,
- rtl_arena_type * source_arena,
+rtl_arena_type * rtl_arena_activate(
+ rtl_arena_type * arena,
+ const char * name,
+ sal_Size quantum,
+ sal_Size quantum_cache_max,
+ rtl_arena_type * source_arena,
void * (SAL_CALL * source_alloc)(rtl_arena_type *, sal_Size *),
void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size)
)
@@ -733,12 +664,7 @@ rtl_arena_activate (
return arena;
}
-/** rtl_arena_deactivate()
- */
-void
-rtl_arena_deactivate (
- rtl_arena_type * arena
-)
+void rtl_arena_deactivate(rtl_arena_type * arena)
{
rtl_arena_segment_type * head, * segment;
@@ -768,23 +694,10 @@ rtl_arena_deactivate (
}
/* check for leaked segments */
- // SAL_INFO(
- // "sal.rtl",
- // "rtl_arena_deactivate(" << arena->m_name << "): allocs: "
- // << arena->m_stats.m_alloc << ", frees: " << arena->m_stats.m_free
- // << "; total: " << arena->m_stats.m_mem_total << ", used: "
- // << arena->m_stats.m_mem_alloc);
if (arena->m_stats.m_alloc > arena->m_stats.m_free)
{
sal_Size i, n;
- // SAL_INFO(
- // "sal.rtl",
- // "rtl_arena_deactivate(" << arena->m_name << "): cleaning up "
- // << (arena->m_stats.m_alloc - arena->m_stats.m_free)
- // << " leaked segment(s) [" << arena->m_stats.m_mem_alloc
- // << " bytes]");
-
/* cleanup still used segment(s) */
for (i = 0, n = arena->m_hash_size; i < n; i++)
{
@@ -806,13 +719,13 @@ rtl_arena_deactivate (
/* cleanup hash table */
if (arena->m_hash_table != arena->m_hash_table_0)
{
- rtl_arena_free (
+ rtl_arena_free(
gp_arena_arena,
arena->m_hash_table,
arena->m_hash_size * sizeof(rtl_arena_segment_type*));
arena->m_hash_table = arena->m_hash_table_0;
- arena->m_hash_size = RTL_ARENA_HASH_SIZE;
+ arena->m_hash_size = RTL_ARENA_HASH_SIZE;
arena->m_hash_shift = highbit(arena->m_hash_size) - 1;
}
@@ -861,17 +774,9 @@ rtl_arena_deactivate (
}
}
-} //namespace
-/* ================================================================= *
- *
- * arena implementation.
- *
- * ================================================================= */
+} // namespace
-/** rtl_arena_create()
- */
-rtl_arena_type *
-SAL_CALL rtl_arena_create (
+rtl_arena_type * SAL_CALL rtl_arena_create(
const char * name,
sal_Size quantum,
sal_Size quantum_cache_max,
@@ -926,12 +831,7 @@ try_alloc:
return result;
}
-/** rtl_arena_destroy()
- */
-void
-SAL_CALL rtl_arena_destroy (
- rtl_arena_type * arena
-) SAL_THROW_EXTERN_C()
+void SAL_CALL rtl_arena_destroy(rtl_arena_type * arena) SAL_THROW_EXTERN_C()
{
if (arena != nullptr)
{
@@ -941,10 +841,7 @@ SAL_CALL rtl_arena_destroy (
}
}
-/** rtl_arena_alloc()
- */
-void *
-SAL_CALL rtl_arena_alloc (
+void * SAL_CALL rtl_arena_alloc(
rtl_arena_type * arena,
sal_Size * pSize
) SAL_THROW_EXTERN_C()
@@ -1013,10 +910,7 @@ SAL_CALL rtl_arena_alloc (
return addr;
}
-/** rtl_arena_free()
- */
-void
-SAL_CALL rtl_arena_free (
+void SAL_CALL rtl_arena_free (
rtl_arena_type * arena,
void * addr,
sal_Size size
@@ -1096,12 +990,6 @@ SAL_CALL rtl_arena_free (
}
}
-/* ================================================================= *
- *
- * machdep internals.
- *
- * ================================================================= */
-
#if defined(SAL_UNX)
#include <sys/mman.h>
#elif defined(SAL_W32)
@@ -1111,10 +999,7 @@ SAL_CALL rtl_arena_free (
namespace
{
-/** rtl_machdep_alloc()
- */
-void *
-SAL_CALL rtl_machdep_alloc (
+void * SAL_CALL rtl_machdep_alloc(
rtl_arena_type * pArena,
sal_Size * pSize
)
@@ -1136,7 +1021,7 @@ SAL_CALL rtl_machdep_alloc (
size -= (pArena->m_quantum + pArena->m_quantum); /* "red-zone" pages */
#else
/* default allocation granularity */
- if(pArena->m_quantum < (64 << 10))
+ if (pArena->m_quantum < (64 << 10))
{
size = RTL_MEMORY_P2ROUNDUP(size, (64 << 10));
}
@@ -1164,10 +1049,7 @@ SAL_CALL rtl_machdep_alloc (
return nullptr;
}
-/** rtl_machdep_free()
- */
-void
-SAL_CALL rtl_machdep_free (
+void SAL_CALL rtl_machdep_free(
rtl_arena_type * pArena,
void * pAddr,
sal_Size nSize
@@ -1186,8 +1068,7 @@ SAL_CALL rtl_machdep_free (
#endif /* (SAL_UNX || SAL_W32) */
}
-sal_Size
-rtl_machdep_pagesize()
+sal_Size rtl_machdep_pagesize()
{
#if defined(SAL_UNX)
#if defined(FREEBSD) || defined(NETBSD) || defined(DRAGONFLY)
@@ -1204,14 +1085,7 @@ rtl_machdep_pagesize()
} //namespace
-/* ================================================================= *
- *
- * arena initialization.
- *
- * ================================================================= */
-
-void
-rtl_arena_init()
+void rtl_arena_init()
{
{
/* list of arenas */
@@ -1259,7 +1133,7 @@ rtl_arena_init()
assert(gp_arena_arena == nullptr);
rtl_arena_constructor (&g_arena_arena);
- gp_arena_arena = rtl_arena_activate (
+ gp_arena_arena = rtl_arena_activate(
&g_arena_arena,
"rtl_arena_internal_arena",
64, /* quantum */
@@ -1270,13 +1144,9 @@ rtl_arena_init()
);
assert(gp_arena_arena != nullptr);
}
- // SAL_INFO("sal.rtl", "rtl_arena_init completed");
}
-/* ================================================================= */
-
-void
-rtl_arena_fini()
+void rtl_arena_fini()
{
if (gp_arena_arena != nullptr)
{
@@ -1287,19 +1157,10 @@ rtl_arena_fini()
for (arena = head->m_arena_next; arena != head; arena = arena->m_arena_next)
{
- // SAL_INFO(
- // "sal.rtl",
- // "rtl_arena_fini(" << arena->m_name << "): allocs: "
- // << arena->m_stats.m_alloc << ", frees: "
- // << arena->m_stats.m_free << "; total: "
- // << arena->m_stats.m_mem_total << ", used: "
- // << arena->m_stats.m_mem_alloc);
+ // noop
}
RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock));
}
- // SAL_INFO("sal.rtl", "rtl_arena_fini completed");
}
-/* ================================================================= */
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx
index d2c5fc5c8745..4dfa1eb966c4 100644
--- a/sal/rtl/alloc_cache.cxx
+++ b/sal/rtl/alloc_cache.cxx
@@ -32,13 +32,7 @@
#include <sys/time.h>
#endif
-/* ================================================================= *
- *
- * cache internals.
- *
- * ================================================================= */
-
-/** g_cache_list
+/**
* @internal
*/
struct rtl_cache_list_st
@@ -58,32 +52,28 @@ struct rtl_cache_list_st
static rtl_cache_list_st g_cache_list;
-/** gp_cache_arena
- * provided for cache_type allocations, and hash_table resizing.
- *
- * @internal
- */
+/**
+ provided for cache_type allocations, and hash_table resizing.
+
+ @internal
+*/
static rtl_arena_type * gp_cache_arena = nullptr;
-/** gp_cache_magazine_cache
- * @internal
- */
+/**
+ @internal
+*/
static rtl_cache_type * gp_cache_magazine_cache = nullptr;
-/** gp_cache_slab_cache
- * @internal
- */
+/**
+ @internal
+*/
static rtl_cache_type * gp_cache_slab_cache = nullptr;
-/** gp_cache_bufctl_cache
- * @internal
- */
+/**
+ @internal
+*/
static rtl_cache_type * gp_cache_bufctl_cache = nullptr;
-/* ================================================================= */
-
-/** RTL_CACHE_HASH_INDEX()
- */
#define RTL_CACHE_HASH_INDEX_IMPL(a, s, q, m) \
((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m))
@@ -93,8 +83,7 @@ static rtl_cache_type * gp_cache_bufctl_cache = nullptr;
namespace
{
-void
-rtl_cache_hash_rescale (
+void rtl_cache_hash_rescale(
rtl_cache_type * cache,
sal_Size new_size
)
@@ -117,16 +106,6 @@ rtl_cache_hash_rescale (
old_table = cache->m_hash_table;
old_size = cache->m_hash_size;
- // SAL_INFO(
- // "sal.rtl",
- // "rtl_cache_hash_rescale(" << cache->m_name << "): nbuf: "
- // << (cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free)
- // << " (ave: "
- // << ((cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free)
- // >> cache->m_hash_shift)
- // << "), frees: " << cache->m_slab_stats.m_free << " [old_size: "
- // << old_size << ", new_size: " << new_size << ']');
-
cache->m_hash_table = new_table;
cache->m_hash_size = new_size;
const auto bit = highbit(cache->m_hash_size);
@@ -160,8 +139,7 @@ rtl_cache_hash_rescale (
}
}
-inline sal_uIntPtr
-rtl_cache_hash_insert (
+inline sal_uIntPtr rtl_cache_hash_insert(
rtl_cache_type * cache,
rtl_cache_bufctl_type * bufctl
)
@@ -176,10 +154,7 @@ rtl_cache_hash_insert (
return bufctl->m_addr;
}
-/** rtl_cache_hash_remove()
- */
-rtl_cache_bufctl_type *
-rtl_cache_hash_remove (
+rtl_cache_bufctl_type * rtl_cache_hash_remove(
rtl_cache_type * cache,
sal_uIntPtr addr
)
@@ -228,17 +203,10 @@ rtl_cache_hash_remove (
return bufctl;
}
-/* ================================================================= */
-
-/** RTL_CACHE_SLAB()
- */
#define RTL_CACHE_SLAB(addr, size) \
((reinterpret_cast<rtl_cache_slab_type*>(RTL_MEMORY_P2END(reinterpret_cast<sal_uIntPtr>(addr), (size)))) - 1)
-/** rtl_cache_slab_constructor()
- */
-int
-rtl_cache_slab_constructor (void * obj, SAL_UNUSED_PARAMETER void *)
+int rtl_cache_slab_constructor(void * obj, SAL_UNUSED_PARAMETER void *)
{
rtl_cache_slab_type * slab = static_cast<rtl_cache_slab_type*>(obj);
@@ -248,10 +216,7 @@ rtl_cache_slab_constructor (void * obj, SAL_UNUSED_PARAMETER void *)
return 1;
}
-/** rtl_cache_slab_destructor()
- */
-void
-rtl_cache_slab_destructor (void * obj, SAL_UNUSED_PARAMETER void *)
+void rtl_cache_slab_destructor(void * obj, SAL_UNUSED_PARAMETER void *)
{
rtl_cache_slab_type * slab = static_cast< rtl_cache_slab_type * >(obj);
assert(QUEUE_STARTED_NAMED(slab, slab_)); // assure removed from queue(s)
@@ -259,14 +224,10 @@ rtl_cache_slab_destructor (void * obj, SAL_UNUSED_PARAMETER void *)
(void) slab; // avoid warnings
}
-/** rtl_cache_slab_create()
- *
- * @precond cache->m_slab_lock released.
- */
-rtl_cache_slab_type *
-rtl_cache_slab_create (
- rtl_cache_type * cache
-)
+/**
+ @precond cache->m_slab_lock released.
+*/
+rtl_cache_slab_type * rtl_cache_slab_create(rtl_cache_type * cache)
{
rtl_cache_slab_type * slab = nullptr;
void * addr;
@@ -306,12 +267,10 @@ rtl_cache_slab_create (
return slab;
}
-/** rtl_cache_slab_destroy()
- *
- * @precond cache->m_slab_lock released.
- */
-void
-rtl_cache_slab_destroy (
+/**
+ @precond cache->m_slab_lock released.
+*/
+void rtl_cache_slab_destroy(
rtl_cache_type * cache,
rtl_cache_slab_type * slab
)
@@ -352,14 +311,10 @@ rtl_cache_slab_destroy (
}
}
-/** rtl_cache_slab_populate()
- *
- * @precond cache->m_slab_lock acquired.
- */
-bool
-rtl_cache_slab_populate (
- rtl_cache_type * cache
-)
+/**
+ @precond cache->m_slab_lock acquired.
+*/
+bool rtl_cache_slab_populate(rtl_cache_type * cache)
{
rtl_cache_slab_type * slab;
@@ -385,16 +340,10 @@ rtl_cache_slab_populate (
return (slab != nullptr);
}
-/* ================================================================= */
-
-/** rtl_cache_slab_alloc()
- *
- * Allocate a buffer from slab layer; used by magazine layer.
- */
-void *
-rtl_cache_slab_alloc (
- rtl_cache_type * cache
-)
+/**
+ Allocate a buffer from slab layer; used by magazine layer.
+*/
+void * rtl_cache_slab_alloc (rtl_cache_type * cache)
{
void * addr = nullptr;
rtl_cache_slab_type * head;
@@ -471,12 +420,10 @@ rtl_cache_slab_alloc (
return addr;
}
-/** rtl_cache_slab_free()
- *
- * Return a buffer to slab layer; used by magazine layer.
- */
-void
-rtl_cache_slab_free (
+/**
+ Return a buffer to slab layer; used by magazine layer.
+*/
+void rtl_cache_slab_free(
rtl_cache_type * cache,
void * addr
)
@@ -538,12 +485,7 @@ rtl_cache_slab_free (
RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock));
}
-/* ================================================================= */
-
-/** rtl_cache_magazine_constructor()
- */
-int
-rtl_cache_magazine_constructor (void * obj, SAL_UNUSED_PARAMETER void *)
+int rtl_cache_magazine_constructor(void * obj, SAL_UNUSED_PARAMETER void *)
{
rtl_cache_magazine_type * mag = static_cast<rtl_cache_magazine_type*>(obj);
/* @@@ sal_Size size = (sal_Size)(arg); @@@ */
@@ -555,10 +497,7 @@ rtl_cache_magazine_constructor (void * obj, SAL_UNUSED_PARAMETER void *)
return 1;
}
-/** rtl_cache_magazine_destructor()
- */
-void
-rtl_cache_magazine_destructor (void * obj, SAL_UNUSED_PARAMETER void *)
+void rtl_cache_magazine_destructor(void * obj, SAL_UNUSED_PARAMETER void *)
{
rtl_cache_magazine_type * mag = static_cast< rtl_cache_magazine_type * >(
obj);
@@ -567,10 +506,7 @@ rtl_cache_magazine_destructor (void * obj, SAL_UNUSED_PARAMETER void *)
(void) mag; // avoid warnings
}
-/** rtl_cache_magazine_clear()
- */
-void
-rtl_cache_magazine_clear (
+void rtl_cache_magazine_clear(
rtl_cache_type * cache,
rtl_cache_magazine_type * mag
)
@@ -591,14 +527,10 @@ rtl_cache_magazine_clear (
}
}
-/* ================================================================= */
-
-/** rtl_cache_depot_enqueue()
- *
- * @precond cache->m_depot_lock acquired.
- */
-inline void
-rtl_cache_depot_enqueue (
+/**
+ @precond cache->m_depot_lock acquired.
+*/
+inline void rtl_cache_depot_enqueue(
rtl_cache_depot_type * depot,
rtl_cache_magazine_type * mag
)
@@ -611,12 +543,10 @@ rtl_cache_depot_enqueue (
depot->m_mag_count++;
}
-/** rtl_cache_depot_dequeue()
- *
- * @precond cache->m_depot_lock acquired.
- */
-inline rtl_cache_magazine_type *
-rtl_cache_depot_dequeue (
+/**
+ @precond cache->m_depot_lock acquired.
+*/
+inline rtl_cache_magazine_type * rtl_cache_depot_dequeue(
rtl_cache_depot_type * depot
)
{
@@ -640,12 +570,10 @@ rtl_cache_depot_dequeue (
return mag;
}
-/** rtl_cache_depot_exchange_alloc()
- *
- * @precond cache->m_depot_lock acquired.
- */
-inline rtl_cache_magazine_type *
-rtl_cache_depot_exchange_alloc (
+/**
+ @precond cache->m_depot_lock acquired.
+*/
+inline rtl_cache_magazine_type * rtl_cache_depot_exchange_alloc(
rtl_cache_type * cache,
rtl_cache_magazine_type * empty
)
@@ -667,12 +595,10 @@ rtl_cache_depot_exchange_alloc (
return full;
}
-/** rtl_cache_depot_exchange_free()
- *
- * @precond cache->m_depot_lock acquired.
- */
-inline rtl_cache_magazine_type *
-rtl_cache_depot_exchange_free (
+/**
+ @precond cache->m_depot_lock acquired.
+*/
+inline rtl_cache_magazine_type * rtl_cache_depot_exchange_free(
rtl_cache_type * cache,
rtl_cache_magazine_type * full
)
@@ -694,14 +620,10 @@ rtl_cache_depot_exchange_free (
return empty;
}
-/** rtl_cache_depot_populate()
- *
- * @precond cache->m_depot_lock acquired.
- */
-bool
-rtl_cache_depot_populate (
- rtl_cache_type * cache
-)
+/**
+ @precond cache->m_depot_lock acquired.
+*/
+bool rtl_cache_depot_populate(rtl_cache_type * cache)
{
rtl_cache_magazine_type * empty = nullptr;
@@ -720,12 +642,7 @@ rtl_cache_depot_populate (
return (empty != nullptr);
}
-/* ================================================================= */
-
-/** rtl_cache_constructor()
- */
-int
-rtl_cache_constructor (void * obj)
+int rtl_cache_constructor(void * obj)
{
rtl_cache_type * cache = static_cast<rtl_cache_type*>(obj);
@@ -750,10 +667,7 @@ rtl_cache_constructor (void * obj)
return 1;
}
-/** rtl_cache_destructor()
- */
-void
-rtl_cache_destructor (void * obj)
+void rtl_cache_destructor(void * obj)
{
rtl_cache_type * cache = static_cast<rtl_cache_type*>(obj);
@@ -774,12 +688,7 @@ rtl_cache_destructor (void * obj)
RTL_MEMORY_LOCK_DESTROY(&(cache->m_depot_lock));
}
-/* ================================================================= */
-
-/** rtl_cache_activate()
- */
-rtl_cache_type *
-rtl_cache_activate (
+rtl_cache_type * rtl_cache_activate(
rtl_cache_type * cache,
const char * name,
size_t objsize,
@@ -896,12 +805,7 @@ rtl_cache_activate (
return cache;
}
-/** rtl_cache_deactivate()
- */
-void
-rtl_cache_deactivate (
- rtl_cache_type * cache
-)
+void rtl_cache_deactivate(rtl_cache_type * cache)
{
/* remove from cache list */
RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock));
@@ -951,29 +855,9 @@ rtl_cache_deactivate (
}
}
- // SAL_INFO(
- // "sal.rtl",
- // "rtl_cache_deactivate(" << cache->m_name << "): [slab]: allocs: "
- // << cache->m_slab_stats.m_alloc << ", frees: "
- // << cache->m_slab_stats.m_free << "; total: "
- // << cache->m_slab_stats.m_mem_total << ", used: "
- // << cache->m_slab_stats.m_mem_alloc << "; [cpu]: allocs: "
- // << cache->m_cpu_stats.m_alloc << ", frees: "
- // << cache->m_cpu_stats.m_free << "; [total]: allocs: "
- // << (cache->m_slab_stats.m_alloc + cache->m_cpu_stats.m_alloc)
- // << ", frees: "
- // << (cache->m_slab_stats.m_free + cache->m_cpu_stats.m_free));
-
/* cleanup slab layer */
if (cache->m_slab_stats.m_alloc > cache->m_slab_stats.m_free)
{
- // SAL_INFO(
- // "sal.rtl",
- // "rtl_cache_deactivate(" << cache->m_name << "): cleaning up "
- // << (cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free)
- // << " leaked buffer(s) [" << cache->m_slab_stats.m_mem_alloc
- // << " bytes] [" << cache->m_slab_stats.m_mem_total << " total]");
-
if (cache->m_features & RTL_CACHE_FEATURE_HASH)
{
/* cleanup bufctl(s) for leaking buffer(s) */
@@ -1039,16 +923,7 @@ rtl_cache_deactivate (
} //namespace
-/* ================================================================= *
- *
- * cache implementation.
- *
- * ================================================================= */
-
-/** rtl_cache_create()
- */
-rtl_cache_type *
-SAL_CALL rtl_cache_create (
+rtl_cache_type * SAL_CALL rtl_cache_create(
const char * name,
sal_Size objsize,
sal_Size objalign,
@@ -1109,11 +984,7 @@ try_alloc:
return result;
}
-/** rtl_cache_destroy()
- */
-void SAL_CALL rtl_cache_destroy (
- rtl_cache_type * cache
-) SAL_THROW_EXTERN_C()
+void SAL_CALL rtl_cache_destroy(rtl_cache_type * cache) SAL_THROW_EXTERN_C()
{
if (cache != nullptr)
{
@@ -1123,12 +994,7 @@ void SAL_CALL rtl_cache_destroy (
}
}
-/** rtl_cache_alloc()
- */
-void *
-SAL_CALL rtl_cache_alloc (
- rtl_cache_type * cache
-) SAL_THROW_EXTERN_C()
+void * SAL_CALL rtl_cache_alloc(rtl_cache_type * cache) SAL_THROW_EXTERN_C()
{
void * obj = nullptr;
@@ -1208,10 +1074,7 @@ SAL_CALL rtl_cache_alloc (
return obj;
}
-/** rtl_cache_free()
- */
-void
-SAL_CALL rtl_cache_free (
+void SAL_CALL rtl_cache_free(
rtl_cache_type * cache,
void * obj
) SAL_THROW_EXTERN_C()
@@ -1290,8 +1153,7 @@ SAL_CALL rtl_cache_free (
#if defined(SAL_UNX)
-void SAL_CALL
-rtl_secureZeroMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
+void SAL_CALL rtl_secureZeroMemory(void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
{
//currently glibc doesn't implement memset_s
volatile char *p = static_cast<volatile char*>(Ptr);
@@ -1299,11 +1161,9 @@ rtl_secureZeroMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
*p++ = 0;
}
-static void *
-rtl_cache_wsupdate_all (void * arg);
+static void * rtl_cache_wsupdate_all(void * arg);
-static void
-rtl_cache_wsupdate_init()
+static void rtl_cache_wsupdate_init()
{
RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock));
g_cache_list.m_update_done = 0;
@@ -1317,8 +1177,7 @@ rtl_cache_wsupdate_init()
RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock));
}
-static void
-rtl_cache_wsupdate_wait (unsigned int seconds)
+static void rtl_cache_wsupdate_wait(unsigned int seconds)
{
if (seconds > 0)
{
@@ -1336,8 +1195,7 @@ rtl_cache_wsupdate_wait (unsigned int seconds)
}
}
-static void
-rtl_cache_wsupdate_fini()
+static void rtl_cache_wsupdate_fini()
{
RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock));
g_cache_list.m_update_done = 1;
@@ -1348,21 +1206,16 @@ rtl_cache_wsupdate_fini()
pthread_join (g_cache_list.m_update_thread, nullptr);
}
-/* ================================================================= */
-
#elif defined(SAL_W32)
-void SAL_CALL
-rtl_secureZeroMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
+void SAL_CALL rtl_secureZeroMemory(void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
{
RtlSecureZeroMemory(Ptr, Bytes);
}
-static DWORD WINAPI
-rtl_cache_wsupdate_all (void * arg);
+static DWORD WINAPI rtl_cache_wsupdate_all(void * arg);
-static void
-rtl_cache_wsupdate_init()
+static void rtl_cache_wsupdate_init()
{
DWORD dwThreadId;
@@ -1375,8 +1228,7 @@ rtl_cache_wsupdate_init()
RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock));
}
-static void
-rtl_cache_wsupdate_wait (unsigned int seconds)
+static void rtl_cache_wsupdate_wait(unsigned int seconds)
{
if (seconds > 0)
{
@@ -1386,8 +1238,7 @@ rtl_cache_wsupdate_wait (unsigned int seconds)
}
}
-static void
-rtl_cache_wsupdate_fini()
+static void rtl_cache_wsupdate_fini()
{
RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock));
g_cache_list.m_update_done = 1;
@@ -1399,15 +1250,12 @@ rtl_cache_wsupdate_fini()
#endif /* SAL_UNX || SAL_W32 */
-/* ================================================================= */
+/**
+ update depot stats and purge excess magazines.
-/** rtl_cache_depot_wsupdate()
- * update depot stats and purge excess magazines.
- *
- * @precond cache->m_depot_lock acquired
- */
-static void
-rtl_cache_depot_wsupdate (
+ @precond cache->m_depot_lock acquired
+*/
+static void rtl_cache_depot_wsupdate(
rtl_cache_type * cache,
rtl_cache_depot_type * depot
)
@@ -1432,30 +1280,15 @@ rtl_cache_depot_wsupdate (
// coverity[missing_unlock]
}
-/** rtl_cache_wsupdate()
- *
- * @precond cache->m_depot_lock released
- */
-static void
-rtl_cache_wsupdate (
- rtl_cache_type * cache
-)
+/**
+ @precond cache->m_depot_lock released
+*/
+static void rtl_cache_wsupdate(rtl_cache_type * cache)
{
if (cache->m_magazine_cache != nullptr)
{
RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock));
- // SAL_INFO(
- // "sal.rtl",
- // "rtl_cache_wsupdate(" << cache->m_name
- // << ") [depot: count, curr_min, prev_min] full: "
- // << cache->m_depot_full.m_mag_count << ", "
- // << cache->m_depot_full.m_curr_min << ", "
- // << cache->m_depot_full.m_prev_min << "; empty: "
- // << cache->m_depot_empty.m_mag_count << ", "
- // << cache->m_depot_empty.m_curr_min << ", "
- // << cache->m_depot_empty.m_prev_min);
-
rtl_cache_depot_wsupdate (cache, &(cache->m_depot_full));
rtl_cache_depot_wsupdate (cache, &(cache->m_depot_empty));
@@ -1463,15 +1296,12 @@ rtl_cache_wsupdate (
}
}
-/** rtl_cache_wsupdate_all()
- *
- */
#if defined(SAL_UNX)
static void *
#elif defined(SAL_W32)
static DWORD WINAPI
#endif /* SAL_UNX || SAL_W32 */
-rtl_cache_wsupdate_all (void * arg)
+rtl_cache_wsupdate_all(void * arg)
{
osl::Thread::setName("rtl_cache_wsupdate_all");
unsigned int seconds = sal::static_int_cast< unsigned int >(
@@ -1503,14 +1333,7 @@ rtl_cache_wsupdate_all (void * arg)
#endif
}
-/* ================================================================= *
- *
- * cache initialization.
- *
- * ================================================================= */
-
-void
-rtl_cache_init()
+void rtl_cache_init()
{
{
/* list of caches */
@@ -1600,13 +1423,9 @@ rtl_cache_init()
}
rtl_cache_wsupdate_init();
- // SAL_INFO("sal.rtl", "rtl_cache_init completed");
}
-/* ================================================================= */
-
-void
-rtl_cache_fini()
+void rtl_cache_fini()
{
if (gp_cache_arena != nullptr)
{
@@ -1645,24 +1464,10 @@ rtl_cache_fini()
head = &(g_cache_list.m_cache_head);
for (cache = head->m_cache_next; cache != head; cache = cache->m_cache_next)
{
- // SAL_INFO(
- // "sal.rtl",
- // "rtl_cache_fini(" << cache->m_name << ") [slab]: allocs: "
- // << cache->m_slab_stats.m_alloc << ", frees: "
- // << cache->m_slab_stats.m_free << "; total: "
- // << cache->m_slab_stats.m_mem_total << ", used: "
- // << cache->m_slab_stats.m_mem_alloc << "; [cpu]: allocs: "
- // << cache->m_cpu_stats.m_alloc << ", frees: "
- // << cache->m_cpu_stats.m_free << "; [total]: allocs: "
- // << (cache->m_slab_stats.m_alloc
- // + cache->m_cpu_stats.m_alloc)
- // << ", frees: "
- // << (cache->m_slab_stats.m_free
- // + cache->m_cpu_stats.m_free));
+ // noop
}
RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock));
}
- // SAL_INFO("sal.rtl", "rtl_cache_fini completed");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/rtl/alloc_cache.hxx b/sal/rtl/alloc_cache.hxx
index cd35285740e0..a7c1c497e7c0 100644
--- a/sal/rtl/alloc_cache.hxx
+++ b/sal/rtl/alloc_cache.hxx
@@ -24,9 +24,9 @@
#include "rtl/alloc.h"
#include "alloc_impl.hxx"
-/** rtl_cache_stat_type
- * @internal
- */
+/**
+ @internal
+*/
struct rtl_cache_stat_type
{
sal_uInt64 m_alloc;
@@ -36,9 +36,9 @@ struct rtl_cache_stat_type
sal_Size m_mem_alloc;
};
-/** rtl_cache_bufctl_type
- * @internal
- */
+/**
+ @internal
+*/
struct rtl_cache_bufctl_type
{
rtl_cache_bufctl_type * m_next; /* linkage */
@@ -47,9 +47,9 @@ struct rtl_cache_bufctl_type
sal_uIntPtr m_slab; /* parent slab address */
};
-/** rtl_cache_slab_type
- * @internal
- */
+/**
+ @internal
+*/
struct rtl_cache_slab_type
{
rtl_cache_slab_type * m_slab_next; /* slab linkage */
@@ -62,9 +62,9 @@ struct rtl_cache_slab_type
rtl_cache_bufctl_type * m_sp; /* free buffer linkage 'stack pointer' */
};
-/** rtl_cache_magazine_type
- * @internal
- */
+/**
+ @internal
+*/
#define RTL_CACHE_MAGAZINE_SIZE 61
struct rtl_cache_magazine_type
@@ -77,9 +77,9 @@ struct rtl_cache_magazine_type
void * m_objects[RTL_CACHE_MAGAZINE_SIZE];
};
-/** rtl_cache_depot_type
- * @internal
- */
+/**
+ @internal
+*/
struct rtl_cache_depot_type
{
/* magazine list */
@@ -91,10 +91,10 @@ struct rtl_cache_depot_type
sal_Size m_prev_min;
};
-/** rtl_cache_type
- * @internal
- */
-#define RTL_CACHE_HASH_SIZE 8
+/**
+ @internal
+*/
+#define RTL_CACHE_HASH_SIZE 8
#define RTL_CACHE_FEATURE_HASH 1
#define RTL_CACHE_FEATURE_BULKDESTROY 2
diff --git a/sal/rtl/alloc_global.cxx b/sal/rtl/alloc_global.cxx
index e17df316acbe..a16550589960 100644
--- a/sal/rtl/alloc_global.cxx
+++ b/sal/rtl/alloc_global.cxx
@@ -38,12 +38,6 @@ static void determine_alloc_mode()
alloc_mode = (getenv("G_SLICE") == nullptr ? AllocMode::CUSTOM : AllocMode::SYSTEM);
}
-/* ================================================================= *
- *
- * custom allocator internals.
- *
- * ================================================================= */
-
static const sal_Size g_alloc_sizes[] =
{
/* powers of 2**(1/4) */
@@ -78,14 +72,7 @@ static rtl_cache_type * g_alloc_table[RTL_MEMORY_CACHED_LIMIT >> RTL_MEMALIGN_SH
static rtl_arena_type * gp_alloc_arena = nullptr;
-/* ================================================================= *
- *
- * custom allocator implementation.
- *
- * ================================================================= */
-
-void *
-SAL_CALL rtl_allocateMemory_CUSTOM (sal_Size n) SAL_THROW_EXTERN_C()
+void * SAL_CALL rtl_allocateMemory_CUSTOM(sal_Size n) SAL_THROW_EXTERN_C()
{
void * p = nullptr;
if (n > 0)
@@ -124,8 +111,6 @@ try_alloc:
return p;
}
-/* ================================================================= */
-
void SAL_CALL rtl_freeMemory_CUSTOM (void * p) SAL_THROW_EXTERN_C()
{
if (p != nullptr)
@@ -140,8 +125,6 @@ void SAL_CALL rtl_freeMemory_CUSTOM (void * p) SAL_THROW_EXTERN_C()
}
}
-/* ================================================================= */
-
void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXTERN_C()
{
if (n > 0)
@@ -173,12 +156,6 @@ void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXT
#endif
-/* ================================================================= *
- *
- * custom allocator initialization / finalization.
- *
- * ================================================================= */
-
void rtl_memory_init()
{
#if !defined(FORCE_SYSALLOC)
@@ -219,11 +196,8 @@ void rtl_memory_init()
}
}
#endif
- // SAL_INFO("sal.rtl", "rtl_memory_init completed");
}
-/* ================================================================= */
-
void rtl_memory_fini()
{
#if !defined(FORCE_SYSALLOC)
@@ -250,37 +224,24 @@ void rtl_memory_fini()
gp_alloc_arena = nullptr;
}
#endif
- // SAL_INFO("sal.rtl", "rtl_memory_fini completed");
}
-/* ================================================================= *
- *
- * system allocator implementation.
- *
- * ================================================================= */
-
-void * SAL_CALL rtl_allocateMemory_SYSTEM (sal_Size n)
+void * SAL_CALL rtl_allocateMemory_SYSTEM(sal_Size n)
{
return malloc (n);
}
-/* ================================================================= */
-
-void SAL_CALL rtl_freeMemory_SYSTEM (void * p)
+void SAL_CALL rtl_freeMemory_SYSTEM(void * p)
{
free (p);
}
-/* ================================================================= */
-
-void * SAL_CALL rtl_reallocateMemory_SYSTEM (void * p, sal_Size n)
+void * SAL_CALL rtl_reallocateMemory_SYSTEM(void * p, sal_Size n)
{
return realloc (p, n);
}
-/* ================================================================= */
-
-void* SAL_CALL rtl_allocateMemory (sal_Size n) SAL_THROW_EXTERN_C()
+void* SAL_CALL rtl_allocateMemory(sal_Size n) SAL_THROW_EXTERN_C()
{
SAL_WARN_IF(
n >= SAL_MAX_INT32, "sal.rtl",
@@ -303,7 +264,7 @@ void* SAL_CALL rtl_allocateMemory (sal_Size n) SAL_THROW_EXTERN_C()
#endif
}
-void* SAL_CALL rtl_reallocateMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C()
+void* SAL_CALL rtl_reallocateMemory(void * p, sal_Size n) SAL_THROW_EXTERN_C()
{
SAL_WARN_IF(
n >= SAL_MAX_INT32, "sal.rtl",
@@ -326,7 +287,7 @@ void* SAL_CALL rtl_reallocateMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C()
#endif
}
-void SAL_CALL rtl_freeMemory (void * p) SAL_THROW_EXTERN_C()
+void SAL_CALL rtl_freeMemory(void * p) SAL_THROW_EXTERN_C()
{
#if !defined(FORCE_SYSALLOC)
while (true)
@@ -348,13 +309,7 @@ void SAL_CALL rtl_freeMemory (void * p) SAL_THROW_EXTERN_C()
#endif
}
-/* ================================================================= *
- *
- * rtl_(allocate|free)ZeroMemory() implementation.
- *
- * ================================================================= */
-
-void * SAL_CALL rtl_allocateZeroMemory (sal_Size n) SAL_THROW_EXTERN_C()
+void * SAL_CALL rtl_allocateZeroMemory(sal_Size n) SAL_THROW_EXTERN_C()
{
void * p = rtl_allocateMemory (n);
if (p != nullptr)
@@ -362,9 +317,7 @@ void * SAL_CALL rtl_allocateZeroMemory (sal_Size n) SAL_THROW_EXTERN_C()
return p;
}
-/* ================================================================= */
-
-void SAL_CALL rtl_freeZeroMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C()
+void SAL_CALL rtl_freeZeroMemory(void * p, sal_Size n) SAL_THROW_EXTERN_C()
{
if (p != nullptr)
{
@@ -373,16 +326,14 @@ void SAL_CALL rtl_freeZeroMemory (void * p, sal_Size n) SAL_THROW_EXTERN_C()
}
}
-void* SAL_CALL rtl_allocateAlignedMemory (sal_Size Alignment, sal_Size Bytes) SAL_THROW_EXTERN_C()
+void* SAL_CALL rtl_allocateAlignedMemory(sal_Size Alignment, sal_Size Bytes) SAL_THROW_EXTERN_C()
{
return osl_aligned_alloc(Alignment, Bytes);
}
-void SAL_CALL rtl_freeAlignedMemory (void* Ptr) SAL_THROW_EXTERN_C()
+void SAL_CALL rtl_freeAlignedMemory(void* Ptr) SAL_THROW_EXTERN_C()
{
osl_aligned_free(Ptr);
}
-/* ================================================================= */
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/rtl/alloc_impl.hxx b/sal/rtl/alloc_impl.hxx
index fada22718d43..bac110f2cac2 100644
--- a/sal/rtl/alloc_impl.hxx
+++ b/sal/rtl/alloc_impl.hxx
@@ -63,10 +63,9 @@
#endif /* PRIu64 */
/** highbit(): log2() + 1
- * (complexity O(1))
- */
-static inline unsigned int
-highbit(sal_Size n)
+ (complexity O(1))
+*/
+static inline unsigned int highbit(sal_Size n)
{
unsigned int k = 1;
@@ -105,16 +104,16 @@ highbit(sal_Size n)
return k;
}
-/** lowbit(): find first bit set
- * (complexity O(1))
- */
-static inline unsigned int
-lowbit(sal_Size n)
+/** find first bit set
+ (complexity O(1))
+*/
+static inline unsigned int lowbit(sal_Size n)
{
unsigned int k = 1;
if (n == 0)
return 0;
+
#if SAL_TYPES_SIZEOFLONG == 8
if (!(n & 0xffffffff))
{
@@ -122,35 +121,41 @@ lowbit(sal_Size n)
n >>= 32;
}
#endif
+
if (!(n & 0xffff))
{
k |= 16;
n >>= 16;
}
+
if (!(n & 0xff))
{
k |= 8;
n >>= 8;
}
+
if (!(n & 0xf))
{
k |= 4;
n >>= 4;
}
+
if (!(n & 0x3))
{
k |= 2;
n >>= 2;
}
+
if (!(n & 0x1))
k++;
+
return k;
}
/** Queue manipulation macros
- * (doubly linked circular list)
- * (complexity O(1))
- */
+ (doubly linked circular list)
+ (complexity O(1))
+*/
#define QUEUE_STARTED_NAMED(entry, name) \
(((entry)->m_##name##next == (entry)) && ((entry)->m_##name##prev == (entry)))
@@ -183,9 +188,6 @@ lowbit(sal_Size n)
(entry)->m_##name##prev->m_##name##next = (entry); \
}
-/** rtl_memory_lock_type
- * (platform dependent)
- */
#if defined(SAL_UNX)
#include <unistd.h>
@@ -223,8 +225,8 @@ typedef CRITICAL_SECTION rtl_memory_lock_type;
#endif /* SAL_UNX | SAL_W32 */
/** Cache creation flags.
- * @internal
- */
+ @internal
+*/
#define RTL_CACHE_FLAG_NOMAGAZINE (1 << 13) /* w/o magazine layer */
#define RTL_CACHE_FLAG_QUANTUMCACHE (2 << 13) /* used as arena quantum cache */