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.
pull/6377/head
Steven Cartmell 2018-03-20 14:23:00 +00:00
parent 6d7576a309
commit ab2abcb29d
2 changed files with 25 additions and 19 deletions

View File

@ -68,26 +68,18 @@ extern "C" {
void sleep_tracker_lock(const char *const filename, int line);
void sleep_tracker_unlock(const char *const filename, int line);
#if defined(__CC_ARM)
#define __FILENAME__ __MODULE__
#elif defined(__GNUC__)
#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__)
#else
#define __FILENAME__ __FILE__
#endif
#define sleep_manager_lock_deep_sleep() \
do \
{ \
sleep_manager_lock_deep_sleep_internal(); \
sleep_tracker_lock(__FILENAME__, __LINE__); \
#define sleep_manager_lock_deep_sleep() \
do \
{ \
sleep_manager_lock_deep_sleep_internal(); \
sleep_tracker_lock(MBED_FILENAME, __LINE__); \
} while (0);
#define sleep_manager_unlock_deep_sleep() \
do \
{ \
sleep_manager_unlock_deep_sleep_internal(); \
sleep_tracker_unlock(__FILENAME__, __LINE__); \
#define sleep_manager_unlock_deep_sleep() \
do \
{ \
sleep_manager_unlock_deep_sleep_internal(); \
sleep_tracker_unlock(MBED_FILENAME, __LINE__); \
} while (0);
#else

View File

@ -376,13 +376,27 @@
#endif
#endif
// Macro containing the filename part of the value of __FILE__. Defined as
// string literal.
#ifndef MBED_FILENAME
#if defined(__CC_ARM)
#define MBED_FILENAME __MODULE__
#elif defined(__GNUC__)
#define MBED_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__)
#elif defined(__ICCARM__)
#define MBED_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#else
#define MBED_FILENAME __FILE__
#endif
#endif // #ifndef MBED_FILENAME
// FILEHANDLE declaration
#if defined(TOOLCHAIN_ARM)
#include <rt_sys.h>
#endif
#ifndef FILEHANDLE
typedef int FILEHANDLE;
typedef int FILEHANDLE;
#endif
// Backwards compatibility