summaryrefslogtreecommitdiffstats
path: root/third_party/talloc
diff options
context:
space:
mode:
authorsenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-18 17:23:07 +0000
committersenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-18 17:23:07 +0000
commit7f036f8e35fc23141788448a0d1a37df695135e6 (patch)
tree4b01f0644c813336c8c3207b731f94e77a53e9d4 /third_party/talloc
parent214c3363664dd47b693dcc90888379541f1cb5d7 (diff)
downloadchromium_src-7f036f8e35fc23141788448a0d1a37df695135e6.zip
chromium_src-7f036f8e35fc23141788448a0d1a37df695135e6.tar.gz
chromium_src-7f036f8e35fc23141788448a0d1a37df695135e6.tar.bz2
Fix for talloc, in order to improve mesa shader compiler performance on windows from abysmal to merely poor. The vsnprintf() implementation in MSVC's libc does not conform to C99, and returns -1 if the given buffer is too small to hold the given format. Passing it NULL and a size of zero returns the number of chars required.
BUG=NONE TEST=all GPU layout tests R=kbr Review URL: http://codereview.chromium.org/6711035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78710 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/talloc')
-rw-r--r--third_party/talloc/README.chromium2
-rw-r--r--third_party/talloc/chromium.patch44
-rw-r--r--third_party/talloc/talloc.c7
3 files changed, 42 insertions, 11 deletions
diff --git a/third_party/talloc/README.chromium b/third_party/talloc/README.chromium
index d0400c7..cfd2251 100644
--- a/third_party/talloc/README.chromium
+++ b/third_party/talloc/README.chromium
@@ -19,3 +19,5 @@ chromium.patch):
- An implementation of strnlen was provided for platforms not
supporting it (in particular, Mac OS X).
- A use of ssize_t was changed to size_t on Windows.
+ - a call to vsnprintf() querying the required buffer size was changed to use
+ ptr NULL size 0 in order to satisfy MSVC
diff --git a/third_party/talloc/chromium.patch b/third_party/talloc/chromium.patch
index 247d577..26d4463 100644
--- a/third_party/talloc/chromium.patch
+++ b/third_party/talloc/chromium.patch
@@ -1,6 +1,6 @@
diff -c -r talloc-2.0.1/talloc.c talloc/talloc.c
*** talloc-2.0.1/talloc.c Tue Dec 15 06:16:57 2009
---- talloc/talloc.c Mon Oct 25 13:58:42 2010
+--- talloc/talloc.c Fri Mar 18 13:03:11 2011
***************
*** 30,36 ****
inspired by http://swapped.cc/halloc/
@@ -285,7 +285,30 @@ diff -c -r talloc-2.0.1/talloc.c talloc/talloc.c
{
char *ret;
***************
-*** 1736,1749 ****
+*** 1699,1709 ****
+ int len;
+ char *ret;
+ va_list ap2;
+- char c;
+
+- /* this call looks strange, but it makes it work on older solaris boxes */
+ va_copy(ap2, ap);
+! len = vsnprintf(&c, 1, fmt, ap2);
+ va_end(ap2);
+ if (unlikely(len < 0)) {
+ return NULL;
+--- 1722,1730 ----
+ int len;
+ char *ret;
+ va_list ap2;
+
+ va_copy(ap2, ap);
+! len = vsnprintf(NULL, 0, fmt, ap2);
+ va_end(ap2);
+ if (unlikely(len < 0)) {
+ return NULL;
+***************
+*** 1736,1754 ****
return ret;
}
@@ -298,9 +321,14 @@ diff -c -r talloc-2.0.1/talloc.c talloc/talloc.c
{
ssize_t alen;
va_list ap2;
- char c;
+- char c;
---- 1759,1777 ----
+ va_copy(ap2, ap);
+! alen = vsnprintf(&c, 1, fmt, ap2);
+ va_end(ap2);
+
+ if (alen <= 0) {
+--- 1757,1779 ----
return ret;
}
@@ -318,11 +346,15 @@ diff -c -r talloc-2.0.1/talloc.c talloc/talloc.c
+ size_t alen;
+ #endif
va_list ap2;
- char c;
+ va_copy(ap2, ap);
+! alen = vsnprintf(NULL, 0, fmt, ap2);
+ va_end(ap2);
+
+ if (alen <= 0) {
diff -c -r talloc-2.0.1/talloc.h talloc/talloc.h
*** talloc-2.0.1/talloc.h Wed Oct 28 16:14:20 2009
---- talloc/talloc.h Mon Oct 25 15:11:18 2010
+--- talloc/talloc.h Fri Mar 18 13:03:02 2011
***************
*** 28,33 ****
--- 28,37 ----
diff --git a/third_party/talloc/talloc.c b/third_party/talloc/talloc.c
index 598084e..ecf625a 100644
--- a/third_party/talloc/talloc.c
+++ b/third_party/talloc/talloc.c
@@ -1722,11 +1722,9 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
int len;
char *ret;
va_list ap2;
- char c;
- /* this call looks strange, but it makes it work on older solaris boxes */
va_copy(ap2, ap);
- len = vsnprintf(&c, 1, fmt, ap2);
+ len = vsnprintf(NULL, 0, fmt, ap2);
va_end(ap2);
if (unlikely(len < 0)) {
return NULL;
@@ -1773,10 +1771,9 @@ static INLINE char *__talloc_vaslenprintf_append(char *s, size_t slen,
size_t alen;
#endif
va_list ap2;
- char c;
va_copy(ap2, ap);
- alen = vsnprintf(&c, 1, fmt, ap2);
+ alen = vsnprintf(NULL, 0, fmt, ap2);
va_end(ap2);
if (alen <= 0) {