Skip to content

[compiler-rt] Simplify and rename of operator_new_size_type #83912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler-rt/lib/sanitizer_common/sanitizer_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ inline u32 GetNumberOfCPUsCached() {

} // namespace __sanitizer

inline void *operator new(__sanitizer::operator_new_size_type size,
inline void *operator new(__sanitizer::usize size,
__sanitizer::LowLevelAllocator &alloc) {
return alloc.Allocate(size);
}
Expand Down
11 changes: 3 additions & 8 deletions compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,10 @@ typedef uptr OFF_T;
#endif
typedef u64 OFF64_T;

#if (SANITIZER_WORDSIZE == 64) || SANITIZER_APPLE
typedef uptr operator_new_size_type;
#ifdef __SIZE_TYPE__
typedef __SIZE_TYPE__ usize;
#else
# if defined(__s390__) && !defined(__s390x__)
// Special case: 31-bit s390 has unsigned long as size_t.
typedef unsigned long operator_new_size_type;
# else
typedef u32 operator_new_size_type;
# endif
typedef uptr usize;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it work for s390?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's correct: https://godbolt.org/z/rjnhWeW6v

#endif

typedef u64 tid_t;
Expand Down
4 changes: 1 addition & 3 deletions compiler-rt/lib/sanitizer_common/sanitizer_placement_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

#include "sanitizer_internal_defs.h"

inline void *operator new(__sanitizer::operator_new_size_type sz, void *p) {
return p;
}
inline void *operator new(__sanitizer::usize sz, void *p) { return p; }

#endif // SANITIZER_PLACEMENT_NEW_H