Port Mesa to build on a P64 platform (e.g., Win64). P64 platforms
use 64-bit pointers and 32-bit longs. So, operations like casting pointers to unsigned long and back to pointer won't work. glheader.h now includes files to define uintptr_t, which should instead be used for this sort of operation. It is an integer type that is the same size as a pointer.
This commit is contained in:
@@ -989,7 +989,7 @@ void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
|
||||
/* generic attributes */
|
||||
for (at = actx->attribs; at->func; at++) {
|
||||
const GLubyte *src = at->array->BufferObj->Data
|
||||
+ (unsigned long) at->array->Ptr
|
||||
+ (uintptr_t) at->array->Ptr
|
||||
+ elt * at->array->StrideB;
|
||||
at->func( at->index, src );
|
||||
}
|
||||
@@ -997,7 +997,7 @@ void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
|
||||
/* conventional arrays */
|
||||
for (aa = actx->arrays; aa->func ; aa++) {
|
||||
const GLubyte *src = aa->array->BufferObj->Data
|
||||
+ (unsigned long) aa->array->Ptr
|
||||
+ (uintptr_t) aa->array->Ptr
|
||||
+ elt * aa->array->StrideB;
|
||||
aa->func( src );
|
||||
}
|
||||
|
@@ -449,11 +449,11 @@ _mesa_validate_pbo_access(GLuint dimensions,
|
||||
format, type, depth-1, height-1, width);
|
||||
|
||||
|
||||
if ((const GLubyte *) start > (const GLubyte *) pack->BufferObj->Size) {
|
||||
if ((const GLubyte *) start > (const GLubyte *)(uintptr_t) pack->BufferObj->Size) {
|
||||
/* This will catch negative values / wrap-around */
|
||||
return GL_FALSE;
|
||||
}
|
||||
if ((const GLubyte *) end > (const GLubyte *) pack->BufferObj->Size) {
|
||||
if ((const GLubyte *) end > (const GLubyte *)(uintptr_t) pack->BufferObj->Size) {
|
||||
/* Image read goes beyond end of buffer */
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#include "mtypes.h"
|
||||
|
||||
|
||||
#define F(x) (int)(unsigned long)&(((struct gl_extensions *)0)->x)
|
||||
#define F(x) (int)(uintptr_t)&(((struct gl_extensions *)0)->x)
|
||||
#define ON GL_TRUE
|
||||
#define OFF GL_FALSE
|
||||
|
||||
@@ -489,7 +489,7 @@ _mesa_make_extension_string( GLcontext *ctx )
|
||||
for (i = 0 ; i < Elements(default_extensions) ; i++) {
|
||||
if (!default_extensions[i].flag_offset ||
|
||||
*(base + default_extensions[i].flag_offset)) {
|
||||
extStrLen += _mesa_strlen(default_extensions[i].name) + 1;
|
||||
extStrLen += (GLuint)_mesa_strlen(default_extensions[i].name) + 1;
|
||||
}
|
||||
}
|
||||
s = (GLubyte *) _mesa_malloc(extStrLen);
|
||||
@@ -499,7 +499,7 @@ _mesa_make_extension_string( GLcontext *ctx )
|
||||
for (i = 0 ; i < Elements(default_extensions) ; i++) {
|
||||
if (!default_extensions[i].flag_offset ||
|
||||
*(base + default_extensions[i].flag_offset)) {
|
||||
GLuint len = _mesa_strlen(default_extensions[i].name);
|
||||
GLuint len = (GLuint)_mesa_strlen(default_extensions[i].name);
|
||||
_mesa_memcpy(s + extStrLen, default_extensions[i].name, len);
|
||||
extStrLen += len;
|
||||
s[extStrLen] = (GLubyte) ' ';
|
||||
|
@@ -76,6 +76,13 @@
|
||||
#endif
|
||||
|
||||
|
||||
/* Get typedefs for uintptr_t and friends */
|
||||
#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
|
||||
#include <BaseTsd.h>
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
|
||||
# define __WIN32__
|
||||
# define finite _finite
|
||||
@@ -117,7 +124,7 @@
|
||||
*/
|
||||
/* compatibility guard so we don't need to change client code */
|
||||
#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
|
||||
typedef int (GLAPIENTRY *PROC)();
|
||||
typedef INT_PTR (GLAPIENTRY *PROC)();
|
||||
typedef unsigned long COLORREF;
|
||||
#endif
|
||||
|
||||
|
@@ -124,16 +124,16 @@ _mesa_free(void *ptr)
|
||||
void *
|
||||
_mesa_align_malloc(size_t bytes, unsigned long alignment)
|
||||
{
|
||||
unsigned long ptr, buf;
|
||||
uintptr_t ptr, buf;
|
||||
|
||||
ASSERT( alignment > 0 );
|
||||
|
||||
ptr = (unsigned long) _mesa_malloc(bytes + alignment + sizeof(void *));
|
||||
ptr = (uintptr_t) _mesa_malloc(bytes + alignment + sizeof(void *));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
buf = (ptr + alignment + sizeof(void *)) & ~(unsigned long)(alignment - 1);
|
||||
*(unsigned long *)(buf - sizeof(void *)) = ptr;
|
||||
buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
|
||||
*(uintptr_t *)(buf - sizeof(void *)) = ptr;
|
||||
|
||||
#ifdef DEBUG
|
||||
/* mark the non-aligned area */
|
||||
@@ -151,16 +151,16 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
|
||||
void *
|
||||
_mesa_align_calloc(size_t bytes, unsigned long alignment)
|
||||
{
|
||||
unsigned long ptr, buf;
|
||||
uintptr_t ptr, buf;
|
||||
|
||||
ASSERT( alignment > 0 );
|
||||
|
||||
ptr = (unsigned long) _mesa_calloc(bytes + alignment + sizeof(void *));
|
||||
ptr = (uintptr_t) _mesa_calloc(bytes + alignment + sizeof(void *));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
buf = (ptr + alignment + sizeof(void *)) & ~(unsigned long)(alignment - 1);
|
||||
*(unsigned long *)(buf - sizeof(void *)) = ptr;
|
||||
buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
|
||||
*(uintptr_t *)(buf - sizeof(void *)) = ptr;
|
||||
|
||||
#ifdef DEBUG
|
||||
/* mark the non-aligned area */
|
||||
@@ -777,7 +777,7 @@ _mesa_strncmp( const char *s1, const char *s2, size_t n )
|
||||
char *
|
||||
_mesa_strdup( const char *s )
|
||||
{
|
||||
int l = _mesa_strlen(s);
|
||||
size_t l = _mesa_strlen(s);
|
||||
char *s2 = (char *) _mesa_malloc(l + 1);
|
||||
if (s2)
|
||||
_mesa_strcpy(s2, s);
|
||||
|
@@ -100,7 +100,7 @@ extern "C" {
|
||||
* this macro.
|
||||
* Both pointers/offsets are expressed in bytes.
|
||||
*/
|
||||
#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (unsigned long) (B) )
|
||||
#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) )
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
|
@@ -2127,7 +2127,7 @@ _mesa_validate_pbo_compressed_teximage(GLcontext *ctx,
|
||||
return pixels;
|
||||
}
|
||||
if ((const GLubyte *) pixels + imageSize >
|
||||
(const GLubyte *) packing->BufferObj->Size) {
|
||||
(const GLubyte *)(uintptr_t) packing->BufferObj->Size) {
|
||||
/* out of bounds read! */
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access");
|
||||
return NULL;
|
||||
|
@@ -530,7 +530,7 @@ static void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4],
|
||||
const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride;
|
||||
GLuint i;
|
||||
|
||||
if (((((long) f | (long) stride)) & 3L) == 0L) {
|
||||
if (((((uintptr_t) f | (uintptr_t) stride)) & 3L) == 0L) {
|
||||
/* Aligned.
|
||||
*/
|
||||
for (i = DST_START ; i < n ; i++, f += stride) {
|
||||
|
@@ -3884,7 +3884,7 @@ static int extension_is_supported (const GLubyte *ext)
|
||||
{
|
||||
const GLubyte *extensions = GL_CALL(GetString)(GL_EXTENSIONS);
|
||||
const GLubyte *end = extensions + _mesa_strlen ((const char *) extensions);
|
||||
const GLint ext_len = _mesa_strlen ((const char *) ext);
|
||||
const GLint ext_len = (GLint)_mesa_strlen ((const char *) ext);
|
||||
|
||||
while (extensions < end)
|
||||
{
|
||||
|
@@ -509,7 +509,7 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
|
||||
|
||||
switch (pname) {
|
||||
case GL_PROGRAM_LENGTH_ARB:
|
||||
*params = prog->String ? _mesa_strlen((char *) prog->String) : 0;
|
||||
*params = prog->String ? (GLint)_mesa_strlen((char *) prog->String) : 0;
|
||||
break;
|
||||
case GL_PROGRAM_FORMAT_ARB:
|
||||
*params = prog->Format;
|
||||
|
@@ -36,13 +36,13 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
void grammar_alloc_free (void *);
|
||||
void *grammar_alloc_malloc (unsigned int);
|
||||
void *grammar_alloc_realloc (void *, unsigned int, unsigned int);
|
||||
void *grammar_alloc_malloc (size_t);
|
||||
void *grammar_alloc_realloc (void *, size_t, size_t);
|
||||
void *grammar_memory_copy (void *, const void *, unsigned int);
|
||||
int grammar_string_compare (const byte *, const byte *);
|
||||
int grammar_string_compare_n (const byte *, const byte *, unsigned int);
|
||||
int grammar_string_compare_n (const byte *, const byte *, size_t);
|
||||
byte *grammar_string_copy (byte *, const byte *);
|
||||
byte *grammar_string_copy_n (byte *, const byte *, unsigned int);
|
||||
byte *grammar_string_copy_n (byte *, const byte *, size_t);
|
||||
byte *grammar_string_duplicate (const byte *);
|
||||
unsigned int grammar_string_length (const byte *);
|
||||
|
||||
|
@@ -40,17 +40,17 @@ void grammar_alloc_free (void *ptr)
|
||||
_mesa_free (ptr);
|
||||
}
|
||||
|
||||
void *grammar_alloc_malloc (unsigned int size)
|
||||
void *grammar_alloc_malloc (size_t size)
|
||||
{
|
||||
return _mesa_malloc (size);
|
||||
}
|
||||
|
||||
void *grammar_alloc_realloc (void *ptr, unsigned int old_size, unsigned int size)
|
||||
void *grammar_alloc_realloc (void *ptr, size_t old_size, size_t size)
|
||||
{
|
||||
return _mesa_realloc (ptr, old_size, size);
|
||||
}
|
||||
|
||||
void *grammar_memory_copy (void *dst, const void * src, unsigned int size)
|
||||
void *grammar_memory_copy (void *dst, const void * src, size_t size)
|
||||
{
|
||||
return _mesa_memcpy (dst, src, size);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ int grammar_string_compare (const byte *str1, const byte *str2)
|
||||
return _mesa_strcmp ((const char *) str1, (const char *) str2);
|
||||
}
|
||||
|
||||
int grammar_string_compare_n (const byte *str1, const byte *str2, unsigned int n)
|
||||
int grammar_string_compare_n (const byte *str1, const byte *str2, size_t n)
|
||||
{
|
||||
return _mesa_strncmp ((const char *) str1, (const char *) str2, n);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ byte *grammar_string_copy (byte *dst, const byte *src)
|
||||
return (byte *) _mesa_strcpy ((char *) dst, (const char *) src);
|
||||
}
|
||||
|
||||
byte *grammar_string_copy_n (byte *dst, const byte *src, unsigned int n)
|
||||
byte *grammar_string_copy_n (byte *dst, const byte *src, size_t n)
|
||||
{
|
||||
return (byte *) _mesa_strncpy ((char *) dst, (const char *) src, n);
|
||||
}
|
||||
@@ -82,6 +82,6 @@ byte *grammar_string_duplicate (const byte *src)
|
||||
|
||||
unsigned int grammar_string_length (const byte *str)
|
||||
{
|
||||
return _mesa_strlen ((const char *) str);
|
||||
return (unsigned int)_mesa_strlen ((const char *) str);
|
||||
}
|
||||
|
||||
|
@@ -373,7 +373,7 @@ Peek_Token(struct parse_state *parseState, GLubyte *token)
|
||||
parseState->pos += (-i);
|
||||
return GL_FALSE;
|
||||
}
|
||||
len = _mesa_strlen((const char *) token);
|
||||
len = (GLint)_mesa_strlen((const char *) token);
|
||||
parseState->pos += (i - len);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
@@ -266,7 +266,7 @@ _mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params)
|
||||
*params = prog->Target;
|
||||
return;
|
||||
case GL_PROGRAM_LENGTH_NV:
|
||||
*params = prog->String ? _mesa_strlen((char *) prog->String) : 0;
|
||||
*params = prog->String ?(GLint)_mesa_strlen((char *) prog->String) : 0;
|
||||
return;
|
||||
case GL_PROGRAM_RESIDENT_NV:
|
||||
*params = prog->Resident;
|
||||
|
@@ -233,7 +233,7 @@ Peek_Token(struct parse_state *parseState, GLubyte *token)
|
||||
parseState->pos += (-i);
|
||||
return GL_FALSE;
|
||||
}
|
||||
len = _mesa_strlen((const char *) token);
|
||||
len = (GLint)_mesa_strlen((const char *) token);
|
||||
parseState->pos += (i - len);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user