are .mainthread_base and .mainthread_end from os/rt/src/chsys.c:chSysInit() missing an #if? Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
nikiwaibel
Posts: 22
Joined: Sat Mar 17, 2018 2:51 pm
Has thanked: 4 times
Been thanked: 12 times

are .mainthread_base and .mainthread_end from os/rt/src/chsys.c:chSysInit() missing an #if?

Postby nikiwaibel » Wed Jul 15, 2020 3:03 pm

svn revision 13762

os/rt/src/chsys.c has

Code: Select all

void chSysInit(void) {

  /* OS library modules.*/
  __oslib_init();

  /* Initializing default OS instance.*/
  {
    extern stkalign_t __main_thread_stack_base__,
                      __main_thread_stack_end__;
    static const os_instance_config_t default_cfg = {
      .name             = "c0",
      .mainthread_base  = &__main_thread_stack_base__,
      .mainthread_end   = &__main_thread_stack_end__,
#if CH_CFG_NO_IDLE_THREAD == FALSE
      .idlethread_base  = THD_WORKING_AREA_BASE(ch_idle_thread_wa),
      .idlethread_end   = THD_WORKING_AREA_END(ch_idle_thread_wa)
#endif
    };

    chSchObjectInit(&ch, &default_cfg);
  }

  /* It is alive now.*/
  chSysUnlock();
}


but os/rt/include/chobjects.h has

Code: Select all

/**
 * @brief   Type of an system instance configuration.
 */
typedef struct ch_os_instance_config {
  /**
   * @brief   Instance name.
   */
  const char            *name;
#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) ||  \
    defined(__DOXYGEN__)
  /**
   * @brief   Lower limit of the main function thread stack.
   */
  stkalign_t            *mainthread_base;
  /**
   * @brief   Upper limit of the main function thread stack.
   */
  stkalign_t            *mainthread_end;
#endif
#if (CH_CFG_NO_IDLE_THREAD == FALSE) || defined(__DOXYGEN__)
  /**
   * @brief   Lower limit of the dedicated idle thread stack.
   */
  stkalign_t            *idlethread_base;
  /**
   * @brief   Upper limit of the dedicated idle thread stack.
   */
  stkalign_t            *idlethread_end;
#endif
} os_instance_config_t;


it seems

Code: Select all

      .mainthread_base  = &__main_thread_stack_base__,
      .mainthread_end   = &__main_thread_stack_end__,

as well as

Code: Select all

    extern stkalign_t __main_thread_stack_base__,
                      __main_thread_stack_end__;

from os/rt/src/chsys.c should be wrapped into

Code: Select all

 #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
 #endif

as well. otherwise it may fail to compile when CH_CFG_USE_DYNAMIC and CH_DBG_ENABLE_STACK_CHECK are set to FALSE.
Last edited by nikiwaibel on Wed Jul 15, 2020 3:11 pm, edited 1 time in total.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: are .mainthread_base and .mainthread_end from os/rt/src/chsys.c:chSysInit() missing an #if?  Topic is solved

Postby Giovanni » Wed Jul 15, 2020 3:07 pm

Thanks for finding, RT7 has just been merged and is not yet fully tested.

Giovanni

nikiwaibel
Posts: 22
Joined: Sat Mar 17, 2018 2:51 pm
Has thanked: 4 times
Been thanked: 12 times

Re: are .mainthread_base and .mainthread_end from os/rt/src/chsys.c:chSysInit() missing an #if?

Postby nikiwaibel » Wed Sep 30, 2020 11:22 am

it seems this is still required in -r13877
Attachments
r13762.patch.gz
(416 Bytes) Downloaded 119 times

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: are .mainthread_base and .mainthread_end from os/rt/src/chsys.c:chSysInit() missing an #if?

Postby Giovanni » Wed Sep 30, 2020 11:36 am

Fixed now, the thread was marked with the green check box so I assumed "done"....

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 9 guests