Add _mesa_atanf and _mesa_asinf functions.
[mesa.git] / src / mesa / main / imports.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 1999-2006 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 * \file imports.h
28 * Standard C library function wrappers.
29 *
30 * This file provides wrappers for all the standard C library functions
31 * like malloc(), free(), printf(), getenv(), etc.
32 */
33
34
35 #ifndef IMPORTS_H
36 #define IMPORTS_H
37
38
39 /* XXX some of the stuff in glheader.h should be moved into this file.
40 */
41 #include "glheader.h"
42 #include <GL/internal/glcore.h>
43
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49
50 /**********************************************************************/
51 /** \name General macros */
52 /*@{*/
53
54 #ifndef NULL
55 #define NULL 0
56 #endif
57
58 /*@}*/
59
60
61 /**********************************************************************/
62 /** Memory macros */
63 /*@{*/
64
65 /** Allocate \p BYTES bytes */
66 #define MALLOC(BYTES) _mesa_malloc(BYTES)
67 /** Allocate and zero \p BYTES bytes */
68 #define CALLOC(BYTES) _mesa_calloc(BYTES)
69 /** Allocate a structure of type \p T */
70 #define MALLOC_STRUCT(T) (struct T *) _mesa_malloc(sizeof(struct T))
71 /** Allocate and zero a structure of type \p T */
72 #define CALLOC_STRUCT(T) (struct T *) _mesa_calloc(sizeof(struct T))
73 /** Free memory */
74 #define FREE(PTR) _mesa_free(PTR)
75
76 /** Allocate \p BYTES aligned at \p N bytes */
77 #define ALIGN_MALLOC(BYTES, N) _mesa_align_malloc(BYTES, N)
78 /** Allocate and zero \p BYTES bytes aligned at \p N bytes */
79 #define ALIGN_CALLOC(BYTES, N) _mesa_align_calloc(BYTES, N)
80 /** Allocate a structure of type \p T aligned at \p N bytes */
81 #define ALIGN_MALLOC_STRUCT(T, N) (struct T *) _mesa_align_malloc(sizeof(struct T), N)
82 /** Allocate and zero a structure of type \p T aligned at \p N bytes */
83 #define ALIGN_CALLOC_STRUCT(T, N) (struct T *) _mesa_align_calloc(sizeof(struct T), N)
84 /** Free aligned memory */
85 #define ALIGN_FREE(PTR) _mesa_align_free(PTR)
86
87 /** Copy \p BYTES bytes from \p SRC into \p DST */
88 #define MEMCPY( DST, SRC, BYTES) _mesa_memcpy(DST, SRC, BYTES)
89 /** Set \p N bytes in \p DST to \p VAL */
90 #define MEMSET( DST, VAL, N ) _mesa_memset(DST, VAL, N)
91
92 /*@}*/
93
94
95 /*
96 * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers
97 * as offsets into buffer stores. Since the vertex array pointer and
98 * buffer store pointer are both pointers and we need to add them, we use
99 * this macro.
100 * Both pointers/offsets are expressed in bytes.
101 */
102 #define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) )
103
104
105 /**
106 * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float
107 * as a int (thereby using integer registers instead of FP registers) is
108 * a performance win. Typically, this can be done with ordinary casts.
109 * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0)
110 * these casts generate warnings.
111 * The following union typedef is used to solve that.
112 */
113 typedef union { GLfloat f; GLint i; } fi_type;
114
115
116
117 /**********************************************************************
118 * Math macros
119 */
120
121 #define MAX_GLUSHORT 0xffff
122 #define MAX_GLUINT 0xffffffff
123
124 #ifndef M_PI
125 #define M_PI (3.1415926536)
126 #endif
127
128 #ifndef M_E
129 #define M_E (2.7182818284590452354)
130 #endif
131
132
133 /* XXX this is a bit of a hack needed for compilation within XFree86 */
134 #ifndef FLT_MIN
135 #define FLT_MIN (1.0e-37)
136 #endif
137
138 /* Degrees to radians conversion: */
139 #define DEG2RAD (M_PI/180.0)
140
141
142 /***
143 *** USE_IEEE: Determine if we're using IEEE floating point
144 ***/
145 #if defined(__i386__) || defined(__386__) || defined(__sparc__) || \
146 defined(__s390x__) || defined(__powerpc__) || \
147 defined(__amd64__) || \
148 defined(ia64) || defined(__ia64__) || \
149 defined(__hppa__) || defined(hpux) || \
150 defined(__mips) || defined(_MIPS_ARCH) || \
151 defined(__arm__) || \
152 defined(__sh__) || \
153 (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS)))
154 #define USE_IEEE
155 #define IEEE_ONE 0x3f800000
156 #endif
157
158
159 /***
160 *** SQRTF: single-precision square root
161 ***/
162 #if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */
163 # define SQRTF(X) _mesa_sqrtf(X)
164 #elif defined(XFree86LOADER) && defined(IN_MODULE) && !defined(NO_LIBCWRAPPER)
165 # define SQRTF(X) (float) xf86sqrt((float) (X))
166 #else
167 # define SQRTF(X) (float) sqrt((float) (X))
168 #endif
169
170
171 /***
172 *** INV_SQRTF: single-precision inverse square root
173 ***/
174 #if 0
175 #define INV_SQRTF(X) _mesa_inv_sqrt(X)
176 #else
177 #define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */
178 #endif
179
180
181 /***
182 *** LOG2: Log base 2 of float
183 ***/
184 #ifdef USE_IEEE
185 #if 0
186 /* This is pretty fast, but not accurate enough (only 2 fractional bits).
187 * Based on code from http://www.stereopsis.com/log2.html
188 */
189 static INLINE GLfloat LOG2(GLfloat x)
190 {
191 const GLfloat y = x * x * x * x;
192 const GLuint ix = *((GLuint *) &y);
193 const GLuint exp = (ix >> 23) & 0xFF;
194 const GLint log2 = ((GLint) exp) - 127;
195 return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */
196 }
197 #endif
198 /* Pretty fast, and accurate.
199 * Based on code from http://www.flipcode.com/totd/
200 */
201 static INLINE GLfloat LOG2(GLfloat val)
202 {
203 fi_type num;
204 GLint log_2;
205 num.f = val;
206 log_2 = ((num.i >> 23) & 255) - 128;
207 num.i &= ~(255 << 23);
208 num.i += 127 << 23;
209 num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
210 return num.f + log_2;
211 }
212 #elif defined(XFree86LOADER) && defined(IN_MODULE) && !defined(NO_LIBCWRAPPER)
213 #define LOG2(x) ((GLfloat) (xf86log(x) * 1.442695))
214 #else
215 /*
216 * NOTE: log_base_2(x) = log(x) / log(2)
217 * NOTE: 1.442695 = 1/log(2).
218 */
219 #define LOG2(x) ((GLfloat) (log(x) * 1.442695F))
220 #endif
221
222
223 /***
224 *** IS_INF_OR_NAN: test if float is infinite or NaN
225 ***/
226 #ifdef USE_IEEE
227 static INLINE int IS_INF_OR_NAN( float x )
228 {
229 fi_type tmp;
230 tmp.f = x;
231 return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31);
232 }
233 #elif defined(isfinite)
234 #define IS_INF_OR_NAN(x) (!isfinite(x))
235 #elif defined(finite)
236 #define IS_INF_OR_NAN(x) (!finite(x))
237 #elif defined(__VMS)
238 #define IS_INF_OR_NAN(x) (!finite(x))
239 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
240 #define IS_INF_OR_NAN(x) (!isfinite(x))
241 #else
242 #define IS_INF_OR_NAN(x) (!finite(x))
243 #endif
244
245
246 /***
247 *** IS_NEGATIVE: test if float is negative
248 ***/
249 #if defined(USE_IEEE)
250 static INLINE int GET_FLOAT_BITS( float x )
251 {
252 fi_type fi;
253 fi.f = x;
254 return fi.i;
255 }
256 #define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0)
257 #else
258 #define IS_NEGATIVE(x) (x < 0.0F)
259 #endif
260
261
262 /***
263 *** DIFFERENT_SIGNS: test if two floats have opposite signs
264 ***/
265 #if defined(USE_IEEE)
266 #define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
267 #else
268 /* Could just use (x*y<0) except for the flatshading requirements.
269 * Maybe there's a better way?
270 */
271 #define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
272 #endif
273
274
275 /***
276 *** CEILF: ceiling of float
277 *** FLOORF: floor of float
278 *** FABSF: absolute value of float
279 *** LOGF: the natural logarithm (base e) of the value
280 *** EXPF: raise e to the value
281 *** LDEXPF: multiply value by an integral power of two
282 *** FREXPF: extract mantissa and exponent from value
283 ***/
284 #if defined(XFree86LOADER) && defined(IN_MODULE) && !defined(NO_LIBCWRAPPER)
285 #define CEILF(x) ((GLfloat) xf86ceil(x))
286 #define FLOORF(x) ((GLfloat) xf86floor(x))
287 #define FABSF(x) ((GLfloat) xf86fabs(x))
288 #define LOGF(x) ((GLfloat) xf86log(x))
289 #define EXPF(x) ((GLfloat) xf86exp(x))
290 #define LDEXPF(x,y) ((GLfloat) xf86ldexp(x,y))
291 #define FREXPF(x,y) ((GLfloat) xf86frexp(x,y))
292 #elif defined(__gnu_linux__)
293 /* C99 functions */
294 #define CEILF(x) ceilf(x)
295 #define FLOORF(x) floorf(x)
296 #define FABSF(x) fabsf(x)
297 #define LOGF(x) logf(x)
298 #define EXPF(x) expf(x)
299 #define LDEXPF(x,y) ldexpf(x,y)
300 #define FREXPF(x,y) frexpf(x,y)
301 #else
302 #define CEILF(x) ((GLfloat) ceil(x))
303 #define FLOORF(x) ((GLfloat) floor(x))
304 #define FABSF(x) ((GLfloat) fabs(x))
305 #define LOGF(x) ((GLfloat) log(x))
306 #define EXPF(x) ((GLfloat) exp(x))
307 #define LDEXPF(x,y) ((GLfloat) ldexp(x,y))
308 #define FREXPF(x,y) ((GLfloat) frexp(x,y))
309 #endif
310
311
312 /***
313 *** IROUND: return (as an integer) float rounded to nearest integer
314 ***/
315 #if defined(USE_SPARC_ASM) && defined(__GNUC__) && defined(__sparc__)
316 static INLINE int iround(float f)
317 {
318 int r;
319 __asm__ ("fstoi %1, %0" : "=f" (r) : "f" (f));
320 return r;
321 }
322 #define IROUND(x) iround(x)
323 #elif defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) && \
324 (!defined(__BEOS__) || (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)))
325 static INLINE int iround(float f)
326 {
327 int r;
328 __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
329 return r;
330 }
331 #define IROUND(x) iround(x)
332 #elif defined(USE_X86_ASM) && defined(__MSC__) && defined(__WIN32__)
333 static INLINE int iround(float f)
334 {
335 int r;
336 _asm {
337 fld f
338 fistp r
339 }
340 return r;
341 }
342 #define IROUND(x) iround(x)
343 #elif defined(__WATCOMC__) && defined(__386__)
344 long iround(float f);
345 #pragma aux iround = \
346 "push eax" \
347 "fistp dword ptr [esp]" \
348 "pop eax" \
349 parm [8087] \
350 value [eax] \
351 modify exact [eax];
352 #define IROUND(x) iround(x)
353 #else
354 #define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F)))
355 #endif
356
357
358 /***
359 *** IROUND_POS: return (as an integer) positive float rounded to nearest int
360 ***/
361 #ifdef DEBUG
362 #define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f))
363 #else
364 #define IROUND_POS(f) (IROUND(f))
365 #endif
366
367
368 /***
369 *** IFLOOR: return (as an integer) floor of float
370 ***/
371 #if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
372 /*
373 * IEEE floor for computers that round to nearest or even.
374 * 'f' must be between -4194304 and 4194303.
375 * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
376 * but uses some IEEE specific tricks for better speed.
377 * Contributed by Josh Vanderhoof
378 */
379 static INLINE int ifloor(float f)
380 {
381 int ai, bi;
382 double af, bf;
383 af = (3 << 22) + 0.5 + (double)f;
384 bf = (3 << 22) + 0.5 - (double)f;
385 /* GCC generates an extra fstp/fld without this. */
386 __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
387 __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
388 return (ai - bi) >> 1;
389 }
390 #define IFLOOR(x) ifloor(x)
391 #elif defined(USE_IEEE)
392 static INLINE int ifloor(float f)
393 {
394 int ai, bi;
395 double af, bf;
396 fi_type u;
397
398 af = (3 << 22) + 0.5 + (double)f;
399 bf = (3 << 22) + 0.5 - (double)f;
400 u.f = (float) af; ai = u.i;
401 u.f = (float) bf; bi = u.i;
402 return (ai - bi) >> 1;
403 }
404 #define IFLOOR(x) ifloor(x)
405 #else
406 static INLINE int ifloor(float f)
407 {
408 int i = IROUND(f);
409 return (i > f) ? i - 1 : i;
410 }
411 #define IFLOOR(x) ifloor(x)
412 #endif
413
414
415 /***
416 *** ICEIL: return (as an integer) ceiling of float
417 ***/
418 #if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
419 /*
420 * IEEE ceil for computers that round to nearest or even.
421 * 'f' must be between -4194304 and 4194303.
422 * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1",
423 * but uses some IEEE specific tricks for better speed.
424 * Contributed by Josh Vanderhoof
425 */
426 static INLINE int iceil(float f)
427 {
428 int ai, bi;
429 double af, bf;
430 af = (3 << 22) + 0.5 + (double)f;
431 bf = (3 << 22) + 0.5 - (double)f;
432 /* GCC generates an extra fstp/fld without this. */
433 __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
434 __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
435 return (ai - bi + 1) >> 1;
436 }
437 #define ICEIL(x) iceil(x)
438 #elif defined(USE_IEEE)
439 static INLINE int iceil(float f)
440 {
441 int ai, bi;
442 double af, bf;
443 fi_type u;
444 af = (3 << 22) + 0.5 + (double)f;
445 bf = (3 << 22) + 0.5 - (double)f;
446 u.f = (float) af; ai = u.i;
447 u.f = (float) bf; bi = u.i;
448 return (ai - bi + 1) >> 1;
449 }
450 #define ICEIL(x) iceil(x)
451 #else
452 static INLINE int iceil(float f)
453 {
454 int i = IROUND(f);
455 return (i < f) ? i + 1 : i;
456 }
457 #define ICEIL(x) iceil(x)
458 #endif
459
460
461 /***
462 *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255]
463 *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255]
464 ***/
465 #if defined(USE_IEEE) && !defined(DEBUG)
466 #define IEEE_0996 0x3f7f0000 /* 0.996 or so */
467 /* This function/macro is sensitive to precision. Test very carefully
468 * if you change it!
469 */
470 #define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \
471 do { \
472 fi_type __tmp; \
473 __tmp.f = (F); \
474 if (__tmp.i < 0) \
475 UB = (GLubyte) 0; \
476 else if (__tmp.i >= IEEE_0996) \
477 UB = (GLubyte) 255; \
478 else { \
479 __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F; \
480 UB = (GLubyte) __tmp.i; \
481 } \
482 } while (0)
483 #define CLAMPED_FLOAT_TO_UBYTE(UB, F) \
484 do { \
485 fi_type __tmp; \
486 __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \
487 UB = (GLubyte) __tmp.i; \
488 } while (0)
489 #else
490 #define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \
491 ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))
492 #define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
493 ub = ((GLubyte) IROUND((f) * 255.0F))
494 #endif
495
496
497 /***
498 *** START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save
499 *** original mode to a temporary).
500 *** END_FAST_MATH: Restore x86 FPU to original mode.
501 ***/
502 #if defined(__GNUC__) && defined(__i386__)
503 /*
504 * Set the x86 FPU control word to guarentee only 32 bits of precision
505 * are stored in registers. Allowing the FPU to store more introduces
506 * differences between situations where numbers are pulled out of memory
507 * vs. situations where the compiler is able to optimize register usage.
508 *
509 * In the worst case, we force the compiler to use a memory access to
510 * truncate the float, by specifying the 'volatile' keyword.
511 */
512 /* Hardware default: All exceptions masked, extended double precision,
513 * round to nearest (IEEE compliant):
514 */
515 #define DEFAULT_X86_FPU 0x037f
516 /* All exceptions masked, single precision, round to nearest:
517 */
518 #define FAST_X86_FPU 0x003f
519 /* The fldcw instruction will cause any pending FP exceptions to be
520 * raised prior to entering the block, and we clear any pending
521 * exceptions before exiting the block. Hence, asm code has free
522 * reign over the FPU while in the fast math block.
523 */
524 #if defined(NO_FAST_MATH)
525 #define START_FAST_MATH(x) \
526 do { \
527 static GLuint mask = DEFAULT_X86_FPU; \
528 __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
529 __asm__ ( "fldcw %0" : : "m" (mask) ); \
530 } while (0)
531 #else
532 #define START_FAST_MATH(x) \
533 do { \
534 static GLuint mask = FAST_X86_FPU; \
535 __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
536 __asm__ ( "fldcw %0" : : "m" (mask) ); \
537 } while (0)
538 #endif
539 /* Restore original FPU mode, and clear any exceptions that may have
540 * occurred in the FAST_MATH block.
541 */
542 #define END_FAST_MATH(x) \
543 do { \
544 __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \
545 } while (0)
546
547 #elif defined(__WATCOMC__) && defined(__386__)
548 #define DEFAULT_X86_FPU 0x037f /* See GCC comments above */
549 #define FAST_X86_FPU 0x003f /* See GCC comments above */
550 void _watcom_start_fast_math(unsigned short *x,unsigned short *mask);
551 #pragma aux _watcom_start_fast_math = \
552 "fnstcw word ptr [eax]" \
553 "fldcw word ptr [ecx]" \
554 parm [eax] [ecx] \
555 modify exact [];
556 void _watcom_end_fast_math(unsigned short *x);
557 #pragma aux _watcom_end_fast_math = \
558 "fnclex" \
559 "fldcw word ptr [eax]" \
560 parm [eax] \
561 modify exact [];
562 #if defined(NO_FAST_MATH)
563 #define START_FAST_MATH(x) \
564 do { \
565 static GLushort mask = DEFAULT_X86_FPU; \
566 _watcom_start_fast_math(&x,&mask); \
567 } while (0)
568 #else
569 #define START_FAST_MATH(x) \
570 do { \
571 static GLushort mask = FAST_X86_FPU; \
572 _watcom_start_fast_math(&x,&mask); \
573 } while (0)
574 #endif
575 #define END_FAST_MATH(x) _watcom_end_fast_math(&x)
576 #else
577 #define START_FAST_MATH(x) x = 0
578 #define END_FAST_MATH(x) (void)(x)
579 #endif
580
581
582
583 /**********************************************************************
584 * Functions
585 */
586
587 extern void *
588 _mesa_malloc( size_t bytes );
589
590 extern void *
591 _mesa_calloc( size_t bytes );
592
593 extern void
594 _mesa_free( void *ptr );
595
596 extern void *
597 _mesa_align_malloc( size_t bytes, unsigned long alignment );
598
599 extern void *
600 _mesa_align_calloc( size_t bytes, unsigned long alignment );
601
602 extern void
603 _mesa_align_free( void *ptr );
604
605 extern void *
606 _mesa_exec_malloc( GLuint size );
607
608 extern void
609 _mesa_exec_free( void *addr );
610
611 extern void *
612 _mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize );
613
614 extern void *
615 _mesa_memcpy( void *dest, const void *src, size_t n );
616
617 extern void
618 _mesa_memset( void *dst, int val, size_t n );
619
620 extern void
621 _mesa_memset16( unsigned short *dst, unsigned short val, size_t n );
622
623 extern void
624 _mesa_bzero( void *dst, size_t n );
625
626 extern int
627 _mesa_memcmp( const void *s1, const void *s2, size_t n );
628
629 extern double
630 _mesa_sin(double a);
631
632 extern double
633 _mesa_cos(double a);
634
635 extern float
636 _mesa_asinf(float x);
637
638 extern float
639 _mesa_atanf(float x);
640
641 extern double
642 _mesa_sqrtd(double x);
643
644 extern float
645 _mesa_sqrtf(float x);
646
647 extern float
648 _mesa_inv_sqrtf(float x);
649
650 extern double
651 _mesa_pow(double x, double y);
652
653 extern int
654 _mesa_ffs(int i);
655
656 extern unsigned int
657 _mesa_bitcount(unsigned int n);
658
659 extern GLhalfARB
660 _mesa_float_to_half(float f);
661
662 extern float
663 _mesa_half_to_float(GLhalfARB h);
664
665
666 extern void *
667 _mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
668 int (*compar)(const void *, const void *) );
669
670 extern char *
671 _mesa_getenv( const char *var );
672
673 extern char *
674 _mesa_strstr( const char *haystack, const char *needle );
675
676 extern char *
677 _mesa_strncat( char *dest, const char *src, size_t n );
678
679 extern char *
680 _mesa_strcpy( char *dest, const char *src );
681
682 extern char *
683 _mesa_strncpy( char *dest, const char *src, size_t n );
684
685 extern size_t
686 _mesa_strlen( const char *s );
687
688 extern int
689 _mesa_strcmp( const char *s1, const char *s2 );
690
691 extern int
692 _mesa_strncmp( const char *s1, const char *s2, size_t n );
693
694 extern char *
695 _mesa_strdup( const char *s );
696
697 extern int
698 _mesa_atoi( const char *s );
699
700 extern double
701 _mesa_strtod( const char *s, char **end );
702
703 extern int
704 _mesa_sprintf( char *str, const char *fmt, ... );
705
706 extern void
707 _mesa_printf( const char *fmtString, ... );
708
709 extern int
710 _mesa_vsprintf( char *str, const char *fmt, va_list args );
711
712
713 extern void
714 _mesa_warning( __GLcontext *gc, const char *fmtString, ... );
715
716 extern void
717 _mesa_problem( const __GLcontext *ctx, const char *fmtString, ... );
718
719 extern void
720 _mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
721
722 extern void
723 _mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
724
725 extern void
726 _mesa_exit( int status );
727
728
729 extern void
730 _mesa_init_default_imports( __GLimports *imports, void *driverCtx );
731
732
733 #ifdef __cplusplus
734 }
735 #endif
736
737
738 #endif /* IMPORTS_H */