Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit a59c383

Browse files
authored
Merge pull request #2313 from ibuclaw/bshedversion
posix.mak: Enforce whitespace before opening parenthesis for version conditions merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
2 parents 5b700c4 + b16f356 commit a59c383

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+1544
-1541
lines changed

posix.mak

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ style_lint:
372372
$(GREP) -nr '[[:blank:]]$$' $(MANIFEST) ; test $$? -eq 1
373373

374374
@echo "Enforce whitespace before opening parenthesis"
375-
grep -nrE "\<(for|foreach|foreach_reverse|if|while|switch|catch)\(" $$(find src -name '*.d') ; test $$? -eq 1
375+
$(GREP) -nrE "\<(for|foreach|foreach_reverse|if|while|switch|catch|version)\(" $$(find src -name '*.d') ; test $$? -eq 1
376+
377+
@echo "Enforce no whitespace after opening parenthesis"
378+
$(GREP) -nrE "\<(version) \( " $$(find src -name '*.d') ; test $$? -eq 1
376379

377380
.PHONY : auto-tester-build
378381
auto-tester-build: target checkwhitespace

src/core/atomic.d

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
module core.atomic;
1212

13-
version( D_InlineAsm_X86 )
13+
version (D_InlineAsm_X86)
1414
{
1515
version = AsmX86;
1616
version = AsmX86_32;
1717
enum has64BitCAS = true;
1818
enum has128BitCAS = false;
1919
}
20-
else version( D_InlineAsm_X86_64 )
20+
else version (D_InlineAsm_X86_64)
2121
{
2222
version = AsmX86;
2323
version = AsmX86_64;
@@ -147,7 +147,7 @@ private
147147
}
148148

149149

150-
version( AsmX86 )
150+
version (AsmX86)
151151
{
152152
// NOTE: Strictly speaking, the x86 supports atomic operations on
153153
// unaligned values. However, this is far slower than the
@@ -169,7 +169,7 @@ version( AsmX86 )
169169
}
170170

171171

172-
version( CoreDdoc )
172+
version (CoreDdoc)
173173
{
174174
/**
175175
* Performs the binary operation 'op' on val using 'mod' as the modifier.
@@ -268,7 +268,7 @@ version( CoreDdoc )
268268
*/
269269
void atomicFence() nothrow @nogc;
270270
}
271-
else version( AsmX86_32 )
271+
else version (AsmX86_32)
272272
{
273273
// Uses specialized asm for fast fetch and add operations
274274
private TailShared!(T) atomicFetchAdd(T)( ref shared T val, size_t mod ) pure nothrow @nogc @safe
@@ -756,7 +756,7 @@ else version( AsmX86_32 )
756756
}
757757
}
758758
}
759-
else version( AsmX86_64 )
759+
else version (AsmX86_64)
760760
{
761761
// Uses specialized asm for fast fetch and add operations
762762
private TailShared!(T) atomicFetchAdd(T)( ref shared T val, size_t mod ) pure nothrow @nogc @trusted
@@ -947,7 +947,7 @@ else version( AsmX86_64 )
947947
//////////////////////////////////////////////////////////////////
948948
// 16 Byte CAS on a 64-Bit Processor
949949
//////////////////////////////////////////////////////////////////
950-
version(Win64){
950+
version (Win64){
951951
//Windows 64 calling convention uses different registers.
952952
//DMD appears to reverse the register order.
953953
asm pure nothrow @nogc @trusted
@@ -1148,7 +1148,7 @@ else version( AsmX86_64 )
11481148
//////////////////////////////////////////////////////////////////
11491149
// 16 Byte Load on a 64-Bit Processor
11501150
//////////////////////////////////////////////////////////////////
1151-
version(Win64){
1151+
version (Win64){
11521152
size_t[2] retVal;
11531153
asm pure nothrow @nogc @trusted
11541154
{
@@ -1321,7 +1321,7 @@ else version( AsmX86_64 )
13211321
//////////////////////////////////////////////////////////////////
13221322
// 16 Byte Store on a 64-Bit Processor
13231323
//////////////////////////////////////////////////////////////////
1324-
version(Win64){
1324+
version (Win64){
13251325
asm pure nothrow @nogc @trusted
13261326
{
13271327
push RDI;
@@ -1414,7 +1414,7 @@ if (__traits(isFloating, T))
14141414
////////////////////////////////////////////////////////////////////////////////
14151415

14161416

1417-
version( unittest )
1417+
version (unittest)
14181418
{
14191419
void testCAS(T)( T val ) pure nothrow @nogc @trusted
14201420
in
@@ -1622,7 +1622,7 @@ version( unittest )
16221622
assert(atomicOp!"+="(i8, 8) == 13);
16231623
assert(atomicOp!"+="(i16, 8) == 14);
16241624
assert(atomicOp!"+="(i32, 8) == 15);
1625-
version( AsmX86_64 )
1625+
version (AsmX86_64)
16261626
{
16271627
shared ulong u64 = 4;
16281628
shared long i64 = 8;
@@ -1646,7 +1646,7 @@ version( unittest )
16461646
assert(atomicOp!"-="(i8, 1) == 4);
16471647
assert(atomicOp!"-="(i16, 1) == 5);
16481648
assert(atomicOp!"-="(i32, 1) == 6);
1649-
version( AsmX86_64 )
1649+
version (AsmX86_64)
16501650
{
16511651
shared ulong u64 = 4;
16521652
shared long i64 = 8;

src/core/bitop.d

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ nothrow:
1313
@safe:
1414
@nogc:
1515

16-
version( D_InlineAsm_X86_64 )
16+
version (D_InlineAsm_X86_64)
1717
version = AsmX86;
18-
else version( D_InlineAsm_X86 )
18+
else version (D_InlineAsm_X86)
1919
version = AsmX86;
2020

2121
version (X86_64)
@@ -29,7 +29,7 @@ private union Split64
2929
ulong u64;
3030
struct
3131
{
32-
version(LittleEndian)
32+
version (LittleEndian)
3333
{
3434
uint lo;
3535
uint hi;
@@ -561,7 +561,7 @@ version (DigitalMars) version (AnyX86) @system // not pure
561561
int popcnt(uint x) pure
562562
{
563563
// Select the fastest method depending on the compiler and CPU architecture
564-
version(DigitalMars)
564+
version (DigitalMars)
565565
{
566566
static if (is(typeof(_popcnt(uint.max))))
567567
{
@@ -598,7 +598,7 @@ int popcnt(ulong x) pure
598598
static if (size_t.sizeof == uint.sizeof)
599599
{
600600
const sx = Split64(x);
601-
version(DigitalMars)
601+
version (DigitalMars)
602602
{
603603
static if (is(typeof(_popcnt(uint.max))))
604604
{
@@ -611,7 +611,7 @@ int popcnt(ulong x) pure
611611
}
612612
else static if (size_t.sizeof == ulong.sizeof)
613613
{
614-
version(DigitalMars)
614+
version (DigitalMars)
615615
{
616616
static if (is(typeof(_popcnt(ulong.max))))
617617
{

src/core/cpuid.d

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -426,16 +426,16 @@ CpuFeatures* getCpuFeatures() @nogc nothrow
426426
}
427427

428428

429-
version(GNU) {
430-
version(X86)
429+
version (GNU) {
430+
version (X86)
431431
enum supportedX86 = true;
432-
else version(X86_64)
432+
else version (X86_64)
433433
enum supportedX86 = true;
434434
else
435435
enum supportedX86 = false;
436-
} else version(D_InlineAsm_X86) {
436+
} else version (D_InlineAsm_X86) {
437437
enum supportedX86 = true;
438-
} else version(D_InlineAsm_X86_64) {
438+
} else version (D_InlineAsm_X86_64) {
439439
enum supportedX86 = true;
440440
} else {
441441
enum supportedX86 = false;
@@ -509,7 +509,7 @@ void getcacheinfoCPUID2()
509509
// for old single-core CPUs.
510510
uint numinfos = 1;
511511
do {
512-
version(GNU) asm pure nothrow @nogc {
512+
version (GNU) asm pure nothrow @nogc {
513513
"cpuid" : "=a" a[0], "=b" a[1], "=c" a[2], "=d" a[3] : "a" 2;
514514
} else asm pure nothrow @nogc {
515515
mov EAX, 2;
@@ -553,7 +553,7 @@ void getcacheinfoCPUID4()
553553
int cachenum = 0;
554554
for (;;) {
555555
uint a, b, number_of_sets;
556-
version(GNU) asm pure nothrow @nogc {
556+
version (GNU) asm pure nothrow @nogc {
557557
"cpuid" : "=a" a, "=b" b, "=c" number_of_sets : "a" 4, "c" cachenum : "edx";
558558
} else asm pure nothrow @nogc {
559559
mov EAX, 4;
@@ -593,7 +593,7 @@ void getcacheinfoCPUID4()
593593
void getAMDcacheinfo()
594594
{
595595
uint dummy, c5, c6, d6;
596-
version(GNU) asm pure nothrow @nogc {
596+
version (GNU) asm pure nothrow @nogc {
597597
"cpuid" : "=a" dummy, "=c" c5 : "a" 0x8000_0005 : "ebx", "edx";
598598
} else asm pure nothrow @nogc {
599599
mov EAX, 0x8000_0005; // L1 cache
@@ -612,7 +612,7 @@ void getAMDcacheinfo()
612612
// AMD K6-III or K6-2+ or later.
613613
ubyte numcores = 1;
614614
if (max_extended_cpuid >= 0x8000_0008) {
615-
version(GNU) asm pure nothrow @nogc {
615+
version (GNU) asm pure nothrow @nogc {
616616
"cpuid" : "=a" dummy, "=c" numcores : "a" 0x8000_0008 : "ebx", "edx";
617617
} else asm pure nothrow @nogc {
618618
mov EAX, 0x8000_0008;
@@ -623,7 +623,7 @@ void getAMDcacheinfo()
623623
if (numcores>cpuFeatures.maxCores) cpuFeatures.maxCores = numcores;
624624
}
625625

626-
version(GNU) asm pure nothrow @nogc {
626+
version (GNU) asm pure nothrow @nogc {
627627
"cpuid" : "=a" dummy, "=c" c6, "=d" d6 : "a" 0x8000_0006 : "ebx";
628628
} else asm pure nothrow @nogc {
629629
mov EAX, 0x8000_0006; // L2/L3 cache
@@ -652,7 +652,7 @@ void getCpuInfo0B()
652652
int threadsPerCore;
653653
uint a, b, c, d;
654654
do {
655-
version(GNU) asm pure nothrow @nogc {
655+
version (GNU) asm pure nothrow @nogc {
656656
"cpuid" : "=a" a, "=b" b, "=c" c, "=d" d : "a" 0x0B, "c" level;
657657
} else asm pure nothrow @nogc {
658658
mov EAX, 0x0B;
@@ -684,15 +684,15 @@ void cpuidX86()
684684

685685
uint a, b, c, d;
686686
uint* venptr = cast(uint*)cf.vendorID.ptr;
687-
version(GNU)
687+
version (GNU)
688688
{
689689
asm pure nothrow @nogc { "cpuid" : "=a" max_cpuid, "=b" venptr[0], "=d" venptr[1], "=c" venptr[2] : "a" 0; }
690690
asm pure nothrow @nogc { "cpuid" : "=a" max_extended_cpuid : "a" 0x8000_0000 : "ebx", "ecx", "edx"; }
691691
}
692692
else
693693
{
694694
uint a2;
695-
version(D_InlineAsm_X86)
695+
version (D_InlineAsm_X86)
696696
{
697697
asm pure nothrow @nogc {
698698
mov EAX, 0;
@@ -704,7 +704,7 @@ void cpuidX86()
704704
mov [EAX + 8], ECX;
705705
}
706706
}
707-
else version(D_InlineAsm_X86_64)
707+
else version (D_InlineAsm_X86_64)
708708
{
709709
asm pure nothrow @nogc {
710710
mov EAX, 0;
@@ -729,7 +729,7 @@ void cpuidX86()
729729
cf.probablyIntel = cf.vendorID == "GenuineIntel";
730730
cf.probablyAMD = cf.vendorID == "AuthenticAMD";
731731
uint apic = 0; // brand index, apic id
732-
version(GNU) asm pure nothrow @nogc {
732+
version (GNU) asm pure nothrow @nogc {
733733
"cpuid" : "=a" a, "=b" apic, "=c" cf.miscfeatures, "=d" cf.features : "a" 1;
734734
} else {
735735
asm pure nothrow @nogc {
@@ -752,7 +752,7 @@ void cpuidX86()
752752

753753
if (max_cpuid >= 7)
754754
{
755-
version(GNU) asm pure nothrow @nogc {
755+
version (GNU) asm pure nothrow @nogc {
756756
"cpuid" : "=a" a, "=b" cf.extfeatures, "=c" c : "a" 7, "c" 0 : "edx";
757757
} else {
758758
uint ext;
@@ -768,7 +768,7 @@ void cpuidX86()
768768

769769
if (cf.miscfeatures & OSXSAVE_BIT)
770770
{
771-
version(GNU) asm pure nothrow @nogc {
771+
version (GNU) asm pure nothrow @nogc {
772772
"xgetbv" : "=a" a, "=d" d : "c" 0;
773773
} else asm pure nothrow @nogc {
774774
mov ECX, 0;
@@ -782,7 +782,7 @@ void cpuidX86()
782782
cf.amdfeatures = 0;
783783
cf.amdmiscfeatures = 0;
784784
if (max_extended_cpuid >= 0x8000_0001) {
785-
version(GNU) asm pure nothrow @nogc {
785+
version (GNU) asm pure nothrow @nogc {
786786
"cpuid" : "=a" a, "=c" cf.amdmiscfeatures, "=d" cf.amdfeatures : "a" 0x8000_0001 : "ebx";
787787
} else {
788788
asm pure nothrow @nogc {
@@ -803,7 +803,7 @@ void cpuidX86()
803803
cf.maxCores = 1;
804804
if (hyperThreadingBit) {
805805
// determine max number of cores for AMD
806-
version(GNU) asm pure nothrow @nogc {
806+
version (GNU) asm pure nothrow @nogc {
807807
"cpuid" : "=a" a, "=c" c : "a" 0x8000_0008 : "ebx", "edx";
808808
} else asm pure nothrow @nogc {
809809
mov EAX, 0x8000_0008;
@@ -816,13 +816,13 @@ void cpuidX86()
816816

817817
if (max_extended_cpuid >= 0x8000_0004) {
818818
uint* pnb = cast(uint*)cf.processorNameBuffer.ptr;
819-
version(GNU)
819+
version (GNU)
820820
{
821821
asm pure nothrow @nogc { "cpuid" : "=a" pnb[0], "=b" pnb[1], "=c" pnb[ 2], "=d" pnb[ 3] : "a" 0x8000_0002; }
822822
asm pure nothrow @nogc { "cpuid" : "=a" pnb[4], "=b" pnb[5], "=c" pnb[ 6], "=d" pnb[ 7] : "a" 0x8000_0003; }
823823
asm pure nothrow @nogc { "cpuid" : "=a" pnb[8], "=b" pnb[9], "=c" pnb[10], "=d" pnb[11] : "a" 0x8000_0004; }
824824
}
825-
else version(D_InlineAsm_X86)
825+
else version (D_InlineAsm_X86)
826826
{
827827
asm pure nothrow @nogc {
828828
push ESI;
@@ -848,7 +848,7 @@ void cpuidX86()
848848
pop ESI;
849849
}
850850
}
851-
else version(D_InlineAsm_X86_64)
851+
else version (D_InlineAsm_X86_64)
852852
{
853853
asm pure nothrow @nogc {
854854
push RSI;
@@ -951,12 +951,12 @@ void cpuidX86()
951951
// BUG(WONTFIX): Returns false for Cyrix 6x86 and 6x86L. They will be treated as 486 machines.
952952
bool hasCPUID()
953953
{
954-
version(X86_64)
954+
version (X86_64)
955955
return true;
956956
else
957957
{
958958
uint flags;
959-
version(GNU)
959+
version (GNU)
960960
{
961961
// http://wiki.osdev.org/CPUID#Checking_CPUID_availability
962962
// ASM template supports both AT&T and Intel syntax.
@@ -974,7 +974,7 @@ bool hasCPUID()
974974
" : "=a" flags;
975975
}
976976
}
977-
else version(D_InlineAsm_X86)
977+
else version (D_InlineAsm_X86)
978978
{
979979
asm nothrow @nogc {
980980
pushfd;

src/core/demangle.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,14 +2412,14 @@ private template hasPlainMangling(FT) if (is(FT == function))
24122412
/***
24132413
* C name mangling is done by adding a prefix on some platforms.
24142414
*/
2415-
version(Win32)
2415+
version (Win32)
24162416
enum string cPrefix = "_";
2417-
else version(Darwin)
2417+
else version (Darwin)
24182418
enum string cPrefix = "_";
24192419
else
24202420
enum string cPrefix = "";
24212421

2422-
version(unittest)
2422+
version (unittest)
24232423
{
24242424
immutable string[2][] table =
24252425
[

src/core/internal/abort.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ void abort(scope string msg, scope string filename = __FILE__, size_t line = __L
88
{
99
import core.stdc.stdlib: c_abort = abort;
1010
// use available OS system calls to print the message to stderr
11-
version(Posix)
11+
version (Posix)
1212
{
1313
import core.sys.posix.unistd: write;
1414
static void writeStr(scope const(char)[][] m...) @nogc nothrow @trusted
@@ -17,7 +17,7 @@ void abort(scope string msg, scope string filename = __FILE__, size_t line = __L
1717
write(2, s.ptr, s.length);
1818
}
1919
}
20-
else version(Windows)
20+
else version (Windows)
2121
{
2222
import core.sys.windows.windows: GetStdHandle, STD_ERROR_HANDLE, WriteFile, INVALID_HANDLE_VALUE;
2323
auto h = (() @trusted => GetStdHandle(STD_ERROR_HANDLE))();

0 commit comments

Comments
 (0)