[Openmp-commits] [openmp] r264777 - Fix incorrect indention in kmp_alloc.c

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Tue Mar 29 13:10:01 PDT 2016


Author: jlpeyton
Date: Tue Mar 29 15:10:00 2016
New Revision: 264777

URL: http://llvm.org/viewvc/llvm-project?rev=264777&view=rev
Log:
Fix incorrect indention in kmp_alloc.c

Modified:
    openmp/trunk/runtime/src/kmp_alloc.c

Modified: openmp/trunk/runtime/src/kmp_alloc.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_alloc.c?rev=264777&r1=264776&r2=264777&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_alloc.c (original)
+++ openmp/trunk/runtime/src/kmp_alloc.c Tue Mar 29 15:10:00 2016
@@ -1427,8 +1427,7 @@ void *
 kmpc_malloc( size_t size )
 {
     void * ptr;
-        ptr = bget( __kmp_entry_thread(), (bufsize) size );
-
+    ptr = bget( __kmp_entry_thread(), (bufsize) size );
     return ptr;
 }
 
@@ -1436,8 +1435,7 @@ void *
 kmpc_calloc( size_t nelem, size_t elsize )
 {
     void * ptr;
-        ptr = bgetz( __kmp_entry_thread(), (bufsize) (nelem * elsize) );
-
+    ptr = bgetz( __kmp_entry_thread(), (bufsize) (nelem * elsize) );
     return ptr;
 }
 
@@ -1445,19 +1443,17 @@ void *
 kmpc_realloc( void * ptr, size_t size )
 {
     void * result = NULL;
-
-        if ( ptr == NULL ) {
-            // If pointer is NULL, realloc behaves like malloc.
-            result = bget( __kmp_entry_thread(), (bufsize) size );
-        } else if ( size == 0 ) {
-            // If size is 0, realloc behaves like free.
-            // The thread must be registered by the call to kmpc_malloc() or kmpc_calloc() before.
-            // So it should be safe to call __kmp_get_thread(), not __kmp_entry_thread().
-            brel( __kmp_get_thread(), ptr );
-        } else {
-            result = bgetr( __kmp_entry_thread(), ptr, (bufsize) size );
-        }; // if
-
+    if ( ptr == NULL ) {
+        // If pointer is NULL, realloc behaves like malloc.
+        result = bget( __kmp_entry_thread(), (bufsize) size );
+    } else if ( size == 0 ) {
+        // If size is 0, realloc behaves like free.
+        // The thread must be registered by the call to kmpc_malloc() or kmpc_calloc() before.
+        // So it should be safe to call __kmp_get_thread(), not __kmp_entry_thread().
+        brel( __kmp_get_thread(), ptr );
+    } else {
+        result = bgetr( __kmp_entry_thread(), ptr, (bufsize) size );
+    }; // if
     return result;
 }
 
@@ -1470,9 +1466,9 @@ kmpc_free( void * ptr )
         return;
     }; // if
     if ( ptr != NULL ) {
-            kmp_info_t *th = __kmp_get_thread();
-            __kmp_bget_dequeue( th );         /* Release any queued buffers */
-            brel( th, ptr );
+        kmp_info_t *th = __kmp_get_thread();
+        __kmp_bget_dequeue( th );         /* Release any queued buffers */
+        brel( th, ptr );
     };
 }
 
@@ -1489,7 +1485,7 @@ ___kmp_thread_malloc( kmp_info_t *th, si
         (int) size
         KMP_SRC_LOC_PARM
     ) );
-        ptr = bget( th, (bufsize) size );
+    ptr = bget( th, (bufsize) size );
     KE_TRACE( 30, ( "<- __kmp_thread_malloc() returns %p\n", ptr ) );
     return ptr;
 }
@@ -1505,7 +1501,7 @@ ___kmp_thread_calloc( kmp_info_t *th, si
         (int) elsize
         KMP_SRC_LOC_PARM
     ) );
-        ptr = bgetz( th, (bufsize) (nelem * elsize) );
+    ptr = bgetz( th, (bufsize) (nelem * elsize) );
     KE_TRACE( 30, ( "<- __kmp_thread_calloc() returns %p\n", ptr ) );
     return ptr;
 }
@@ -1520,7 +1516,7 @@ ___kmp_thread_realloc( kmp_info_t *th, v
         (int) size
         KMP_SRC_LOC_PARM
     ) );
-        ptr = bgetr( th, ptr, (bufsize) size );
+    ptr = bgetr( th, ptr, (bufsize) size );
     KE_TRACE( 30, ( "<- __kmp_thread_realloc() returns %p\n", ptr ) );
     return ptr;
 }
@@ -1535,8 +1531,8 @@ ___kmp_thread_free( kmp_info_t *th, void
         KMP_SRC_LOC_PARM
     ) );
     if ( ptr != NULL ) {
-            __kmp_bget_dequeue( th );         /* Release any queued buffers */
-            brel( th, ptr );
+        __kmp_bget_dequeue( th );         /* Release any queued buffers */
+        brel( th, ptr );
     }
     KE_TRACE( 30, ( "<- __kmp_thread_free()\n" ) );
 }
@@ -1602,11 +1598,11 @@ ___kmp_allocate_align( size_t size, size
     descr.size_aligned = size;
     descr.size_allocated = descr.size_aligned + sizeof( kmp_mem_descr_t ) + alignment;
 
-    #if KMP_DEBUG
-        descr.ptr_allocated = _malloc_src_loc( descr.size_allocated, _file_, _line_ );
-    #else
+#if KMP_DEBUG
+    descr.ptr_allocated = _malloc_src_loc( descr.size_allocated, _file_, _line_ );
+#else
     descr.ptr_allocated = malloc_src_loc( descr.size_allocated KMP_SRC_LOC_PARM );
-    #endif
+#endif
     KE_TRACE( 10, (
         "   malloc( %d ) returned %p\n",
         (int) descr.size_allocated,
@@ -1638,11 +1634,10 @@ ___kmp_allocate_align( size_t size, size
     KMP_DEBUG_ASSERT( addr_descr + sizeof( kmp_mem_descr_t ) == addr_aligned );
     KMP_DEBUG_ASSERT( addr_aligned + descr.size_aligned <= addr_allocated + descr.size_allocated );
     KMP_DEBUG_ASSERT( addr_aligned % alignment == 0 );
-
-    #ifdef KMP_DEBUG
-        memset( descr.ptr_allocated, 0xEF, descr.size_allocated );
-            // Fill allocated memory block with 0xEF.
-    #endif
+#ifdef KMP_DEBUG
+    memset( descr.ptr_allocated, 0xEF, descr.size_allocated );
+        // Fill allocated memory block with 0xEF.
+#endif
     memset( descr.ptr_aligned, 0x00, descr.size_aligned );
         // Fill the aligned memory block (which is intended for using by caller) with 0x00. Do not
         // put this filling under KMP_DEBUG condition! Many callers expect zeroed memory. (Padding
@@ -1653,7 +1648,6 @@ ___kmp_allocate_align( size_t size, size
 
     KE_TRACE( 25, ( "<- ___kmp_allocate_align() returns %p\n", descr.ptr_aligned ) );
     return descr.ptr_aligned;
-
 } // func ___kmp_allocate_align
 
 
@@ -1666,13 +1660,11 @@ ___kmp_allocate_align( size_t size, size
 void *
 ___kmp_allocate( size_t size KMP_SRC_LOC_DECL )
 {
-
     void * ptr;
     KE_TRACE( 25, ( "-> __kmp_allocate( %d ) called from %s:%d\n", (int) size KMP_SRC_LOC_PARM ) );
-        ptr = ___kmp_allocate_align( size, __kmp_align_alloc KMP_SRC_LOC_PARM );
+    ptr = ___kmp_allocate_align( size, __kmp_align_alloc KMP_SRC_LOC_PARM );
     KE_TRACE( 25, ( "<- __kmp_allocate() returns %p\n", ptr ) );
     return ptr;
-
 } // func ___kmp_allocate
 
 #if (BUILD_MEMORY==FIRST_TOUCH)
@@ -1726,7 +1718,7 @@ ___kmp_page_allocate( size_t size KMP_SR
         (int) size
         KMP_SRC_LOC_PARM
     ) );
-        ptr = ___kmp_allocate_align( size, page_size KMP_SRC_LOC_PARM );
+    ptr = ___kmp_allocate_align( size, page_size KMP_SRC_LOC_PARM );
     KE_TRACE( 25, ( "<- __kmp_page_allocate( %d ) returns %p\n", (int) size, ptr ) );
     return ptr;
 } // ___kmp_page_allocate
@@ -1738,49 +1730,45 @@ ___kmp_page_allocate( size_t size KMP_SR
 void
 ___kmp_free( void * ptr KMP_SRC_LOC_DECL )
 {
+    kmp_mem_descr_t descr;
+    kmp_uintptr_t   addr_allocated;        // Address returned by malloc().
+    kmp_uintptr_t   addr_aligned;          // Aligned address passed by caller.
+
+    KE_TRACE( 25, ( "-> __kmp_free( %p ) called from %s:%d\n", ptr KMP_SRC_LOC_PARM ) );
+    KMP_ASSERT( ptr != NULL );
+
+    descr = * ( kmp_mem_descr_t *) ( (kmp_uintptr_t) ptr - sizeof( kmp_mem_descr_t ) );
+
+    KE_TRACE( 26, ( "   __kmp_free:     "
+                    "ptr_allocated=%p, size_allocated=%d, "
+                    "ptr_aligned=%p, size_aligned=%d\n",
+                    descr.ptr_allocated, (int) descr.size_allocated,
+                    descr.ptr_aligned, (int) descr.size_aligned ));
 
-        kmp_mem_descr_t descr;
-        kmp_uintptr_t   addr_allocated;        // Address returned by malloc().
-        kmp_uintptr_t   addr_aligned;          // Aligned address passed by caller.
-
-        KE_TRACE( 25, ( "-> __kmp_free( %p ) called from %s:%d\n", ptr KMP_SRC_LOC_PARM ) );
-        KMP_ASSERT( ptr != NULL );
-
-        descr = * ( kmp_mem_descr_t *) ( (kmp_uintptr_t) ptr - sizeof( kmp_mem_descr_t ) );
-
-        KE_TRACE( 26, ( "   __kmp_free:     "
-                        "ptr_allocated=%p, size_allocated=%d, "
-                        "ptr_aligned=%p, size_aligned=%d\n",
-                        descr.ptr_allocated, (int) descr.size_allocated,
-                        descr.ptr_aligned, (int) descr.size_aligned ));
-
-        addr_allocated = (kmp_uintptr_t) descr.ptr_allocated;
-        addr_aligned   = (kmp_uintptr_t) descr.ptr_aligned;
-
-        KMP_DEBUG_ASSERT( addr_aligned % CACHE_LINE == 0 );
-        KMP_DEBUG_ASSERT( descr.ptr_aligned == ptr );
-        KMP_DEBUG_ASSERT( addr_allocated + sizeof( kmp_mem_descr_t ) <= addr_aligned );
-        KMP_DEBUG_ASSERT( descr.size_aligned < descr.size_allocated );
-        KMP_DEBUG_ASSERT( addr_aligned + descr.size_aligned <= addr_allocated + descr.size_allocated );
-
-        #ifdef KMP_DEBUG
-            memset( descr.ptr_allocated, 0xEF, descr.size_allocated );
-                // Fill memory block with 0xEF, it helps catch using freed memory.
-        #endif
-
-        #ifndef LEAK_MEMORY
-            KE_TRACE( 10, ( "   free( %p )\n", descr.ptr_allocated ) );
-        # ifdef KMP_DEBUG
-            _free_src_loc( descr.ptr_allocated, _file_, _line_ );
-        # else
-            free_src_loc( descr.ptr_allocated KMP_SRC_LOC_PARM );
-        # endif
-        #endif
+    addr_allocated = (kmp_uintptr_t) descr.ptr_allocated;
+    addr_aligned   = (kmp_uintptr_t) descr.ptr_aligned;
 
-    KMP_MB();
+    KMP_DEBUG_ASSERT( addr_aligned % CACHE_LINE == 0 );
+    KMP_DEBUG_ASSERT( descr.ptr_aligned == ptr );
+    KMP_DEBUG_ASSERT( addr_allocated + sizeof( kmp_mem_descr_t ) <= addr_aligned );
+    KMP_DEBUG_ASSERT( descr.size_aligned < descr.size_allocated );
+    KMP_DEBUG_ASSERT( addr_aligned + descr.size_aligned <= addr_allocated + descr.size_allocated );
 
-    KE_TRACE( 25, ( "<- __kmp_free() returns\n" ) );
+    #ifdef KMP_DEBUG
+        memset( descr.ptr_allocated, 0xEF, descr.size_allocated );
+            // Fill memory block with 0xEF, it helps catch using freed memory.
+    #endif
 
+    #ifndef LEAK_MEMORY
+        KE_TRACE( 10, ( "   free( %p )\n", descr.ptr_allocated ) );
+    # ifdef KMP_DEBUG
+        _free_src_loc( descr.ptr_allocated, _file_, _line_ );
+    # else
+        free_src_loc( descr.ptr_allocated KMP_SRC_LOC_PARM );
+    # endif
+    #endif
+    KMP_MB();
+    KE_TRACE( 25, ( "<- __kmp_free() returns\n" ) );
 } // func ___kmp_free
 
 /* ------------------------------------------------------------------------ */




More information about the Openmp-commits mailing list