Skip to contentSkip to conversation

qemu-ga: Fix use of environ on Darwin

PATCH In review Andreas Färber 2 participants 2 messages May 27, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-ga: Fix use of environ on Darwin

Use _NSGetEnviron() helper to access the environment.

Cc Charlie Somerville <[email protected]>

---
Michael, can you please append this to your qemu-ga PULL?

 qga/commands-posix.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
qga/commands-posix.c +5 -0
index dab3bf9..4a71c27 100644
@@ -22,8 +22,13 @@
 #include "host-utils.h"
 
 #ifndef CONFIG_HAS_ENVIRON
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
 extern char **environ;
 #endif
+#endif
 
 #if defined(__linux__)
 #include <mntent.h>
Signature · 1 line
1.7.5.3
#1 lore raw

Am 27.05.2012 17:02, schrieb Andreas Färber:

Quoted 18 lines

Use _NSGetEnviron() helper to access the environment.

Cc Charlie Somerville <[email protected]>

---
Michael, can you please append this to your qemu-ga PULL?

 qga/commands-posix.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
qga/commands-posix.c +0 -0
index dab3bf9..4a71c27 100644
@@ -22,8 +22,13 @@
 #include "host-utils.h"
 
 #ifndef CONFIG_HAS_ENVIRON

qga/commands-posix.c line 34

Quoted 10 lines
qga/commands-posix.c +5 -0
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
 extern char **environ;
 #endif
+#endif
 
 #if defined(__linux__)
 #include <mntent.h>

For 1.2 it might also be a good idea to move this block to osdep.h, so that it doesn't get duplicated when needed somewhere else.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg