cb424d7448
verify-patch-sanity.py validates every active recipe .patch has internally- consistent hunk line counts — catching the 'malformed patch at line N' failure at commit/CI/preflight time instead of hours into a cook. This cycle hit that class three times (qtwaylandscanner, sddm, xwayland), each only discovered when cookbook tried to apply the patch. Running it across the repo found 29 latent malformed patches (validated against GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22'). They were harmless only because they sit in vendored recipes (baked, not re- applied) — but would fail on any version-bump re-derivation. --fix recounts the hunk headers (body untouched) and repaired all 29. Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test (test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats (empty placeholders, bare-@@ git hunks).
117 lines
3.4 KiB
C
117 lines
3.4 KiB
C
// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
|
|
// RUN: -triple x86_64--windows -Oz -emit-llvm -target-feature +cx16 %s -o - \
|
|
// RUN: | FileCheck %s --check-prefixes=CHECK
|
|
|
|
// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
|
|
// RUN: -triple aarch64--windows -Oz -emit-llvm %s -o - \
|
|
// RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-AARCH64
|
|
|
|
// Ensure that we emit _Interlocked atomic operations specifying natural
|
|
// alignment, even when clang's usual alignment derivation would result in a
|
|
// lower alignment value.
|
|
|
|
// intrin.h needs size_t, but -ffreestanding prevents us from getting it from
|
|
// stddef.h. Work around it with this typedef.
|
|
typedef __SIZE_TYPE__ size_t;
|
|
|
|
#include <intrin.h>
|
|
|
|
#pragma pack(1)
|
|
typedef struct {
|
|
char a;
|
|
short b;
|
|
long c;
|
|
long long d;
|
|
void *p;
|
|
} X;
|
|
|
|
_Static_assert(sizeof(X) == 23, "");
|
|
_Static_assert(__alignof__(X) == 1, "");
|
|
|
|
// CHECK-LABEL: @test_InterlockedExchangePointer(
|
|
// CHECK: atomicrmw {{.*}} align 8
|
|
void *test_InterlockedExchangePointer(X *x) {
|
|
return _InterlockedExchangePointer(&x->p, 0);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedExchange8(
|
|
// CHECK: atomicrmw {{.*}} align 1
|
|
char test_InterlockedExchange8(X *x) {
|
|
return _InterlockedExchange8(&x->a, 0);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedExchange16(
|
|
// CHECK: atomicrmw {{.*}} align 2
|
|
short test_InterlockedExchange16(X *x) {
|
|
return _InterlockedExchange16(&x->b, 0);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedExchange(
|
|
// CHECK: atomicrmw {{.*}} align 4
|
|
long test_InterlockedExchange(X *x) {
|
|
return _InterlockedExchange(&x->c, 0);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedExchange64(
|
|
// CHECK: atomicrmw {{.*}} align 8
|
|
long long test_InterlockedExchange64(X *x) {
|
|
return _InterlockedExchange64(&x->d, 0);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedIncrement(
|
|
// CHECK: atomicrmw {{.*}} align 4
|
|
long test_InterlockedIncrement(X *x) {
|
|
return _InterlockedIncrement(&x->c);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedDecrement16(
|
|
// CHECK: atomicrmw {{.*}} align 2
|
|
short test_InterlockedDecrement16(X *x) {
|
|
return _InterlockedDecrement16(&x->b);
|
|
}
|
|
|
|
|
|
// CHECK-LABEL: @test_InterlockedCompareExchangePointer(
|
|
// CHECK: cmpxchg {{.*}} align 8
|
|
void *test_InterlockedCompareExchangePointer(X *x) {
|
|
return _InterlockedCompareExchangePointer(&x->p, 0, 0);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedCompareExchange8(
|
|
// CHECK: cmpxchg {{.*}} align 1
|
|
char test_InterlockedCompareExchange8(X *x) {
|
|
return _InterlockedCompareExchange8(&x->a, 0, 0);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedCompareExchange16(
|
|
// CHECK: cmpxchg {{.*}} align 2
|
|
short test_InterlockedCompareExchange16(X *x) {
|
|
return _InterlockedCompareExchange16(&x->b, 0, 0);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedCompareExchange(
|
|
// CHECK: cmpxchg {{.*}} align 4
|
|
long test_InterlockedCompareExchange(X *x) {
|
|
return _InterlockedCompareExchange(&x->c, 0, 0);
|
|
}
|
|
|
|
// CHECK-LABEL: @test_InterlockedCompareExchange64(
|
|
// CHECK: cmpxchg {{.*}} align 8
|
|
long long test_InterlockedCompareExchange64(X *x) {
|
|
return _InterlockedCompareExchange64(&x->d, 0, 0);
|
|
}
|
|
|
|
#ifdef __aarch64__
|
|
// CHECK-AARCH64-LABEL: @test_InterlockedAdd(
|
|
// CHECK-AARCH64: atomicrmw {{.*}} align 4
|
|
long test_InterlockedAdd(X *x) {
|
|
return _InterlockedAdd(&x->c, 4);
|
|
}
|
|
|
|
// CHECK-AARCH64-LABEL: @test_InterlockedAdd64(
|
|
// CHECK-AARCH64: atomicrmw {{.*}} align 8
|
|
long test_InterlockedAdd64(X *x) {
|
|
return _InterlockedAdd64(&x->c, 4);
|
|
}
|
|
#endif
|