Browse code

* fix error value EINVAL on enumerate and improve comments detailing error codes

Nat! authored on 21-05-2019 18:21:23 • Nat! committed on 27-05-2019 14:48:59
Showing 5 changed files
... ...
@@ -1,3 +1,7 @@
1
+### 2.2.3
2
+
3
+* fix error value EINVAL on enumerate and improve comments detailing error codes
4
+
1 5
 ### 2.2.2
2 6
 
3 7
 * modernized to mulle-sde with .mulle folder
... ...
@@ -35,7 +35,7 @@ if( NOT __ALL_LOAD_C_CMAKE__)
35 35
    # to generate an RPATH
36 36
    #
37 37
    function( CreateForceAllLoadList listname outputname)
38
-      if( ${${listname}})
38
+      if( ${listname})
39 39
          set( list ${BEGIN_ALL_LOAD})
40 40
          foreach( library ${${listname}})
41 41
             if( APPLE)
... ...
@@ -169,9 +169,9 @@ static struct _mulle_concurrent_hashvaluepair  *
169 169
 // register:
170 170
 //
171 171
 //  return value is either
172
-//     NULL  : an error occured (see ERRNO)
173
-//     value : means it did insert
174
-//     other : the read value
172
+//     MULLE_CONCURRENT_NO_POINTER      : means it did insert
173
+//     MULLE_CONCURRENT_INVALID_POINTER : is busy
174
+//     old                              : value that is already registered
175 175
 //
176 176
 static void   *_mulle_concurrent_hashmapstorage_register( struct _mulle_concurrent_hashmapstorage *p,
177 177
                                                           intptr_t hash,
... ...
@@ -211,7 +211,7 @@ static void   *_mulle_concurrent_hashmapstorage_register( struct _mulle_concurre
211 211
             entry->hash = hash;
212 212
          }
213 213
 
214
-         return( found);
214
+         return( found); // MULLE_CONCURRENT_NO_POINTER
215 215
       }
216 216
 
217 217
       ++index;
... ...
@@ -416,6 +416,14 @@ int  _mulle_concurrent_hashmap_init( struct mulle_concurrent_hashmap *map,
416 416
 {
417 417
    struct _mulle_concurrent_hashmapstorage   *storage;
418 418
 
419
+   //
420
+   // check assumption that we can use EINVAL ENOMEM ECANCELED and
421
+   // not clash with 0/1
422
+   //
423
+   assert( EINVAL != 1 && EINVAL != 0);
424
+   assert( ENOMEM != 1 && ENOMEM != 0);
425
+   assert( ECANCELED != 1 && ECANCELED != 0);
426
+
419 427
    if( ! allocator)
420 428
       allocator = &mulle_default_allocator;
421 429
 
... ...
@@ -587,7 +595,12 @@ static inline void   assert_hash_value( intptr_t hash, void *value)
587 595
    assert( value != MULLE_CONCURRENT_INVALID_POINTER);
588 596
 }
589 597
 
590
-
598
+//  return value:
599
+//
600
+//     MULLE_CONCURRENT_NO_POINTER      : means it did insert
601
+//     MULLE_CONCURRENT_INVALID_POINTER : error
602
+//     old                              : value that is already registered
603
+//
591 604
 void   *_mulle_concurrent_hashmap_register( struct mulle_concurrent_hashmap *map,
592 605
                                             intptr_t hash,
593 606
                                             void *value)
... ...
@@ -60,8 +60,8 @@ struct _mulle_concurrent_hashmapstorage
60 60
 static inline int
61 61
    _mulle_concurrent_hashmapstorage_is_const( struct _mulle_concurrent_hashmapstorage *p)
62 62
 {
63
-	// non atomic because const
64
-	return( _mulle_atomic_pointer_nonatomic_read( &p->n_hashs) == (void *) -1);
63
+   // non atomic because const
64
+   return( _mulle_atomic_pointer_nonatomic_read( &p->n_hashs) == (void *) -1);
65 65
 }
66 66
 
67 67
 
... ...
@@ -131,17 +131,17 @@ static inline unsigned int
131 131
 #pragma mark multi-threaded
132 132
 
133 133
 // Return value (rval):
134
-//   value                            : OK, inserted
135
-//   MULLE_CONCURRENT_INVALID_POINTER : an error occurred (see errno)
136
-//   other                            : retrieved value for hash
134
+//
135
+//     MULLE_CONCURRENT_NO_POINTER      : means it did insert
136
+//     MULLE_CONCURRENT_INVALID_POINTER : error (check errno)
137
+//     other                            : value that was already registered
137 138
 //
138 139
 // Do not use hash=0
139 140
 // Do not use value=0 or value=INTPTR_MIN
140 141
 //
141
-
142 142
 void   *mulle_concurrent_hashmap_register( struct mulle_concurrent_hashmap *map,
143
-                                                intptr_t hash,
144
-                                                void *value);
143
+                                           intptr_t hash,
144
+                                           void *value);
145 145
 // Return value (rval):
146 146
 //   0      : OK, inserted
147 147
 //   EEXIST : detected duplicate
... ...
@@ -198,7 +198,7 @@ struct mulle_concurrent_hashmapenumerator
198 198
 // stop (but will tell you). If the map grows, the rover is equally unhappy.
199 199
 //
200 200
 static inline struct mulle_concurrent_hashmapenumerator
201
-	mulle_concurrent_hashmap_enumerate( struct mulle_concurrent_hashmap *map)
201
+   mulle_concurrent_hashmap_enumerate( struct mulle_concurrent_hashmap *map)
202 202
 {
203 203
    struct mulle_concurrent_hashmapenumerator   rover;
204 204
 
... ...
@@ -225,7 +225,7 @@ static inline int
225 225
                                                  intptr_t *hash,
226 226
                                                  void **value);
227 227
    if( ! rover)
228
-      return( -EINVAL);
228
+      return( EINVAL);
229 229
    return( _mulle_concurrent_hashmapenumerator_next( rover, hash, value));
230 230
 }
231 231
 
... ...
@@ -34,7 +34,7 @@
34 34
 #ifndef mulle_concurrent_h__
35 35
 #define mulle_concurrent_h__
36 36
 
37
-#define MULLE_CONCURRENT_VERSION  ((2 << 20) | (2 << 8) | 2)
37
+#define MULLE_CONCURRENT_VERSION  ((2 << 20) | (2 << 8) | 3)
38 38
 
39 39
 #include "include.h"
40 40