summaryrefslogtreecommitdiff
path: root/indra/llcommon/llmemory.h
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-05-21 15:11:16 +0100
committerTofu Linden <tofu.linden@lindenlab.com>2010-05-21 15:11:16 +0100
commitab31e3bb217089e0cc28ca57bb5c4e46c06789dd (patch)
treeb398183e8f5a7ecf5593c6bb0a2a73cf3f2f1073 /indra/llcommon/llmemory.h
parentcd13bc0e044d5014a0d7e131ae9d47924e376997 (diff)
Fix up the SSE stuff so it compiles on Linux. Though I don't think it actually works properly.
Diffstat (limited to 'indra/llcommon/llmemory.h')
-rw-r--r--indra/llcommon/llmemory.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 1c6f64dd8b..f0813fb4ee 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -32,14 +32,33 @@
#ifndef LLMEMORY_H
#define LLMEMORY_H
+#include <stdlib.h>
+inline void* ll_aligned_malloc(size_t size, size_t alignment = 16) // alignment MUST be power-of-two multiple of sizeof(void*). returned hunk MUST be freed with ll_aligned_free().
+{
+#if defined(LL_WINDOWS)
+ return _mm_malloc(size, alignment);
+#else
+ void *rtn;
+ if (LL_LIKELY(0 == posix_memalign(&rtn, alignment, size)))
+ {
+ return rtn;
+ }
+ else // bad alignment requested, or out of memory
+ {
+ return NULL;
+ }
+#endif
+}
-extern S32 gTotalDAlloc;
-extern S32 gTotalDAUse;
-extern S32 gDACount;
-
-extern void* ll_allocate (size_t size);
-extern void ll_release (void *p);
+inline void ll_aligned_free(void *p)
+{
+#if defined(LL_WINDOWS)
+ _mm_free(p);
+#else
+ free(p); // posix_memalign() is compatible with heap deallocator
+#endif
+}
class LL_COMMON_API LLMemory
{