Clean up bionic_macros.h a bit.
Use <android-base/macros.h> instead where possible, and move the bionic
macros out of the way of the libbase ones. Yes, there are folks who manage
to end up with both included at once (thanks OpenGL!), and cleaning that
up doesn't seem nearly as practical as just making this change.
Bug: N/A
Test: builds
Change-Id: I23fc544f39d5addf81dc61471771a5438778895b
diff --git a/libc/private/ErrnoRestorer.h b/libc/private/ErrnoRestorer.h
index f467393..52e115a 100644
--- a/libc/private/ErrnoRestorer.h
+++ b/libc/private/ErrnoRestorer.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef ERRNO_RESTORER_H
-#define ERRNO_RESTORER_H
+#pragma once
#include <errno.h>
@@ -37,7 +36,5 @@
private:
int saved_errno_;
- DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
};
-
-#endif // ERRNO_RESTORER_H
diff --git a/libc/private/KernelArgumentBlock.h b/libc/private/KernelArgumentBlock.h
index e05ceb9..886dd32 100644
--- a/libc/private/KernelArgumentBlock.h
+++ b/libc/private/KernelArgumentBlock.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef KERNEL_ARGUMENT_BLOCK_H
-#define KERNEL_ARGUMENT_BLOCK_H
+#pragma once
#include <elf.h>
#include <link.h>
@@ -71,7 +70,5 @@
libc_shared_globals* shared_globals;
private:
- DISALLOW_COPY_AND_ASSIGN(KernelArgumentBlock);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(KernelArgumentBlock);
};
-
-#endif // KERNEL_ARGUMENT_BLOCK_H
diff --git a/libc/private/ScopedPthreadMutexLocker.h b/libc/private/ScopedPthreadMutexLocker.h
index 58462e3..1c1e4a7 100644
--- a/libc/private/ScopedPthreadMutexLocker.h
+++ b/libc/private/ScopedPthreadMutexLocker.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef SCOPED_PTHREAD_MUTEX_LOCKER_H
-#define SCOPED_PTHREAD_MUTEX_LOCKER_H
+#pragma once
#include <pthread.h>
@@ -34,7 +33,5 @@
private:
pthread_mutex_t* mu_;
- DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedPthreadMutexLocker);
+ BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedPthreadMutexLocker);
};
-
-#endif // SCOPED_PTHREAD_MUTEX_LOCKER_H
diff --git a/libc/private/ScopedReaddir.h b/libc/private/ScopedReaddir.h
index 1a59e1a..dc22309 100644
--- a/libc/private/ScopedReaddir.h
+++ b/libc/private/ScopedReaddir.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef SCOPED_READDIR_H
-#define SCOPED_READDIR_H
+#pragma once
#include <dirent.h>
@@ -47,7 +46,5 @@
private:
DIR* dir_;
- DISALLOW_COPY_AND_ASSIGN(ScopedReaddir);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(ScopedReaddir);
};
-
-#endif // SCOPED_READDIR_H
diff --git a/libc/private/ScopedSignalBlocker.h b/libc/private/ScopedSignalBlocker.h
index d1cf629..10aacb3 100644
--- a/libc/private/ScopedSignalBlocker.h
+++ b/libc/private/ScopedSignalBlocker.h
@@ -46,5 +46,5 @@
sigset64_t old_set_;
- DISALLOW_COPY_AND_ASSIGN(ScopedSignalBlocker);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(ScopedSignalBlocker);
};
diff --git a/libc/private/WriteProtected.h b/libc/private/WriteProtected.h
index 7a6b098..69a6822 100644
--- a/libc/private/WriteProtected.h
+++ b/libc/private/WriteProtected.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef _PRIVATE_WRITEPROTECTED_H
-#define _PRIVATE_WRITEPROTECTED_H
+#pragma once
#include <errno.h>
#include <string.h>
@@ -33,7 +32,7 @@
char padding[PAGE_SIZE];
WriteProtectedContents() = default;
- DISALLOW_COPY_AND_ASSIGN(WriteProtectedContents);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(WriteProtectedContents);
} __attribute__((aligned(PAGE_SIZE)));
// Write protected wrapper class that aligns its contents to a page boundary,
@@ -49,7 +48,7 @@
public:
WriteProtected() = default;
- DISALLOW_COPY_AND_ASSIGN(WriteProtected);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(WriteProtected);
void initialize() {
// Not strictly necessary, but this will hopefully segfault if we initialize
@@ -82,5 +81,3 @@
}
}
};
-
-#endif
diff --git a/libc/private/bionic_lock.h b/libc/private/bionic_lock.h
index 54168d3..eebfeff 100644
--- a/libc/private/bionic_lock.h
+++ b/libc/private/bionic_lock.h
@@ -25,8 +25,8 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#ifndef _BIONIC_LOCK_H
-#define _BIONIC_LOCK_H
+
+#pragma once
#include <stdatomic.h>
#include "private/bionic_futex.h"
@@ -85,10 +85,8 @@
lock_.unlock();
}
- DISALLOW_COPY_AND_ASSIGN(LockGuard);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(LockGuard);
private:
Lock& lock_;
};
-
-#endif // _BIONIC_LOCK_H
diff --git a/libc/private/bionic_macros.h b/libc/private/bionic_macros.h
index 0a36cdb..4800e3a 100644
--- a/libc/private/bionic_macros.h
+++ b/libc/private/bionic_macros.h
@@ -14,31 +14,17 @@
* limitations under the License.
*/
-#ifndef _BIONIC_MACROS_H_
-#define _BIONIC_MACROS_H_
+#pragma once
#include <stdint.h>
-// Frameworks OpenGL code currently leaks this header and allows
-// collisions with other declarations, e.g., from libnativehelper.
-// TODO: Remove once cleaned up. b/18334516
-#if !defined(DISALLOW_COPY_AND_ASSIGN)
-// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions.
-// It goes in the private: declarations in a class.
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&) = delete; \
+#define BIONIC_DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete
-#endif // !defined(DISALLOW_COPY_AND_ASSIGN)
-// A macro to disallow all the implicit constructors, namely the
-// default constructor, copy constructor and operator= functions.
-//
-// This should be used in the private: declarations for a class
-// that wants to prevent anyone from instantiating it. This is
-// especially useful for classes containing only static methods.
-#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
- TypeName() = delete; \
- DISALLOW_COPY_AND_ASSIGN(TypeName)
+#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) \
@@ -101,5 +87,3 @@
#else
#define __BIONIC_FALLTHROUGH
#endif
-
-#endif // _BIONIC_MACROS_H_
diff --git a/libc/private/bionic_systrace.h b/libc/private/bionic_systrace.h
index 304fb80..86d2a08 100644
--- a/libc/private/bionic_systrace.h
+++ b/libc/private/bionic_systrace.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef BIONIC_SYSTRACE_H
-#define BIONIC_SYSTRACE_H
+#pragma once
#include "bionic_macros.h"
@@ -31,10 +30,8 @@
void End();
private:
bool called_end_;
- DISALLOW_COPY_AND_ASSIGN(ScopedTrace);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(ScopedTrace);
};
void bionic_trace_begin(const char* message);
void bionic_trace_end();
-
-#endif