Make more functions friendly to Address Sanitizer

This commit is contained in:
Justine Tunney 2021-02-02 03:45:31 -08:00
parent 3ab76b2312
commit cbfd4ccd1e
70 changed files with 1267 additions and 291 deletions

View file

@ -10,6 +10,7 @@ THIRD_PARTY_COMPILER_RT_A_FILES := \
$(wildcard third_party/compiler_rt/*) \
$(wildcard third_party/compiler_rt/nexgen32e/*)
THIRD_PARTY_COMPILER_RT_A_HDRS = $(filter %.h,$(THIRD_PARTY_COMPILER_RT_A_FILES))
THIRD_PARTY_COMPILER_RT_A_INCS = $(filter %.inc,$(THIRD_PARTY_COMPILER_RT_A_FILES))
THIRD_PARTY_COMPILER_RT_A_SRCS_S = $(filter %.S,$(THIRD_PARTY_COMPILER_RT_A_FILES))
THIRD_PARTY_COMPILER_RT_A_SRCS_C = $(filter %.c,$(THIRD_PARTY_COMPILER_RT_A_FILES))
@ -51,6 +52,7 @@ $(THIRD_PARTY_COMPILER_RT_A_OBJS): \
THIRD_PARTY_COMPILER_RT_LIBS = $(foreach x,$(THIRD_PARTY_COMPILER_RT_ARTIFACTS),$($(x)))
THIRD_PARTY_COMPILER_RT_SRCS = $(foreach x,$(THIRD_PARTY_COMPILER_RT_ARTIFACTS),$($(x)_SRCS))
THIRD_PARTY_COMPILER_RT_HDRS = $(foreach x,$(THIRD_PARTY_COMPILER_RT_ARTIFACTS),$($(x)_HDRS))
THIRD_PARTY_COMPILER_RT_INCS = $(foreach x,$(THIRD_PARTY_COMPILER_RT_ARTIFACTS),$($(x)_INCS))
THIRD_PARTY_COMPILER_RT_CHECKS = $(foreach x,$(THIRD_PARTY_COMPILER_RT_ARTIFACTS),$($(x)_CHECKS))
THIRD_PARTY_COMPILER_RT_OBJS = $(foreach x,$(THIRD_PARTY_COMPILER_RT_ARTIFACTS),$($(x)_OBJS))

View file

@ -8,6 +8,7 @@ THIRD_PARTY_DUKTAPE = $(THIRD_PARTY_DUKTAPE_A_DEPS) $(THIRD_PARTY_DUKTAPE_A)
THIRD_PARTY_DUKTAPE_A = o/$(MODE)/third_party/duktape/duktape.a
THIRD_PARTY_DUKTAPE_A_FILES := $(wildcard third_party/duktape/*)
THIRD_PARTY_DUKTAPE_A_HDRS = $(filter %.h,$(THIRD_PARTY_DUKTAPE_A_FILES))
THIRD_PARTY_DUKTAPE_A_INCS = $(filter %.inc,$(THIRD_PARTY_DUKTAPE_A_FILES))
THIRD_PARTY_DUKTAPE_A_SRCS_A = $(filter %.s,$(THIRD_PARTY_DUKTAPE_A_FILES))
THIRD_PARTY_DUKTAPE_A_SRCS_S = $(filter %.S,$(THIRD_PARTY_DUKTAPE_A_FILES))
THIRD_PARTY_DUKTAPE_A_SRCS_C = $(filter %.c,$(THIRD_PARTY_DUKTAPE_A_FILES))
@ -60,6 +61,7 @@ o/dbg/third_party/duktape/duk_js_executor.o: \
THIRD_PARTY_DUKTAPE_LIBS = $(foreach x,$(THIRD_PARTY_DUKTAPE_ARTIFACTS),$($(x)))
THIRD_PARTY_DUKTAPE_SRCS = $(foreach x,$(THIRD_PARTY_DUKTAPE_ARTIFACTS),$($(x)_SRCS))
THIRD_PARTY_DUKTAPE_HDRS = $(foreach x,$(THIRD_PARTY_DUKTAPE_ARTIFACTS),$($(x)_HDRS))
THIRD_PARTY_DUKTAPE_INCS = $(foreach x,$(THIRD_PARTY_DUKTAPE_ARTIFACTS),$($(x)_INCS))
THIRD_PARTY_DUKTAPE_BINS = $(foreach x,$(THIRD_PARTY_DUKTAPE_ARTIFACTS),$($(x)_BINS))
THIRD_PARTY_DUKTAPE_CHECKS = $(foreach x,$(THIRD_PARTY_DUKTAPE_ARTIFACTS),$($(x)_CHECKS))
THIRD_PARTY_DUKTAPE_OBJS = $(foreach x,$(THIRD_PARTY_DUKTAPE_ARTIFACTS),$($(x)_OBJS))

View file

@ -8,6 +8,7 @@ THIRD_PARTY_GDTOA = $(THIRD_PARTY_GDTOA_A_DEPS) $(THIRD_PARTY_GDTOA_A)
THIRD_PARTY_GDTOA_A = o/$(MODE)/third_party/gdtoa/gdtoa.a
THIRD_PARTY_GDTOA_A_FILES := $(wildcard third_party/gdtoa/*)
THIRD_PARTY_GDTOA_A_HDRS = $(filter %.h,$(THIRD_PARTY_GDTOA_A_FILES))
THIRD_PARTY_GDTOA_A_INCS = $(filter %.inc,$(THIRD_PARTY_GDTOA_A_FILES))
THIRD_PARTY_GDTOA_A_SRCS_S = $(filter %.S,$(THIRD_PARTY_GDTOA_A_FILES))
THIRD_PARTY_GDTOA_A_SRCS_C = $(filter %.c,$(THIRD_PARTY_GDTOA_A_FILES))
@ -54,6 +55,7 @@ $(THIRD_PARTY_GDTOA_A_OBJS): \
THIRD_PARTY_GDTOA_LIBS = $(foreach x,$(THIRD_PARTY_GDTOA_ARTIFACTS),$($(x)))
THIRD_PARTY_GDTOA_SRCS = $(foreach x,$(THIRD_PARTY_GDTOA_ARTIFACTS),$($(x)_SRCS))
THIRD_PARTY_GDTOA_HDRS = $(foreach x,$(THIRD_PARTY_GDTOA_ARTIFACTS),$($(x)_HDRS))
THIRD_PARTY_GDTOA_INCS = $(foreach x,$(THIRD_PARTY_GDTOA_ARTIFACTS),$($(x)_INCS))
THIRD_PARTY_GDTOA_CHECKS = $(foreach x,$(THIRD_PARTY_GDTOA_ARTIFACTS),$($(x)_CHECKS))
THIRD_PARTY_GDTOA_OBJS = $(foreach x,$(THIRD_PARTY_GDTOA_ARTIFACTS),$($(x)_OBJS))
$(THIRD_PARTY_GDTOA_OBJS): $(BUILD_FILES) third_party/gdtoa/gdtoa.mk

View file

@ -1,6 +1,12 @@
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
PKGS += THIRD_PARTY_LEMON
THIRD_PARTY_LEMON_FILES := $(wildcard third_party/lemon/*)
THIRD_PARTY_LEMON_HDRS = $(filter %.h,$(THIRD_PARTY_LEMON_FILES))
THIRD_PARTY_LEMON_INCS = $(filter %.inc,$(THIRD_PARTY_LEMON_FILES))
THIRD_PARTY_LEMON_SRCS = $(filter %.c,$(THIRD_PARTY_LEMON_FILES))
LEMON = $(MKDIR) $(@D) && ACTION="LEMON $@" build/do $(THIRD_PARTY_LEMON)
THIRD_PARTY_LEMON = o/$(MODE)/third_party/lemon/lemon.com.dbg

View file

@ -36,8 +36,8 @@
/* *************************************
* Includes
***************************************/
#include "platform.h" /* Compiler options */
#include "util.h" /* UTIL_GetFileSize, UTIL_sleep */
#include "third_party/lz4cli/platform.h" /* Compiler options */
#include "third_party/lz4cli/util.h" /* UTIL_GetFileSize, UTIL_sleep */
#include "libc/mem/mem.h" /* malloc, free */
#include "libc/str/str.h" /* memset */
#include "libc/stdio/stdio.h" /* fprintf, fopen, ftello */
@ -46,17 +46,17 @@
#include "libc/bits/initializer.internal.h"
#include "libc/runtime/runtime.h" /* assert */
#include "datagen.h" /* RDG_genBuffer */
#include "xxhash.h"
#include "third_party/lz4cli/datagen.h" /* RDG_genBuffer */
#include "third_party/lz4cli/xxhash.h"
#include "lz4.h"
#include "third_party/lz4cli/lz4.h"
#define COMPRESSOR0 LZ4_compress_local
static int LZ4_compress_local(const char* src, char* dst, int srcSize, int dstSize, int clevel) {
int const acceleration = (clevel < 0) ? -clevel + 1 : 1;
return LZ4_compress_fast(src, dst, srcSize, dstSize, acceleration);
}
#include "lz4hc.h"
#include "third_party/lz4cli/lz4hc.h"
#define COMPRESSOR1 LZ4_compress_HC
#define DEFAULTCOMPRESSOR COMPRESSOR0
#define LZ4_isError(errcode) (errcode==0)

View file

@ -27,8 +27,8 @@
/**************************************
* Includes
**************************************/
#include "platform.h" /* Compiler options, SET_BINARY_MODE */
#include "util.h" /* U32 */
#include "third_party/lz4cli/platform.h" /* Compiler options, SET_BINARY_MODE */
#include "third_party/lz4cli/util.h" /* U32 */
#include "libc/mem/mem.h" /* malloc */
#include "libc/stdio/stdio.h" /* FILE, fwrite */
#include "libc/str/str.h" /* memcpy */

View file

@ -94,7 +94,7 @@
**************************************/
#define LZ4_STATIC_LINKING_ONLY
#define LZ4_DISABLE_DEPRECATE_WARNINGS /* due to LZ4_decompress_safe_withPrefix64k */
#include "lz4.h"
#include "third_party/lz4cli/lz4.h"
/* see also "memory routines" below */

View file

@ -36,17 +36,17 @@ asm(".include \"third_party/lz4cli/COPYING\"");
/****************************
* Includes
*****************************/
#include "platform.h" /* Compiler options, IS_CONSOLE */
#include "util.h" /* UTIL_HAS_CREATEFILELIST, UTIL_createFileList */
#include "third_party/lz4cli/platform.h" /* Compiler options, IS_CONSOLE */
#include "third_party/lz4cli/util.h" /* UTIL_HAS_CREATEFILELIST, UTIL_createFileList */
#include "libc/stdio/stdio.h" /* fprintf, getchar */
#include "libc/mem/mem.h" /* exit, calloc, free */
#include "libc/str/str.h" /* strcmp, strlen */
#include "bench.h" /* BMK_benchFile, BMK_SetNbIterations, BMK_SetBlocksize, BMK_SetPause */
#include "lz4io.h" /* LZ4IO_compressFilename, LZ4IO_decompressFilename, LZ4IO_compressMultipleFilenames */
#include "lz4hc.h" /* LZ4HC_CLEVEL_MAX */
#include "third_party/lz4cli/bench.h" /* BMK_benchFile, BMK_SetNbIterations, BMK_SetBlocksize, BMK_SetPause */
#include "third_party/lz4cli/lz4io.h" /* LZ4IO_compressFilename, LZ4IO_decompressFilename, LZ4IO_compressMultipleFilenames */
#include "third_party/lz4cli/lz4hc.h" /* LZ4HC_CLEVEL_MAX */
#include "libc/runtime/runtime.h"
#include "libc/log/log.h"
#include "lz4.h" /* LZ4_VERSION_STRING */
#include "third_party/lz4cli/lz4.h" /* LZ4_VERSION_STRING */
/*****************************

View file

@ -13,6 +13,10 @@
PKGS += THIRD_PARTY_LZ4CLI
THIRD_PARTY_LZ4CLI_FILES := $(wildcard third_party/lz4cli/*)
THIRD_PARTY_LZ4CLI_SRCS = $(filter %.c,$(THIRD_PARTY_LZ4CLI_FILES))
THIRD_PARTY_LZ4CLI_HDRS = $(filter %.h,$(THIRD_PARTY_LZ4CLI_FILES))
THIRD_PARTY_LZ4CLI = \
o/$(MODE)/third_party/lz4cli/lz4cli.com

View file

@ -51,7 +51,7 @@
/*=== Dependency ===*/
#define LZ4_HC_STATIC_LINKING_ONLY
#include "lz4hc.h"
#include "third_party/lz4cli/lz4hc.h"
/*=== Common LZ4 definitions ===*/
@ -63,7 +63,7 @@
#endif
#define LZ4_COMMONDEFS_ONLY
#include "lz4.c" /* LZ4_count, constants, mem */
#include "third_party/lz4cli/lz4.c" /* LZ4_count, constants, mem */
/*=== Constants ===*/

View file

@ -41,7 +41,7 @@ extern "C" {
/* --- Dependency --- */
/* note : lz4hc requires lz4.h/lz4.c for compilation */
#include "lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */
#include "third_party/lz4cli/lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */
/* --- Useful constants --- */

View file

@ -106,7 +106,7 @@ static void XXH_free (void* p) { free(p); }
static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
#define XXH_STATIC_LINKING_ONLY
#include "xxhash.h"
#include "third_party/lz4cli/xxhash.h"
/* *************************************

View file

@ -280,7 +280,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src
#endif
# ifdef XXH_PRIVATE_API
# include "xxhash.c" /* include xxhash function bodies as `static`, for inlining */
# include "third_party/lz4cli/xxhash.c" /* include xxhash function bodies as `static`, for inlining */
# endif
#endif /* XXH_STATIC_LINKING_ONLY */

View file

@ -8,6 +8,7 @@ THIRD_PARTY_REGEX = $(THIRD_PARTY_REGEX_A_DEPS) $(THIRD_PARTY_REGEX_A)
THIRD_PARTY_REGEX_A = o/$(MODE)/third_party/regex/regex.a
THIRD_PARTY_REGEX_A_FILES := $(wildcard third_party/regex/*)
THIRD_PARTY_REGEX_A_HDRS = $(filter %.h,$(THIRD_PARTY_REGEX_A_FILES))
THIRD_PARTY_REGEX_A_INCS = $(filter %.inc,$(THIRD_PARTY_REGEX_A_FILES))
THIRD_PARTY_REGEX_A_SRCS = $(filter %.c,$(THIRD_PARTY_REGEX_A_FILES))
THIRD_PARTY_REGEX_A_OBJS = \