OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [linuxthreads/] [td_thr_get_info.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* Get thread information.
2
   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
5
 
6
   The GNU C Library is free software; you can redistribute it and/or
7
   modify it under the terms of the GNU Lesser General Public
8
   License as published by the Free Software Foundation; either
9
   version 2.1 of the License, or (at your option) any later version.
10
 
11
   The GNU C Library is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
   Lesser General Public License for more details.
15
 
16
   You should have received a copy of the GNU Lesser General Public
17
   License along with the GNU C Library; if not, write to the Free
18
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19
   02111-1307 USA.  */
20
 
21
#include <stddef.h>
22
#include <string.h>
23
 
24
#include "thread_dbP.h"
25
 
26
 
27
td_err_e
28
td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop)
29
{
30
  struct _pthread_descr_struct pds;
31
 
32
  LOG ("td_thr_get_info");
33
 
34
  /* Get the thread descriptor.  */
35
  if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds,
36
                 th->th_ta_p->sizeof_descr) != PS_OK)
37
    return TD_ERR;      /* XXX Other error value?  */
38
 
39
  /* Fill in information.  Clear first to provide reproducable
40
     results for the fields we do not fill in.  */
41
  memset (infop, '\0', sizeof (td_thrinfo_t));
42
 
43
  /* We have to handle the manager thread special since the thread
44
     descriptor in older versions is not fully initialized.  */
45
  if (pds.p_nr == 1)
46
    {
47
      infop->ti_tid = th->th_ta_p->pthread_threads_max * 2 + 1;
48
      infop->ti_type = TD_THR_SYSTEM;
49
      infop->ti_state = TD_THR_ACTIVE;
50
    }
51
  else
52
    {
53
      infop->ti_tid = pds.p_tid;
54
      infop->ti_tls = (char *) pds.p_specific;
55
      infop->ti_pri = pds.p_priority;
56
      infop->ti_type = TD_THR_USER;
57
 
58
      if (! pds.p_terminated)
59
        /* XXX For now there is no way to get more information.  */
60
        infop->ti_state = TD_THR_ACTIVE;
61
      else if (! pds.p_detached)
62
        infop->ti_state = TD_THR_ZOMBIE;
63
      else
64
        infop->ti_state = TD_THR_UNKNOWN;
65
    }
66
 
67
  /* Initialization which are the same in both cases.  */
68
  infop->ti_lid = pds.p_pid ?: ps_getpid (th->th_ta_p->ph);
69
  infop->ti_ta_p = th->th_ta_p;
70
  infop->ti_startfunc = pds.p_start_args.start_routine;
71
  memcpy (&infop->ti_events, &pds.p_eventbuf.eventmask,
72
          sizeof (td_thr_events_t));
73
  infop->ti_traceme = pds.p_report_events != 0;
74
 
75
  return TD_OK;
76
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.