[PATCH 04/14] introduce some env helpers

Sascha Hauer s.hauer at pengutronix.de
Mon Nov 28 03:02:10 EST 2011


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/env.c          |   22 ++++++++++++++++++++++
 include/environment.h |    3 +++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/common/env.c b/common/env.c
index 05ed714..e57a520 100644
--- a/common/env.c
+++ b/common/env.c
@@ -251,3 +251,25 @@ int export(const char *varname)
 	return 0;
 }
 EXPORT_SYMBOL(export);
+
+void export_env_ull(const char *name, unsigned long long val)
+{
+	char *valstr = asprintf("%lld", val);
+
+	setenv(name, valstr);
+	export(name);
+
+	kfree(valstr);
+}
+EXPORT_SYMBOL(export_env_ull);
+
+unsigned long long getenv_ull(const char *name)
+{
+	const char *valstr = getenv(name);
+
+	if (!valstr)
+		return 0;
+
+	return simple_strtoull(valstr, NULL, 0);
+}
+EXPORT_SYMBOL(getenv_ull);
diff --git a/include/environment.h b/include/environment.h
index da032e2..6d38755 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -59,6 +59,9 @@ static inline int setenv(const char *var, const char *val)
 }
 #endif
 
+void export_env_ull(const char *name, unsigned long long val);
+unsigned long long getenv_ull(const char *name);
+
 int env_pop_context(void);
 int env_push_context(void);
 
-- 
1.7.7.1




More information about the barebox mailing list