Rename assert to CHECK.

To avoid confusion with the usual definition of assert in C which will
sometimes be compiled out and the expression not evaluated. CHECK will
always be evaluated and tested.

Change-Id: I6a36359ecdecdada5c12ebf70c67cffec9574f7d
diff --git a/inc/hf/assert.h b/inc/hf/check.h
similarity index 77%
rename from inc/hf/assert.h
rename to inc/hf/check.h
index 299b296..41e005f 100644
--- a/inc/hf/assert.h
+++ b/inc/hf/check.h
@@ -16,22 +16,19 @@
 
 #pragma once
 
-#if !defined(__cplusplus)
-
 #include "hf/panic.h"
 
 /**
- * Only use for exceptional cases and never if the condition could be false e.g.
- * when processing external inputs.
+ * Only use to check assumptions which, if false, mean the system is in a bad
+ * state and it is unsafe to continue.
+ *
+ * Do not use if the condition could ever be legitimately false e.g. when
+ * processing external inputs.
  */
-#define assert(x)                                                             \
+#define CHECK(x)                                                              \
 	do {                                                                  \
 		if (!(x)) {                                                   \
 			panic("assertion failed (%s) at %s:%d", #x, __FILE__, \
 			      __LINE__);                                      \
 		}                                                             \
 	} while (0)
-
-#define static_assert _Static_assert
-
-#endif
diff --git a/inc/hf/io.h b/inc/hf/io.h
index 12bc440..fbafaf8 100644
--- a/inc/hf/io.h
+++ b/inc/hf/io.h
@@ -21,7 +21,7 @@
 
 #include "hf/arch/barriers.h"
 
-#include "hf/assert.h"
+#include "hf/check.h"
 
 /* Opaque types for different sized fields of memory mapped IO. */
 
@@ -101,25 +101,25 @@
 
 static inline uint8_t io_read8_array(io8_array_t io, size_t n)
 {
-	assert(n < io.count);
+	CHECK(n < io.count);
 	return io.base[n];
 }
 
 static inline uint16_t io_read16_array(io16_array_t io, size_t n)
 {
-	assert(n < io.count);
+	CHECK(n < io.count);
 	return io.base[n];
 }
 
 static inline uint32_t io_read32_array(io32_array_t io, size_t n)
 {
-	assert(n < io.count);
+	CHECK(n < io.count);
 	return io.base[n];
 }
 
 static inline uint64_t io_read64_array(io64_array_t io, size_t n)
 {
-	assert(n < io.count);
+	CHECK(n < io.count);
 	return io.base[n];
 }
 
@@ -217,25 +217,25 @@
 
 static inline void io_write8_array(io8_array_t io, size_t n, uint8_t v)
 {
-	assert(n < io.count);
+	CHECK(n < io.count);
 	io.base[n] = v;
 }
 
 static inline void io_write16_array(io16_array_t io, size_t n, uint16_t v)
 {
-	assert(n < io.count);
+	CHECK(n < io.count);
 	io.base[n] = v;
 }
 
 static inline void io_write32_array(io32_array_t io, size_t n, uint32_t v)
 {
-	assert(n < io.count);
+	CHECK(n < io.count);
 	io.base[n] = v;
 }
 
 static inline void io_write64_array(io64_array_t io, size_t n, uint64_t v)
 {
-	assert(n < io.count);
+	CHECK(n < io.count);
 	io.base[n] = v;
 }
 
diff --git a/inc/hf/mm.h b/inc/hf/mm.h
index b34fb2c..aebe77d 100644
--- a/inc/hf/mm.h
+++ b/inc/hf/mm.h
@@ -23,8 +23,8 @@
 #include "hf/arch/mm.h"
 
 #include "hf/addr.h"
-#include "hf/assert.h"
 #include "hf/mpool.h"
+#include "hf/static_assert.h"
 
 /* Keep macro alignment */
 /* clang-format off */
diff --git a/inc/hf/static_assert.h b/inc/hf/static_assert.h
new file mode 100644
index 0000000..da71ac6
--- /dev/null
+++ b/inc/hf/static_assert.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2019 The Hafnium Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#if !defined(__cplusplus)
+
+#define static_assert _Static_assert
+
+#endif