summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/android.c46
-rw-r--r--src/process.c5
-rw-r--r--src/sysdep.c10
4 files changed, 55 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac
index f92339225b5..ee13b2e0659 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6513,7 +6513,7 @@ case $opsys in
esac
case $opsys in
- gnu-* | solaris | cygwin )
+ gnu-* | android | solaris | cygwin )
dnl FIXME Can't we test if this exists (eg /proc/$$)?
AC_DEFINE([HAVE_PROCFS], [1], [Define if you have the /proc filesystem.])
;;
diff --git a/src/android.c b/src/android.c
index b501a66b25d..76014cbcb3a 100644
--- a/src/android.c
+++ b/src/android.c
@@ -282,6 +282,46 @@ static volatile sig_atomic_t android_pselect_interrupted;
#endif
+/* Set the task name of the current task to NAME, a string at most 16
+ characters in length.
+
+ This name is displayed as that of the task (LWP)'s pthread in
+ GDB. */
+
+static void
+android_set_task_name (const char *name)
+{
+ char proc_name[INT_STRLEN_BOUND (long)
+ + sizeof "/proc/self/task//comm"];
+ int fd;
+ pid_t lwp;
+ size_t length;
+
+ lwp = gettid ();
+ sprintf (proc_name, "/proc/self/task/%ld/comm", (long) lwp);
+ fd = open (proc_name, O_WRONLY | O_TRUNC);
+
+ if (fd < 1)
+ goto failure;
+
+ length = strlen (name);
+
+ if (write (fd, name, MIN (16, length)) < 0)
+ goto failure;
+
+ close (fd);
+ return;
+
+ failure:
+ __android_log_print (ANDROID_LOG_WARN, __func__,
+ "Failed to set task name for LWP %ld: %s",
+ (long) lwp, strerror (errno));
+
+ /* Close the file descriptor if it is already set. */
+ if (fd >= 0)
+ close (fd);
+}
+
static void *
android_run_select_thread (void *data)
{
@@ -298,6 +338,9 @@ android_run_select_thread (void *data)
int sig;
#endif
+ /* Set the name of this thread's LWP for debugging purposes. */
+ android_set_task_name ("`android_select'");
+
#if __ANDROID_API__ < 16
/* A completely different implementation is used when building for
Android versions earlier than 16, because pselect with a signal
@@ -797,6 +840,9 @@ android_run_debug_thread (void *data)
char *line;
size_t n;
+ /* Set the name of this thread's LWP for debugging purposes. */
+ android_set_task_name ("`android_debug'");
+
fd = (int) (intptr_t) data;
file = fdopen (fd, "r");
diff --git a/src/process.c b/src/process.c
index 08cb810ec13..dbd677e59d7 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2206,9 +2206,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
inchannel = p->open_fd[READ_FROM_SUBPROCESS];
forkout = p->open_fd[SUBPROCESS_STDOUT];
-#if defined(GNU_LINUX) && defined(F_SETPIPE_SZ)
+#if (defined (GNU_LINUX) || defined __ANDROID__) \
+ && defined (F_SETPIPE_SZ)
fcntl (inchannel, F_SETPIPE_SZ, read_process_output_max);
-#endif
+#endif /* (GNU_LINUX || __ANDROID__) && F_SETPIPE_SZ */
}
if (!NILP (p->stderrproc))
diff --git a/src/sysdep.c b/src/sysdep.c
index 52fbfbd1eb1..f49fed7da1e 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3452,7 +3452,7 @@ make_lisp_timeval (struct timeval t)
#endif
-#if defined (GNU_LINUX) || defined (CYGWIN)
+#if defined (GNU_LINUX) || defined (CYGWIN) || defined __ANDROID__
static Lisp_Object
time_from_jiffies (unsigned long long ticks, Lisp_Object hz, Lisp_Object form)
@@ -3500,7 +3500,7 @@ get_up_time (void)
return up;
}
-# ifdef GNU_LINUX
+# if defined GNU_LINUX || defined __ANDROID__
#define MAJOR(d) (((unsigned)(d) >> 8) & 0xfff)
#define MINOR(d) (((unsigned)(d) & 0xff) | (((unsigned)(d) & 0xfff00000) >> 12))
@@ -3546,7 +3546,7 @@ procfs_ttyname (int rdev)
unblock_input ();
return build_string (name);
}
-# endif /* GNU_LINUX */
+# endif /* GNU_LINUX || __ANDROID__ */
static uintmax_t
procfs_get_total_memory (void)
@@ -3695,9 +3695,9 @@ system_process_attributes (Lisp_Object pid)
attrs = Fcons (Fcons (Qppid, INT_TO_INTEGER (ppid)), attrs);
attrs = Fcons (Fcons (Qpgrp, INT_TO_INTEGER (pgrp)), attrs);
attrs = Fcons (Fcons (Qsess, INT_TO_INTEGER (sess)), attrs);
-# ifdef GNU_LINUX
+# if defined GNU_LINUX || defined __ANDROID__
attrs = Fcons (Fcons (Qttname, procfs_ttyname (tty)), attrs);
-# endif
+# endif /* GNU_LINUX || __ANDROID__ */
attrs = Fcons (Fcons (Qtpgid, INT_TO_INTEGER (tpgid)), attrs);
attrs = Fcons (Fcons (Qminflt, INT_TO_INTEGER (minflt)), attrs);
attrs = Fcons (Fcons (Qmajflt, INT_TO_INTEGER (majflt)), attrs);