pkarashchenko commented on a change in pull request #4935: URL: https://github.com/apache/incubator-nuttx/pull/4935#discussion_r762470441
########## File path: arch/arm/src/common/arm_tls.c ########## @@ -0,0 +1,83 @@ +/**************************************************************************** + * arch/arm/src/common/arm_tls.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/arch.h> +#include <nuttx/tls.h> + +#include "arm_internal.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_tls_size + * + * Description: + * Get tls (tdata + tbss) section size + * + * Returned Value: + * Size of (tdata + tbss) + * + ****************************************************************************/ + +int up_tls_size(void) +{ + /* Extra 8 bytes (2 pointer) according to GCC */ + + return 8 + sizeof(uint32_t) * (_END_TBSS - _START_TDATA); +} + +/**************************************************************************** + * Name: up_tls_initialize + * + * Description: + * Initialize thread local region + * + * Input Parameters: + * tls_data - The memory region to initialize + * + ****************************************************************************/ + +void up_tls_initialize(FAR void *tls_data) +{ + uint32_t tdata_len = sizeof(uint32_t) * (_END_TDATA - _START_TDATA); + uint32_t tbss_len = sizeof(uint32_t) * (_END_TBSS - _START_TBSS); + memcpy(tls_data + 8, _START_TDATA, tdata_len); Review comment: ```suggestion memcpy(tls_data + sizeof(void *) * 2, _START_TDATA, tdata_len); ``` ########## File path: arch/arm/src/common/arm_tls.c ########## @@ -0,0 +1,83 @@ +/**************************************************************************** + * arch/arm/src/common/arm_tls.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/arch.h> +#include <nuttx/tls.h> + +#include "arm_internal.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_tls_size + * + * Description: + * Get tls (tdata + tbss) section size + * + * Returned Value: + * Size of (tdata + tbss) + * + ****************************************************************************/ + +int up_tls_size(void) +{ + /* Extra 8 bytes (2 pointer) according to GCC */ + + return 8 + sizeof(uint32_t) * (_END_TBSS - _START_TDATA); +} + +/**************************************************************************** + * Name: up_tls_initialize + * + * Description: + * Initialize thread local region + * + * Input Parameters: + * tls_data - The memory region to initialize + * + ****************************************************************************/ + +void up_tls_initialize(FAR void *tls_data) +{ + uint32_t tdata_len = sizeof(uint32_t) * (_END_TDATA - _START_TDATA); + uint32_t tbss_len = sizeof(uint32_t) * (_END_TBSS - _START_TBSS); + memcpy(tls_data + 8, _START_TDATA, tdata_len); + memset(tls_data + 8 + tdata_len, 0, tbss_len); Review comment: ```suggestion memset(tls_data + sizeof(void *) * 2 + tdata_len, 0, tbss_len); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
