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