aboutsummaryrefslogtreecommitdiff
path: root/support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c
diff options
context:
space:
mode:
Diffstat (limited to 'support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c')
-rw-r--r--support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c b/support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c
new file mode 100644
index 0000000000..ed87e345af
--- /dev/null
+++ b/support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c
@@ -0,0 +1,39 @@
+#include "native.h"
+#include <stdio.h>
+#include <time.h>
+
+// Pure native functions
+
+#define CHAR_BUFFER_SIZE 256
+static char buffer[CHAR_BUFFER_SIZE];
+
+const char* read_constant_string()
+{
+ return "Hello from C";
+}
+const char* read_internal_string()
+{
+ return buffer;
+}
+void write_internal_string(const char* string)
+{
+ snprintf(buffer, CHAR_BUFFER_SIZE, "%s", string);
+}
+void write_external_string(char* string, size_t maxLength)
+{
+ snprintf(string, maxLength, "Set from C");
+}
+void execute_function(void(*function)(void*), void* context)
+{
+ function(context);
+}
+void set_time_in_seconds(int seconds)
+{
+ time_t timeToSet = seconds;
+ stime(&timeToSet);
+}
+void write_internal_time_in_seconds()
+{
+ time_t systemTime = time(NULL);
+ snprintf(buffer, CHAR_BUFFER_SIZE, "%u", systemTime);
+}