3
0

runit_lib.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. Copyright (c) 2001-2006, Gerrit Pape
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. 1. Redistributions of source code must retain the above copyright notice,
  7. this list of conditions and the following disclaimer.
  8. 2. Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. 3. The name of the author may not be used to endorse or promote products
  12. derived from this software without specific prior written permission.
  13. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  14. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  15. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  16. EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  19. OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  20. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  21. OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  22. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #if __GNUC_PREREQ(4,1)
  25. # pragma GCC visibility push(hidden)
  26. #endif
  27. extern unsigned byte_chr(char *s,unsigned n,int c);
  28. #define direntry struct dirent
  29. //struct tai {
  30. // uint64_t x;
  31. //};
  32. //
  33. //#define tai_unix(t,u) ((void) ((t)->x = 0x400000000000000aULL + (uint64_t) (u)))
  34. //
  35. //#define TAI_PACK 8
  36. //extern void tai_unpack(const char *,struct tai *);
  37. //
  38. //extern void tai_uint(struct tai *,unsigned);
  39. //
  40. //struct taia {
  41. // struct tai sec;
  42. // unsigned long nano; /* 0...999999999 */
  43. // unsigned long atto; /* 0...999999999 */
  44. //};
  45. //
  46. //extern void taia_now(struct taia *);
  47. //
  48. //extern void taia_add(struct taia *,const struct taia *,const struct taia *);
  49. //extern void taia_addsec(struct taia *,const struct taia *,int);
  50. //extern void taia_sub(struct taia *,const struct taia *,const struct taia *);
  51. //extern void taia_half(struct taia *,const struct taia *);
  52. //extern int taia_less(const struct taia *,const struct taia *);
  53. //
  54. //#define TAIA_PACK 16
  55. //extern void taia_pack(char *,const struct taia *);
  56. //
  57. //extern void taia_uint(struct taia *,unsigned);
  58. //
  59. //typedef struct pollfd iopause_fd;
  60. //#define IOPAUSE_READ POLLIN
  61. //#define IOPAUSE_WRITE POLLOUT
  62. //
  63. //extern void iopause(iopause_fd *,unsigned,struct taia *,struct taia *);
  64. extern int lock_ex(int);
  65. extern int lock_un(int);
  66. extern int lock_exnb(int);
  67. extern int open_read(const char *);
  68. extern int open_excl(const char *);
  69. extern int open_append(const char *);
  70. extern int open_trunc(const char *);
  71. extern int open_write(const char *);
  72. extern unsigned pmatch(const char *, const char *, unsigned);
  73. #define str_diff(s,t) strcmp((s), (t))
  74. #define str_equal(s,t) (!strcmp((s), (t)))
  75. /*
  76. * runsv / supervise / sv stuff
  77. */
  78. typedef struct svstatus_t {
  79. uint64_t time_be64 ATTRIBUTE_PACKED;
  80. uint32_t time_nsec_be32 ATTRIBUTE_PACKED;
  81. uint32_t pid_le32 ATTRIBUTE_PACKED;
  82. uint8_t paused;
  83. uint8_t want;
  84. uint8_t got_term;
  85. uint8_t run_or_finish;
  86. } svstatus_t;
  87. struct ERR_svstatus_must_be_20_bytes {
  88. char ERR_svstatus_must_be_20_bytes[sizeof(svstatus_t) == 20 ? 1 : -1];
  89. };
  90. #if __GNUC_PREREQ(4,1)
  91. # pragma GCC visibility pop
  92. #endif