stored in unsigned long to be consistent with X. */
unsigned int event_serial;
+#ifdef __i386__
+
/* Unused pointer used to control compiler optimizations. */
void *unused_pointer;
+#endif /* __i386__ */
+
\f
/* Event handling functions. Events are stored on a (circular) queue
static void *
android_run_select_thread (void *data)
{
+ /* Apparently this is required too. */
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
int rc;
#if __ANDROID_API__ < 16
int nfds;
- fd_set readfds;
+ fd_set readfds, writefds;
char byte;
#else
sigset_t signals, waitset;
pthread_mutex_lock (&event_queue.select_mutex);
nfds = android_pselect_nfds;
- readfds = *android_pselect_readfds;
+
+ if (android_pselect_readfds)
+ readfds = *android_pselect_readfds;
+ else
+ FD_ZERO (&readfds);
if (nfds < select_pipe[0] + 1)
nfds = select_pipe[0] + 1;
FD_SET (select_pipe[0], &readfds);
- rc = pselect (nfds, &readfds,
- android_pselect_writefds,
+ rc = pselect (nfds, &readfds, &writefds,
android_pselect_exceptfds,
android_pselect_timeout,
NULL);
/* Subtract 1 from rc if writefds contains the select pipe. */
- if (FD_ISSET (select_pipe[0],
- android_pselect_writefds))
+ if (FD_ISSET (select_pipe[0], &writefds))
rc -= 1;
+ /* Save the writefds back again. */
+ if (android_pselect_writefds)
+ *android_pselect_writefds = writefds;
+
android_pselect_rc = rc;
pthread_mutex_unlock (&event_queue.select_mutex);
JNIEXPORT jint JNICALL
NATIVE_NAME (dup) (JNIEnv *env, jobject object, jint fd)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
return dup (fd);
}
JNIEXPORT jstring JNICALL
NATIVE_NAME (getFingerprint) (JNIEnv *env, jobject object)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
char buffer[sizeof fingerprint * 2 + 1];
memset (buffer, 0, sizeof buffer);
jobject class_path,
jobject emacs_service_object)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
int pipefd[2];
pthread_t thread;
const char *java_string;
JNIEXPORT jobject JNICALL
NATIVE_NAME (getProcName) (JNIEnv *env, jobject object, jint fd)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
char buffer[PATH_MAX + 1];
size_t length;
jbyteArray array;
NATIVE_NAME (initEmacs) (JNIEnv *env, jobject object, jarray argv,
jobject dump_file_object, jint api_level)
{
- char **c_argv;
- jsize nelements, i;
- jobject argument;
- const char *c_argument;
- char *dump_file;
-
/* android_emacs_init is not main, so GCC is not nice enough to add
the stack alignment prologue.
Unfortunately for us, dalvik on Android 4.0.x calls native code
- with a 4 byte aligned stack. */
+ with a 4 byte aligned stack, so this prologue must be inserted
+ before each function exported via JNI. */
- __attribute__ ((aligned (32))) char buffer[32];
+ JNI_STACK_ALIGNMENT_PROLOGUE;
- /* Trick GCC into not optimizing this variable away. */
- unused_pointer = buffer;
+ char **c_argv;
+ jsize nelements, i;
+ jobject argument;
+ const char *c_argument;
+ char *dump_file;
/* Set the Android API level. */
android_api_level = api_level;
JNIEXPORT void JNICALL
NATIVE_NAME (emacsAbort) (JNIEnv *env, jobject object)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
emacs_abort ();
}
JNIEXPORT void JNICALL
NATIVE_NAME (quit) (JNIEnv *env, jobject object)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
Vquit_flag = Qt;
}
jint x, jint y, jint width,
jint height)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xconfigure.type = ANDROID_CONFIGURE_NOTIFY;
jint state, jint keycode,
jint unicode_char)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xkey.type = ANDROID_KEY_PRESS;
jint state, jint keycode,
jint unicode_char)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xkey.type = ANDROID_KEY_RELEASE;
NATIVE_NAME (sendFocusIn) (JNIEnv *env, jobject object,
jshort window, jlong time)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xfocus.type = ANDROID_FOCUS_IN;
NATIVE_NAME (sendFocusOut) (JNIEnv *env, jobject object,
jshort window, jlong time)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xfocus.type = ANDROID_FOCUS_OUT;
NATIVE_NAME (sendWindowAction) (JNIEnv *env, jobject object,
jshort window, jint action)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xaction.type = ANDROID_WINDOW_ACTION;
jshort window, jint x, jint y,
jlong time)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xcrossing.type = ANDROID_ENTER_NOTIFY;
jshort window, jint x, jint y,
jlong time)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xcrossing.type = ANDROID_LEAVE_NOTIFY;
jshort window, jint x, jint y,
jlong time)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xmotion.type = ANDROID_MOTION_NOTIFY;
jlong time, jint state,
jint button)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xbutton.type = ANDROID_BUTTON_PRESS;
jlong time, jint state,
jint button)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xbutton.type = ANDROID_BUTTON_RELEASE;
jshort window, jint x, jint y,
jlong time, jint pointer_id)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.touch.type = ANDROID_TOUCH_DOWN;
jshort window, jint x, jint y,
jlong time, jint pointer_id)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.touch.type = ANDROID_TOUCH_UP;
jshort window, jint x, jint y,
jlong time, jint pointer_id)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.touch.type = ANDROID_TOUCH_MOVE;
jlong time, jint state,
jfloat x_delta, jfloat y_delta)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.wheel.type = ANDROID_WHEEL;
NATIVE_NAME (sendIconified) (JNIEnv *env, jobject object,
jshort window)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.iconified.type = ANDROID_ICONIFIED;
NATIVE_NAME (sendDeiconified) (JNIEnv *env, jobject object,
jshort window)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.iconified.type = ANDROID_DEICONIFIED;
NATIVE_NAME (sendContextMenu) (JNIEnv *env, jobject object,
jshort window, jint menu_event_id)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.menu.type = ANDROID_CONTEXT_MENU;
jshort window, jint x, jint y,
jint width, jint height)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.xexpose.type = ANDROID_EXPOSE;
JNIEXPORT void JNICALL
NATIVE_NAME (beginSynchronous) (JNIEnv *env, jobject object)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
android_begin_query ();
}
JNIEXPORT void JNICALL
NATIVE_NAME (endSynchronous) (JNIEnv *env, jobject object)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
android_end_query ();
}
JNIEXPORT void JNICALL
NATIVE_NAME (beginBatchEdit) (JNIEnv *env, jobject object, jshort window)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.ime.type = ANDROID_INPUT_METHOD;
JNIEXPORT void JNICALL
NATIVE_NAME (endBatchEdit) (JNIEnv *env, jobject object, jshort window)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.ime.type = ANDROID_INPUT_METHOD;
NATIVE_NAME (commitCompletion) (JNIEnv *env, jobject object, jshort window,
jstring completion_text, jint position)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
unsigned short *text;
size_t length;
NATIVE_NAME (commitText) (JNIEnv *env, jobject object, jshort window,
jstring commit_text, jint position)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
unsigned short *text;
size_t length;
jshort window, jint left_length,
jint right_length)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.ime.type = ANDROID_INPUT_METHOD;
NATIVE_NAME (finishComposingText) (JNIEnv *env, jobject object,
jshort window)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.ime.type = ANDROID_INPUT_METHOD;
NATIVE_NAME (getTextAfterCursor) (JNIEnv *env, jobject object, jshort window,
jint length, jint flags)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
struct android_conversion_query_context context;
jstring string;
NATIVE_NAME (getTextBeforeCursor) (JNIEnv *env, jobject object, jshort window,
jint length, jint flags)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
struct android_conversion_query_context context;
jstring string;
jstring composing_text,
jint new_cursor_position)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
unsigned short *text;
size_t length;
NATIVE_NAME (setComposingRegion) (JNIEnv *env, jobject object, jshort window,
jint start, jint end)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
event.ime.type = ANDROID_INPUT_METHOD;
NATIVE_NAME (setSelection) (JNIEnv *env, jobject object, jshort window,
jint start, jint end)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
/* While IMEs want access to the entire selection, Emacs only
JNIEXPORT jintArray JNICALL
NATIVE_NAME (getSelection) (JNIEnv *env, jobject object, jshort window)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
struct android_get_selection_context context;
jintArray array;
jint contents[2];
NATIVE_NAME (performEditorAction) (JNIEnv *env, jobject object,
jshort window, int action)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
union android_event event;
/* Undocumented behavior: performEditorAction is apparently expected
jshort window, jobject request,
jint flags)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
struct android_get_extracted_text_context context;
static struct android_extracted_text_request_class request_class;
static struct android_extracted_text_class text_class;
NATIVE_NAME (getSelectedText) (JNIEnv *env, jobject object,
jshort window)
{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
struct android_get_extracted_text_context context;
jstring string;