Add environ as a link seam for platform APIs

Allow precise redirection of platform-related APIs (such as those
provided by libc) for the purpose of unit tests.

Change-Id: I615b25805fc7a24eb5d67e87237bf35c8e262b93
Signed-off-by: Amithash Prasad <amithash@meta.com>
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/src/environ/meson.build b/src/environ/meson.build
new file mode 100644
index 0000000..24d6ce7
--- /dev/null
+++ b/src/environ/meson.build
@@ -0,0 +1 @@
+libpldm_sources += files('time.c')
diff --git a/src/environ/time.c b/src/environ/time.c
new file mode 100644
index 0000000..f70022b
--- /dev/null
+++ b/src/environ/time.c
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
+#include "compiler.h"
+#include "environ/time.h"
+
+#include <time.h>
+
+LIBPLDM_ABI_TESTING LIBPLDM_CC_WEAK int
+libpldm_clock_gettime(clockid_t clockid, struct timespec *ts)
+{
+	return clock_gettime(clockid, ts);
+}
diff --git a/src/environ/time.h b/src/environ/time.h
new file mode 100644
index 0000000..eed558e
--- /dev/null
+++ b/src/environ/time.h
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+#ifndef LIBPLDM_ENVIRON_TIME_H
+#define LIBPLDM_ENVIRON_TIME_H
+#include <sys/time.h>
+#include <time.h>
+
+/** @brief Weak symbol wrapping clock_gettime() */
+int libpldm_clock_gettime(clockid_t clockid, struct timespec *ts);
+
+#endif