summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorKarl Schultz <kschultz@freedesktop.org>2005-05-05 21:08:07 +0000
committerKarl Schultz <kschultz@freedesktop.org>2005-05-05 21:08:07 +0000
commit6258b76c49f49a56a7c713914b798e80c6553b06 (patch)
tree2cc86a17fdda506fc9c86daba7ff3900d2d64996 /src/mesa/main
parent203dcb733d36cc91107554b0d323ed8ccef6e105 (diff)
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.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/api_arrayelt.c4
-rw-r--r--src/mesa/main/bufferobj.c4
-rw-r--r--src/mesa/main/extensions.c6
-rw-r--r--src/mesa/main/glheader.h9
-rw-r--r--src/mesa/main/imports.c18
-rw-r--r--src/mesa/main/imports.h2
-rw-r--r--src/mesa/main/texstore.c2
7 files changed, 26 insertions, 19 deletions
diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index cb827c2ec9..6a531aa2aa 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -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 );
}
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 07b2341ff7..a1d4c0190a 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -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;
}
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 150492e7c3..8f6b554a47 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -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) ' ';
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index 7855fd63fa..0b1c16d244 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -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
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 50bc1510b1..767cef59e2 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -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);
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 5158bcd8b2..2ae1116f41 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -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) )
/**********************************************************************/
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 02f2dbe69f..e4c3f6651d 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -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;