Changeset 5c90e3e in mainline for uspace/lib/bithenge/src/failure.h


Ignore:
Timestamp:
2012-10-18T22:38:27Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
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.
Message:

merge mainline changes

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/bithenge/src/failure.h

    rb801f2d r5c90e3e  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
    3  * Copyright (c) 2011 Radim Vansa
     2 * Copyright (c) 2012 Sean Bartell
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 /** @addtogroup libc
     29/** @cond internal */
     30/** @addtogroup bithenge
    3131 * @{
    3232 */
    33 /** @file
     33/**
     34 * @file
     35 * Fake system call errors for testing.
    3436 */
    3537
    36 #ifndef LIBC_HASH_SET_H_
    37 #define LIBC_HASH_SET_H_
     38#ifndef BITHENGE_FAILURE_H_
     39#define BITHENGE_FAILURE_H_
    3840
    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>
    4046#include <unistd.h>
    4147
    42 #define HASH_SET_MIN_SIZE  8
     48int bithenge_should_fail(void);
     49void *bithenge_failure_malloc(size_t);
     50void *bithenge_failure_realloc(void *, size_t);
     51ssize_t bithenge_failure_read(int, void *, size_t);
     52off_t bithenge_failure_lseek(int, off_t, int);
     53int bithenge_failure_ferror(FILE *);
     54char *bithenge_failure_str_ndup(const char *, size_t);
     55int bithenge_failure_open(const char *, int);
     56int bithenge_failure_fstat(int, struct stat *);
    4357
    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
    8068
    8169#endif
     
    8371/** @}
    8472 */
     73
     74/** @endcond */
     75
Note: See TracChangeset for help on using the changeset viewer.