@@ -74,8 +74,10 @@ enum class WiFiStatsCountType
74
74
kWiFiOverrunCount
75
75
};
76
76
77
+ #if defined(__GLIBC__)
77
78
// Static variable to store the maximum heap size
78
79
static size_t maxHeapHighWatermark = 0 ;
80
+ #endif
79
81
80
82
CHIP_ERROR GetEthernetStatsCount (EthernetStatsCountType type, uint64_t & count)
81
83
{
@@ -223,24 +225,22 @@ DiagnosticDataProviderImpl & DiagnosticDataProviderImpl::GetDefaultInstance()
223
225
224
226
CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapFree (uint64_t & currentHeapFree)
225
227
{
226
- #ifndef __GLIBC__
227
- return CHIP_ERROR_NOT_IMPLEMENTED;
228
- #else
228
+ #if defined(__GLIBC__)
229
229
struct mallinfo mallocInfo = mallinfo ();
230
230
231
231
// Get the current amount of heap memory, in bytes, that are not being utilized
232
232
// by the current running program.
233
233
currentHeapFree = mallocInfo.fordblks ;
234
234
235
235
return CHIP_NO_ERROR;
236
+ #else
237
+ return CHIP_ERROR_NOT_IMPLEMENTED;
236
238
#endif
237
239
}
238
240
239
241
CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapUsed (uint64_t & currentHeapUsed)
240
242
{
241
- #ifndef __GLIBC__
242
- return CHIP_ERROR_NOT_IMPLEMENTED;
243
- #else
243
+ #if defined(__GLIBC__)
244
244
struct mallinfo mallocInfo = mallinfo ();
245
245
246
246
// Get the current amount of heap memory, in bytes, that are being used by
@@ -253,14 +253,14 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapUsed(uint64_t & currentHeap
253
253
maxHeapHighWatermark = currentHeapUsed;
254
254
}
255
255
return CHIP_NO_ERROR;
256
+ #else
257
+ return CHIP_ERROR_NOT_IMPLEMENTED;
256
258
#endif
257
259
}
258
260
259
261
CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark (uint64_t & currentHeapHighWatermark)
260
262
{
261
- #ifndef __GLIBC__
262
- return CHIP_ERROR_NOT_IMPLEMENTED;
263
- #else
263
+ #if defined(__GLIBC__)
264
264
struct mallinfo mallocInfo = mallinfo ();
265
265
266
266
// The usecase of this function is embedded devices,on which we would need to intercept
@@ -279,6 +279,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & cu
279
279
currentHeapHighWatermark = maxHeapHighWatermark;
280
280
281
281
return CHIP_NO_ERROR;
282
+ #else
283
+ return CHIP_ERROR_NOT_IMPLEMENTED;
282
284
#endif
283
285
}
284
286
@@ -287,10 +289,12 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks()
287
289
// If implemented, the server SHALL set the value of the CurrentHeapHighWatermark attribute to the
288
290
// value of the CurrentHeapUsed.
289
291
292
+ #if defined(__GLIBC__)
290
293
// Get the current amount of heap memory, in bytes, that are being used by
291
294
// the current running program and reset the max heap high watermark to current heap amount.
292
295
struct mallinfo mallocInfo = mallinfo ();
293
296
maxHeapHighWatermark = mallocInfo.uordblks ;
297
+ #endif
294
298
295
299
return CHIP_NO_ERROR;
296
300
}
0 commit comments