diff options
Diffstat (limited to 'libgfortran/intrinsics/string_intrinsics.c')
-rw-r--r-- | libgfortran/intrinsics/string_intrinsics.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libgfortran/intrinsics/string_intrinsics.c b/libgfortran/intrinsics/string_intrinsics.c index e2e14e0..a1d3b31 100644 --- a/libgfortran/intrinsics/string_intrinsics.c +++ b/libgfortran/intrinsics/string_intrinsics.c @@ -51,6 +51,23 @@ memset_char4 (gfc_char4_t *b, gfc_char4_t c, size_t len) return b; } +/* Compare wide character types, which are handled internally as + unsigned 4-byte integers. */ +int +memcmp_char4 (const void *a, const void *b, size_t len) +{ + const GFC_UINTEGER_4 *pa = a; + const GFC_UINTEGER_4 *pb = b; + while (len-- > 0) + { + if (*pa != *pb) + return *pa < *pb ? -1 : 1; + pa ++; + pb ++; + } + return 0; +} + /* All other functions are defined using a few generic macros in string_intrinsics_inc.c, so we avoid code duplication between the @@ -64,6 +81,8 @@ memset_char4 (gfc_char4_t *b, gfc_char4_t c, size_t len) #define SUFFIX(x) x #undef MEMSET #define MEMSET memset +#undef MEMCMP +#define MEMCMP memcmp #include "string_intrinsics_inc.c" @@ -76,6 +95,8 @@ memset_char4 (gfc_char4_t *b, gfc_char4_t c, size_t len) #define SUFFIX(x) x ## _char4 #undef MEMSET #define MEMSET memset_char4 +#undef MEMCMP +#define MEMCMP memcmp_char4 #include "string_intrinsics_inc.c" |