Patchwork [v2] sdl: fix setenv for win32

login
register
mail settings
Submitter TeLeMan
Date June 1, 2010, 1:44 a.m.
Message ID <AANLkTikka7d2puLjlEGeMNDQkUQauh6Mzujs7QBwtV95@mail.gmail.com>
Download mbox | patch
Permalink /patch/54139/
State New
Headers show

Comments

TeLeMan - June 1, 2010, 1:44 a.m.
setenv() is not implemented on MinGW, so we have to use putenv().

Signed-off-by: TeLeMan <geleman@gmail.com>
---
 sdl.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

     flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
Jan Kiszka - June 1, 2010, 6:28 a.m.
TeLeMan wrote:
> setenv() is not implemented on MinGW, so we have to use putenv().
> 
> Signed-off-by: TeLeMan <geleman@gmail.com>
> ---
>  sdl.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/sdl.c b/sdl.c
> index add1148..eac898a 100644
> --- a/sdl.c
> +++ b/sdl.c
> @@ -850,7 +850,14 @@ void sdl_display_init(DisplayState *ds, int
> full_screen, int no_frame)
>          gui_noframe = 1;
> 
>      if (!full_screen) {
> +#ifdef _WIN32
> +        /* setenv() is not implemented on MinGW */
> +        if(!getenv("SDL_VIDEO_ALLOW_SCREENSAVER")) {
> +            putenv("SDL_VIDEO_ALLOW_SCREENSAVER=1");
> +        }
> +#else
>          setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
> +#endif

As I said: both variants are equivalent, no need for #ifdefs, just
consolidate over the open-coded version.

>      }
> 
>      flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;

Jan
Avi Kivity - June 1, 2010, 6:33 a.m.
On 06/01/2010 09:28 AM, Jan Kiszka wrote:
> TeLeMan wrote:
>    
>> setenv() is not implemented on MinGW, so we have to use putenv().
>>
>> Signed-off-by: TeLeMan<geleman@gmail.com>
>> ---
>>   sdl.c |    7 +++++++
>>   1 files changed, 7 insertions(+), 0 deletions(-)
>>
>> diff --git a/sdl.c b/sdl.c
>> index add1148..eac898a 100644
>> --- a/sdl.c
>> +++ b/sdl.c
>> @@ -850,7 +850,14 @@ void sdl_display_init(DisplayState *ds, int
>> full_screen, int no_frame)
>>           gui_noframe = 1;
>>
>>       if (!full_screen) {
>> +#ifdef _WIN32
>> +        /* setenv() is not implemented on MinGW */
>> +        if(!getenv("SDL_VIDEO_ALLOW_SCREENSAVER")) {
>> +            putenv("SDL_VIDEO_ALLOW_SCREENSAVER=1");
>> +        }
>> +#else
>>           setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
>> +#endif
>>      
> As I said: both variants are equivalent, no need for #ifdefs, just
> consolidate over the open-coded version.
>
>    

The open coded version is less readable.  qemu_setenv()?

Patch

diff --git a/sdl.c b/sdl.c
index add1148..eac898a 100644
--- a/sdl.c
+++ b/sdl.c
@@ -850,7 +850,14 @@  void sdl_display_init(DisplayState *ds, int
full_screen, int no_frame)
         gui_noframe = 1;

     if (!full_screen) {
+#ifdef _WIN32
+        /* setenv() is not implemented on MinGW */
+        if(!getenv("SDL_VIDEO_ALLOW_SCREENSAVER")) {
+            putenv("SDL_VIDEO_ALLOW_SCREENSAVER=1");
+        }
+#else
         setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
+#endif
     }