summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-02-23 05:31:11 +0000
committerMatt Turner <mattst88@gmail.com>2008-02-23 05:31:11 +0000
commit2902668e951a44db215867a2c2d9aa2d899d686b (patch)
tree0576c35973e8ee393e0c9f7587e7be5cef58602a
parent01fad53a58f67c948fcf2b5617e9b557f264671c (diff)
Only use inline-asm with gcc. Add fallback for other compilers
git-svn-id: svn://mattst88.com/svn/glpong/trunk@10 449aeecc-241a-0410-943f-e2f883e2d7a2
-rw-r--r--glpong.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/glpong.c b/glpong.c
index b5ad25c..6642f3b 100644
--- a/glpong.c
+++ b/glpong.c
@@ -168,6 +168,8 @@ GLPong_HandleEvents() {
static INLINE unsigned int
NextPow2(unsigned int value) {
+#if (defined __i386__ || defined __amd64__ || defined __x86_64__) \
+ && (defined __GNUC__)
unsigned int x;
__asm(
"dec %1 \n\t" /* so that if the number is a power of
@@ -179,6 +181,12 @@ NextPow2(unsigned int value) {
: "=r" (x)
: "c" (value)
);
+#else
+ unsigned int x = 0;
+ while (x < value) {
+ x *= 2;
+ }
+#endif
return x;
}