Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 

72 рядки
2.0 KiB

  1. /* this header file comes from libowfat, http://www.fefe.de/libowfat/ */
  2. #ifndef BYTE_H
  3. #define BYTE_H
  4. /* for size_t: */
  5. #include <stddef.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /* dietlibc defines these in sys/cdefs.h, which is included from stddef.h */
  10. #ifndef __pure__
  11. #define __pure__
  12. #endif
  13. #ifndef __writememsz__
  14. #define __writememsz__(a,b)
  15. #define __readmemsz__(a,b)
  16. #endif
  17. /* byte_chr returns the smallest integer i between 0 and len-1
  18. * inclusive such that one[i] equals needle, or len if not found. */
  19. __readmemsz__(1,2)
  20. size_t byte_chr(const void* haystack, size_t len, char needle) __pure__;
  21. /* byte_rchr returns the largest integer i between 0 and len-1 inclusive
  22. * such that one[i] equals needle, or len if not found. */
  23. __readmemsz__(1,2)
  24. size_t byte_rchr(const void* haystack,size_t len,char needle) __pure__;
  25. /* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1]
  26. * to out[len-1]. */
  27. __writememsz__(1,2)
  28. __readmemsz__(3,2)
  29. void byte_copy(void* out, size_t len, const void* in);
  30. /* byte_copyr copies in[len-1] to out[len-1], in[len-2] to out[len-2],
  31. * ... and in[0] to out[0] */
  32. __writememsz__(1,2)
  33. __readmemsz__(3,2)
  34. void byte_copyr(void* out, size_t len, const void* in);
  35. /* byte_diff returns negative, 0, or positive, depending on whether the
  36. * string a[0], a[1], ..., a[len-1] is lexicographically smaller
  37. * than, equal to, or greater than the string b[0], b[1], ...,
  38. * b[len-1]. When the strings are different, byte_diff does not read
  39. * bytes past the first difference. */
  40. __readmemsz__(1,2)
  41. __readmemsz__(3,2)
  42. int byte_diff(const void* a, size_t len, const void* b) __pure__;
  43. /* byte_zero sets the bytes out[0], out[1], ..., out[len-1] to 0 */
  44. __writememsz__(1,2)
  45. void byte_zero(void* out, size_t len);
  46. #define byte_equal(s,n,t) (!byte_diff((s),(n),(t)))
  47. __readmemsz__(1,2)
  48. __readmemsz__(3,2)
  49. int byte_equal_notimingattack(const void* a, size_t len,const void* b) __pure__;
  50. #if defined(__i386__) || defined(__x86_64__)
  51. #define UNALIGNED_ACCESS_OK
  52. #endif
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif