Move `MBEDTLS_ERR_ADD` macro and functions to `error.*`

`error.c` and  error.h are the more logical place to keep this code and it
prevents issues with building `common.c` and conflicts with other projects
that use mbedtls (such as mbedOS).

`error.c` has been automatically generated by first adding the code to
`error.fmt` and then running `./scripts/generate_errors.pl`.

Also add parenthesis to the addition in `MBEDTLS_ERR_ADD`.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
diff --git a/scripts/data_files/error.fmt b/scripts/data_files/error.fmt
index 9e479bb..fdb3ce2 100644
--- a/scripts/data_files/error.fmt
+++ b/scripts/data_files/error.fmt
@@ -82,6 +82,22 @@
     return( NULL );
 }
 
+#if defined(MBEDTLS_TEST_HOOKS)
+static void (*err_add_hook)( int, int, const char *, int );
+
+void mbedtls_set_err_add_hook(void *hook)
+{
+    err_add_hook = hook;
+}
+
+int mbedtls_err_add( int high, int low, const char *file, int line )
+{
+    if( err_add_hook != NULL )
+        (*err_add_hook)( high, low, file, line );
+    return ( high + low );
+}
+#endif /* MBEDTLS_TEST_HOOKS */
+
 void mbedtls_strerror( int ret, char *buf, size_t buflen )
 {
     size_t len;