Merge pull request #73 from apstndb/fix-va-copy

Fix musl libc incompatibility
pull/13171/head
Joshua Haberman 8 years ago committed by GitHub
commit 9a91f7bba8
  1. 2
      tests/pb/test_decoder.cc
  2. 13
      upb/upb.h

@ -111,7 +111,7 @@ using std::string;
void vappendf(string* str, const char *format, va_list args) { void vappendf(string* str, const char *format, va_list args) {
va_list copy; va_list copy;
__va_copy(copy, args); _upb_va_copy(copy, args);
int count = vsnprintf(NULL, 0, format, args); int count = vsnprintf(NULL, 0, format, args);
if (count >= 0) if (count >= 0)

@ -51,20 +51,21 @@ template <int N> class InlinedEnvironment;
#define UPB_NORETURN #define UPB_NORETURN
#endif #endif
#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
/* C99/C++11 versions. */
#include <stdio.h>
#define _upb_snprintf snprintf
#define _upb_vsnprintf vsnprintf
#define _upb_va_copy(a, b) va_copy(a, b)
#elif defined __GNUC__
/* A few hacky workarounds for functions not in C89. /* A few hacky workarounds for functions not in C89.
* For internal use only! * For internal use only!
* TODO(haberman): fix these by including our own implementations, or finding * TODO(haberman): fix these by including our own implementations, or finding
* another workaround. * another workaround.
*/ */
#ifdef __GNUC__
#define _upb_snprintf __builtin_snprintf #define _upb_snprintf __builtin_snprintf
#define _upb_vsnprintf __builtin_vsnprintf #define _upb_vsnprintf __builtin_vsnprintf
#define _upb_va_copy(a, b) __va_copy(a, b) #define _upb_va_copy(a, b) __va_copy(a, b)
#elif __STDC_VERSION__ >= 199901L
/* C99 versions. */
#define _upb_snprintf snprintf
#define _upb_vsnprintf vsnprintf
#define _upb_va_copy(a, b) va_copy(a, b)
#else #else
#error Need implementations of [v]snprintf and va_copy #error Need implementations of [v]snprintf and va_copy
#endif #endif

Loading…
Cancel
Save