Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:18

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2023 Google LLC.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 #ifndef UPB_PORT_VSNPRINTF_COMPAT_H_
0009 #define UPB_PORT_VSNPRINTF_COMPAT_H_
0010 
0011 // Must be last.
0012 #include "upb/port/def.inc"
0013 
0014 UPB_INLINE int _upb_vsnprintf(char* buf, size_t size, const char* fmt,
0015                               va_list ap) {
0016 #if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
0017   // The msvc runtime has a non-conforming vsnprintf() that requires the
0018   // following compatibility code to become conformant.
0019   int n = -1;
0020   if (size != 0) n = _vsnprintf_s(buf, size, _TRUNCATE, fmt, ap);
0021   if (n == -1) n = _vscprintf(fmt, ap);
0022   return n;
0023 #else
0024   return vsnprintf(buf, size, fmt, ap);
0025 #endif
0026 }
0027 
0028 #include "upb/port/undef.inc"
0029 
0030 #endif  // UPB_PORT_VSNPRINTF_COMPAT_H_