annotate test/testpower.c @ 5130:f2c2f0ecba5f

Fixed bug #1111 kwm@rainbow-runner.nl 2011-01-30 06:28:27 PST Created attachment 562 [details] Build fix with clang. When building sdl 1.2.14 with the Clang compiler http://clang.llvm.org . The build fails in src/video/mmx.h with the following error: -------------------------------------------------- ./src/video/SDL_RLEaccel.c:831:5: error: invalid operand for instruction CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt); ^ ./src/video/SDL_RLEaccel.c:831:17: note: instantiated from: CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt); ^ ./src/video/SDL_RLEaccel.c:831:5: note: instantiated from: CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt); ^ ./src/video/SDL_RLEaccel.c:647:23: note: instantiated from: blitter(2, Uint8, ALPHA_BLIT16_565MMX); \ ^ ./src/video/SDL_RLEaccel.c:282:4: note: instantiated from: movq_r2m(mm3, *dstp); \ ^ In file included from ./src/video/SDL_RLEaccel.c:99: ./src/video/mmx.h:379:28: note: instantiated from: #define movq_r2m(reg, var) mmx_r2m(movq, reg, var) ^ <scratch space>:192:1: note: instantiated from: "movq" ^ <inline asm>:1:2: note: instantiated into assembly here movq %mm3, %dx ^ -------------------------------------------------- According to the clang developers this is a invalid inline assembly. Using the attached patch from the last commit in the below bug report fixes the compile. More details from: http://llvm.org/bugs/show_bug.cgi?id=6730
author Sam Lantinga <slouken@libsdl.org>
date Sun, 30 Jan 2011 13:42:05 -0800
parents 51750b7a966f
children
rev   line source
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /* Simple test of power subsystem. */
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 #include <stdio.h>
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4 #include "SDL.h"
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
6 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
7 report_power(void)
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9 int seconds, percent;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 char *statestr = NULL;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 printf("SDL-reported power info...\n");
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
14 switch (state) {
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
15 case SDL_POWERSTATE_UNKNOWN:
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
16 statestr = "Unknown";
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
17 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
18 case SDL_POWERSTATE_ON_BATTERY:
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
19 statestr = "On battery";
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
20 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
21 case SDL_POWERSTATE_NO_BATTERY:
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
22 statestr = "No battery";
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
23 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
24 case SDL_POWERSTATE_CHARGING:
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
25 statestr = "Charging";
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
26 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
27 case SDL_POWERSTATE_CHARGED:
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
28 statestr = "Charged";
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
29 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
30 default:
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
31 statestr = "!!API ERROR!!";
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
32 break;
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 printf("State: %s\n", statestr);
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 if (percent == -1) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 printf("Percent left: unknown\n");
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 } else {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 printf("Percent left: %d%%\n", percent);
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43 if (seconds == -1) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 printf("Time left: unknown\n");
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 } else {
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
46 printf("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
47 (int) (seconds % 60));
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
51
3186
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
52 int
Sam Lantinga <slouken@libsdl.org>
parents: 3170
diff changeset
53 main(int argc, char *argv[])
3170
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55 if (SDL_Init(SDL_INIT_VIDEO) == -1) {
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
57 return 1;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
58 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 report_power();
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62 SDL_Quit();
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63 return 0;
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64 }
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65
b7a48f533966 Initial work on power subsystem for SDL 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66 /* end of testpower.c ... */