[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59170] branches/soc-2013-depsgraph_mt/ intern: Code cleanup: remove some ifdef code from guardedalloc

Sergey Sharybin sergey.vfx at gmail.com
Fri Aug 16 07:21:40 CEST 2013


Revision: 59170
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59170
Author:   nazgul
Date:     2013-08-16 05:21:40 +0000 (Fri, 16 Aug 2013)
Log Message:
-----------
Code cleanup: remove some ifdef code from guardedalloc

Didn't notice all needed functions are in atomic already.

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/intern/atomic/atomic_ops.h
    branches/soc-2013-depsgraph_mt/intern/guardedalloc/intern/mallocn.c

Modified: branches/soc-2013-depsgraph_mt/intern/atomic/atomic_ops.h
===================================================================
--- branches/soc-2013-depsgraph_mt/intern/atomic/atomic_ops.h	2013-08-15 22:29:56 UTC (rev 59169)
+++ branches/soc-2013-depsgraph_mt/intern/atomic/atomic_ops.h	2013-08-16 05:21:40 UTC (rev 59170)
@@ -45,7 +45,7 @@
 #endif
 
 /* TODO(sergey): check on other 64bit platforms. */
-#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__)
+#if defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__) || defined(__x86_64__)
 #  define LG_SIZEOF_PTR 3
 #  define LG_SIZEOF_INT 3
 #else

Modified: branches/soc-2013-depsgraph_mt/intern/guardedalloc/intern/mallocn.c
===================================================================
--- branches/soc-2013-depsgraph_mt/intern/guardedalloc/intern/mallocn.c	2013-08-15 22:29:56 UTC (rev 59169)
+++ branches/soc-2013-depsgraph_mt/intern/guardedalloc/intern/mallocn.c	2013-08-16 05:21:40 UTC (rev 59170)
@@ -212,21 +212,9 @@
 /* --------------------------------------------------------------------- */
 	
 
-/* TODO(sergey): need smarter check for 64bit platform. */
-#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__)
-typedef uint64_t mem_uintptr_t;
-#  define mem_atomic_uint_sub atomic_sub_uint64
-#  define mem_atomic_uint_add atomic_add_uint64
-#else
-typedef int32_t mem_int_t;
-typedef uint32_t mem_uintptr_t;
-#  define mem_atomic_uint_sub atomic_sub_uint32
-#  define mem_atomic_uint_add atomic_add_uint32
-#endif
+static unsigned int totblock = 0;
+static size_t mem_in_use = 0, mmap_in_use = 0, peak_mem = 0;
 
-static mem_uintptr_t totblock = 0;
-static mem_uintptr_t mem_in_use = 0, mmap_in_use = 0, peak_mem = 0;
-
 static volatile struct localListBase _membase;
 static volatile struct localListBase *membase = &_membase;
 static void (*error_callback)(const char *) = NULL;
@@ -508,8 +496,8 @@
 	memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + len);
 	memt->tag3 = MEMTAG3;
 
-	mem_atomic_uint_add(&totblock, 1);
-	mem_atomic_uint_add(&mem_in_use, len);
+	atomic_add_u(&totblock, 1);
+	atomic_add_z(&mem_in_use, len);
 
 	mem_lock_thread();
 	addtail(membase, &memh->next);
@@ -580,7 +568,7 @@
 	if (memh != (MemHead *)-1) {
 		make_memhead_header(memh, len, str);
 		memh->mmap = 1;
-		mem_atomic_uint_add(&mmap_in_use, len);
+		atomic_add_z(&mmap_in_use, len);
 		mem_lock_thread();
 		peak_mem = mmap_in_use > peak_mem ? mmap_in_use : peak_mem;
 		mem_unlock_thread();
@@ -939,8 +927,8 @@
 	}
 	mem_unlock_thread();
 
-	mem_atomic_uint_sub(&totblock, 1);
-	mem_atomic_uint_sub(&mem_in_use, memh->len);
+	atomic_sub_u(&totblock, 1);
+	atomic_sub_z(&mem_in_use, memh->len);
 
 #ifdef DEBUG_MEMDUPLINAME
 	if (memh->need_free_name)
@@ -948,7 +936,7 @@
 #endif
 
 	if (memh->mmap) {
-		mem_atomic_uint_sub(&mmap_in_use, memh->len);
+		atomic_sub_z(&mmap_in_use, memh->len);
 		if (munmap(memh, memh->len + sizeof(MemHead) + sizeof(MemTail)))
 			printf("Couldn't unmap memory %s\n", memh->name);
 	}




More information about the Bf-blender-cvs mailing list