Skip to content

Commit 5460f04

Browse files
author
Keith Packard
committed
Move newlib-specific definitions to separate file
This reduces the clutter in FreeRTOS.h caused by having newlib-specific macros present there. Signed-off-by: Keith Packard <[email protected]>
1 parent 08dbdef commit 5460f04

File tree

2 files changed

+63
-27
lines changed

2 files changed

+63
-27
lines changed

include/FreeRTOS.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,34 +72,8 @@
7272
/* Required if struct _reent is used. */
7373
#if ( configUSE_NEWLIB_REENTRANT == 1 )
7474

75-
/* Note Newlib support has been included by popular demand, but is not
76-
* used by the FreeRTOS maintainers themselves. FreeRTOS is not
77-
* responsible for resulting newlib operation. User must be familiar with
78-
* newlib and must provide system-wide implementations of the necessary
79-
* stubs. Be warned that (at the time of writing) the current newlib design
80-
* implements a system-wide malloc() that must be provided with locks.
81-
*
82-
* See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
83-
* for additional information. */
84-
#include <reent.h>
85-
86-
#define configUSE_C_RUNTIME_TLS_SUPPORT 1
75+
#include "newlib-freertos.h"
8776

88-
#ifndef configTLS_BLOCK_TYPE
89-
#define configTLS_BLOCK_TYPE struct _reent
90-
#endif
91-
92-
#ifndef configINIT_TLS_BLOCK
93-
#define configINIT_TLS_BLOCK( xTLSBlock, pxTopOfStack ) _REENT_INIT_PTR( &( xTLSBlock ) )
94-
#endif
95-
96-
#ifndef configSET_TLS_BLOCK
97-
#define configSET_TLS_BLOCK( xTLSBlock ) _impure_ptr = &( xTLSBlock )
98-
#endif
99-
100-
#ifndef configDEINIT_TLS_BLOCK
101-
#define configDEINIT_TLS_BLOCK( xTLSBlock ) _reclaim_reent( &( xTLSBlock ) )
102-
#endif
10377
#endif /* if ( configUSE_NEWLIB_REENTRANT == 1 ) */
10478

10579
#ifndef configUSE_C_RUNTIME_TLS_SUPPORT

include/newlib-freertos.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
3+
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
*
5+
* SPDX-License-Identifier: MIT
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
* this software and associated documentation files (the "Software"), to deal in
9+
* the Software without restriction, including without limitation the rights to
10+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11+
* the Software, and to permit persons to whom the Software is furnished to do so,
12+
* subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
*
24+
* https://www.FreeRTOS.org
25+
* https://github.com/FreeRTOS
26+
*
27+
*/
28+
29+
#ifndef INC_NEWLIB_FREERTOS_H
30+
#define INC_NEWLIB_FREERTOS_H
31+
32+
/* Note Newlib support has been included by popular demand, but is not
33+
* used by the FreeRTOS maintainers themselves. FreeRTOS is not
34+
* responsible for resulting newlib operation. User must be familiar with
35+
* newlib and must provide system-wide implementations of the necessary
36+
* stubs. Be warned that (at the time of writing) the current newlib design
37+
* implements a system-wide malloc() that must be provided with locks.
38+
*
39+
* See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
40+
* for additional information. */
41+
42+
#include <reent.h>
43+
44+
#define configUSE_C_RUNTIME_TLS_SUPPORT 1
45+
46+
#ifndef configTLS_BLOCK_TYPE
47+
#define configTLS_BLOCK_TYPE struct _reent
48+
#endif
49+
50+
#ifndef configINIT_TLS_BLOCK
51+
#define configINIT_TLS_BLOCK( xTLSBlock, pxTopOfStack ) _REENT_INIT_PTR( &( xTLSBlock ) )
52+
#endif
53+
54+
#ifndef configSET_TLS_BLOCK
55+
#define configSET_TLS_BLOCK( xTLSBlock ) _impure_ptr = &( xTLSBlock )
56+
#endif
57+
58+
#ifndef configDEINIT_TLS_BLOCK
59+
#define configDEINIT_TLS_BLOCK( xTLSBlock ) _reclaim_reent( &( xTLSBlock ) )
60+
#endif
61+
62+
#endif /* INC_NEWLIB_FREERTOS_H */

0 commit comments

Comments
 (0)