diff --git a/common/util.h b/common/util.h
index 86ea8d2..460aea5 100644
--- a/common/util.h
+++ b/common/util.h
@@ -66,6 +66,12 @@ extern intgen_t read_buf( char *bufp,
 			  rrbfp_t return_read_buf_funcp,
 			  intgen_t *statp );
 
+#ifndef min
+#define min( a, b )	( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
+#endif
+#ifndef max
+#define max( a, b )	( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
+#endif
 
 
 /* strncpyterm - like strncpy, but guarantees the destination is null-terminated
diff --git a/restore/dirattr.c b/restore/dirattr.c
index fcfa0c8..6413c15 100644
--- a/restore/dirattr.c
+++ b/restore/dirattr.c
@@ -51,6 +51,10 @@
 
 /* structure definitions used locally ****************************************/
 
+#ifndef max
+#define max( a, b )	( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
+#endif
+
 /* node handle limits
  */
 #ifdef DIRATTRCHK
diff --git a/restore/namreg.c b/restore/namreg.c
index 41362d1..4630605 100644
--- a/restore/namreg.c
+++ b/restore/namreg.c
@@ -34,6 +34,10 @@
 
 /* structure definitions used locally ****************************************/
 
+#ifndef max
+#define max( a, b )	( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
+#endif
+
 #define NAMREG_AVGLEN	10
 
 /* persistent context for a namreg - placed in first page
diff --git a/restore/node.c b/restore/node.c
index 4cc8fb0..97d46e1 100644
--- a/restore/node.c
+++ b/restore/node.c
@@ -30,6 +30,13 @@
 #include "node.h"
 #include "mmap.h"
 
+#ifndef max
+#define max( a, b )	( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
+#endif
+#ifndef min
+#define min( a, b )	( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
+#endif
+
 extern size_t pgsz;
 extern size_t pgmask;
 
