Skip to content

Commit a366ed8

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 762f30b commit a366ed8

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
@@ -95,34 +95,8 @@
9595
/* Required if struct _reent is used. */
9696
#if ( configUSE_NEWLIB_REENTRANT == 1 )
9797

98-
/* Note Newlib support has been included by popular demand, but is not
99-
* used by the FreeRTOS maintainers themselves. FreeRTOS is not
100-
* responsible for resulting newlib operation. User must be familiar with
101-
* newlib and must provide system-wide implementations of the necessary
102-
* stubs. Be warned that (at the time of writing) the current newlib design
103-
* implements a system-wide malloc() that must be provided with locks.
104-
*
105-
* See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
106-
* for additional information. */
107-
#include <reent.h>
108-
109-
#define configUSE_C_RUNTIME_TLS_SUPPORT 1
98+
#include "newlib-freertos.h"
11099

111-
#ifndef configTLS_BLOCK_TYPE
112-
#define configTLS_BLOCK_TYPE struct _reent
113-
#endif
114-
115-
#ifndef configINIT_TLS_BLOCK
116-
#define configINIT_TLS_BLOCK( xTLSBlock, pxTopOfStack ) _REENT_INIT_PTR( &( xTLSBlock ) )
117-
#endif
118-
119-
#ifndef configSET_TLS_BLOCK
120-
#define configSET_TLS_BLOCK( xTLSBlock ) ( _impure_ptr = &( xTLSBlock ) )
121-
#endif
122-
123-
#ifndef configDEINIT_TLS_BLOCK
124-
#define configDEINIT_TLS_BLOCK( xTLSBlock ) _reclaim_reent( &( xTLSBlock ) )
125-
#endif
126100
#endif /* if ( configUSE_NEWLIB_REENTRANT == 1 ) */
127101

128102
#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)