gallium: Move align_pointer() to p_pointer.h.
This commit is contained in:

committed by
José Fonseca

parent
f44b30f1eb
commit
8828dd1443
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "p_compiler.h"
|
||||
#include "p_debug.h"
|
||||
#include "p_pointer.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
@@ -114,33 +115,6 @@ REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
|
||||
#define CALLOC_STRUCT(T) (struct T *) CALLOC(1, sizeof(struct T))
|
||||
|
||||
|
||||
/**
|
||||
* Return a pointer aligned to next multiple of N bytes.
|
||||
*/
|
||||
static INLINE void *
|
||||
align_pointer( void *unaligned, uint alignment )
|
||||
{
|
||||
if (sizeof(void *) == 64) {
|
||||
union {
|
||||
void *p;
|
||||
uint64 u;
|
||||
} pu;
|
||||
pu.p = unaligned;
|
||||
pu.u = (pu.u + alignment - 1) & ~(uint64) (alignment - 1);
|
||||
return pu.p;
|
||||
}
|
||||
else {
|
||||
/* 32-bit pointers */
|
||||
union {
|
||||
void *p;
|
||||
uint u;
|
||||
} pu;
|
||||
pu.p = unaligned;
|
||||
pu.u = (pu.u + alignment - 1) & ~(alignment - 1);
|
||||
return pu.p;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return memory on given byte alignment
|
||||
*/
|
||||
|
Reference in New Issue
Block a user