Skip to content

Commit

Permalink
Missing wchar_t.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekKnapek committed Dec 10, 2023
1 parent dd76fe2 commit b1ca158
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mk_clib/src/mk_lang_alignof.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
#define mk_lang_alignof_bi_uchar_t mk_lang_alignof_bi_pchar_t
#define mk_lang_alignof_bi_schar_t mk_lang_alignof_bi_pchar_t

#if defined __SIZEOF_WCHAR_T__
#define mk_lang_alignof_bi_wchar_t __SIZEOF_WCHAR_T__
#else
#define mk_lang_alignof_bi_wchar_t 2
#endif

#define mk_lang_alignof_bi_ushort_t 2
#define mk_lang_alignof_bi_sshort_t mk_lang_alignof_bi_ushort_t

Expand Down
1 change: 1 addition & 0 deletions mk_clib/src/mk_lang_alignof_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
mk_lang_jumbo void mk_lang_alignof_test(void) mk_lang_noexcept
{
mk_lang_static_assert(mk_lang_alignof_bi_pchar_t == mk_lang_alignof(mk_lang_bi_pchar_t));
mk_lang_static_assert(mk_lang_alignof_bi_wchar_t == mk_lang_alignof(mk_lang_bi_wchar_t));
mk_lang_static_assert(mk_lang_alignof_bi_uchar_t == mk_lang_alignof(mk_lang_bi_uchar_t));
mk_lang_static_assert(mk_lang_alignof_bi_schar_t == mk_lang_alignof(mk_lang_bi_schar_t));
mk_lang_static_assert(mk_lang_alignof_bi_ushort_t == mk_lang_alignof(mk_lang_bi_ushort_t));
Expand Down
9 changes: 9 additions & 0 deletions mk_clib/src/mk_lang_bi.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#include "mk_lang_lllong.h"
#include "mk_lang_llong.h"
#include "mk_lang_sizet.h"
#include "mk_lang_wchar.h"


#define mk_lang_bi_pchar_t char
#define mk_lang_bi_wchar_t mk_lang_wchar_t
#define mk_lang_bi_uchar_t unsigned char
#define mk_lang_bi_schar_t signed char
#define mk_lang_bi_ushort_t unsigned short int
Expand All @@ -30,6 +32,7 @@
#define mk_lang_bi_ssize_t mk_lang_ssize_t

#define mk_lang_bi_is_unsigned_pchar_t 0
#define mk_lang_bi_is_unsigned_wchar_t 0
#define mk_lang_bi_is_unsigned_uchar_t 1
#define mk_lang_bi_is_unsigned_schar_t 0
#define mk_lang_bi_is_unsigned_ushort_t 1
Expand All @@ -50,6 +53,11 @@
#define mk_lang_bi_is_unsigned_ssize_t 0

#define mk_lang_bi_to_unsigned_pchar_t mk_lang_bi_uchar_t
#if defined __SIZEOF_WCHAR_T__ && __SIZEOF_WCHAR_T__ == 4
#define mk_lang_bi_to_unsigned_wchar_t mk_lang_bi_uint_t
#else
#define mk_lang_bi_to_unsigned_wchar_t mk_lang_bi_ushort_t
#endif
#define mk_lang_bi_to_unsigned_uchar_t mk_lang_bi_uchar_t
#define mk_lang_bi_to_unsigned_schar_t mk_lang_bi_uchar_t
#define mk_lang_bi_to_unsigned_ushort_t mk_lang_bi_ushort_t
Expand All @@ -70,6 +78,7 @@
#define mk_lang_bi_to_unsigned_ssize_t mk_lang_bi_usize_t

#define mk_lang_bi_to_unsigned_prefix_pchar_t uchar
#define mk_lang_bi_to_unsigned_prefix_wchar_t ushort
#define mk_lang_bi_to_unsigned_prefix_uchar_t uchar
#define mk_lang_bi_to_unsigned_prefix_schar_t uchar
#define mk_lang_bi_to_unsigned_prefix_ushort_t ushort
Expand Down
2 changes: 2 additions & 0 deletions mk_clib/src/mk_lang_bi_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mk_lang_jumbo void mk_lang_bi_info_print_sizes(void) mk_lang_noexcept
printf("mk_lang_charbit == %d\n", ((int)(mk_lang_charbit)));
printf("\n");
printf("sizeof(mk_lang_bi_pchar_t) == %d\n", ((int)(sizeof(mk_lang_bi_pchar_t))));
printf("sizeof(mk_lang_bi_wchar_t) == %d\n", ((int)(sizeof(mk_lang_bi_wchar_t))));
printf("sizeof(mk_lang_bi_uchar_t) == %d\n", ((int)(sizeof(mk_lang_bi_uchar_t))));
printf("sizeof(mk_lang_bi_schar_t) == %d\n", ((int)(sizeof(mk_lang_bi_schar_t))));
printf("sizeof(mk_lang_bi_ushort_t) == %d\n", ((int)(sizeof(mk_lang_bi_ushort_t))));
Expand All @@ -34,6 +35,7 @@ mk_lang_jumbo void mk_lang_bi_info_print_sizes(void) mk_lang_noexcept
printf("sizeof(mk_lang_bi_ssize_t) == %d\n", ((int)(sizeof(mk_lang_bi_ssize_t))));
printf("\n");
printf("alignof(mk_lang_bi_pchar_t) == %d\n", ((int)(mk_lang_alignof(mk_lang_bi_pchar_t))));
printf("alignof(mk_lang_bi_wchar_t) == %d\n", ((int)(mk_lang_alignof(mk_lang_bi_wchar_t))));
printf("alignof(mk_lang_bi_uchar_t) == %d\n", ((int)(mk_lang_alignof(mk_lang_bi_uchar_t))));
printf("alignof(mk_lang_bi_schar_t) == %d\n", ((int)(mk_lang_alignof(mk_lang_bi_schar_t))));
printf("alignof(mk_lang_bi_ushort_t) == %d\n", ((int)(mk_lang_alignof(mk_lang_bi_ushort_t))));
Expand Down
2 changes: 2 additions & 0 deletions mk_clib/src/mk_lang_bi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mk_lang_jumbo void mk_lang_bi_test(void) mk_lang_noexcept
mk_lang_static_assert(sizeof(mk_lang_bi_sintptr_t) == sizeof(void*));

mk_lang_static_assert(sizeof(mk_lang_bi_to_unsigned_pchar_t) == sizeof(mk_lang_bi_pchar_t));
mk_lang_static_assert(sizeof(mk_lang_bi_to_unsigned_wchar_t) == sizeof(mk_lang_bi_wchar_t));
mk_lang_static_assert(sizeof(mk_lang_bi_to_unsigned_uchar_t) == sizeof(mk_lang_bi_uchar_t));
mk_lang_static_assert(sizeof(mk_lang_bi_to_unsigned_schar_t) == sizeof(mk_lang_bi_schar_t));
mk_lang_static_assert(sizeof(mk_lang_bi_to_unsigned_ushort_t) == sizeof(mk_lang_bi_ushort_t));
Expand All @@ -32,6 +33,7 @@ mk_lang_jumbo void mk_lang_bi_test(void) mk_lang_noexcept
mk_lang_static_assert(sizeof(mk_lang_bi_to_unsigned_ssize_t) == sizeof(mk_lang_bi_ssize_t));

mk_lang_static_assert(sizeof(mk_lang_bi_pchar_t*) == sizeof(void*));
mk_lang_static_assert(sizeof(mk_lang_bi_wchar_t*) == sizeof(void*));
mk_lang_static_assert(sizeof(mk_lang_bi_uchar_t*) == sizeof(void*));
mk_lang_static_assert(sizeof(mk_lang_bi_schar_t*) == sizeof(void*));
mk_lang_static_assert(sizeof(mk_lang_bi_ushort_t*) == sizeof(void*));
Expand Down
6 changes: 6 additions & 0 deletions mk_clib/src/mk_lang_sizeof.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#define mk_lang_sizeof_bi_uchar_t mk_lang_sizeof_bi_pchar_t
#define mk_lang_sizeof_bi_schar_t mk_lang_sizeof_bi_pchar_t

#if defined __SIZEOF_WCHAR_T__
#define mk_lang_sizeof_bi_wchar_t __SIZEOF_WCHAR_T__
#else
#define mk_lang_sizeof_bi_wchar_t 2
#endif

#define mk_lang_sizeof_bi_ushort_t 2
#define mk_lang_sizeof_bi_sshort_t mk_lang_sizeof_bi_ushort_t

Expand Down
1 change: 1 addition & 0 deletions mk_clib/src/mk_lang_sizeof_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
mk_lang_jumbo void mk_lang_sizeof_test(void) mk_lang_noexcept
{
mk_lang_static_assert(mk_lang_sizeof_bi_pchar_t == sizeof(mk_lang_bi_pchar_t));
mk_lang_static_assert(mk_lang_sizeof_bi_wchar_t == sizeof(mk_lang_bi_wchar_t));
mk_lang_static_assert(mk_lang_sizeof_bi_uchar_t == sizeof(mk_lang_bi_uchar_t));
mk_lang_static_assert(mk_lang_sizeof_bi_schar_t == sizeof(mk_lang_bi_schar_t));
mk_lang_static_assert(mk_lang_sizeof_bi_ushort_t == sizeof(mk_lang_bi_ushort_t));
Expand Down

0 comments on commit b1ca158

Please sign in to comment.