Skip to content

Commit 7a06760

Browse files
tkchiatkchia
and
tkchia
authored
Rename LINUX to _HOSTLINUX etc. to reduce clashes (#655)
Co-authored-by: tkchia <[email protected]>
1 parent 9209ea6 commit 7a06760

File tree

15 files changed

+85
-85
lines changed

15 files changed

+85
-85
lines changed

ape/ape.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ ape_macho:
874874
.long (520f-510f)/4 # count
875875
510: .quad 0 # rax
876876
.quad IMAGE_BASE_VIRTUAL # rbx
877-
.quad XNU # rcx
877+
.quad _HOSTXNU # rcx
878878
.quad 0 # rdx
879879
.quad 0 # rdi
880880
.quad 0 # rsi
@@ -1555,7 +1555,7 @@ kernel: movabs $ape_stack_vaddr,%rsp
15551555
.byte 0x0f,0x1f,0207 # nop rdi binbase
15561556
.long (IMAGE_BASE_VIRTUAL-IMAGE_BASE_REAL)/512
15571557
#endif
1558-
push $METAL # sets __hostos in crt.S
1558+
push $_HOSTMETAL # sets __hostos in crt.S
15591559
pop %rcx
15601560
push $0
15611561
mov %rsp,%rbp

ape/loader-elf.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ macho: .long 0xFEEDFACE+1
175175
510: .quad 0 # rax
176176
.quad 0 # rbx
177177
.quad 0 # rcx
178-
.quad XNU # rdx
178+
.quad _HOSTXNU # rdx
179179
.quad 0 # rdi
180180
.quad 0 # rsi
181181
.quad 0 # rbp
@@ -221,7 +221,7 @@ _start:
221221
jne 0f
222222
cmp $+1,%edx
223223
jne 0f
224-
mov $XNU,%dl
224+
mov $_HOSTXNU,%dl
225225
xor %ecx,%ecx
226226

227227
0: mov %rsp,%rsi

ape/loader-macho.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ macho: .long 0xFEEDFACE+1
9090
510: .quad 0 # rax
9191
.quad 0 # rbx
9292
.quad 0 # rcx
93-
.quad XNU # rdx
93+
.quad _HOSTXNU # rdx
9494
.quad 0 # rdi
9595
.quad 0 # rsi
9696
.quad 0 # rbp
@@ -121,7 +121,7 @@ _start:
121121
jne 0f
122122
cmp $+1,%edx
123123
jne 0f
124-
mov $XNU,%dl
124+
mov $_HOSTXNU,%dl
125125
xor %ecx,%ecx
126126

127127
0: mov %rsp,%rsi

libc/calls/sigaction.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,23 @@ void __sigenter_openbsd(int, void *, void *) hidden;
9090
static void sigaction_cosmo2native(union metasigaction *sa) {
9191
if (!sa) return;
9292
switch (__hostos) {
93-
case LINUX:
93+
case _HOSTLINUX:
9494
SWITCHEROO(sa->cosmo, sa->linux, sa_handler, sa_flags, sa_restorer,
9595
sa_mask);
9696
break;
97-
case XNU:
97+
case _HOSTXNU:
9898
SWITCHEROO(sa->cosmo, sa->xnu_in, sa_handler, sa_flags, sa_restorer,
9999
sa_mask);
100100
break;
101-
case FREEBSD:
101+
case _HOSTFREEBSD:
102102
SWITCHEROO(sa->cosmo, sa->freebsd, sa_handler, sa_flags, sa_flags,
103103
sa_mask);
104104
break;
105-
case OPENBSD:
105+
case _HOSTOPENBSD:
106106
SWITCHEROO(sa->cosmo, sa->openbsd, sa_handler, sa_flags, sa_flags,
107107
sa_mask);
108108
break;
109-
case NETBSD:
109+
case _HOSTNETBSD:
110110
SWITCHEROO(sa->cosmo, sa->netbsd, sa_handler, sa_flags, sa_flags,
111111
sa_mask);
112112
break;
@@ -118,23 +118,23 @@ static void sigaction_cosmo2native(union metasigaction *sa) {
118118
static void sigaction_native2cosmo(union metasigaction *sa) {
119119
if (!sa) return;
120120
switch (__hostos) {
121-
case LINUX:
121+
case _HOSTLINUX:
122122
SWITCHEROO(sa->linux, sa->cosmo, sa_handler, sa_flags, sa_restorer,
123123
sa_mask);
124124
break;
125-
case XNU:
125+
case _HOSTXNU:
126126
SWITCHEROO(sa->xnu_out, sa->cosmo, sa_handler, sa_flags, sa_flags,
127127
sa_mask);
128128
break;
129-
case FREEBSD:
129+
case _HOSTFREEBSD:
130130
SWITCHEROO(sa->freebsd, sa->cosmo, sa_handler, sa_flags, sa_flags,
131131
sa_mask);
132132
break;
133-
case OPENBSD:
133+
case _HOSTOPENBSD:
134134
SWITCHEROO(sa->openbsd, sa->cosmo, sa_handler, sa_flags, sa_flags,
135135
sa_mask);
136136
break;
137-
case NETBSD:
137+
case _HOSTNETBSD:
138138
SWITCHEROO(sa->netbsd, sa->cosmo, sa_handler, sa_flags, sa_flags,
139139
sa_mask);
140140
break;

libc/crt/crt.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ _start:
3838
jne 0f
3939
cmp $+1,%edx
4040
jne 0f
41-
mov $XNU,%cl
41+
mov $_HOSTXNU,%cl
4242
xor %edi,%edi
4343
0:
4444
#endif
@@ -48,7 +48,7 @@ _start:
4848
test %rdi,%rdi
4949
cmovnz %rdi,%rsp
5050
jz 0f
51-
movb $FREEBSD,%cl
51+
movb $_HOSTFREEBSD,%cl
5252
0:
5353
#endif
5454

libc/dce.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
#define SUPPORT_VECTOR 255
1313
#endif
1414

15-
#define LINUX 1
16-
#define METAL 2
17-
#define WINDOWS 4
18-
#define XNU 8
19-
#define OPENBSD 16
20-
#define FREEBSD 32
21-
#define NETBSD 64
15+
#define _HOSTLINUX 1
16+
#define _HOSTMETAL 2
17+
#define _HOSTWINDOWS 4
18+
#define _HOSTXNU 8
19+
#define _HOSTOPENBSD 16
20+
#define _HOSTFREEBSD 32
21+
#define _HOSTNETBSD 64
2222

2323
#ifdef NDEBUG
2424
#define NoDebug() 1
@@ -68,36 +68,36 @@
6868
#define IsPositionIndependent() 0
6969
#endif
7070

71-
#define SupportsLinux() ((SUPPORT_VECTOR & LINUX) == LINUX)
72-
#define SupportsMetal() ((SUPPORT_VECTOR & METAL) == METAL)
73-
#define SupportsWindows() ((SUPPORT_VECTOR & WINDOWS) == WINDOWS)
74-
#define SupportsXnu() ((SUPPORT_VECTOR & XNU) == XNU)
75-
#define SupportsFreebsd() ((SUPPORT_VECTOR & FREEBSD) == FREEBSD)
76-
#define SupportsOpenbsd() ((SUPPORT_VECTOR & OPENBSD) == OPENBSD)
77-
#define SupportsNetbsd() ((SUPPORT_VECTOR & NETBSD) == NETBSD)
78-
#define SupportsBsd() (!!(SUPPORT_VECTOR & (XNU | FREEBSD | OPENBSD | NETBSD)))
71+
#define SupportsLinux() ((SUPPORT_VECTOR & _HOSTLINUX) == _HOSTLINUX)
72+
#define SupportsMetal() ((SUPPORT_VECTOR & _HOSTMETAL) == _HOSTMETAL)
73+
#define SupportsWindows() ((SUPPORT_VECTOR & _HOSTWINDOWS) == _HOSTWINDOWS)
74+
#define SupportsXnu() ((SUPPORT_VECTOR & _HOSTXNU) == _HOSTXNU)
75+
#define SupportsFreebsd() ((SUPPORT_VECTOR & _HOSTFREEBSD) == _HOSTFREEBSD)
76+
#define SupportsOpenbsd() ((SUPPORT_VECTOR & _HOSTOPENBSD) == _HOSTOPENBSD)
77+
#define SupportsNetbsd() ((SUPPORT_VECTOR & _HOSTNETBSD) == _HOSTNETBSD)
78+
#define SupportsBsd() (!!(SUPPORT_VECTOR & (_HOSTXNU | _HOSTFREEBSD | _HOSTOPENBSD | _HOSTNETBSD)))
7979
#define SupportsSystemv() \
80-
(!!(SUPPORT_VECTOR & (LINUX | XNU | OPENBSD | FREEBSD | NETBSD)))
80+
(!!(SUPPORT_VECTOR & (_HOSTLINUX | _HOSTXNU | _HOSTOPENBSD | _HOSTFREEBSD | _HOSTNETBSD)))
8181

8282
#ifndef __ASSEMBLER__
83-
#define IsLinux() (SupportsLinux() && (__hostos & LINUX))
84-
#define IsMetal() (SupportsMetal() && (__hostos & METAL))
85-
#define IsWindows() (SupportsWindows() && (__hostos & WINDOWS))
86-
#define IsXnu() (SupportsXnu() && (__hostos & XNU))
87-
#define IsFreebsd() (SupportsFreebsd() && (__hostos & FREEBSD))
88-
#define IsOpenbsd() (SupportsOpenbsd() && (__hostos & OPENBSD))
89-
#define IsNetbsd() (SupportsNetbsd() && (__hostos & NETBSD))
83+
#define IsLinux() (SupportsLinux() && (__hostos & _HOSTLINUX))
84+
#define IsMetal() (SupportsMetal() && (__hostos & _HOSTMETAL))
85+
#define IsWindows() (SupportsWindows() && (__hostos & _HOSTWINDOWS))
86+
#define IsXnu() (SupportsXnu() && (__hostos & _HOSTXNU))
87+
#define IsFreebsd() (SupportsFreebsd() && (__hostos & _HOSTFREEBSD))
88+
#define IsOpenbsd() (SupportsOpenbsd() && (__hostos & _HOSTOPENBSD))
89+
#define IsNetbsd() (SupportsNetbsd() && (__hostos & _HOSTNETBSD))
9090
#define IsBsd() (IsXnu() || IsFreebsd() || IsOpenbsd() || IsNetbsd())
9191
#else
9292
/* clang-format off */
93-
#define IsLinux() $LINUX,__hostos(%rip)
94-
#define IsMetal() $METAL,__hostos(%rip)
95-
#define IsWindows() $WINDOWS,__hostos(%rip)
96-
#define IsBsd() $XNU|FREEBSD|OPENBSD|NETBSD,__hostos(%rip)
97-
#define IsXnu() $XNU,__hostos(%rip)
98-
#define IsFreebsd() $FREEBSD,__hostos(%rip)
99-
#define IsOpenbsd() $OPENBSD,__hostos(%rip)
100-
#define IsNetbsd() $NETBSD,__hostos(%rip)
93+
#define IsLinux() $_HOSTLINUX,__hostos(%rip)
94+
#define IsMetal() $_HOSTMETAL,__hostos(%rip)
95+
#define IsWindows() $_HOSTWINDOWS,__hostos(%rip)
96+
#define IsBsd() $_HOSTXNU|_HOSTFREEBSD|_HOSTOPENBSD|_HOSTNETBSD,__hostos(%rip)
97+
#define IsXnu() $_HOSTXNU,__hostos(%rip)
98+
#define IsFreebsd() $_HOSTFREEBSD,__hostos(%rip)
99+
#define IsOpenbsd() $_HOSTOPENBSD,__hostos(%rip)
100+
#define IsNetbsd() $_HOSTNETBSD,__hostos(%rip)
101101
/* clang-format on */
102102
#endif
103103

libc/intrin/sched_yield.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ sched_yield:
3232
mov __hostos(%rip),%dl
3333

3434
#if SupportsMetal()
35-
testb $METAL,%dl
35+
testb $_HOSTMETAL,%dl
3636
jnz 9f
3737
#endif
3838

@@ -46,7 +46,7 @@ sched_yield:
4646
// threads ready to run and no user APCs are queued, the function
4747
// returns immediately, and the thread continues execution.
4848
// ──Quoth MSDN
49-
testb $WINDOWS,%dl
49+
testb $_HOSTWINDOWS,%dl
5050
jz 1f
5151
xor %ecx,%ecx
5252
xor %edx,%edx

libc/runtime/arch_prctl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,22 +205,22 @@ int arch_prctl(int code, int64_t addr) {
205205
rc = efault();
206206
} else {
207207
switch (__hostos) {
208-
case METAL:
208+
case _HOSTMETAL:
209209
rc = arch_prctl_msr(code, addr);
210210
break;
211-
case FREEBSD:
211+
case _HOSTFREEBSD:
212212
rc = arch_prctl_freebsd(code, addr);
213213
break;
214-
case NETBSD:
214+
case _HOSTNETBSD:
215215
rc = arch_prctl_netbsd(code, addr);
216216
break;
217-
case OPENBSD:
217+
case _HOSTOPENBSD:
218218
rc = arch_prctl_openbsd(code, addr);
219219
break;
220-
case LINUX:
220+
case _HOSTLINUX:
221221
rc = sys_arch_prctl(code, addr);
222222
break;
223-
case XNU:
223+
case _HOSTXNU:
224224
rc = arch_prctl_xnu(code, addr);
225225
break;
226226
default:

libc/runtime/efimain.greg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ __msabi noasan EFI_STATUS EfiMain(EFI_HANDLE ImageHandle,
7474
uint64_t p, pe, cr4, *m, *pd, *sp, *pml4t, *pdt1, *pdt2, *pdpt1, *pdpt2;
7575
extern char __os asm("__hostos");
7676

77-
__os = METAL;
77+
__os = _HOSTMETAL;
7878

7979
/*
8080
* Allocates and clears PC-compatible memory and copies image.

libc/runtime/winmain.greg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ __msabi textwindows int64_t WinMain(int64_t hInstance, int64_t hPrevInstance,
266266
const char *lpCmdLine, int64_t nCmdShow) {
267267
const char16_t *cmdline;
268268
extern char os asm("__hostos");
269-
os = WINDOWS; /* madness https://news.ycombinator.com/item?id=21019722 */
269+
os = _HOSTWINDOWS; /* madness https://news.ycombinator.com/item?id=21019722 */
270270
kStartTsc = rdtsc();
271271
__pid = GetCurrentProcessId();
272272
#if !IsTiny()

libc/sysv/syscall.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ syscall:
5252
// convert from consts.sh to syscalls.sh encoding
5353
push %rcx
5454
mov __hostos(%rip),%cl
55-
test $LINUX,%cl
55+
test $_HOSTLINUX,%cl
5656
jnz 2f
57-
1: test $FREEBSD,%cl
57+
1: test $_HOSTFREEBSD,%cl
5858
jz 1f
5959
shl $4*7,%rax
6060
jmp 2f
61-
1: test $OPENBSD,%cl
61+
1: test $_HOSTOPENBSD,%cl
6262
jz 1f
6363
shl $4*10,%rax
6464
jmp 2f
65-
1: test $NETBSD,%cl
65+
1: test $_HOSTNETBSD,%cl
6666
jz 1f
6767
shl $4*13,%rax
6868
jmp 2f
69-
1: test $XNU,%cl
69+
1: test $_HOSTXNU,%cl
7070
jz 2f
7171
mov %eax,%ecx
7272
and $0x0f000000,%ecx

libc/sysv/systemfive.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,22 @@ systemfive_xnu:
219219
#if SupportsOpenbsd()
220220
cmpq $0,(%r15) # OpenBSD has no auxv
221221
jnz 0f
222-
mov $OPENBSD,%al
222+
mov $_HOSTOPENBSD,%al
223223
jmp _init_systemfive_detected
224224
0:
225225
#endif
226226
#if SupportsNetbsd()
227227
xor %ecx,%ecx
228228
0: cmpq $2014,(%r15,%rcx,8) # NetBSD's AT_EXECFN
229229
jne 1f
230-
mov $NETBSD,%al
230+
mov $_HOSTNETBSD,%al
231231
jmp _init_systemfive_detected
232232
1: cmpq $0,(%r15,%rcx,8)
233233
lea 2(%ecx),%ecx
234234
jnz 0b
235235
2:
236236
#endif
237-
mov $LINUX,%al
237+
mov $_HOSTLINUX,%al
238238
_init_systemfive_detected:
239239
stosq #→ __hostos
240240
bsr %eax,%eax
@@ -356,7 +356,7 @@ _init_systemfive_pid:
356356
ezlea __hostos,cx
357357
mov (%rcx),%al
358358
mov (%rdi),%eax
359-
testb $WINDOWS|METAL,(%rcx)
359+
testb $_HOSTWINDOWS|_HOSTMETAL,(%rcx)
360360
jnz 1f
361361
mov __NR_getpid,%eax
362362
syscall

net/finger/getsynfingeros.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
int GetSynFingerOs(uint32_t x) {
2626
switch (x) {
2727
case 0x7e7a6599:
28-
return XNU;
28+
return _HOSTXNU;
2929
case 0xbb724187:
30-
return LINUX;
30+
return _HOSTLINUX;
3131
case 0xb228b212:
32-
return WINDOWS;
32+
return _HOSTWINDOWS;
3333
case 0x77c30887:
34-
return FREEBSD;
34+
return _HOSTFREEBSD;
3535
case 0xc45d694b:
36-
return OPENBSD;
36+
return _HOSTOPENBSD;
3737
default:
3838
return 0;
3939
}

0 commit comments

Comments
 (0)