aboutsummaryrefslogtreecommitdiffstats
path: root/src/android.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/android.h')
-rw-r--r--src/android.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/android.h b/src/android.h
new file mode 100644
index 00000000000..6bdcd38ed68
--- /dev/null
+++ b/src/android.h
@@ -0,0 +1,70 @@
1/* Android initialization for GNU Emacs.
2
3Copyright (C) 2023 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or (at
10your option) any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19
20/* On Android, Emacs is built as a shared library loaded from Java
21 using the Java Native Interface. Emacs's `main' function is
22 renamed `android_emacs_init', and runs with some modifications
23 inside a separate thread, communicating with the Java code through
24 a table of function pointers. */
25
26#ifndef _ANDROID_H_
27#ifndef ANDROID_STUBIFY
28#include <jni.h>
29#include <pwd.h>
30#include <sys/stat.h>
31#endif
32
33/* This must be used in every symbol declaration to export it to the
34 JNI Emacs wrapper. */
35#define ANDROID_EXPORT __attribute__ ((visibility ("default")))
36
37extern bool ANDROID_EXPORT android_init_gui;
38extern int ANDROID_EXPORT android_emacs_init (int, char **);
39
40#ifndef ANDROID_STUBIFY
41
42extern int android_select (int, fd_set *, fd_set *, fd_set *,
43 struct timespec *, const sigset_t *);
44
45extern bool android_file_access_p (const char *, int);
46extern int android_open (const char *, int, int);
47extern char *android_user_full_name (struct passwd *);
48extern int android_fstat (int, struct stat *);
49extern int android_fstatat (int, const char *restrict,
50 struct stat *restrict, int);
51extern int android_close (int);
52
53#endif
54
55/* JNI functions should not be built when Emacs is stubbed out for the
56 build. These should be documented in EmacsNative.java. */
57
58#ifndef ANDROID_STUBIFY
59#include <jni.h>
60
61extern JNIEnv *android_java_env;
62
63#define ANDROID_DELETE_LOCAL_REF(ref) \
64 ((*android_java_env)->DeleteLocalRef (android_java_env, \
65 (ref)))
66
67#define NATIVE_NAME(name) Java_org_gnu_emacs_EmacsNative_##name
68
69#endif
70#endif /* _ANDROID_H_ */