diff --git a/src/encode.c b/src/encode.c
index a2786c70324e6ff8e575826c23e624dd48426cfc..b2f95fb23690af0e8757641db24a195b6ca6b3af 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -25,7 +25,7 @@
 #include "version.h"
 #include "bignum.h"
 
-RCSID("$Id: encode.c,v 1.61 2000/07/07 01:27:16 hubbe Exp $");
+RCSID("$Id: encode.c,v 1.62 2000/07/07 19:27:12 grubba Exp $");
 
 /* #define ENCODE_DEBUG */
 
@@ -35,6 +35,12 @@ RCSID("$Id: encode.c,v 1.61 2000/07/07 01:27:16 hubbe Exp $");
 #define EDB(X)
 #endif
 
+/* The sp macro conflicts with Solaris 2.5.1's <sys/conf.h>. */
+#ifdef sp
+#undef sp
+#define STACKPOINTER_WAS_DEFINED
+#endif /* sp */
+
 #ifdef _AIX
 #include <net/nh.h>
 #endif
@@ -45,6 +51,12 @@ RCSID("$Id: encode.c,v 1.61 2000/07/07 01:27:16 hubbe Exp $");
 
 #include <math.h>
 
+/* Restore the sp macro */
+#ifdef STACKPOINTER_WAS_DEFINED
+#define sp Pike_sp
+#undef STACK_POINTER_WAS_DEFINED
+#endif /* STACKPOINTER_WAS_DEFINED */
+
 #ifdef HAVE_FREXP
 #define FREXP frexp
 #else