Move bionic_macros.h from private to platform.
Test: treehugger
Change-Id: Ie473914f4c8924c7240b3ac22093a9daf42fc948
diff --git a/libc/private/CFIShadow.h b/libc/private/CFIShadow.h
index 84fbea5..ec87e3c 100644
--- a/libc/private/CFIShadow.h
+++ b/libc/private/CFIShadow.h
@@ -20,7 +20,7 @@
#include <stdint.h>
#include "platform/bionic/page.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
constexpr unsigned kLibraryAlignmentBits = 18;
constexpr size_t kLibraryAlignment = 1UL << kLibraryAlignmentBits;
diff --git a/libc/private/ErrnoRestorer.h b/libc/private/ErrnoRestorer.h
index 52e115a..cecf103 100644
--- a/libc/private/ErrnoRestorer.h
+++ b/libc/private/ErrnoRestorer.h
@@ -18,7 +18,7 @@
#include <errno.h>
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
class ErrnoRestorer {
public:
diff --git a/libc/private/KernelArgumentBlock.h b/libc/private/KernelArgumentBlock.h
index c8ce841..ee28d69 100644
--- a/libc/private/KernelArgumentBlock.h
+++ b/libc/private/KernelArgumentBlock.h
@@ -21,7 +21,7 @@
#include <stdint.h>
#include <sys/auxv.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
// When the kernel starts the dynamic linker, it passes a pointer to a block
// of memory containing argc, the argv array, the environment variable array,
diff --git a/libc/private/MallocXmlElem.h b/libc/private/MallocXmlElem.h
index a367972..f8c72ab 100644
--- a/libc/private/MallocXmlElem.h
+++ b/libc/private/MallocXmlElem.h
@@ -20,7 +20,7 @@
#include <stdio.h>
#include <unistd.h>
-#include <private/bionic_macros.h>
+#include <platform/bionic/macros.h>
class MallocXmlElem {
public:
diff --git a/libc/private/ScopedFd.h b/libc/private/ScopedFd.h
index 1cec916..ea7f59e 100644
--- a/libc/private/ScopedFd.h
+++ b/libc/private/ScopedFd.h
@@ -30,7 +30,7 @@
#include <unistd.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "private/ErrnoRestorer.h"
class ScopedFd final {
diff --git a/libc/private/ScopedPthreadMutexLocker.h b/libc/private/ScopedPthreadMutexLocker.h
index 1c1e4a7..a87750c 100644
--- a/libc/private/ScopedPthreadMutexLocker.h
+++ b/libc/private/ScopedPthreadMutexLocker.h
@@ -18,7 +18,7 @@
#include <pthread.h>
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
class ScopedPthreadMutexLocker {
public:
diff --git a/libc/private/ScopedRWLock.h b/libc/private/ScopedRWLock.h
index f034505..0af372b 100644
--- a/libc/private/ScopedRWLock.h
+++ b/libc/private/ScopedRWLock.h
@@ -30,7 +30,7 @@
#include <pthread.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
template <bool write> class ScopedRWLock {
public:
diff --git a/libc/private/ScopedReaddir.h b/libc/private/ScopedReaddir.h
index 9a20c09..7b07921 100644
--- a/libc/private/ScopedReaddir.h
+++ b/libc/private/ScopedReaddir.h
@@ -18,7 +18,7 @@
#include <dirent.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
class ScopedReaddir {
public:
diff --git a/libc/private/ScopedSignalBlocker.h b/libc/private/ScopedSignalBlocker.h
index 10aacb3..ce0ae64 100644
--- a/libc/private/ScopedSignalBlocker.h
+++ b/libc/private/ScopedSignalBlocker.h
@@ -18,7 +18,7 @@
#include <signal.h>
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
class ScopedSignalBlocker {
public:
diff --git a/libc/private/WriteProtected.h b/libc/private/WriteProtected.h
index 26c239c..8f5b32d 100644
--- a/libc/private/WriteProtected.h
+++ b/libc/private/WriteProtected.h
@@ -24,7 +24,7 @@
#include <async_safe/log.h>
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
template <typename T>
union WriteProtectedContents {
diff --git a/libc/private/bionic_lock.h b/libc/private/bionic_lock.h
index d70ba6c..8ed4939 100644
--- a/libc/private/bionic_lock.h
+++ b/libc/private/bionic_lock.h
@@ -30,7 +30,7 @@
#include <stdatomic.h>
#include "private/bionic_futex.h"
-#include "private/bionic_macros.h"
+#include "platform/bionic/macros.h"
// Lock is used in places like pthread_rwlock_t, which can be initialized without calling
// an initialization function. So make sure Lock can be initialized by setting its memory to 0.
diff --git a/libc/private/bionic_macros.h b/libc/private/bionic_macros.h
deleted file mode 100644
index 54903f5..0000000
--- a/libc/private/bionic_macros.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <stdint.h>
-
-#define BIONIC_DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&) = delete; \
- void operator=(const TypeName&) = delete
-
-#define BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
- TypeName() = delete; \
- BIONIC_DISALLOW_COPY_AND_ASSIGN(TypeName)
-
-#define BIONIC_ROUND_UP_POWER_OF_2(value) \
- ((sizeof(value) == 8) \
- ? (1UL << (64 - __builtin_clzl(static_cast<unsigned long>(value)))) \
- : (1UL << (32 - __builtin_clz(static_cast<unsigned int>(value)))))
-
-static constexpr uintptr_t align_down(uintptr_t p, size_t align) {
- return p & ~(align - 1);
-}
-
-static constexpr uintptr_t align_up(uintptr_t p, size_t align) {
- return (p + align - 1) & ~(align - 1);
-}
-
-template <typename T>
-static inline T* align_down(T* p, size_t align) {
- return reinterpret_cast<T*>(align_down(reinterpret_cast<uintptr_t>(p), align));
-}
-
-template <typename T>
-static inline T* align_up(T* p, size_t align) {
- return reinterpret_cast<T*>(align_up(reinterpret_cast<uintptr_t>(p), align));
-}
-
-#if defined(__arm__)
-#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined r14")
-#elif defined(__aarch64__)
-#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined x30")
-#elif defined(__i386__)
-#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined \%eip")
-#elif defined(__x86_64__)
-#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined \%rip")
-#elif defined (__mips__)
-#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined $ra")
-#endif
-
-// The arraysize(arr) macro returns the # of elements in an array arr.
-// The expression is a compile-time constant, and therefore can be
-// used in defining new arrays, for example. If you use arraysize on
-// a pointer by mistake, you will get a compile-time error.
-//
-// One caveat is that arraysize() doesn't accept any array of an
-// anonymous type or a type defined inside a function.
-//
-// This template function declaration is used in defining arraysize.
-// Note that the function doesn't need an implementation, as we only
-// use its type.
-template <typename T, size_t N>
-char (&ArraySizeHelper(T (&array)[N]))[N]; // NOLINT(readability/casting)
-
-#define arraysize(array) (sizeof(ArraySizeHelper(array)))
-
-// Used to inform clang's -Wimplicit-fallthrough that a fallthrough is intended. There's no way to
-// silence (or enable, apparently) -Wimplicit-fallthrough in C yet.
-#ifdef __cplusplus
-#define __BIONIC_FALLTHROUGH [[clang::fallthrough]]
-#else
-#define __BIONIC_FALLTHROUGH
-#endif
-
-template <typename T>
-static inline T* untag_address(T* p) {
-#if defined(__aarch64__)
- return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(p) & ((1ULL << 56) - 1));
-#else
- return p;
-#endif
-}
diff --git a/libc/private/bionic_systrace.h b/libc/private/bionic_systrace.h
index 86d2a08..dbe1739 100644
--- a/libc/private/bionic_systrace.h
+++ b/libc/private/bionic_systrace.h
@@ -16,7 +16,7 @@
#pragma once
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
// Tracing class for bionic. To begin a trace at a specified point:
// ScopedTrace("Trace message");
diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h
index 9a80140..bb5c67b 100644
--- a/libc/private/bionic_tls.h
+++ b/libc/private/bionic_tls.h
@@ -36,7 +36,7 @@
#include <platform/bionic/tls.h>
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
#include "grp_pwd.h"
/** WARNING WARNING WARNING
diff --git a/libc/private/sigrtmin.h b/libc/private/sigrtmin.h
index 5de1a32..af73280 100644
--- a/libc/private/sigrtmin.h
+++ b/libc/private/sigrtmin.h
@@ -32,7 +32,7 @@
#include <signal.h>
-#include "bionic_macros.h"
+#include "platform/bionic/macros.h"
// Realtime signals reserved for internal use:
// 32 (__SIGRTMIN + 0) POSIX timers