1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"
  27 
  28 #include <sys/zone.h>
  29 #include <sys/types.h>
  30 #include <sys/systm.h>
  31 #include <sys/thread.h>
  32 #include <sys/cpuvar.h>
  33 #include <sys/brand.h>
  34 #include <sys/lx_brand.h>
  35 #include <sys/lx_pid.h>
  36 
  37 /*
  38  * return the pid
  39  */
  40 long
  41 lx_getpid()
  42 {
  43         lx_lwp_data_t *lwpd = ttolxlwp(curthread);
  44         long rv;
  45 
  46         if (curproc->p_pid == curproc->p_zone->zone_proc_initpid) {
  47                 rv = 1;
  48         } else {
  49                 ASSERT(lwpd != NULL);
  50                 rv = lwpd->br_tgid;
  51         }
  52 
  53         return (rv);
  54 }
  55 
  56 /*
  57  * return the parent pid
  58  */
  59 long
  60 lx_getppid(void)
  61 {
  62         return (lx_lwp_ppid(ttolwp(curthread), NULL, NULL));
  63 }
  64 
  65 /*
  66  * return the thread id
  67  */
  68 long
  69 lx_gettid(void)
  70 {
  71         lx_lwp_data_t *lwpd = ttolxlwp(curthread);
  72 
  73         return (lwpd->br_pid);
  74 }