am 04766565
: am 9c102ccf
: am 7fe8229b
: am 9c1912c4
: Merge "Avoid changing the C++ ABI with ssize_t."
* commit '04766565d3743d70f679ca180d7fcc35321143b8': Avoid changing the C++ ABI with ssize_t.
This commit is contained in:
commit
bfc25aa33c
@ -85,8 +85,17 @@ typedef .... pthread_t;
|
|||||||
|
|
||||||
#ifndef _SSIZE_T_DEFINED_
|
#ifndef _SSIZE_T_DEFINED_
|
||||||
#define _SSIZE_T_DEFINED_
|
#define _SSIZE_T_DEFINED_
|
||||||
|
/* Traditionally, bionic's ssize_t was "long int". This causes GCC to emit warnings when you
|
||||||
|
* pass a ssize_t to a printf-style function. The correct type is __kernel_ssize_t, which is
|
||||||
|
* "int", which isn't an ABI change for C code (because they're the same size) but is an ABI
|
||||||
|
* change for C++ because "int" and "long int" mangle to "i" and "l" respectively. So until
|
||||||
|
* we can fix the ABI, this is the best we can do. http://b/8253769. */
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
typedef long int ssize_t;
|
||||||
|
#else
|
||||||
typedef __kernel_ssize_t ssize_t;
|
typedef __kernel_ssize_t ssize_t;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef __kernel_suseconds_t suseconds_t;
|
typedef __kernel_suseconds_t suseconds_t;
|
||||||
typedef __kernel_time_t time_t;
|
typedef __kernel_time_t time_t;
|
||||||
|
@ -171,10 +171,17 @@ TEST(stdio, getline_invalid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(stdio, printf_ssize_t) {
|
TEST(stdio, printf_ssize_t) {
|
||||||
// We used to have a ssize_t definition that confused GCC into saying:
|
#if __BIONIC__
|
||||||
|
// http://b/8253769
|
||||||
|
ASSERT_EQ(sizeof(__kernel_ssize_t), sizeof(long int));
|
||||||
|
ASSERT_EQ(sizeof(ssize_t), sizeof(long int));
|
||||||
|
#else
|
||||||
|
// TODO: add a .c file so we can test this for bionic --- our C ssize_t is fine.
|
||||||
|
// For our 32-bit C++ ABI, we have a ssize_t definition that confuses GCC into saying:
|
||||||
// error: format '%zd' expects argument of type 'signed size_t',
|
// error: format '%zd' expects argument of type 'signed size_t',
|
||||||
// but argument 4 has type 'ssize_t {aka long int}' [-Werror=format]
|
// but argument 4 has type 'ssize_t {aka long int}' [-Werror=format]
|
||||||
ssize_t v = 1;
|
ssize_t v = 1;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
snprintf(buf, sizeof(buf), "%zd", v);
|
snprintf(buf, sizeof(buf), "%zd", v);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user