diff --git a/platform/mbed_power_mgmt.h b/platform/mbed_power_mgmt.h index 6e59929533..6e4540ca1c 100644 --- a/platform/mbed_power_mgmt.h +++ b/platform/mbed_power_mgmt.h @@ -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 diff --git a/platform/mbed_toolchain.h b/platform/mbed_toolchain.h index f51e1f4c11..e345cc914e 100644 --- a/platform/mbed_toolchain.h +++ b/platform/mbed_toolchain.h @@ -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 #endif #ifndef FILEHANDLE -typedef int FILEHANDLE; + typedef int FILEHANDLE; #endif // Backwards compatibility