#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"
/**************************************************************************
- *
+ *
* 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
* 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.
* 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"
*/
_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);
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) {
*/
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);
return;
}
- _mesa_align_free(intel_obj->sys_buffer);
+ align_free(intel_obj->sys_buffer);
intel_obj->sys_buffer = NULL;
}
return obj->Mappings[index].Pointer;
}
- _mesa_align_free(intel_obj->sys_buffer);
+ align_free(intel_obj->sys_buffer);
intel_obj->sys_buffer = NULL;
}
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 {
* 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 -
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;
}
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;
#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"
#include "main/streaming-load-memcpy.h"
#include "util/format_srgb.h"
+#include "util/u_memory.h"
#include "x86/common_x86_asm.h"
intel_miptree_unmap_raw(mt);
}
- _mesa_align_free(map->buffer);
+ align_free(map->buffer);
map->buffer = map->ptr = NULL;
}
* 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);
unsigned int level,
unsigned int slice)
{
- _mesa_align_free(map->buffer);
+ align_free(map->buffer);
map->buffer = NULL;
map->ptr = NULL;
}
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;
#include "glheader.h"
#include "enums.h"
#include "hash.h"
-#include "util/imports.h"
#include "context.h"
#include "bufferobj.h"
#include "externalobjects.h"
(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;
(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;
#include "main/glheader.h"
#include "main/context.h"
#include "main/macros.h"
-#include "util/imports.h"
#include "m_matrix.h"
#include "m_xform.h"
(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 );
}
}
- _mesa_align_free( mat->m );
+ align_free( mat->m );
return 1;
}
#include "main/glheader.h"
#include "main/context.h"
#include "main/macros.h"
-#include "util/imports.h"
#include "m_matrix.h"
#include "m_xform.h"
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;
}
}
- _mesa_align_free( mat->m );
+ align_free( mat->m );
return 1;
}
#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
/*@}*/
-/**
+/**
* 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)
* \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 )
* 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.
*/
* \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.
*/
*
* \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.
*/
/**
* Dumps the contents of a GLmatrix structure.
- *
+ *
* \param m pointer to the GLmatrix structure.
*/
void
* \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)]
/**
* 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@star.be
*
/**
* 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.
/**
* 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
/**
* 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.
/**
* 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 )
{
/**
* 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
/**
* 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
#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 )
/**
* Analyze a matrix given that its flags are accurate.
- *
+ *
* This is the more common operation, hopefully.
*/
static void analyse_from_flags( GLmatrix *mat )
/**
* Loads a matrix array into GLmatrix.
- *
+ *
* \param m matrix array.
* \param mat matrix.
*
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;
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;
}
#include <stddef.h>
#include "main/glheader.h"
-#include "util/imports.h"
#include "main/macros.h"
#include "m_vector.h"
+#include "util/u_memory.h"
+
/**
{
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;
_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;
#include "main/glheader.h"
-#include "util/imports.h"
#include "main/macros.h"
#include "util/u_memory.h"
#include "prog_instruction.h"
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;
}
}
free(paramList->Parameters);
free(paramList->ParameterValueOffset);
- _mesa_align_free(paramList->ParameterValues);
+ align_free(paramList->ParameterValues);
free(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);
}
}
* 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.
#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"
#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"
_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;
{
struct swrast_texture_image *swImage = swrast_texture_image(texImage);
- _mesa_align_free(swImage->Buffer);
+ align_free(swImage->Buffer);
swImage->Buffer = NULL;
free(swImage->ImageSlices);
#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"
#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"
#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
}
/* 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;
}
/* free misc arrays */
_mesa_vector4f_free( &store->ndcCoords );
- _mesa_align_free( store->clipmask );
+ align_free( store->clipmask );
free( store );
stage->privatePtr = NULL;
#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"
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);
/* 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 );
_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 ||
_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;
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);
}
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) {
#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"
/* 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;
}
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;
}
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
* 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);