diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c
index 4fa3ad24a832e2e5a0bad4a094baf33d30c451e3..0f3b354e5988a31501f5b28486e148460a79aa8d 100644
--- a/gtests/net/packetdrill/run_system_call.c
+++ b/gtests/net/packetdrill/run_system_call.c
@@ -39,9 +39,11 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/ioctl.h>
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+#include <stddef.h>
+#endif
 #if defined(__FreeBSD__)
 #include <kvm.h>
-#include <stddef.h>
 #include <sys/sysctl.h>
 #include <sys/user.h>
 #include <sys/param.h>