| index 54a63c8..fc8719d 100644 | | index 54a63c8..fc8719d 100644 |
| --- a/src/plugin_sysmon.c | | --- a/src/plugin_sysmon.c |
| +++ b/src/plugin_sysmon.c | | +++ b/src/plugin_sysmon.c |
| @@ -18,10 +18,15 @@ | | @@ -18,10 +18,15 @@ |
| 18 | * MIT License. Copyright (c) 2026 SCORPIOX INC. | 18 | * MIT License. Copyright (c) 2026 SCORPIOX INC. |
| 19 | */ | 19 | */ |
| 20 | | 20 | |
| 21 | -#if !defined(_WIN32) | 21 | +#if defined(__APPLE__) |
| | 22 | + /* sysctl.h pulls in BSD types (u_int) that strict c99 would hide */ |
| | 23 | +# define _DARWIN_C_SOURCE 1 |
| | 24 | +#elif !defined(_WIN32) |
| 22 | # define _POSIX_C_SOURCE 200809L | 25 | # define _POSIX_C_SOURCE 200809L |
| 23 | # define _DEFAULT_SOURCE 1 | 26 | # define _DEFAULT_SOURCE 1 |
| 24 | -#elif !defined(_WIN32_WINNT) | 27 | +#endif |
| | 28 | + |
| | 29 | +#if defined(_WIN32) && !defined(_WIN32_WINNT) |
| 25 | # define _WIN32_WINNT 0x0601 /* GetTickCount64 needs Vista or later; must precede windows.h */ | 30 | # define _WIN32_WINNT 0x0601 /* GetTickCount64 needs Vista or later; must precede windows.h */ |
| 26 | #endif | 31 | #endif |
| 27 | | 32 | |
| @@ -616,8 +621,6 @@ static void sample_macos(sys_t *s) | | @@ -616,8 +621,6 @@ static void sample_macos(sys_t *s) |
| 616 | integer_t *cpu0 = NULL, *cpu1 = NULL; | 621 | integer_t *cpu0 = NULL, *cpu1 = NULL; |
| 617 | natural_t ncpu0 = 0, ncpu1 = 0; | 622 | natural_t ncpu0 = 0, ncpu1 = 0; |
| 618 | unsigned long long page_kb; | 623 | unsigned long long page_kb; |
| 619 | - unsigned long long tick_hz = 1000ULL; /* we time the window ourselves */ | | |
| 620 | - double window; | | |
| 621 | | 624 | |
| 622 | strcpy(s->platform, "macos"); | 625 | strcpy(s->platform, "macos"); |
| 623 | | 626 | |
| @@ -651,8 +654,6 @@ static void sample_macos(sys_t *s) | | @@ -651,8 +654,6 @@ static void sample_macos(sys_t *s) |
| 651 | cpu1 = NULL; | 654 | cpu1 = NULL; |
| 652 | } | 655 | } |
| 653 | | 656 | |
| 654 | - window = (double)SAMPLE_MS / 1000.0; | | |
| 655 | - | | |
| 656 | if (cpu0 && cpu1) { | 657 | if (cpu0 && cpu1) { |
| 657 | natural_t i; | 658 | natural_t i; |
| 658 | natural_t n = ncpu1 < ncpu0 ? ncpu1 : ncpu0; | 659 | natural_t n = ncpu1 < ncpu0 ? ncpu1 : ncpu0; |
| @@ -683,16 +684,12 @@ static void sample_macos(sys_t *s) | | @@ -683,16 +684,12 @@ static void sample_macos(sys_t *s) |
| 683 | s->cpu_pct = t_total ? clamp_pct(100.0 - 100.0 * (double)t_idle / (double)t_total) : 0.0; | 684 | s->cpu_pct = t_total ? clamp_pct(100.0 - 100.0 * (double)t_idle / (double)t_total) : 0.0; |
| 684 | } | 685 | } |
| 685 | | 686 | |
| 686 | - if (cpu0) { | 687 | + if (cpu0) |
| 687 | - vm_size_t freed = 0; | | |
| 688 | (void)vm_deallocate(mach_task_self(), (vm_address_t)cpu0, | 688 | (void)vm_deallocate(mach_task_self(), (vm_address_t)cpu0, |
| 689 | (vm_size_t)(ncpu0 * CPU_STATE_MAX * sizeof(integer_t))); | 689 | (vm_size_t)(ncpu0 * CPU_STATE_MAX * sizeof(integer_t))); |
| 690 | - } | 690 | + if (cpu1) |
| 691 | - if (cpu1) { | | |
| 692 | - vm_size_t freed = 0; | | |
| 693 | (void)vm_deallocate(mach_task_self(), (vm_address_t)cpu1, | 691 | (void)vm_deallocate(mach_task_self(), (vm_address_t)cpu1, |
| 694 | (vm_size_t)(ncpu1 * CPU_STATE_MAX * sizeof(integer_t))); | 692 | (vm_size_t)(ncpu1 * CPU_STATE_MAX * sizeof(integer_t))); |
| 695 | - } | | |
| 696 | | 693 | |
| 697 | sz = sizeof(total_mem); | 694 | sz = sizeof(total_mem); |
| 698 | if (sysctlbyname("hw.memsize", &total_mem, &sz, NULL, 0) != 0) | 695 | if (sysctlbyname("hw.memsize", &total_mem, &sz, NULL, 0) != 0) |
| @@ -768,7 +765,6 @@ static void sample_macos(sys_t *s) | | @@ -768,7 +765,6 @@ static void sample_macos(sys_t *s) |
| 768 | } | 765 | } |
| 769 | | 766 | |
| 770 | s->ok = (s->ncores > 0 && s->mem_total_kb > 0.0); | 767 | s->ok = (s->ncores > 0 && s->mem_total_kb > 0.0); |
| 771 | - (void)tick_hz; | | |
| 772 | } | 768 | } |
| 773 | | 769 | |
| 774 | #endif /* __APPLE__ */ | 770 | #endif /* __APPLE__ */ |
| 775 | | 771 | |