Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:22

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSImplClassic
0007  *
0008  * @brief This source file contains the implementation of rtems_version(),
0009  *   rtems_version_control_key(), rtems_version_major(), rtems_version_minor(),
0010  *   and rtems_version_revision().
0011  *
0012  * The version strings are created from the various pieces of version
0013  * information.  The main version number is part of the build system
0014  * and is stamped into <rtems/score/cpuopts.h>. The revision label is
0015  * determined by the build system and is a string. It can be used and
0016  * so set when deploying the sources or the release label can be
0017  * formed using the version control tool when the code is not released
0018  * and being built with a version controlled repository.
0019  */
0020 
0021 /*
0022  *  Copyright (C) 2017, 2024.
0023  *  Chris Johns <chrisj@rtems.org>
0024  *
0025  * Redistribution and use in source and binary forms, with or without
0026  * modification, are permitted provided that the following conditions
0027  * are met:
0028  * 1. Redistributions of source code must retain the above copyright
0029  *    notice, this list of conditions and the following disclaimer.
0030  * 2. Redistributions in binary form must reproduce the above copyright
0031  *    notice, this list of conditions and the following disclaimer in the
0032  *    documentation and/or other materials provided with the distribution.
0033  *
0034  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0035  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0036  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0037  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0038  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0039  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0040  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0041  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0042  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0043  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0044  * POSSIBILITY OF SUCH DAMAGE.
0045  */
0046 
0047 #ifdef HAVE_CONFIG_H
0048 #include "config.h"
0049 #endif
0050 
0051 #include <rtems/version.h>
0052 #include <rtems/score/cpuopts.h>
0053 
0054 #include "version-vc-key.h"
0055 
0056 const char *rtems_version( void )
0057 {
0058 #ifdef RTEMS_VERSION_CONTROL_KEY
0059   return RTEMS_VERSION "." RTEMS_VERSION_CONTROL_KEY;
0060 #else
0061   return RTEMS_VERSION;
0062 #endif
0063 }
0064 
0065 int rtems_version_major( void )
0066 {
0067   return __RTEMS_MAJOR__;
0068 }
0069 
0070 int rtems_version_minor( void )
0071 {
0072   return __RTEMS_MINOR__;
0073 }
0074 
0075 int rtems_version_revision( void )
0076 {
0077   return __RTEMS_REVISION__;
0078 }
0079 
0080 const char *rtems_version_control_key( void )
0081 {
0082 #ifdef RTEMS_VERSION_CONTROL_KEY
0083   return RTEMS_VERSION_CONTROL_KEY;
0084 #else
0085   return "";
0086 #endif
0087 }
0088 
0089 const char *rtems_version_release_label( void )
0090 {
0091   /*
0092    * RTEMS 5 and 6 only provide the VC key. The VC key header will be
0093    * moved to `version-release-label.h` after RTEMS 6
0094    */
0095 #ifdef RTEMS_VERSION_CONTROL_KEY
0096   return RTEMS_VERSION_CONTROL_KEY;
0097 #else
0098   return "";
0099 #endif
0100 }
0101 
0102 bool rtems_version_release_label_is_valid( void )
0103 {
0104   const char* release_label = rtems_version_release_label( );
0105   return release_label[ 0 ] != '\0';
0106 }