a couple casts (Evgeny Kotsuba)
[mesa.git] / src / mesa / main / imports.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 5.1
4 *
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /*
27 * This file provides wrappers for all the standard C library functions
28 * like malloc, free, printf, getenv, etc.
29 */
30
31
32 #ifndef IMPORTS_H
33 #define IMPORTS_H
34
35
36 /* XXX some of the stuff in glheader.h should be moved into this file.
37 */
38 #include "glheader.h"
39
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45
46 /**********************************************************************
47 * General macros
48 */
49
50 #ifndef NULL
51 #define NULL 0
52 #endif
53
54
55
56 /**********************************************************************
57 * Memory macros
58 */
59
60 #define MALLOC(BYTES) _mesa_malloc(BYTES)
61 #define CALLOC(BYTES) _mesa_calloc(BYTES)
62 #define MALLOC_STRUCT(T) (struct T *) _mesa_malloc(sizeof(struct T))
63 #define CALLOC_STRUCT(T) (struct T *) _mesa_calloc(sizeof(struct T))
64 #define FREE(PTR) _mesa_free(PTR)
65
66 #define ALIGN_MALLOC(BYTES, N) _mesa_align_malloc(BYTES, N)
67 #define ALIGN_CALLOC(BYTES, N) _mesa_align_calloc(BYTES, N)
68 #define ALIGN_MALLOC_STRUCT(T, N) (struct T *) _mesa_align_malloc(sizeof(struct T), N)
69 #define ALIGN_CALLOC_STRUCT(T, N) (struct T *) _mesa_align_calloc(sizeof(struct T), N)
70 #define ALIGN_FREE(PTR) _mesa_align_free(PTR)
71
72 #define MEMCPY( DST, SRC, BYTES) _mesa_memcpy(DST, SRC, BYTES)
73 #define MEMSET( DST, VAL, N ) _mesa_memset(DST, VAL, N)
74
75 #define MEMSET16( DST, VAL, N ) _mesa_memset16( (DST), (VAL), (size_t) (N) )
76
77
78 /* MACs and BeOS don't support static larger than 32kb, so... */
79 #if defined(macintosh) && !defined(__MRC__)
80 /*extern char *AGLAlloc(int size);*/
81 /*extern void AGLFree(char* ptr);*/
82 # define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)_mesa_alloc(sizeof(TYPE)*(SIZE))
83 # define DEFMARRAY(TYPE,NAME,SIZE1,SIZE2) TYPE (*NAME)[SIZE2] = (TYPE(*)[SIZE2])_mesa_alloc(sizeof(TYPE)*(SIZE1)*(SIZE2))
84 # define DEFMNARRAY(TYPE,NAME,SIZE1,SIZE2,SIZE3) TYPE (*NAME)[SIZE2][SIZE3] = (TYPE(*)[SIZE2][SIZE3])_mesa_alloc(sizeof(TYPE)*(SIZE1)*(SIZE2)*(SIZE3))
85
86 # define CHECKARRAY(NAME,CMD) do {if (!(NAME)) {CMD;}} while (0)
87 # define UNDEFARRAY(NAME) do {if ((NAME)) {_mesa_free((char*)NAME);} }while (0)
88 #elif defined(__BEOS__)
89 # define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)_mesa_malloc(sizeof(TYPE)*(SIZE))
90 # define DEFMARRAY(TYPE,NAME,SIZE1,SIZE2) TYPE (*NAME)[SIZE2] = (TYPE(*)[SIZE2])_mesa_malloc(sizeof(TYPE)*(SIZE1)*(SIZE2))
91 # define DEFMNARRAY(TYPE,NAME,SIZE1,SIZE2,SIZE3) TYPE (*NAME)[SIZE2][SIZE3] = (TYPE(*)[SIZE2][SIZE3])_mesa_malloc(sizeof(TYPE)*(SIZE1)*(SIZE2)*(SIZE3))
92 # define CHECKARRAY(NAME,CMD) do {if (!(NAME)) {CMD;}} while (0)
93 # define UNDEFARRAY(NAME) do {if ((NAME)) {_mesa_free((char*)NAME);} }while (0)
94 #else
95 # define DEFARRAY(TYPE,NAME,SIZE) TYPE NAME[SIZE]
96 # define DEFMARRAY(TYPE,NAME,SIZE1,SIZE2) TYPE NAME[SIZE1][SIZE2]
97 # define DEFMNARRAY(TYPE,NAME,SIZE1,SIZE2,SIZE3) TYPE NAME[SIZE1][SIZE2][SIZE3]
98 # define CHECKARRAY(NAME,CMD) do {} while(0)
99 # define UNDEFARRAY(NAME)
100 #endif
101
102
103 #ifdef MESA_EXTERNAL_BUFFERALLOC
104 /*
105 * If you want Mesa's depth/stencil/accum/etc buffers to be allocated
106 * with a specialized allocator you can define MESA_EXTERNAL_BUFFERALLOC
107 * and implement _ext_mesa_alloc/free_pixelbuffer() in your app.
108 * Contributed by Gerk Huisma (gerk@five-d.demon.nl).
109 */
110 extern void *_ext_mesa_alloc_pixelbuffer( unsigned int size );
111 extern void _ext_mesa_free_pixelbuffer( void *pb );
112
113 #define MESA_PBUFFER_ALLOC(BYTES) (void *) _ext_mesa_alloc_pixelbuffer(BYTES)
114 #define MESA_PBUFFER_FREE(PTR) _ext_mesa_free_pixelbuffer(PTR)
115 #else
116 /* Default buffer allocation uses the aligned allocation routines: */
117 #define MESA_PBUFFER_ALLOC(BYTES) (void *) _mesa_align_malloc(BYTES, 512)
118 #define MESA_PBUFFER_FREE(PTR) _mesa_align_free(PTR)
119 #endif
120
121
122
123 /**********************************************************************
124 * Math macros
125 */
126
127 #define MAX_GLUSHORT 0xffff
128 #define MAX_GLUINT 0xffffffff
129
130 #ifndef M_PI
131 #define M_PI (3.1415926)
132 #endif
133
134 /* Degrees to radians conversion: */
135 #define DEG2RAD (M_PI/180.0)
136
137
138 /***
139 *** USE_IEEE: Determine if we're using IEEE floating point
140 ***/
141 #if defined(__i386__) || defined(__sparc__) || defined(__s390x__) || \
142 defined(__powerpc__) || \
143 ( defined(__alpha__) && ( defined(__IEEE_FLOAT) || !defined(VMS) ) )
144 #define USE_IEEE
145 #define IEEE_ONE 0x3f800000
146 #endif
147
148
149 /***
150 *** SQRTF: single-precision square root
151 ***/
152 #if defined(__WATCOMC__) && defined(USE_X86_ASM)
153 float asm_sqrt (float x);
154 #pragma aux asm_sqrt = \
155 "fsqrt" \
156 parm [8087] \
157 value [8087] \
158 modify exact [];
159 # define SQRTF(X) asm_sqrt(X)
160 #elif 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */
161 # define SQRTF(X) _mesa_sqrtf(X)
162 #elif defined(XFree86LOADER) && defined(IN_MODULE)
163 # define SQRTF(X) (float) xf86sqrt((float) (X))
164 #else
165 # define SQRTF(X) (float) sqrt((float) (X))
166 #endif
167
168
169 /***
170 *** INV_SQRTF: single-precision inverse square root
171 ***/
172 #if 0
173 #define INV_SQRTF(X) _mesa_inv_sqrt(X)
174 #else
175 #define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */
176 #endif
177
178
179 /***
180 *** LOG2: Log base 2 of float
181 ***/
182 #ifdef USE_IEEE
183 #if 0
184 /* This is pretty fast, but not accurate enough (only 2 fractional bits).
185 * Based on code from http://www.stereopsis.com/log2.html
186 */
187 static INLINE GLfloat LOG2(GLfloat x)
188 {
189 const GLfloat y = x * x * x * x;
190 const GLuint ix = *((GLuint *) &y);
191 const GLuint exp = (ix >> 23) & 0xFF;
192 const GLint log2 = ((GLint) exp) - 127;
193 return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */
194 }
195 #endif
196 /* Pretty fast, and accurate.
197 * Based on code from http://www.flipcode.com/totd/
198 */
199 static INLINE GLfloat LOG2(GLfloat val)
200 {
201 fi_type num;
202 GLint log_2;
203 num.f = val;
204 log_2 = ((num.i >> 23) & 255) - 128;
205 num.i &= ~(255 << 23);
206 num.i += 127 << 23;
207 num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
208 return num.f + log_2;
209 }
210 #elif defined(XFree86LOADER) && defined(IN_MODULE)
211 #define LOG2(x) ((GLfloat) (xf86log(x) * 1.442695))
212 #else
213 /*
214 * NOTE: log_base_2(x) = log(x) / log(2)
215 * NOTE: 1.442695 = 1/log(2).
216 */
217 #define LOG2(x) ((GLfloat) (log(x) * 1.442695F))
218 #endif
219
220
221 /***
222 *** IS_INF_OR_NAN: test if float is infinite or NaN
223 ***/
224 #ifdef USE_IEEE
225 static INLINE int IS_INF_OR_NAN( float x )
226 {
227 fi_type tmp;
228 tmp.f = x;
229 return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31);
230 }
231 #elif defined(isfinite)
232 #define IS_INF_OR_NAN(x) (!isfinite(x))
233 #elif defined(finite)
234 #define IS_INF_OR_NAN(x) (!finite(x))
235 #elif __VMS
236 #define IS_INF_OR_NAN(x) (!finite(x))
237 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
238 #define IS_INF_OR_NAN(x) (!isfinite(x))
239 #else
240 #define IS_INF_OR_NAN(x) (!finite(x))
241 #endif
242
243
244 /***
245 *** IS_NEGATIVE: test if float is negative
246 ***/
247 #if defined(USE_IEEE)
248 #define GET_FLOAT_BITS(x) ((fi_type *) &(x))->i
249 #define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) & (1<<31))
250 #else
251 #define IS_NEGATIVE(x) (x < 0.0F)
252 #endif
253
254
255 /***
256 *** DIFFERENT_SIGNS: test if two floats have opposite signs
257 ***/
258 #if defined(USE_IEEE)
259 #define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
260 #else
261 /* Could just use (x*y<0) except for the flatshading requirements.
262 * Maybe there's a better way?
263 */
264 #define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
265 #endif
266
267
268 /***
269 *** CEILF: ceiling of float
270 *** FLOORF: floor of float
271 *** FABSF: absolute value of float
272 ***/
273 #if defined(XFree86LOADER) && defined(IN_MODULE)
274 #define CEILF(x) ((GLfloat) xf86ceil(x))
275 #define FLOORF(x) ((GLfloat) xf86floor(x))
276 #define FABSF(x) ((GLfloat) xf86fabs(x))
277 #elif defined(__gnu_linux__)
278 /* C99 functions */
279 #define CEILF(x) ceilf(x)
280 #define FLOORF(x) floorf(x)
281 #define FABSF(x) fabsf(x)
282 #else
283 #define CEILF(x) ((GLfloat) ceil(x))
284 #define FLOORF(x) ((GLfloat) floor(x))
285 #define FABSF(x) ((GLfloat) fabs(x))
286 #endif
287
288
289 /***
290 *** IROUND: return (as an integer) float rounded to nearest integer
291 ***/
292 #if defined(USE_SPARC_ASM) && defined(__GNUC__) && defined(__sparc__)
293 static INLINE int iround(float f)
294 {
295 int r;
296 __asm__ ("fstoi %1, %0" : "=f" (r) : "f" (f));
297 return r;
298 }
299 #define IROUND(x) iround(x)
300 #elif defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
301 static INLINE int iround(float f)
302 {
303 int r;
304 __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
305 return r;
306 }
307 #define IROUND(x) iround(x)
308 #elif defined(USE_X86_ASM) && defined(__MSC__) && defined(__WIN32__)
309 static INLINE int iround(float f)
310 {
311 int r;
312 _asm {
313 fld f
314 fistp r
315 }
316 return r;
317 }
318 #define IROUND(x) iround(x)
319 #elif defined(USE_X86_ASM) && defined(__WATCOMC__)
320 long iround(float f);
321 #pragma aux iround = \
322 "push eax" \
323 "fistp dword ptr [esp]" \
324 "pop eax" \
325 parm [8087] \
326 value [eax] \
327 modify exact [eax];
328 #define IROUND(x) iround(x)
329 #elif defined(__OS2__)
330 #ifndef FIST_MAGIC
331 #define FIST_MAGIC ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0))
332 #endif
333 inline int iround(float x)
334 {
335 double dtemp = FIST_MAGIC + x;
336 return ((*(int *)&dtemp) - 0x80000000);
337 }
338 #define IROUND(f) iround((float)f)
339 #else
340 #define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F)))
341 #endif
342
343
344 /***
345 *** IROUND_POS: return (as an integer) positive float rounded to nearest int
346 ***/
347 #ifdef DEBUG
348 #define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f))
349 #else
350 #define IROUND_POS(f) (IROUND(f))
351 #endif
352
353
354 /***
355 *** IFLOOR: return (as an integer) floor of float
356 ***/
357 #if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
358 /*
359 * IEEE floor for computers that round to nearest or even.
360 * 'f' must be between -4194304 and 4194303.
361 * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
362 * but uses some IEEE specific tricks for better speed.
363 * Contributed by Josh Vanderhoof
364 */
365 static INLINE int ifloor(float f)
366 {
367 int ai, bi;
368 double af, bf;
369 af = (3 << 22) + 0.5 + (double)f;
370 bf = (3 << 22) + 0.5 - (double)f;
371 /* GCC generates an extra fstp/fld without this. */
372 __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
373 __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
374 return (ai - bi) >> 1;
375 }
376 #define IFLOOR(x) ifloor(x)
377 #elif defined(USE_IEEE)
378 static INLINE int ifloor(float f)
379 {
380 int ai, bi;
381 double af, bf;
382 fi_type u;
383
384 af = (3 << 22) + 0.5 + (double)f;
385 bf = (3 << 22) + 0.5 - (double)f;
386 u.f = (float) af; ai = u.i;
387 u.f = (float) bf; bi = u.i;
388 return (ai - bi) >> 1;
389 }
390 #define IFLOOR(x) ifloor(x)
391 #else
392 static INLINE int ifloor(float f)
393 {
394 int i = IROUND(f);
395 return (i > f) ? i - 1 : i;
396 }
397 #define IFLOOR(x) ifloor(x)
398 #endif
399
400
401 /***
402 *** ICEIL: return (as an integer) ceiling of float
403 ***/
404 #if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
405 /*
406 * IEEE ceil for computers that round to nearest or even.
407 * 'f' must be between -4194304 and 4194303.
408 * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1",
409 * but uses some IEEE specific tricks for better speed.
410 * Contributed by Josh Vanderhoof
411 */
412 static INLINE int iceil(float f)
413 {
414 int ai, bi;
415 double af, bf;
416 af = (3 << 22) + 0.5 + (double)f;
417 bf = (3 << 22) + 0.5 - (double)f;
418 /* GCC generates an extra fstp/fld without this. */
419 __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
420 __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
421 return (ai - bi + 1) >> 1;
422 }
423 #define ICEIL(x) iceil(x)
424 #elif defined(USE_IEEE)
425 static INLINE int iceil(float f)
426 {
427 int ai, bi;
428 double af, bf;
429 fi_type u;
430 af = (3 << 22) + 0.5 + (double)f;
431 bf = (3 << 22) + 0.5 - (double)f;
432 u.f = (float) af; ai = u.i;
433 u.f = (float) bf; bi = u.i;
434 return (ai - bi + 1) >> 1;
435 }
436 #define ICEIL(x) iceil(x)
437 #else
438 static INLINE int iceil(float f)
439 {
440 int i = IROUND(f);
441 return (i < f) ? i + 1 : i;
442 }
443 #define ICEIL(x) iceil(x)
444 #endif
445
446
447 /***
448 *** UNCLAMPED_FLOAT_TO_UBYTE: map float from {0,1} to ubyte in [0,255]
449 *** CLAMPED_FLOAT_TO_UBYTE: map float in [0,1] to ubyte in [0,255]
450 ***/
451 #if defined(USE_IEEE) && !defined(DEBUG)
452 #define IEEE_0996 0x3f7f0000 /* 0.996 or so */
453 /* This function/macro is sensitive to precision. Test very carefully
454 * if you change it!
455 */
456 #define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \
457 do { \
458 fi_type __tmp; \
459 __tmp.f = (F); \
460 UB = ((__tmp.i >= IEEE_0996) \
461 ? ((GLint)__tmp.i < 0) ? (GLubyte)0 : (GLubyte)255 \
462 : (__tmp.f = __tmp.f*(255.0F/256.0F) + 32768.0F, \
463 (GLubyte)__tmp.i)); \
464 } while (0)
465 #define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
466 UNCLAMPED_FLOAT_TO_UBYTE(ub, f)
467 #else
468 #define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \
469 ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))
470 #define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
471 ub = ((GLubyte) IROUND((f) * 255.0F))
472 #endif
473
474
475 /***
476 *** COPY_FLOAT: copy a float from src to dest, avoid slow FP regs if possible
477 ***/
478 #if defined(USE_IEEE) && !defined(DEBUG)
479 #define COPY_FLOAT( dst, src ) \
480 ((fi_type *) &(dst))->i = ((fi_type *) &(src))->i
481 #else
482 #define COPY_FLOAT( dst, src ) (dst) = (src)
483 #endif
484
485
486 /***
487 *** START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save
488 *** original mode to a temporary).
489 *** END_FAST_MATH: Restore x86 FPU to original mode.
490 ***/
491 #if defined(__GNUC__) && defined(__i386__)
492 /*
493 * Set the x86 FPU control word to guarentee only 32 bits of precision
494 * are stored in registers. Allowing the FPU to store more introduces
495 * differences between situations where numbers are pulled out of memory
496 * vs. situations where the compiler is able to optimize register usage.
497 *
498 * In the worst case, we force the compiler to use a memory access to
499 * truncate the float, by specifying the 'volatile' keyword.
500 */
501 /* Hardware default: All exceptions masked, extended double precision,
502 * round to nearest (IEEE compliant):
503 */
504 #define DEFAULT_X86_FPU 0x037f
505 /* All exceptions masked, single precision, round to nearest:
506 */
507 #define FAST_X86_FPU 0x003f
508 /* The fldcw instruction will cause any pending FP exceptions to be
509 * raised prior to entering the block, and we clear any pending
510 * exceptions before exiting the block. Hence, asm code has free
511 * reign over the FPU while in the fast math block.
512 */
513 #if defined(NO_FAST_MATH)
514 #define START_FAST_MATH(x) \
515 do { \
516 static GLuint mask = DEFAULT_X86_FPU; \
517 __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
518 __asm__ ( "fldcw %0" : : "m" (mask) ); \
519 } while (0)
520 #else
521 #define START_FAST_MATH(x) \
522 do { \
523 static GLuint mask = FAST_X86_FPU; \
524 __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
525 __asm__ ( "fldcw %0" : : "m" (mask) ); \
526 } while (0)
527 #endif
528 /* Restore original FPU mode, and clear any exceptions that may have
529 * occurred in the FAST_MATH block.
530 */
531 #define END_FAST_MATH(x) \
532 do { \
533 __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \
534 } while (0)
535
536 #elif defined(__WATCOMC__) && !defined(NO_FAST_MATH)
537 void _wacom_start_fast_math(unsigned short *x);
538 #pragma aux _wacom_start_fast_math = \
539 "fstcw word ptr [esi]" \
540 "or word ptr [esi], 0x3f" \
541 "fldcw word ptr [esi]" \
542 parm [esi] \
543 modify exact [];
544 void _wacom_end_fast_math(unsigned short *x);
545 #pragma aux _wacom_end_fast_math = \
546 "fldcw word ptr [esi]" \
547 parm [esi] \
548 modify exact [];
549 #define START_FAST_MATH(x) _wacom_start_fast_math(& x)
550 #define END_FAST_MATH(x) _wacom_end_fast_math(& x)
551 #else
552 #define START_FAST_MATH(x) x = 0
553 #define END_FAST_MATH(x) (void)(x)
554 #endif
555
556
557
558 /**********************************************************************
559 * Functions
560 */
561
562 extern void *
563 _mesa_malloc( size_t bytes );
564
565 extern void *
566 _mesa_calloc( size_t bytes );
567
568 extern void
569 _mesa_free( void *ptr );
570
571 extern void *
572 _mesa_align_malloc( size_t bytes, unsigned long alignment );
573
574 extern void *
575 _mesa_align_calloc( size_t bytes, unsigned long alignment );
576
577 extern void
578 _mesa_align_free( void *ptr );
579
580 extern void *
581 _mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize );
582
583 extern void *
584 _mesa_memcpy( void *dest, const void *src, size_t n );
585
586 extern void
587 _mesa_memset( void *dst, int val, size_t n );
588
589 extern void
590 _mesa_memset16( unsigned short *dst, unsigned short val, size_t n );
591
592 extern void
593 _mesa_bzero( void *dst, size_t n );
594
595
596 extern double
597 _mesa_sin(double a);
598
599 extern double
600 _mesa_cos(double a);
601
602 extern double
603 _mesa_sqrtd(double x);
604
605 extern float
606 _mesa_sqrtf(float x);
607
608 extern float
609 _mesa_inv_sqrtf(float x);
610
611 extern double
612 _mesa_pow(double x, double y);
613
614 extern float
615 _mesa_log2(float x);
616
617 extern unsigned int
618 _mesa_bitcount(unsigned int n);
619
620
621 extern char *
622 _mesa_getenv( const char *var );
623
624 extern char *
625 _mesa_strstr( const char *haystack, const char *needle );
626
627 extern char *
628 _mesa_strncat( char *dest, const char *src, size_t n );
629
630 extern char *
631 _mesa_strcpy( char *dest, const char *src );
632
633 extern char *
634 _mesa_strncpy( char *dest, const char *src, size_t n );
635
636 extern size_t
637 _mesa_strlen( const char *s );
638
639 extern int
640 _mesa_strcmp( const char *s1, const char *s2 );
641
642 extern int
643 _mesa_strncmp( const char *s1, const char *s2, size_t n );
644
645 extern char *
646 _mesa_strdup( const char *s );
647
648 extern int
649 _mesa_atoi( const char *s );
650
651 extern double
652 _mesa_strtod( const char *s, char **end );
653
654 extern int
655 _mesa_sprintf( char *str, const char *fmt, ... );
656
657 extern void
658 _mesa_printf( const char *fmtString, ... );
659
660
661 extern void
662 _mesa_warning( __GLcontext *gc, const char *fmtString, ... );
663
664 extern void
665 _mesa_problem( const __GLcontext *ctx, const char *fmtString, ... );
666
667 extern void
668 _mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
669
670 extern void
671 _mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
672
673
674 extern void
675 _mesa_init_default_imports( __GLimports *imports, void *driverCtx );
676
677
678 #ifdef __cplusplus
679 }
680 #endif
681
682
683 #endif /* IMPORTS_H */