[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59299] trunk/blender/intern/atomic/ atomic_ops.h: Apparently sizeof(unsigned) is 4 bytes on both 32 and 64 bit platforms
Sergey Sharybin
sergey.vfx at gmail.com
Mon Aug 19 16:03:44 CEST 2013
Revision: 59299
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59299
Author: nazgul
Date: 2013-08-19 14:03:44 +0000 (Mon, 19 Aug 2013)
Log Message:
-----------
Apparently sizeof(unsigned) is 4 bytes on both 32 and 64 bit platforms
For now assume sizeof(int) == 4 for all supported platforms, could be
changed in the future.
Added an assert to functions which depends on this this, so we'll
easily notice bad things happening.
Modified Paths:
--------------
trunk/blender/intern/atomic/atomic_ops.h
Modified: trunk/blender/intern/atomic/atomic_ops.h
===================================================================
--- trunk/blender/intern/atomic/atomic_ops.h 2013-08-19 13:41:05 UTC (rev 59298)
+++ trunk/blender/intern/atomic/atomic_ops.h 2013-08-19 14:03:44 UTC (rev 59299)
@@ -29,6 +29,8 @@
#ifndef ATOMIC_OPS_H__
#define ATOMIC_OPS_H__
+#include <assert.h>
+
#if defined (__APPLE__)
# include <libkern/OSAtomic.h>
#elif defined(_MSC_VER)
@@ -52,7 +54,7 @@
#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__)
# define LG_SIZEOF_PTR 3
-# define LG_SIZEOF_INT 3
+# define LG_SIZEOF_INT 2
#else
# define LG_SIZEOF_PTR 2
# define LG_SIZEOF_INT 2
@@ -251,6 +253,8 @@
ATOMIC_INLINE size_t
atomic_add_z(size_t *p, size_t x)
{
+ assert(sizeof(size_t) == 1 << LG_SIZEOF_PTR);
+
#if (LG_SIZEOF_PTR == 3)
return ((size_t)atomic_add_uint64((uint64_t *)p, (uint64_t)x));
#elif (LG_SIZEOF_PTR == 2)
@@ -261,6 +265,8 @@
ATOMIC_INLINE size_t
atomic_sub_z(size_t *p, size_t x)
{
+ assert(sizeof(size_t) == 1 << LG_SIZEOF_PTR);
+
#if (LG_SIZEOF_PTR == 3)
return ((size_t)atomic_add_uint64((uint64_t *)p,
(uint64_t)-((int64_t)x)));
@@ -275,6 +281,8 @@
ATOMIC_INLINE unsigned
atomic_add_u(unsigned *p, unsigned x)
{
+ assert(sizeof(unsigned) == 1 << LG_SIZEOF_INT);
+
#if (LG_SIZEOF_INT == 3)
return ((unsigned)atomic_add_uint64((uint64_t *)p, (uint64_t)x));
#elif (LG_SIZEOF_INT == 2)
@@ -285,6 +293,8 @@
ATOMIC_INLINE unsigned
atomic_sub_u(unsigned *p, unsigned x)
{
+ assert(sizeof(unsigned) == 1 << LG_SIZEOF_INT);
+
#if (LG_SIZEOF_INT == 3)
return ((unsigned)atomic_add_uint64((uint64_t *)p,
(uint64_t)-((int64_t)x)));
More information about the Bf-blender-cvs
mailing list