am 5ce362b4: am cf113ab9: am 4b57305a: Merge "Bring in google3-style DISALLOW_* macros."

* commit '5ce362b4c5a942beea8dc90542f00d19b3b49845':
  Bring in google3-style DISALLOW_* macros.
This commit is contained in:
Elliott Hughes 2014-05-10 03:46:15 +00:00 committed by Android Git Automerger
commit d35f1b508e
8 changed files with 56 additions and 27 deletions

View File

@ -19,6 +19,7 @@
#include <pthread.h>
#include "private/bionic_macros.h"
#include "pthread_internal.h"
class pthread_accessor {
@ -57,9 +58,7 @@ class pthread_accessor {
is_locked_ = true;
}
// Disallow copy and assignment.
pthread_accessor(const pthread_accessor&);
void operator=(const pthread_accessor&);
DISALLOW_COPY_AND_ASSIGN(pthread_accessor);
};
#endif // PTHREAD_ACCESSOR_H

View File

@ -19,6 +19,7 @@
#include <errno.h>
#include <stdlib.h>
#include "private/bionic_macros.h"
#include "private/ScopedReaddir.h"
// A smart pointer to the scandir dirent**.
@ -84,9 +85,7 @@ class ScandirResult {
return copy;
}
// Disallow copy and assignment.
ScandirResult(const ScandirResult&);
void operator=(const ScandirResult&);
DISALLOW_COPY_AND_ASSIGN(ScandirResult);
};
int scandir(const char* dirname, dirent*** name_list,

View File

@ -54,6 +54,7 @@
#include <sys/atomics.h>
#include "private/bionic_atomic_inline.h"
#include "private/bionic_macros.h"
#define ALIGN(x, a) (((x) + (a - 1)) & ~(a - 1))
@ -100,9 +101,7 @@ struct prop_bt {
}
private:
// Disallow copy and assign.
prop_bt(const prop_bt&);
prop_bt& operator=(const prop_bt&);
DISALLOW_COPY_AND_ASSIGN(prop_bt);
};
struct prop_area {
@ -121,9 +120,7 @@ struct prop_area {
}
private:
// Disallow copy and assign.
prop_area(const prop_area&);
prop_area& operator=(const prop_area&);
DISALLOW_COPY_AND_ASSIGN(prop_area);
};
struct prop_info {
@ -141,9 +138,7 @@ struct prop_info {
ANDROID_MEMBAR_FULL();
}
private:
// Disallow copy and assign.
prop_info(const prop_info&);
prop_info& operator=(const prop_info&);
DISALLOW_COPY_AND_ASSIGN(prop_info);
};
struct find_nth_cookie {

View File

@ -19,6 +19,8 @@
#include <errno.h>
#include "bionic_macros.h"
class ErrnoRestorer {
public:
explicit ErrnoRestorer() : saved_errno_(errno) {
@ -35,9 +37,7 @@ class ErrnoRestorer {
private:
int saved_errno_;
// Disallow copy and assignment.
ErrnoRestorer(const ErrnoRestorer&);
void operator=(const ErrnoRestorer&);
DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
};
#endif // ERRNO_RESTORER_H

View File

@ -22,6 +22,8 @@
#include <stdint.h>
#include <sys/auxv.h>
#include "private/bionic_macros.h"
struct abort_msg_t;
// When the kernel starts the dynamic linker, it passes a pointer to a block
@ -73,9 +75,7 @@ class KernelArgumentBlock {
abort_msg_t** abort_message_ptr;
private:
// Disallow copy and assignment.
KernelArgumentBlock(const KernelArgumentBlock&);
void operator=(const KernelArgumentBlock&);
DISALLOW_COPY_AND_ASSIGN(KernelArgumentBlock);
};
#endif // KERNEL_ARGUMENT_BLOCK_H

View File

@ -19,6 +19,8 @@
#include <pthread.h>
#include "bionic_macros.h"
class ScopedPthreadMutexLocker {
public:
explicit ScopedPthreadMutexLocker(pthread_mutex_t* mu) : mu_(mu) {
@ -32,9 +34,7 @@ class ScopedPthreadMutexLocker {
private:
pthread_mutex_t* mu_;
// Disallow copy and assignment.
ScopedPthreadMutexLocker(const ScopedPthreadMutexLocker&);
void operator=(const ScopedPthreadMutexLocker&);
DISALLOW_COPY_AND_ASSIGN(ScopedPthreadMutexLocker);
};
#endif // SCOPED_PTHREAD_MUTEX_LOCKER_H

View File

@ -19,6 +19,8 @@
#include <dirent.h>
#include "private/bionic_macros.h"
class ScopedReaddir {
public:
ScopedReaddir(const char* path) {
@ -42,9 +44,7 @@ class ScopedReaddir {
private:
DIR* dir_;
// Disallow copy and assignment.
ScopedReaddir(const ScopedReaddir&);
void operator=(const ScopedReaddir&);
DISALLOW_COPY_AND_ASSIGN(ScopedReaddir);
};
#endif // SCOPED_READDIR_H

View File

@ -0,0 +1,36 @@
/*
* 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.
*/
#ifndef _BIONIC_MACROS_H_
#define _BIONIC_MACROS_H_
// 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&); \
void operator=(const TypeName&)
// 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(); \
DISALLOW_COPY_AND_ASSIGN(TypeName)
#endif // _BIONIC_MACROS_H_