aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/os
diff options
context:
space:
mode:
authorDylan Baker <[email protected]>2018-11-09 10:40:15 -0800
committerRob Clark <[email protected]>2018-11-27 15:44:02 -0500
commit88c4680b5a50ea8840c38aa0a80acde63ef1677b (patch)
tree091b7d017b915fcdafd315288a2114a8169c3a3f /src/gallium/auxiliary/os
parentbade179153b10300129c93afb1e629d9814c122e (diff)
util: promote u_memory to src/util
as well as os_memory* Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/os')
-rw-r--r--src/gallium/auxiliary/os/os_memory.h80
-rw-r--r--src/gallium/auxiliary/os/os_memory_aligned.h98
-rw-r--r--src/gallium/auxiliary/os/os_memory_debug.h92
-rw-r--r--src/gallium/auxiliary/os/os_memory_stdc.h76
4 files changed, 0 insertions, 346 deletions
diff --git a/src/gallium/auxiliary/os/os_memory.h b/src/gallium/auxiliary/os/os_memory.h
deleted file mode 100644
index 46a6b6e4572..00000000000
--- a/src/gallium/auxiliary/os/os_memory.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Vmware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/*
- * OS memory management abstractions
- */
-
-
-#ifndef _OS_MEMORY_H_
-#define _OS_MEMORY_H_
-
-
-#include "pipe/p_config.h"
-#include "pipe/p_compiler.h"
-
-
-#if defined(PIPE_SUBSYSTEM_EMBEDDED)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void *
-os_malloc(size_t size);
-
-void *
-os_calloc(size_t count, size_t size);
-
-void
-os_free(void *ptr);
-
-void *
-os_realloc(void *ptr, size_t old_size, size_t new_size);
-
-void *
-os_malloc_aligned(size_t size, size_t alignment);
-
-void
-os_free_aligned(void *ptr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#elif defined(PIPE_OS_WINDOWS) && defined(DEBUG) && !defined(DEBUG_MEMORY_IMPLEMENTATION)
-
-# include "os_memory_debug.h"
-
-#else
-
-# include "os_memory_stdc.h"
-
-#endif
-
-#endif /* _OS_MEMORY_H_ */
diff --git a/src/gallium/auxiliary/os/os_memory_aligned.h b/src/gallium/auxiliary/os/os_memory_aligned.h
deleted file mode 100644
index df398a32bfd..00000000000
--- a/src/gallium/auxiliary/os/os_memory_aligned.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/*
- * Memory alignment wrappers.
- */
-
-
-#ifndef _OS_MEMORY_H_
-#error "Must not be included directly. Include os_memory.h instead"
-#endif
-
-
-#include "pipe/p_compiler.h"
-
-
-
-/**
- * Add two size_t values with integer overflow check.
- * TODO: leverage __builtin_add_overflow where available
- */
-static inline bool
-add_overflow_size_t(size_t a, size_t b, size_t *res)
-{
- *res = a + b;
- return *res < a || *res < b;
-}
-
-
-/**
- * Return memory on given byte alignment
- */
-static inline void *
-os_malloc_aligned(size_t size, size_t alignment)
-{
- char *ptr, *buf;
- size_t alloc_size;
-
- /*
- * Calculate
- *
- * alloc_size = size + alignment + sizeof(void *)
- *
- * while checking for overflow.
- */
- if (add_overflow_size_t(size, alignment, &alloc_size) ||
- add_overflow_size_t(alloc_size, sizeof(void *), &alloc_size)) {
- return NULL;
- }
-
- ptr = (char *) os_malloc(alloc_size);
- if (!ptr)
- return NULL;
-
- buf = (char *)(((uintptr_t)ptr + sizeof(void *) + alignment - 1) & ~((uintptr_t)(alignment - 1)));
- *(char **)(buf - sizeof(void *)) = ptr;
-
- return buf;
-}
-
-
-/**
- * Free memory returned by os_malloc_aligned().
- */
-static inline void
-os_free_aligned(void *ptr)
-{
- if (ptr) {
- void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
- void *realAddr = *cubbyHole;
- os_free(realAddr);
- }
-}
diff --git a/src/gallium/auxiliary/os/os_memory_debug.h b/src/gallium/auxiliary/os/os_memory_debug.h
deleted file mode 100644
index 9a487dec05c..00000000000
--- a/src/gallium/auxiliary/os/os_memory_debug.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/*
- * Debugging wrappers for OS memory management abstractions.
- */
-
-
-#ifndef _OS_MEMORY_H_
-#error "Must not be included directly. Include os_memory.h instead"
-#endif
-
-
-#include "pipe/p_compiler.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-void *
-debug_malloc(const char *file, unsigned line, const char *function,
- size_t size);
-
-void *
-debug_calloc(const char *file, unsigned line, const char *function,
- size_t count, size_t size );
-
-void
-debug_free(const char *file, unsigned line, const char *function,
- void *ptr);
-
-void *
-debug_realloc(const char *file, unsigned line, const char *function,
- void *old_ptr, size_t old_size, size_t new_size );
-
-void
-debug_memory_tag(void *ptr, unsigned tag);
-
-void
-debug_memory_check_block(void *ptr);
-
-void
-debug_memory_check(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#ifndef DEBUG_MEMORY_IMPLEMENTATION
-
-#define os_malloc( _size ) \
- debug_malloc( __FILE__, __LINE__, __FUNCTION__, _size )
-#define os_calloc( _count, _size ) \
- debug_calloc(__FILE__, __LINE__, __FUNCTION__, _count, _size )
-#define os_free( _ptr ) \
- debug_free( __FILE__, __LINE__, __FUNCTION__, _ptr )
-#define os_realloc( _ptr, _old_size, _new_size ) \
- debug_realloc( __FILE__, __LINE__, __FUNCTION__, _ptr, _old_size, _new_size )
-
-/* TODO: wrap os_malloc_aligned() and os_free_aligned() too */
-#include "os_memory_aligned.h"
-
-#endif /* !DEBUG_MEMORY_IMPLEMENTATION */
diff --git a/src/gallium/auxiliary/os/os_memory_stdc.h b/src/gallium/auxiliary/os/os_memory_stdc.h
deleted file mode 100644
index c9fde06d8ac..00000000000
--- a/src/gallium/auxiliary/os/os_memory_stdc.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/*
- * OS memory management abstractions for the standard C library.
- */
-
-
-#ifndef _OS_MEMORY_H_
-#error "Must not be included directly. Include os_memory.h instead"
-#endif
-
-#include <stdlib.h>
-
-#include "pipe/p_compiler.h"
-
-
-#define os_malloc(_size) malloc(_size)
-#define os_calloc(_count, _size ) calloc(_count, _size )
-#define os_free(_ptr) free(_ptr)
-
-#define os_realloc( _old_ptr, _old_size, _new_size) \
- realloc(_old_ptr, _new_size + 0*(_old_size))
-
-
-#if defined(HAVE_POSIX_MEMALIGN)
-
-static inline void *
-os_malloc_aligned(size_t size, size_t alignment)
-{
- void *ptr;
- alignment = (alignment + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
- if(posix_memalign(&ptr, alignment, size) != 0)
- return NULL;
- return ptr;
-}
-
-#define os_free_aligned(_ptr) free(_ptr)
-
-#elif defined(PIPE_OS_WINDOWS)
-
-#include <malloc.h>
-
-#define os_malloc_aligned(_size, _align) _aligned_malloc(_size, _align)
-#define os_free_aligned(_ptr) _aligned_free(_ptr)
-
-#else
-
-#include "os_memory_aligned.h"
-
-#endif