summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkx <kx@radix-linux.su>2026-10-18 13:52:03 +0300
committerkx <kx@radix-linux.su>2026-10-18 13:52:03 +0300
commit8949ef8b9e8a5bdbdbc56f9a97c94ecfafc239bf (patch)
treec338069d902e353d49c4b12924517c2432d78377 /src
parent81811df9bdd97d8230eb7dec75e30d4297a930ab (diff)
downloadmcpu-cpp-8949ef8b9e8a5bdbdbc56f9a97c94ecfafc239bf.tar.xz
Predefined complex types are aligned with LibMCPU
Diffstat (limited to 'src')
-rw-r--r--src/mcpp-predefined.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/mcpp-predefined.c b/src/mcpp-predefined.c
index 32b1ec4..325ac3b 100644
--- a/src/mcpp-predefined.c
+++ b/src/mcpp-predefined.c
@@ -1,3 +1,4 @@
+
#include <defs.h>
@@ -371,9 +372,9 @@ define_real_family( mcpu_macro_table *table, unsigned bits )
int nb = (int)(bits / 8);
/*
- * Real and Complex language types exist only through the configured
- * MPU_REAL_IO_LIMIT. Complex WIDTH is the width parameter in the language
- * type name (complex128 -> 128), while SIZEOF is twice the Real storage.
+ * Real and Complex types are limited by MPU_REAL_IO_LIMIT. A Complex
+ * width is the total storage width: complex128 consists of two real64
+ * components. The smallest Complex type is complex64.
*/
if( bits > MCPU_CPP_MPU_REAL_IO_LIMIT )
return( 0 );
@@ -383,24 +384,33 @@ define_real_family( mcpu_macro_table *table, unsigned bits )
if( define_utf8(table, name, type) != 0 )
return( -1 );
- snprintf( name, sizeof(name), "__COMPLEX%u_TYPE__", bits );
- snprintf( type, sizeof(type), "complex%u", bits );
- if( define_utf8(table, name, type) != 0 )
- return( -1 );
+ if( bits >= 64 )
+ {
+ snprintf( name, sizeof(name), "__COMPLEX%u_TYPE__", bits );
+ snprintf( type, sizeof(type), "complex%u", bits );
+ if( define_utf8(table, name, type) != 0 )
+ return( -1 );
+ }
snprintf( name, sizeof(name), "__REAL%u_WIDTH__", bits );
if( define_unsigned(table, name, bits) != 0 )
return( -1 );
- snprintf( name, sizeof(name), "__COMPLEX%u_WIDTH__", bits );
- if( define_unsigned(table, name, bits) != 0 )
- return( -1 );
+ if( bits >= 64 )
+ {
+ snprintf( name, sizeof(name), "__COMPLEX%u_WIDTH__", bits );
+ if( define_unsigned(table, name, bits) != 0 )
+ return( -1 );
+ }
snprintf( name, sizeof(name), "__SIZEOF_REAL%u__", bits );
if( define_unsigned(table, name, bits / 8) != 0 )
return( -1 );
- snprintf( name, sizeof(name), "__SIZEOF_COMPLEX%u__", bits );
- if( define_unsigned(table, name, bits / 4) != 0 )
- return( -1 );
+ if( bits >= 64 )
+ {
+ snprintf( name, sizeof(name), "__SIZEOF_COMPLEX%u__", bits );
+ if( define_unsigned(table, name, bits / 8) != 0 )
+ return( -1 );
+ }
/*
* These are compact structural/text-conversion properties. They are