diff options
Diffstat (limited to 'src/mesa/main')
64 files changed, 64 insertions, 693 deletions
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c index 89ae31556d3..86d19c57d92 100644 --- a/src/mesa/main/accum.c +++ b/src/mesa/main/accum.c @@ -29,7 +29,7 @@ #include "format_unpack.h" #include "format_pack.h" #include "framebuffer.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "state.h" #include "mtypes.h" diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index 51a7d63b83e..022a1285c26 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -39,7 +39,7 @@ #include "api_arrayelt.h" #include "bufferobj.h" #include "context.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "mtypes.h" #include "main/dispatch.h" diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c index 1c8cc13d061..25de173784c 100644 --- a/src/mesa/main/arbprogram.c +++ b/src/mesa/main/arbprogram.c @@ -32,7 +32,7 @@ #include "main/glheader.h" #include "main/context.h" #include "main/hash.h" -#include "main/imports.h" +#include "util/imports.h" #include "main/macros.h" #include "main/mtypes.h" #include "main/arbprogram.h" diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 6dbd09b39ec..371ca7b04e3 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -43,7 +43,7 @@ #include "glheader.h" #include "hash.h" #include "image.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "bufferobj.h" #include "arrayobj.h" diff --git a/src/mesa/main/atifragshader.c b/src/mesa/main/atifragshader.c index 71c8ce5efdf..75998f97bb8 100644 --- a/src/mesa/main/atifragshader.c +++ b/src/mesa/main/atifragshader.c @@ -24,7 +24,7 @@ #include "main/glheader.h" #include "main/context.h" #include "main/hash.h" -#include "main/imports.h" +#include "util/imports.h" #include "main/macros.h" #include "main/enums.h" #include "main/mtypes.h" diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 133f1a8c424..c39412e9fe0 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -24,7 +24,7 @@ */ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "accum.h" #include "arrayobj.h" #include "attrib.h" diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index b5d6bb188d9..881a9d3e00e 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -36,7 +36,7 @@ #include "glheader.h" #include "enums.h" #include "hash.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "bufferobj.h" #include "externalobjects.h" diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h deleted file mode 100644 index 43a06b43139..00000000000 --- a/src/mesa/main/compiler.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - - -/** - * \file compiler.h - * Compiler-related stuff. - */ - - -#ifndef COMPILER_H -#define COMPILER_H - - -#include <assert.h> - -#include "util/macros.h" - -#include "c99_compat.h" /* inline, __func__, etc. */ - - -/** - * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. - * Do not use these unless absolutely necessary! - * Try to use a runtime test instead. - * For now, only used by some DRI hardware drivers for color/texel packing. - */ -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN -#if defined(__linux__) -#include <byteswap.h> -#define CPU_TO_LE32( x ) bswap_32( x ) -#elif defined(__APPLE__) -#include <CoreFoundation/CFByteOrder.h> -#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) -#elif defined(__OpenBSD__) -#include <sys/types.h> -#define CPU_TO_LE32( x ) htole32( x ) -#else /*__linux__ */ -#include <sys/endian.h> -#define CPU_TO_LE32( x ) bswap32( x ) -#endif /*__linux__*/ -#define MESA_BIG_ENDIAN 1 -#else -#define CPU_TO_LE32( x ) ( x ) -#define MESA_LITTLE_ENDIAN 1 -#endif -#define LE32_TO_CPU( x ) CPU_TO_LE32( x ) - - - -#define IEEE_ONE 0x3f800000 - - -#endif /* COMPILER_H */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index c183378d1d3..f9c8d22820a 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -77,7 +77,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "accum.h" #include "api_exec.h" #include "api_loopback.h" diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index bf39ef2d08e..a816131742e 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -50,7 +50,7 @@ #include "errors.h" -#include "imports.h" +#include "util/imports.h" #include "extensions.h" #include "mtypes.h" #include "vbo/vbo.h" diff --git a/src/mesa/main/cpuinfo.c b/src/mesa/main/cpuinfo.c index 67f22ab9c81..c085d3430d4 100644 --- a/src/mesa/main/cpuinfo.c +++ b/src/mesa/main/cpuinfo.c @@ -23,7 +23,7 @@ */ -#include "main/imports.h" +#include "util/imports.h" #include "main/cpuinfo.h" diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index c27d1b80357..66ee2841b03 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -30,7 +30,7 @@ #include "enums.h" #include "formats.h" #include "hash.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "debug.h" #include "get.h" diff --git a/src/mesa/main/debug_output.c b/src/mesa/main/debug_output.c index cd08015b73f..d643866c55a 100644 --- a/src/mesa/main/debug_output.c +++ b/src/mesa/main/debug_output.c @@ -28,7 +28,7 @@ #include "context.h" #include "debug_output.h" #include "enums.h" -#include "imports.h" +#include "util/imports.h" #include "hash.h" #include "mtypes.h" #include "version.h" diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c index 27bd4958253..f37d175b888 100644 --- a/src/mesa/main/depth.c +++ b/src/mesa/main/depth.c @@ -24,7 +24,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "depth.h" #include "enums.h" diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 0fe027f0afc..3abac73ebb9 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -31,7 +31,7 @@ #include "c99_math.h" #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "api_arrayelt.h" #include "api_exec.h" #include "api_loopback.h" diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c index 779cd1c12c7..523281f7012 100644 --- a/src/mesa/main/draw_validate.c +++ b/src/mesa/main/draw_validate.c @@ -28,7 +28,7 @@ #include "arrayobj.h" #include "bufferobj.h" #include "context.h" -#include "imports.h" +#include "util/imports.h" #include "mtypes.h" #include "pipelineobj.h" #include "enums.h" diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index 2f55dde7b80..320081911bb 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -23,7 +23,7 @@ */ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "draw_validate.h" #include "bufferobj.h" #include "context.h" diff --git a/src/mesa/main/drawtex.c b/src/mesa/main/drawtex.c index 6114b3277b0..304c74879b5 100644 --- a/src/mesa/main/drawtex.c +++ b/src/mesa/main/drawtex.c @@ -24,7 +24,7 @@ #include "main/errors.h" #include "main/drawtex.h" #include "main/state.h" -#include "main/imports.h" +#include "util/imports.h" #include "main/mtypes.h" diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 071b75c4727..7c8cb3886d9 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -32,7 +32,7 @@ #include <stdio.h> #include "errors.h" #include "enums.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "debug_output.h" diff --git a/src/mesa/main/es1_conversion.c b/src/mesa/main/es1_conversion.c index 1dfe8278e71..020d891ae33 100644 --- a/src/mesa/main/es1_conversion.c +++ b/src/mesa/main/es1_conversion.c @@ -9,7 +9,7 @@ #include "context.h" #include "depth.h" #include "fog.h" -#include "imports.h" +#include "util/imports.h" #include "light.h" #include "lines.h" #include "matrix.h" diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c index 86c8f75a1d2..e970265e2c3 100644 --- a/src/mesa/main/eval.c +++ b/src/mesa/main/eval.c @@ -38,7 +38,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "eval.h" #include "macros.h" diff --git a/src/mesa/main/execmem.c b/src/mesa/main/execmem.c index 35d4574ba2b..3b08f42a3dd 100644 --- a/src/mesa/main/execmem.c +++ b/src/mesa/main/execmem.c @@ -32,7 +32,8 @@ #include <stdio.h> -#include "imports.h" +#include "util/imports.h" +#include "main/glheader.h" #include "execmem.h" #include "c11/threads.h" diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 0aeda39cc22..6c1551687b2 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -31,7 +31,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "extensions.h" #include "macros.h" diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index 8f2b4e9de48..9ae86f4ee13 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -29,7 +29,7 @@ #include "main/glheader.h" #include "main/context.h" -#include "main/imports.h" +#include "util/imports.h" #include "main/macros.h" #include "main/samplerobj.h" #include "main/shaderobj.h" diff --git a/src/mesa/main/format_utils.h b/src/mesa/main/format_utils.h index 3a528ceb3db..c298d0477ad 100644 --- a/src/mesa/main/format_utils.h +++ b/src/mesa/main/format_utils.h @@ -32,7 +32,7 @@ #define FORMAT_UTILS_H #include "formats.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "util/rounding.h" #include "util/half_float.h" diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 370859d37ca..53f01ffc18a 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -25,7 +25,7 @@ #include "errors.h" -#include "imports.h" +#include "util/imports.h" #include "formats.h" #include "macros.h" #include "glformats.h" diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 1c72f446b0d..1cfc472c8fa 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -31,7 +31,7 @@ #include <stdio.h> #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "blend.h" #include "buffers.h" #include "context.h" diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h index 64f2962aba6..040c6cb5824 100644 --- a/src/mesa/main/hash.h +++ b/src/mesa/main/hash.h @@ -33,7 +33,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "c11/threads.h" /** diff --git a/src/mesa/main/hint.c b/src/mesa/main/hint.c index 2bcaeebc4aa..5a09a7362a9 100644 --- a/src/mesa/main/hint.c +++ b/src/mesa/main/hint.c @@ -28,7 +28,7 @@ #include "enums.h" #include "context.h" #include "hint.h" -#include "imports.h" +#include "util/imports.h" #include "mtypes.h" diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index ad6b378f7f6..0ec1d09853e 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -34,7 +34,7 @@ #include "colormac.h" #include "glformats.h" #include "image.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "mtypes.h" diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c deleted file mode 100644 index 96f8ad443f3..00000000000 --- a/src/mesa/main/imports.c +++ /dev/null @@ -1,234 +0,0 @@ -/** - * \file imports.c - * Standard C library function wrappers. - * - * Imports are services which the device driver or window system or - * operating system provides to the core renderer. The core renderer (Mesa) - * will call these functions in order to do memory allocation, simple I/O, - * etc. - * - * Some drivers will want to override/replace this file with something - * specialized, but that'll be rare. - * - * Eventually, I want to move roll the glheader.h file into this. - * - * \todo Functions still needed: - * - scanf - * - qsort - * - rand and RAND_MAX - */ - -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2007 Brian Paul 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include <stdio.h> -#include <stdarg.h> -#include "c99_math.h" -#include "imports.h" -#include "context.h" -#include "version.h" - -#ifdef _GNU_SOURCE -#include <locale.h> -#ifdef __APPLE__ -#include <xlocale.h> -#endif -#endif - - -#ifdef _WIN32 -#define vsnprintf _vsnprintf -#elif defined(__IBMC__) || defined(__IBMCPP__) -extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg); -#endif - -/**********************************************************************/ -/** \name Memory */ -/*@{*/ - -/** - * Allocate aligned memory. - * - * \param bytes number of bytes to allocate. - * \param alignment alignment (must be greater than zero). - * - * Allocates extra memory to accommodate rounding up the address for - * alignment and to record the real malloc address. - * - * \sa _mesa_align_free(). - */ -void * -_mesa_align_malloc(size_t bytes, unsigned long alignment) -{ -#if defined(HAVE_POSIX_MEMALIGN) - void *mem; - int err = posix_memalign(& mem, alignment, bytes); - if (err) - return NULL; - return mem; -#elif defined(_WIN32) - return _aligned_malloc(bytes, alignment); -#else - uintptr_t ptr, buf; - - assert( alignment > 0 ); - - ptr = (uintptr_t)malloc(bytes + alignment + sizeof(void *)); - if (!ptr) - return NULL; - - buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); - *(uintptr_t *)(buf - sizeof(void *)) = ptr; - -#ifndef NDEBUG - /* mark the non-aligned area */ - while ( ptr < buf - sizeof(void *) ) { - *(unsigned long *)ptr = 0xcdcdcdcd; - ptr += sizeof(unsigned long); - } -#endif - - return (void *) buf; -#endif /* defined(HAVE_POSIX_MEMALIGN) */ -} - -/** - * Same as _mesa_align_malloc(), but using calloc(1, ) instead of - * malloc() - */ -void * -_mesa_align_calloc(size_t bytes, unsigned long alignment) -{ -#if defined(HAVE_POSIX_MEMALIGN) - void *mem; - - mem = _mesa_align_malloc(bytes, alignment); - if (mem != NULL) { - (void) memset(mem, 0, bytes); - } - - return mem; -#elif defined(_WIN32) - void *mem; - - mem = _aligned_malloc(bytes, alignment); - if (mem != NULL) { - (void) memset(mem, 0, bytes); - } - - return mem; -#else - uintptr_t ptr, buf; - - assert( alignment > 0 ); - - ptr = (uintptr_t)calloc(1, bytes + alignment + sizeof(void *)); - if (!ptr) - return NULL; - - buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); - *(uintptr_t *)(buf - sizeof(void *)) = ptr; - -#ifndef NDEBUG - /* mark the non-aligned area */ - while ( ptr < buf - sizeof(void *) ) { - *(unsigned long *)ptr = 0xcdcdcdcd; - ptr += sizeof(unsigned long); - } -#endif - - return (void *)buf; -#endif /* defined(HAVE_POSIX_MEMALIGN) */ -} - -/** - * Free memory which was allocated with either _mesa_align_malloc() - * or _mesa_align_calloc(). - * \param ptr pointer to the memory to be freed. - * The actual address to free is stored in the word immediately before the - * address the client sees. - * Note that it is legal to pass NULL pointer to this function and will be - * handled accordingly. - */ -void -_mesa_align_free(void *ptr) -{ -#if defined(HAVE_POSIX_MEMALIGN) - free(ptr); -#elif defined(_WIN32) - _aligned_free(ptr); -#else - if (ptr) { - void **cubbyHole = (void **) ((char *) ptr - sizeof(void *)); - void *realAddr = *cubbyHole; - free(realAddr); - } -#endif /* defined(HAVE_POSIX_MEMALIGN) */ -} - -/** - * Reallocate memory, with alignment. - */ -void * -_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, - unsigned long alignment) -{ -#if defined(_WIN32) - (void) oldSize; - return _aligned_realloc(oldBuffer, newSize, alignment); -#else - const size_t copySize = (oldSize < newSize) ? oldSize : newSize; - void *newBuf = _mesa_align_malloc(newSize, alignment); - if (newBuf && oldBuffer && copySize > 0) { - memcpy(newBuf, oldBuffer, copySize); - } - - _mesa_align_free(oldBuffer); - return newBuf; -#endif -} - -/*@}*/ - - -/** Needed due to #ifdef's, above. */ -int -_mesa_vsnprintf(char *str, size_t size, const char *fmt, va_list args) -{ - return vsnprintf( str, size, fmt, args); -} - -/** Wrapper around vsnprintf() */ -int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) -{ - int r; - va_list args; - va_start( args, fmt ); - r = vsnprintf( str, size, fmt, args ); - va_end( args ); - return r; -} - - diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h deleted file mode 100644 index 7cf5f247be4..00000000000 --- a/src/mesa/main/imports.h +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - - -/** - * \file imports.h - * Standard C library function wrappers. - * - * This file provides wrappers for all the standard C library functions - * like malloc(), free(), printf(), getenv(), etc. - */ - - -#ifndef IMPORTS_H -#define IMPORTS_H - - -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include "compiler.h" -#include "glheader.h" -#include "util/bitscan.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/**********************************************************************/ -/** Memory macros */ -/*@{*/ - -/** Allocate a structure of type \p T */ -#define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) -/** Allocate and zero a structure of type \p T */ -#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) - -/*@}*/ - - -/* - * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers - * as offsets into buffer stores. Since the vertex array pointer and - * buffer store pointer are both pointers and we need to add them, we use - * this macro. - * Both pointers/offsets are expressed in bytes. - */ -#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) ) - - -/** - * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float - * as an int (thereby using integer registers instead of FP registers) is - * a performance win. Typically, this can be done with ordinary casts. - * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0) - * these casts generate warnings. - * The following union typedef is used to solve that. - */ -typedef union { GLfloat f; GLint i; GLuint u; } fi_type; - - - -/*@}*/ - - -/*** - *** LOG2: Log base 2 of float - ***/ -static inline GLfloat LOG2(GLfloat x) -{ -#if 0 - /* This is pretty fast, but not accurate enough (only 2 fractional bits). - * Based on code from http://www.stereopsis.com/log2.html - */ - const GLfloat y = x * x * x * x; - const GLuint ix = *((GLuint *) &y); - const GLuint exp = (ix >> 23) & 0xFF; - const GLint log2 = ((GLint) exp) - 127; - return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */ -#endif - /* Pretty fast, and accurate. - * Based on code from http://www.flipcode.com/totd/ - */ - fi_type num; - GLint log_2; - num.f = x; - log_2 = ((num.i >> 23) & 255) - 128; - num.i &= ~(255 << 23); - num.i += 127 << 23; - num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3; - return num.f + log_2; -} - - - -/** - * finite macro. - */ -#if defined(_MSC_VER) -# define finite _finite -#endif - - -/*** - *** IS_INF_OR_NAN: test if float is infinite or NaN - ***/ -#if defined(isfinite) -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#elif defined(finite) -#define IS_INF_OR_NAN(x) (!finite(x)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#else -#define IS_INF_OR_NAN(x) (!finite(x)) -#endif - - -/** - * Convert float to int by rounding to nearest integer, away from zero. - */ -static inline int IROUND(float f) -{ - return (int) ((f >= 0.0F) ? (f + 0.5F) : (f - 0.5F)); -} - -/** - * Convert double to int by rounding to nearest integer, away from zero. - */ -static inline int IROUNDD(double d) -{ - return (int) ((d >= 0.0) ? (d + 0.5) : (d - 0.5)); -} - -/** - * Convert float to int64 by rounding to nearest integer. - */ -static inline GLint64 IROUND64(float f) -{ - return (GLint64) ((f >= 0.0F) ? (f + 0.5F) : (f - 0.5F)); -} - - -/** - * Convert positive float to int by rounding to nearest integer. - */ -static inline int IROUND_POS(float f) -{ - assert(f >= 0.0F); - return (int) (f + 0.5F); -} - -/** Return (as an integer) floor of float */ -static inline int IFLOOR(float f) -{ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) - /* - * IEEE floor for computers that round to nearest or even. - * 'f' must be between -4194304 and 4194303. - * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1", - * but uses some IEEE specific tricks for better speed. - * Contributed by Josh Vanderhoof - */ - int ai, bi; - double af, bf; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - /* GCC generates an extra fstp/fld without this. */ - __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); - __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); - return (ai - bi) >> 1; -#else - int ai, bi; - double af, bf; - fi_type u; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - u.f = (float) af; ai = u.i; - u.f = (float) bf; bi = u.i; - return (ai - bi) >> 1; -#endif -} - - -/** - * Is x a power of two? - */ -static inline int -_mesa_is_pow_two(int x) -{ - return !(x & (x - 1)); -} - -/** - * Round given integer to next higer power of two - * If X is zero result is undefined. - * - * Source for the fallback implementation is - * Sean Eron Anderson's webpage "Bit Twiddling Hacks" - * http://graphics.stanford.edu/~seander/bithacks.html - * - * When using builtin function have to do some work - * for case when passed values 1 to prevent hiting - * undefined result from __builtin_clz. Undefined - * results would be different depending on optimization - * level used for build. - */ -static inline int32_t -_mesa_next_pow_two_32(uint32_t x) -{ -#ifdef HAVE___BUILTIN_CLZ - uint32_t y = (x != 1); - return (1 + y) << ((__builtin_clz(x - y) ^ 31) ); -#else - x--; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - x++; - return x; -#endif -} - -static inline int64_t -_mesa_next_pow_two_64(uint64_t x) -{ -#ifdef HAVE___BUILTIN_CLZLL - uint64_t y = (x != 1); - STATIC_ASSERT(sizeof(x) == sizeof(long long)); - return (1 + y) << ((__builtin_clzll(x - y) ^ 63)); -#else - x--; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - x |= x >> 32; - x++; - return x; -#endif -} - - -/* - * Returns the floor form of binary logarithm for a 32-bit integer. - */ -static inline GLuint -_mesa_logbase2(GLuint n) -{ -#ifdef HAVE___BUILTIN_CLZ - return (31 - __builtin_clz(n | 1)); -#else - GLuint pos = 0; - if (n >= 1<<16) { n >>= 16; pos += 16; } - if (n >= 1<< 8) { n >>= 8; pos += 8; } - if (n >= 1<< 4) { n >>= 4; pos += 4; } - if (n >= 1<< 2) { n >>= 2; pos += 2; } - if (n >= 1<< 1) { pos += 1; } - return pos; -#endif -} - - -/********************************************************************** - * Functions - */ - -extern void * -_mesa_align_malloc( size_t bytes, unsigned long alignment ); - -extern void * -_mesa_align_calloc( size_t bytes, unsigned long alignment ); - -extern void -_mesa_align_free( void *ptr ); - -extern void * -_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, - unsigned long alignment); - -extern int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4); - -extern int -_mesa_vsnprintf(char *str, size_t size, const char *fmt, va_list arg); - - -#if defined(_WIN32) && !defined(HAVE_STRTOK_R) -#define strtok_r strtok_s -#endif - -#ifdef __cplusplus -} -#endif - - -#endif /* IMPORTS_H */ diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 67faf8a1452..bae17c76f60 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -26,7 +26,7 @@ #include "c99_math.h" #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "enums.h" #include "light.h" diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index efdb0a09570..a54ade1fc9b 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -34,7 +34,8 @@ #include "util/macros.h" #include "util/u_math.h" #include "util/rounding.h" -#include "imports.h" +#include "util/imports.h" +#include "main/glheader.h" /** diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index 7d75a900e1b..58a48ed9933 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -36,7 +36,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "enums.h" #include "macros.h" diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 88e6baa08ad..dc606877d01 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -28,7 +28,7 @@ */ #include "errors.h" -#include "imports.h" +#include "util/imports.h" #include "formats.h" #include "glformats.h" #include "mipmap.h" diff --git a/src/mesa/main/objectpurge.c b/src/mesa/main/objectpurge.c index d730f46b8ec..28d046b565c 100644 --- a/src/mesa/main/objectpurge.c +++ b/src/mesa/main/objectpurge.c @@ -31,7 +31,7 @@ #include "glheader.h" #include "enums.h" #include "hash.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "bufferobj.h" #include "fbobject.h" diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c index 64ad115f8b5..818fcf85384 100644 --- a/src/mesa/main/pack.c +++ b/src/mesa/main/pack.c @@ -46,12 +46,12 @@ #include "glheader.h" #include "enums.h" #include "image.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "mtypes.h" #include "pack.h" #include "pixeltransfer.h" -#include "imports.h" +#include "util/imports.h" #include "glformats.h" #include "format_utils.h" #include "format_pack.h" diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index cea55f2a0d2..6af815759f1 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -36,7 +36,7 @@ #include "bufferobj.h" #include "glformats.h" #include "image.h" -#include "imports.h" +#include "util/imports.h" #include "mtypes.h" #include "pbo.h" diff --git a/src/mesa/main/pixeltransfer.c b/src/mesa/main/pixeltransfer.c index 22eac00a7df..1b8abd87a61 100644 --- a/src/mesa/main/pixeltransfer.c +++ b/src/mesa/main/pixeltransfer.c @@ -33,7 +33,7 @@ #include "glheader.h" #include "macros.h" #include "pixeltransfer.h" -#include "imports.h" +#include "util/imports.h" #include "mtypes.h" #include "util/rounding.h" diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index ae8f2a85645..f44542385b9 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -29,7 +29,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "image.h" #include "enums.h" diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 981ccf8f9c0..032f9e9a437 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -28,7 +28,7 @@ #include "context.h" #include "enums.h" #include "hash.h" -#include "imports.h" +#include "util/imports.h" #include "queryobj.h" #include "mtypes.h" diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index 6b3685dd82b..45e5754d9a4 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -23,7 +23,7 @@ */ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "blend.h" #include "bufferobj.h" #include "context.h" diff --git a/src/mesa/main/remap.c b/src/mesa/main/remap.c index fa412c0c4f7..c8b01fb1a58 100644 --- a/src/mesa/main/remap.c +++ b/src/mesa/main/remap.c @@ -37,7 +37,7 @@ #include <stdbool.h> #include "remap.h" -#include "imports.h" +#include "util/imports.h" #include "glapi/glapi.h" #define MAX_ENTRY_POINTS 16 diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 0e017125ac0..34959776a6f 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -24,7 +24,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "fbobject.h" #include "formats.h" diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index 07fdc76ee56..3da48f3e747 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -27,7 +27,7 @@ * Shared-context state */ -#include "imports.h" +#include "util/imports.h" #include "mtypes.h" #include "hash.h" #include "atifragshader.h" diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c index d89312ce12d..6ef6833bb71 100644 --- a/src/mesa/main/stencil.c +++ b/src/mesa/main/stencil.c @@ -48,7 +48,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "macros.h" #include "stencil.h" diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index 736f043f90c..41b7b22b0ae 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -57,7 +57,7 @@ #include <inttypes.h> #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "macros.h" #include "get.h" diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index e0324bd54d2..f03317a2d5f 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -43,7 +43,7 @@ #include "GL/gl.h" #include "GL/glext.h" -#include "main/compiler.h" +#include "util/compiler.h" #include "main/api_exec.h" #include "main/context.h" #include "main/remap.h" diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 48d794ddfd2..6b97695c8ef 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -31,7 +31,7 @@ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "context.h" #include "formats.h" #include "mtypes.h" diff --git a/src/mesa/main/texcompress_cpal.c b/src/mesa/main/texcompress_cpal.c index c46ef8c53fb..db99649e2bf 100644 --- a/src/mesa/main/texcompress_cpal.c +++ b/src/mesa/main/texcompress_cpal.c @@ -34,7 +34,7 @@ #include "glheader.h" #include "context.h" #include "mtypes.h" -#include "imports.h" +#include "util/imports.h" #include "pixelstore.h" #include "texcompress_cpal.h" #include "teximage.h" diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index bd284b36113..5b93eee3439 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -31,7 +31,7 @@ #include "errors.h" #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "image.h" #include "macros.h" #include "mipmap.h" diff --git a/src/mesa/main/texcompress_rgtc.c b/src/mesa/main/texcompress_rgtc.c index ef5c2bbfd8d..e6f6075ecff 100644 --- a/src/mesa/main/texcompress_rgtc.c +++ b/src/mesa/main/texcompress_rgtc.c @@ -35,7 +35,7 @@ #include "config.h" #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "image.h" #include "macros.h" #include "mipmap.h" diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 78f03bf2920..faec72f365d 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -30,7 +30,7 @@ */ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "image.h" #include "macros.h" #include "mtypes.h" diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 65952bca5fa..86de72d7593 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -38,7 +38,7 @@ #include "framebuffer.h" #include "hash.h" #include "image.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "mipmap.h" #include "multisample.h" diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index c5459f4540f..4dc1bb1eed0 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -35,7 +35,7 @@ #include "fbobject.h" #include "formats.h" #include "hash.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "shaderimage.h" #include "teximage.h" diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c index d2e0e52ecab..5f2d78e07d4 100644 --- a/src/mesa/main/texstorage.c +++ b/src/mesa/main/texstorage.c @@ -30,7 +30,7 @@ #include "glheader.h" #include "context.h" #include "enums.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "teximage.h" #include "texobj.h" diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 9bbac5f1512..5c5331a6402 100755 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -62,7 +62,7 @@ #include "mtypes.h" #include "pack.h" #include "pbo.h" -#include "imports.h" +#include "util/imports.h" #include "texcompress.h" #include "texcompress_fxt1.h" #include "texcompress_rgtc.h" diff --git a/src/mesa/main/texturebindless.c b/src/mesa/main/texturebindless.c index 9aaa0367c2d..eddf0ee4684 100644 --- a/src/mesa/main/texturebindless.c +++ b/src/mesa/main/texturebindless.c @@ -24,7 +24,7 @@ #include "glheader.h" #include "context.h" #include "enums.h" -#include "imports.h" +#include "util/imports.h" #include "hash.h" #include "mtypes.h" #include "shaderimage.h" diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c index 62c86eb5f03..da09c1e3c58 100644 --- a/src/mesa/main/textureview.c +++ b/src/mesa/main/textureview.c @@ -34,7 +34,7 @@ #include "glheader.h" #include "context.h" #include "enums.h" -#include "imports.h" +#include "util/imports.h" #include "macros.h" #include "teximage.h" #include "texobj.h" diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h index 063e295a2ec..729b790ed6f 100644 --- a/src/mesa/main/transformfeedback.h +++ b/src/mesa/main/transformfeedback.h @@ -28,7 +28,7 @@ #include <stdbool.h> #include "bufferobj.h" -#include "compiler.h" +#include "util/compiler.h" #include "glheader.h" #include "mtypes.h" diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 2f6aefc9ccb..3c9c6f3d31a 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -28,7 +28,7 @@ #include <inttypes.h> /* for PRId64 macro */ #include "glheader.h" -#include "imports.h" +#include "util/imports.h" #include "bufferobj.h" #include "context.h" #include "enable.h" diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 58deb4b3cf8..cacf22e7950 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -25,7 +25,7 @@ #include <stdio.h> #include "context.h" -#include "imports.h" +#include "util/imports.h" #include "mtypes.h" #include "version.h" #include "git_sha1.h" diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c index f5ef0ac56c3..666124e1ca6 100644 --- a/src/mesa/main/vtxfmt.c +++ b/src/mesa/main/vtxfmt.c @@ -28,7 +28,7 @@ #include "glheader.h" #include "api_arrayelt.h" #include "context.h" -#include "imports.h" +#include "util/imports.h" #include "mtypes.h" #include "vtxfmt.h" #include "eval.h" |