[Android] Add missing eventfd syscall for 2.2

Rafaël Carré git at videolan.org
Thu Apr 26 21:32:43 CEST 2012


android | branch: master | Rafaël Carré <funman at videolan.org> | Wed Apr 25 22:03:07 2012 -0400| [b88d59d73e93ce9401ce8734089419845c396017] | committer: Rafaël Carré

Add missing eventfd syscall for 2.2

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=b88d59d73e93ce9401ce8734089419845c396017
---

 vlc-android/jni/Android.mk |    2 +-
 vlc-android/jni/eventfd.c  |   46 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/vlc-android/jni/Android.mk b/vlc-android/jni/Android.mk
index d9b8ba5..c6642e6 100644
--- a/vlc-android/jni/Android.mk
+++ b/vlc-android/jni/Android.mk
@@ -3,7 +3,7 @@ include $(CLEAR_VARS)
 
 LOCAL_MODULE    := libvlcjni
 
-LOCAL_SRC_FILES := libvlcjni.c aout.c thumbnailer.c pthread-condattr.c pthread-rwlocks.c
+LOCAL_SRC_FILES := libvlcjni.c aout.c thumbnailer.c pthread-condattr.c pthread-rwlocks.c eventfd.c
 
 LOCAL_C_INCLUDES := $(VLC_SRC_DIR)/include
 
diff --git a/vlc-android/jni/eventfd.c b/vlc-android/jni/eventfd.c
new file mode 100644
index 0000000..b54e879
--- /dev/null
+++ b/vlc-android/jni/eventfd.c
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * libvlcjni.c
+ *****************************************************************************
+ * Copyright © 2012 Rafaël Carré
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include <sys/linux-syscalls.h>
+#include <errno.h>
+
+int eventfd(unsigned int initval, int flags)
+{
+    int ret;
+    int syscall_nr = __NR_eventfd2;
+
+    asm(
+    "mov    r0, %[initval]      \n\t"
+    "mov    r1, %[flags]        \n\t"
+    "mov    r7, %[nr]           \n\t"
+    "svc    #0                  \n\t"
+    "mov    %[ret], r0          \n\t"
+    : [ret] "=r" (ret)
+    : [initval] "r" (initval), [flags] "r" (flags), [nr] "r" (syscall_nr)
+    : "r7"
+    );
+
+    if (ret < 0) {
+        errno = -ret;
+        return -1;
+    }
+
+    return ret;
+}



More information about the Android mailing list