Changeset 5c90e3e in mainline for uspace/lib/bithenge/src/failure.h
- Timestamp:
- 2012-10-18T22:38:27Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 508fff8
- Parents:
- b801f2d (diff), 7d248e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
uspace/lib/bithenge/src/failure.h (moved) (moved from uspace/lib/c/include/adt/hash_set.h ) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/bithenge/src/failure.h
rb801f2d r5c90e3e 1 1 /* 2 * Copyright (c) 2006 Jakub Jermar 3 * Copyright (c) 2011 Radim Vansa 2 * Copyright (c) 2012 Sean Bartell 4 3 * All rights reserved. 5 4 * … … 28 27 */ 29 28 30 /** @addtogroup libc 29 /** @cond internal */ 30 /** @addtogroup bithenge 31 31 * @{ 32 32 */ 33 /** @file 33 /** 34 * @file 35 * Fake system call errors for testing. 34 36 */ 35 37 36 #ifndef LIBC_HASH_SET_H_37 #define LIBC_HASH_SET_H_38 #ifndef BITHENGE_FAILURE_H_ 39 #define BITHENGE_FAILURE_H_ 38 40 39 #include <adt/list.h> 41 #include <fcntl.h> 42 #include <stdio.h> 43 #include <stdlib.h> 44 #include <sys/stat.h> 45 #include <sys/types.h> 40 46 #include <unistd.h> 41 47 42 #define HASH_SET_MIN_SIZE 8 48 int bithenge_should_fail(void); 49 void *bithenge_failure_malloc(size_t); 50 void *bithenge_failure_realloc(void *, size_t); 51 ssize_t bithenge_failure_read(int, void *, size_t); 52 off_t bithenge_failure_lseek(int, off_t, int); 53 int bithenge_failure_ferror(FILE *); 54 char *bithenge_failure_str_ndup(const char *, size_t); 55 int bithenge_failure_open(const char *, int); 56 int bithenge_failure_fstat(int, struct stat *); 43 57 44 typedef unsigned long (*hash_set_hash)(const link_t *); 45 typedef int (*hash_set_equals)(const link_t *, const link_t *); 46 47 /** Hash table structure. */ 48 typedef struct { 49 list_t *table; 50 51 /** Current table size */ 52 size_t size; 53 54 /** 55 * Current number of entries. If count > size, 56 * the table is rehashed into table with double 57 * size. If (4 * count < size) && (size > min_size), 58 * the table is rehashed into table with half the size. 59 */ 60 size_t count; 61 62 /** Hash function */ 63 hash_set_hash hash; 64 65 /** Hash table item equals function */ 66 hash_set_equals equals; 67 } hash_set_t; 68 69 extern int hash_set_init(hash_set_t *, hash_set_hash, hash_set_equals, size_t); 70 extern int hash_set_insert(hash_set_t *, link_t *); 71 extern link_t *hash_set_find(hash_set_t *, const link_t *); 72 extern int hash_set_contains(const hash_set_t *, const link_t *); 73 extern size_t hash_set_count(const hash_set_t *); 74 extern link_t *hash_set_remove(hash_set_t *, const link_t *); 75 extern void hash_set_remove_selected(hash_set_t *, 76 int (*)(link_t *, void *), void *); 77 extern void hash_set_destroy(hash_set_t *); 78 extern void hash_set_apply(hash_set_t *, void (*)(link_t *, void *), void *); 79 extern void hash_set_clear(hash_set_t *, void (*)(link_t *, void *), void *); 58 #ifndef BITHENGE_FAILURE_DECLS_ONLY 59 #define malloc bithenge_failure_malloc 60 #define realloc bithenge_failure_realloc 61 #define read bithenge_failure_read 62 #define lseek bithenge_failure_lseek 63 #define ferror bithenge_failure_ferror 64 #define str_ndup bithenge_failure_str_ndup 65 #define open bithenge_failure_open 66 #define fstat bithenge_failure_fstat 67 #endif 80 68 81 69 #endif … … 83 71 /** @} 84 72 */ 73 74 /** @endcond */ 75
Note:
See TracChangeset
for help on using the changeset viewer.
