Reduce header complexity

- Remove most __ASSEMBLER__ __LINKER__ ifdefs
- Rename libc/intrin/bits.h to libc/serialize.h
- Block pthread cancelation in fchmodat() polyfill
- Remove `clang-format off` statements in third_party
This commit is contained in:
Justine Tunney 2023-11-28 14:24:28 -08:00
parent 96f979dfc5
commit fa20edc44d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
3057 changed files with 410 additions and 4398 deletions

View file

@ -1,8 +1,6 @@
// clang-format off
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi
*/
// clang-format off
/* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2011, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h

View file

@ -1,7 +1,6 @@
asm(".ident\t\"\\n\\n\
Chromium (BSD-3 License)\\n\
Copyright 2017 The Chromium Authors\"");
// clang-format off
/* adler32_simd.c
*

View file

@ -1,4 +1,3 @@
// clang-format off
/* chunkcopy.h -- fast chunk copy and set operations
* Copyright (C) 2017 ARM, Inc.
* Copyright 2017 The Chromium Authors

View file

@ -8,7 +8,6 @@
#include "third_party/zlib/internal.h"
#include "third_party/zlib/macros.internal.h"
#include "third_party/zlib/zlib.h"
// clang-format off
/* @(#) $Id$ */

View file

@ -2,7 +2,6 @@
#define COSMOPOLITAN_THIRD_PARTY_ZLIB_CPU_FEATURES_H_
#include "libc/nexgen32e/x86feature.h"
#include "third_party/zlib/zconf.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#ifdef __x86_64__
@ -28,5 +27,4 @@ void cpu_check_features(void);
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_CPU_FEATURES_H_ */

View file

@ -13,7 +13,6 @@
#include "third_party/zlib/deflate.internal.h"
#include "third_party/zlib/internal.h"
#include "third_party/zlib/macros.internal.h"
// clang-format off
/* @(#) $Id$ */

View file

@ -1,4 +1,3 @@
// clang-format off
/* crc32.inc -- tables for rapid CRC calculation
* Generated automatically by crc32.c

View file

@ -8,7 +8,6 @@
asm(".ident\t\"\\n\\n\
Chromium (BSD-3 License)\\n\
Copyright 2017 The Chromium Authors\"");
// clang-format off
#include "third_party/intel/x86gprintrin.internal.h"
#include "third_party/zlib/crc32_simd.internal.h"

View file

@ -3,9 +3,7 @@
#include "third_party/zlib/deflate.internal.h"
#include "third_party/zlib/zconf.h"
#include "third_party/zlib/zutil.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
// clang-format off
/*
* crc32_sse42_simd_(): compute the crc32 of the buffer, where the buffer
@ -53,5 +51,4 @@ uint32_t ZLIB_INTERNAL armv8_crc32_pmull_little(const unsigned char* buf,
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_CRC32_SIMD_INTERNAL_H_ */

View file

@ -7,7 +7,6 @@
#include "third_party/intel/immintrin.internal.h"
#include "third_party/intel/wmmintrin.internal.h"
#include "third_party/zlib/deflate.internal.h"
// clang-format off
/*
* Compute the CRC32 using a parallelized folding approach with the PCLMULQDQ

View file

@ -16,7 +16,6 @@ asm(".ident\t\"\\n\\n\
zlib 1.2.13 (zlib License)\\n\
Copyright 1995-2022 Jean-loup Gailly and Mark Adler\\n\
Invented 1990 Phillip Walter Katz\"");
// clang-format off
/*
* ALGORITHM

View file

@ -2,7 +2,6 @@
#define COSMOPOLITAN_THIRD_PARTY_ZLIB_DEFLATE_INTERNAL_H_
#include "third_party/zlib/macros.internal.h"
#include "third_party/zlib/zutil.internal.h"
/* clang-format off */
#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
@ -40,7 +39,6 @@
#define FINISH_STATE 666 /* stream complete */
/* Stream status */
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/* define NO_GZIP when compiling if you want to disable gzip header and
@ -349,5 +347,4 @@ void ZLIB_INTERNAL crc_fold_copy(deflate_state* const s,
unsigned ZLIB_INTERNAL crc_fold_512to32(deflate_state* const s);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_DEFLATE_INTERNAL_H_ */

View file

@ -7,7 +7,6 @@
*/
#include "third_party/zlib/gz/gzguts.inc"
#include "third_party/zlib/macros.internal.h"
// clang-format off
/* gzclose() is in a separate file so that it is linked in only if it is used.
That way the other gzclose functions can be used instead to avoid linking in

View file

@ -4,7 +4,6 @@
#include "third_party/zlib/macros.internal.h"
#include "third_party/zlib/zlib.h"
#include "third_party/zlib/zutil.internal.h"
// clang-format off
/* gzguts.h -- zlib internal header definitions for gz* operations
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler

View file

@ -14,7 +14,6 @@
#include "third_party/zlib/gz/gzguts.inc"
#include "third_party/zlib/zlib.h"
#include "third_party/zlib/zutil.internal.h"
// clang-format off
#define LSEEK lseek

View file

@ -12,7 +12,6 @@
#include "libc/str/str.h"
#include "third_party/zlib/gz/gzguts.inc"
#include "third_party/zlib/zlib.h"
// clang-format off
/* Local functions */
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));

View file

@ -9,7 +9,6 @@
#include "libc/mem/mem.h"
#include "libc/stdio/stdio.h"
#include "third_party/zlib/gz/gzguts.inc"
// clang-format off
/* Local functions */
local int gz_init OF((gz_statep));

View file

@ -11,7 +11,6 @@
#include "third_party/zlib/internal.h"
#include "third_party/zlib/macros.internal.h"
#include "third_party/zlib/zutil.internal.h"
// clang-format off
/*
This code is largely copied from inflate.c. Normally either infback.o or

View file

@ -5,7 +5,6 @@
* Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
// clang-format off
#include "third_party/zlib/zutil.internal.h"
#include "third_party/zlib/inftrees.internal.h"

View file

@ -1,9 +1,7 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_ZLIB_INFFAST_INTERNAL_H_
#define COSMOPOLITAN_THIRD_PARTY_ZLIB_INFFAST_INTERNAL_H_
#include "third_party/zlib/zlib.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/* clang-format off */
/* INFLATE_FAST_MIN_INPUT: the minimum number of input bytes needed so that
we can safely call inflate_fast() with only one up-front bounds check. One
@ -23,5 +21,4 @@ COSMOPOLITAN_C_START_
void inflate_fast(z_streamp strm, unsigned start);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_INFFAST_INTERNAL_H_ */

View file

@ -10,7 +10,6 @@
asm(".ident\t\"\\n\\n\
Chromium (BSD-3 License)\\n\
Copyright 2017 The Chromium Authors\"");
// clang-format off
#include "third_party/zlib/zutil.internal.h"
#include "third_party/zlib/inftrees.internal.h"

View file

@ -1,4 +1,3 @@
// clang-format off
/* inffixed.h -- table for decoding fixed codes
* Generated automatically by makefixed().

View file

@ -10,7 +10,6 @@ asm(".ident\t\"\\n\\n\
zlib 1.2.13 (zlib License)\\n\
Copyright 1995-2022 Jean-loup Gailly and Mark Adler\\n\
Invented 1990 Phillip Walter Katz\"");
// clang-format off
/*
* Change history:

View file

@ -3,9 +3,7 @@
#include "third_party/zlib/inftrees.internal.h"
#include "third_party/zlib/macros.internal.h"
#include "third_party/zlib/zlib.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/* clang-format off */
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
@ -130,5 +128,4 @@ struct inflate_state {
};
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_INFLATE_H_ */

View file

@ -1,4 +1,3 @@
// clang-format off
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi
*/
@ -13,7 +12,6 @@ asm(".ident\t\"\\n\\n\
zlib 1.2.13 (zlib License)\\n\
Copyright 1995-2022 Jean-loup Gailly and Mark Adler\\n\
Invented 1990 Phillip Walter Katz\"");
// clang-format off
#define MAXBITS 15

View file

@ -2,9 +2,7 @@
#define COSMOPOLITAN_THIRD_PARTY_ZLIB_INFTREES_INTERNAL_H_
#include "third_party/zlib/macros.internal.h"
#include "third_party/zlib/zutil.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/* clang-format off */
/* inftrees.h -- header to use inftrees.c
* Copyright (C) 1995-2005, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
@ -69,5 +67,4 @@ int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
unsigned FAR *bits, unsigned short FAR *work));
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_INFTREES_INTERNAL_H_ */

View file

@ -1,4 +1,3 @@
// clang-format off
/* insert_string.h
*
* Copyright 2019 The Chromium Authors
@ -19,7 +18,6 @@
#include "third_party/zlib/cpu_features.internal.h"
// clang-format off
#if defined(CRC32_SIMD_SSE42_PCLMUL)
#include "third_party/intel/smmintrin.internal.h" /* Required to make MSVC bot build pass. */

View file

@ -7,7 +7,6 @@
#define Z_CRC32_SSE42_MINIMUM_LENGTH 64
#define Z_CRC32_SSE42_CHUNKSIZE_MASK 15
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#define zmemzero bzero
@ -27,5 +26,4 @@ void *zcalloc(void *, uInt, uInt);
void zcfree(void *, void *);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_INTERNAL_H_ */

View file

@ -1,8 +1,6 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_ZLIB_MACROS_INTERNAL_H_
#define COSMOPOLITAN_THIRD_PARTY_ZLIB_MACROS_INTERNAL_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/* clang-format off */
#ifndef OF /* function prototypes */
# ifdef STDC
@ -100,5 +98,4 @@ COSMOPOLITAN_C_START_
#define z_off_t long
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_MACROS_INTERNAL_H_ */

View file

@ -1,4 +1,3 @@
// clang-format off
/* slide_hash_simd.h
*
* Copyright 2022 The Chromium Authors

View file

@ -11,7 +11,6 @@
#include "libc/temp.h"
#include "libc/str/str.h"
#include "third_party/zlib/deflate.internal.h"
// clang-format off
/*
* ALGORITHM

View file

@ -1,4 +1,3 @@
// clang-format off
local const ct_data static_ltree[L_CODES+2] = {
{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},

View file

@ -9,7 +9,6 @@
#include "third_party/zlib/internal.h"
#include "third_party/zlib/macros.internal.h"
#include "third_party/zlib/zlib.h"
// clang-format off
/* @(#) $Id$ */

View file

@ -162,7 +162,6 @@
#define zlibCompileFlags _Cz_zlibCompileFlags
#define zlibVersion _Cz_zlibVersion
#if !(__ASSEMBLER__ + __LINKER__ + 0)
typedef unsigned char Byte;
typedef unsigned int uInt; /* 16 bits or more */
@ -179,5 +178,4 @@ typedef uint32_t z_crc_t;
typedef int64_t z_off64_t;
typedef size_t z_size_t;
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_ZCONF_H_ */

View file

@ -137,7 +137,6 @@
/* The deflate compression method (the only one supported in this version) */
#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size);
@ -1751,5 +1750,4 @@ int gzvprintf(gzFile file, const char *format, va_list va);
void inflate_fast_chunk(z_streamp strm, unsigned start);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_ZLIB_ZLIB_H_ */

View file

@ -10,7 +10,6 @@
#include "libc/mem/mem.h"
#include "third_party/zlib/internal.h"
#include "third_party/zlib/zutil.internal.h"
// clang-format off
#pragma GCC diagnostic ignored "-Wimplicit-int"

View file

@ -28,7 +28,6 @@
#define HAVE_MEMCPY
#endif
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#ifndef local
@ -135,5 +134,4 @@ typedef unsigned long ulg;
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* ZUTIL_H */