qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <weil@mail.berlios.de>
To: QEMU Developers <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] win32: Add missing function setenv
Date: Thu,  1 Jul 2010 12:47:49 +0200	[thread overview]
Message-ID: <1277981269-751-1-git-send-email-weil@mail.berlios.de> (raw)

Mingw32 does not provide a declaration and implementation of function
setenv (which is used in sdl.c), so this patch adds both.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 os-win32.c |   15 +++++++++++++++
 osdep.h    |    2 ++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/os-win32.c b/os-win32.c
index d98fd77..dd46bf4 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -34,6 +34,21 @@
 #include "qemu-options.h"
 
 /***********************************************************/
+/* Functions missing in mingw */
+
+int setenv(const char *name, const char *value, int overwrite)
+{
+    int result = 0;
+    if (overwrite || !getenv(name)) {
+        size_t length = strlen(name) + strlen(value) + 2;
+        char *string = qemu_malloc(length);
+        snprintf(string, length, "%s=%s", name, value);
+        result = putenv(string);
+    }
+    return result;
+}
+
+/***********************************************************/
 /* Polling handling */
 
 typedef struct PollingEntry {
diff --git a/osdep.h b/osdep.h
index 75b5816..1cdc7e2 100644
--- a/osdep.h
+++ b/osdep.h
@@ -95,6 +95,8 @@ int qemu_create_pidfile(const char *filename);
 #ifdef _WIN32
 int ffs(int i);
 
+int setenv(const char *name, const char *value, int overwrite);
+
 typedef struct {
     long tv_sec;
     long tv_usec;
-- 
1.7.1

             reply	other threads:[~2010-07-01 10:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-01 10:47 Stefan Weil [this message]
2010-07-01 11:50 ` [Qemu-devel] [PATCH] win32: Add missing function setenv Jes Sorensen
2010-07-01 13:22   ` Stefan Weil
2010-07-01 13:24     ` Jes Sorensen
2010-07-01 15:51       ` Stefan Weil
2010-07-01 15:53         ` Jes Sorensen
2010-07-01 17:53           ` Stefan Weil
2010-07-02  8:40             ` Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1277981269-751-1-git-send-email-weil@mail.berlios.de \
    --to=weil@mail.berlios.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).