source: rtems/cpukit/sapi/src/extensioncreate.c

Last change on this file was 0b263b0e, checked in by Sebastian Huber <sebastian.huber@…>, on Feb 21, 2021 at 9:47:36 AM

score: Remove _Objects_Open()

Use the type safe _Objects_Open_u32() instead. Return the object
identifier to enforce a common usage pattern.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSImplClassicUserExt
5 *
6 * @brief This source file contains the implementation of
7 *   rtems_extension_create() and the User Extensions Manager system
8 *   initialization.
9 */
10
11/*
12 *  COPYRIGHT (c) 1989-2007.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <rtems/extensionimpl.h>
25#include <rtems/rtems/support.h>
26#include <rtems/score/userextimpl.h>
27#include <rtems/sysinit.h>
28
29rtems_status_code rtems_extension_create(
30  rtems_name                    name,
31  const rtems_extensions_table *extension_table,
32  rtems_id                     *id
33)
34{
35  Extension_Control *the_extension;
36
37  if ( !rtems_is_name_valid( name ) ) {
38    return RTEMS_INVALID_NAME;
39  }
40
41  if ( extension_table == NULL ) {
42    return RTEMS_INVALID_ADDRESS;
43  }
44
45  if ( id == NULL ) {
46    return RTEMS_INVALID_ADDRESS;
47  }
48
49  the_extension = _Extension_Allocate();
50
51  if ( the_extension == NULL ) {
52    _Objects_Allocator_unlock();
53    return RTEMS_TOO_MANY;
54  }
55
56  _User_extensions_Add_set_with_table( &the_extension->Extension, extension_table );
57
58  *id = _Objects_Open_u32(
59    &_Extension_Information,
60    &the_extension->Object,
61    name
62  );
63  _Objects_Allocator_unlock();
64  return RTEMS_SUCCESSFUL;
65}
66
67static void _Extension_Manager_initialization( void )
68{
69  _Objects_Initialize_information( &_Extension_Information);
70}
71
72RTEMS_SYSINIT_ITEM(
73  _Extension_Manager_initialization,
74  RTEMS_SYSINIT_USER_EXTENSIONS,
75  RTEMS_SYSINIT_ORDER_MIDDLE
76);
Note: See TracBrowser for help on using the repository browser.