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/bionic/grp_pwd_file.h b/libc/bionic/grp_pwd_file.h
index 29d75f4..9004c4e 100644
--- a/libc/bionic/grp_pwd_file.h
+++ b/libc/bionic/grp_pwd_file.h
@@ -45,7 +45,7 @@
bool FindByName(const char* name, Line* line);
void Unmap();
- DISALLOW_COPY_AND_ASSIGN(MmapFile);
+ BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(MmapFile);
private:
enum class FileStatus {
@@ -78,7 +78,7 @@
mmap_file_.Unmap();
}
- DISALLOW_COPY_AND_ASSIGN(PasswdFile);
+ BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(PasswdFile);
private:
MmapFile mmap_file_;
@@ -94,7 +94,7 @@
mmap_file_.Unmap();
}
- DISALLOW_COPY_AND_ASSIGN(GroupFile);
+ BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(GroupFile);
private:
MmapFile mmap_file_;
diff --git a/libc/bionic/locale.cpp b/libc/bionic/locale.cpp
index 2a5bcab..8358fb0 100644
--- a/libc/bionic/locale.cpp
+++ b/libc/bionic/locale.cpp
@@ -66,7 +66,7 @@
}
}
- DISALLOW_COPY_AND_ASSIGN(__locale_t);
+ BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(__locale_t);
};
size_t __ctype_get_mb_cur_max() {
diff --git a/libc/bionic/malloc_info.cpp b/libc/bionic/malloc_info.cpp
index 99caedb..9c8a4bf 100644
--- a/libc/bionic/malloc_info.cpp
+++ b/libc/bionic/malloc_info.cpp
@@ -53,7 +53,7 @@
FILE* fp;
const char* name;
- DISALLOW_COPY_AND_ASSIGN(Elem);
+ BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(Elem);
};
int malloc_info(int options, FILE* fp) {
diff --git a/libc/bionic/pthread_atfork.cpp b/libc/bionic/pthread_atfork.cpp
index 84e511c..fb12a3b 100644
--- a/libc/bionic/pthread_atfork.cpp
+++ b/libc/bionic/pthread_atfork.cpp
@@ -107,7 +107,7 @@
atfork_t* first_;
atfork_t* last_;
- DISALLOW_COPY_AND_ASSIGN(atfork_list_t);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(atfork_list_t);
};
static pthread_mutex_t g_atfork_list_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
@@ -180,4 +180,3 @@
});
pthread_mutex_unlock(&g_atfork_list_mutex);
}
-
diff --git a/libc/bionic/pthread_internal.cpp b/libc/bionic/pthread_internal.cpp
index 829194c..92786fe 100644
--- a/libc/bionic/pthread_internal.cpp
+++ b/libc/bionic/pthread_internal.cpp
@@ -54,7 +54,7 @@
private:
pthread_rwlock_t* rwlock_;
- DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedRWLock);
+ BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedRWLock);
};
typedef ScopedRWLock<true> ScopedWriteLock;
diff --git a/libc/bionic/scandir.cpp b/libc/bionic/scandir.cpp
index e55be42..0b39049 100644
--- a/libc/bionic/scandir.cpp
+++ b/libc/bionic/scandir.cpp
@@ -90,7 +90,7 @@
return copy;
}
- DISALLOW_COPY_AND_ASSIGN(ScandirResult);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(ScandirResult);
};
int scandirat(int parent_fd, const char* dir_name, dirent*** name_list,
diff --git a/libc/bionic/system_property_set.cpp b/libc/bionic/system_property_set.cpp
index a70a376..bc3ba76 100644
--- a/libc/bionic/system_property_set.cpp
+++ b/libc/bionic/system_property_set.cpp
@@ -170,7 +170,7 @@
uint32_t uint_buf_[kUintBufSize];
size_t uint_buf_index_;
- DISALLOW_IMPLICIT_CONSTRUCTORS(SocketWriter);
+ BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(SocketWriter);
};
struct prop_msg {
diff --git a/libc/malloc_debug/DebugData.h b/libc/malloc_debug/DebugData.h
index f7cf8ab..3a36299 100644
--- a/libc/malloc_debug/DebugData.h
+++ b/libc/malloc_debug/DebugData.h
@@ -94,7 +94,7 @@
Config config_;
- DISALLOW_COPY_AND_ASSIGN(DebugData);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(DebugData);
};
extern DebugData* g_debug;
diff --git a/libc/malloc_debug/GuardData.h b/libc/malloc_debug/GuardData.h
index 7b21671..b6ec889 100644
--- a/libc/malloc_debug/GuardData.h
+++ b/libc/malloc_debug/GuardData.h
@@ -56,7 +56,7 @@
virtual const char* GetTypeName() = 0;
- DISALLOW_COPY_AND_ASSIGN(GuardData);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(GuardData);
};
class FrontGuardData : public GuardData {
@@ -75,7 +75,7 @@
size_t offset_ = 0;
- DISALLOW_COPY_AND_ASSIGN(FrontGuardData);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(FrontGuardData);
};
class RearGuardData : public GuardData {
@@ -90,5 +90,5 @@
private:
const char* GetTypeName() override { return "REAR"; }
- DISALLOW_COPY_AND_ASSIGN(RearGuardData);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(RearGuardData);
};
diff --git a/libc/malloc_debug/MapData.h b/libc/malloc_debug/MapData.h
index d8398bd..b9b697c 100644
--- a/libc/malloc_debug/MapData.h
+++ b/libc/malloc_debug/MapData.h
@@ -68,5 +68,5 @@
std::mutex m_;
std::set<MapEntry*, compare_entries> entries_;
- DISALLOW_COPY_AND_ASSIGN(MapData);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(MapData);
};
diff --git a/libc/malloc_debug/OptionData.h b/libc/malloc_debug/OptionData.h
index 3fa8e14..8fb13a4 100644
--- a/libc/malloc_debug/OptionData.h
+++ b/libc/malloc_debug/OptionData.h
@@ -39,5 +39,5 @@
protected:
DebugData* debug_;
- DISALLOW_COPY_AND_ASSIGN(OptionData);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(OptionData);
};
diff --git a/libc/malloc_debug/PointerData.h b/libc/malloc_debug/PointerData.h
index 62d4186..b05a763 100644
--- a/libc/malloc_debug/PointerData.h
+++ b/libc/malloc_debug/PointerData.h
@@ -184,5 +184,5 @@
static std::mutex free_pointer_mutex_;
static std::deque<FreePointerInfoType> free_pointers_;
- DISALLOW_COPY_AND_ASSIGN(PointerData);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(PointerData);
};
diff --git a/libc/malloc_debug/RecordData.h b/libc/malloc_debug/RecordData.h
index 3e5ca02..a015882 100644
--- a/libc/malloc_debug/RecordData.h
+++ b/libc/malloc_debug/RecordData.h
@@ -49,7 +49,7 @@
pid_t tid_;
private:
- DISALLOW_COPY_AND_ASSIGN(RecordEntry);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(RecordEntry);
};
class ThreadCompleteEntry : public RecordEntry {
@@ -60,7 +60,7 @@
std::string GetString() const override;
private:
- DISALLOW_COPY_AND_ASSIGN(ThreadCompleteEntry);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(ThreadCompleteEntry);
};
class AllocEntry : public RecordEntry {
@@ -72,7 +72,7 @@
void* pointer_;
private:
- DISALLOW_COPY_AND_ASSIGN(AllocEntry);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(AllocEntry);
};
class MallocEntry : public AllocEntry {
@@ -86,7 +86,7 @@
size_t size_;
private:
- DISALLOW_COPY_AND_ASSIGN(MallocEntry);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(MallocEntry);
};
class FreeEntry : public AllocEntry {
@@ -97,7 +97,7 @@
std::string GetString() const override;
private:
- DISALLOW_COPY_AND_ASSIGN(FreeEntry);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(FreeEntry);
};
class CallocEntry : public MallocEntry {
@@ -111,7 +111,7 @@
size_t nmemb_;
private:
- DISALLOW_COPY_AND_ASSIGN(CallocEntry);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(CallocEntry);
};
class ReallocEntry : public MallocEntry {
@@ -125,7 +125,7 @@
void* old_pointer_;
private:
- DISALLOW_COPY_AND_ASSIGN(ReallocEntry);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(ReallocEntry);
};
// aligned_alloc, posix_memalign, memalign, pvalloc, valloc all recorded with this class.
@@ -140,7 +140,7 @@
size_t alignment_;
private:
- DISALLOW_COPY_AND_ASSIGN(MemalignEntry);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(MemalignEntry);
};
class Config;
@@ -170,5 +170,5 @@
std::atomic_bool dump_;
std::string dump_file_;
- DISALLOW_COPY_AND_ASSIGN(RecordData);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(RecordData);
};
diff --git a/libc/malloc_debug/debug_disable.h b/libc/malloc_debug/debug_disable.h
index 0049595..f9c3149 100644
--- a/libc/malloc_debug/debug_disable.h
+++ b/libc/malloc_debug/debug_disable.h
@@ -57,5 +57,5 @@
private:
bool disabled_;
- DISALLOW_COPY_AND_ASSIGN(ScopedDisableDebugCalls);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(ScopedDisableDebugCalls);
};
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
diff --git a/libc/system_properties/include/system_properties/context_node.h b/libc/system_properties/include/system_properties/context_node.h
index 35d0e92..20f4013 100644
--- a/libc/system_properties/include/system_properties/context_node.h
+++ b/libc/system_properties/include/system_properties/context_node.h
@@ -42,7 +42,7 @@
Unmap();
}
- DISALLOW_COPY_AND_ASSIGN(ContextNode);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(ContextNode);
bool Open(bool access_rw, bool* fsetxattr_failed);
bool CheckAccessAndOpen();
diff --git a/libc/system_properties/include/system_properties/prop_area.h b/libc/system_properties/include/system_properties/prop_area.h
index 2c25337..a69f90e 100644
--- a/libc/system_properties/include/system_properties/prop_area.h
+++ b/libc/system_properties/include/system_properties/prop_area.h
@@ -86,7 +86,7 @@
}
private:
- DISALLOW_COPY_AND_ASSIGN(prop_bt);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(prop_bt);
};
class prop_area {
@@ -158,5 +158,5 @@
uint32_t reserved_[28];
char data_[0];
- DISALLOW_COPY_AND_ASSIGN(prop_area);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(prop_area);
};
diff --git a/libc/system_properties/include/system_properties/prop_info.h b/libc/system_properties/include/system_properties/prop_info.h
index a127550..27b29c8 100644
--- a/libc/system_properties/include/system_properties/prop_info.h
+++ b/libc/system_properties/include/system_properties/prop_info.h
@@ -83,7 +83,7 @@
prop_info(const char* name, uint32_t namelen, uint32_t long_offset);
private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(prop_info);
+ BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(prop_info);
};
static_assert(sizeof(prop_info) == 96, "sizeof struct prop_info must be 96 bytes");
diff --git a/libc/system_properties/include/system_properties/system_properties.h b/libc/system_properties/include/system_properties/system_properties.h
index 52ffcaf..cad29cc 100644
--- a/libc/system_properties/include/system_properties/system_properties.h
+++ b/libc/system_properties/include/system_properties/system_properties.h
@@ -52,7 +52,7 @@
explicit SystemProperties(bool initialized) : initialized_(initialized) {
}
- DISALLOW_COPY_AND_ASSIGN(SystemProperties);
+ BIONIC_DISALLOW_COPY_AND_ASSIGN(SystemProperties);
bool Init(const char* filename);
bool AreaInit(const char* filename, bool* fsetxattr_failed);