summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/tlsallocsize.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/src/tlsallocsize.c')
-rw-r--r--cpukit/score/src/tlsallocsize.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/cpukit/score/src/tlsallocsize.c b/cpukit/score/src/tlsallocsize.c
index 8fa5600602..a9f0c0cd23 100644
--- a/cpukit/score/src/tlsallocsize.c
+++ b/cpukit/score/src/tlsallocsize.c
@@ -1,7 +1,7 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (C) 2014, 2019 embedded brains GmbH
+ * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,6 +30,8 @@
#endif
#include <rtems/score/tls.h>
+#include <rtems/score/interr.h>
+#include <rtems/score/thread.h>
static uintptr_t _TLS_Allocation_size;
@@ -65,6 +67,14 @@ uintptr_t _TLS_Get_allocation_size( void )
allocation_size += sizeof(TLS_Dynamic_thread_vector);
#endif
+ if ( _Thread_Maximum_TLS_size != 0 ) {
+ if ( allocation_size <= _Thread_Maximum_TLS_size ) {
+ allocation_size = _Thread_Maximum_TLS_size;
+ } else {
+ _Internal_error( INTERNAL_ERROR_TOO_LARGE_TLS_SIZE );
+ }
+ }
+
_TLS_Allocation_size = allocation_size;
}