hslot.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 FhG Fokus
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /*! \file
  23. * \brief USRLOC - Hash table collision slot related functions
  24. * \ingroup usrloc
  25. */
  26. #ifndef HSLOT_H
  27. #define HSLOT_H
  28. #include "../../locking.h"
  29. #include "udomain.h"
  30. #include "urecord.h"
  31. struct udomain;
  32. struct urecord;
  33. typedef struct hslot {
  34. int n; /*!< Number of elements in the collision slot */
  35. struct urecord* first; /*!< First element in the list */
  36. struct urecord* last; /*!< Last element in the list */
  37. struct udomain* d; /*!< Domain we belong to */
  38. #ifdef GEN_LOCK_T_PREFERED
  39. gen_lock_t *lock; /*!< Lock for hash entry - fastlock */
  40. #else
  41. int lockidx; /*!< Lock index for hash entry - the rest*/
  42. #endif
  43. } hslot_t;
  44. /*! \brief
  45. * Initialize slot structure
  46. */
  47. void init_slot(struct udomain* _d, hslot_t* _s, int n);
  48. /*! \brief
  49. * Deinitialize given slot structure
  50. */
  51. void deinit_slot(hslot_t* _s);
  52. /*! \brief
  53. * Add an element to slot linked list
  54. */
  55. void slot_add(hslot_t* _s, struct urecord* _r);
  56. /*! \brief
  57. * Remove an element from slot linked list
  58. */
  59. void slot_rem(hslot_t* _s, struct urecord* _r);
  60. /*!
  61. * \brief Initialize locks for the hash table
  62. * \return 0 on success, -1 on failure
  63. */
  64. int ul_init_locks(void);
  65. /*!
  66. * \brief Destroy all locks on the list
  67. */
  68. void ul_unlock_locks(void);
  69. void ul_destroy_locks(void);
  70. #ifndef GEN_LOCK_T_PREFERED
  71. void ul_lock_idx(int idx);
  72. void ul_release_idx(int idx);
  73. #endif
  74. #endif /* HSLOT_H */