compat.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef COMPAT_H
  22. #define COMPAT_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #ifndef HAVE_OFFSETOF
  27. #define offsetof(st, m) ((size_t)&((st *)NULL)->m)
  28. #endif
  29. /*
  30. * Define WCOREDUMP if we don't have it already, coredumps won't be
  31. * detected, though.
  32. */
  33. #ifndef HAVE_WCOREDUMP
  34. #define WCOREDUMP(x) 0
  35. #endif
  36. #ifndef HAVE_STRTOUL
  37. #define strtoul strtol
  38. #endif
  39. #ifndef HAVE_VA_COPY
  40. #include <string.h>
  41. #define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
  42. #endif
  43. #include <strnlen.h>
  44. #ifndef HAVE_STRERROR
  45. const char *strerror(int);
  46. #endif
  47. #ifndef HAVE_STRSIGNAL
  48. const char *strsignal(int);
  49. #endif
  50. #ifndef HAVE_SCANDIR
  51. struct dirent;
  52. int scandir(const char *dir, struct dirent ***namelist,
  53. int (*filter)(const struct dirent *),
  54. int (*cmp)(const void *, const void *));
  55. #endif
  56. #ifndef HAVE_ALPHASORT
  57. int alphasort(const void *a, const void *b);
  58. #endif
  59. #ifndef HAVE_UNSETENV
  60. int unsetenv(const char *x);
  61. #endif
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* COMPAT_H */