From c7e30854f284a17200892ce8e5405744e3c46c24 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 24 Jun 2020 13:54:23 +0200 Subject: rtems: Add _RTEMS_Name_to_id() Simplify object name to identifier directives. Using _RTEMS_Name_to_id() to implement the directives enables a tail call optimization. Change license to BSD-2-Clause according to file history. Update #3053. --- cpukit/Makefile.am | 1 + cpukit/headers.am | 1 + cpukit/include/rtems/rtems/objectimpl.h | 82 +++++++++++++++++++++++++++++++ cpukit/include/rtems/score/objectimpl.h | 23 +++++---- cpukit/rtems/src/barrierident.c | 55 ++++++++++++--------- cpukit/rtems/src/dpmemident.c | 51 ++++++++++++------- cpukit/rtems/src/msgqident.c | 57 +++++++++++---------- cpukit/rtems/src/partident.c | 47 +++++++++++------- cpukit/rtems/src/ratemonident.c | 56 ++++++++++++--------- cpukit/rtems/src/regionident.c | 57 ++++++++++++--------- cpukit/rtems/src/rtemsnametoid.c | 55 +++++++++++++++++++++ cpukit/rtems/src/semident.c | 44 +++++++++++------ cpukit/rtems/src/taskident.c | 65 ++++++++++++++---------- cpukit/rtems/src/timerident.c | 56 ++++++++++++--------- cpukit/sapi/src/extensionident.c | 52 ++++++++++++-------- cpukit/score/src/objectnametoid.c | 4 +- testsuites/sptests/spsimplesched02/init.c | 4 +- 17 files changed, 480 insertions(+), 230 deletions(-) create mode 100644 cpukit/include/rtems/rtems/objectimpl.h create mode 100644 cpukit/rtems/src/rtemsnametoid.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index aa1fe5fc16..1ea3def4ef 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -745,6 +745,7 @@ librtemscpu_a_SOURCES += rtems/src/regionreturnsegment.c librtemscpu_a_SOURCES += rtems/src/rtemsbuildid.c librtemscpu_a_SOURCES += rtems/src/rtemsbuildname.c librtemscpu_a_SOURCES += rtems/src/rtemsmaxprio.c +librtemscpu_a_SOURCES += rtems/src/rtemsnametoid.c librtemscpu_a_SOURCES += rtems/src/rtemsobjectapimaximumclass.c librtemscpu_a_SOURCES += rtems/src/rtemsobjectapiminimumclass.c librtemscpu_a_SOURCES += rtems/src/rtemsobjectgetapiclassname.c diff --git a/cpukit/headers.am b/cpukit/headers.am index c9aa181e54..e1d450a99d 100644 --- a/cpukit/headers.am +++ b/cpukit/headers.am @@ -276,6 +276,7 @@ include_rtems_rtems_HEADERS += include/rtems/rtems/modesimpl.h include_rtems_rtems_HEADERS += include/rtems/rtems/mp.h include_rtems_rtems_HEADERS += include/rtems/rtems/msgmp.h include_rtems_rtems_HEADERS += include/rtems/rtems/object.h +include_rtems_rtems_HEADERS += include/rtems/rtems/objectimpl.h include_rtems_rtems_HEADERS += include/rtems/rtems/options.h include_rtems_rtems_HEADERS += include/rtems/rtems/optionsimpl.h include_rtems_rtems_HEADERS += include/rtems/rtems/part.h diff --git a/cpukit/include/rtems/rtems/objectimpl.h b/cpukit/include/rtems/rtems/objectimpl.h new file mode 100644 index 0000000000..08a9749832 --- /dev/null +++ b/cpukit/include/rtems/rtems/objectimpl.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup ClassicObjectImpl + * + * @brief Implementation Interfaces for Classic Objects + */ + +/* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RTEMS_RTEMS_OBJECTIMPL_H +#define _RTEMS_RTEMS_OBJECTIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicObjectImpl Classic Object Implementation + * + * @ingroup RTEMSInternalClassic + * + * @{ + */ + +/** + * @brief Calls _Objects_Name_to_id_u32() and converts the status. + * + * @param name is the name of the object to find. + * @param node is the set of nodes to search. + * @param[out] id is the pointer to an object identifier variable or NULL. The + * object identifier will be stored in the referenced variable, if the + * operation was successful. + * @param information is the pointer to an object class information block. + * + * @retval RTEMS_SUCCESSFUL The operations was successful. + * @retval RTEMS_INVALID_ADDRESS The id parameter was NULL. + * @retval RTEMS_INVALID_NAME No object exists with the specified name on the + * specified node set. + */ +rtems_status_code _RTEMS_Name_to_id( + uint32_t name, + uint32_t node, + Objects_Id *id, + const Objects_Information *information +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_RTEMS_OBJECTIMPL_H */ diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h index a8c7fcb457..32387594f2 100644 --- a/cpukit/include/rtems/score/objectimpl.h +++ b/cpukit/include/rtems/score/objectimpl.h @@ -221,26 +221,29 @@ typedef enum { #define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE /** - * @brief Converts an object name to an Id. + * @brief Searches an object of the specified class with the specified name on + * the specified set of nodes. * - * This method converts an object name to an Id. It performs a look up + * This method converts an object name to an identifier. It performs a look up * using the object information block for this object class. * - * @param information points to an object class information block. * @param name is the name of the object to find. * @param node is the set of nodes to search. - * @param[out] id will contain the Id if the search is successful. + * @param[out] id is the pointer to an object identifier variable or NULL. The + * object identifier will be stored in the referenced variable, if the + * operation was successful. + * @param information is the pointer to an object class information block. * - * @retval OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL The operations was successful - * @a id contains the ID. - * @retval OBJECTS_INVALID_NAME The name was invalid. - * @retval OBJECTS_INVALID_ID The id is not 0 before the operation. + * @retval OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL The operations was successful. + * @retval OBJECTS_INVALID_ADDRESS The id parameter was NULL. + * @retval OBJECTS_INVALID_NAME No object exists with the specified name on the + * specified node set. */ Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( - const Objects_Information *information, uint32_t name, uint32_t node, - Objects_Id *id + Objects_Id *id, + const Objects_Information *information ); typedef enum { diff --git a/cpukit/rtems/src/barrierident.c b/cpukit/rtems/src/barrierident.c index e3d6a84b80..928cc0ce9e 100644 --- a/cpukit/rtems/src/barrierident.c +++ b/cpukit/rtems/src/barrierident.c @@ -1,41 +1,52 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file + * + * @ingroup ClassicBarrierImpl * - * @brief RTEMS Barrier name to Id - * @ingroup ClassicBarrier + * @brief rtems_barrier_ident() Implementation */ /* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include #include +#include -rtems_status_code rtems_barrier_ident( - rtems_name name, - rtems_id *id -) +rtems_status_code rtems_barrier_ident( rtems_name name, rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - status = _Objects_Name_to_id_u32( - &_Barrier_Information, + return _RTEMS_Name_to_id( name, OBJECTS_SEARCH_LOCAL_NODE, - id + id, + &_Barrier_Information ); - - return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/rtems/src/dpmemident.c b/cpukit/rtems/src/dpmemident.c index 775d833bde..38d906833f 100644 --- a/cpukit/rtems/src/dpmemident.c +++ b/cpukit/rtems/src/dpmemident.c @@ -1,42 +1,55 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file + * + * @ingroup ClassicDPMEMImpl * - * @brief RTEMS Port Name to Id - * @ingroup ClassicDPMEM + * @brief rtems_port_ident() Implementation */ /* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include #include -#include +#include rtems_status_code rtems_port_ident( rtems_name name, rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - status = _Objects_Name_to_id_u32( - &_Dual_ported_memory_Information, + return _RTEMS_Name_to_id( name, OBJECTS_SEARCH_ALL_NODES, - id + id, + &_Dual_ported_memory_Information ); - - return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/rtems/src/msgqident.c b/cpukit/rtems/src/msgqident.c index f25f0cdc6c..dfd68d21f0 100644 --- a/cpukit/rtems/src/msgqident.c +++ b/cpukit/rtems/src/msgqident.c @@ -1,33 +1,45 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file + * + * @ingroup ClassicMessageQueueImpl * - * @brief RTEMS Message Queue Name to Id - * @ingroup ClassicMessageQueue + * @brief rtems_message_queue_ident() Implementation */ /* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include -#include -#include -#include -#include #include -#include -#include +#include rtems_status_code rtems_message_queue_ident( rtems_name name, @@ -35,14 +47,5 @@ rtems_status_code rtems_message_queue_ident( rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - status = _Objects_Name_to_id_u32( - &_Message_queue_Information, - name, - node, - id - ); - - return _Status_Object_name_errors_to_status[ status ]; + return _RTEMS_Name_to_id( name, node, id, &_Message_queue_Information ); } diff --git a/cpukit/rtems/src/partident.c b/cpukit/rtems/src/partident.c index 03490cd95d..5e7140f8d9 100644 --- a/cpukit/rtems/src/partident.c +++ b/cpukit/rtems/src/partident.c @@ -1,28 +1,45 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file + * + * @ingroup ClassicPartitionImpl * - * @brief RTEMS Partition Name to Id - * @ingroup ClassicPart + * @brief rtems_partition_ident() Implementation */ /* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include #include -#include +#include rtems_status_code rtems_partition_ident( rtems_name name, @@ -30,9 +47,5 @@ rtems_status_code rtems_partition_ident( rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - status = _Objects_Name_to_id_u32( &_Partition_Information, name, node, id ); - - return _Status_Object_name_errors_to_status[ status ]; + return _RTEMS_Name_to_id( name, node, id, &_Partition_Information ); } diff --git a/cpukit/rtems/src/ratemonident.c b/cpukit/rtems/src/ratemonident.c index 9c1ae3fba0..67ba13b476 100644 --- a/cpukit/rtems/src/ratemonident.c +++ b/cpukit/rtems/src/ratemonident.c @@ -1,42 +1,52 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file + * + * @ingroup ClassicRateMonImpl * - * @brief RTEMS Rate Monotonic Name to Id - * @ingroup ClassicRateMon + * @brief rtems_rate_monotonic_ident() Implementation */ /* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include #include -#include +#include -rtems_status_code rtems_rate_monotonic_ident( - rtems_name name, - rtems_id *id -) +rtems_status_code rtems_rate_monotonic_ident( rtems_name name, rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - status = _Objects_Name_to_id_u32( - &_Rate_monotonic_Information, + return _RTEMS_Name_to_id( name, OBJECTS_SEARCH_LOCAL_NODE, - id + id, + &_Rate_monotonic_Information ); - - return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/rtems/src/regionident.c b/cpukit/rtems/src/regionident.c index 9e4d4b7085..c8a643c356 100644 --- a/cpukit/rtems/src/regionident.c +++ b/cpukit/rtems/src/regionident.c @@ -1,43 +1,52 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file + * + * @ingroup ClassicRegionImpl * - * @brief RTEMS Region Name to Id - * @ingroup ClassicRegion + * @brief rtems_region_ident() Implementation */ /* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include #include -#include -#include +#include -rtems_status_code rtems_region_ident( - rtems_name name, - rtems_id *id -) +rtems_status_code rtems_region_ident( rtems_name name, rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - status = _Objects_Name_to_id_u32( - &_Region_Information, + return _RTEMS_Name_to_id( name, OBJECTS_SEARCH_LOCAL_NODE, - id + id, + &_Region_Information ); - - return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/rtems/src/rtemsnametoid.c b/cpukit/rtems/src/rtemsnametoid.c new file mode 100644 index 0000000000..43a6d20908 --- /dev/null +++ b/cpukit/rtems/src/rtemsnametoid.c @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup ClassicObjectImpl + * + * @brief _RTEMS_Name_to_id() Implementation + */ + +/* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +rtems_status_code _RTEMS_Name_to_id( + uint32_t name, + uint32_t node, + Objects_Id *id, + const Objects_Information *information +) +{ + Objects_Name_or_id_lookup_errors status; + + status = _Objects_Name_to_id_u32( name, node, id, information ); + + return _Status_Object_name_errors_to_status[ status ]; +} diff --git a/cpukit/rtems/src/semident.c b/cpukit/rtems/src/semident.c index 37c776cf81..93c325c48d 100644 --- a/cpukit/rtems/src/semident.c +++ b/cpukit/rtems/src/semident.c @@ -1,17 +1,37 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file + * + * @ingroup ClassicSemImpl * - * @brief RTEMS Semaphore Name to Id - * @ingroup ClassicSem + * @brief rtems_semaphore_ident() Implementation */ /* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H @@ -19,7 +39,7 @@ #endif #include -#include +#include rtems_status_code rtems_semaphore_ident( rtems_name name, @@ -27,9 +47,5 @@ rtems_status_code rtems_semaphore_ident( rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - status = _Objects_Name_to_id_u32( &_Semaphore_Information, name, node, id ); - - return _Status_Object_name_errors_to_status[ status ]; + return _RTEMS_Name_to_id( name, node, id, &_Semaphore_Information ); } diff --git a/cpukit/rtems/src/taskident.c b/cpukit/rtems/src/taskident.c index d35a617c1f..501bd0b05f 100644 --- a/cpukit/rtems/src/taskident.c +++ b/cpukit/rtems/src/taskident.c @@ -1,53 +1,66 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file + * + * @ingroup ClassicTasksImpl * - * @brief RTEMS Task Name to Id - * @ingroup ClassicTasks + * @brief rtems_task_ident() Implementation */ /* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include -#include #include -#include -#include +#include +#include rtems_status_code rtems_task_ident( - rtems_name name, - uint32_t node, - rtems_id *id + rtems_name name, + uint32_t node, + rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - if ( !id ) + if ( id == NULL ) { return RTEMS_INVALID_ADDRESS; + } if ( name == OBJECTS_ID_OF_SELF ) { *id = _Thread_Get_executing()->Object.id; return RTEMS_SUCCESSFUL; - } + } - status = _Objects_Name_to_id_u32( - &_RTEMS_tasks_Information.Objects, + return _RTEMS_Name_to_id( name, node, - id + id, + &_RTEMS_tasks_Information.Objects ); - - return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/rtems/src/timerident.c b/cpukit/rtems/src/timerident.c index b11550a744..8259507c15 100644 --- a/cpukit/rtems/src/timerident.c +++ b/cpukit/rtems/src/timerident.c @@ -1,42 +1,52 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file + * + * @ingroup ClassicTimerImpl * - * @brief RTEMS Timer Name to Id - * @ingroup ClassicTimer + * @brief rtems_timer_ident() Implementation */ /* - * COPYRIGHT (c) 1989-2002. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include #include -#include +#include -rtems_status_code rtems_timer_ident( - rtems_name name, - rtems_id *id -) +rtems_status_code rtems_timer_ident( rtems_name name, rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - status = _Objects_Name_to_id_u32( - &_Timer_Information, + return _RTEMS_Name_to_id( name, OBJECTS_SEARCH_LOCAL_NODE, - id + id, + &_Timer_Information ); - - return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/sapi/src/extensionident.c b/cpukit/sapi/src/extensionident.c index c92a779c0b..d408f68dd1 100644 --- a/cpukit/sapi/src/extensionident.c +++ b/cpukit/sapi/src/extensionident.c @@ -1,42 +1,52 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @ingroup ClassicUserExtensions + * @ingroup ClassicUserExtensionsImpl * - * @brief User Extensions Implementation. + * @brief rtems_extension_ident() Implementation */ /* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1989 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include #include +#include -rtems_status_code rtems_extension_ident( - rtems_name name, - rtems_id *id -) +rtems_status_code rtems_extension_ident( rtems_name name, rtems_id *id ) { - Objects_Name_or_id_lookup_errors status; - - status = _Objects_Name_to_id_u32( - &_Extension_Information, + return _RTEMS_Name_to_id( name, OBJECTS_SEARCH_LOCAL_NODE, - id + id, + &_Extension_Information ); - - return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/score/src/objectnametoid.c b/cpukit/score/src/objectnametoid.c index 2a9052d948..d89e161c8c 100644 --- a/cpukit/score/src/objectnametoid.c +++ b/cpukit/score/src/objectnametoid.c @@ -21,10 +21,10 @@ #include Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( - const Objects_Information *information, uint32_t name, uint32_t node, - Objects_Id *id + Objects_Id *id, + const Objects_Information *information ) { bool search_local_node; diff --git a/testsuites/sptests/spsimplesched02/init.c b/testsuites/sptests/spsimplesched02/init.c index 27e2f6577c..d19d3553d9 100644 --- a/testsuites/sptests/spsimplesched02/init.c +++ b/testsuites/sptests/spsimplesched02/init.c @@ -81,10 +81,10 @@ rtems_task Init( TEST_BEGIN(); status = _Objects_Name_to_id_u32( - &_Thread_Information.Objects, rtems_build_name( 'I', 'D', 'L', 'E' ), RTEMS_SEARCH_LOCAL_NODE, - &Idle_id + &Idle_id, + &_Thread_Information.Objects ); rtems_test_assert( status == RTEMS_SUCCESSFUL ); -- cgit v1.2.3