Mesa (master): replace imports memory functions with utils memory functions

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 21 20:52:39 UTC 2020


Module: Mesa
Branch: master
Commit: c495c3af26b73cb1d444fdd67cc6c1f0226bd168
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c495c3af26b73cb1d444fdd67cc6c1f0226bd168

Author: Dylan Baker <dylan at pnwbakers.com>
Date:   Wed Sep 12 16:31:13 2018 -0700

replace imports memory functions with utils memory functions

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3024>

---

 src/gallium/drivers/iris/iris_state.c            |   1 +
 src/mesa/drivers/dri/i915/intel_buffer_objects.c |  29 +++--
 src/mesa/drivers/dri/i965/brw_context.c          |   1 +
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c    |   9 +-
 src/mesa/main/bufferobj.c                        |   7 +-
 src/mesa/math/m_debug_norm.c                     |   5 +-
 src/mesa/math/m_debug_xform.c                    |   5 +-
 src/mesa/math/m_matrix.c                         |  71 +++++------
 src/mesa/math/m_vector.c                         |   7 +-
 src/mesa/program/prog_parameter.c                |  17 ++-
 src/mesa/state_tracker/st_context.c              |   1 +
 src/mesa/state_tracker/st_extensions.c           |   1 +
 src/mesa/swrast/s_texture.c                      |   4 +-
 src/mesa/tnl/t_vb_program.c                      |  12 +-
 src/mesa/tnl/t_vb_vertex.c                       |  10 +-
 src/mesa/tnl/t_vertex.c                          |   4 +-
 src/mesa/vbo/vbo_exec_api.c                      |   5 +-
 src/util/imports.c                               | 148 -----------------------
 src/util/imports.h                               |  13 --
 19 files changed, 96 insertions(+), 254 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index f572c0213dd..d708f6a45bc 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -95,6 +95,7 @@
 #include "util/u_transfer.h"
 #include "util/u_upload_mgr.h"
 #include "util/u_viewport.h"
+#include "util/u_memory.h"
 #include "drm-uapi/i915_drm.h"
 #include "nir.h"
 #include "intel/compiler/brw_compiler.h"
diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
index 841808b7e3d..b0547276958 100644
--- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
@@ -1,8 +1,8 @@
 /**************************************************************************
- * 
+ *
  * Copyright 2003 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
@@ -10,11 +10,11 @@
  * 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.
@@ -22,11 +22,10 @@
  * 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 "util/imports.h"
 #include "main/mtypes.h"
 #include "main/macros.h"
 #include "main/bufferobj.h"
@@ -97,7 +96,7 @@ intel_bufferobj_free(struct gl_context * ctx, struct gl_buffer_object *obj)
     */
    _mesa_buffer_unmap_all_mappings(ctx, obj);
 
-   _mesa_align_free(intel_obj->sys_buffer);
+   align_free(intel_obj->sys_buffer);
 
    drm_intel_bo_unreference(intel_obj->buffer);
    _mesa_delete_buffer_object(ctx, obj);
@@ -134,7 +133,7 @@ intel_bufferobj_data(struct gl_context * ctx,
    if (intel_obj->buffer != NULL)
       release_buffer(intel_obj);
 
-   _mesa_align_free(intel_obj->sys_buffer);
+   align_free(intel_obj->sys_buffer);
    intel_obj->sys_buffer = NULL;
 
    if (size != 0) {
@@ -143,7 +142,7 @@ intel_bufferobj_data(struct gl_context * ctx,
        */
       if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
 	 intel_obj->sys_buffer =
-            _mesa_align_malloc(size, ctx->Const.MinMapBufferAlignment);
+            align_malloc(size, ctx->Const.MinMapBufferAlignment);
 	 if (intel_obj->sys_buffer != NULL) {
 	    if (data != NULL)
 	       memcpy(intel_obj->sys_buffer, data, size);
@@ -194,7 +193,7 @@ intel_bufferobj_subdata(struct gl_context * ctx,
 	 return;
       }
 
-      _mesa_align_free(intel_obj->sys_buffer);
+      align_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
    }
 
@@ -302,7 +301,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 	 return obj->Mappings[index].Pointer;
       }
 
-      _mesa_align_free(intel_obj->sys_buffer);
+      align_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
    }
 
@@ -351,7 +350,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 
       if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {
          intel_obj->range_map_buffer[index] =
-            _mesa_align_malloc(length + extra, alignment);
+            align_malloc(length + extra, alignment);
          obj->Mappings[index].Pointer =
             intel_obj->range_map_buffer[index] + extra;
       } else {
@@ -446,7 +445,7 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj,
        * usage inside of a batchbuffer.
        */
       intel_batchbuffer_emit_mi_flush(intel);
-      _mesa_align_free(intel_obj->range_map_buffer[index]);
+      align_free(intel_obj->range_map_buffer[index]);
       intel_obj->range_map_buffer[index] = NULL;
    } else if (intel_obj->range_map_bo[index] != NULL) {
       const unsigned extra = obj->Mappings[index].Pointer -
@@ -491,7 +490,7 @@ intel_bufferobj_buffer(struct intel_context *intel,
 			   0, intel_obj->Base.Size,
 			   intel_obj->sys_buffer);
 
-      _mesa_align_free(intel_obj->sys_buffer);
+      align_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
       intel_obj->offset = 0;
    }
@@ -678,7 +677,7 @@ intel_buffer_object_purgeable(struct gl_context * ctx,
       return intel_buffer_purgeable(intel_obj->buffer);
 
    if (option == GL_RELEASED_APPLE) {
-      _mesa_align_free(intel_obj->sys_buffer);
+      align_free(intel_obj->sys_buffer);
       intel_obj->sys_buffer = NULL;
 
       return GL_RELEASED_APPLE;
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index e5b66a78d0c..7a359b32c48 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -76,6 +76,7 @@
 #include "util/ralloc.h"
 #include "util/debug.h"
 #include "util/disk_cache.h"
+#include "util/u_memory.h"
 #include "isl/isl.h"
 
 #include "common/gen_defines.h"
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 63ca925e775..35b84848641 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -47,6 +47,7 @@
 #include "main/streaming-load-memcpy.h"
 
 #include "util/format_srgb.h"
+#include "util/u_memory.h"
 
 #include "x86/common_x86_asm.h"
 
@@ -2553,7 +2554,7 @@ intel_miptree_unmap_tiled_memcpy(struct brw_context *brw,
 
       intel_miptree_unmap_raw(mt);
    }
-   _mesa_align_free(map->buffer);
+   align_free(map->buffer);
    map->buffer = map->ptr = NULL;
 }
 
@@ -2635,7 +2636,7 @@ intel_miptree_map_tiled_memcpy(struct brw_context *brw,
     * aligned). Here we over-allocate the linear buffer by enough
     * bytes to get the proper alignment.
     */
-   map->buffer = _mesa_align_malloc(map->stride * (y2 - y1) + (x1 & 0xf), 16);
+   map->buffer = align_malloc(map->stride * (y2 - y1) + (x1 & 0xf), 16);
    map->ptr = (char *)map->buffer + (x1 & 0xf);
    assert(map->buffer);
 
@@ -2728,7 +2729,7 @@ intel_miptree_unmap_movntdqa(struct brw_context *brw,
                              unsigned int level,
                              unsigned int slice)
 {
-   _mesa_align_free(map->buffer);
+   align_free(map->buffer);
    map->buffer = NULL;
    map->ptr = NULL;
 }
@@ -2778,7 +2779,7 @@ intel_miptree_map_movntdqa(struct brw_context *brw,
 
    map->stride = ALIGN(misalignment + width_bytes, 16);
 
-   map->buffer = _mesa_align_malloc(map->stride * map->h, 16);
+   map->buffer = align_malloc(map->stride * map->h, 16);
    /* Offset the destination so it has the same misalignment as src. */
    map->ptr = map->buffer + misalignment;
 
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index fdd5a908108..5bfa3668152 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -36,7 +36,6 @@
 #include "glheader.h"
 #include "enums.h"
 #include "hash.h"
-#include "util/imports.h"
 #include "context.h"
 #include "bufferobj.h"
 #include "externalobjects.h"
@@ -483,7 +482,7 @@ _mesa_delete_buffer_object(struct gl_context *ctx,
    (void) ctx;
 
    vbo_delete_minmax_cache(bufObj);
-   _mesa_align_free(bufObj->Data);
+   align_free(bufObj->Data);
 
    /* assign strange values here to help w/ debugging */
    bufObj->RefCount = -1000;
@@ -623,9 +622,9 @@ buffer_data_fallback(struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
 
    (void) target;
 
-   _mesa_align_free( bufObj->Data );
+   align_free( bufObj->Data );
 
-   new_data = _mesa_align_malloc( size, ctx->Const.MinMapBufferAlignment );
+   new_data = align_malloc( size, ctx->Const.MinMapBufferAlignment );
    if (new_data) {
       bufObj->Data = (GLubyte *) new_data;
       bufObj->Size = size;
diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c
index 7ad5b6f6b29..dccbdad4dd6 100644
--- a/src/mesa/math/m_debug_norm.c
+++ b/src/mesa/math/m_debug_norm.c
@@ -30,7 +30,6 @@
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "util/imports.h"
 
 #include "m_matrix.h"
 #include "m_xform.h"
@@ -209,7 +208,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
 
    (void) cycles;
 
-   mat->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+   mat->m = align_malloc( 16 * sizeof(GLfloat), 16 );
    mat->inv = m = mat->m;
 
    init_matrix( m );
@@ -328,7 +327,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
       }
    }
 
-   _mesa_align_free( mat->m );
+   align_free( mat->m );
    return 1;
 }
 
diff --git a/src/mesa/math/m_debug_xform.c b/src/mesa/math/m_debug_xform.c
index f6e0bb24f54..4795df286d6 100644
--- a/src/mesa/math/m_debug_xform.c
+++ b/src/mesa/math/m_debug_xform.c
@@ -29,7 +29,6 @@
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/macros.h"
-#include "util/imports.h"
 
 #include "m_matrix.h"
 #include "m_xform.h"
@@ -183,7 +182,7 @@ static int test_transform_function( transform_func func, int psize,
       return 0;
    }
 
-   mat->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+   mat->m = align_malloc( 16 * sizeof(GLfloat), 16 );
    mat->type = mtypes[mtype];
 
    m = mat->m;
@@ -273,7 +272,7 @@ static int test_transform_function( transform_func func, int psize,
       }
    }
 
-   _mesa_align_free( mat->m );
+   align_free( mat->m );
    return 1;
 }
 
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index cc3af6870f8..31b7665a3ba 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -38,13 +38,14 @@
 #include "c99_math.h"
 #include "main/errors.h"
 #include "main/glheader.h"
-#include "util/imports.h"
 #include "main/macros.h"
 #define MATH_ASM_PTR_SIZE sizeof(void *)
 #include "math/m_vector_asm.h"
 
 #include "m_matrix.h"
 
+#include "util/u_memory.h"
+
 
 /**
  * \defgroup MatFlags MAT_FLAG_XXX-flags
@@ -104,15 +105,15 @@
 /*@}*/
 
 
-/** 
+/**
  * Test geometry related matrix flags.
- * 
+ *
  * \param mat a pointer to a GLmatrix structure.
  * \param a flags mask.
  *
  * \returns non-zero if all geometry related matrix flags are contained within
  * the mask, or zero otherwise.
- */ 
+ */
 #define TEST_MAT_FLAGS(mat, a)  \
     ((MAT_FLAGS_GEOMETRY & (~(a)) & ((mat)->flags) ) == 0)
 
@@ -162,7 +163,7 @@ static const GLfloat Identity[16] = {
  * \warning Is assumed that \p product != \p b. \p product == \p a is allowed.
  *
  * \note KW: 4*16 = 64 multiplications
- * 
+ *
  * \author This \c matmul was contributed by Thomas Malik
  */
 static void matmul4( GLfloat *product, const GLfloat *a, const GLfloat *b )
@@ -212,7 +213,7 @@ static void matmul34( GLfloat *product, const GLfloat *a, const GLfloat *b )
  * matrix, and that will receive the product result.
  * \param m right multiplication matrix array.
  * \param flags flags of the matrix \p m.
- * 
+ *
  * Joins both flags and marks the type and inverse as dirty.  Calls matmul34()
  * if both matrices are 3D, or matmul4() otherwise.
  */
@@ -232,7 +233,7 @@ static void matrix_multf( GLmatrix *mat, const GLfloat *m, GLuint flags )
  * \param dest destination matrix.
  * \param a left matrix.
  * \param b right matrix.
- * 
+ *
  * Joins both flags and marks the type and inverse as dirty.  Calls matmul34()
  * if both matrices are 3D, or matmul4() otherwise.
  */
@@ -255,7 +256,7 @@ _math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b )
  *
  * \param dest left and destination matrix.
  * \param m right matrix array.
- * 
+ *
  * Marks the matrix flags with general flag, and type and inverse dirty flags.
  * Calls matmul4() for the multiplication.
  */
@@ -294,7 +295,7 @@ static void print_matrix_floats( const GLfloat m[16] )
 
 /**
  * Dumps the contents of a GLmatrix structure.
- * 
+ *
  * \param m pointer to the GLmatrix structure.
  */
 void
@@ -320,10 +321,10 @@ _math_matrix_print( const GLmatrix *m )
  * \param m matrix array.
  * \param c column of the desired element.
  * \param r row of the desired element.
- * 
+ *
  * \return value of the desired element.
  *
- * Calculate the linear storage index of the element and references it. 
+ * Calculate the linear storage index of the element and references it.
  */
 #define MAT(m,r,c) (m)[(c)*4+(r)]
 
@@ -341,12 +342,12 @@ _math_matrix_print( const GLmatrix *m )
 
 /**
  * Compute inverse of 4x4 transformation matrix.
- * 
+ *
  * \param mat pointer to a GLmatrix structure. The matrix inverse will be
  * stored in the GLmatrix::inv attribute.
- * 
+ *
  * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
- * 
+ *
  * \author
  * Code contributed by Jacques Leroy jle at star.be
  *
@@ -469,10 +470,10 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
 
 /**
  * Compute inverse of a general 3d transformation matrix.
- * 
+ *
  * \param mat pointer to a GLmatrix structure. The matrix inverse will be
  * stored in the GLmatrix::inv attribute.
- * 
+ *
  * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
  *
  * \author Adapted from graphics gems II.
@@ -543,10 +544,10 @@ static GLboolean invert_matrix_3d_general( GLmatrix *mat )
 
 /**
  * Compute inverse of a 3d transformation matrix.
- * 
+ *
  * \param mat pointer to a GLmatrix structure. The matrix inverse will be
  * stored in the GLmatrix::inv attribute.
- * 
+ *
  * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
  *
  * If the matrix is not an angle preserving matrix then calls
@@ -626,10 +627,10 @@ static GLboolean invert_matrix_3d( GLmatrix *mat )
 
 /**
  * Compute inverse of an identity transformation matrix.
- * 
+ *
  * \param mat pointer to a GLmatrix structure. The matrix inverse will be
  * stored in the GLmatrix::inv attribute.
- * 
+ *
  * \return always GL_TRUE.
  *
  * Simply copies Identity into GLmatrix::inv.
@@ -642,13 +643,13 @@ static GLboolean invert_matrix_identity( GLmatrix *mat )
 
 /**
  * Compute inverse of a no-rotation 3d transformation matrix.
- * 
+ *
  * \param mat pointer to a GLmatrix structure. The matrix inverse will be
  * stored in the GLmatrix::inv attribute.
- * 
+ *
  * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
  *
- * Calculates the 
+ * Calculates the
  */
 static GLboolean invert_matrix_3d_no_rot( GLmatrix *mat )
 {
@@ -674,10 +675,10 @@ static GLboolean invert_matrix_3d_no_rot( GLmatrix *mat )
 
 /**
  * Compute inverse of a no-rotation 2d transformation matrix.
- * 
+ *
  * \param mat pointer to a GLmatrix structure. The matrix inverse will be
  * stored in the GLmatrix::inv attribute.
- * 
+ *
  * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
  *
  * Calculates the inverse matrix by applying the inverse scaling and
@@ -758,10 +759,10 @@ static inv_mat_func inv_mat_tab[7] = {
 
 /**
  * Compute inverse of a transformation matrix.
- * 
+ *
  * \param mat pointer to a GLmatrix structure. The matrix inverse will be
  * stored in the GLmatrix::inv attribute.
- * 
+ *
  * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
  *
  * Calls the matrix inversion function in inv_mat_tab corresponding to the
@@ -1200,10 +1201,10 @@ _math_matrix_set_identity( GLmatrix *mat )
 #define SQ(x) ((x)*(x))
 
 /**
- * Determine type and flags from scratch.  
+ * Determine type and flags from scratch.
  *
  * \param mat matrix.
- * 
+ *
  * This is expensive enough to only want to do it once.
  */
 static void analyse_from_scratch( GLmatrix *mat )
@@ -1316,7 +1317,7 @@ static void analyse_from_scratch( GLmatrix *mat )
 
 /**
  * Analyze a matrix given that its flags are accurate.
- * 
+ *
  * This is the more common operation, hopefully.
  */
 static void analyse_from_flags( GLmatrix *mat )
@@ -1452,7 +1453,7 @@ _math_matrix_copy( GLmatrix *to, const GLmatrix *from )
 
 /**
  * Loads a matrix array into GLmatrix.
- * 
+ *
  * \param m matrix array.
  * \param mat matrix.
  *
@@ -1476,10 +1477,10 @@ _math_matrix_loadf( GLmatrix *mat, const GLfloat *m )
 void
 _math_matrix_ctr( GLmatrix *m )
 {
-   m->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+   m->m = align_malloc( 16 * sizeof(GLfloat), 16 );
    if (m->m)
       memcpy( m->m, Identity, sizeof(Identity) );
-   m->inv = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+   m->inv = align_malloc( 16 * sizeof(GLfloat), 16 );
    if (m->inv)
       memcpy( m->inv, Identity, sizeof(Identity) );
    m->type = MATRIX_IDENTITY;
@@ -1496,10 +1497,10 @@ _math_matrix_ctr( GLmatrix *m )
 void
 _math_matrix_dtr( GLmatrix *m )
 {
-   _mesa_align_free( m->m );
+   align_free( m->m );
    m->m = NULL;
 
-   _mesa_align_free( m->inv );
+   align_free( m->inv );
    m->inv = NULL;
 }
 
diff --git a/src/mesa/math/m_vector.c b/src/mesa/math/m_vector.c
index af4eceaf014..b757f244985 100644
--- a/src/mesa/math/m_vector.c
+++ b/src/mesa/math/m_vector.c
@@ -30,11 +30,12 @@
 #include <stddef.h>
 
 #include "main/glheader.h"
-#include "util/imports.h"
 #include "main/macros.h"
 
 #include "m_vector.h"
 
+#include "util/u_memory.h"
+
 
 
 /**
@@ -109,7 +110,7 @@ _mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags, GLuint count,
 {
    v->stride = 4 * sizeof(GLfloat);
    v->size = 2;
-   v->storage = _mesa_align_malloc( count * 4 * sizeof(GLfloat), alignment );
+   v->storage = align_malloc( count * 4 * sizeof(GLfloat), alignment );
    v->storage_count = count;
    v->start = (GLfloat *) v->storage;
    v->data = (GLfloat (*)[4]) v->storage;
@@ -127,7 +128,7 @@ void
 _mesa_vector4f_free( GLvector4f *v )
 {
    if (v->flags & VEC_MALLOC) {
-      _mesa_align_free( v->storage );
+      align_free( v->storage );
       v->data = NULL;
       v->start = NULL;
       v->storage = NULL;
diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c
index 0dce7cb9801..b674472b4fd 100644
--- a/src/mesa/program/prog_parameter.c
+++ b/src/mesa/program/prog_parameter.c
@@ -30,7 +30,6 @@
 
 
 #include "main/glheader.h"
-#include "util/imports.h"
 #include "main/macros.h"
 #include "util/u_memory.h"
 #include "prog_instruction.h"
@@ -155,12 +154,12 @@ _mesa_new_parameter_list_sized(unsigned size)
       p->ParameterValueOffset = (unsigned *) calloc(size, sizeof(unsigned));
 
       p->ParameterValues = (gl_constant_value *)
-         _mesa_align_malloc(size * 4 *sizeof(gl_constant_value), 16);
+         align_malloc(size * 4 *sizeof(gl_constant_value), 16);
 
 
       if ((p->Parameters == NULL) || (p->ParameterValues == NULL)) {
          free(p->Parameters);
-         _mesa_align_free(p->ParameterValues);
+         align_free(p->ParameterValues);
          free(p);
          p = NULL;
       }
@@ -182,7 +181,7 @@ _mesa_free_parameter_list(struct gl_program_parameter_list *paramList)
    }
    free(paramList->Parameters);
    free(paramList->ParameterValueOffset);
-   _mesa_align_free(paramList->ParameterValues);
+   align_free(paramList->ParameterValues);
    free(paramList);
 }
 
@@ -214,10 +213,10 @@ _mesa_reserve_parameter_storage(struct gl_program_parameter_list *paramList,
                  paramList->Size * sizeof(unsigned));
 
       paramList->ParameterValues = (gl_constant_value *)
-         _mesa_align_realloc(paramList->ParameterValues,         /* old buf */
-                             oldNum * 4 * sizeof(gl_constant_value),/* old sz */
-                             paramList->Size*4*sizeof(gl_constant_value),/*new*/
-                             16);
+         align_realloc(paramList->ParameterValues,         /* old buf */
+                       oldNum * 4 * sizeof(gl_constant_value),/* old sz */
+                       paramList->Size*4*sizeof(gl_constant_value),/*new*/
+                       16);
    }
 }
 
@@ -229,7 +228,7 @@ _mesa_reserve_parameter_storage(struct gl_program_parameter_list *paramList,
  * store all the values (in blocks of 4).
  *
  * \param paramList  the list to add the parameter to
- * \param type  type of parameter, such as 
+ * \param type  type of parameter, such as
  * \param name  the parameter name, will be duplicated/copied!
  * \param size  number of elements in 'values' vector (1..4, or more)
  * \param datatype  GL_FLOAT, GL_FLOAT_VECx, GL_INT, GL_INT_VECx or GL_NONE.
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 645c02f3dfd..b4be7078aec 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -85,6 +85,7 @@
 #include "util/u_inlines.h"
 #include "util/u_upload_mgr.h"
 #include "util/u_vbuf.h"
+#include "util/u_memory.h"
 #include "cso_cache/cso_context.h"
 #include "compiler/glsl/glsl_parser_extras.h"
 
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 97ab11f41d4..96a329741be 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -39,6 +39,7 @@
 #include "pipe/p_screen.h"
 #include "tgsi/tgsi_from_mesa.h"
 #include "util/u_math.h"
+#include "util/u_memory.h"
 
 #include "st_context.h"
 #include "st_debug.h"
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 88b4e87c62a..7228d2e0e0d 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -100,7 +100,7 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
                                            _swrast_teximage_slice_height(texImage), 1);
 
    assert(!swImg->Buffer);
-   swImg->Buffer = _mesa_align_malloc(bytesPerSlice * slices, 512);
+   swImg->Buffer = align_malloc(bytesPerSlice * slices, 512);
    if (!swImg->Buffer)
       return GL_FALSE;
 
@@ -166,7 +166,7 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx,
 {
    struct swrast_texture_image *swImage = swrast_texture_image(texImage);
 
-   _mesa_align_free(swImage->Buffer);
+   align_free(swImage->Buffer);
    swImage->Buffer = NULL;
 
    free(swImage->ImageSlices);
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 7a49e393464..f240e98387f 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -33,7 +33,6 @@
 
 #include "main/glheader.h"
 #include "main/macros.h"
-#include "util/imports.h"
 #include "main/samplerobj.h"
 #include "main/state.h"
 #include "math/m_xform.h"
@@ -42,6 +41,7 @@
 #include "program/prog_execute.h"
 #include "swrast/s_context.h"
 #include "util/bitscan.h"
+#include "util/u_memory.h"
 
 #include "tnl/tnl.h"
 #include "tnl/t_context.h"
@@ -392,9 +392,9 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage )
 #endif
 #if 0
       printf("HPOS: %f %f %f %f\n",
-             machine->Outputs[0][0], 
-             machine->Outputs[0][1], 
-             machine->Outputs[0][2], 
+             machine->Outputs[0][0],
+             machine->Outputs[0][1],
+             machine->Outputs[0][2],
              machine->Outputs[0][3]);
 #endif
    }
@@ -481,7 +481,7 @@ init_vp(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
 
    /* a few other misc allocations */
    _mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 );
-   store->clipmask = _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
+   store->clipmask = align_malloc(sizeof(GLubyte)*size, 32 );
 
    return GL_TRUE;
 }
@@ -504,7 +504,7 @@ dtr(struct tnl_pipeline_stage *stage)
 
       /* free misc arrays */
       _mesa_vector4f_free( &store->ndcCoords );
-      _mesa_align_free( store->clipmask );
+      align_free( store->clipmask );
 
       free( store );
       stage->privatePtr = NULL;
diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c
index 1a55f7e6957..1309b465b78 100644
--- a/src/mesa/tnl/t_vb_vertex.c
+++ b/src/mesa/tnl/t_vb_vertex.c
@@ -28,12 +28,12 @@
 
 #include "main/glheader.h"
 #include "main/macros.h"
-#include "util/imports.h"
 #include "main/mtypes.h"
 
 #include "math/m_xform.h"
 
 #include "util/bitscan.h"
+#include "util/u_memory.h"
 
 #include "t_context.h"
 #include "t_pipeline.h"
@@ -141,7 +141,7 @@ static GLboolean run_vertex_stage( struct gl_context *ctx,
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
 
-   if (ctx->VertexProgram._Current) 
+   if (ctx->VertexProgram._Current)
       return GL_TRUE;
 
    tnl_clip_prepare(ctx);
@@ -165,7 +165,7 @@ static GLboolean run_vertex_stage( struct gl_context *ctx,
    /* Drivers expect this to be clean to element 4...
     */
    switch (VB->ClipPtr->size) {
-   case 1:			
+   case 1:
       /* impossible */
    case 2:
       _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 );
@@ -247,7 +247,7 @@ static GLboolean init_vertex_stage( struct gl_context *ctx,
    _mesa_vector4f_alloc( &store->clip, 0, size, 32 );
    _mesa_vector4f_alloc( &store->proj, 0, size, 32 );
 
-   store->clipmask = _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
+   store->clipmask = align_malloc(sizeof(GLubyte)*size, 32 );
 
    if (!store->clipmask ||
        !store->eye.data ||
@@ -266,7 +266,7 @@ static void dtr( struct tnl_pipeline_stage *stage )
       _mesa_vector4f_free( &store->eye );
       _mesa_vector4f_free( &store->clip );
       _mesa_vector4f_free( &store->proj );
-      _mesa_align_free( store->clipmask );
+      align_free( store->clipmask );
       free(store);
       stage->privatePtr = NULL;
       stage->run = init_vertex_stage;
diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c
index baea953b88f..0d29403a846 100644
--- a/src/mesa/tnl/t_vertex.c
+++ b/src/mesa/tnl/t_vertex.c
@@ -512,7 +512,7 @@ void _tnl_init_vertices( struct gl_context *ctx,
    if (max_vertex_size > vtx->max_vertex_size) {
       _tnl_free_vertices( ctx );
       vtx->max_vertex_size = max_vertex_size;
-      vtx->vertex_buf = _mesa_align_calloc(vb_size * max_vertex_size, 32 );
+      vtx->vertex_buf = align_calloc(vb_size * max_vertex_size, 32 );
       invalidate_funcs(vtx);
    }
 
@@ -558,7 +558,7 @@ void _tnl_free_vertices( struct gl_context *ctx )
       struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
       struct tnl_clipspace_fastpath *fp, *tmp;
 
-      _mesa_align_free(vtx->vertex_buf);
+      align_free(vtx->vertex_buf);
       vtx->vertex_buf = NULL;
 
       for (fp = vtx->fastpath ; fp ; fp = tmp) {
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 74be1c574a8..5e90f3671d7 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -43,6 +43,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/draw_validate.h"
 #include "main/dispatch.h"
 #include "util/bitscan.h"
+#include "util/u_memory.h"
 
 #include "vbo_noop.h"
 #include "vbo_private.h"
@@ -1015,7 +1016,7 @@ vbo_exec_vtx_init(struct vbo_exec_context *exec, bool use_buffer_objects)
       /* Use allocated memory for immediate mode. */
       exec->vtx.bufferobj = NULL;
       exec->vtx.buffer_map =
-         _mesa_align_malloc(ctx->Const.glBeginEndBufferSize, 64);
+         align_malloc(ctx->Const.glBeginEndBufferSize, 64);
       exec->vtx.buffer_ptr = exec->vtx.buffer_map;
    }
 
@@ -1039,7 +1040,7 @@ vbo_exec_vtx_destroy(struct vbo_exec_context *exec)
       assert(!exec->vtx.bufferobj ||
              exec->vtx.bufferobj->Name == IMM_BUFFER_NAME);
       if (!exec->vtx.bufferobj) {
-         _mesa_align_free(exec->vtx.buffer_map);
+         align_free(exec->vtx.buffer_map);
          exec->vtx.buffer_map = NULL;
          exec->vtx.buffer_ptr = NULL;
       }
diff --git a/src/util/imports.c b/src/util/imports.c
index f264e725cc4..2744ee988d3 100644
--- a/src/util/imports.c
+++ b/src/util/imports.c
@@ -61,154 +61,6 @@
 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
diff --git a/src/util/imports.h b/src/util/imports.h
index 47c7d5931c4..4d7405dbf55 100644
--- a/src/util/imports.h
+++ b/src/util/imports.h
@@ -76,19 +76,6 @@ typedef union { float f; int i; unsigned u; } fi_type;
  * 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);
 



More information about the mesa-commit mailing list