watchdog.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
  3. * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License version 2.1
  7. * as published by the Free Software Foundation
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef __PROCD_WATCHDOG_H
  15. #define __PROCD_WATCHDOG_H
  16. #include <stdbool.h>
  17. #ifndef DISABLE_INIT
  18. void watchdog_init(int preinit);
  19. char* watchdog_fd(void);
  20. int watchdog_timeout(int timeout);
  21. int watchdog_frequency(int frequency);
  22. void watchdog_set_magicclose(bool val);
  23. bool watchdog_get_magicclose(void);
  24. void watchdog_set_stopped(bool val);
  25. bool watchdog_get_stopped(void);
  26. void watchdog_set_cloexec(bool val);
  27. void watchdog_ping(void);
  28. #else
  29. static inline void watchdog_init(int preinit)
  30. {
  31. }
  32. static inline char* watchdog_fd(void)
  33. {
  34. return "";
  35. }
  36. static inline int watchdog_timeout(int timeout)
  37. {
  38. return 0;
  39. }
  40. static inline int watchdog_frequency(int frequency)
  41. {
  42. return 0;
  43. }
  44. static inline void watchdog_set_magicclose(bool val)
  45. {
  46. }
  47. static inline bool watchdog_get_magicclose(void)
  48. {
  49. return false;
  50. }
  51. static inline void watchdog_set_stopped(bool val)
  52. {
  53. }
  54. static inline bool watchdog_get_stopped(void)
  55. {
  56. return true;
  57. }
  58. static inline void watchdog_set_cloexec(bool val)
  59. {
  60. }
  61. static inline void watchdog_ping(void)
  62. {
  63. }
  64. #endif
  65. #endif