diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-05-23 05:33:34 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-05-23 05:33:34 +0000 |
commit | 9886815a25d84be79f51e65ebd8e458bb5d26ca8 (patch) | |
tree | a65edf018dd992543337433f7303fb29a6c8e8cf /lib/mesa/src/gallium/auxiliary/os | |
parent | e2a3acb64af2657b1181806818eacad061103c23 (diff) |
Merge Mesa 19.0.5
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/os')
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/os/os_memory.h | 80 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/os/os_memory_aligned.h | 98 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/os/os_memory_debug.h | 92 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/os/os_memory_stdc.h | 76 |
4 files changed, 0 insertions, 346 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/os/os_memory.h b/lib/mesa/src/gallium/auxiliary/os/os_memory.h deleted file mode 100644 index 46a6b6e45..000000000 --- a/lib/mesa/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/lib/mesa/src/gallium/auxiliary/os/os_memory_aligned.h b/lib/mesa/src/gallium/auxiliary/os/os_memory_aligned.h deleted file mode 100644 index f7d0e3652..000000000 --- a/lib/mesa/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 align_malloc(). - */ -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/lib/mesa/src/gallium/auxiliary/os/os_memory_debug.h b/lib/mesa/src/gallium/auxiliary/os/os_memory_debug.h deleted file mode 100644 index 9a487dec0..000000000 --- a/lib/mesa/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/lib/mesa/src/gallium/auxiliary/os/os_memory_stdc.h b/lib/mesa/src/gallium/auxiliary/os/os_memory_stdc.h deleted file mode 100644 index c9fde06d8..000000000 --- a/lib/mesa/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 |