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