compat.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * libcompat - system compatibility library
  3. * compat.h - system compatibility declarations
  4. *
  5. * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. * Copyright © 2008, 2009 Guillem Jover <guillem@debian.org>
  7. *
  8. * This is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2,
  11. * or (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful, but
  14. * 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
  19. * License along with dpkg; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #ifndef COMPAT_H
  23. #define COMPAT_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #ifndef HAVE_OFFSETOF
  28. #define offsetof(st, m) ((size_t)&((st *)NULL)->m)
  29. #endif
  30. /*
  31. * Define WCOREDUMP if we don't have it already, coredumps won't be
  32. * detected, though.
  33. */
  34. #ifndef HAVE_WCOREDUMP
  35. #define WCOREDUMP(x) 0
  36. #endif
  37. #ifndef HAVE_STRTOUL
  38. #define strtoul strtol
  39. #endif
  40. #ifndef HAVE_VA_COPY
  41. #include <string.h>
  42. #define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
  43. #endif
  44. #include <strnlen.h>
  45. #ifndef HAVE_STRERROR
  46. const char *strerror(int);
  47. #endif
  48. #ifndef HAVE_STRSIGNAL
  49. const char *strsignal(int);
  50. #endif
  51. #ifndef HAVE_SCANDIR
  52. struct dirent;
  53. int scandir(const char *dir, struct dirent ***namelist,
  54. int (*filter)(const struct dirent *),
  55. int (*cmp)(const void *, const void *));
  56. #endif
  57. #ifndef HAVE_ALPHASORT
  58. int alphasort(const void *a, const void *b);
  59. #endif
  60. #ifndef HAVE_UNSETENV
  61. int unsetenv(const char *x);
  62. #endif
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif /* COMPAT_H */