3030#include <sys/proc_info.h>
3131#include <sys/stat.h>
3232#include <unistd.h>
33- #elif defined(__linux__ )
33+ #elif defined(__linux__ ) || defined( __NetBSD__ )
3434#include <fcntl.h>
3535#include <sys/stat.h>
3636#include <unistd.h>
@@ -135,7 +135,7 @@ typedef struct {
135135 HANDLE file ;
136136 BY_HANDLE_FILE_INFORMATION information ;
137137 LARGE_INTEGER size ;
138- #elif defined(__APPLE__ ) || defined(__linux__ )
138+ #elif defined(__APPLE__ ) || defined(__linux__ ) || defined( __NetBSD__ )
139139 int fd ;
140140 struct stat status ;
141141#endif
@@ -490,7 +490,7 @@ static bool runtime_activation_response_decode(
490490static uint64_t runtime_current_process_id (void ) {
491491#ifdef _WIN32
492492 return (uint64_t )GetCurrentProcessId ();
493- #elif defined(__APPLE__ ) || defined(__linux__ )
493+ #elif defined(__APPLE__ ) || defined(__linux__ ) || defined( __NetBSD__ )
494494 return (uint64_t )getpid ();
495495#else
496496 return 0 ;
@@ -504,7 +504,7 @@ static void runtime_process_image_reference_init(runtime_process_image_reference
504504 memset (reference , 0 , sizeof (* reference ));
505505#ifdef _WIN32
506506 reference -> file = INVALID_HANDLE_VALUE ;
507- #elif defined(__APPLE__ ) || defined(__linux__ )
507+ #elif defined(__APPLE__ ) || defined(__linux__ ) || defined( __NetBSD__ )
508508 reference -> fd = -1 ;
509509#endif
510510}
@@ -518,7 +518,7 @@ static bool runtime_process_image_reference_release(runtime_process_image_refere
518518 if (reference -> file != INVALID_HANDLE_VALUE && !CloseHandle (reference -> file )) {
519519 ok = false;
520520 }
521- #elif defined(__APPLE__ ) || defined(__linux__ )
521+ #elif defined(__APPLE__ ) || defined(__linux__ ) || defined( __NetBSD__ )
522522 if (reference -> fd >= 0 && close (reference -> fd ) != 0 ) {
523523 ok = false;
524524 }
@@ -658,7 +658,7 @@ static bool runtime_mac_process_maps_file_executable(int process_id, const struc
658658 return false;
659659}
660660
661- #elif defined(__linux__ )
661+ #elif defined(__linux__ ) || defined( __NetBSD__ )
662662
663663static bool runtime_linux_stat_same_image (const struct stat * first , const struct stat * second ) {
664664 return first && second && S_ISREG (first -> st_mode ) && S_ISREG (second -> st_mode ) &&
@@ -753,7 +753,7 @@ static bool runtime_process_image_reference_acquire(
753753 } else if (fd >= 0 ) {
754754 (void )close (fd );
755755 }
756- #elif defined(__linux__ )
756+ #elif defined(__linux__ ) || defined( __NetBSD__ )
757757 char proc_path [64 ];
758758 int written =
759759 snprintf (proc_path , sizeof (proc_path ), "/proc/%llu" , (unsigned long long )process_id );
@@ -827,7 +827,7 @@ static bool runtime_process_image_reference_matches_process(
827827 runtime_mac_stat_same (& active -> status , & peer .status );
828828 bool released = runtime_process_image_reference_release (& peer );
829829 return same && released ;
830- #elif defined(__linux__ )
830+ #elif defined(__linux__ ) || defined( __NetBSD__ )
831831 runtime_process_image_reference_t peer ;
832832 runtime_process_image_reference_init (& peer );
833833 bool same = runtime_process_image_reference_acquire (process_id , & peer , NULL );
0 commit comments