annotate src/libm/s_floor.c @ 3099:82e60908fab1

Date: Mon, 23 Mar 2009 09:17:24 +0200 From: "Mike Gorchak" Subject: New QNX patches Please apply patch qnx4.diff, which is attached. What has been done: 1)Added back OpenGL ES renderer for QNX target. Added few corrections to OpenGL ES renderer to let it work under QNX. OpenGL ES renderer do not support textures under QNX, so I think some additional work must be done. 2) Added GL_OES_query_matrix extension to SDL_opengles.h header file, which required by OpenGL ES 1.1 specification. 3) Added attribute clearing at the entrance of function SDL_GL_GetAttribure(). Added error checking into the function SDL_GL_GetAttribure(), because some attributes can't be obtained in OpenGL ES 1.0. 4) Porting testdyngles to OpenGL ES 1.0 (1.1 has glColor4ub() and glColor4f() functions, but 1.0 has glColor4f() only). 5) Added error checking after obtaining attributes using SDL_GL_GetAttribute() function to the testgl2 and testgles. 6) Small correction to testmultiaudio with printing errors. 7) Added software and accelerated OpenGL ES 1.0 support into the QNX GF driver. Please remove ./src/audio/nto directory - it will not be used anymore. Please create ./src/audio/qsa directory and add content of the archive qsa.tar.gz into this directory. I rewrote some sound code, added support for multiple audio cards, enumeration, etc. Added initial support for capture. As far as I can understand SDL 1.3 is not supporting audio capture right now ? Sam, Am I right ? Or audio capture must be supported through the PlayDevice routine ? And last, please put file SDL_gf_opengles.c to the ./src/video/qnxgf directory. It is OpenGL ES 1.1 emulation layer for some functions, which are not supported by OpenGL ES 1.0.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 24 Mar 2009 10:33:12 +0000
parents f55c87ae336b
children dc1eb82ffdaa
rev   line source
2758
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /* @(#)s_floor.c 5.1 93/09/24 */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 /*
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 * ====================================================
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 *
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 * Permission to use, copy, modify, and distribute this
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 * software is freely granted, provided that this notice
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 * is preserved.
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 * ====================================================
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 #if defined(LIBM_SCCS) && !defined(lint)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 static char rcsid[] =
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 "$NetBSD: s_floor.c,v 1.8 1995/05/10 20:47:20 jtc Exp $";
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 #endif
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 /*
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 * floor(x)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 * Return x rounded toward -inf to integral value
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 * Method:
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 * Bit twiddling.
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 * Exception:
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 * Inexact flag raised if x not equal to floor(x).
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #include "math.h"
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include "math_private.h"
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #ifdef __STDC__
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 static const double huge = 1.0e300;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #else
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 static double huge = 1.0e300;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #endif
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 libm_hidden_proto(floor)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #ifdef __STDC__
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 double floor(double x)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #else
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 double floor(x)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 double x;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #endif
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 {
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 int32_t i0, i1, j0;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 u_int32_t i, j;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 EXTRACT_WORDS(i0, i1, x);
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 if (j0 < 20) {
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 if (j0 < 0) { /* raise inexact if x != 0 */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 if (huge + x > 0.0) { /* return 0*sign(x) if |x|<1 */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 if (i0 >= 0) {
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 i0 = i1 = 0;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 } else if (((i0 & 0x7fffffff) | i1) != 0) {
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 i0 = 0xbff00000;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 i1 = 0;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 }
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 }
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 } else {
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 i = (0x000fffff) >> j0;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 if (((i0 & i) | i1) == 0)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 return x; /* x is integral */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 if (huge + x > 0.0) { /* raise inexact flag */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 if (i0 < 0)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 i0 += (0x00100000) >> j0;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 i0 &= (~i);
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 i1 = 0;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 }
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 }
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 } else if (j0 > 51) {
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 if (j0 == 0x400)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 return x + x; /* inf or NaN */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 else
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 return x; /* x is integral */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 } else {
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 i = ((u_int32_t) (0xffffffff)) >> (j0 - 20);
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 if ((i1 & i) == 0)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 return x; /* x is integral */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 if (huge + x > 0.0) { /* raise inexact flag */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 if (i0 < 0) {
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 if (j0 == 20)
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 i0 += 1;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 else {
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 j = i1 + (1 << (52 - j0));
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2760
diff changeset
84 if (j < (u_int32_t) i1)
2758
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 i0 += 1; /* got a carry */
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 i1 = j;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 }
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 }
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 i1 &= (~i);
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 }
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 }
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 INSERT_WORDS(x, i0, i1);
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 return x;
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 }
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95
045d9976f285 Yet more math...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 libm_hidden_def(floor)