Print this page
OS-???? [lx] SIGEV_THREAD_ID emulation needed

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/brand/lx/os/lx_brand.c
          +++ new/usr/src/uts/common/brand/lx/os/lx_brand.c
↓ open down ↓ 982 lines elided ↑ open up ↑
 983  983                  }
 984  984  
 985  985                  if (copyout(&s_pid, (void *)arg2, sizeof (s_pid)) != 0 ||
 986  986                      copyout(&s_tid, (void *)arg3, sizeof (s_tid)) != 0) {
 987  987                          return (EFAULT);
 988  988                  }
 989  989  
 990  990                  return (0);
 991  991          }
 992  992  
      993 +        case B_SIGEV_THREAD_ID: {
      994 +                /*
      995 +                 * Emulate Linux's timer_create(2) SIGEV_THREAD_ID
      996 +                 * notification method. This mechanism is only meant
      997 +                 * for userland threading libraries such as glibc and
      998 +                 * is documented as such. Therefore, assume this is
      999 +                 * only ever invoked for the purpose of alerting a
     1000 +                 * Linux threading library. Assume that the tid is a
     1001 +                 * member of the caller's process and the signal
     1002 +                 * number is valid. See lx_sigev_thread_id() for the
     1003 +                 * userland side of this emulation.
     1004 +                 *
     1005 +                 * arg1 -- Linux tid
     1006 +                 * arg2 -- signal number
     1007 +                 * arg3 -- union sigval
     1008 +                 */
     1009 +
     1010 +                proc_t *pp, *cp = curproc;
     1011 +                int native_sig = ltos_signo[(int)arg2];
     1012 +                pid_t native_pid;
     1013 +                int native_tid;
     1014 +                sigqueue_t *sqp;
     1015 +
     1016 +                lx_lpid_to_spair((pid_t)arg1, &native_pid, &native_tid);
     1017 +
     1018 +                mutex_enter(&pidlock);
     1019 +                if (((pp = prfind(native_pid)) == NULL) || (pp->p_stat == SIDL)) {
     1020 +                        mutex_exit(&pidlock);
     1021 +                        return (ESRCH);
     1022 +                }
     1023 +                mutex_enter(&pp->p_lock);
     1024 +                mutex_exit(&pidlock);
     1025 +
     1026 +                if ((t = idtot(pp, native_tid)) == NULL) {
     1027 +                        mutex_exit(&pp->p_lock);
     1028 +                        return (ESRCH);
     1029 +                }
     1030 +
     1031 +                sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
     1032 +                sqp->sq_info.si_signo = native_sig;
     1033 +                sqp->sq_info.si_code = SI_TIMER;
     1034 +                sqp->sq_info.si_pid = cp->p_pid;
     1035 +                sqp->sq_info.si_zoneid = getzoneid();
     1036 +                sqp->sq_info.si_uid = crgetruid(CRED());
     1037 +                sqp->sq_info.si_value = (union sigval)((void *)arg3);
     1038 +                sigaddqa(pp, t, sqp);
     1039 +
     1040 +                mutex_exit(&pp->p_lock);
     1041 +                return (0);
     1042 +        }
     1043 +
 993 1044          case B_SET_AFFINITY_MASK:
 994 1045          case B_GET_AFFINITY_MASK:
 995 1046                  /*
 996 1047                   * Retrieve or store the CPU affinity mask for the
 997 1048                   * requested linux pid.
 998 1049                   *
 999 1050                   * arg1 is a linux PID (0 means curthread).
1000 1051                   * arg2 is the size of the given mask.
1001 1052                   * arg3 is the address of the affinity mask.
1002 1053                   */
↓ open down ↓ 923 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX