From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=46118 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUHOG-0004KC-Kd for qemu-devel@nongnu.org; Thu, 01 Jul 2010 06:53:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OUHOF-0004ye-3w for qemu-devel@nongnu.org; Thu, 01 Jul 2010 06:53:08 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:59011) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OUHOE-0004xZ-PN for qemu-devel@nongnu.org; Thu, 01 Jul 2010 06:53:07 -0400 From: Stefan Weil Date: Thu, 1 Jul 2010 12:47:49 +0200 Message-Id: <1277981269-751-1-git-send-email-weil@mail.berlios.de> Subject: [Qemu-devel] [PATCH] win32: Add missing function setenv List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers 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 --- 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