diff --git a/main/asterisk.c b/main/asterisk.c
index eaf2d7d56b9d3247c39ccbea6e5a7115b408289d..4520318254391de2a9df7d55ad1c06cae2f698af 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -810,10 +810,10 @@ int64_t ast_profile(int i, int64_t delta)
 /* The RDTSC instruction was introduced on the Pentium processor and is not
  * implemented on certain clones, like the Cyrix 586. Hence, the previous
  * expectation of __i386__ was in error. */
-#if defined ( __i686__) && (defined(__FreeBSD__) || defined(linux))
+#if defined ( __i686__) && (defined(__FreeBSD__) || defined(__NetBSD__) || defined(linux))
 #if defined(__FreeBSD__)
 #include <machine/cpufunc.h>
-#elif defined(linux)
+#elif defined(__NetBSD__) || defined(linux)
 static __inline uint64_t
 rdtsc(void)
 {