summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Jensen2023-01-12 09:07:37 +0100
committerGabriel Jensen2023-01-12 09:07:37 +0100
commitaae11fc934acd16c8b50dc35487dce44f5c482d2 (patch)
tree4e0ddb5066d627cf920d4f0e5c6c073687c5d4f0
parent4651f12786ee0056924bb13243161ef947b333d2 (diff)
Improve compatibility with C++; Add missing C++ support for 'key' header; Fix and improve 'limits' header;HEAD12.2master
-rw-r--r--CHANGELOG.txt6
-rw-r--r--ax/GNUmakefile2
-rw-r--r--ax/include-private/ax/priv.h8
-rw-r--r--ax/include/ax/algo.h10
-rw-r--r--ax/include/ax/bs.h22
-rw-r--r--ax/include/ax/gfx.h8
-rw-r--r--ax/include/ax/key.h4
-rw-r--r--ax/include/limits.h6
-rw-r--r--ax/include/string.h2
-rw-r--r--demo/GNUmakefile1
10 files changed, 39 insertions, 30 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index addbf43..2a66c38 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,9 @@
+# C.2
+
+* Improve compatibility with C++;
+* Add missing C++ support for 'key' header;
+* Fix and improve 'limits' header;
+
# C.1
* Update copyright notices;
diff --git a/ax/GNUmakefile b/ax/GNUmakefile
index 14ab462..babcdab 100644
--- a/ax/GNUmakefile
+++ b/ax/GNUmakefile
@@ -21,6 +21,7 @@ CFLAGS := \
-Wextra \
-Wpadded \
-Wpedantic \
+ -Wno-attributes \
-ffreestanding \
-fno-strict-aliasing \
-fshort-enums \
@@ -39,6 +40,7 @@ CXXFLAGS := \
-Wall \
-Wextra \
-Wpedantic \
+ -Wno-attributes \
-ffreestanding \
-fno-exceptions \
-fno-strict-aliasing \
diff --git a/ax/include-private/ax/priv.h b/ax/include-private/ax/priv.h
index c676e13..0cd1b51 100644
--- a/ax/include-private/ax/priv.h
+++ b/ax/include-private/ax/priv.h
@@ -9,9 +9,7 @@
#include <ax/bs.h>
-#if defined(__cplusplus)
-extern "C" {
-#endif
+__ax_cdecl
#define __ax_get01(_addr) (*(ax_i01 volatile *)_addr)
@@ -30,9 +28,7 @@ extern "C" {
__ax_set01(addr,_col); \
}
-#if defined(__cplusplus)
-}
-#endif
+__ax_endcdecl
#if defined(__cplusplus)
diff --git a/ax/include/ax/algo.h b/ax/include/ax/algo.h
index 587133a..6dc73f8 100644
--- a/ax/include/ax/algo.h
+++ b/ax/include/ax/algo.h
@@ -9,9 +9,7 @@
#include <ax/bs.h>
-#if defined(__cplusplus)
-extern "C" {
-#endif
+__ax_cdecl
typedef struct {
ax_i02 quot;
@@ -22,10 +20,8 @@ void ax_cp( void const * in, ax_i02 num,void * out);
void ax_cp8( void const * in, ax_i02 num,void * out);
void ax_fill(void * ptr,ax_i02 num,ax_i8 byte);
-ax_quotrem ax_divmod(ax_i02 num,ax_i02 den) [[unsequenced]];
+[[unsequenced]] ax_quotrem ax_divmod(ax_i02 num,ax_i02 den);
-#if defined(__cplusplus)
-}
-#endif
+__ax_endcdecl
#endif
diff --git a/ax/include/ax/bs.h b/ax/include/ax/bs.h
index 4c84563..c35e06b 100644
--- a/ax/include/ax/bs.h
+++ b/ax/include/ax/bs.h
@@ -8,10 +8,10 @@
#define __ax_hdr_ax_bs
#if defined(__cplusplus)
-extern "C" {
-#endif
-
-#if !defined(__cplusplus)
+#define __ax_cdecl extern "C" {
+#define __ax_endcdecl }
+#define __ax_unseq
+#else
/* C23 compatibility: */
#define alignas _Alignas
#define alignof _Alignof
@@ -24,8 +24,14 @@ extern "C" {
#define true ((_Bool)+0x1u)
#define typeof __typeof__
#define typeof_unqual __typeof__
+
+#define __ax_cdecl
+#define __ax_endcdecl
+#define __ax_unseq [[unsequenced]]
#endif
+__ax_cdecl
+
#define ax_maxval_i ((int)+0x7FFFFFFF)
#define ax_minval_i ((int)-0x80000000)
@@ -92,11 +98,9 @@ void ax_set01(ax_i02 addr,ax_i01 val);
void ax_set02(ax_i02 addr,ax_i02 val);
void ax_set8( ax_i02 addr,ax_i8 val);
-void ax_done(ax_err err) [[noreturn]];
-void ax_trap(void) [[noreturn]];
+[[noreturn]] void ax_done(ax_err err);
+[[noreturn]] void ax_trap(void);
-#if defined(__cplusplus)
-}
-#endif
+__ax_endcdecl
#endif
diff --git a/ax/include/ax/gfx.h b/ax/include/ax/gfx.h
index 946de1f..e108c3c 100644
--- a/ax/include/ax/gfx.h
+++ b/ax/include/ax/gfx.h
@@ -9,9 +9,7 @@
#include <ax/bs.h>
-#if defined(__cplusplus)
-extern "C" {
-#endif
+__ax_cdecl
constexpr ax_i8 ax_scrnw3 = 0xF0u;
constexpr ax_i8 ax_scrnw5 = 0xA0u;
@@ -59,8 +57,6 @@ void ax_rec2( ax_i02 vaddr,ax_i8 scrnw,ax_i01 px,ax_i8 w,ax_i8 h,ax_i01 col);
void ax_hrec1(ax_i02 vaddr,ax_i8 scrnw,ax_i01 px,ax_i8 w,ax_i8 h,ax_i8 col);
void ax_hrec2(ax_i02 vaddr,ax_i8 scrnw,ax_i01 px,ax_i8 w,ax_i8 h,ax_i01 col);
-#if defined(__cplusplus)
-}
-#endif
+__ax_endcdecl
#endif
diff --git a/ax/include/ax/key.h b/ax/include/ax/key.h
index 1bab2b8..290f3b2 100644
--- a/ax/include/ax/key.h
+++ b/ax/include/ax/key.h
@@ -9,6 +9,8 @@
#include <ax/bs.h>
+__ax_cdecl
+
typedef enum {
ax_key_a = 0b00000000'00000001u,
ax_key_b = 0b00000000'00000010u,
@@ -30,4 +32,6 @@ typedef struct {
ax_keymap ax_getkeymap(void);
+__ax_endcdecl
+
#endif
diff --git a/ax/include/limits.h b/ax/include/limits.h
index fc696bd..31b48a6 100644
--- a/ax/include/limits.h
+++ b/ax/include/limits.h
@@ -30,12 +30,16 @@
#define ULLONG_WIDTH (0x40)
#define LLONG_WIDTH ULLONG_WIDTH
+#if defined(__BITINT_MAXWIDTH__)
+#define BITINT_MAXWIDTH (__BITINT_MAXWIDTH__)
+#else
#define BITINT_MAXWIDTH ULLONG_WIDTH
+#endif
#define MB_LEN_MAX (0x4)
#define UCHAR_MAX ((unsigned int)+ax_maxval_uc)
-#define CHAR_MAX CHAR_MAX
+#define CHAR_MAX UCHAR_MAX
#define USHRT_MAX ((unsigned int)+ax_maxval_us)
diff --git a/ax/include/string.h b/ax/include/string.h
index 5ec1195..fd63ec9 100644
--- a/ax/include/string.h
+++ b/ax/include/string.h
@@ -32,7 +32,7 @@ int strcmp( char const * s1,char const * s2);
int strncmp(char const * s1,char const * s2);
/* strxfrm not required. */
-/* We're missing the generic variations of the following functions: */
+/* We're missing the generic variants of the following functions: */
void * memchr( void const * s, int c, size_t n);
char * strchr( char const * s, int c);
size_t strcspn(char const * s1,char const * s2);
diff --git a/demo/GNUmakefile b/demo/GNUmakefile
index b3f038b..c2e5143 100644
--- a/demo/GNUmakefile
+++ b/demo/GNUmakefile
@@ -19,6 +19,7 @@ CFLAGS := \
-Wall \
-Wextra \
-Wpedantic \
+ -Wno-attributes \
-ffreestanding \
-fshort-enums \
-mcpu=arm7tdmi \