~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/mesa/main/imports.h

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
#define exp2f(f) ((float) exp2(f))
135
135
#define floorf(f) ((float) floor(f))
136
136
#define logf(f) ((float) log(f))
 
137
 
 
138
#ifdef ANDROID
 
139
#define log2f(f) (logf(f) * (float) (1.0 / M_LN2))
 
140
#else
137
141
#define log2f(f) ((float) log2(f))
 
142
#endif
 
143
 
138
144
#define powf(x,y) ((float) pow(x,y))
139
145
#define sinf(f) ((float) sin(f))
140
146
#define sinhf(f) ((float) sinh(f))
147
153
#endif
148
154
 
149
155
#if defined(_MSC_VER)
150
 
static INLINE float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); }
151
 
static INLINE float exp2f(float x) { return powf(2.0f, x); }
152
 
static INLINE float log2f(float x) { return logf(x) * 1.442695041f; }
153
 
static INLINE float asinhf(float x) { return logf(x + sqrtf(x * x + 1.0f)); }
154
 
static INLINE float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); }
155
 
static INLINE float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; }
156
 
static INLINE int isblank(int ch) { return ch == ' ' || ch == '\t'; }
 
156
static inline float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); }
 
157
static inline float exp2f(float x) { return powf(2.0f, x); }
 
158
static inline float log2f(float x) { return logf(x) * 1.442695041f; }
 
159
static inline float asinhf(float x) { return logf(x + sqrtf(x * x + 1.0f)); }
 
160
static inline float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); }
 
161
static inline float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; }
 
162
static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; }
157
163
#define strtoll(p, e, b) _strtoi64(p, e, b)
158
164
#endif
159
165
/*@}*/
166
172
/* This is pretty fast, but not accurate enough (only 2 fractional bits).
167
173
 * Based on code from http://www.stereopsis.com/log2.html
168
174
 */
169
 
static INLINE GLfloat LOG2(GLfloat x)
 
175
static inline GLfloat LOG2(GLfloat x)
170
176
{
171
177
   const GLfloat y = x * x * x * x;
172
178
   const GLuint ix = *((GLuint *) &y);
178
184
/* Pretty fast, and accurate.
179
185
 * Based on code from http://www.flipcode.com/totd/
180
186
 */
181
 
static INLINE GLfloat LOG2(GLfloat val)
 
187
static inline GLfloat LOG2(GLfloat val)
182
188
{
183
189
   fi_type num;
184
190
   GLint log_2;
202
208
 *** IS_INF_OR_NAN: test if float is infinite or NaN
203
209
 ***/
204
210
#ifdef USE_IEEE
205
 
static INLINE int IS_INF_OR_NAN( float x )
 
211
static inline int IS_INF_OR_NAN( float x )
206
212
{
207
213
   fi_type tmp;
208
214
   tmp.f = x;
225
231
 *** IS_NEGATIVE: test if float is negative
226
232
 ***/
227
233
#if defined(USE_IEEE)
228
 
static INLINE int GET_FLOAT_BITS( float x )
 
234
static inline int GET_FLOAT_BITS( float x )
229
235
{
230
236
   fi_type fi;
231
237
   fi.f = x;
283
289
 *** IROUND: return (as an integer) float rounded to nearest integer
284
290
 ***/
285
291
#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
286
 
static INLINE int iround(float f)
 
292
static inline int iround(float f)
287
293
{
288
294
   int r;
289
295
   __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
291
297
}
292
298
#define IROUND(x)  iround(x)
293
299
#elif defined(USE_X86_ASM) && defined(_MSC_VER)
294
 
static INLINE int iround(float f)
 
300
static inline int iround(float f)
295
301
{
296
302
   int r;
297
303
   _asm {
338
344
 * but uses some IEEE specific tricks for better speed.
339
345
 * Contributed by Josh Vanderhoof
340
346
 */
341
 
static INLINE int ifloor(float f)
 
347
static inline int ifloor(float f)
342
348
{
343
349
   int ai, bi;
344
350
   double af, bf;
351
357
}
352
358
#define IFLOOR(x)  ifloor(x)
353
359
#elif defined(USE_IEEE)
354
 
static INLINE int ifloor(float f)
 
360
static inline int ifloor(float f)
355
361
{
356
362
   int ai, bi;
357
363
   double af, bf;
365
371
}
366
372
#define IFLOOR(x)  ifloor(x)
367
373
#else
368
 
static INLINE int ifloor(float f)
 
374
static inline int ifloor(float f)
369
375
{
370
376
   int i = IROUND(f);
371
377
   return (i > f) ? i - 1 : i;
385
391
 * but uses some IEEE specific tricks for better speed.
386
392
 * Contributed by Josh Vanderhoof
387
393
 */
388
 
static INLINE int iceil(float f)
 
394
static inline int iceil(float f)
389
395
{
390
396
   int ai, bi;
391
397
   double af, bf;
398
404
}
399
405
#define ICEIL(x)  iceil(x)
400
406
#elif defined(USE_IEEE)
401
 
static INLINE int iceil(float f)
 
407
static inline int iceil(float f)
402
408
{
403
409
   int ai, bi;
404
410
   double af, bf;
411
417
}
412
418
#define ICEIL(x)  iceil(x)
413
419
#else
414
 
static INLINE int iceil(float f)
 
420
static inline int iceil(float f)
415
421
{
416
422
   int i = IROUND(f);
417
423
   return (i < f) ? i + 1 : i;
423
429
/**
424
430
 * Is x a power of two?
425
431
 */
426
 
static INLINE int
 
432
static inline int
427
433
_mesa_is_pow_two(int x)
428
434
{
429
435
   return !(x & (x - 1));
443
449
 * results would be different depending on optimization
444
450
 * level used for build.
445
451
 */
446
 
static INLINE int32_t
 
452
static inline int32_t
447
453
_mesa_next_pow_two_32(uint32_t x)
448
454
{
449
455
#if defined(__GNUC__) && \
450
 
        ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
 
456
        ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
451
457
        uint32_t y = (x != 1);
452
458
        return (1 + y) << ((__builtin_clz(x - y) ^ 31) );
453
459
#else
462
468
#endif
463
469
}
464
470
 
465
 
static INLINE int64_t
 
471
static inline int64_t
466
472
_mesa_next_pow_two_64(uint64_t x)
467
473
{
468
474
#if defined(__GNUC__) && \
469
 
        ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
 
475
        ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
470
476
        uint64_t y = (x != 1);
471
477
        if (sizeof(x) == sizeof(long))
472
478
                return (1 + y) << ((__builtin_clzl(x - y) ^ 63));
489
495
/*
490
496
 * Returns the floor form of binary logarithm for a 32-bit integer.
491
497
 */
492
 
static INLINE GLuint
 
498
static inline GLuint
493
499
_mesa_logbase2(GLuint n)
494
500
{
495
501
#if defined(__GNUC__) && \
496
 
   ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
 
502
   ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
497
503
   return (31 - __builtin_clz(n | 1));
498
504
#else
499
505
   GLuint pos = 0;
510
516
/**
511
517
 * Return 1 if this is a little endian machine, 0 if big endian.
512
518
 */
513
 
static INLINE GLboolean
 
519
static inline GLboolean
514
520
_mesa_little_endian(void)
515
521
{
516
522
   const GLuint ui = 1; /* intentionally not static */
562
568
 
563
569
#ifdef __GNUC__
564
570
 
565
 
#ifdef __MINGW32__
 
571
#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(ANDROID) || defined(__APPLE__)
566
572
#define ffs __builtin_ffs
567
573
#define ffsll __builtin_ffsll
568
574
#endif
570
576
#define _mesa_ffs(i)  ffs(i)
571
577
#define _mesa_ffsll(i)  ffsll(i)
572
578
 
573
 
#if ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
 
579
#if ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
574
580
#define _mesa_bitcount(i) __builtin_popcount(i)
 
581
#define _mesa_bitcount_64(i) __builtin_popcountll(i)
575
582
#else
576
583
extern unsigned int
577
584
_mesa_bitcount(unsigned int n);
 
585
extern unsigned int
 
586
_mesa_bitcount_64(uint64_t n);
578
587
#endif
579
588
 
580
589
#else