Skip to content

Commit 82f1967

Browse files
authored
[libc] Update size_t and ssize_t definitions to use __SIZE_TYPE__ and __PTRDIFF_TYPE__ respectively. (#143921)
The current definition of `ssize_t` does not have the same bit width as `size_t` on 32-bit platforms.
1 parent 53e5047 commit 82f1967

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

libc/include/llvm-libc-types/size_t.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
#ifndef LLVM_LIBC_TYPES_SIZE_T_H
1010
#define LLVM_LIBC_TYPES_SIZE_T_H
1111

12-
// Since __need_size_t is defined, we get the definition of size_t from the
13-
// standalone C header stddef.h. Also, because __need_size_t is defined,
14-
// including stddef.h will pull only the type size_t and nothing else.
15-
#define __need_size_t
16-
#include <stddef.h>
17-
#undef __need_size_t
12+
typedef __SIZE_TYPE__ size_t;
1813

1914
#endif // LLVM_LIBC_TYPES_SIZE_T_H

libc/include/llvm-libc-types/ssize_t.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
#ifndef LLVM_LIBC_TYPES_SSIZE_T_H
1010
#define LLVM_LIBC_TYPES_SSIZE_T_H
1111

12-
typedef __INT64_TYPE__ ssize_t;
12+
typedef __PTRDIFF_TYPE__ ssize_t;
1313

1414
#endif // LLVM_LIBC_TYPES_SSIZE_T_H

0 commit comments

Comments
 (0)