--- old/usr/src/lib/brand/lx/lx_brand/common/clock.c	Tue Jul 14 22:19:58 2015
+++ new/usr/src/lib/brand/lx/lx_brand/common/clock.c	Tue Jul 14 22:19:58 2015
@@ -25,7 +25,10 @@
  * Copyright 2015 Joyent, Inc.
  */
 
+#include <sys/syscall.h>
+
 #include <errno.h>
+#include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <sys/resource.h>
@@ -107,6 +110,8 @@
 	} lx_sigev_un;
 } lx_sigevent_t;
 
+#define	lx_sigev_notify_attributes	lx_sigev_un.lx_sigev_thread.lx_notify_attribute
+
 /* sigevent sigev_notify conversion table */
 static int ltos_sigev[] = {
 	SIGEV_SIGNAL,
@@ -113,10 +118,11 @@
 	SIGEV_NONE,
 	SIGEV_THREAD,
 	0,		/* Linux skips event 3 */
-	SIGEV_THREAD	/* the Linux SIGEV_THREAD_ID */
+	SIGEV_THREAD	/* Linux SIGEV_THREAD_ID -- see lx_sigev_thread_id() */
 };
 
-#define	LX_SIGEV_MAX	(sizeof (ltos_sigev) / sizeof (ltos_sigev[0]))
+#define	LX_SIGEV_MAX		(sizeof (ltos_sigev) / sizeof (ltos_sigev[0]))
+#define	LX_SIGEV_THREAD_ID	4
 
 long
 lx_clock_nanosleep(int clock, int flags, struct timespec *rqtp,
@@ -163,6 +169,22 @@
 }
 
 /*
+ * Notification function for use with native SIGEV_THREAD in order to
+ * emulate Linux SIGEV_THREAD_ID. Native SIGEV_THREAD is used as the
+ * timer mechanism and B_SIGEV_THREAD_ID performs the actual event
+ * delivery to the appropriate lx tid.
+ */
+static void
+lx_sigev_thread_id(union sigval sival)
+{
+	lx_sigevent_t *lev = (lx_sigevent_t *)sival.sival_ptr;
+	syscall(SYS_brand, B_SIGEV_THREAD_ID, lev->lx_sigev_un.lx_tid,
+	    lev->lx_sigev_signo, lev->lx_sigev_value);
+	free(lev);
+}
+
+
+/*
  * The Illumos timer_create man page says it accepts the following clocks:
  *   CLOCK_REALTIME (3)	wall clock
  *   CLOCK_VIRTUAL (1)	user CPU usage clock - No Backend
@@ -193,10 +215,28 @@
 	sev.sigev_value = lev.lx_sigev_value;
 
 	/*
-	 * The sigevent sigev_notify_function and sigev_notify_attributes
-	 * members are not used by timer_create, so no conversion is needed.
+	 * Assume all Linux libc implementations map SIGEV_THREAD to
+	 * SIGEV_THREAD_ID and ignore passed-in attributes.
 	 */
+	sev.sigev_notify_attributes = NULL;
 
+	if (lev.lx_sigev_notify == LX_SIGEV_THREAD_ID) {
+		/*
+		 * Pass the original lx sigevent_t to the native
+		 * notify function so that it may pass it to the lx
+		 * helper thread.
+		 */
+		lx_sigevent_t *lev_copy = malloc(sizeof (lx_sigevent_t));
+		if (lev_copy == NULL)
+			return (-ENOMEM);
+
+		if (uucopy(&lev, lev_copy, sizeof (lx_sigevent_t)) < 0)
+			return (-EFAULT);
+
+		sev.sigev_notify_function = lx_sigev_thread_id;
+		sev.sigev_value.sival_ptr = lev_copy;
+	}
+
 	return ((timer_create(ltos_timer[clock], &sev, tid) < 0) ? -errno : 0);
 }
 
--- old/usr/src/uts/common/brand/lx/os/lx_brand.c	Tue Jul 14 22:19:59 2015
+++ new/usr/src/uts/common/brand/lx/os/lx_brand.c	Tue Jul 14 22:19:59 2015
@@ -990,6 +990,57 @@
 		return (0);
 	}
 
+	case B_SIGEV_THREAD_ID: {
+		/*
+		 * Emulate Linux's timer_create(2) SIGEV_THREAD_ID
+		 * notification method. This mechanism is only meant
+		 * for userland threading libraries such as glibc and
+		 * is documented as such. Therefore, assume this is
+		 * only ever invoked for the purpose of alerting a
+		 * Linux threading library. Assume that the tid is a
+		 * member of the caller's process and the signal
+		 * number is valid. See lx_sigev_thread_id() for the
+		 * userland side of this emulation.
+		 *
+		 * arg1 -- Linux tid
+		 * arg2 -- signal number
+		 * arg3 -- union sigval
+		 */
+
+		proc_t *pp, *cp = curproc;
+		int native_sig = ltos_signo[(int)arg2];
+		pid_t native_pid;
+		int native_tid;
+		sigqueue_t *sqp;
+
+		lx_lpid_to_spair((pid_t)arg1, &native_pid, &native_tid);
+
+		mutex_enter(&pidlock);
+		if (((pp = prfind(native_pid)) == NULL) || (pp->p_stat == SIDL)) {
+			mutex_exit(&pidlock);
+			return (ESRCH);
+		}
+		mutex_enter(&pp->p_lock);
+		mutex_exit(&pidlock);
+
+		if ((t = idtot(pp, native_tid)) == NULL) {
+			mutex_exit(&pp->p_lock);
+			return (ESRCH);
+		}
+
+		sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
+		sqp->sq_info.si_signo = native_sig;
+		sqp->sq_info.si_code = SI_TIMER;
+		sqp->sq_info.si_pid = cp->p_pid;
+		sqp->sq_info.si_zoneid = getzoneid();
+		sqp->sq_info.si_uid = crgetruid(CRED());
+		sqp->sq_info.si_value = (union sigval)((void *)arg3);
+		sigaddqa(pp, t, sqp);
+
+		mutex_exit(&pp->p_lock);
+		return (0);
+	}
+
 	case B_SET_AFFINITY_MASK:
 	case B_GET_AFFINITY_MASK:
 		/*
--- old/usr/src/uts/common/brand/lx/sys/lx_brand.h	Tue Jul 14 22:19:59 2015
+++ new/usr/src/uts/common/brand/lx/sys/lx_brand.h	Tue Jul 14 22:19:59 2015
@@ -95,6 +95,7 @@
 #define	B_HELPER_SIGQUEUE	145
 #define	B_HELPER_TGSIGQUEUE	146
 #define	B_SET_NATIVE_STACK	147
+#define	B_SIGEV_THREAD_ID	148
 
 #ifndef _ASM
 /*
