From 412f0429295e38e853f5a1246a2b2711165309f4 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 10 Dec 2015 11:17:15 +0100
Subject: [PATCH 2/2] HSA: add configure check of secure_getenv in libgomp
---
libgomp/configure | 2 +-
libgomp/configure.ac | 2 +-
libgomp/plugin/plugin-hsa.c | 12 ++++++++++--
3 files changed, 12 insertions(+), 4 deletions(-)
@@ -15459,7 +15459,7 @@ _ACEOF
# Check for functions needed.
-for ac_func in getloadavg clock_gettime strtoull
+for ac_func in getloadavg clock_gettime strtoull secure_getenv __secure_getenv
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -205,7 +205,7 @@ esac
m4_include([plugin/configfrag.ac])
# Check for functions needed.
-AC_CHECK_FUNCS(getloadavg clock_gettime strtoull)
+AC_CHECK_FUNCS(getloadavg clock_gettime strtoull secure_getenv __secure_getenv)
# Check for broken semaphore implementation on darwin.
# sem_init returns: sem_init error: Function not implemented.
@@ -37,6 +37,14 @@
#include "libgomp-plugin.h"
#include "gomp-constants.h"
+#ifndef HAVE_SECURE_GETENV
+# ifdef HAVE___SECURE_GETENV
+# define secure_getenv __secure_getenv
+# else
+# define secure_getenv getenv
+# endif
+#endif
+
/* Part of the libgomp plugin interface. Return the name of the accelerator,
which is "hsa". */
@@ -87,12 +95,12 @@ static bool suppress_host_fallback;
static void
init_enviroment_variables (void)
{
- if (getenv ("HSA_DEBUG"))
+ if (secure_getenv ("HSA_DEBUG"))
debug = true;
else
debug = false;
- if (getenv ("HSA_SUPPRESS_HOST_FALLBACK"))
+ if (secure_getenv ("HSA_SUPPRESS_HOST_FALLBACK"))
suppress_host_fallback = true;
else
suppress_host_fallback = false;
--
2.6.3