Add test for pthread types alignment check.
Bug: 19249079 Change-Id: I83c4f0d11ec5d82a346ae0057d02a92bb1d519e8
This commit is contained in:
@@ -120,9 +120,15 @@ struct pthread_cond_internal_t {
|
||||
#endif
|
||||
};
|
||||
|
||||
static_assert(sizeof(pthread_cond_t) == sizeof(pthread_cond_internal_t),
|
||||
"pthread_cond_t should actually be pthread_cond_internal_t in implementation.");
|
||||
|
||||
// For binary compatibility with old version of pthread_cond_t, we can't use more strict alignment
|
||||
// than 4-byte alignment.
|
||||
static_assert(alignof(pthread_cond_t) == 4,
|
||||
"pthread_cond_t should fulfill the alignment requirement of pthread_cond_internal_t.");
|
||||
|
||||
static pthread_cond_internal_t* __get_internal_cond(pthread_cond_t* cond_interface) {
|
||||
static_assert(sizeof(pthread_cond_t) == sizeof(pthread_cond_internal_t),
|
||||
"pthread_cond_t should actually be pthread_cond_internal_t in implementation.");
|
||||
return reinterpret_cast<pthread_cond_internal_t*>(cond_interface);
|
||||
}
|
||||
|
||||
|
@@ -107,9 +107,15 @@ struct pthread_rwlock_internal_t {
|
||||
#endif
|
||||
};
|
||||
|
||||
static_assert(sizeof(pthread_rwlock_t) == sizeof(pthread_rwlock_internal_t),
|
||||
"pthread_rwlock_t should actually be pthread_rwlock_internal_t in implementation.");
|
||||
|
||||
// For binary compatibility with old version of pthread_rwlock_t, we can't use more strict
|
||||
// alignment than 4-byte alignment.
|
||||
static_assert(alignof(pthread_rwlock_t) == 4,
|
||||
"pthread_rwlock_t should fulfill the alignment requirement of pthread_rwlock_internal_t.");
|
||||
|
||||
static inline pthread_rwlock_internal_t* __get_internal_rwlock(pthread_rwlock_t* rwlock_interface) {
|
||||
static_assert(sizeof(pthread_rwlock_t) == sizeof(pthread_rwlock_internal_t),
|
||||
"pthread_rwlock_t should actually be pthread_rwlock_internal_t in implementation.");
|
||||
return reinterpret_cast<pthread_rwlock_internal_t*>(rwlock_interface);
|
||||
}
|
||||
|
||||
|
@@ -78,7 +78,7 @@ typedef struct {
|
||||
#else
|
||||
char __private[4];
|
||||
#endif
|
||||
} pthread_cond_t __attribute__((aligned(sizeof(long))));
|
||||
} pthread_cond_t __attribute__((aligned(4)));
|
||||
|
||||
#define PTHREAD_COND_INITIALIZER { { 0 } }
|
||||
|
||||
@@ -93,7 +93,7 @@ typedef struct {
|
||||
#else
|
||||
char __private[40];
|
||||
#endif
|
||||
} pthread_rwlock_t __attribute__((aligned(8)));
|
||||
} pthread_rwlock_t __attribute__((aligned(4)));
|
||||
|
||||
#define PTHREAD_RWLOCK_INITIALIZER { { 0 } }
|
||||
|
||||
|
Reference in New Issue
Block a user