Skip to content

Commit 36b5c58

Browse files
authored
Rollup merge of #136173 - taiki-e:c-char, r=tgross35
Update comments and sort target_arch in c_char_definition Follow-up to #132975. - Clang's wrong default on MSP430 has been fixed in llvm/llvm-project#115964, and will be included in LLVM 20, which will be used soon. - Add a reference on Xtensa's default (from #132975 (comment)). - Fix link for Windows's default. - Add a link to the discussion on L4Re (#132975 (comment)) - Sort `target_arch`. (now match with `target_arch`s in comments) r? `@tgross35`
2 parents 995eb5c + ea70688 commit 36b5c58

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Diff for: library/core/src/ffi/mod.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ mod c_char_definition {
116116
// Section 2.1 "Basic Types" in MSP430 Embedded Application Binary
117117
// Interface says "The char type is unsigned by default".
118118
// https://www.ti.com/lit/an/slaa534a/slaa534a.pdf
119-
// Note: this doesn't seem to match Clang's default (https://github.com/rust-lang/rust/issues/129945).
120119
// powerpc/powerpc64:
121120
// - PPC32 SysV: "Table 3-1 Scalar Types" in System V Application Binary Interface PowerPC
122121
// Processor Supplement says ANSI C char is unsigned byte
@@ -139,8 +138,10 @@ mod c_char_definition {
139138
// https://github.com/IBM/s390x-abi/releases/tag/v1.6.1
140139
// - z/OS: XL C/C++ Language Reference says: "By default, char behaves like an unsigned char."
141140
// https://www.ibm.com/docs/en/zos/3.1.0?topic=specifiers-character-types
142-
// Xtensa:
143-
// - "The char type is unsigned by default for Xtensa processors."
141+
// xtensa:
142+
// Section 2.17.1 "Data Types and Alignment" of Xtensa LX Microprocessor Overview handbook
143+
// says "`char` type is unsigned by default".
144+
// https://loboris.eu/ESP32/Xtensa_lx%20Overview%20handbook.pdf
144145
//
145146
// On the following operating systems, c_char is signed by default, regardless of architecture.
146147
// Darwin (macOS, iOS, etc.):
@@ -150,11 +151,12 @@ mod c_char_definition {
150151
// Windows MSVC C++ Language Reference says "Microsoft-specific: Variables of type char
151152
// are promoted to int as if from type signed char by default, unless the /J compilation
152153
// option is used."
153-
// https://learn.microsoft.com/en-us/cpp/cpp/fundamental-types-cpp?view=msvc-170#character-types)
154-
// L4RE:
154+
// https://learn.microsoft.com/en-us/cpp/cpp/fundamental-types-cpp?view=msvc-170#character-types
155+
// L4Re:
155156
// The kernel builds with -funsigned-char on all targets (but useserspace follows the
156157
// architecture defaults). As we only have a target for userspace apps so there are no
157-
// special cases for L4RE below.
158+
// special cases for L4Re below.
159+
// https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240
158160
if #[cfg(all(
159161
not(windows),
160162
not(target_vendor = "apple"),
@@ -166,8 +168,8 @@ mod c_char_definition {
166168
target_arch = "msp430",
167169
target_arch = "powerpc",
168170
target_arch = "powerpc64",
169-
target_arch = "riscv64",
170171
target_arch = "riscv32",
172+
target_arch = "riscv64",
171173
target_arch = "s390x",
172174
target_arch = "xtensa",
173175
)

0 commit comments

Comments
 (0)