From 8949ef8b9e8a5bdbdbc56f9a97c94ecfafc239bf Mon Sep 17 00:00:00 2001 From: kx Date: Sun, 18 Oct 2026 13:52:03 +0300 Subject: Predefined complex types are aligned with LibMCPU --- src/mcpp-predefined.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/mcpp-predefined.c') 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 @@ -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 -- cgit v1.2.3