From c3f9f302a358183670930998d56ce8e7c49f373e Mon Sep 17 00:00:00 2001 From: seleznevae Date: Fri, 29 Nov 2019 23:40:06 +0300 Subject: [PATCH] [F] Fix compilation for tcc --- ChangeLog.md | 4 ++++ lib/fort.c | 9 ++++++--- src/fort_utils.c | 4 ++-- src/utf8.h | 5 ++++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7b3bbbd..da12e74 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,10 @@ - Fix undefined behavior due to incorrect usage of `isprint` function. +### Internal + +- Fix compilation for compilers other than gcc, clang, msvc. + ## v0.3.1 ### Bug fixes diff --git a/lib/fort.c b/lib/fort.c index d93b162..5153a33 100644 --- a/lib/fort.c +++ b/lib/fort.c @@ -436,7 +436,10 @@ extern "C" { #define utf8_restrict __restrict #define utf8_weak __inline #else -#error Non clang, non gcc, non MSVC compiler found! +#define utf8_nonnull +#define utf8_pure +#define utf8_restrict +#define utf8_weak #endif #ifdef __cplusplus @@ -3566,7 +3569,7 @@ char g_col_separator = FORT_DEFAULT_COL_SEPARATOR; * LIBFORT helpers *****************************************************************************/ -#ifndef FT_MICROSOFT_COMPILER +#if defined(FT_GCC_COMPILER) || defined(FT_CLANG_COMPILER) void *(*fort_malloc)(size_t size) = &malloc; void (*fort_free)(void *ptr) = &free; void *(*fort_calloc)(size_t nmemb, size_t size) = &calloc; @@ -3637,7 +3640,7 @@ void set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr)) || (f_malloc != NULL && f_free != NULL) /* Use custom functions */); if (f_malloc == NULL && f_free == NULL) { -#ifndef FT_MICROSOFT_COMPILER +#if defined(FT_GCC_COMPILER) || defined(FT_CLANG_COMPILER) fort_malloc = &malloc; fort_free = &free; fort_calloc = &calloc; diff --git a/src/fort_utils.c b/src/fort_utils.c index 1feb5b7..53a6005 100644 --- a/src/fort_utils.c +++ b/src/fort_utils.c @@ -14,7 +14,7 @@ char g_col_separator = FORT_DEFAULT_COL_SEPARATOR; * LIBFORT helpers *****************************************************************************/ -#ifndef FT_MICROSOFT_COMPILER +#if defined(FT_GCC_COMPILER) || defined(FT_CLANG_COMPILER) void *(*fort_malloc)(size_t size) = &malloc; void (*fort_free)(void *ptr) = &free; void *(*fort_calloc)(size_t nmemb, size_t size) = &calloc; @@ -85,7 +85,7 @@ void set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr)) || (f_malloc != NULL && f_free != NULL) /* Use custom functions */); if (f_malloc == NULL && f_free == NULL) { -#ifndef FT_MICROSOFT_COMPILER +#if defined(FT_GCC_COMPILER) || defined(FT_CLANG_COMPILER) fort_malloc = &malloc; fort_free = &free; fort_calloc = &calloc; diff --git a/src/utf8.h b/src/utf8.h index be0932e..005e427 100644 --- a/src/utf8.h +++ b/src/utf8.h @@ -71,7 +71,10 @@ extern "C" { #define utf8_restrict __restrict #define utf8_weak __inline #else -#error Non clang, non gcc, non MSVC compiler found! +#define utf8_nonnull +#define utf8_pure +#define utf8_restrict +#define utf8_weak #endif #ifdef __cplusplus