Rework remaining tests
cover Rework remaining tests
This series covers
- Remove the hackish "include xf86drmfoo.c" from dristat
- Extract the remaining two xf86drmfoo.c tests to standalone ones
- beat them into shape, and
- wire them up to make check.
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/9 tests/dristat: don't include C files
Remove the hack of including C files, by reworking the only requirement drmOpenMinor() to an open(buf...). After all we do know the exact name of the device we're going to open, so might as well use it. Replace hard-coded 16 with DRM_MAX_MINOR while we're here.
--- tests/dristat.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
tests/dristat.c +6 -5
@@ -31,13 +31,14 @@# include <config.h> #endif +#include <ctype.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> +#include <sys/stat.h> #include <unistd.h> #include "xf86drm.h" -#include "xf86drmRandom.c" -#include "xf86drmHash.c" -#include "xf86drm.c" #define DRM_VERSION 0x00000001#define DRM_MEMORY 0x00000002
@@ -267,9 +268,9 @@ int main(int argc, char **argv)return 1 ; } -for (i =0 ; i <16 ; i++)if (!minor || i == minor) { +for (i =0 ; i <DRM_MAX_MINOR ; i++)if (!minor || i == minor) {sprintf (buf,DRM_DEV_NAME ,DRM_DIR_NAME , i); - fd =drmOpenMinor (i,1 ,DRM_NODE_PRIMARY ); + fd =open (buf,O_RDWR ,0 );if (fd >=0 ) {printf ("%s\n" , buf);if (mask &DRM_BUSID )getbusid (fd);
Signature · 6 lines
2.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 1/9] tests/dristat: don't include C files
Quoted 33 lines · Emil Velikov
Remove the hack of including C files, by reworking the only requirement
drmOpenMinor()to an open(buf...). After all we do know the exact name of the device we're going to open, so might as well use it. Replace hard-coded 16 withDRM_MAX_MINORwhile we're here.Signed-off-by Emil Velikov <[email protected]>--- tests/dristat.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)tests/dristat.c +4
-3@@ -31,13 +31,14 @@# include <config.h> #endif +#include <ctype.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> +#include <sys/stat.h> #include <unistd.h> #include "xf86drm.h" -#include "xf86drmRandom.c" -#include "xf86drmHash.c" -#include "xf86drm.c" #define DRM_VERSION 0x00000001#define DRM_MEMORY 0x00000002
tests/dristat.c int main(int argc, char **argv) · line 273
Quoted 8 lines
tests/dristat.c +2
-2@@ -267,9 +268,9 @@ int main(int argc, char **argv)return 1 ; } -for (i =0 ; i <16 ; i++)if (!minor || i == minor) { +for (i =0 ; i <DRM_MAX_MINOR ; i++)if (!minor || i == minor) {sprintf (buf,DRM_DEV_NAME ,DRM_DIR_NAME , i); - fd =drmOpenMinor (i,1 ,DRM_NODE_PRIMARY ); + fd =open (buf,O_RDWR ,0 );
What about the "create" (second) argument? The original code creates the node if it does not exist (on non-UDEV systems), or waits some time for udev to create it.
Not sure how this is relevant for the test.
Quoted 3 lines
tests/dristat.c +0
-0if (fd >=0 ) {printf ("%s\n" , buf);if (mask &DRM_BUSID )getbusid (fd);
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 1/9] tests/dristat: don't include C files
Quoted 37 lines · Jan Vesely
Quoted 36 lines · Emil Velikov
Remove the hack of including C files, by reworking the only requirement
drmOpenMinor()to an open(buf...). After all we do know the exact name of the device we're going to open, so might as well use it. Replace hard-coded 16 withDRM_MAX_MINORwhile we're here.Signed-off-by Emil Velikov <[email protected]>--- tests/dristat.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)tests/dristat.c +4
-3@@ -31,13 +31,14 @@# include <config.h> #endif +#include <ctype.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> +#include <sys/stat.h> #include <unistd.h> #include "xf86drm.h" -#include "xf86drmRandom.c" -#include "xf86drmHash.c" -#include "xf86drm.c" #define DRM_VERSION 0x00000001#define DRM_MEMORY 0x00000002@@ -267,9 +268,9 @@ int main(int argc, char **argv)return 1 ; }
Quoted 11 lines
tests/dristat.c int main(int argc, char **argv) · line 273
Quoted 5 lines
tests/dristat.c +2
-2-for (i =0 ; i <16 ; i++)if (!minor || i == minor) { +for (i =0 ; i <DRM_MAX_MINOR ; i++)if (!minor || i == minor) {sprintf (buf,DRM_DEV_NAME ,DRM_DIR_NAME , i); - fd =drmOpenMinor (i,1 ,DRM_NODE_PRIMARY ); + fd =open (buf,O_RDWR ,0 );What about the "create" (second) argument? The original code creates the node if it does not exist (on non-UDEV systems), or waits some time for udev to create it.
Not sure how this is relevant for the test.
Hmm brain triggered this as "create = 0", as I was going through. Fwiw I would opt for nuking this custom hack, and stick with open().
If one needs to wait for udev or manually create the nod then they have bigger ship to fry. All of that should be resolved before anyone has the change to run the program.
Let's give it some time for people to voice their opinions on the topic. Could be that something more elaborate is happing if create is set.
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/9 tests/hash: extract test out of xf86drmHash.c
In reply to Emil VelikovThis way with follow up commits we can fix it and wire it up to make check
--- tests/Makefile.am | 3 +- tests/hash.c | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ xf86drmHash.c | 174 +++---------------------------------------- 3 files changed, 231 insertions(+), 165 deletions(-) create mode 100644 tests/hash.c
tests/Makefile.am +2 -1
@@ -29,7 +29,8 @@ LDADD = $(top_builddir)/libdrm.la check_PROGRAMS = \ dristat \ - drmstat + drmstat \ + hash if HAVE_NOUVEAU SUBDIRS += nouveau
tests/hash.c new file +219 -0
219 lines not on this page · raw message
xf86drmHash.c +10 -164
228 lines not on this page · raw message
Signature · 6 lines
2.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 2/9] tests/hash: extract test out of xf86drmHash.c
Quoted 117 lines · Emil Velikov
This way with follow up commits we can fix it and wire it up to make check
Signed-off-by Emil Velikov <[email protected]>--- tests/Makefile.am | 3 +- tests/hash.c | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ xf86drmHash.c | 174 +++---------------------------------------- 3 files changed, 231 insertions(+), 165 deletions(-) create mode 100644 tests/hash.ctests/Makefile.am +2
-1@@ -29,7 +29,8 @@ LDADD = $(top_builddir)/libdrm.la check_PROGRAMS = \ dristat \ - drmstat + drmstat \ + hash if HAVE_NOUVEAU SUBDIRS += nouveautests/hash.c new file +86
-0@@ -0,0 +1,219 @@ +/* xf86drmHash.c -- Small hash table support for integer -> integer mapping +* Created: Sun Apr 18 09:35:45 1999 by [email protected] +* +* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. +* All Rights Reserved. +* +* 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 +* PRECISION INSIGHT AND/OR ITS SUPPLIERS 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. +* +* Authors: Rickard E. (Rik) Faith <[email protected]> +* +* DESCRIPTION +* +* This file contains a straightforward implementation of a fixed-sized +* hash table using self-organizing linked lists [Knuth73, pp. 398-399] for +* collision resolution. There are two potentially interesting things +* about this implementation: +* +* 1) The table is power-of-two sized. Prime sized tables are more +* traditional, but do not have a significant advantage over power-of-two +* sized table, especially when double hashing is not used for collision +* resolution. +* +* 2) The hash computation uses a table of random integers [Hanson97, +* pp. 39-41]. +* +* FUTURE ENHANCEMENTS +* +* With a table size of 512, the current implementation is sufficient for a +* few hundred keys. Since this is well above the expected size of the +* tables for which this implementation was designed, the implementation of +* dynamic hash tables was postponed until the need arises. A common (and +* naive) approach to dynamic hash table implementation simply creates a +* new hash table when necessary, rehashes all the data into the new table, +* and destroys the old table. The approach in [Larson88] is superior in +* two ways: 1) only a portion of the table is expanded when needed, +* distributing the expansion cost over several insertions, and 2) portions +* of the table can be locked, enabling a scalable thread-safe +* implementation. +* +* REFERENCES +* +* [Hanson97] David R. Hanson. C Interfaces and Implementations: +* Techniques for Creating Reusable Software. Reading, Massachusetts: +* Addison-Wesley, 1997. +* +* [Knuth73] Donald E. Knuth. The Art of Computer Programming. Volume 3: +* Sorting and Searching. Reading, Massachusetts: Addison-Wesley, 1973. +* +* [Larson88] Per-Ake Larson. "Dynamic Hash Tables". CACM 31(4), April +* 1988, pp. 446-457. +* +*/ + +#include <stdio.h> +#include <stdlib.h> + +#include "xf86drm.h" + +#define HASH_SIZE 512/* Good for about 100 entries */ +/* If you change this value, you probably +have to change the HashHash hashing +function! */ + +typedef struct HashBucket { +unsigned long key; +void *value; +struct HashBucket *next; +}HashBucket , *HashBucketPtr ; +
tests/hash.c line 96
Quoted 10 lines
tests/hash.c new file +10
-0+typedef struct HashTable { +unsigned long magic; +unsigned long entries; +unsigned long hits;/* At top of linked list */ +unsigned long partials;/* Not at top of linked list */ +unsigned long misses;/* Not in table */ +HashBucketPtr buckets[HASH_SIZE ]; +int p0; +HashBucketPtr p1; +}HashTable , *HashTablePtr ;
I don't think it's a good idea to duplicate these. maybe having an internal header would be a better way to go.
Quoted 364 lines
tests/hash.c new file +123
-0+ +#define DIST_LIMIT 10 +static int dist[DIST_LIMIT ]; + +static void clear_dist (void ) { +int i; + +for (i =0 ; i <DIST_LIMIT ; i++) dist[i] =0 ; +} + +static int count_entries (HashBucketPtr bucket) +{ +int count =0 ; + +for (; bucket; bucket = bucket->next) ++count; +return count; +} + +static void update_dist (int count) +{ +if (count >=DIST_LIMIT ) ++dist[DIST_LIMIT -1 ]; +else ++dist[count]; +} + +static void compute_dist (HashTablePtr table) +{ +int i; +HashBucketPtr bucket; + +printf ("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n" , + table->entries, table->hits, table->partials, table->misses); +clear_dist (); +for (i =0 ; i <HASH_SIZE ; i++) { + bucket = table->buckets[i]; +update_dist (count_entries (bucket)); + } +for (i =0 ; i <DIST_LIMIT ; i++) { +if (i !=DIST_LIMIT -1 )printf ("%5d %10d\n" , i, dist[i]); +else printf ("other %10d\n" , dist[i]); + } +} + +static void check_table (HashTablePtr table, +unsigned long key,unsigned long value) +{ +unsigned long retval =0 ; +int retcode =drmHashLookup (table, key, &retval); + +switch (retcode) { +case -1 : +printf ("Bad magic = 0x%08lx:" +" key = %lu, expected = %lu, returned = %lu\n" , + table->magic, key, value, retval); +break ; +case 1 : +printf ("Not found: key = %lu, expected = %lu returned = %lu\n" , + key, value, retval); +break ; +case 0 : +if (value != retval) +printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , + key, value, retval); +break ; +default : +printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , + retcode, key, value, retval); +break ; + } +} + +int main (void ) +{ +HashTablePtr table; +int i; + +printf ("\n***** 256 consecutive integers ****\n" ); + table =drmHashCreate (); +for (i =0 ; i <256 ; i++)drmHashInsert (table, i, i); +for (i =0 ; i <256 ; i++)check_table (table, i, i); +for (i =256 ; i >=0 ; i--)check_table (table, i, i); +compute_dist (table); +drmHashDestroy (table); + +printf ("\n***** 1024 consecutive integers ****\n" ); + table =drmHashCreate (); +for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, i); +for (i =0 ; i <1024 ; i++)check_table (table, i, i); +for (i =1024 ; i >=0 ; i--)check_table (table, i, i); +compute_dist (table); +drmHashDestroy (table); + +printf ("\n***** 1024 consecutive page addresses (4k pages) ****\n" ); + table =drmHashCreate (); +for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , i); +for (i =0 ; i <1024 ; i++)check_table (table, i*4096 , i); +for (i =1024 ; i >=0 ; i--)check_table (table, i*4096 , i); +compute_dist (table); +drmHashDestroy (table); + +printf ("\n***** 1024 random integers ****\n" ); + table =drmHashCreate (); +srandom (0xbeefbeef ); +for (i =0 ; i <1024 ; i++)drmHashInsert (table,random (), i); +srandom (0xbeefbeef ); +for (i =0 ; i <1024 ; i++)check_table (table,random (), i); +srandom (0xbeefbeef ); +for (i =0 ; i <1024 ; i++)check_table (table,random (), i); +compute_dist (table); +drmHashDestroy (table); + +printf ("\n***** 5000 random integers ****\n" ); + table =drmHashCreate (); +srandom (0xbeefbeef ); +for (i =0 ; i <5000 ; i++)drmHashInsert (table,random (), i); +srandom (0xbeefbeef ); +for (i =0 ; i <5000 ; i++)check_table (table,random (), i); +srandom (0xbeefbeef ); +for (i =0 ; i <5000 ; i++)check_table (table,random (), i); +compute_dist (table); +drmHashDestroy (table); + +return 0 ; +}xf86drmHash.c +10
-164@@ -71,11 +71,7 @@#include <stdio.h> #include <stdlib.h> -#define HASH_MAIN 0 - -#if !HASH_MAIN -# include "xf86drm.h" -#endif +#include "xf86drm.h" #define HASH_MAGIC 0xdeadbeef#define HASH_DEBUG 0@@ -84,23 +80,6 @@have to change the HashHash hashing function! */ -#if HASH_MAIN -#define HASH_ALLOC malloc -#define HASH_FREE free -#define HASH_RANDOM_DECL -#define HASH_RANDOM_INIT (seed) srandom(seed) -#define HASH_RANDOM random() -#define HASH_RANDOM_DESTROY -#else -#define HASH_ALLOC drmMalloc -#define HASH_FREE drmFree -#define HASH_RANDOM_DECL void *state -#define HASH_RANDOM_INIT (seed) state = drmRandomCreate(seed) -#define HASH_RANDOM drmRandom(state) -#define HASH_RANDOM_DESTROY drmRandomDestroy(state) - -#endif - typedef struct HashBucket { unsigned long key; void *value;@@ -118,14 +97,6 @@ typedef struct HashTable {HashBucketPtr p1; } HashTable, *HashTablePtr; -#if HASH_MAIN -extern void *drmHashCreate (void ); -extern int drmHashDestroy (void *t); -extern int drmHashLookup (void *t,unsigned long key,unsigned long *value); -extern int drmHashInsert (void *t,unsigned long key,unsigned long value); -extern int drmHashDelete (void *t,unsigned long key); -#endif -static unsigned long HashHash (unsigned long key) {unsigned long hash =0 ;@@ -135,10 +106,10 @@ static unsigned long HashHash(unsigned long key)int i;if (!init) { -HASH_RANDOM_DECL ; -HASH_RANDOM_INIT (37 ); -for (i =0 ; i <256 ; i++) scatter[i] =HASH_RANDOM ; -HASH_RANDOM_DESTROY ; +void *state; + state =drmRandomCreate (37 ); +for (i =0 ; i <256 ; i++) scatter[i] =drmRandom (state); +drmRandomDestroy (state); ++init; }@@ -159,7 +130,7 @@ void *drmHashCreate(void)HashTablePtr table;int i; - table =HASH_ALLOC (sizeof (*table)); + table =drmMalloc (sizeof (*table));if (!table)return NULL ; table->magic =HASH_MAGIC ; table->entries =0 ;@@ -183,11 +154,11 @@ int drmHashDestroy(void *t)for (i =0 ; i <HASH_SIZE ; i++) {for (bucket = table->buckets[i]; bucket;) { next = bucket->next; -HASH_FREE (bucket); +drmFree (bucket); bucket = next; } } -HASH_FREE (table); +drmFree (table);return 0 ; }@@ -245,7 +216,7 @@ int drmHashInsert(void *t, unsigned long key, void *value)if (HashFind (table, key, &hash))return 1 ;/* Already in table */ - bucket =HASH_ALLOC (sizeof (*bucket)); + bucket =drmMalloc (sizeof (*bucket));if (!bucket)return -1 ;/* Error */ bucket->key = key; bucket->value = value;@@ -270,7 +241,7 @@ int drmHashDelete(void *t, unsigned long key)if (!bucket)return 1 ;/* Not found */ table->buckets[hash] = bucket->next; -HASH_FREE (bucket); +drmFree (bucket);return 0 ; }@@ -301,128 +272,3 @@ int drmHashFirst(void *t, unsigned long *key, void **value) table->p1 = table->buckets[0 ];return drmHashNext (table, key, value); } - -#if HASH_MAIN -#define DIST_LIMIT 10 -static int dist[DIST_LIMIT ]; - -static void clear_dist (void ) { -int i; - -for (i =0 ; i <DIST_LIMIT ; i++) dist[i] =0 ; -} - -static int count_entries (HashBucketPtr bucket) -{ -int count =0 ; - -for (; bucket; bucket = bucket->next) ++count; -return count; -} - -static void update_dist (int count) -{ -if (count >=DIST_LIMIT ) ++dist[DIST_LIMIT -1 ]; -else ++dist[count]; -} - -static void compute_dist (HashTablePtr table) -{ -int i; -HashBucketPtr bucket; - -printf ("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n" , - table->entries, table->hits, table->partials, table->misses); -clear_dist (); -for (i =0 ; i <HASH_SIZE ; i++) { - bucket = table->buckets[i]; -update_dist (count_entries (bucket)); - } -for (i =0 ; i <DIST_LIMIT ; i++) { -if (i !=DIST_LIMIT -1 )printf ("%5d %10d\n" , i, dist[i]); -else printf ("other %10d\n" , dist[i]); - } -} - -static void check_table (HashTablePtr table, -unsigned long key,unsigned long value) -{ -unsigned long retval =0 ; -int retcode =drmHashLookup (table, key, &retval); - -switch (retcode) { -case -1 : -printf ("Bad magic = 0x%08lx:" -" key = %lu, expected = %lu, returned = %lu\n" , - table->magic, key, value, retval); -break ; -case 1 : -printf ("Not found: key = %lu, expected = %lu returned = %lu\n" , - key, value, retval); -break ; -case 0 : -if (value != retval) -printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , - key, value, retval); -break ; -default : -printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , - retcode, key, value, retval); -break ; - } -} - -int main (void ) -{ -HashTablePtr table; -int i; - -printf ("\n***** 256 consecutive integers ****\n" ); - table =drmHashCreate (); -for (i =0 ; i <256 ; i++)drmHashInsert (table, i, i); -for (i =0 ; i <256 ; i++)check_table (table, i, i); -for (i =256 ; i >=0 ; i--)check_table (table, i, i); -compute_dist (table); -drmHashDestroy (table); - -printf ("\n***** 1024 consecutive integers ****\n" ); - table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, i); -for (i =0 ; i <1024 ; i++)check_table (table, i, i); -for (i =1024 ; i >=0 ; i--)check_table (table, i, i); -compute_dist (table); -drmHashDestroy (table); - -printf ("\n***** 1024 consecutive page addresses (4k pages) ****\n" ); - table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , i); -for (i =0 ; i <1024 ; i++)check_table (table, i*4096 , i); -for (i =1024 ; i >=0 ; i--)check_table (table, i*4096 , i); -compute_dist (table); -drmHashDestroy (table); - -printf ("\n***** 1024 random integers ****\n" ); - table =drmHashCreate (); -srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)drmHashInsert (table,random (), i); -srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)check_table (table,random (), i); -srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)check_table (table,random (), i); -compute_dist (table); -drmHashDestroy (table); - -printf ("\n***** 5000 random integers ****\n" ); - table =drmHashCreate (); -srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)drmHashInsert (table,random (), i); -srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)check_table (table,random (), i); -srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)check_table (table,random (), i); -compute_dist (table); -drmHashDestroy (table); - -return 0 ; -} -#endif
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/9 tests/hash: misc compilation fixes
In reply to Emil VelikovGet the test from completely broken to working like a charm.
- Use the same variable type for both HashInsert and HashLookup.
- Use correct storage type for the HashLookup return value.
- Remove useless backward iteration of HashLookup(i).
--- tests/hash.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
tests/hash.c +14 -17
@@ -139,27 +139,27 @@ static void compute_dist(HashTablePtr table)static void check_table (HashTablePtr table,unsigned long key,unsigned long value) { -unsigned long retval =0 ; -int retcode =drmHashLookup (table, key, &retval); +unsigned long *retval; +int retcode =drmHashLookup (table, key, (void **)&retval);switch (retcode) {case -1 :printf ("Bad magic = 0x%08lx:" " key = %lu, expected = %lu, returned = %lu\n" , - table->magic, key, value, retval); + table->magic, key, value, *retval);break ;case 1 : -printf ("Not found: key = %lu, expected = %lu returned = %lu\n" , - key, value, retval); +printf ("Not found: key = %lu, expected = %lu, returned = %lu\n" , + key, value, *retval);break ;case 0 : -if (value != retval) +if (value != *retval)printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , - key, value, retval); + key, value, *retval);break ;default :printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , - retcode, key, value, retval); + retcode, key, value, *retval);break ; } }
@@ -167,36 +167,33 @@ static void check_table(HashTablePtr table,int main (void ) {HashTablePtr table; -int i; +unsigned long i;printf ("\n***** 256 consecutive integers ****\n" ); table =drmHashCreate (); -for (i =0 ; i <256 ; i++)drmHashInsert (table, i, i); +for (i =0 ; i <256 ; i++)drmHashInsert (table, i, (void *)&i);for (i =0 ; i <256 ; i++)check_table (table, i, i); -for (i =256 ; i >=0 ; i--)check_table (table, i, i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 consecutive integers ****\n" ); table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, i); +for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, (void *)&i);for (i =0 ; i <1024 ; i++)check_table (table, i, i); -for (i =1024 ; i >=0 ; i--)check_table (table, i, i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 consecutive page addresses (4k pages) ****\n" ); table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , i); +for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , (void *)&i);for (i =0 ; i <1024 ; i++)check_table (table, i*4096 , i); -for (i =1024 ; i >=0 ; i--)check_table (table, i*4096 , i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 random integers ****\n" ); table =drmHashCreate ();srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)drmHashInsert (table,random (), i); +for (i =0 ; i <1024 ; i++)drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef );for (i =0 ; i <1024 ; i++)check_table (table,random (), i);srandom (0xbeefbeef );
@@ -207,7 +204,7 @@ int main(void)printf ("\n***** 5000 random integers ****\n" ); table =drmHashCreate ();srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)drmHashInsert (table,random (), i); +for (i =0 ; i <5000 ; i++)drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef );for (i =0 ; i <5000 ; i++)check_table (table,random (), i);srandom (0xbeefbeef );
Signature · 6 lines
2.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 3/9] tests/hash: misc compilation fixes
Quoted 16 lines · Emil Velikov
Get the test from completely broken to working like a charm.
- Use the same variable type for both HashInsert and HashLookup.
- Use correct storage type for the HashLookup return value.
- Remove useless backward iteration of HashLookup(i).Signed-off-by Emil Velikov <[email protected]>--- tests/hash.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)tests/hash.c +0
-0
tests/hash.c static void compute_dist(HashTablePtr table) · line 140
Quoted 2 lines
tests/hash.c +0
-0@@ -139,27 +139,27 @@ static void compute_dist(HashTablePtr table)static void check_table (HashTablePtr table,unsigned long key,unsigned long value)
I think we should use void* for value here.
tests/hash.c static void compute_dist(HashTablePtr table) · line 143
Quoted 5 lines
tests/hash.c +2
-2{ -unsigned long retval =0 ; -int retcode =drmHashLookup (table, key, &retval); +unsigned long *retval; +int retcode =drmHashLookup (table, key, (void **)&retval);
I don't think this is correct. If the entry is found, it stores address to stack variable i in retval, which at this point in iteration incidentally contains the value we are looking for.
Quoted 29 lines
tests/hash.c +6
-6switch (retcode) {case -1 :printf ("Bad magic = 0x%08lx:" " key = %lu, expected = %lu, returned = %lu\n" , - table->magic, key, value, retval); + table->magic, key, value, *retval);break ;case 1 : -printf ("Not found: key = %lu, expected = %lu returned = %lu\n" , - key, value, retval); +printf ("Not found: key = %lu, expected = %lu, returned = %lu\n" , + key, value, *retval);break ;case 0 : -if (value != retval) +if (value != *retval)printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , - key, value, retval); + key, value, *retval);break ;default :printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , - retcode, key, value, retval); + retcode, key, value, *retval);break ; } }
tests/hash.c static void check_table(HashTablePtr table, · line 174
Quoted 10 lines
tests/hash.c +2
-2@@ -167,36 +167,33 @@ static void check_table(HashTablePtr table,int main (void ) {HashTablePtr table; -int i; +unsigned long i;printf ("\n***** 256 consecutive integers ****\n" ); table =drmHashCreate (); -for (i =0 ; i <256 ; i++)drmHashInsert (table, i, i); +for (i =0 ; i <256 ; i++)drmHashInsert (table, i, (void *)&i);
This changes the entries inserted. previously it would insert values [0, 256). Now it inserts address of i 256 times.
I think we should change the inserted values to be different from the key (offset should be enough), to catch the kind of scenario this tests creates.
Quoted 40 lines
tests/hash.c +4
-7for (i =0 ; i <256 ; i++)check_table (table, i, i); -for (i =256 ; i >=0 ; i--)check_table (table, i, i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 consecutive integers ****\n" ); table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, i); +for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, (void *)&i);for (i =0 ; i <1024 ; i++)check_table (table, i, i); -for (i =1024 ; i >=0 ; i--)check_table (table, i, i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 consecutive page addresses (4k pages) ****\n" ); table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , i); +for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , (void *)&i);for (i =0 ; i <1024 ; i++)check_table (table, i*4096 , i); -for (i =1024 ; i >=0 ; i--)check_table (table, i*4096 , i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 random integers ****\n" ); table =drmHashCreate ();srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)drmHashInsert (table,random (), i); +for (i =0 ; i <1024 ; i++)drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef );for (i =0 ; i <1024 ; i++)check_table (table,random (), i);srandom (0xbeefbeef );@@ -207,7 +204,7 @@ int main(void)printf ("\n***** 5000 random integers ****\n" ); table =drmHashCreate ();srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)drmHashInsert (table,random (), i); +for (i =0 ; i <5000 ; i++)drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef );for (i =0 ; i <5000 ; i++)check_table (table,random (), i);srandom (0xbeefbeef );
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/9 tests/hash: style fixes
In reply to Emil Velikov--- tests/hash.c | 102 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 42 deletions(-)
tests/hash.c +60 -42
@@ -73,8 +73,8 @@#include "xf86drm.h" -#define HASH_SIZE 512/* Good for about 100 entries */ -/* If you change this value, you probably +#define HASH_SIZE 512/* Good for about 100 entries */ +/* If you change this value, you probably have to change the HashHash hashing function! */
@@ -87,9 +87,9 @@ typedef struct HashBucket { typedef struct HashTable { unsigned long magic; unsigned long entries; - unsigned long hits; /* At top of linked list */ - unsigned long partials; /* Not at top of linked list */ - unsigned long misses; /* Not in table */ + unsigned long hits; /* At top of linked list */ + unsigned long partials; /* Not at top of linked list */ + unsigned long misses; /* Not in table */ HashBucketPtr buckets[HASH_SIZE]; int p0; HashBucketPtr p1;
@@ -101,21 +101,25 @@ static int dist[DIST_LIMIT];static void clear_dist (void ) {int i; -for (i =0 ; i <DIST_LIMIT ; i++) dist[i] =0 ; +for (i =0 ; i <DIST_LIMIT ; i++) + dist[i] =0 ; }static int count_entries (HashBucketPtr bucket) { -int count =0 ; +int count; -for (; bucket; bucket = bucket->next) ++count; +for (count =0 ; bucket; bucket = bucket->next) + ++count;return count; }static void update_dist (int count) { -if (count >=DIST_LIMIT ) ++dist[DIST_LIMIT -1 ]; -else ++dist[count]; +if (count >=DIST_LIMIT ) + ++dist[DIST_LIMIT -1 ]; +else + ++dist[count]; }static void compute_dist (HashTablePtr table)
@@ -124,43 +128,45 @@ static void compute_dist(HashTablePtr table)HashBucketPtr bucket;printf ("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n" , - table->entries, table->hits, table->partials, table->misses); + table->entries, table->hits, table->partials, table->misses);clear_dist ();for (i =0 ; i <HASH_SIZE ; i++) { - bucket = table->buckets[i]; -update_dist (count_entries (bucket)); + bucket = table->buckets[i]; +update_dist (count_entries (bucket)); }for (i =0 ; i <DIST_LIMIT ; i++) { -if (i !=DIST_LIMIT -1 )printf ("%5d %10d\n" , i, dist[i]); -else printf ("other %10d\n" , dist[i]); +if (i !=DIST_LIMIT -1 ) +printf ("%5d %10d\n" , i, dist[i]); +else +printf ("other %10d\n" , dist[i]); } }static void check_table (HashTablePtr table, -unsigned long key,unsigned long value) +unsigned long key,unsigned long value) {unsigned long *retval;int retcode =drmHashLookup (table, key, (void **)&retval);switch (retcode) {case -1 : -printf ("Bad magic = 0x%08lx:" -" key = %lu, expected = %lu, returned = %lu\n" , - table->magic, key, value, *retval); -break ; +printf ("Bad magic = 0x%08lx:" +" key = %lu, expected = %lu, returned = %lu\n" , + table->magic, key, value, *retval); +break ;case 1 : -printf ("Not found: key = %lu, expected = %lu, returned = %lu\n" , - key, value, *retval); -break ; +printf ("Not found: key = %lu, expected = %lu, returned = %lu\n" , + key, value, *retval); +break ;case 0 : -if (value != *retval) -printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , - key, value, *retval); -break ; +if (value != *retval) +printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , + key, value, *retval); +break ;default : -printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , - retcode, key, value, *retval); -break ; +printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , + retcode, key, value, *retval); +break ; } }
@@ -171,44 +177,56 @@ int main(void)printf ("\n***** 256 consecutive integers ****\n" ); table =drmHashCreate (); -for (i =0 ; i <256 ; i++)drmHashInsert (table, i, (void *)&i); -for (i =0 ; i <256 ; i++)check_table (table, i, i); +for (i =0 ; i <256 ; i++) +drmHashInsert (table, i, (void *)&i); +for (i =0 ; i <256 ; i++) +check_table (table, i, i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 consecutive integers ****\n" ); table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, (void *)&i); -for (i =0 ; i <1024 ; i++)check_table (table, i, i); +for (i =0 ; i <1024 ; i++) +drmHashInsert (table, i, (void *)&i); +for (i =0 ; i <1024 ; i++) +check_table (table, i, i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 consecutive page addresses (4k pages) ****\n" ); table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , (void *)&i); -for (i =0 ; i <1024 ; i++)check_table (table, i*4096 , i); +for (i =0 ; i <1024 ; i++) +drmHashInsert (table, i*4096 , (void *)&i); +for (i =0 ; i <1024 ; i++) +check_table (table, i*4096 , i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 random integers ****\n" ); table =drmHashCreate ();srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)drmHashInsert (table,random (), (void *)&i); +for (i =0 ; i <1024 ; i++) +drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)check_table (table,random (), i); +for (i =0 ; i <1024 ; i++) +check_table (table,random (), i);srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)check_table (table,random (), i); +for (i =0 ; i <1024 ; i++) +check_table (table,random (), i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 5000 random integers ****\n" ); table =drmHashCreate ();srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)drmHashInsert (table,random (), (void *)&i); +for (i =0 ; i <5000 ; i++) +drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)check_table (table,random (), i); +for (i =0 ; i <5000 ; i++) +check_table (table,random (), i);srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)check_table (table,random (), i); +for (i =0 ; i <5000 ; i++) +check_table (table,random (), i);compute_dist (table);drmHashDestroy (table);
Signature · 6 lines
2.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 4/9] tests/hash: style fixes
Quoted 40 lines · Emil Velikov
Signed-off-by Emil Velikov <[email protected]>--- tests/hash.c | 102 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 42 deletions(-)tests/hash.c +7
-6@@ -73,8 +73,8 @@#include "xf86drm.h" -#define HASH_SIZE 512/* Good for about 100 entries */ -/* If you change this value, you probably +#define HASH_SIZE 512/* Good for about 100 entries */ +/* If you change this value, you probably have to change the HashHash hashing function! */ @@ -87,9 +87,9 @@ typedef struct HashBucket { typedef struct HashTable { unsigned long magic; unsigned long entries; - unsigned long hits; /* At top of linked list */ - unsigned long partials; /* Not at top of linked list */ - unsigned long misses; /* Not in table */ + unsigned long hits; /* At top of linked list */ + unsigned long partials; /* Not at top of linked list */ + unsigned long misses; /* Not in table */ HashBucketPtr buckets[HASH_SIZE]; int p0; HashBucketPtr p1;@@ -101,21 +101,25 @@ static int dist[DIST_LIMIT];static void clear_dist (void ) {int i; -for (i =0 ; i <DIST_LIMIT ; i++) dist[i] =0 ; +for (i =0 ; i <DIST_LIMIT ; i++) + dist[i] =0 ;
tests/hash.c static int dist[DIST_LIMIT]; · line 113
Quoted 10 lines
tests/hash.c +3
-2}static int count_entries (HashBucketPtr bucket) { -int count =0 ; +int count; -for (; bucket; bucket = bucket->next) ++count; +for (count =0 ; bucket; bucket = bucket->next) + ++count;
I personally prefer to initialize early, especially since it's not for-loop iterating variable, but I don't insist.
Quoted 149 lines
tests/hash.c +50
-34return count; }static void update_dist (int count) { -if (count >=DIST_LIMIT ) ++dist[DIST_LIMIT -1 ]; -else ++dist[count]; +if (count >=DIST_LIMIT ) + ++dist[DIST_LIMIT -1 ]; +else + ++dist[count]; }static void compute_dist (HashTablePtr table)@@ -124,43 +128,45 @@ static void compute_dist(HashTablePtr table)HashBucketPtr bucket;printf ("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n" , - table->entries, table->hits, table->partials, table->misses); + table->entries, table->hits, table->partials, table->misses);clear_dist ();for (i =0 ; i <HASH_SIZE ; i++) { - bucket = table->buckets[i]; -update_dist (count_entries (bucket)); + bucket = table->buckets[i]; +update_dist (count_entries (bucket)); }for (i =0 ; i <DIST_LIMIT ; i++) { -if (i !=DIST_LIMIT -1 )printf ("%5d %10d\n" , i, dist[i]); -else printf ("other %10d\n" , dist[i]); +if (i !=DIST_LIMIT -1 ) +printf ("%5d %10d\n" , i, dist[i]); +else +printf ("other %10d\n" , dist[i]); } }static void check_table (HashTablePtr table, -unsigned long key,unsigned long value) +unsigned long key,unsigned long value) {unsigned long *retval;int retcode =drmHashLookup (table, key, (void **)&retval);switch (retcode) {case -1 : -printf ("Bad magic = 0x%08lx:" -" key = %lu, expected = %lu, returned = %lu\n" , - table->magic, key, value, *retval); -break ; +printf ("Bad magic = 0x%08lx:" +" key = %lu, expected = %lu, returned = %lu\n" , + table->magic, key, value, *retval); +break ;case 1 : -printf ("Not found: key = %lu, expected = %lu, returned = %lu\n" , - key, value, *retval); -break ; +printf ("Not found: key = %lu, expected = %lu, returned = %lu\n" , + key, value, *retval); +break ;case 0 : -if (value != *retval) -printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , - key, value, *retval); -break ; +if (value != *retval) +printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , + key, value, *retval); +break ;default : -printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , - retcode, key, value, *retval); -break ; +printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , + retcode, key, value, *retval); +break ; } }@@ -171,44 +177,56 @@ int main(void)printf ("\n***** 256 consecutive integers ****\n" ); table =drmHashCreate (); -for (i =0 ; i <256 ; i++)drmHashInsert (table, i, (void *)&i); -for (i =0 ; i <256 ; i++)check_table (table, i, i); +for (i =0 ; i <256 ; i++) +drmHashInsert (table, i, (void *)&i); +for (i =0 ; i <256 ; i++) +check_table (table, i, i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 consecutive integers ****\n" ); table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, (void *)&i); -for (i =0 ; i <1024 ; i++)check_table (table, i, i); +for (i =0 ; i <1024 ; i++) +drmHashInsert (table, i, (void *)&i); +for (i =0 ; i <1024 ; i++) +check_table (table, i, i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 consecutive page addresses (4k pages) ****\n" ); table =drmHashCreate (); -for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , (void *)&i); -for (i =0 ; i <1024 ; i++)check_table (table, i*4096 , i); +for (i =0 ; i <1024 ; i++) +drmHashInsert (table, i*4096 , (void *)&i); +for (i =0 ; i <1024 ; i++) +check_table (table, i*4096 , i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 1024 random integers ****\n" ); table =drmHashCreate ();srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)drmHashInsert (table,random (), (void *)&i); +for (i =0 ; i <1024 ; i++) +drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)check_table (table,random (), i); +for (i =0 ; i <1024 ; i++) +check_table (table,random (), i);srandom (0xbeefbeef ); -for (i =0 ; i <1024 ; i++)check_table (table,random (), i); +for (i =0 ; i <1024 ; i++) +check_table (table,random (), i);compute_dist (table);drmHashDestroy (table);printf ("\n***** 5000 random integers ****\n" ); table =drmHashCreate ();srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)drmHashInsert (table,random (), (void *)&i); +for (i =0 ; i <5000 ; i++) +drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)check_table (table,random (), i); +for (i =0 ; i <5000 ; i++) +check_table (table,random (), i);srandom (0xbeefbeef ); -for (i =0 ; i <5000 ; i++)check_table (table,random (), i); +for (i =0 ; i <5000 ; i++) +check_table (table,random (), i);compute_dist (table);drmHashDestroy (table);
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/9 tests/hash: return non-zero on failure
In reply to Emil Velikov... and wire up to `make check' now that it's useful.
--- tests/Makefile.am | 12 +++++++----- tests/hash.c | 26 +++++++++++++++----------- 2 files changed, 22 insertions(+), 16 deletions(-)
tests/Makefile.am +7 -5
@@ -29,13 +29,15 @@ LDADD = $(top_builddir)/libdrm.la check_PROGRAMS = \ dristat \ - drmstat \ - hash + drmstat if HAVE_NOUVEAU SUBDIRS += nouveau endif +TESTS = \ + hash + if HAVE_LIBUDEV check_LTLIBRARIES = libdrmtest.la
@@ -53,7 +55,7 @@ XFAIL_TESTS = \ auth \ lock -TESTS = \ +TESTS += \ openclose \ getversion \ getclient \
@@ -62,6 +64,6 @@ TESTS = \ updatedraw \ name_from_fd -check_PROGRAMS += $(TESTS) - endif + +check_PROGRAMS += $(TESTS)
tests/hash.c +15 -11
@@ -142,7 +142,7 @@ static void compute_dist(HashTablePtr table) } } -static void check_table (HashTablePtr table, +static int check_table (HashTablePtr table,unsigned long key,unsigned long value) {unsigned long *retval;
@@ -159,28 +159,32 @@ static void check_table(HashTablePtr table, key, value, *retval);break ;case 0 : -if (value != *retval) +if (value != *retval) {printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , key, value, *retval); + retcode =-1 ; + }break ;default :printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , retcode, key, value, *retval);break ; } +return retcode; }int main (void ) { -HashTablePtr table; -unsigned long i; +HashTablePtr table; +unsigned long i; +int ret =0 ;printf ("\n***** 256 consecutive integers ****\n" ); table =drmHashCreate ();for (i =0 ; i <256 ; i++)drmHashInsert (table, i, (void *)&i);for (i =0 ; i <256 ; i++) -check_table (table, i, i); + ret =check_table (table, i, i) && ret;compute_dist (table);drmHashDestroy (table);
@@ -189,7 +193,7 @@ int main(void)for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, (void *)&i);for (i =0 ; i <1024 ; i++) -check_table (table, i, i); + ret =check_table (table, i, i) && ret;compute_dist (table);drmHashDestroy (table);
@@ -198,7 +202,7 @@ int main(void)for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , (void *)&i);for (i =0 ; i <1024 ; i++) -check_table (table, i*4096 , i); + ret =check_table (table, i*4096 , i) && ret;compute_dist (table);drmHashDestroy (table);
@@ -209,10 +213,10 @@ int main(void)drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef );for (i =0 ; i <1024 ; i++) -check_table (table,random (), i); + ret =check_table (table,random (), i) && ret;srandom (0xbeefbeef );for (i =0 ; i <1024 ; i++) -check_table (table,random (), i); + ret =check_table (table,random (), i) && ret;compute_dist (table);drmHashDestroy (table);
@@ -223,10 +227,10 @@ int main(void)drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef );for (i =0 ; i <5000 ; i++) -check_table (table,random (), i); + ret =check_table (table,random (), i) && ret;srandom (0xbeefbeef );for (i =0 ; i <5000 ; i++) -check_table (table,random (), i); + ret =check_table (table,random (), i) && ret;compute_dist (table);drmHashDestroy (table);
Signature · 6 lines
2.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 5/9] tests/hash: return non-zero on failure
Quoted 132 lines · Emil Velikov
... and wire up to `make check' now that it's useful.
Signed-off-by Emil Velikov <[email protected]>--- tests/Makefile.am | 12 +++++++----- tests/hash.c | 26 +++++++++++++++----------- 2 files changed, 22 insertions(+), 16 deletions(-)tests/Makefile.am +7
-5@@ -29,13 +29,15 @@ LDADD = $(top_builddir)/libdrm.la check_PROGRAMS = \ dristat \ - drmstat \ - hash + drmstat if HAVE_NOUVEAU SUBDIRS += nouveau endif +TESTS = \ + hash + if HAVE_LIBUDEV check_LTLIBRARIES = libdrmtest.la@@ -53,7 +55,7 @@ XFAIL_TESTS = \ auth \ lock -TESTS = \ +TESTS += \ openclose \ getversion \ getclient \@@ -62,6 +64,6 @@ TESTS = \ updatedraw \ name_from_fd -check_PROGRAMS += $(TESTS) - endif + +check_PROGRAMS += $(TESTS)tests/hash.c +13
-9@@ -142,7 +142,7 @@ static void compute_dist(HashTablePtr table) } } -static void check_table (HashTablePtr table, +static int check_table (HashTablePtr table,unsigned long key,unsigned long value) {unsigned long *retval;@@ -159,28 +159,32 @@ static void check_table(HashTablePtr table, key, value, *retval);break ;case 0 : -if (value != *retval) +if (value != *retval) {printf ("Bad value: key = %lu, expected = %lu, returned = %lu\n" , key, value, *retval); + retcode =-1 ; + }break ;default :printf ("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n" , retcode, key, value, *retval);break ; } +return retcode; }int main (void ) { -HashTablePtr table; -unsigned long i; +HashTablePtr table; +unsigned long i; +int ret =0 ;printf ("\n***** 256 consecutive integers ****\n" ); table =drmHashCreate ();for (i =0 ; i <256 ; i++)drmHashInsert (table, i, (void *)&i);for (i =0 ; i <256 ; i++) -check_table (table, i, i); + ret =check_table (table, i, i) && ret;compute_dist (table);drmHashDestroy (table);@@ -189,7 +193,7 @@ int main(void)for (i =0 ; i <1024 ; i++)drmHashInsert (table, i, (void *)&i);for (i =0 ; i <1024 ; i++) -check_table (table, i, i); + ret =check_table (table, i, i) && ret;compute_dist (table);drmHashDestroy (table);@@ -198,7 +202,7 @@ int main(void)for (i =0 ; i <1024 ; i++)drmHashInsert (table, i*4096 , (void *)&i);for (i =0 ; i <1024 ; i++) -check_table (table, i*4096 , i); + ret =check_table (table, i*4096 , i) && ret;compute_dist (table);drmHashDestroy (table);@@ -209,10 +213,10 @@ int main(void)drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef );for (i =0 ; i <1024 ; i++) -check_table (table,random (), i); + ret =check_table (table,random (), i) && ret;srandom (0xbeefbeef );for (i =0 ; i <1024 ; i++) -check_table (table,random (), i); + ret =check_table (table,random (), i) && ret;compute_dist (table);drmHashDestroy (table);@@ -223,10 +227,10 @@ int main(void)drmHashInsert (table,random (), (void *)&i);srandom (0xbeefbeef );
tests/hash.c int main(void) · line 236
Quoted 10 lines
tests/hash.c +2
-2for (i =0 ; i <5000 ; i++) -check_table (table,random (), i); + ret =check_table (table,random (), i) && ret;srandom (0xbeefbeef );for (i =0 ; i <5000 ; i++) -check_table (table,random (), i); + ret =check_table (table,random (), i) && ret;compute_dist (table);drmHashDestroy (table);
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/9 tests/random: extract test out of xf86drmRandom.c
In reply to Emil VelikovWith follow up commits we can clear it up and wire to make check
--- tests/Makefile.am | 3 +- tests/random.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ xf86drmRandom.c | 67 ++-------------------------- 3 files changed, 132 insertions(+), 65 deletions(-) create mode 100644 tests/random.c
tests/Makefile.am +2 -1
@@ -29,7 +29,8 @@ LDADD = $(top_builddir)/libdrm.la check_PROGRAMS = \ dristat \ - drmstat + drmstat \ + random if HAVE_NOUVEAU SUBDIRS += nouveau
tests/random.c new file +127 -0
127 lines not on this page · raw message
xf86drmRandom.c +3 -64
96 lines not on this page · raw message
Signature · 6 lines
2.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 6/9] tests/random: extract test out of xf86drmRandom.c
Quoted 108 lines · Emil Velikov
With follow up commits we can clear it up and wire to make check
Signed-off-by Emil Velikov <[email protected]>--- tests/Makefile.am | 3 +- tests/random.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ xf86drmRandom.c | 67 ++-------------------------- 3 files changed, 132 insertions(+), 65 deletions(-) create mode 100644 tests/random.ctests/Makefile.am +2
-1@@ -29,7 +29,8 @@ LDADD = $(top_builddir)/libdrm.la check_PROGRAMS = \ dristat \ - drmstat + drmstat \ + random if HAVE_NOUVEAU SUBDIRS += nouveautests/random.c new file +77
-0@@ -0,0 +1,127 @@ +/* xf86drmRandom.c -- "Minimal Standard" PRNG Implementation +* Created: Mon Apr 19 08:28:13 1999 by [email protected] +* +* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. +* All Rights Reserved. +* +* 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 +* PRECISION INSIGHT AND/OR ITS SUPPLIERS 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. +* +* Authors: Rickard E. (Rik) Faith <[email protected]> +* +* DESCRIPTION +* +* This file contains a simple, straightforward implementation of the Park +* & Miller "Minimal Standard" PRNG [PM88, PMS93], which is a Lehmer +* multiplicative linear congruential generator (MLCG) with a period of +* 2^31-1. +* +* This implementation is intended to provide a reliable, portable PRNG +* that is suitable for testing a hash table implementation and for +* implementing skip lists. +* +* FUTURE ENHANCEMENTS +* +* If initial seeds are not selected randomly, two instances of the PRNG +* can be correlated. [Knuth81, pp. 32-33] describes a shuffling technique +* that can eliminate this problem. +* +* If PRNGs are used for simulation, the period of the current +* implementation may be too short. [LE88] discusses methods of combining +* MLCGs to produce much longer periods, and suggests some alternative +* values for A and M. [LE90 and Sch92] also provide information on +* long-period PRNGs. +* +* REFERENCES +* +* [Knuth81] Donald E. Knuth. The Art of Computer Programming. Volume 2: +* Seminumerical Algorithms. Reading, Massachusetts: Addison-Wesley, 1981. +* +* [LE88] Pierre L'Ecuyer. "Efficient and Portable Combined Random Number +* Generators". CACM 31(6), June 1988, pp. 742-774. +* +* [LE90] Pierre L'Ecuyer. "Random Numbers for Simulation". CACM 33(10, +* October 1990, pp. 85-97. +* +* [PM88] Stephen K. Park and Keith W. Miller. "Random Number Generators: +* Good Ones are Hard to Find". CACM 31(10), October 1988, pp. 1192-1201. +* +* [Sch92] Bruce Schneier. "Pseudo-Ransom Sequence Generator for 32-Bit +* CPUs". Dr. Dobb's Journal 17(2), February 1992, pp. 34, 37-38, 40. +* +* [PMS93] Stephen K. Park, Keith W. Miller, and Paul K. Stockmeyer. In +* "Technical Correspondence: Remarks on Choosing and Implementing Random +* Number Generators". CACM 36(7), July 1993, pp. 105-110. +* +*/ + +#include <stdio.h> +#include <stdlib.h> + +#include "xf86drm.h"
tests/random.c line 87
Quoted 10 lines
tests/random.c new file +10
-0+ +typedef struct RandomState { +unsigned long magic; +unsigned long a; +unsigned long m; +unsigned long q;/* m div a */ +unsigned long r;/* m mod a */ +unsigned long check; +unsigned long seed; +}RandomState ;
I think this should also go to an internal header. Otherwise lgtm
Quoted 144 lines
tests/random.c new file +40
-0+ +static void check_period (unsigned long seed) +{ +unsigned long count =0 ; +unsigned long initial; +void *state; + + state =drmRandomCreate (seed); + initial =drmRandom (state); + ++count; +while (initial !=drmRandom (state)) { +if (!++count)break ; + } +printf ("With seed of %10lu, period = %10lu (0x%08lx)\n" , + seed, count, count); +drmRandomDestroy (state); +} + +int main (void ) +{ +RandomState *state; +int i; +unsigned long rand; + + state =drmRandomCreate (1 ); +for (i =0 ; i <10000 ; i++) { + rand =drmRandom (state); + } +printf ("After 10000 iterations: %lu (%lu expected): %s\n" , + rand, state->check, + rand - state->check ?"*INCORRECT*" :"CORRECT" ); +drmRandomDestroy (state); + +printf ("Checking periods...\n" ); +check_period (1 ); +check_period (2 ); +check_period (31415926 ); + +return 0 ; +}xf86drmRandom.c +3
-64@@ -74,23 +74,11 @@#include <stdio.h> #include <stdlib.h> -#define RANDOM_MAIN 0 - -#if !RANDOM_MAIN -# include "xf86drm.h" -#endif +#include "xf86drm.h" #define RANDOM_MAGIC 0xfeedbeef#define RANDOM_DEBUG 0 -#if RANDOM_MAIN -#define RANDOM_ALLOC malloc -#define RANDOM_FREE free -#else -#define RANDOM_ALLOC drmMalloc -#define RANDOM_FREE drmFree -#endif - typedef struct RandomState { unsigned long magic; unsigned long a;@@ -101,18 +89,11 @@ typedef struct RandomState {unsigned long seed; } RandomState; -#if RANDOM_MAIN -extern void *drmRandomCreate (unsigned long seed); -extern int drmRandomDestroy (void *state); -extern unsigned long drmRandom (void *state); -extern double drmRandomDouble (void *state); -#endif -void *drmRandomCreate (unsigned long seed) {RandomState *state; - state =RANDOM_ALLOC (sizeof (*state)); + state =drmMalloc (sizeof (*state));if (!state)return NULL ; state->magic =RANDOM_MAGIC ;#if 0 @@ -140,7 +121,7 @@ void *drmRandomCreate(unsigned long seed)int drmRandomDestroy (void *state) { -RANDOM_FREE (state); +drmFree (state);return 0 ; }@@ -164,45 +145,3 @@ double drmRandomDouble(void *state)return (double )drmRandom (state)/(double )s->m; } - -#if RANDOM_MAIN -static void check_period (unsigned long seed) -{ -unsigned long count =0 ; -unsigned long initial; -void *state; - - state =drmRandomCreate (seed); - initial =drmRandom (state); - ++count; -while (initial !=drmRandom (state)) { -if (!++count)break ; - } -printf ("With seed of %10lu, period = %10lu (0x%08lx)\n" , - seed, count, count); -drmRandomDestroy (state); -} - -int main (void ) -{ -RandomState *state; -int i; -unsigned long rand; - - state =drmRandomCreate (1 ); -for (i =0 ; i <10000 ; i++) { - rand =drmRandom (state); - } -printf ("After 10000 iterations: %lu (%lu expected): %s\n" , - rand, state->check, - rand - state->check ?"*INCORRECT*" :"CORRECT" ); -drmRandomDestroy (state); - -printf ("Checking periods...\n" ); -check_period (1 ); -check_period (2 ); -check_period (31415926 ); - -return 0 ; -} -#endif
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/9 tests/random: return non-zero on test failure
In reply to Emil Velikov... and wire it up to make check
--- tests/Makefile.am | 6 +++--- tests/random.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-)
tests/Makefile.am +3 -3
@@ -29,15 +29,15 @@ LDADD = $(top_builddir)/libdrm.la check_PROGRAMS = \ dristat \ - drmstat \ - random + drmstat if HAVE_NOUVEAU SUBDIRS += nouveau endif TESTS = \ - hash + hash \ + random if HAVE_LIBUDEV
tests/random.c +4 -2
@@ -107,15 +107,17 @@ int main(void) {RandomState *state;int i; +int ret;unsigned long rand; state =drmRandomCreate (1 );for (i =0 ; i <10000 ; i++) { rand =drmRandom (state); } + ret = rand - state->check;printf ("After 10000 iterations: %lu (%lu expected): %s\n" , rand, state->check, - rand - state->check ?"*INCORRECT*" :"CORRECT" ); + ret ?"*INCORRECT*" :"CORRECT" );drmRandomDestroy (state);printf ("Checking periods...\n" );
@@ -123,5 +125,5 @@ int main(void)check_period (2 );check_period (31415926 ); -return 0 ; +return ret; }
Signature · 6 lines
2.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 7/9] tests/random: return non-zero on test failure
Quoted 37 lines · Emil Velikov
... and wire it up to make check
Signed-off-by Emil Velikov <[email protected]>--- tests/Makefile.am | 6 +++--- tests/random.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-)tests/Makefile.am +3
-3@@ -29,15 +29,15 @@ LDADD = $(top_builddir)/libdrm.la check_PROGRAMS = \ dristat \ - drmstat \ - random + drmstat if HAVE_NOUVEAU SUBDIRS += nouveau endif TESTS = \ - hash + hash \ + random if HAVE_LIBUDEVtests/random.c +0
-0@@ -107,15 +107,17 @@ int main(void) {
tests/random.c int main(void) · line 117
Quoted 10 lines
tests/random.c +2
-0RandomState *state;int i; +int ret;unsigned long rand; state =drmRandomCreate (1 );for (i =0 ; i <10000 ; i++) { rand =drmRandom (state); } + ret = rand - state->check;
Since you are touching this line, I think rand != state->check would be more readable.
Quoted 14 lines
tests/random.c +2
-2printf ("After 10000 iterations: %lu (%lu expected): %s\n" , rand, state->check, - rand - state->check ?"*INCORRECT*" :"CORRECT" ); + ret ?"*INCORRECT*" :"CORRECT" );drmRandomDestroy (state);printf ("Checking periods...\n" );@@ -123,5 +125,5 @@ int main(void)check_period (2 );check_period (31415926 ); -return 0 ; +return ret; }
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/9 drm: replace HASH_DEBUG with DEBUG
In reply to Emil Velikov... and remove the useless SL_DEBUG and RANDOM_DEBUG
--- xf86drmHash.c | 5 ++--- xf86drmRandom.c | 1 - xf86drmSL.c | 1 - 3 files changed, 2 insertions(+), 5 deletions(-)
xf86drmHash.c +2 -3
@@ -74,7 +74,6 @@#include "xf86drm.h" #define HASH_MAGIC 0xdeadbeef -#define HASH_DEBUG 0#define HASH_SIZE 512/* Good for about 100 entries */ /* If you change this value, you probably have to change the HashHash hashing
@@ -119,7 +118,7 @@ static unsigned long HashHash(unsigned long key) } hash %=HASH_SIZE ; -#if HASH_DEBUG +#if DEBUG printf ("Hash(%d) = %d\n" , key, hash);#endif return hash;
@@ -222,7 +221,7 @@ int drmHashInsert(void *t, unsigned long key, void *value) bucket->value = value; bucket->next = table->buckets[hash]; table->buckets[hash] = bucket; -#if HASH_DEBUG +#if DEBUG printf ("Inserted %d at %d/%p\n" , key, hash, bucket);#endif return 0 ;/* Added to table */
xf86drmRandom.c +0 -1
@@ -77,7 +77,6 @@#include "xf86drm.h" #define RANDOM_MAGIC 0xfeedbeef -#define RANDOM_DEBUG 0 typedef struct RandomState { unsigned long magic;
xf86drmSL.c +0 -1
@@ -53,7 +53,6 @@#define SL_ENTRY_MAGIC 0x00fab1edLU#define SL_FREED_MAGIC 0xdecea5edLU#define SL_MAX_LEVEL 16 -#define SL_DEBUG 0#define SL_RANDOM_SEED 0xc01055a1LU#if SL_MAIN
Signature · 6 lines
2.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 8/9] drm: replace HASH_DEBUG with DEBUG
Quoted 56 lines · Emil Velikov
... and remove the useless
SL_DEBUGandRANDOM_DEBUGSigned-off-by Emil Velikov <[email protected]>--- xf86drmHash.c | 5 ++--- xf86drmRandom.c | 1 - xf86drmSL.c | 1 - 3 files changed, 2 insertions(+), 5 deletions(-)xf86drmHash.c +2
-3@@ -74,7 +74,6 @@#include "xf86drm.h" #define HASH_MAGIC 0xdeadbeef -#define HASH_DEBUG 0#define HASH_SIZE 512/* Good for about 100 entries */ /* If you change this value, you probably have to change the HashHash hashing @@ -119,7 +118,7 @@ static unsigned long HashHash(unsigned long key) } hash %=HASH_SIZE ; -#if HASH_DEBUG +#if DEBUG printf ("Hash(%d) = %d\n" , key, hash);#endif return hash;@@ -222,7 +221,7 @@ int drmHashInsert(void *t, unsigned long key, void *value) bucket->value = value; bucket->next = table->buckets[hash]; table->buckets[hash] = bucket; -#if HASH_DEBUG +#if DEBUG printf ("Inserted %d at %d/%p\n" , key, hash, bucket);#endif return 0 ;/* Added to table */ xf86drmRandom.c +0
-1@@ -77,7 +77,6 @@#include "xf86drm.h" #define RANDOM_MAGIC 0xfeedbeef -#define RANDOM_DEBUG 0 typedef struct RandomState { unsigned long magic;xf86drmSL.c +0
-0
xf86drmSL.c line 58
Quoted 7 lines
xf86drmSL.c +0
-1@@ -53,7 +53,6 @@#define SL_ENTRY_MAGIC 0x00fab1edLU#define SL_FREED_MAGIC 0xdecea5edLU#define SL_MAX_LEVEL 16 -#define SL_DEBUG 0#define SL_RANDOM_SEED 0xc01055a1LU#if SL_MAIN
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 9/9 drm: use correct printf modifiers
In reply to Emil VelikovThe valies are unsigned long, thus we should use %lu.
--- xf86drmHash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
xf86drmHash.c +3 -2
@@ -119,7 +119,7 @@ static unsigned long HashHash(unsigned long key) hash %=HASH_SIZE ;#if DEBUG -printf ("Hash(%d) = %d\n" , key, hash); +printf ("Hash(%lu) = %lu\n" , key, hash);#endif return hash; }
@@ -221,8 +221,9 @@ int drmHashInsert(void *t, unsigned long key, void *value) bucket->value = value; bucket->next = table->buckets[hash]; table->buckets[hash] = bucket; -#if DEBUG printf ("Inserted %d at %d/%p\n" , key, hash, bucket); +#if DEBUG +printf ("Inserted %lu at %lu/%p\n" , key, hash, bucket);#endif return 0 ;/* Added to table */ }
Signature · 6 lines
2.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 9/9] drm: use correct printf modifiers
Quoted 21 lines · Emil Velikov
The valies are unsigned long, thus we should use %lu.
Signed-off-by Emil Velikov <[email protected]>--- xf86drmHash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)xf86drmHash.c +1
-1@@ -119,7 +119,7 @@ static unsigned long HashHash(unsigned long key) hash %=HASH_SIZE ;#if DEBUG -printf ("Hash(%d) = %d\n" , key, hash); +printf ("Hash(%lu) = %lu\n" , key, hash);#endif return hash; }
xf86drmHash.c int drmHashInsert(void *t, unsigned long key, void *value) · line 227
Quoted 8 lines
xf86drmHash.c +2
-1@@ -221,8 +221,9 @@ int drmHashInsert(void *t, unsigned long key, void *value) bucket->value = value; bucket->next = table->buckets[hash]; table->buckets[hash] = bucket; -#if DEBUG printf ("Inserted %d at %d/%p\n" , key, hash, bucket); +#if DEBUG +printf ("Inserted %lu at %lu/%p\n" , key, hash, bucket);#endif
^^ This change looks funny in the patch. I assume you just replace the printf call? If that's so LGTM
Quoted 2 lines
xf86drmHash.c +0
-0return 0 ;/* Added to table */ }
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 5 lines · Emil Velikov
This series covers
- Remove the hackish "includexf86drmfoo.c" from dristat
- Extract the remaining twoxf86drmfoo.ctests to standalone ones
- beat them into shape, and
- wire them up to make check.
I finished going through the series. Feel free to ignore the internal header suggestions, I don;t think the risk of desynchronizing structures in test and implementation is real since few ppl will touch it anyway.
drmHash test looks weird after cleanup.
other than that looks good
regards,
jan
Quoted 8 lines
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Jan Vesely
Quoted 5 lines · Emil Velikov
This series covers
- Remove the hackish "includexf86drmfoo.c" from dristat
- Extract the remaining twoxf86drmfoo.ctests to standalone ones
- beat them into shape, and
- wire them up to make check.
Quoted 7 lines
I finished going through the series. Feel free to ignore the internal header suggestions, I don;t think the risk of desynchronizing structures in test and implementation is real since few ppl will touch it anyway.
drmHash test looks weird after cleanup.
other than that looks good
Thanks I'll update the series (incorporating all of your comments), drop patch 1 for now, and send it out in a bit.
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel