aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/api_arrayelt.c4
-rw-r--r--mesalib/src/mesa/main/attrib.c10
-rw-r--r--mesalib/src/mesa/main/errors.c6
-rw-r--r--mesalib/src/mesa/main/eval.c60
-rw-r--r--mesalib/src/mesa/main/imports.h153
-rw-r--r--mesalib/src/mesa/main/macros.h32
-rw-r--r--mesalib/src/mesa/main/matrix.c4
-rw-r--r--mesalib/src/mesa/main/renderbuffer.c6
-rw-r--r--mesalib/src/mesa/main/samplerobj.c2
-rw-r--r--mesalib/src/mesa/main/syncobj.c8
-rw-r--r--mesalib/src/mesa/main/teximage.c2
11 files changed, 133 insertions, 154 deletions
diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c
index 6de6de2b7..152340b5f 100644
--- a/mesalib/src/mesa/main/api_arrayelt.c
+++ b/mesalib/src/mesa/main/api_arrayelt.c
@@ -1426,7 +1426,7 @@ GLboolean _ae_create_context( struct gl_context *ctx )
FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
FogCoordFuncs[7] = _gloffset_FogCoorddvEXT;
- ctx->aelt_context = CALLOC( sizeof(AEcontext) );
+ ctx->aelt_context = calloc(1, sizeof(AEcontext));
if (!ctx->aelt_context)
return GL_FALSE;
@@ -1438,7 +1438,7 @@ GLboolean _ae_create_context( struct gl_context *ctx )
void _ae_destroy_context( struct gl_context *ctx )
{
if ( AE_CONTEXT( ctx ) ) {
- FREE( ctx->aelt_context );
+ free(ctx->aelt_context);
ctx->aelt_context = NULL;
}
}
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index 8cb2a689b..b3d10d31e 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -398,7 +398,7 @@ _mesa_PushAttrib(GLbitfield mask)
if (mask & GL_POLYGON_STIPPLE_BIT) {
GLuint *stipple;
- stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) );
+ stipple = (GLuint *) malloc( 32*sizeof(GLuint) );
memcpy( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );
save_attrib_data(&head, GL_POLYGON_STIPPLE_BIT, stipple);
}
@@ -1314,8 +1314,8 @@ _mesa_PopAttrib(void)
}
next = attr->next;
- FREE( attr->data );
- FREE( attr );
+ free(attr->data);
+ free(attr);
attr = next;
}
}
@@ -1592,8 +1592,8 @@ _mesa_PopClientAttrib(void)
}
next = node->next;
- FREE( node->data );
- FREE( node );
+ free(node->data);
+ free(node);
node = next;
}
}
diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c
index 8b96319ce..796b6beff 100644
--- a/mesalib/src/mesa/main/errors.c
+++ b/mesalib/src/mesa/main/errors.c
@@ -322,7 +322,7 @@ _mesa_log_msg(struct gl_context *ctx, GLenum source, GLenum type,
assert(!emptySlot->message && !emptySlot->length);
- emptySlot->message = MALLOC(len+1);
+ emptySlot->message = malloc(len+1);
if (emptySlot->message) {
(void) strncpy(emptySlot->message, buf, (size_t)len);
emptySlot->message[len] = '\0';
@@ -391,7 +391,7 @@ _mesa_get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
}
if (msg->message != (char*)out_of_memory)
- FREE(msg->message);
+ free(msg->message);
msg->message = NULL;
msg->length = 0;
@@ -786,7 +786,7 @@ _mesa_free_errors_data(struct gl_context *ctx)
foreach_s(node, tmp, &ClientIDs->Namespaces[s][t].Severity[sev]) {
entry = (struct gl_client_severity *)node;
- FREE(entry);
+ free(entry);
}
}
}
diff --git a/mesalib/src/mesa/main/eval.c b/mesalib/src/mesa/main/eval.c
index e651715f7..0ae349f2d 100644
--- a/mesalib/src/mesa/main/eval.c
+++ b/mesalib/src/mesa/main/eval.c
@@ -218,7 +218,7 @@ GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
if (!points || !size)
return NULL;
- buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
+ buffer = (GLfloat *) malloc(uorder * size * sizeof(GLfloat));
if (buffer)
for (i = 0, p = buffer; i < uorder; i++, points += ustride)
@@ -242,7 +242,7 @@ GLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder,
if (!points || !size)
return NULL;
- buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
+ buffer = (GLfloat *) malloc(uorder * size * sizeof(GLfloat));
if (buffer)
for (i = 0, p = buffer; i < uorder; i++, points += ustride)
@@ -286,9 +286,9 @@ GLfloat *_mesa_copy_map_points2f( GLenum target,
hsize = (uorder > vorder ? uorder : vorder)*size;
if(hsize>dsize)
- buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
+ buffer = (GLfloat *) malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
else
- buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
+ buffer = (GLfloat *) malloc((uorder*vorder*size+dsize)*sizeof(GLfloat));
/* compute the increment value for the u-loop */
uinc = ustride - vorder*vstride;
@@ -329,9 +329,9 @@ GLfloat *_mesa_copy_map_points2d(GLenum target,
hsize = (uorder > vorder ? uorder : vorder)*size;
if(hsize>dsize)
- buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
+ buffer = (GLfloat *) malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
else
- buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
+ buffer = (GLfloat *) malloc((uorder*vorder*size+dsize)*sizeof(GLfloat));
/* compute the increment value for the u-loop */
uinc = ustride - vorder*vstride;
@@ -416,7 +416,7 @@ map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
map->u2 = u2;
map->du = 1.0F / (u2 - u1);
if (map->Points)
- FREE( map->Points );
+ free( map->Points );
map->Points = pnts;
}
@@ -516,7 +516,7 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
map->v2 = v2;
map->dv = 1.0F / (v2 - v1);
if (map->Points)
- FREE( map->Points );
+ free( map->Points );
map->Points = pnts;
}
@@ -940,7 +940,7 @@ init_1d_map( struct gl_1d_map *map, int n, const float *initial )
map->Order = 1;
map->u1 = 0.0;
map->u2 = 1.0;
- map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
+ map->Points = (GLfloat *) malloc(n * sizeof(GLfloat));
if (map->Points) {
GLint i;
for (i=0;i<n;i++)
@@ -961,7 +961,7 @@ init_2d_map( struct gl_2d_map *map, int n, const float *initial )
map->u2 = 1.0;
map->v1 = 0.0;
map->v2 = 1.0;
- map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
+ map->Points = (GLfloat *) malloc(n * sizeof(GLfloat));
if (map->Points) {
GLint i;
for (i=0;i<n;i++)
@@ -1048,44 +1048,44 @@ void _mesa_free_eval_data( struct gl_context *ctx )
/* Free evaluator data */
if (ctx->EvalMap.Map1Vertex3.Points)
- FREE( ctx->EvalMap.Map1Vertex3.Points );
+ free( ctx->EvalMap.Map1Vertex3.Points );
if (ctx->EvalMap.Map1Vertex4.Points)
- FREE( ctx->EvalMap.Map1Vertex4.Points );
+ free( ctx->EvalMap.Map1Vertex4.Points );
if (ctx->EvalMap.Map1Index.Points)
- FREE( ctx->EvalMap.Map1Index.Points );
+ free( ctx->EvalMap.Map1Index.Points );
if (ctx->EvalMap.Map1Color4.Points)
- FREE( ctx->EvalMap.Map1Color4.Points );
+ free( ctx->EvalMap.Map1Color4.Points );
if (ctx->EvalMap.Map1Normal.Points)
- FREE( ctx->EvalMap.Map1Normal.Points );
+ free( ctx->EvalMap.Map1Normal.Points );
if (ctx->EvalMap.Map1Texture1.Points)
- FREE( ctx->EvalMap.Map1Texture1.Points );
+ free( ctx->EvalMap.Map1Texture1.Points );
if (ctx->EvalMap.Map1Texture2.Points)
- FREE( ctx->EvalMap.Map1Texture2.Points );
+ free( ctx->EvalMap.Map1Texture2.Points );
if (ctx->EvalMap.Map1Texture3.Points)
- FREE( ctx->EvalMap.Map1Texture3.Points );
+ free( ctx->EvalMap.Map1Texture3.Points );
if (ctx->EvalMap.Map1Texture4.Points)
- FREE( ctx->EvalMap.Map1Texture4.Points );
+ free( ctx->EvalMap.Map1Texture4.Points );
for (i = 0; i < 16; i++)
- FREE((ctx->EvalMap.Map1Attrib[i].Points));
+ free((ctx->EvalMap.Map1Attrib[i].Points));
if (ctx->EvalMap.Map2Vertex3.Points)
- FREE( ctx->EvalMap.Map2Vertex3.Points );
+ free( ctx->EvalMap.Map2Vertex3.Points );
if (ctx->EvalMap.Map2Vertex4.Points)
- FREE( ctx->EvalMap.Map2Vertex4.Points );
+ free( ctx->EvalMap.Map2Vertex4.Points );
if (ctx->EvalMap.Map2Index.Points)
- FREE( ctx->EvalMap.Map2Index.Points );
+ free( ctx->EvalMap.Map2Index.Points );
if (ctx->EvalMap.Map2Color4.Points)
- FREE( ctx->EvalMap.Map2Color4.Points );
+ free( ctx->EvalMap.Map2Color4.Points );
if (ctx->EvalMap.Map2Normal.Points)
- FREE( ctx->EvalMap.Map2Normal.Points );
+ free( ctx->EvalMap.Map2Normal.Points );
if (ctx->EvalMap.Map2Texture1.Points)
- FREE( ctx->EvalMap.Map2Texture1.Points );
+ free( ctx->EvalMap.Map2Texture1.Points );
if (ctx->EvalMap.Map2Texture2.Points)
- FREE( ctx->EvalMap.Map2Texture2.Points );
+ free( ctx->EvalMap.Map2Texture2.Points );
if (ctx->EvalMap.Map2Texture3.Points)
- FREE( ctx->EvalMap.Map2Texture3.Points );
+ free( ctx->EvalMap.Map2Texture3.Points );
if (ctx->EvalMap.Map2Texture4.Points)
- FREE( ctx->EvalMap.Map2Texture4.Points );
+ free( ctx->EvalMap.Map2Texture4.Points );
for (i = 0; i < 16; i++)
- FREE((ctx->EvalMap.Map2Attrib[i].Points));
+ free((ctx->EvalMap.Map2Attrib[i].Points));
}
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index 73913b5ab..2f854e574 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -156,44 +156,47 @@ static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; }
#endif
/*@}*/
+#if defined(__SUNPRO_C)
+#define sqrtf(f) ((float) sqrt(f))
+#endif
+
+
/***
*** LOG2: Log base 2 of float
***/
-#ifdef USE_IEEE
-#if 0
-/* This is pretty fast, but not accurate enough (only 2 fractional bits).
- * Based on code from http://www.stereopsis.com/log2.html
- */
static inline GLfloat LOG2(GLfloat x)
{
+#ifdef USE_IEEE
+#if 0
+ /* This is pretty fast, but not accurate enough (only 2 fractional bits).
+ * Based on code from http://www.stereopsis.com/log2.html
+ */
const GLfloat y = x * x * x * x;
const GLuint ix = *((GLuint *) &y);
const GLuint exp = (ix >> 23) & 0xFF;
const GLint log2 = ((GLint) exp) - 127;
return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */
-}
#endif
-/* Pretty fast, and accurate.
- * Based on code from http://www.flipcode.com/totd/
- */
-static inline GLfloat LOG2(GLfloat val)
-{
+ /* Pretty fast, and accurate.
+ * Based on code from http://www.flipcode.com/totd/
+ */
fi_type num;
GLint log_2;
- num.f = val;
+ num.f = x;
log_2 = ((num.i >> 23) & 255) - 128;
num.i &= ~(255 << 23);
num.i += 127 << 23;
num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
return num.f + log_2;
-}
#else
-/*
- * NOTE: log_base_2(x) = log(x) / log(2)
- * NOTE: 1.442695 = 1/log(2).
- */
-#define LOG2(x) ((GLfloat) (log(x) * 1.442695F))
+ /*
+ * NOTE: log_base_2(x) = log(x) / log(2)
+ * NOTE: 1.442695 = 1/log(2).
+ */
+ return (GLfloat) (log(x) * 1.442695F);
#endif
+}
+
/***
@@ -220,35 +223,6 @@ static inline int IS_INF_OR_NAN( float x )
/***
- *** IS_NEGATIVE: test if float is negative
- ***/
-#if defined(USE_IEEE)
-static inline int GET_FLOAT_BITS( float x )
-{
- fi_type fi;
- fi.f = x;
- return fi.i;
-}
-#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0)
-#else
-#define IS_NEGATIVE(x) (x < 0.0F)
-#endif
-
-
-/***
- *** DIFFERENT_SIGNS: test if two floats have opposite signs
- ***/
-#if defined(USE_IEEE)
-#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
-#else
-/* Could just use (x*y<0) except for the flatshading requirements.
- * Maybe there's a better way?
- */
-#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
-#endif
-
-
-/***
*** CEILF: ceiling of float
*** FLOORF: floor of float
*** FABSF: absolute value of float
@@ -309,50 +283,36 @@ static inline int IROUND_POS(float f)
* Convert float to int using a fast method. The rounding mode may vary.
* XXX We could use an x86-64/SSE2 version here.
*/
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
static inline int F_TO_I(float f)
{
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
int r;
__asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
return r;
-}
#elif defined(USE_X86_ASM) && defined(_MSC_VER)
-static inline int F_TO_I(float f)
-{
int r;
_asm {
fld f
fistp r
}
return r;
-}
-#elif defined(__WATCOMC__) && defined(__386__)
-long F_TO_I(float f);
-#pragma aux iround = \
- "push eax" \
- "fistp dword ptr [esp]" \
- "pop eax" \
- parm [8087] \
- value [eax] \
- modify exact [eax];
#else
-#define F_TO_I(f) IROUND(f)
+ return IROUND(f);
#endif
+}
-/***
- *** IFLOOR: return (as an integer) floor of float
- ***/
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
-/*
- * IEEE floor for computers that round to nearest or even.
- * 'f' must be between -4194304 and 4194303.
- * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
- * but uses some IEEE specific tricks for better speed.
- * Contributed by Josh Vanderhoof
- */
-static inline int ifloor(float f)
+/** Return (as an integer) floor of float */
+static inline int IFLOOR(float f)
{
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+ /*
+ * IEEE floor for computers that round to nearest or even.
+ * 'f' must be between -4194304 and 4194303.
+ * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
+ * but uses some IEEE specific tricks for better speed.
+ * Contributed by Josh Vanderhoof
+ */
int ai, bi;
double af, bf;
af = (3 << 22) + 0.5 + (double)f;
@@ -361,45 +321,33 @@ static inline int ifloor(float f)
__asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
__asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
return (ai - bi) >> 1;
-}
-#define IFLOOR(x) ifloor(x)
#elif defined(USE_IEEE)
-static inline int ifloor(float f)
-{
int ai, bi;
double af, bf;
fi_type u;
-
af = (3 << 22) + 0.5 + (double)f;
bf = (3 << 22) + 0.5 - (double)f;
u.f = (float) af; ai = u.i;
u.f = (float) bf; bi = u.i;
return (ai - bi) >> 1;
-}
-#define IFLOOR(x) ifloor(x)
#else
-static inline int ifloor(float f)
-{
int i = IROUND(f);
return (i > f) ? i - 1 : i;
-}
-#define IFLOOR(x) ifloor(x)
#endif
+}
-/***
- *** ICEIL: return (as an integer) ceiling of float
- ***/
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
-/*
- * IEEE ceil for computers that round to nearest or even.
- * 'f' must be between -4194304 and 4194303.
- * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1",
- * but uses some IEEE specific tricks for better speed.
- * Contributed by Josh Vanderhoof
- */
-static inline int iceil(float f)
+/** Return (as an integer) ceiling of float */
+static inline int ICEIL(float f)
{
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+ /*
+ * IEEE ceil for computers that round to nearest or even.
+ * 'f' must be between -4194304 and 4194303.
+ * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1",
+ * but uses some IEEE specific tricks for better speed.
+ * Contributed by Josh Vanderhoof
+ */
int ai, bi;
double af, bf;
af = (3 << 22) + 0.5 + (double)f;
@@ -408,11 +356,7 @@ static inline int iceil(float f)
__asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
__asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
return (ai - bi + 1) >> 1;
-}
-#define ICEIL(x) iceil(x)
#elif defined(USE_IEEE)
-static inline int iceil(float f)
-{
int ai, bi;
double af, bf;
fi_type u;
@@ -421,16 +365,11 @@ static inline int iceil(float f)
u.f = (float) af; ai = u.i;
u.f = (float) bf; bi = u.i;
return (ai - bi + 1) >> 1;
-}
-#define ICEIL(x) iceil(x)
#else
-static inline int iceil(float f)
-{
int i = IROUND(f);
return (i < f) ? i + 1 : i;
-}
-#define ICEIL(x) iceil(x)
#endif
+}
/**
diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h
index 5af9487cb..7d0a375d1 100644
--- a/mesalib/src/mesa/main/macros.h
+++ b/mesalib/src/mesa/main/macros.h
@@ -689,6 +689,38 @@ NORMALIZE_3FV(GLfloat v[3])
}
+/** Is float value negative? */
+static inline GLboolean
+IS_NEGATIVE(float x)
+{
+#if defined(USE_IEEE)
+ fi_type fi;
+ fi.f = x;
+ return fi.i < 0;
+#else
+ return x < 0.0F;
+#endif
+}
+
+
+/** Test two floats have opposite signs */
+static inline GLboolean
+DIFFERENT_SIGNS(GLfloat x, GLfloat y)
+{
+#if defined(USE_IEEE)
+ fi_type xfi, yfi;
+ xfi.f = x;
+ yfi.f = y;
+ return (xfi.i ^ yfi.i) & (1u << 31);
+#else
+ /* Could just use (x*y<0) except for the flatshading requirements.
+ * Maybe there's a better way?
+ */
+ return ((x) * (y) <= 0.0F && (x) - (y) != 0.0F);
+#endif
+}
+
+
/** Compute ceiling of integer quotient of A divided by B. */
#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
diff --git a/mesalib/src/mesa/main/matrix.c b/mesalib/src/mesa/main/matrix.c
index 7157433de..a6193071d 100644
--- a/mesalib/src/mesa/main/matrix.c
+++ b/mesalib/src/mesa/main/matrix.c
@@ -671,7 +671,7 @@ init_matrix_stack( struct gl_matrix_stack *stack,
stack->MaxDepth = maxDepth;
stack->DirtyFlag = dirtyFlag;
/* The stack */
- stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix));
+ stack->Stack = (GLmatrix *) calloc(maxDepth, sizeof(GLmatrix));
for (i = 0; i < maxDepth; i++) {
_math_matrix_ctr(&stack->Stack[i]);
}
@@ -693,7 +693,7 @@ free_matrix_stack( struct gl_matrix_stack *stack )
for (i = 0; i < stack->MaxDepth; i++) {
_math_matrix_dtr(&stack->Stack[i]);
}
- FREE(stack->Stack);
+ free(stack->Stack);
stack->Stack = stack->Top = NULL;
}
diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c
index 1bb09bfe6..26f53d100 100644
--- a/mesalib/src/mesa/main/renderbuffer.c
+++ b/mesalib/src/mesa/main/renderbuffer.c
@@ -75,11 +75,15 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name)
/**
* Delete a gl_framebuffer.
* This is the default function for renderbuffer->Delete().
+ * Drivers which subclass gl_renderbuffer should probably implement their
+ * own delete function. But the driver might also call this function to
+ * free the object in the end.
*/
void
_mesa_delete_renderbuffer(struct gl_renderbuffer *rb)
{
- /* no-op */
+ _glthread_DESTROY_MUTEX(rb->Mutex);
+ free(rb);
}
diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c
index 8bf5f490a..4514b1224 100644
--- a/mesalib/src/mesa/main/samplerobj.c
+++ b/mesalib/src/mesa/main/samplerobj.c
@@ -155,7 +155,7 @@ void
_mesa_delete_sampler_object(struct gl_context *ctx,
struct gl_sampler_object *sampObj)
{
- FREE(sampObj);
+ free(sampObj);
}
diff --git a/mesalib/src/mesa/main/syncobj.c b/mesalib/src/mesa/main/syncobj.c
index 85dd41aac..1c09e421c 100644
--- a/mesalib/src/mesa/main/syncobj.c
+++ b/mesalib/src/mesa/main/syncobj.c
@@ -326,9 +326,13 @@ _mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
if (syncObj->StatusFlag) {
ret = GL_ALREADY_SIGNALED;
} else {
- ctx->Driver.ClientWaitSync(ctx, syncObj, flags, timeout);
+ if (timeout == 0) {
+ ret = GL_TIMEOUT_EXPIRED;
+ } else {
+ ctx->Driver.ClientWaitSync(ctx, syncObj, flags, timeout);
- ret = syncObj->StatusFlag ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED;
+ ret = syncObj->StatusFlag ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED;
+ }
}
_mesa_unref_sync_object(ctx, syncObj);
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 11b1b3043..cdb090542 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -1015,7 +1015,7 @@ make_null_texture(GLint width, GLint height, GLint depth, GLenum format)
{
const GLint components = _mesa_components_in_format(format);
const GLint numPixels = width * height * depth;
- GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte));
+ GLubyte *data = (GLubyte *) malloc(numPixels * components * sizeof(GLubyte));
#ifdef DEBUG
/*