Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pull across changes within the XBMC project.

  • Loading branch information...
commit 5991469bcc20cff93140f94c84a7918d3f67df40 1 parent 22d1ad0
David Teirney authored
View
17 include/refmem/atomic.h
@@ -20,7 +20,12 @@
#ifndef __MVP_ATOMIC_H
#define __MVP_ATOMIC_H
+#ifdef __APPLE__
+#pragma GCC optimization_level 0
+#endif
+
#if defined(_MSC_VER)
+#include <windows.h>
#define inline __inline
#endif
@@ -62,7 +67,7 @@ __mvp_atomic_increment(mvp_atomic_t *valp)
: "memory");
/* on the x86 __val is the pre-increment value, so normalize it. */
++__val;
-#elif defined __powerpc__
+#elif defined __powerpc__ || defined __ppc__
asm volatile ("1: lwarx %0,0,%1\n"
" addic. %0,%0,1\n"
" dcbt %0,%1\n"
@@ -72,6 +77,8 @@ __mvp_atomic_increment(mvp_atomic_t *valp)
: "=&r" (__val)
: "r" (valp)
: "cc", "memory");
+#elif defined _MSC_VER
+ __val = InterlockedIncrement(valp);
#elif defined ANDROID
__val = __atomic_inc(valp) + 1;
#elif defined __arm__ && !defined __thumb__
@@ -130,7 +137,7 @@ __mvp_atomic_decrement(mvp_atomic_t *valp)
: "memory");
/* __val is the pre-decrement value, so normalize it */
--__val;
-#elif defined __powerpc__
+#elif defined __powerpc__ || defined __ppc__
asm volatile ("1: lwarx %0,0,%1\n"
" addic. %0,%0,-1\n"
" dcbt %0,%1\n"
@@ -171,6 +178,8 @@ __mvp_atomic_decrement(mvp_atomic_t *valp)
while (__newval != __oldval);
/* The value for __val is in '__oldval' */
__val = __oldval;
+#elif defined _MSC_VER
+ __val = InterlockedDecrement(valp);
#elif defined __GNUC__
/*
* Don't know how to atomic decrement for a generic architecture
@@ -212,4 +221,8 @@ static inline int mvp_atomic_val(mvp_atomic_t *a) {
return *a;
};
+#ifdef __APPLE__
+#pragma GCC optimization_level reset
+#endif
+
#endif /* __MVP_ATOMIC_H */
View
2  include/refmem/refmem.h
@@ -24,7 +24,7 @@
#ifndef __REFMEM_H
#define __REFMEM_H
-#include <refmem/atomic.h>
+#include "atomic.h"
/*
* -----------------------------------------------------------------
View
17 librefmem/alloc.c
@@ -59,6 +59,12 @@
#endif
#endif /* DEBUG */
+/* Disable optimization on OSX ppc
+ Compilation fails in release mode both with Apple gcc build 5490 and 5493 */
+#if defined(__APPLE__) && defined(__ppc__)
+#pragma GCC optimization_level 0
+#endif
+
static mvp_atomic_t total_refcount=0;
static mvp_atomic_t total_bytecount=0;
/*
@@ -326,7 +332,8 @@ ref_realloc(void *p, size_t len)
refmem_dbg(REF_DBG_DEBUG, "%s(%d, ret = %p, ref = %p) {\n",
__FUNCTION__, len, ret, ref);
#ifdef DEBUG
- assert(ref->magic == ALLOC_MAGIC);
+ if(p)
+ assert(ref->magic == ALLOC_MAGIC);
#endif /* DEBUG */
if (p && ret) {
memcpy(ret, p, ref->length);
@@ -522,8 +529,8 @@ ref_release(void *p)
ref_remove(ref);
ref->next = NULL;
#endif /* DEBUG */
-/* Remove its bytes */
- total_bytecount -= ( sizeof(refcounter_t) + ref->length);
+ /* Remove its bytes */
+ total_bytecount -= ( sizeof(refcounter_t) + ref->length);
free(block);
}
if (refcount < 0)
@@ -532,3 +539,7 @@ ref_release(void *p)
}
refmem_dbg(REF_DBG_DEBUG, "%s(%p) }\n", __FUNCTION__, p);
}
+
+#if defined(__APPLE__) && defined(__ppc__)
+#pragma GCC optimization_level reset
+#endif

0 comments on commit 5991469

Please sign in to comment.
Something went wrong with that request. Please try again.