Index: trunk/psLib/src/sys/Makefile.am
===================================================================
--- trunk/psLib/src/sys/Makefile.am	(revision 7707)
+++ trunk/psLib/src/sys/Makefile.am	(revision 7766)
@@ -30,4 +30,5 @@
 pslibinclude_HEADERS = \
 	psAbort.h \
+	psAssert.h \
 	psConfigure.h  \
 	psError.h      \
Index: trunk/psLib/src/sys/psAssert.h
===================================================================
--- trunk/psLib/src/sys/psAssert.h	(revision 7766)
+++ trunk/psLib/src/sys/psAssert.h	(revision 7766)
@@ -0,0 +1,223 @@
+#ifndef PS_ASSERT_H
+#define PS_ASSERT_H
+
+#include "psError.h"
+#include "psLogMsg.h"
+
+#define PS_ASSERT_INT_UNEQUAL(NAME1, NAME2, RVAL) \
+if ((NAME1) == (NAME2)) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s and %s are equal.", \
+            #NAME1, #NAME2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_INT_EQUAL(NAME1, NAME2, RVAL) \
+if ((NAME1) != (NAME2)) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s and %s are not equal.", \
+            #NAME1, #NAME2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_INT_NONNEGATIVE(NAME, RVAL) \
+if ((NAME) < 0) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error: %s is less than 0.", #NAME); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_INT_POSITIVE(NAME, RVAL) \
+if ((NAME) < 1) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s is 0 or less.", #NAME); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_INT_ZERO(NAME, RVAL) \
+if ((NAME) != 0) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s is 0.", #NAME); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_INT_NONZERO(NAME, RVAL) \
+if ((NAME) == 0) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s is 0.", #NAME); \
+    return(RVAL); \
+}
+
+// XXX: Where did these int casts come from?
+#define PS_ASSERT_INT_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) \
+if ((int)(NAME) < LOWER || (int)(NAME) > UPPER) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s, %d, is out of range.  Must be between %d and %d.", \
+            #NAME,(int)NAME,LOWER,UPPER); \
+    return RVAL; \
+}
+
+#define PS_ASSERT_INT_LESS_THAN(VAR1, VAR2, RVAL) \
+if (!(VAR1 < VAR2)) { \
+    psError(PS_ERR_UNKNOWN, true, \
+            "Error: %s is not less than %s (%d, %d)", #VAR1, #VAR2, VAR1, VAR2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_INT_LESS_THAN_OR_EQUAL(VAR1, VAR2, RVAL) \
+if (!(VAR1 <= VAR2)) { \
+    psError(PS_ERR_UNKNOWN, true, \
+            "Error: %s is not less than %s (%d, %d)", #VAR1, #VAR2, VAR1, VAR2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_INT_LARGER_THAN(NAME1, NAME2, RVAL) \
+if (!((NAME1) > (NAME2))) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: !(%s > %s) (%d %d).", \
+            #NAME1, #NAME2, NAME1, NAME2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_INT_LARGER_THAN_OR_EQUAL(NAME1, NAME2, RVAL) \
+if (!((NAME1) >= (NAME2))) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: !(%s >= %s) (%d %d).", \
+            #NAME1, #NAME2, NAME1, NAME2); \
+    return(RVAL); \
+}
+#define PS_ASSERT_FLOAT_LARGER_THAN(NAME1, NAME2, RVAL) \
+if (!((NAME1) > (NAME2))) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: !(%s > %s) (%f %f).", \
+            #NAME1, #NAME2, NAME1, NAME2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(NAME1, NAME2, RVAL) \
+if (!((NAME1) >= (NAME2))) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: !(%s >= %s) (%f %f).", \
+            #NAME1, #NAME2, NAME1, NAME2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_FLOAT_LESS_THAN(NAME1, NAME2, RVAL) \
+if (!((NAME1) < (NAME2))) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: !(%s < %s) (%f %f).", \
+            #NAME1, #NAME2, NAME1, NAME2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(NAME1, NAME2, RVAL) \
+if (!((NAME1) <= (NAME2))) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: !(%s <= %s) (%f %f).", \
+            #NAME1, #NAME2, NAME1, NAME2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_FLOAT_NON_EQUAL(NAME1, NAME2, RVAL) \
+if (fabs((NAME2) - (NAME1)) < FLT_EPSILON) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s and %s are equal.", \
+            #NAME1, #NAME2); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_FLOAT_EQUAL(NAME1, NAME2, RVAL) \
+if (fabs((NAME2) - (NAME1)) > FLT_EPSILON) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s and %s are not equal.", \
+            #NAME1, #NAME2); \
+    return(RVAL); \
+}
+
+// Return an error if the arg lies outside the supplied range.
+#define PS_ASSERT_FLOAT_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) \
+if ((NAME) < (LOWER) || (NAME) > (UPPER)) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s, %f, is out of range.  Must be between %f and %f.", \
+            #NAME, NAME, LOWER, UPPER); \
+    return RVAL; \
+}
+
+#define PS_ASSERT_DOUBLE_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) \
+if ((NAME) < (LOWER) || (NAME) > (UPPER)) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s, %lf, is out of range.  Must be between %lf and %lf.", \
+            #NAME, NAME, LOWER, UPPER); \
+    return RVAL; \
+}
+
+#define PS_ASSERT_LONG_WITHIN_RANGE(NAME, LOWER, UPPER, RVAL) \
+if ((NAME) < (LOWER) || (NAME) > (UPPER)) { \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Error: %s, %lld, is out of range.", \
+            #NAME, NAME, LOWER, UPPER); \
+    return RVAL; \
+}
+
+/*****************************************************************************
+Macros which take a generic psLib type and determine if it is NULL, or has
+the wrong type.
+*****************************************************************************/
+#define PS_WARN_PTR_NON_NULL(NAME) \
+if ((NAME) == NULL) { \
+    psLogMsg(__func__, PS_LOG_WARN, "WARNING: %s is NULL.", #NAME); \
+} \
+
+#define PS_ASSERT_PTR_NON_NULL(NAME, RVAL) PS_ASSERT_GENERAL_PTR_NON_NULL(NAME, return RVAL)
+#define PS_ASSERT_GENERAL_PTR_NON_NULL(NAME, CLEANUP) \
+if ((NAME) == NULL) { \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: %s is NULL.", \
+            #NAME); \
+    CLEANUP; \
+}
+
+#define PS_ASSERT_PTR_TYPE(NAME, TYPE, RVAL) \
+if ((NAME)->type.type != TYPE) { \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: %s has incorrect type.", \
+            #NAME); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_PTR_DIMEN(NAME, DIMEN, RVAL) PS_ASSERT_GENERAL_PTR_DIMEN(NAME, DIMEN, return RVAL)
+#define PS_ASSERT_GENERAL_PTR_DIMEN(NAME, DIMEN, CLEANUP) \
+if ((NAME)->type.dimen != DIMEN) { \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: %s has incorrect dimensionality.", \
+            #NAME); \
+    CLEANUP; \
+}
+
+#define PS_ASSERT_PTR_DIMEN_GENERAL_NOT(NAME, DIMEN, CLEANUP) \
+if ((NAME)->type.dimen == DIMEN) { \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "Unallowable operation: %s has incorrect dimensionality.", \
+            #NAME); \
+    CLEANUP; \
+}
+
+
+#define PS_ASSERT_PTRS_SIZE_EQUAL(PTR1, PTR2, RVAL) \
+if (PTR1->n != PTR2->n) { \
+    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
+            "ptr %s has size %d, ptr %s has size %d.", \
+            #PTR1, PTR1->n, #PTR2, PTR2->n); \
+    return(RVAL); \
+}
+
+#define PS_ASSERT_PTR_TYPE_EQUAL(PTR1, PTR2, RVAL) PS_ASSERT_PTRS_TYPE_EQUAL_GENERAL(PTR1, PTR2, return RVAL)
+#define PS_ASSERT_PTRS_TYPE_EQUAL_GENERAL(PTR1, PTR2, CLEANUP) \
+if (PTR1->type.type != PTR2->type.type) { \
+    psError(PS_ERR_BAD_PARAMETER_TYPE, true, \
+            "ptr %s has type %d, ptr %s has type %d.", \
+            #PTR1, PTR1->type.type, #PTR2, PTR2->type.type); \
+    CLEANUP; \
+}
+
+
+#endif
Index: trunk/psLib/src/sys/psString.c
===================================================================
--- trunk/psLib/src/sys/psString.c	(revision 7707)
+++ trunk/psLib/src/sys/psString.c	(revision 7766)
@@ -13,6 +13,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-23 20:29:39 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-06-30 02:20:06 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -25,5 +25,5 @@
 #include "psMemory.h"
 #include "psError.h"
-#include "psConstants.h"
+#include "psAssert.h"
 
 #include "psErrorText.h"
