Skip to content

Commit 366ad75

Browse files
authored
[Windows] Add macro for weak linkage for Windows platforms (#9100)
1 parent 56adfd4 commit 366ad75

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

runtime/platform/default/posix.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ static bool initialized = false;
7575
* This function should be called before any other function provided by the PAL
7676
* to initialize any global state. Typically overridden by PAL implementer.
7777
*/
78+
#ifdef _MSC_VER
79+
#pragma weak et_pal_init
80+
#endif // _MSC_VER
7881
void et_pal_init(void) {
7982
if (initialized) {
8083
return;
@@ -88,6 +91,9 @@ void et_pal_init(void) {
8891
* Immediately abort execution, setting the device into an error state, if
8992
* available.
9093
*/
94+
#ifdef _MSC_VER
95+
#pragma weak et_pal_abort
96+
#endif // _MSC_VER
9197
ET_NORETURN void et_pal_abort(void) {
9298
std::abort();
9399
}
@@ -97,6 +103,9 @@ ET_NORETURN void et_pal_abort(void) {
97103
*
98104
* @retval Timestamp value in system ticks.
99105
*/
106+
#ifdef _MSC_VER
107+
#pragma weak et_pal_current_ticks
108+
#endif // _MSC_VER
100109
et_timestamp_t et_pal_current_ticks(void) {
101110
_ASSERT_PAL_INITIALIZED();
102111
auto systemCurrentTime = std::chrono::steady_clock::now();
@@ -113,6 +122,9 @@ et_timestamp_t et_pal_current_ticks(void) {
113122
*
114123
* @retval The ratio of nanoseconds to system ticks.
115124
*/
125+
#ifdef _MSC_VER
126+
#pragma weak et_pal_ticks_to_ns_multiplier
127+
#endif // _MSC_VER
116128
et_tick_ratio_t et_pal_ticks_to_ns_multiplier(void) {
117129
// The system tick interval is 1 nanosecond, so the conversion factor is 1.
118130
return {1, 1};
@@ -130,6 +142,9 @@ et_tick_ratio_t et_pal_ticks_to_ns_multiplier(void) {
130142
* @param[in] message Message string to log.
131143
* @param[in] length Message string length.
132144
*/
145+
#ifdef _MSC_VER
146+
#pragma weak et_pal_emit_log_message
147+
#endif // _MSC_VER
133148
void et_pal_emit_log_message(
134149
et_timestamp_t timestamp,
135150
et_pal_log_level_t level,
@@ -181,6 +196,9 @@ void et_pal_emit_log_message(
181196
* @returns the allocated memory, or nullptr on failure. Must be freed using
182197
* et_pal_free().
183198
*/
199+
#ifdef _MSC_VER
200+
#pragma weak et_pal_allocate
201+
#endif // _MSC_VER
184202
void* et_pal_allocate(size_t size) {
185203
return malloc(size);
186204
}
@@ -190,6 +208,9 @@ void* et_pal_allocate(size_t size) {
190208
*
191209
* @param[in] ptr Pointer to memory to free. May be nullptr.
192210
*/
211+
#ifdef _MSC_VER
212+
#pragma weak et_pal_free
213+
#endif // _MSC_VER
193214
void et_pal_free(void* ptr) {
194215
free(ptr);
195216
}

0 commit comments

Comments
 (0)