| 556 | #include <unistd.h> // pathconf |
| 557 | |
| 558 | static size_t mi_path_max(void) { |
| 559 | static _Atomic(size_t) path_max = 0; |
| 560 | size_t pmax = mi_atomic_load_acquire(&path_max); |
| 561 | if (pmax == 0) { |
| 562 | long m = 0; |
| 563 | #ifdef _PC_PATH_MAX |
| 564 | m = pathconf("/",_PC_PATH_MAX); |
| 565 | #endif |
| 566 | if (m <= 0) pmax = 4096; // guess |
| 567 | else if (m < 256) pmax = 256; // at least 256 |
| 568 | else if (m > 64*1024) pmax = 64*1024; // at most 64 KiB |
| 569 | else pmax = m; |
| 570 | size_t expected = 0; |
| 571 | mi_atomic_cas_strong_acq_rel(&path_max, &expected, pmax); |
| 572 | } |
| 573 | return pmax; |
| 574 | } |
| 575 | |
| 576 | char* mi_theap_realpath(mi_theap_t* theap, const char* fname, char* resolved_name) mi_attr_noexcept { |
| 577 | if (resolved_name != NULL) { |
no test coverage detected