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,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_C11_H_
#define COSMOPOLITAN_DSP_CORE_C11_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
/**
* Fixed-point 8-bit rounded mean kernel.
@ -17,5 +16,4 @@ __funline unsigned char C11(unsigned char al, unsigned char bl) {
return al;
}
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_C11_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_C121_H_
#define COSMOPOLITAN_DSP_CORE_C121_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
__funline unsigned char C121(unsigned char al, unsigned char bl,
@ -16,5 +15,4 @@ __funline unsigned char C121(unsigned char al, unsigned char bl,
}
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_C121_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_C121S_H_
#define COSMOPOLITAN_DSP_CORE_C121S_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
__funline signed char C121S(signed char al, signed char bl, signed char cl) {
short ax;
@ -13,5 +12,4 @@ __funline signed char C121S(signed char al, signed char bl, signed char cl) {
return ax;
}
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_C121S_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_C1331_H_
#define COSMOPOLITAN_DSP_CORE_C1331_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
/**
* Byte sized kernel for resampling memory in half.
@ -24,5 +23,4 @@ __funline unsigned char C1331(unsigned char al, unsigned char bl,
return al;
}
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_C1331_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_C1331S_H_
#define COSMOPOLITAN_DSP_CORE_C1331S_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
/**
* Byte sized kernel for resampling difference samples in half.
@ -22,5 +21,4 @@ __funline signed char C1331S(signed char al, signed char bl, signed char cl,
return ax;
}
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_C1331S_H_ */

View file

@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_DSP_CORE_C161_H_
#define COSMOPOLITAN_DSP_CORE_C161_H_
#include "libc/macros.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#define EXTRA_SHARP 2
@ -28,5 +27,4 @@ __funline unsigned char C161(unsigned char al, unsigned char bl,
return MIN(255, MAX(0, ax));
}
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_C161_H_ */

View file

@ -2,7 +2,6 @@
#define COSMOPOLITAN_DSP_CORE_C161S_H_
#include "dsp/core/c161.h"
#include "libc/macros.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
__funline signed char C161S(signed char al, signed char bl, signed char cl) {
short ax, bx, cx;
@ -20,5 +19,4 @@ __funline signed char C161S(signed char al, signed char bl, signed char cl) {
return al;
}
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_C161S_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_C331_H_
#define COSMOPOLITAN_DSP_CORE_C331_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/**
@ -25,5 +24,4 @@ __funline unsigned char C331(unsigned char al, unsigned char bl,
}
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_C331_H_ */

View file

@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_DSP_CORE_GAMMA_H_
#define COSMOPOLITAN_DSP_CORE_GAMMA_H_
#include "libc/math.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#define COMPANDLUMA(X, ...) COMPANDLUMA_(X, __VA_ARGS__)
#define COMPANDLUMA_(X, K1, K2, K3, K4) \
@ -19,5 +18,4 @@
#define COMPANDLUMA_BT1886(X) COMPANDLUMA(X, COMPANDLUMA_BT1886_MAGNUM)
#define UNCOMPANDLUMA_BT1886(X) UNCOMPANDLUMA(X, COMPANDLUMA_BT1886_MAGNUM)
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_GAMMA_H_ */

View file

@ -1,12 +1,10 @@
#ifndef COSMOPOLITAN_DSP_CORE_HALF_H_
#define COSMOPOLITAN_DSP_CORE_HALF_H_
#include "libc/macros.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
/**
* Divides integer in half w/ rounding.
*/
#define HALF(X) (((X) + 1) / 2)
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_HALF_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_ILLUMINANT_H_
#define COSMOPOLITAN_DSP_CORE_ILLUMINANT_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const double kBradford[3][3];
@ -27,5 +26,4 @@ void *GetChromaticAdaptationMatrix(double[3][3], const double[3],
const double[3]);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_ILLUMINANT_H_ */

View file

@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_DSP_CORE_ITUROUND_H_
#define COSMOPOLITAN_DSP_CORE_ITUROUND_H_
#include "libc/math.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
/**
* An ITU recommended rounding function.
@ -19,5 +18,4 @@ __funline int ituroundf(float x) {
return floorf(x + .5f);
}
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_ITUROUND_H_ */

View file

@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_DSP_CORE_KS8_H_
#define COSMOPOLITAN_DSP_CORE_KS8_H_
#include "libc/macros.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
/**
* Performs 16-bit scaled rounded madd w/ eight coefficients or fewer.
@ -43,5 +42,4 @@
x1; \
})
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_KS8_H_ */

View file

@ -2,7 +2,6 @@
#define COSMOPOLITAN_DSP_CORE_KSS8_H_
#include "libc/limits.h"
#include "libc/macros.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
/**
* Performs 16-bit scaled rounded saturated madd w/ eight coefficients or fewer.
@ -39,5 +38,4 @@
x1; \
})
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_KSS8_H_ */

View file

@ -3,7 +3,6 @@
#include "libc/limits.h"
#include "libc/macros.internal.h"
#include "libc/math.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
/**
* @fileoverview Fixed point arithmetic macros.
@ -23,5 +22,4 @@ long GetIntegerCoefficients(long[static 6], const double[static 6], long, long,
long GetIntegerCoefficients8(long[static 8], const double[static 8], long, long,
long);
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_Q_H_ */

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "dsp/core/core.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/limits.h"

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_TWIXT8_H_
#define COSMOPOLITAN_DSP_CORE_TWIXT8_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/**
@ -19,5 +18,4 @@ __funline unsigned char twixt8(unsigned char al, unsigned char bl,
}
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_TWIXT8_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_MPEG_BLOCKSET_H_
#define COSMOPOLITAN_DSP_MPEG_BLOCKSET_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#define PLM_BLOCK_SET(DEST, DEST_INDEX, DEST_WIDTH, SOURCE_INDEX, \
SOURCE_WIDTH, BLOCK_SIZE, OP) \
@ -18,5 +17,4 @@
} \
} while (false)
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_MPEG_BLOCKSET_H_ */

View file

@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_DSP_MPEG_BUFFER_H_
#define COSMOPOLITAN_DSP_MPEG_BUFFER_H_
#include "dsp/mpeg/mpeg.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct FILE;
@ -159,5 +158,4 @@ forceinline uint16_t plm_buffer_read_vlc_uint(plm_buffer_t *self,
}
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_MPEG_BUFFER_H_ */

View file

@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_DSP_MPEG_DEMUX_H_
#define COSMOPOLITAN_DSP_MPEG_DEMUX_H_
#include "dsp/mpeg/mpeg.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#define START_PACK 0xBA
@ -27,5 +26,4 @@ plm_packet_t *plm_demux_decode_packet(plm_demux_t *self, int start_code);
plm_packet_t *plm_demux_get_packet(plm_demux_t *self);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_MPEG_DEMUX_H_ */

View file

@ -1,10 +1,8 @@
#ifndef COSMOPOLITAN_DSP_MPEG_IDCT_H_
#define COSMOPOLITAN_DSP_MPEG_IDCT_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
void plm_video_idct(int *);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_MPEG_IDCT_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_MPEG_MPEG_H_
#define COSMOPOLITAN_DSP_MPEG_MPEG_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct FILE;
@ -446,5 +445,4 @@ plm_samples_t *plm_audio_decode(plm_audio_t *self);
extern long plmpegdecode_latency_;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_MPEG_MPEG_H_ */

View file

@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_DSP_MPEG_VIDEO_H_
#define COSMOPOLITAN_DSP_MPEG_VIDEO_H_
#include "dsp/mpeg/mpeg.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
typedef struct {
@ -58,5 +57,4 @@ void plm_video_process_macroblock_16(plm_video_t *, uint8_t *restrict,
uint8_t *restrict, int, int, bool);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_MPEG_VIDEO_H_ */

View file

@ -1,11 +1,9 @@
#ifndef COSMOPOLITAN_DSP_SCALE_CDECIMATE2XUINT8X8_H_
#define COSMOPOLITAN_DSP_SCALE_CDECIMATE2XUINT8X8_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
void *cDecimate2xUint8x8(unsigned long n, unsigned char[n],
const signed char[8]);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_SCALE_CDECIMATE2XUINT8X8_H_ */

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_SCALE_SCALE_H_
#define COSMOPOLITAN_DSP_SCALE_SCALE_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern long gyarados_latency_;
@ -33,5 +32,4 @@ void *EzGyarados(long, long, long, void *, long, long, long, const void *, long,
long, long, long, long, long, double, double, double, double);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_SCALE_SCALE_H_ */

View file

@ -3,7 +3,6 @@
#include "dsp/tty/quant.h"
#include "dsp/tty/ttyrgb.h"
#include "third_party/intel/xmmintrin.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct TtyRgb rgb2tty24f_(ttyrgb_m128);
@ -30,5 +29,4 @@ char *setbgfg24_(char *, struct TtyRgb, struct TtyRgb);
struct TtyRgb rgb2ansi8_(int, int, int);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_TTY_INTERNAL_H_ */

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "dsp/tty/itoa8.h"
#include "libc/intrin/bits.h"
#include "libc/str/str.h"
struct Itoa8 kItoa8;

View file

@ -1,7 +1,6 @@
#ifndef COSMOPOLITAN_DSP_TTY_ITOA8_H_
#define COSMOPOLITAN_DSP_TTY_ITOA8_H_
#include "libc/str/str.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct Itoa8 {
@ -17,5 +16,4 @@ forceinline char *itoa8(char *p, uint8_t c) {
}
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_TTY_ITOA8_H_ */

View file

@ -2,10 +2,8 @@
#define DSP_TTY_QUANT_H_
#include "dsp/tty/ttyrgb.h"
#include "libc/assert.h"
#include "libc/intrin/bits.h"
#include "libc/limits.h"
#include "libc/str/str.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#define TL 0
@ -90,5 +88,4 @@ forceinline bool ttyeq(struct TtyRgb x, struct TtyRgb y) {
}
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* DSP_TTY_QUANT_H_ */

View file

@ -3,7 +3,6 @@
#define kTtyIdScreen 83
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct FILE;
@ -55,5 +54,4 @@ void ttyhisto(uint32_t[hasatleast 256], uint8_t[hasatleast 256],
const uint8_t *, const uint8_t *, size_t);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_TTY_TTY_H_ */

View file

@ -22,7 +22,6 @@
#include "dsp/tty/ttyrgb.h"
#include "dsp/tty/windex.h"
#include "libc/assert.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/limits.h"
#include "libc/log/check.h"

View file

@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_TTY_RGB_H_
#define COSMOPOLITAN_DSP_TTY_RGB_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct TtyRgb {
@ -8,5 +7,4 @@ struct TtyRgb {
};
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_TTY_RGB_H_ */

View file

@ -1,10 +1,8 @@
#ifndef COSMOPOLITAN_DSP_TTY_WINDEX_H_
#define COSMOPOLITAN_DSP_TTY_WINDEX_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern unsigned (*windex)(uint16_t *, size_t);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_TTY_WINDEX_H_ */

View file

@ -1,10 +1,8 @@
#ifndef COSMOPOLITAN_DSP_TTY_XTERMNAME_H_
#define COSMOPOLITAN_DSP_TTY_XTERMNAME_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const char kXtermName[];
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_TTY_XTERMNAME_H_ */