* configure.ac (HAVE_PROCFS): Define if opsys is `android'.
* src/android.c (android_set_task_name): New function.
(android_run_select_thread, android_run_debug_thread): Set the
name of the LWP for debugging purposes.
* src/process.c (create_process): Set F_SETPIPE_SZ on Android in
addition to GNU/Linux.
* src/sysdep.c (procfs_ttyname, system_process_attributes)
[__ANDROID__]: Enable procfs_ttyname on Android systems.
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.])
;;
#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)
{
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
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");
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))
#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)
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))
unblock_input ();
return build_string (name);
}
-# endif /* GNU_LINUX */
+# endif /* GNU_LINUX || __ANDROID__ */
static uintmax_t
procfs_get_total_memory (void)
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);