Skip to content

Commit

Permalink
Reduce header complexity
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jart committed Nov 28, 2023
1 parent 96f979d commit fa20edc
Show file tree
Hide file tree
Showing 3,057 changed files with 410 additions and 4,398 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ o/$(MODE): \
o/$(MODE)/examples \
o/$(MODE)/third_party

.PHONY: o/$(MODE)/.
o/$(MODE)/.: o/$(MODE)

# check if we're using o//third_party/make/make.com
# we added sandboxing to guarantee cosmo's makefile is hermetic
# it also shaves away 200ms of startup latency with native $(uniq)
Expand Down
2 changes: 0 additions & 2 deletions ape/BUILD.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ o/$(MODE)/ape: $(APE)
o/$(MODE)/ape/aarch64.lds: \
ape/aarch64.lds \
libc/zip.internal.h \
libc/intrin/bits.h \
libc/thread/tls.h \
libc/calls/struct/timespec.h \
libc/macros.internal.h \
Expand Down Expand Up @@ -274,7 +273,6 @@ o/$(MODE)/ape/ape.lds: \
ape/macros.internal.h \
ape/relocations.h \
ape/ape.internal.h \
libc/intrin/bits.h \
libc/thread/tls.h \
libc/calls/struct/timespec.h \
libc/thread/thread.h \
Expand Down
2 changes: 0 additions & 2 deletions ape/sections.internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_APE_SECTIONS_INTERNAL_H_
#define COSMOPOLITAN_APE_SECTIONS_INTERNAL_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_

extern const char __comment_start[] __attribute__((__weak__));
Expand All @@ -25,5 +24,4 @@ extern uint8_t __bss_start[] __attribute__((__weak__));
extern uint8_t __bss_end[] __attribute__((__weak__));

COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_APE_SECTIONS_INTERNAL_H_ */
2 changes: 0 additions & 2 deletions dsp/core/c11.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/c121.h
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/c121s.h
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/c1331.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/c1331s.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/c161.h
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/c161s.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/c331.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_C331_H_
#define COSMOPOLITAN_DSP_CORE_C331_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_

/**
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/gamma.h
Original file line number Diff line number Diff line change
@@ -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) \
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/half.h
Original file line number Diff line number Diff line change
@@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/illumination.h
Original file line number Diff line number Diff line change
@@ -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];
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/core/ituround.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -19,5 +18,4 @@ __funline int ituroundf(float x) {
return floorf(x + .5f);
}

#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_ITUROUND_H_ */
2 changes: 0 additions & 2 deletions dsp/core/ks8.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -43,5 +42,4 @@
x1; \
})

#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_KS8_H_ */
2 changes: 0 additions & 2 deletions dsp/core/kss8.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -39,5 +38,4 @@
x1; \
})

#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_CORE_KSS8_H_ */
2 changes: 0 additions & 2 deletions dsp/core/q.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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_ */
1 change: 0 additions & 1 deletion dsp/core/scalevolume.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 0 additions & 2 deletions dsp/core/twixt8.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_DSP_CORE_TWIXT8_H_
#define COSMOPOLITAN_DSP_CORE_TWIXT8_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_

/**
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/mpeg/blockset.h
Original file line number Diff line number Diff line change
@@ -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) \
Expand All @@ -18,5 +17,4 @@
} \
} while (false)

#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_DSP_MPEG_BLOCKSET_H_ */
2 changes: 0 additions & 2 deletions dsp/mpeg/buffer.h
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/mpeg/demux.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/mpeg/idct.h
Original file line number Diff line number Diff line change
@@ -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_ */
2 changes: 0 additions & 2 deletions dsp/mpeg/mpeg.h
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/mpeg/video.h
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/scale/cdecimate2xuint8x8.h
Original file line number Diff line number Diff line change
@@ -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_ */
2 changes: 0 additions & 2 deletions dsp/scale/scale.h
Original file line number Diff line number Diff line change
@@ -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_;
Expand Down Expand Up @@ -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_ */
2 changes: 0 additions & 2 deletions dsp/tty/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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_ */
1 change: 0 additions & 1 deletion dsp/tty/itoa8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit fa20edc

Please sign in to comment.