source: rtems-schedsim/schedsim/shell/shared/lookup_task.c @ 24af09a

Last change on this file since 24af09a was 24af09a, checked in by Joel Sherrill <joel.sherrill@…>, on 05/26/14 at 17:02:56

lookup*.c, main_semobtain.c: Link on uniprocessor again

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  Given Name or ID String, give Id
3 *
4 *  COPYRIGHT (c) 1989-2013.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <stdio.h>
17
18#include <rtems.h>
19#include <rtems/stringto.h>
20#include <rtems/score/threaddispatch.h>
21
22#ifndef METHOD_NAME
23  #define METHOD_NAME lookup_task
24#endif
25#ifndef RTEMS_IDENT_NAME
26  #define RTEMS_IDENT_NAME rtems_task_ident
27  #define DOING_TASKS
28#endif
29
30int METHOD_NAME(
31  const char *string,
32  rtems_id   *id
33)
34{
35  char               name[5];
36  rtems_status_code  status;
37  unsigned long      tmp;
38
39  if ( string[0] != '0' ) {
40    #ifdef DOING_TASKS
41      if ( !strcmp( string, "SELF" ) ) {
42        _Thread_Disable_dispatch();
43          *id = _Thread_Executing->Object.id;
44        _Thread_Enable_dispatch();
45        return 0;
46      }
47    #endif
48    if ( strlen( string ) != 4 ) {
49      return -1;
50    }
51    memset( name, '\0', sizeof(name) );
52    strncpy( name, string, 4 );
53    status = RTEMS_IDENT_NAME(
54      rtems_build_name( name[0], name[1], name[2], name[3] ),
55      OBJECTS_SEARCH_ALL_NODES,
56      id
57    );
58    if ( status != RTEMS_SUCCESSFUL )
59      return 1;
60  } else {
61    if ( rtems_string_to_unsigned_long( string, &tmp, NULL, 0) ) {
62      fprintf( stderr, "Argument (%s) is not a number\n", string );
63      return 1;
64    }
65    *id = (rtems_id) tmp;
66  }
67
68  return 0;
69}
Note: See TracBrowser for help on using the repository browser.