-#ifdef sun
-#include <sys/kmem_alloc.h>
-#define ALLOCATE(n) kmem_alloc((n), KMEM_NOSLEEP)
-#define FREE(p, n) kmem_free((p), (n))
+#ifdef __svr4__ /* SVR4, including SunOS 5.x */
+# include <sys/kmem.h>
+# define ALLOCATE(n) kmem_alloc((n), KM_NOSLEEP)
+# define FREE(p, n) kmem_free((p), (n))
+#else /* SunOS 4.x */
+# ifdef sun
+# include <sys/kmem_alloc.h>
+# define ALLOCATE(n) kmem_alloc((n), KMEM_NOSLEEP)
+# define FREE(p, n) kmem_free((p), (n))
+# endif