Merge "Clean up bionic_macros.h a bit."

This commit is contained in:
Elliott Hughes 2018-10-26 00:09:15 +00:00 committed by Gerrit Code Review
commit 04164f6d05
36 changed files with 68 additions and 99 deletions

View file

@ -45,7 +45,7 @@ class MmapFile {
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 @@ class PasswdFile {
mmap_file_.Unmap();
}
DISALLOW_COPY_AND_ASSIGN(PasswdFile);
BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(PasswdFile);
private:
MmapFile mmap_file_;
@ -94,7 +94,7 @@ class GroupFile {
mmap_file_.Unmap();
}
DISALLOW_COPY_AND_ASSIGN(GroupFile);
BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(GroupFile);
private:
MmapFile mmap_file_;

View file

@ -66,7 +66,7 @@ struct __locale_t {
}
}
DISALLOW_COPY_AND_ASSIGN(__locale_t);
BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(__locale_t);
};
size_t __ctype_get_mb_cur_max() {

View file

@ -53,7 +53,7 @@ private:
FILE* fp;
const char* name;
DISALLOW_COPY_AND_ASSIGN(Elem);
BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(Elem);
};
int malloc_info(int options, FILE* fp) {

View file

@ -107,7 +107,7 @@ class atfork_list_t {
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 @@ extern "C" __LIBC_HIDDEN__ void __unregister_atfork(void* dso) {
});
pthread_mutex_unlock(&g_atfork_list_mutex);
}

View file

@ -54,7 +54,7 @@ template <bool write> class ScopedRWLock {
private:
pthread_rwlock_t* rwlock_;
DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedRWLock);
BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedRWLock);
};
typedef ScopedRWLock<true> ScopedWriteLock;

View file

@ -90,7 +90,7 @@ class ScandirResult {
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,

View file

@ -170,7 +170,7 @@ class SocketWriter {
uint32_t uint_buf_[kUintBufSize];
size_t uint_buf_index_;
DISALLOW_IMPLICIT_CONSTRUCTORS(SocketWriter);
BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(SocketWriter);
};
struct prop_msg {

View file

@ -94,7 +94,7 @@ class DebugData {
Config config_;
DISALLOW_COPY_AND_ASSIGN(DebugData);
BIONIC_DISALLOW_COPY_AND_ASSIGN(DebugData);
};
extern DebugData* g_debug;

View file

@ -56,7 +56,7 @@ class GuardData : public OptionData {
virtual const char* GetTypeName() = 0;
DISALLOW_COPY_AND_ASSIGN(GuardData);
BIONIC_DISALLOW_COPY_AND_ASSIGN(GuardData);
};
class FrontGuardData : public GuardData {
@ -75,7 +75,7 @@ class FrontGuardData : public GuardData {
size_t offset_ = 0;
DISALLOW_COPY_AND_ASSIGN(FrontGuardData);
BIONIC_DISALLOW_COPY_AND_ASSIGN(FrontGuardData);
};
class RearGuardData : public GuardData {
@ -90,5 +90,5 @@ class RearGuardData : public GuardData {
private:
const char* GetTypeName() override { return "REAR"; }
DISALLOW_COPY_AND_ASSIGN(RearGuardData);
BIONIC_DISALLOW_COPY_AND_ASSIGN(RearGuardData);
};

View file

@ -68,5 +68,5 @@ class MapData {
std::mutex m_;
std::set<MapEntry*, compare_entries> entries_;
DISALLOW_COPY_AND_ASSIGN(MapData);
BIONIC_DISALLOW_COPY_AND_ASSIGN(MapData);
};

View file

@ -39,5 +39,5 @@ class OptionData {
protected:
DebugData* debug_;
DISALLOW_COPY_AND_ASSIGN(OptionData);
BIONIC_DISALLOW_COPY_AND_ASSIGN(OptionData);
};

View file

@ -184,5 +184,5 @@ class PointerData : public OptionData {
static std::mutex free_pointer_mutex_;
static std::deque<FreePointerInfoType> free_pointers_;
DISALLOW_COPY_AND_ASSIGN(PointerData);
BIONIC_DISALLOW_COPY_AND_ASSIGN(PointerData);
};

View file

@ -49,7 +49,7 @@ class RecordEntry {
pid_t tid_;
private:
DISALLOW_COPY_AND_ASSIGN(RecordEntry);
BIONIC_DISALLOW_COPY_AND_ASSIGN(RecordEntry);
};
class ThreadCompleteEntry : public RecordEntry {
@ -60,7 +60,7 @@ class ThreadCompleteEntry : public RecordEntry {
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 @@ class AllocEntry : public RecordEntry {
void* pointer_;
private:
DISALLOW_COPY_AND_ASSIGN(AllocEntry);
BIONIC_DISALLOW_COPY_AND_ASSIGN(AllocEntry);
};
class MallocEntry : public AllocEntry {
@ -86,7 +86,7 @@ class MallocEntry : public AllocEntry {
size_t size_;
private:
DISALLOW_COPY_AND_ASSIGN(MallocEntry);
BIONIC_DISALLOW_COPY_AND_ASSIGN(MallocEntry);
};
class FreeEntry : public AllocEntry {
@ -97,7 +97,7 @@ class FreeEntry : public AllocEntry {
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 @@ class CallocEntry : public MallocEntry {
size_t nmemb_;
private:
DISALLOW_COPY_AND_ASSIGN(CallocEntry);
BIONIC_DISALLOW_COPY_AND_ASSIGN(CallocEntry);
};
class ReallocEntry : public MallocEntry {
@ -125,7 +125,7 @@ class ReallocEntry : public MallocEntry {
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 @@ class MemalignEntry : public MallocEntry {
size_t alignment_;
private:
DISALLOW_COPY_AND_ASSIGN(MemalignEntry);
BIONIC_DISALLOW_COPY_AND_ASSIGN(MemalignEntry);
};
class Config;
@ -170,5 +170,5 @@ class RecordData {
std::atomic_bool dump_;
std::string dump_file_;
DISALLOW_COPY_AND_ASSIGN(RecordData);
BIONIC_DISALLOW_COPY_AND_ASSIGN(RecordData);
};

View file

@ -57,5 +57,5 @@ class ScopedDisableDebugCalls {
private:
bool disabled_;
DISALLOW_COPY_AND_ASSIGN(ScopedDisableDebugCalls);
BIONIC_DISALLOW_COPY_AND_ASSIGN(ScopedDisableDebugCalls);
};

View file

@ -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 @@ class ErrnoRestorer {
private:
int saved_errno_;
DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
BIONIC_DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
};
#endif // ERRNO_RESTORER_H

View file

@ -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 @@ class KernelArgumentBlock {
libc_shared_globals* shared_globals;
private:
DISALLOW_COPY_AND_ASSIGN(KernelArgumentBlock);
BIONIC_DISALLOW_COPY_AND_ASSIGN(KernelArgumentBlock);
};
#endif // KERNEL_ARGUMENT_BLOCK_H

View file

@ -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 @@ class ScopedPthreadMutexLocker {
private:
pthread_mutex_t* mu_;
DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedPthreadMutexLocker);
BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedPthreadMutexLocker);
};
#endif // SCOPED_PTHREAD_MUTEX_LOCKER_H

View file

@ -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 @@ class ScopedReaddir {
private:
DIR* dir_;
DISALLOW_COPY_AND_ASSIGN(ScopedReaddir);
BIONIC_DISALLOW_COPY_AND_ASSIGN(ScopedReaddir);
};
#endif // SCOPED_READDIR_H

View file

@ -46,5 +46,5 @@ class ScopedSignalBlocker {
sigset64_t old_set_;
DISALLOW_COPY_AND_ASSIGN(ScopedSignalBlocker);
BIONIC_DISALLOW_COPY_AND_ASSIGN(ScopedSignalBlocker);
};

View file

@ -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 @@ union WriteProtectedContents {
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 @@ class WriteProtected {
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 @@ class WriteProtected {
}
}
};
#endif

View file

@ -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 @@ class LockGuard {
lock_.unlock();
}
DISALLOW_COPY_AND_ASSIGN(LockGuard);
BIONIC_DISALLOW_COPY_AND_ASSIGN(LockGuard);
private:
Lock& lock_;
};
#endif // _BIONIC_LOCK_H

View file

@ -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 @@ char (&ArraySizeHelper(T (&array)[N]))[N]; // NOLINT(readability/casting)
#else
#define __BIONIC_FALLTHROUGH
#endif
#endif // _BIONIC_MACROS_H_

View file

@ -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 @@ class __LIBC_HIDDEN__ ScopedTrace {
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

View file

@ -42,7 +42,7 @@ class ContextNode {
Unmap();
}
DISALLOW_COPY_AND_ASSIGN(ContextNode);
BIONIC_DISALLOW_COPY_AND_ASSIGN(ContextNode);
bool Open(bool access_rw, bool* fsetxattr_failed);
bool CheckAccessAndOpen();

View file

@ -86,7 +86,7 @@ struct prop_bt {
}
private:
DISALLOW_COPY_AND_ASSIGN(prop_bt);
BIONIC_DISALLOW_COPY_AND_ASSIGN(prop_bt);
};
class prop_area {
@ -158,5 +158,5 @@ class prop_area {
uint32_t reserved_[28];
char data_[0];
DISALLOW_COPY_AND_ASSIGN(prop_area);
BIONIC_DISALLOW_COPY_AND_ASSIGN(prop_area);
};

View file

@ -83,7 +83,7 @@ struct prop_info {
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");

View file

@ -52,7 +52,7 @@ class SystemProperties {
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);

View file

@ -15,7 +15,7 @@ cc_library_static {
// We need to access Bionic private headers in the linker.
include_dirs: ["bionic/libc"],
static_libs: ["libasync_safe"],
static_libs: ["libasync_safe", "libbase"],
}
// This is used for bionic on (host) Linux to bootstrap our linker embedded into

View file

@ -28,7 +28,7 @@
#pragma once
#include "private/bionic_macros.h"
#include <android-base/macros.h>
template<typename T>
struct LinkedListEntry {

View file

@ -30,7 +30,8 @@
#include <stdlib.h>
#include <limits.h>
#include "private/bionic_macros.h"
#include <android-base/macros.h>
struct LinkerBlockAllocatorPage;

View file

@ -31,6 +31,8 @@
#include <android/dlext.h>
#include "linked_list.h"
#include <android-base/macros.h>
// TODO(dimitry): move this to linker_defines.h? Unless it is removed by
// consequent refactoring steps.

View file

@ -32,13 +32,14 @@
#include <stdlib.h>
#include <limits.h>
#include "private/bionic_macros.h"
#include <memory>
#include <string>
#include <vector>
#include <unordered_map>
#include <android-base/macros.h>
class NamespaceLinkConfig {
public:
NamespaceLinkConfig() = default;

View file

@ -30,9 +30,11 @@
#include <stdlib.h>
#include <limits.h>
#include "private/bionic_macros.h"
#include "private/bionic_systrace.h"
#include <android-base/macros.h>
#define LD_LOG(type, x...) \
{ \
g_linker_logger.Log(type, x); \

View file

@ -30,7 +30,7 @@
#include <unistd.h>
#include "private/bionic_macros.h"
#include <android-base/macros.h>
class MappedFileFragment {
public:

View file

@ -17,7 +17,7 @@
#include <fcntl.h>
#include <unistd.h>
#include "private/bionic_macros.h"
#include <android-base/macros.h>
template <typename T = int (*)(char*)>
class GenericTemporaryFile {

View file

@ -34,12 +34,12 @@
#include <future>
#include <vector>
#include <android-base/macros.h>
#include <android-base/parseint.h>
#include <android-base/scopeguard.h>
#include <android-base/strings.h>
#include "private/bionic_constants.h"
#include "private/bionic_macros.h"
#include "BionicDeathTest.h"
#include "SignalUtils.h"
#include "utils.h"