You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
2.7 KiB

  1. #!/bin/sh
  2. include_dir=../../include/openssl
  3. out=${include_dir}/lhash_macros.h
  4. cat > $out << EOF
  5. /* Copyright (c) 2014, Google Inc.
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  14. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  16. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  17. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  18. #if !defined(IN_LHASH_H)
  19. #error "Don't include this file directly. Include lhash.h"
  20. #endif
  21. EOF
  22. output_lhash () {
  23. type=$1
  24. cat >> $out << EOF
  25. // ${type}
  26. #define lh_${type}_new(hash, comp)\\
  27. ((LHASH_OF(${type})*) lh_new(CHECKED_CAST(lhash_hash_func, uint32_t (*) (const ${type} *), hash), CHECKED_CAST(lhash_cmp_func, int (*) (const ${type} *a, const ${type} *b), comp)))
  28. #define lh_${type}_free(lh)\\
  29. lh_free(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh));
  30. #define lh_${type}_num_items(lh)\\
  31. lh_num_items(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh))
  32. #define lh_${type}_retrieve(lh, data)\\
  33. ((${type}*) lh_retrieve(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void*, ${type}*, data)))
  34. #define lh_${type}_retrieve_key(lh, key, key_hash, cmp_key)\\
  35. ((${type}*) lh_retrieve_key(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), key, key_hash, CHECKED_CAST(int (*)(const void *, const void *), int (*)(const void *, const ${type} *), cmp_key)))
  36. #define lh_${type}_insert(lh, old_data, data)\\
  37. lh_insert(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void**, ${type}**, old_data), CHECKED_CAST(void*, ${type}*, data))
  38. #define lh_${type}_delete(lh, data)\\
  39. ((${type}*) lh_delete(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void*, ${type}*, data)))
  40. #define lh_${type}_doall(lh, func)\\
  41. lh_doall(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void (*)(void*), void (*) (${type}*), func));
  42. #define lh_${type}_doall_arg(lh, func, arg)\\
  43. lh_doall_arg(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void (*)(void*, void*), void (*) (${type}*, void*), func), arg);
  44. EOF
  45. }
  46. lhash_types=$(cat ${include_dir}/lhash.h | grep '^// LHASH_OF:' | sed -e 's/.*LHASH_OF://' -e 's/ .*//')
  47. for type in $lhash_types; do
  48. echo Hash of ${type}
  49. output_lhash "${type}"
  50. done
  51. clang-format -i $out