xref: /freebsd/share/man/man7/arch.7 (revision 7fde0187cc443468561f0a30d589ff0cfe45eef5)
1*7fde0187SEd Maste.\" Copyright (c) 2016-2017 The FreeBSD Foundation.
2df9330b5SEd Maste.\"
3df9330b5SEd Maste.\" This documentation was created by Ed Maste under sponsorship of
4df9330b5SEd Maste.\" The FreeBSD Foundation.
5df9330b5SEd Maste.\"
6df9330b5SEd Maste.\" Redistribution and use in source and binary forms, with or without
7df9330b5SEd Maste.\" modification, are permitted provided that the following conditions
8df9330b5SEd Maste.\" are met:
9df9330b5SEd Maste.\" 1. Redistributions of source code must retain the above copyright
10df9330b5SEd Maste.\"    notice, this list of conditions and the following disclaimer.
11df9330b5SEd Maste.\" 2. Redistributions in binary form must reproduce the above copyright
12df9330b5SEd Maste.\"    notice, this list of conditions and the following disclaimer in the
13df9330b5SEd Maste.\"    documentation and/or other materials provided with the distribution.
14df9330b5SEd Maste.\"
15df9330b5SEd Maste.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND
16df9330b5SEd Maste.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17df9330b5SEd Maste.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18df9330b5SEd Maste.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
19df9330b5SEd Maste.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20df9330b5SEd Maste.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21df9330b5SEd Maste.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22df9330b5SEd Maste.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23df9330b5SEd Maste.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24df9330b5SEd Maste.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25df9330b5SEd Maste.\" SUCH DAMAGE.
26df9330b5SEd Maste.\"
27df9330b5SEd Maste.\" $FreeBSD$
28df9330b5SEd Maste.\"
299c983ad7SEd Maste.Dd November 25, 2021
30df9330b5SEd Maste.Dt ARCH 7
31df9330b5SEd Maste.Os
32df9330b5SEd Maste.Sh NAME
33df9330b5SEd Maste.Nm arch
34df9330b5SEd Maste.Nd Architecture-specific details
35df9330b5SEd Maste.Sh DESCRIPTION
36df9330b5SEd MasteDifferences between CPU architectures and platforms supported by
37df9330b5SEd Maste.Fx .
38de6fc272SKonstantin Belousov.Ss Introduction
3925b526e6SKonstantin BelousovThis document is a quick reference of key ABI details of
4025b526e6SKonstantin Belousov.Fx
4125b526e6SKonstantin Belousovarchitecture ports.
4225b526e6SKonstantin BelousovFor full details consult the processor-specific ABI supplement
4325b526e6SKonstantin Belousovdocumentation.
4425b526e6SKonstantin Belousov.Pp
45dddb1576SKonstantin BelousovIf not explicitly mentioned, sizes are in bytes.
4645801499SEd MasteThe architecture details in this document apply to
479c983ad7SEd Maste.Fx 12.0
4845801499SEd Masteand later, unless otherwise noted.
49de6fc272SKonstantin Belousov.Pp
50e6c0d5c3SKonstantin Belousov.Fx
517748ab43SKonstantin Belousovuses a flat address space.
527748ab43SKonstantin BelousovVariables of types
53e6c0d5c3SKonstantin Belousov.Vt unsigned long ,
54e6c0d5c3SKonstantin Belousov.Vt uintptr_t ,
55de6fc272SKonstantin Belousovand
56de6fc272SKonstantin Belousov.Vt size_t
577748ab43SKonstantin Belousovand pointers all have the same representation.
58de6fc272SKonstantin Belousov.Pp
59de6fc272SKonstantin BelousovIn order to maximize compatibility with future pointer integrity mechanisms,
60de6fc272SKonstantin Belousovmanipulations of pointers as integers should be performed via
61de6fc272SKonstantin Belousov.Vt uintptr_t
62de6fc272SKonstantin Belousovor
63de6fc272SKonstantin Belousov.Vt intptr_t
64de6fc272SKonstantin Belousovand no other types.
65de6fc272SKonstantin BelousovIn particular,
66de6fc272SKonstantin Belousov.Vt long
67de6fc272SKonstantin Belousovand
68de6fc272SKonstantin Belousov.Vt ptrdiff_t
69de6fc272SKonstantin Belousovshould be avoided.
70de6fc272SKonstantin Belousov.Pp
71098150fbSWarner LoshOn some architectures, e.g.,
72de6fc272SKonstantin Belousov.Dv powerpc
73de6fc272SKonstantin Belousovand AIM variants of
74de6fc272SKonstantin Belousov.Dv powerpc64 ,
75de6fc272SKonstantin Belousovthe kernel uses a separate address space.
76de6fc272SKonstantin BelousovOn other architectures, kernel and a user mode process share a
77de6fc272SKonstantin Belousovsingle address space.
78de6fc272SKonstantin BelousovThe kernel is located at the highest addresses.
79de6fc272SKonstantin Belousov.Pp
80de6fc272SKonstantin BelousovOn each architecture, the main user mode thread's stack starts near
81de6fc272SKonstantin Belousovthe highest user address and grows down.
8245801499SEd Maste.Pp
8345801499SEd Maste.Fx
8445801499SEd Mastearchitecture support varies by release.
859c943f7aSEd MasteThis table shows currently supported CPU architectures along with the first
8645801499SEd Maste.Fx
879c943f7aSEd Masterelease to support each architecture.
889c943f7aSEd Maste.Bl -column -offset indent "Architecture" "Initial Release"
899c943f7aSEd Maste.It Sy Architecture Ta Sy Initial Release
90f38b2297SIan Lepore.It aarch64     Ta 11.0
9145801499SEd Maste.It amd64       Ta 5.1
9245801499SEd Maste.It armv6       Ta 10.0
9313368c38SWarner Losh.It armv7       Ta 12.0
9445801499SEd Maste.It i386        Ta 1.0
959c943f7aSEd Maste.It powerpc     Ta 6.0
969c943f7aSEd Maste.It powerpcspe  Ta 12.0
979c943f7aSEd Maste.It powerpc64   Ta 9.0
989c943f7aSEd Maste.It powerpc64le Ta 13.0
999c943f7aSEd Maste.It riscv64     Ta 12.0
1009c943f7aSEd Maste.It riscv64sf   Ta 12.0
1019c943f7aSEd Maste.El
1029c943f7aSEd Maste.Pp
1039c943f7aSEd MasteDiscontinued architectures are shown in the following table.
1049c943f7aSEd Maste.Bl -column -offset indent "Architecture" "Initial Release" "Final Release"
1059c943f7aSEd Maste.It Sy Architecture Ta Sy Initial Release Ta Sy Final Release
1069c943f7aSEd Maste.It alpha       Ta 3.2   Ta 6.4
1079c943f7aSEd Maste.It arm         Ta 6.0   Ta 12.x
1089c943f7aSEd Maste.It armeb       Ta 8.0   Ta 11.4
1099c943f7aSEd Maste.It ia64        Ta 5.0   Ta 10.4
110a721ac94SWarner Losh.It mips        Ta 8.0   Ta 13.x
111a721ac94SWarner Losh.It mipsel      Ta 9.0   Ta 13.x
112a721ac94SWarner Losh.It mipselhf    Ta 12.0  Ta 13.x
113a721ac94SWarner Losh.It mipshf      Ta 12.0  Ta 13.x
114a721ac94SWarner Losh.It mipsn32     Ta 9.0   Ta 13.x
115a721ac94SWarner Losh.It mips64      Ta 9.0   Ta 13.x
116a721ac94SWarner Losh.It mips64el    Ta 9.0   Ta 13.x
117a721ac94SWarner Losh.It mips64elhf  Ta 12.0  Ta 13.x
118a721ac94SWarner Losh.It mips64hf    Ta 12.0  Ta 13.x
1194f954864SEd Maste.It pc98        Ta 2.2   Ta 11.4
1204940bf26SEd Maste.It sparc64     Ta 5.0   Ta 12.x
12145801499SEd Maste.El
122df9330b5SEd Maste.Ss Type sizes
123e6c0d5c3SKonstantin BelousovAll
124e6c0d5c3SKonstantin Belousov.Fx
125e6c0d5c3SKonstantin Belousovarchitectures use some variant of the ELF (see
126de6fc272SKonstantin Belousov.Xr elf 5 )
127de6fc272SKonstantin Belousov.Sy Application Binary Interface
128de6fc272SKonstantin Belousov(ABI) for the machine processor.
129de6fc272SKonstantin BelousovAll supported ABIs can be divided into two groups:
130de6fc272SKonstantin Belousov.Bl -tag -width "Dv ILP32"
131de6fc272SKonstantin Belousov.It Dv ILP32
132de6fc272SKonstantin Belousov.Vt int ,
133de6fc272SKonstantin Belousov.Vt long ,
134de6fc272SKonstantin Belousov.Vt void *
135de6fc272SKonstantin Belousovtypes machine representations all have 4-byte size.
136de6fc272SKonstantin Belousov.It Dv LP64
137de6fc272SKonstantin Belousov.Vt int
138de6fc272SKonstantin Belousovtype machine representation uses 4 bytes,
139de6fc272SKonstantin Belousovwhile
140de6fc272SKonstantin Belousov.Vt long
141de6fc272SKonstantin Belousovand
142de6fc272SKonstantin Belousov.Vt void *
143de6fc272SKonstantin Belousovare 8 bytes.
144de6fc272SKonstantin Belousov.El
14515d641f0SJohn Baldwin.Pp
146fcfe2d66SIan LeporeSome machines support more than one
147e6c0d5c3SKonstantin Belousov.Fx
148e6c0d5c3SKonstantin BelousovABI.
149de6fc272SKonstantin BelousovTypically these are 64-bit machines, where the
150de6fc272SKonstantin Belousov.Dq native
151de6fc272SKonstantin Belousov.Dv LP64
152de6fc272SKonstantin Belousovexecution environment is accompanied by the
153de6fc272SKonstantin Belousov.Dq legacy
154de6fc272SKonstantin Belousov.Dv ILP32
155fcfe2d66SIan Leporeenvironment, which was the historical 32-bit predecessor for 64-bit evolution.
156de6fc272SKonstantin BelousovExamples are:
157ddc9d6e5SEd Maste.Bl -column -offset indent "powerpc64" "ILP32 counterpart"
158de6fc272SKonstantin Belousov.It Sy LP64        Ta Sy ILP32 counterpart
159de6fc272SKonstantin Belousov.It Dv amd64       Ta Dv i386
160de6fc272SKonstantin Belousov.It Dv powerpc64   Ta Dv powerpc
161de6fc272SKonstantin Belousov.It Dv mips64*     Ta Dv mips*
16214601230SOlivier Houchard.It Dv aarch64     Ta Dv armv6/armv7
163de6fc272SKonstantin Belousov.El
16415d641f0SJohn Baldwin.Pp
165f38b2297SIan Lepore.Dv aarch64
16614601230SOlivier Houchardwill support execution of
167de6fc272SKonstantin Belousov.Dv armv6
16813368c38SWarner Loshor
16913368c38SWarner Losh.Dv armv7
17014601230SOlivier Houchardbinaries if the CPU implements
171de6fc272SKonstantin Belousov.Dv AArch32
17214601230SOlivier Houchardexecution state, however
17314601230SOlivier Houchard.Dv armv5
17414601230SOlivier Houchardbinaries aren't supported.
175de6fc272SKonstantin Belousov.Pp
176dddb1576SKonstantin BelousovOn all supported architectures:
177df9330b5SEd Maste.Bl -column -offset -indent "long long" "Size"
178df9330b5SEd Maste.It Sy Type Ta Sy Size
179df9330b5SEd Maste.It short Ta 2
180df9330b5SEd Maste.It int Ta 4
181df9330b5SEd Maste.It long Ta sizeof(void*)
182df9330b5SEd Maste.It long long Ta 8
183df9330b5SEd Maste.It float Ta 4
184df9330b5SEd Maste.It double Ta 8
185df9330b5SEd Maste.El
18615d641f0SJohn Baldwin.Pp
1877748ab43SKonstantin BelousovIntegers are represented in two's complement.
188de6fc272SKonstantin BelousovAlignment of integer and pointer types is natural, that is,
189e6c0d5c3SKonstantin Belousovthe address of the variable must be congruent to zero modulo the type size.
190e6c0d5c3SKonstantin BelousovMost ILP32 ABIs, except
191e6c0d5c3SKonstantin Belousov.Dv arm ,
192e6c0d5c3SKonstantin Belousovrequire only 4-byte alignment for 64-bit integers.
193dddb1576SKonstantin Belousov.Pp
194dddb1576SKonstantin BelousovMachine-dependent type sizes:
195ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "void *" "long double" "time_t"
196dddb1576SKonstantin Belousov.It Sy Architecture Ta Sy void * Ta Sy long double Ta Sy time_t
197f38b2297SIan Lepore.It aarch64     Ta 8 Ta 16 Ta 8
1986554316cSKonstantin Belousov.It amd64       Ta 8 Ta 16 Ta 8
1996554316cSKonstantin Belousov.It armv6       Ta 4 Ta  8 Ta 8
200bad7e1e8SWarner Losh.It armv7       Ta 4 Ta  8 Ta 8
2016554316cSKonstantin Belousov.It i386        Ta 4 Ta 12 Ta 4
2026554316cSKonstantin Belousov.It mips        Ta 4 Ta  8 Ta 8
2036554316cSKonstantin Belousov.It mipsel      Ta 4 Ta  8 Ta 8
2046554316cSKonstantin Belousov.It mipselhf    Ta 4 Ta  8 Ta 8
2056554316cSKonstantin Belousov.It mipshf      Ta 4 Ta  8 Ta 8
2066554316cSKonstantin Belousov.It mipsn32     Ta 4 Ta  8 Ta 8
2076554316cSKonstantin Belousov.It mips64      Ta 8 Ta  8 Ta 8
2086554316cSKonstantin Belousov.It mips64el    Ta 8 Ta  8 Ta 8
2096554316cSKonstantin Belousov.It mips64elhf  Ta 8 Ta  8 Ta 8
2106554316cSKonstantin Belousov.It mips64hf    Ta 8 Ta  8 Ta 8
211fbcf7bcdSJustin Hibbits.It powerpc     Ta 4 Ta  8 Ta 8
212fbcf7bcdSJustin Hibbits.It powerpcspe  Ta 4 Ta  8 Ta 8
2136554316cSKonstantin Belousov.It powerpc64   Ta 8 Ta  8 Ta 8
2141bdb1aa4SBrandon Bergren.It powerpc64le Ta 8 Ta  8 Ta 8
2154dd67957SJohn Baldwin.It riscv64     Ta 8 Ta 16 Ta 8
2164dd67957SJohn Baldwin.It riscv64sf   Ta 8 Ta 16 Ta 8
217df9330b5SEd Maste.El
218dddb1576SKonstantin Belousov.Pp
219dddb1576SKonstantin Belousov.Sy time_t
22049ccd3feSEd Masteis 8 bytes on all supported architectures except i386.
221df9330b5SEd Maste.Ss Endianness and Char Signedness
222ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "Endianness" "char Signedness"
223df9330b5SEd Maste.It Sy Architecture Ta Sy Endianness Ta Sy char Signedness
224f38b2297SIan Lepore.It aarch64     Ta little Ta unsigned
225df9330b5SEd Maste.It amd64       Ta little Ta   signed
226df9330b5SEd Maste.It armv6       Ta little Ta unsigned
22713368c38SWarner Losh.It armv7       Ta little Ta unsigned
228df9330b5SEd Maste.It i386        Ta little Ta   signed
2298395cdc1SEd Maste.It mips        Ta big    Ta   signed
2308395cdc1SEd Maste.It mipsel      Ta little Ta   signed
2315bca2215SRuslan Bukin.It mipselhf    Ta little Ta   signed
2325bca2215SRuslan Bukin.It mipshf      Ta big    Ta   signed
2338395cdc1SEd Maste.It mipsn32     Ta big    Ta   signed
2348395cdc1SEd Maste.It mips64      Ta big    Ta   signed
235df9330b5SEd Maste.It mips64el    Ta little Ta   signed
2365bca2215SRuslan Bukin.It mips64elhf  Ta little Ta   signed
2375bca2215SRuslan Bukin.It mips64hf    Ta big    Ta   signed
238df9330b5SEd Maste.It powerpc     Ta big    Ta unsigned
239002cc1f9SJustin Hibbits.It powerpcspe  Ta big    Ta unsigned
240df9330b5SEd Maste.It powerpc64   Ta big    Ta unsigned
2411bdb1aa4SBrandon Bergren.It powerpc64le Ta little Ta unsigned
2424dd67957SJohn Baldwin.It riscv64     Ta little Ta   signed
2434dd67957SJohn Baldwin.It riscv64sf   Ta little Ta   signed
244df9330b5SEd Maste.El
245df9330b5SEd Maste.Ss Page Size
246ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "Page Sizes"
247df9330b5SEd Maste.It Sy Architecture Ta Sy Page Sizes
248f38b2297SIan Lepore.It aarch64     Ta 4K, 2M, 1G
249df9330b5SEd Maste.It amd64       Ta 4K, 2M, 1G
250780586e8SEd Maste.It armv6       Ta 4K, 1M
25113368c38SWarner Losh.It armv7       Ta 4K, 1M
252df9330b5SEd Maste.It i386        Ta 4K, 2M (PAE), 4M
253df9330b5SEd Maste.It mips        Ta 4K
254df9330b5SEd Maste.It mipsel      Ta 4K
2555bca2215SRuslan Bukin.It mipselhf    Ta 4K
2565bca2215SRuslan Bukin.It mipshf      Ta 4K
257df9330b5SEd Maste.It mipsn32     Ta 4K
258df9330b5SEd Maste.It mips64      Ta 4K
259df9330b5SEd Maste.It mips64el    Ta 4K
2605bca2215SRuslan Bukin.It mips64elhf  Ta 4K
2615bca2215SRuslan Bukin.It mips64hf    Ta 4K
262df9330b5SEd Maste.It powerpc     Ta 4K
263002cc1f9SJustin Hibbits.It powerpcspe  Ta 4K
264df9330b5SEd Maste.It powerpc64   Ta 4K
2651bdb1aa4SBrandon Bergren.It powerpc64le Ta 4K
266c4ef7cdbSMitchell Horne.It riscv64     Ta 4K, 2M, 1G
267c4ef7cdbSMitchell Horne.It riscv64sf   Ta 4K, 2M, 1G
268df9330b5SEd Maste.El
269df9330b5SEd Maste.Ss Floating Point
270ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "float, double" "long double"
271df9330b5SEd Maste.It Sy Architecture Ta Sy float, double Ta Sy long double
272f38b2297SIan Lepore.It aarch64     Ta hard Ta soft, quad precision
273df9330b5SEd Maste.It amd64       Ta hard Ta hard, 80 bit
2748b3c5418SEd Maste.It armv6       Ta hard Ta hard, double precision
2758b3c5418SEd Maste.It armv7       Ta hard Ta hard, double precision
276df9330b5SEd Maste.It i386        Ta hard Ta hard, 80 bit
277df9330b5SEd Maste.It mips        Ta soft Ta identical to double
278df9330b5SEd Maste.It mipsel      Ta soft Ta identical to double
2795bca2215SRuslan Bukin.It mipselhf    Ta hard Ta identical to double
2805bca2215SRuslan Bukin.It mipshf      Ta hard Ta identical to double
281df9330b5SEd Maste.It mipsn32     Ta soft Ta identical to double
282df9330b5SEd Maste.It mips64      Ta soft Ta identical to double
283df9330b5SEd Maste.It mips64el    Ta soft Ta identical to double
2845bca2215SRuslan Bukin.It mips64elhf  Ta hard Ta identical to double
2855bca2215SRuslan Bukin.It mips64hf    Ta hard Ta identical to double
286df9330b5SEd Maste.It powerpc     Ta hard Ta hard, double precision
287002cc1f9SJustin Hibbits.It powerpcspe  Ta hard Ta hard, double precision
288df9330b5SEd Maste.It powerpc64   Ta hard Ta hard, double precision
2891bdb1aa4SBrandon Bergren.It powerpc64le Ta hard Ta hard, double precision
290c4ef7cdbSMitchell Horne.It riscv64     Ta hard Ta hard, quad precision
291c4ef7cdbSMitchell Horne.It riscv64sf   Ta soft Ta soft, quad precision
292df9330b5SEd Maste.El
2934ef28065SEd Maste.Ss Default Tool Chain
294ce0d5fb4SEd Maste.Fx
295ce0d5fb4SEd Masteuses
2964715c31eSEd Maste.Xr clang 1
297ce0d5fb4SEd Masteas the default compiler on all supported CPU architectures,
298e6f6c36cSEd MasteLLVM's
299e6f6c36cSEd Maste.Xr ld.lld 1
300e6f6c36cSEd Masteas the default linker, and
301e6f6c36cSEd MasteELF Tool Chain binary utilities such as
302ce0d5fb4SEd Maste.Xr objcopy 1
3034715c31eSEd Masteand
304ce0d5fb4SEd Maste.Xr readelf 1 .
305c81e4a69SWarner Losh.Ss MACHINE_ARCH vs MACHINE_CPUARCH vs MACHINE
3067b692b8eSWarner Losh.Dv MACHINE_CPUARCH
3077b692b8eSWarner Loshshould be preferred in Makefiles when the generic
3087b692b8eSWarner Losharchitecture is being tested.
3097b692b8eSWarner Losh.Dv MACHINE_ARCH
3107b692b8eSWarner Loshshould be preferred when there is something specific to a particular type of
3117b692b8eSWarner Losharchitecture where there is a choice of many, or could be a choice of many.
312c81e4a69SWarner LoshUse
313c81e4a69SWarner Losh.Dv MACHINE
314c81e4a69SWarner Loshwhen referring to the kernel, interfaces dependent on a specific type of kernel
315c81e4a69SWarner Loshor similar things like boot sequences.
3167b692b8eSWarner Losh.Bl -column -offset indent "Dv MACHINE" "Dv MACHINE_CPUARCH" "Dv MACHINE_ARCH"
3177b692b8eSWarner Losh.It Dv MACHINE Ta Dv MACHINE_CPUARCH Ta Dv MACHINE_ARCH
3187b692b8eSWarner Losh.It arm64 Ta aarch64 Ta aarch64
3197b692b8eSWarner Losh.It amd64 Ta amd64 Ta amd64
320bad7e1e8SWarner Losh.It arm Ta arm Ta armv6, armv7
3217b692b8eSWarner Losh.It i386 Ta i386 Ta i386
3227b692b8eSWarner Losh.It mips Ta mips Ta mips, mipsel, mips64, mips64el, mipshf, mipselhf, mips64elhf, mipsn32
3231bdb1aa4SBrandon Bergren.It powerpc Ta powerpc Ta powerpc, powerpcspe, powerpc64, powerpc64le
3247b692b8eSWarner Losh.It riscv Ta riscv Ta riscv64, riscv64sf
3257b692b8eSWarner Losh.El
326df9330b5SEd Maste.Ss Predefined Macros
327df9330b5SEd MasteThe compiler provides a number of predefined macros.
328df9330b5SEd MasteSome of these provide architecture-specific details and are explained below.
329df9330b5SEd MasteOther macros, including those required by the language standard, are not
330df9330b5SEd Masteincluded here.
331df9330b5SEd Maste.Pp
332df9330b5SEd MasteThe full set of predefined macros can be obtained with this command:
333df9330b5SEd Maste.Bd -literal -offset indent
3348e71e112SEd Mastecc -x c -dM -E /dev/null
335df9330b5SEd Maste.Ed
336df9330b5SEd Maste.Pp
337df9330b5SEd MasteCommon type size and endianness macros:
338ddc9d6e5SEd Maste.Bl -column -offset indent "BYTE_ORDER" "Meaning"
339df9330b5SEd Maste.It Sy Macro Ta Sy Meaning
340df9330b5SEd Maste.It Dv __LP64__ Ta 64-bit (8-byte) long and pointer, 32-bit (4-byte) int
341df9330b5SEd Maste.It Dv __ILP32__ Ta 32-bit (4-byte) int, long and pointer
342df9330b5SEd Maste.It Dv BYTE_ORDER Ta Either Dv BIG_ENDIAN or Dv LITTLE_ENDIAN .
3431859c867SKonstantin Belousov.Dv PDP11_ENDIAN
3441859c867SKonstantin Belousovis not used on
3451859c867SKonstantin Belousov.Fx .
346df9330b5SEd Maste.El
347df9330b5SEd Maste.Pp
348df9330b5SEd MasteArchitecture-specific macros:
349ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "Predefined macros"
350df9330b5SEd Maste.It Sy Architecture Ta Sy Predefined macros
351f38b2297SIan Lepore.It aarch64     Ta Dv __aarch64__
352df9330b5SEd Maste.It amd64       Ta Dv __amd64__ , Dv __x86_64__
353df9330b5SEd Maste.It armv6       Ta Dv __arm__ , Dv __ARM_ARCH >= 6
35413368c38SWarner Losh.It armv7       Ta Dv __arm__ , Dv __ARM_ARCH >= 7
355df9330b5SEd Maste.It i386        Ta Dv __i386__
356df9330b5SEd Maste.It mips        Ta Dv __mips__ , Dv __MIPSEB__ , Dv __mips_o32
357df9330b5SEd Maste.It mipsel      Ta Dv __mips__ , Dv __mips_o32
3585bca2215SRuslan Bukin.It mipselhf    Ta Dv __mips__ , Dv __mips_o32
3595bca2215SRuslan Bukin.It mipshf      Ta Dv __mips__ , Dv __MIPSEB__ , Dv __mips_o32
360df9330b5SEd Maste.It mipsn32     Ta Dv __mips__ , Dv __MIPSEB__ , Dv __mips_n32
361df9330b5SEd Maste.It mips64      Ta Dv __mips__ , Dv __MIPSEB__ , Dv __mips_n64
362df9330b5SEd Maste.It mips64el    Ta Dv __mips__ , Dv __mips_n64
3635bca2215SRuslan Bukin.It mips64elhf  Ta Dv __mips__ , Dv __mips_n64
3645bca2215SRuslan Bukin.It mips64hf    Ta Dv __mips__ , Dv __MIPSEB__ , Dv __mips_n64
365df9330b5SEd Maste.It powerpc     Ta Dv __powerpc__
366002cc1f9SJustin Hibbits.It powerpcspe  Ta Dv __powerpc__ , Dv __SPE__
367df9330b5SEd Maste.It powerpc64   Ta Dv __powerpc__ , Dv __powerpc64__
3681bdb1aa4SBrandon Bergren.It powerpc64le Ta Dv __powerpc__ , Dv __powerpc64__
369ca20f8ecSRuslan Bukin.It riscv64     Ta Dv __riscv , Dv __riscv_xlen == 64
370c4ef7cdbSMitchell Horne.It riscv64sf   Ta Dv __riscv , Dv __riscv_xlen == 64 , Dv __riscv_float_abi_soft
371df9330b5SEd Maste.El
372f84d8f0cSEd Maste.Pp
373f84d8f0cSEd MasteCompilers may define additional variants of architecture-specific macros.
374f84d8f0cSEd MasteThe macros above are preferred for use in
375f84d8f0cSEd Maste.Fx .
376691e6ea8SWarner Losh.Ss Important Xr make 1 variables
377691e6ea8SWarner LoshMost of the externally settable variables are defined in the
378691e6ea8SWarner Losh.Xr build 7
379691e6ea8SWarner Loshman page.
380691e6ea8SWarner LoshThese variables are not otherwise documented and are used extensively
381691e6ea8SWarner Loshin the build system.
38215d641f0SJohn Baldwin.Bl -tag -width "MACHINE_CPUARCH"
38315d641f0SJohn Baldwin.It Dv MACHINE
3842e4b206fSJohn BaldwinRepresents the hardware platform.
385691e6ea8SWarner LoshThis is the same as the native platform's
386691e6ea8SWarner Losh.Xr uname 1
387691e6ea8SWarner Losh.Fl m
388691e6ea8SWarner Loshoutput.
389691e6ea8SWarner LoshIt defines both the userland / kernel interface, as well as the
390691e6ea8SWarner Loshbootloader / kernel interface.
391691e6ea8SWarner LoshIt should only be used in these contexts.
392691e6ea8SWarner LoshEach CPU architecture may have multiple hardware platforms it supports
393691e6ea8SWarner Loshwhere
394691e6ea8SWarner Losh.Dv MACHINE
395691e6ea8SWarner Loshdiffers among them.
396691e6ea8SWarner LoshIt is used to collect together all the files from
397691e6ea8SWarner Losh.Xr config 8
398691e6ea8SWarner Loshto build the kernel.
399691e6ea8SWarner LoshIt is often the same as
400691e6ea8SWarner Losh.Dv MACHINE_ARCH
401691e6ea8SWarner Loshjust as one CPU architecture can be implemented by many different
402691e6ea8SWarner Loshhardware platforms, one hardware platform may support multiple CPU
403691e6ea8SWarner Losharchitecture family members, though with different binaries.
404691e6ea8SWarner LoshFor example,
405691e6ea8SWarner Losh.Dv MACHINE
406691e6ea8SWarner Loshof i386 supported the IBM-AT hardware platform while the
407691e6ea8SWarner Losh.Dv MACHINE
408691e6ea8SWarner Loshof pc98 supported the Japanese company NEC's PC-9801 and PC-9821
409691e6ea8SWarner Loshhardware platforms.
410691e6ea8SWarner LoshBoth of these hardware platforms supported only the
411691e6ea8SWarner Losh.Dv MACHINE_ARCH
412691e6ea8SWarner Loshof i386 where they shared a common ABI, except for certain kernel /
413691e6ea8SWarner Loshuserland interfaces relating to underlying hardware platform
414691e6ea8SWarner Loshdifferences in bus architecture, device enumeration and boot interface.
415ffab3cb6SWarner LoshGenerally,
416ffab3cb6SWarner Losh.Dv MACHINE
417ffab3cb6SWarner Loshshould only be used in src/sys and src/stand or in system imagers or
418ffab3cb6SWarner Loshinstallers.
41915d641f0SJohn Baldwin.It Dv MACHINE_ARCH
42015d641f0SJohn BaldwinRepresents the CPU processor architecture.
421691e6ea8SWarner LoshThis is the same as the native platforms
422691e6ea8SWarner Losh.Xr uname 1
423691e6ea8SWarner Losh.Fl p
424691e6ea8SWarner Loshoutput.
425691e6ea8SWarner LoshIt defines the CPU instruction family supported.
426691e6ea8SWarner LoshIt may also encode a variation in the byte ordering of multi-byte
427691e6ea8SWarner Loshintegers (endian).
428691e6ea8SWarner LoshIt may also encode a variation in the size of the integer or pointer.
429691e6ea8SWarner LoshIt may also encode a ISA revision.
430691e6ea8SWarner LoshIt may also encode hard versus soft floating point ABI and usage.
431320bd864SWarner LoshIt may also encode a variant ABI when the other factors do not
432320bd864SWarner Loshuniquely define the ABI (e.g., MIPS' n32 ABI).
433691e6ea8SWarner LoshIt, along with
434320bd864SWarner Losh.Dv MACHINE ,
435320bd864SWarner Loshdefines the ABI used by the system.
436691e6ea8SWarner LoshFor example, the MIPS CPU processor family supports 9 different
437098150fbSWarner Loshcombinations encoding pointer size, endian and hard versus soft float (for
438691e6ea8SWarner Losh8 combinations) as well as N32 (which only ever had one variation of
439691e6ea8SWarner Loshall these).
440691e6ea8SWarner LoshGenerally, the plain CPU name specifies the most common (or at least
441691e6ea8SWarner Loshfirst) variant of the CPU.
442bad7e1e8SWarner LoshThis is why mips and mips64 imply 'big endian' while 'armv6' and 'armv7'
443691e6ea8SWarner Loshimply little endian.
444691e6ea8SWarner LoshIf we ever were to support the so-called x32 ABI (using 32-bit
445691e6ea8SWarner Loshpointers on the amd64 architecture), it would most likely be encoded
446691e6ea8SWarner Loshas amd64-x32.
447d56b465cSJohn BaldwinIt is unfortunate that amd64 specifies the 64-bit evolution of the x86
448691e6ea8SWarner Loshplatform (it matches the 'first rule') as everybody else uses x86_64.
449691e6ea8SWarner LoshThere is no standard name for the processor: each OS selects its own
450691e6ea8SWarner Loshconventions.
45115d641f0SJohn Baldwin.It Dv MACHINE_CPUARCH
45215d641f0SJohn BaldwinRepresents the source location for a given
453ffab3cb6SWarner Losh.Dv MACHINE_ARCH .
4547b692b8eSWarner LoshIt is generally the common prefix for all the MACHINE_ARCH that
4557b692b8eSWarner Loshshare the same implementation, though 'riscv' breaks this rule.
456ffab3cb6SWarner LoshFor example,
457ffab3cb6SWarner Losh.Dv MACHINE_CPUARCH
458ffab3cb6SWarner Loshis defined to be mips for all the flavors of mips that we support
459ffab3cb6SWarner Loshsince we support them all with a shared set of sources.
460bf1dea9bSWarner LoshWhile amd64 and i386 are closely related, MACHINE_CPUARCH is not x86
461bf1dea9bSWarner Loshfor them.
46255ed6718SBenedict ReuschlingThe
46355ed6718SBenedict Reuschling.Fx
46455ed6718SBenedict Reuschlingsource base supports amd64 and i386 with two
465bf1dea9bSWarner Loshdistinct source bases living in subdirectories named amd64 and i386
466bf1dea9bSWarner Losh(though behind the scenes there's some sharing that fits into this
467bf1dea9bSWarner Loshframework).
46815d641f0SJohn Baldwin.It Dv CPUTYPE
46915d641f0SJohn BaldwinSets the flavor of
470691e6ea8SWarner Losh.Dv MACHINE_ARCH
471691e6ea8SWarner Loshto build.
472691e6ea8SWarner LoshIt is used to optimize the build for a specific CPU / core that the
473691e6ea8SWarner Loshbinaries run on.
474098150fbSWarner LoshGenerally, this does not change the ABI, though it can be a fine line
475691e6ea8SWarner Loshbetween optimization for specific cases.
47615d641f0SJohn Baldwin.It Dv TARGET
47715d641f0SJohn BaldwinUsed to set
478098150fbSWarner Losh.Dv MACHINE
479098150fbSWarner Loshin the top level Makefile for cross building.
480691e6ea8SWarner LoshUnused outside of that scope.
481691e6ea8SWarner LoshIt is not passed down to the rest of the build.
482098150fbSWarner LoshMakefiles outside of the top level should not use it at all (though
483691e6ea8SWarner Loshsome have their own private copy for hysterical raisons).
48415d641f0SJohn Baldwin.It Dv TARGET_ARCH
48515d641f0SJohn BaldwinUsed to set
486098150fbSWarner Losh.Dv MACHINE_ARCH
487098150fbSWarner Loshby the top level Makefile for cross building.
488691e6ea8SWarner LoshLike
48915d641f0SJohn Baldwin.Dv TARGET ,
49015d641f0SJohn Baldwinit is unused outside of that scope.
491691e6ea8SWarner Losh.El
492df9330b5SEd Maste.Sh SEE ALSO
493df9330b5SEd Maste.Xr src.conf 5 ,
494df9330b5SEd Maste.Xr build 7
495df9330b5SEd Maste.Sh HISTORY
496df9330b5SEd MasteAn
497df9330b5SEd Maste.Nm
498df9330b5SEd Mastemanual page appeared in
4992af3ea6bSEd Maste.Fx 11.1 .
500