mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
univ.i, ut0ut.h, ut0ut.c:
On 64-bit Windows use InnoDB's own printf function where %lu is converted to %I64u; this eliminates Intel compiler warnings on IA64 innobase/ut/ut0ut.c: On 64-bit Windows use InnoDB's own printf function where %lu is converted to %I64u; this eliminates Intel compiler warnings on IA64 innobase/include/ut0ut.h: On 64-bit Windows use InnoDB's own printf function where %lu is converted to %I64u; this eliminates Intel compiler warnings on IA64 innobase/include/univ.i: On 64-bit Windows use InnoDB's own printf function where %lu is converted to %I64u; this eliminates Intel compiler warnings on IA64
This commit is contained in:
parent
8d987f9e53
commit
6797087d72
3 changed files with 255 additions and 21 deletions
|
@ -65,14 +65,17 @@ Microsoft Visual C++ */
|
|||
#define HAVE_PWRITE
|
||||
#endif
|
||||
|
||||
/* Apparently in some old SCO Unixes the return type of sprintf is not
|
||||
an integer as it should be according to the modern Posix standard. Because
|
||||
of that we define sprintf inside InnoDB code as our own function ut_sprintf */
|
||||
#undef sprintf
|
||||
#define sprintf ut_sprintf
|
||||
#endif /* #if (defined(WIN32) || ... */
|
||||
|
||||
/* On the 64-bit Windows we replace printf with ut_printf, etc. so that
|
||||
we can use the %lu format string to print a 64-bit ulint */
|
||||
#if defined(__WIN__) && (defined(WIN64) || defined(_WIN64))
|
||||
#define printf ut_printf
|
||||
#define sprintf ut_sprintf
|
||||
#define fprintf ut_fprintf
|
||||
#endif
|
||||
|
||||
|
||||
/* DEBUG VERSION CONTROL
|
||||
===================== */
|
||||
|
||||
|
|
|
@ -19,14 +19,47 @@ typedef time_t ib_time_t;
|
|||
|
||||
|
||||
/************************************************************
|
||||
Uses vsprintf to emulate sprintf so that the function always returns
|
||||
the printed length. Apparently in some old SCO Unixes sprintf did not
|
||||
return the printed length but a pointer to the end of the printed string. */
|
||||
On the 64-bit Windows we substitute the format string
|
||||
%l -> %I64
|
||||
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
|
||||
and both the Microsoft and Intel C compilers require the format string
|
||||
%I64 in that case instead of %l. */
|
||||
|
||||
ulint
|
||||
int
|
||||
ut_printf(
|
||||
/*======*/
|
||||
/* out: the number of characters written, or
|
||||
negative in case of an error */
|
||||
const char* format, /* in: format of prints */
|
||||
...); /* in: arguments to be printed */
|
||||
/************************************************************
|
||||
On the 64-bit Windows we substitute the format string
|
||||
%l -> %I64
|
||||
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
|
||||
and both the Microsoft and Intel C compilers require the format string
|
||||
%I64 in that case instead of %l. */
|
||||
|
||||
int
|
||||
ut_sprintf(
|
||||
/*=======*/
|
||||
char* buf, /* in/out: buffer where to print */
|
||||
/* out: the number of characters written, or
|
||||
negative in case of an error */
|
||||
char* buf, /* in: buffer where to print */
|
||||
const char* format, /* in: format of prints */
|
||||
...); /* in: arguments to be printed */
|
||||
/************************************************************
|
||||
On the 64-bit Windows we substitute the format string
|
||||
%l -> %I64
|
||||
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
|
||||
and both the Microsoft and Intel C compilers require the format string
|
||||
%I64 in that case instead of %l. */
|
||||
|
||||
int
|
||||
ut_fprintf(
|
||||
/*=======*/
|
||||
/* out: the number of characters written, or
|
||||
negative in case of an error */
|
||||
FILE* stream, /* in: stream where to print */
|
||||
const char* format, /* in: format of prints */
|
||||
...); /* in: arguments to be printed */
|
||||
/************************************************************
|
||||
|
|
|
@ -20,26 +20,224 @@ Created 5/11/1994 Heikki Tuuri
|
|||
ibool ut_always_false = FALSE;
|
||||
|
||||
/************************************************************
|
||||
Uses vsprintf to emulate sprintf so that the function always returns
|
||||
the printed length. Apparently in some old SCO Unixes sprintf did not
|
||||
return the printed length but a pointer to the end of the printed string. */
|
||||
On the 64-bit Windows we substitute the format string
|
||||
%l -> %I64
|
||||
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
|
||||
and both the Microsoft and Intel C compilers require the format string
|
||||
%I64 in that case instead of %l. */
|
||||
|
||||
ulint
|
||||
ut_sprintf(
|
||||
/*=======*/
|
||||
char* buf, /* in/out: buffer where to print */
|
||||
int
|
||||
ut_printf(
|
||||
/*======*/
|
||||
/* out: the number of characters written, or
|
||||
negative in case of an error */
|
||||
const char* format, /* in: format of prints */
|
||||
...) /* in: arguments to be printed */
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_list args;
|
||||
ulint len;
|
||||
char* format_end;
|
||||
char* newformat;
|
||||
char* ptr;
|
||||
char* newptr;
|
||||
int ret;
|
||||
char format_buf_in_stack[500];
|
||||
|
||||
len = strlen(format);
|
||||
|
||||
if (len > 250) {
|
||||
newformat = malloc(2 * len);
|
||||
} else {
|
||||
newformat = format_buf_in_stack;
|
||||
}
|
||||
|
||||
format_end = (char*)format + len;
|
||||
|
||||
ptr = (char*)format;
|
||||
newptr = newformat;
|
||||
|
||||
#if defined(__WIN__) && (defined(WIN64) || defined(_WIN64))
|
||||
/* Replace %l with %I64 if it is not preceded with '\' */
|
||||
|
||||
while (ptr < format_end) {
|
||||
if (*ptr == '%' && *(ptr + 1) == 'l'
|
||||
&& (ptr == format || *(ptr - 1) != '\\')) {
|
||||
|
||||
memcpy(newptr, "%I64", 4);
|
||||
ptr += 2;
|
||||
newptr += 4;
|
||||
} else {
|
||||
*newptr = *ptr;
|
||||
ptr++;
|
||||
newptr++;
|
||||
}
|
||||
}
|
||||
|
||||
*newptr = '\0';
|
||||
|
||||
ut_a(newptr < newformat + 2 * len);
|
||||
#else
|
||||
strcpy(newformat, format);
|
||||
#endif
|
||||
va_start(args, format);
|
||||
|
||||
vsprintf(buf, format, args);
|
||||
ret = vprintf((const char*)newformat, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
return((ulint)strlen(buf));
|
||||
if (newformat != format_buf_in_stack) {
|
||||
free(newformat);
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
On the 64-bit Windows we substitute the format string
|
||||
%l -> %I64
|
||||
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
|
||||
and both the Microsoft and Intel C compilers require the format string
|
||||
%I64 in that case instead of %l. */
|
||||
|
||||
int
|
||||
ut_sprintf(
|
||||
/*=======*/
|
||||
/* out: the number of characters written, or
|
||||
negative in case of an error */
|
||||
char* buf, /* in: buffer where to print */
|
||||
const char* format, /* in: format of prints */
|
||||
...) /* in: arguments to be printed */
|
||||
{
|
||||
va_list args;
|
||||
ulint len;
|
||||
char* format_end;
|
||||
char* newformat;
|
||||
char* ptr;
|
||||
char* newptr;
|
||||
int ret;
|
||||
char format_buf_in_stack[500];
|
||||
|
||||
len = strlen(format);
|
||||
|
||||
if (len > 250) {
|
||||
newformat = malloc(2 * len);
|
||||
} else {
|
||||
newformat = format_buf_in_stack;
|
||||
}
|
||||
|
||||
format_end = (char*)format + len;
|
||||
|
||||
ptr = (char*)format;
|
||||
newptr = newformat;
|
||||
|
||||
#if defined(__WIN__) && (defined(WIN64) || defined(_WIN64))
|
||||
/* Replace %l with %I64 if it is not preceded with '\' */
|
||||
|
||||
while (ptr < format_end) {
|
||||
if (*ptr == '%' && *(ptr + 1) == 'l'
|
||||
&& (ptr == format || *(ptr - 1) != '\\')) {
|
||||
|
||||
memcpy(newptr, "%I64", 4);
|
||||
ptr += 2;
|
||||
newptr += 4;
|
||||
} else {
|
||||
*newptr = *ptr;
|
||||
ptr++;
|
||||
newptr++;
|
||||
}
|
||||
}
|
||||
|
||||
*newptr = '\0';
|
||||
|
||||
ut_a(newptr < newformat + 2 * len);
|
||||
#else
|
||||
strcpy(newformat, format);
|
||||
#endif
|
||||
va_start(args, format);
|
||||
|
||||
ret = vsprintf(buf, (const char*)newformat, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
if (newformat != format_buf_in_stack) {
|
||||
free(newformat);
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
On the 64-bit Windows we substitute the format string
|
||||
%l -> %I64
|
||||
because we define ulint as unsigned __int64 and lint as __int64 on Windows,
|
||||
and both the Microsoft and Intel C compilers require the format string
|
||||
%I64 in that case instead of %l. */
|
||||
|
||||
int
|
||||
ut_fprintf(
|
||||
/*=======*/
|
||||
/* out: the number of characters written, or
|
||||
negative in case of an error */
|
||||
FILE* stream, /* in: stream where to print */
|
||||
const char* format, /* in: format of prints */
|
||||
...) /* in: arguments to be printed */
|
||||
{
|
||||
va_list args;
|
||||
ulint len;
|
||||
char* format_end;
|
||||
char* newformat;
|
||||
char* ptr;
|
||||
char* newptr;
|
||||
int ret;
|
||||
char format_buf_in_stack[500];
|
||||
|
||||
len = strlen(format);
|
||||
|
||||
if (len > 250) {
|
||||
newformat = malloc(2 * len);
|
||||
} else {
|
||||
newformat = format_buf_in_stack;
|
||||
}
|
||||
|
||||
format_end = (char*)format + len;
|
||||
|
||||
ptr = (char*)format;
|
||||
newptr = newformat;
|
||||
|
||||
#if defined(__WIN__) && (defined(WIN64) || defined(_WIN64))
|
||||
/* Replace %l with %I64 if it is not preceded with '\' */
|
||||
|
||||
while (ptr < format_end) {
|
||||
if (*ptr == '%' && *(ptr + 1) == 'l'
|
||||
&& (ptr == format || *(ptr - 1) != '\\')) {
|
||||
|
||||
memcpy(newptr, "%I64", 4);
|
||||
ptr += 2;
|
||||
newptr += 4;
|
||||
} else {
|
||||
*newptr = *ptr;
|
||||
ptr++;
|
||||
newptr++;
|
||||
}
|
||||
}
|
||||
|
||||
*newptr = '\0';
|
||||
|
||||
ut_a(newptr < newformat + 2 * len);
|
||||
#else
|
||||
strcpy(newformat, format);
|
||||
#endif
|
||||
va_start(args, format);
|
||||
|
||||
ret = vfprintf(stream, (const char*)newformat, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
if (newformat != format_buf_in_stack) {
|
||||
free(newformat);
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
|
|
Loading…
Reference in a new issue