shithub: dumb

Download patch

ref: 7ee625748304ef158460633439c153724171eb3e
parent: 97ef9342913d3ea48e8682bf80a3154631fd481d
author: Chris Moeller <kode54@gmail.com>
date: Sun Sep 28 13:48:43 EDT 2014

Updated bit array source and enabled decoration on both bit array and resampler functions

--- a/dumb/include/internal/barray.h
+++ b/dumb/include/internal/barray.h
@@ -3,6 +3,23 @@
 
 #include <stdlib.h>
 
+#ifdef BARRAY_DECORATE
+#define PASTE(a,b) a ## b
+#define EVALUATE(a,b) PASTE(a,b)
+#define bit_array_create EVALUATE(BARRAY_DECORATE,_bit_array_create)
+#define bit_array_destroy EVALUATE(BARRAY_DECORATE,_bit_array_destroy)
+#define bit_array_dup EVALUATE(BARRAY_DECORATE,_bit_array_dup)
+#define bit_array_reset EVALUATE(BARRAY_DECORATE,_bit_array_reset)
+#define bit_array_set EVALUATE(BARRAY_DECORATE,_bit_array_set)
+#define bit_array_set_range EVALUATE(BARRAY_DECORATE,_bit_array_set_range)
+#define bit_array_test EVALUATE(BARRAY_DECORATE,_bit_array_test)
+#define bit_array_test_range EVALUATE(BARRAY_DECORATE,_bit_array_test_range)
+#define bit_array_clear EVALUATE(BARRAY_DECORATE,_bit_array_clear)
+#define bit_array_clear_range EVALUATE(BARRAY_DECORATE,_bit_array_clear_range)
+#define bit_array_merge EVALUATE(BARRAY_DECORATE,_bit_array_merge)
+#define bit_array_mask EVALUATE(BARRAY_DECORATE,_bit_array_mask)
+#endif
+
 void * bit_array_create(size_t size);
 void bit_array_destroy(void * array);
 void * bit_array_dup(void * array);
@@ -10,9 +27,13 @@
 void bit_array_reset(void * array);
 
 void bit_array_set(void * array, size_t bit);
+void bit_array_set_range(void * array, size_t bit, size_t count);
+
 int bit_array_test(void * array, size_t bit);
 int bit_array_test_range(void * array, size_t bit, size_t count);
+
 void bit_array_clear(void * array, size_t bit);
+void bit_array_clear_range(void * array, size_t bit, size_t count);
 
 void bit_array_merge(void * array, void * source, size_t offset);
 void bit_array_mask(void * array, void * source, size_t offset);
--- a/dumb/src/helpers/barray.c
+++ b/dumb/src/helpers/barray.c
@@ -53,6 +53,21 @@
 	}
 }
 
+void bit_array_set_range(void * array, size_t bit, size_t count)
+{
+    if (array && count)
+    {
+        size_t * size = (size_t *) array;
+        if (bit < *size)
+        {
+            unsigned char * ptr = (unsigned char *)(size + 1);
+            size_t i;
+            for (i = bit; i < *size && i < bit + count; ++i)
+                ptr[i >> 3] |= (1U << (i & 7));
+        }
+    }
+}
+
 int bit_array_test(void * array, size_t bit)
 {
 	if (array)
@@ -118,6 +133,21 @@
 			ptr[bit >> 3] &= ~(1U << (bit & 7));
 		}
 	}
+}
+
+void bit_array_clear_range(void * array, size_t bit, size_t count)
+{
+    if (array && count)
+    {
+        size_t * size = (size_t *) array;
+        if (bit < *size)
+        {
+            unsigned char * ptr = (unsigned char *)(size + 1);
+            size_t i;
+            for (i = bit; i < *size && i < bit + count; ++i)
+                ptr[i >> 3] &= ~(1U << (i & 7));
+        }
+    }
 }
 
 void bit_array_merge(void * dest, void * source, size_t offset)
--- a/dumb/vc6/dumb/dumb.vcxproj
+++ b/dumb/vc6/dumb/dumb.vcxproj
@@ -55,7 +55,7 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_USE_SSE;_DEBUG;WIN32;_LIB;DUMB_DECLARE_DEPRECATED;DEBUGMODE=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_USE_SSE;RESAMPLER_DECORATE=dumb;BARRAY_DECORATE=dumb;_DEBUG;WIN32;_LIB;DUMB_DECLARE_DEPRECATED;DEBUGMODE=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -76,7 +76,7 @@
       <Optimization>MaxSpeed</Optimization>
       <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
       <AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_USE_SSE;NDEBUG;WIN32;_LIB;DUMB_DECLARE_DEPRECATED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_USE_SSE;RESAMPLER_DECORATE=dumb;BARRAY_DECORATE=dumb;NDEBUG;WIN32;_LIB;DUMB_DECLARE_DEPRECATED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>