Skip to content

Commit 43e646d

Browse files
Steven Cartmelladbridge
authored andcommitted
Fix issues with __FILENAME__ macro
- Move macro definition to mbed_toolchain.h - Remove double underscores from macro which are reserved. - Fix macro for IAR until compiler flags to disable path are added again.
1 parent 4ff6dd2 commit 43e646d

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

platform/mbed_power_mgmt.h

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,18 @@ extern "C" {
6868
void sleep_tracker_lock(const char *const filename, int line);
6969
void sleep_tracker_unlock(const char *const filename, int line);
7070

71-
#if defined(__CC_ARM)
72-
#define __FILENAME__ __MODULE__
73-
#elif defined(__GNUC__)
74-
#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__)
75-
#else
76-
#define __FILENAME__ __FILE__
77-
#endif
78-
79-
#define sleep_manager_lock_deep_sleep() \
80-
do \
81-
{ \
82-
sleep_manager_lock_deep_sleep_internal(); \
83-
sleep_tracker_lock(__FILENAME__, __LINE__); \
71+
#define sleep_manager_lock_deep_sleep() \
72+
do \
73+
{ \
74+
sleep_manager_lock_deep_sleep_internal(); \
75+
sleep_tracker_lock(MBED_FILENAME, __LINE__); \
8476
} while (0);
8577

86-
#define sleep_manager_unlock_deep_sleep() \
87-
do \
88-
{ \
89-
sleep_manager_unlock_deep_sleep_internal(); \
90-
sleep_tracker_unlock(__FILENAME__, __LINE__); \
78+
#define sleep_manager_unlock_deep_sleep() \
79+
do \
80+
{ \
81+
sleep_manager_unlock_deep_sleep_internal(); \
82+
sleep_tracker_unlock(MBED_FILENAME, __LINE__); \
9183
} while (0);
9284

9385
#else

platform/mbed_toolchain.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,27 @@
376376
#endif
377377
#endif
378378

379+
// Macro containing the filename part of the value of __FILE__. Defined as
380+
// string literal.
381+
#ifndef MBED_FILENAME
382+
#if defined(__CC_ARM)
383+
#define MBED_FILENAME __MODULE__
384+
#elif defined(__GNUC__)
385+
#define MBED_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__)
386+
#elif defined(__ICCARM__)
387+
#define MBED_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
388+
#else
389+
#define MBED_FILENAME __FILE__
390+
#endif
391+
#endif // #ifndef MBED_FILENAME
392+
379393
// FILEHANDLE declaration
380394
#if defined(TOOLCHAIN_ARM)
381395
#include <rt_sys.h>
382396
#endif
383397

384398
#ifndef FILEHANDLE
385-
typedef int FILEHANDLE;
399+
typedef int FILEHANDLE;
386400
#endif
387401

388402
// Backwards compatibility

0 commit comments

Comments
 (0)