diff options
Diffstat (limited to 'src/android.h')
| -rw-r--r-- | src/android.h | 70 |
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 | |||
| 3 | Copyright (C) 2023 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or (at | ||
| 10 | your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along 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 | |||
| 37 | extern bool ANDROID_EXPORT android_init_gui; | ||
| 38 | extern int ANDROID_EXPORT android_emacs_init (int, char **); | ||
| 39 | |||
| 40 | #ifndef ANDROID_STUBIFY | ||
| 41 | |||
| 42 | extern int android_select (int, fd_set *, fd_set *, fd_set *, | ||
| 43 | struct timespec *, const sigset_t *); | ||
| 44 | |||
| 45 | extern bool android_file_access_p (const char *, int); | ||
| 46 | extern int android_open (const char *, int, int); | ||
| 47 | extern char *android_user_full_name (struct passwd *); | ||
| 48 | extern int android_fstat (int, struct stat *); | ||
| 49 | extern int android_fstatat (int, const char *restrict, | ||
| 50 | struct stat *restrict, int); | ||
| 51 | extern 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 | |||
| 61 | extern 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_ */ | ||