summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2023-02-22 12:54:32 +0700
committerGitHub <[email protected]>2023-02-22 12:54:32 +0700
commit557bf82336311611ba3b06e57f48d03362f3d2c3 (patch)
tree97bbedf9ff81a90bd8a85ab33abcc2543bd5df33 /src/common
parent334263523756bf6539546bd11915299704034a39 (diff)
parentbcf5e5f72918a7f5ee991f8d1cc3d4f9a3b2b306 (diff)
Merge pull request #1867 from silvergasp/thread_local_globals
fix: Change all static variables to thread when fuzzing
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_compiler.h7
-rw-r--r--src/common/tusb_debug.h2
-rw-r--r--src/common/tusb_types.h4
3 files changed, 10 insertions, 3 deletions
diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h
index a0a49d7ec..3eb6b41f7 100644
--- a/src/common/tusb_compiler.h
+++ b/src/common/tusb_compiler.h
@@ -61,6 +61,13 @@
#define TU_VERIFY_STATIC(const_expr, _mess) enum { TU_XSTRCAT(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
#endif
+/* --------------------- Fuzzing types -------------------------------------- */
+#ifdef _FUZZ
+ #define _fuzz_thread __thread
+#else
+ #define _fuzz_thread
+#endif
+
// for declaration of reserved field, make use of _TU_COUNTER_
#define TU_RESERVED TU_XSTRCAT(reserved, _TU_COUNTER_)
diff --git a/src/common/tusb_debug.h b/src/common/tusb_debug.h
index 65fd1920d..e5f718f79 100644
--- a/src/common/tusb_debug.h
+++ b/src/common/tusb_debug.h
@@ -114,7 +114,7 @@ typedef struct
static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key)
{
- static char not_found[11];
+ static _fuzz_thread char not_found[11];
for(uint16_t i=0; i<p_table->count; i++)
{
diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h
index 82798a484..14d4365a0 100644
--- a/src/common/tusb_types.h
+++ b/src/common/tusb_types.h
@@ -529,13 +529,13 @@ TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_edpt_packet_size(tusb_desc_endpo
#if CFG_TUSB_DEBUG
TU_ATTR_ALWAYS_INLINE static inline const char *tu_edpt_dir_str(tusb_dir_t dir)
{
- static const char *str[] = {"out", "in"};
+ static _fuzz_thread const char *str[] = {"out", "in"};
return str[dir];
}
TU_ATTR_ALWAYS_INLINE static inline const char *tu_edpt_type_str(tusb_xfer_type_t t)
{
- static const char *str[] = {"control", "isochronous", "bulk", "interrupt"};
+ static _fuzz_thread const char *str[] = {"control", "isochronous", "bulk", "interrupt"};
return str[t];
}
#endif