diff options
author | Kristian Høgsberg Kristensen <[email protected]> | 2015-09-29 17:10:50 -0700 |
---|---|---|
committer | Kristian Høgsberg Kristensen <[email protected]> | 2015-10-01 14:24:29 -0700 |
commit | 005c8e01062e8e88a86904b955d5422742bd32e7 (patch) | |
tree | c32b3e01c2dd93257dc7255a8f3aa99a60551035 /src/util | |
parent | 337caee91078e3d83ff01b929a44a74600cde6a7 (diff) | |
parent | cb758b892a7e62ff1f6187f2ca9ac543ff70a096 (diff) |
Merge branch 'master' of ../mesa into vulkan
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/Makefile.am | 10 | ||||
-rw-r--r-- | src/util/Makefile.sources | 8 | ||||
-rw-r--r-- | src/util/mesa-sha1.c | 4 | ||||
-rw-r--r-- | src/util/strndup.c | 50 | ||||
-rw-r--r-- | src/util/strndup.h | 40 |
5 files changed, 102 insertions, 10 deletions
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 1e087b40d38..e05a2c5958c 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -44,11 +44,7 @@ libmesautil_la_SOURCES = \ $(MESA_UTIL_FILES) \ $(MESA_UTIL_GENERATED_FILES) -if ENABLE_SHADER_CACHE -libmesautil_la_SOURCES += $(MESA_UTIL_SHADER_CACHE_FILES) - libmesautil_la_LIBADD = $(SHA1_LIBS) -endif roundeven_test_LDADD = -lm @@ -59,5 +55,7 @@ BUILT_SOURCES = $(MESA_UTIL_GENERATED_FILES) CLEANFILES = $(BUILT_SOURCES) EXTRA_DIST = format_srgb.py SConscript -format_srgb.c: $(srcdir)/format_srgb.py - $(AM_V_GEN) $(PYTHON2) $< > $@ +PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS) + +format_srgb.c: format_srgb.py + $(PYTHON_GEN) $(srcdir)/format_srgb.py > $@ diff --git a/src/util/Makefile.sources b/src/util/Makefile.sources index 82df3bcb00a..ef38b5ac7d1 100644 --- a/src/util/Makefile.sources +++ b/src/util/Makefile.sources @@ -1,7 +1,3 @@ -MESA_UTIL_SHADER_CACHE_FILES := \ - mesa-sha1.c \ - mesa-sha1.h - MESA_UTIL_FILES := \ bitset.h \ format_srgb.h \ @@ -9,6 +5,8 @@ MESA_UTIL_FILES := \ hash_table.h \ list.h \ macros.h \ + mesa-sha1.c \ + mesa-sha1.h \ ralloc.c \ ralloc.h \ register_allocate.c \ @@ -19,6 +17,8 @@ MESA_UTIL_FILES := \ set.c \ set.h \ simple_list.h \ + strndup.c \ + strndup.h \ strtod.c \ strtod.h \ texcompress_rgtc_tmp.h \ diff --git a/src/util/mesa-sha1.c b/src/util/mesa-sha1.c index fa281937774..faa1c871b5d 100644 --- a/src/util/mesa-sha1.c +++ b/src/util/mesa-sha1.c @@ -26,6 +26,8 @@ #include "mesa-sha1.h" +#ifdef HAVE_SHA1 + #if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ \ || defined(HAVE_SHA1_IN_LIBC) /* Use libc for SHA1 */ @@ -314,3 +316,5 @@ _mesa_sha1_format(char *buf, const unsigned char *sha1) return buf; } + +#endif diff --git a/src/util/strndup.c b/src/util/strndup.c new file mode 100644 index 00000000000..ca1c6f53b57 --- /dev/null +++ b/src/util/strndup.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#if defined(_WIN32) +#include <stdlib.h> +#include <string.h> +#include "strndup.h" + +char * +strndup(const char *str, size_t max) +{ + size_t n; + char *ptr; + + if (!str) + return NULL; + + n = strlen(str); + if (n > max) + n = max; + + ptr = (char *) calloc(n + 1, sizeof(char)); + if (!ptr) + return NULL; + + memcpy(ptr, str, n); + return ptr; +} + +#endif diff --git a/src/util/strndup.h b/src/util/strndup.h new file mode 100644 index 00000000000..c5ed7a8c8d2 --- /dev/null +++ b/src/util/strndup.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#pragma once + +#include <stdlib.h> // size_t + +#if defined(_WIN32) + +#ifdef __cplusplus +extern "C" { +#endif + +char *strndup(const char *str, size_t max); + +#ifdef __cplusplus +} +#endif + +#endif |