[Libreoffice-commits] core.git: sal/rtl

Arnaud Versini arnaud.versini at gmail.com
Mon Mar 4 03:42:31 PST 2013


 sal/rtl/alloc_arena.cxx |   91 ++++++++++++++++++------------------------------
 sal/rtl/alloc_cache.cxx |   62 +++++++++++++-------------------
 sal/rtl/alloc_impl.hxx  |   30 +--------------
 3 files changed, 64 insertions(+), 119 deletions(-)

New commits:
commit 4a0a0bf65ab8fb1ae9426f80d1b0ca920719d607
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Sun Feb 24 20:10:57 2013 +0100

    Cleanup static and inline usage in alloc_impl.
    
    Change-Id: I88170c9d033e0299c4b4462f7d0edb83152b4fbb
    Reviewed-on: https://gerrit.libreoffice.org/2367
    Reviewed-by: Michael Meeks <michael.meeks at suse.com>
    Tested-by: Michael Meeks <michael.meeks at suse.com>

diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx
index 663239f..b3f2a7f 100644
--- a/sal/rtl/alloc_arena.cxx
+++ b/sal/rtl/alloc_arena.cxx
@@ -66,34 +66,35 @@ static rtl_arena_type * gp_arena_arena = 0;
  */
 static rtl_arena_type * gp_machdep_arena = 0;
 
+/** gp_default_arena
+ */
+rtl_arena_type * gp_default_arena = 0;
+
+namespace
+{
 
-static void *
+void *
 SAL_CALL rtl_machdep_alloc (
     rtl_arena_type * pArena,
     sal_Size *       pSize
 );
 
-static void
+void
 SAL_CALL rtl_machdep_free (
     rtl_arena_type * pArena,
     void *           pAddr,
     sal_Size         nSize
 );
 
-static sal_Size
+sal_Size
 rtl_machdep_pagesize();
 
 
-/** gp_default_arena
- */
-rtl_arena_type * gp_default_arena = 0;
-
-
 /* ================================================================= */
 
 /** rtl_arena_segment_constructor()
  */
-static int
+int
 rtl_arena_segment_constructor (void * obj)
 {
     rtl_arena_segment_type * segment = (rtl_arena_segment_type*)(obj);
@@ -107,7 +108,7 @@ rtl_arena_segment_constructor (void * obj)
 
 /** rtl_arena_segment_destructor()
  */
-static void
+void
 rtl_arena_segment_destructor (void * obj)
 {
     rtl_arena_segment_type * segment = static_cast< rtl_arena_segment_type * >(
@@ -123,7 +124,7 @@ rtl_arena_segment_destructor (void * obj)
  *
  *  @precond  arena->m_lock acquired.
  */
-static int
+int
 rtl_arena_segment_populate (
     rtl_arena_type * arena
 )
@@ -165,7 +166,7 @@ rtl_arena_segment_populate (
  *  @precond  arena->m_lock acquired.
  *  @precond  (*ppSegment == 0)
  */
-static RTL_MEMORY_INLINE void
+inline void
 rtl_arena_segment_get (
     rtl_arena_type *          arena,
     rtl_arena_segment_type ** ppSegment
@@ -183,17 +184,12 @@ rtl_arena_segment_get (
     }
 }
 
-#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma inline(rtl_arena_segment_get)
-#endif
-
-
 /** rtl_arena_segment_put()
  *
  *  @precond  arena->m_lock acquired.
  *  @postcond (*ppSegment == 0)
  */
-static RTL_MEMORY_INLINE void
+inline void
 rtl_arena_segment_put (
     rtl_arena_type *          arena,
     rtl_arena_segment_type ** ppSegment
@@ -218,17 +214,12 @@ rtl_arena_segment_put (
     (*ppSegment) = 0;
 }
 
-#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma inline(rtl_arena_segment_put)
-#endif
-
-/* ================================================================= */
 
 /** rtl_arena_freelist_insert()
  *
  *  @precond arena->m_lock acquired.
  */
-static RTL_MEMORY_INLINE void
+inline void
 rtl_arena_freelist_insert (
     rtl_arena_type *         arena,
     rtl_arena_segment_type * segment
@@ -242,16 +233,11 @@ rtl_arena_freelist_insert (
     arena->m_freelist_bitmap |= head->m_size;
 }
 
-#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma inline(rtl_arena_freelist_insert)
-#endif /* __SUNPRO_C */
-
-
 /** rtl_arena_freelist_remove()
  *
  *  @precond arena->m_lock acquired.
  */
-static RTL_MEMORY_INLINE void
+inline void
 rtl_arena_freelist_remove (
     rtl_arena_type *         arena,
     rtl_arena_segment_type * segment
@@ -269,11 +255,6 @@ rtl_arena_freelist_remove (
     QUEUE_REMOVE_NAMED(segment, f);
 }
 
-#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma inline(rtl_arena_freelist_remove)
-#endif /* __SUNPRO_C */
-
-
 /* ================================================================= */
 
 /** RTL_ARENA_HASH_INDEX()
@@ -288,7 +269,7 @@ rtl_arena_freelist_remove (
  *
  * @precond arena->m_lock released.
  */
-static void
+void
 rtl_arena_hash_rescale (
     rtl_arena_type * arena,
     sal_Size         new_size
@@ -356,7 +337,7 @@ rtl_arena_hash_rescale (
 /** rtl_arena_hash_insert()
  *  ...and update stats.
  */
-static RTL_MEMORY_INLINE void
+inline void
 rtl_arena_hash_insert (
     rtl_arena_type *         arena,
     rtl_arena_segment_type * segment
@@ -373,15 +354,10 @@ rtl_arena_hash_insert (
     arena->m_stats.m_mem_alloc += segment->m_size;
 }
 
-#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma inline(rtl_arena_hash_insert)
-#endif /* __SUNPRO_C */
-
-
 /** rtl_arena_hash_remove()
  *  ...and update stats.
  */
-static rtl_arena_segment_type *
+rtl_arena_segment_type *
 rtl_arena_hash_remove (
     rtl_arena_type * arena,
     sal_uIntPtr      addr,
@@ -445,7 +421,7 @@ rtl_arena_hash_remove (
  *  @precond arena->m_lock acquired
  *  @precond (*ppSegment == 0)
  */
-static int
+int
 rtl_arena_segment_alloc (
     rtl_arena_type *          arena,
     sal_Size                  size,
@@ -507,7 +483,7 @@ dequeue_and_leave:
  *  @precond arena->m_lock acquired
  *  @precond (*ppSegment == 0)
  */
-static int
+int
 rtl_arena_segment_create (
     rtl_arena_type *          arena,
     sal_Size                  size,
@@ -562,7 +538,7 @@ rtl_arena_segment_create (
  *  @precond arena->m_lock acquired
  *  @precond segment marked 'used'
  */
-static void
+void
 rtl_arena_segment_coalesce (
     rtl_arena_type *         arena,
     rtl_arena_segment_type * segment
@@ -614,7 +590,7 @@ rtl_arena_segment_coalesce (
 
 /** rtl_arena_constructor()
  */
-static void
+void
 rtl_arena_constructor (void * obj)
 {
     rtl_arena_type * arena = (rtl_arena_type*)(obj);
@@ -656,7 +632,7 @@ rtl_arena_constructor (void * obj)
 
 /** rtl_arena_destructor()
  */
-static void
+void
 rtl_arena_destructor (void * obj)
 {
     rtl_arena_type * arena = (rtl_arena_type*)(obj);
@@ -700,7 +676,7 @@ rtl_arena_destructor (void * obj)
 
 /** rtl_arena_activate()
  */
-static rtl_arena_type *
+rtl_arena_type *
 rtl_arena_activate (
     rtl_arena_type *   arena,
     const char *       name,
@@ -761,7 +737,7 @@ rtl_arena_activate (
 
 /** rtl_arena_deactivate()
  */
-static void
+void
 rtl_arena_deactivate (
     rtl_arena_type * arena
 )
@@ -886,6 +862,7 @@ rtl_arena_deactivate (
     }
 }
 
+} //namespace
 /* ================================================================= *
  *
  * arena implementation.
@@ -1140,9 +1117,12 @@ SAL_CALL rtl_arena_free (
 #define MAP_FAILED 0
 #endif /* SAL_UNX || SAL_W32 */
 
+namespace
+{
+
 /** rtl_machdep_alloc()
  */
-static void *
+void *
 SAL_CALL rtl_machdep_alloc (
     rtl_arena_type * pArena,
     sal_Size *       pSize
@@ -1195,7 +1175,7 @@ SAL_CALL rtl_machdep_alloc (
 
 /** rtl_machdep_free()
  */
-static void
+void
 SAL_CALL rtl_machdep_free (
     rtl_arena_type * pArena,
     void *           pAddr,
@@ -1215,9 +1195,8 @@ SAL_CALL rtl_machdep_free (
 #endif /* (SAL_UNX || SAL_W32) */
 }
 
-/** rtl_machdep_pagesize()
- */
-static sal_Size
+
+sal_Size
 rtl_machdep_pagesize()
 {
 #if defined(SAL_UNX)
@@ -1233,6 +1212,8 @@ rtl_machdep_pagesize()
 #endif /* (SAL_UNX || SAL_W32) */
 }
 
+} //namespace
+
 /* ================================================================= *
  *
  * arena initialization.
diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx
index 745c0a8..d514cfc 100644
--- a/sal/rtl/alloc_cache.cxx
+++ b/sal/rtl/alloc_cache.cxx
@@ -93,10 +93,10 @@ static rtl_cache_type * gp_cache_bufctl_cache = 0;
 #define RTL_CACHE_HASH_INDEX(cache, addr) \
     RTL_CACHE_HASH_INDEX_IMPL((addr), (cache)->m_hash_shift, (cache)->m_type_shift, ((cache)->m_hash_size - 1))
 
+namespace
+{
 
-/** rtl_cache_hash_rescale()
- */
-static void
+void
 rtl_cache_hash_rescale (
     rtl_cache_type * cache,
     sal_Size         new_size
@@ -161,9 +161,7 @@ rtl_cache_hash_rescale (
     }
 }
 
-/** rtl_cache_hash_insert()
- */
-static RTL_MEMORY_INLINE sal_uIntPtr
+inline sal_uIntPtr
 rtl_cache_hash_insert (
     rtl_cache_type *        cache,
     rtl_cache_bufctl_type * bufctl
@@ -179,14 +177,9 @@ rtl_cache_hash_insert (
     return (bufctl->m_addr);
 }
 
-#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma inline(rtl_cache_hash_insert)
-#endif /* __SUNPRO_C */
-
-
 /** rtl_cache_hash_remove()
  */
-static rtl_cache_bufctl_type *
+rtl_cache_bufctl_type *
 rtl_cache_hash_remove (
     rtl_cache_type * cache,
     sal_uIntPtr      addr
@@ -243,7 +236,7 @@ rtl_cache_hash_remove (
 
 /** rtl_cache_slab_constructor()
  */
-static int
+int
 rtl_cache_slab_constructor (void * obj, SAL_UNUSED_PARAMETER void *)
 {
     rtl_cache_slab_type * slab = (rtl_cache_slab_type*)(obj);
@@ -257,7 +250,7 @@ rtl_cache_slab_constructor (void * obj, SAL_UNUSED_PARAMETER void *)
 
 /** rtl_cache_slab_destructor()
  */
-static void
+void
 rtl_cache_slab_destructor (void * obj, SAL_UNUSED_PARAMETER void *)
 {
     rtl_cache_slab_type * slab = static_cast< rtl_cache_slab_type * >(obj);
@@ -271,7 +264,7 @@ rtl_cache_slab_destructor (void * obj, SAL_UNUSED_PARAMETER void *)
  *
  *  @precond cache->m_slab_lock released.
  */
-static rtl_cache_slab_type *
+rtl_cache_slab_type *
 rtl_cache_slab_create (
     rtl_cache_type * cache
 )
@@ -319,7 +312,7 @@ rtl_cache_slab_create (
  *
  *  @precond cache->m_slab_lock released.
  */
-static void
+void
 rtl_cache_slab_destroy (
     rtl_cache_type *      cache,
     rtl_cache_slab_type * slab
@@ -365,7 +358,7 @@ rtl_cache_slab_destroy (
  *
  *  @precond cache->m_slab_lock acquired.
  */
-static int
+int
 rtl_cache_slab_populate (
     rtl_cache_type * cache
 )
@@ -400,7 +393,7 @@ rtl_cache_slab_populate (
  *
  *  Allocate a buffer from slab layer; used by magazine layer.
  */
-static void *
+void *
 rtl_cache_slab_alloc (
     rtl_cache_type * cache
 )
@@ -485,7 +478,7 @@ rtl_cache_slab_alloc (
  *
  *  Return a buffer to slab layer; used by magazine layer.
  */
-static void
+void
 rtl_cache_slab_free (
     rtl_cache_type * cache,
     void *           addr
@@ -552,7 +545,7 @@ rtl_cache_slab_free (
 
 /** rtl_cache_magazine_constructor()
  */
-static int
+int
 rtl_cache_magazine_constructor (void * obj, SAL_UNUSED_PARAMETER void *)
 {
     rtl_cache_magazine_type * mag = (rtl_cache_magazine_type*)(obj);
@@ -568,7 +561,7 @@ rtl_cache_magazine_constructor (void * obj, SAL_UNUSED_PARAMETER void *)
 
 /** rtl_cache_magazine_destructor()
  */
-static void
+void
 rtl_cache_magazine_destructor (void * obj, SAL_UNUSED_PARAMETER void *)
 {
     rtl_cache_magazine_type * mag = static_cast< rtl_cache_magazine_type * >(
@@ -581,7 +574,7 @@ rtl_cache_magazine_destructor (void * obj, SAL_UNUSED_PARAMETER void *)
 
 /** rtl_cache_magazine_clear()
  */
-static void
+void
 rtl_cache_magazine_clear (
     rtl_cache_type *          cache,
     rtl_cache_magazine_type * mag
@@ -609,7 +602,7 @@ rtl_cache_magazine_clear (
  *
  *  @precond cache->m_depot_lock acquired.
  */
-static RTL_MEMORY_INLINE void
+inline void
 rtl_cache_depot_enqueue (
     rtl_cache_depot_type *    depot,
     rtl_cache_magazine_type * mag
@@ -632,7 +625,7 @@ rtl_cache_depot_enqueue (
  *
  *  @precond cache->m_depot_lock acquired.
  */
-static RTL_MEMORY_INLINE rtl_cache_magazine_type *
+inline rtl_cache_magazine_type *
 rtl_cache_depot_dequeue (
     rtl_cache_depot_type * depot
 )
@@ -666,7 +659,7 @@ rtl_cache_depot_dequeue (
  *
  *  @precond cache->m_depot_lock acquired.
  */
-static RTL_MEMORY_INLINE rtl_cache_magazine_type *
+inline rtl_cache_magazine_type *
 rtl_cache_depot_exchange_alloc (
     rtl_cache_type *          cache,
     rtl_cache_magazine_type * empty
@@ -689,16 +682,11 @@ rtl_cache_depot_exchange_alloc (
     return (full);
 }
 
-#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma inline(rtl_cache_depot_exchange_alloc)
-#endif /* __SUNPRO_C */
-
-
 /** rtl_cache_depot_exchange_free()
  *
  *  @precond cache->m_depot_lock acquired.
  */
-static RTL_MEMORY_INLINE rtl_cache_magazine_type *
+inline rtl_cache_magazine_type *
 rtl_cache_depot_exchange_free (
     rtl_cache_type *          cache,
     rtl_cache_magazine_type * full
@@ -730,7 +718,7 @@ rtl_cache_depot_exchange_free (
  *
  *  @precond cache->m_depot_lock acquired.
  */
-static int
+int
 rtl_cache_depot_populate (
     rtl_cache_type * cache
 )
@@ -756,7 +744,7 @@ rtl_cache_depot_populate (
 
 /** rtl_cache_constructor()
  */
-static int
+int
 rtl_cache_constructor (void * obj)
 {
     rtl_cache_type * cache = (rtl_cache_type*)(obj);
@@ -784,7 +772,7 @@ rtl_cache_constructor (void * obj)
 
 /** rtl_cache_destructor()
  */
-static void
+void
 rtl_cache_destructor (void * obj)
 {
     rtl_cache_type * cache = (rtl_cache_type*)(obj);
@@ -810,7 +798,7 @@ rtl_cache_destructor (void * obj)
 
 /** rtl_cache_activate()
  */
-static rtl_cache_type *
+rtl_cache_type *
 rtl_cache_activate (
     rtl_cache_type * cache,
     const char *     name,
@@ -932,7 +920,7 @@ rtl_cache_activate (
 
 /** rtl_cache_deactivate()
  */
-static void
+void
 rtl_cache_deactivate (
     rtl_cache_type * cache
 )
@@ -1067,6 +1055,8 @@ rtl_cache_deactivate (
     }
 }
 
+} //namespace
+
 /* ================================================================= *
  *
  * cache implementation.
diff --git a/sal/rtl/alloc_impl.hxx b/sal/rtl/alloc_impl.hxx
index 6e38839..4101df7 100644
--- a/sal/rtl/alloc_impl.hxx
+++ b/sal/rtl/alloc_impl.hxx
@@ -51,21 +51,6 @@
 #define RTL_MEMORY_P2END(value, align) \
     (-(~(sal_IntPtr)(value) & -(sal_IntPtr)(align)))
 
-
-/** Function inlining macros
- *  (compiler dependent)
- */
-#ifndef RTL_MEMORY_INLINE
-#if defined(__GNUC__)
-#define RTL_MEMORY_INLINE __inline__
-#elif defined(_MSC_VER)
-#define RTL_MEMORY_INLINE __inline
-#else
-#define RTL_MEMORY_INLINE
-#endif /* __GNUC__ || _MSC_VER */
-#endif /* RTL_MEMORY_INLINE */
-
-
 /** printf() format specifier(s)
  *  (from C90 <sys/int_fmtio.h>)
  */
@@ -77,11 +62,10 @@
 #endif /* !_MSC_VER */
 #endif /* PRIu64 */
 
-
 /** highbit(): log2() + 1
  *  (complexity O(1))
  */
-static RTL_MEMORY_INLINE int
+static inline int
 highbit(sal_Size n)
 {
   int k = 1;
@@ -106,15 +90,10 @@ highbit(sal_Size n)
   return (k);
 }
 
-#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma inline(highbit)
-#endif /* __SUNPRO_C */
-
-
 /** lowbit(): find first bit set
  *  (complexity O(1))
  */
-static RTL_MEMORY_INLINE int
+static inline int
 lowbit(sal_Size n)
 {
   int k = 1;
@@ -138,11 +117,6 @@ lowbit(sal_Size n)
   return (k);
 }
 
-#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma inline(lowbit)
-#endif /* __SUNPRO_C */
-
-
 /** Queue manipulation macros
  *  (doubly linked circular list)
  *  (complexity O(1))


More information about the Libreoffice-commits mailing list