etc.git


etc

~ scripts and random things
git clone https://github.com/djnnvx/etc.git
log | files | refs | archive

uv.h (3082B)

      1 #pragma once
      2 /* Minimal libuv stub for fuzzing ttyd — only types, no event loop. */
      3 #include <stddef.h>
      4 #include <stdint.h>
      5 #include <sys/types.h>
      6 
      7 typedef struct uv_loop_s       uv_loop_t;
      8 typedef struct uv_handle_s     uv_handle_t;
      9 typedef struct uv_async_s      uv_async_t;
     10 typedef struct uv_pipe_s       uv_pipe_t;
     11 typedef struct uv_timer_s      uv_timer_t;
     12 typedef struct uv_thread_s     uv_thread_t;
     13 typedef struct uv_mutex_s      uv_mutex_t;
     14 typedef struct uv_process_s    uv_process_t;
     15 typedef struct uv_signal_s     uv_signal_t;
     16 
     17 struct uv_loop_s   { void *data; };
     18 struct uv_handle_s { void *data; uv_loop_t *loop; };
     19 struct uv_async_s  { void *data; uv_loop_t *loop; };
     20 struct uv_pipe_s   { void *data; uv_loop_t *loop; };
     21 struct uv_timer_s  { void *data; uv_loop_t *loop; };
     22 struct uv_thread_s { unsigned long _tid; };
     23 struct uv_mutex_s  { int _m; };
     24 struct uv_process_s{ void *data; };
     25 struct uv_signal_s { void *data; };
     26 
     27 typedef void (*uv_close_cb)(uv_handle_t *handle);
     28 typedef void (*uv_async_cb)(uv_async_t *handle);
     29 typedef void (*uv_alloc_cb)(uv_handle_t *handle, size_t suggested_size, void *buf);
     30 typedef void (*uv_read_cb)(uv_pipe_t *stream, ssize_t nread, const void *buf);
     31 typedef void (*uv_exit_cb)(uv_process_t *process, int64_t exit_status, int term_signal);
     32 typedef void (*uv_walk_cb)(uv_handle_t *handle, void *arg);
     33 typedef void (*uv_thread_cb)(void *arg);
     34 typedef void (*uv_timer_cb)(uv_timer_t *handle);
     35 
     36 #define UV_RUN_DEFAULT 0
     37 #define UV_RUN_ONCE    1
     38 #define UV_RUN_NOWAIT  2
     39 
     40 static inline int   uv_loop_init(uv_loop_t *l)               { return 0; }
     41 static inline int   uv_run(uv_loop_t *l, int mode)            { return 0; }
     42 static inline void  uv_stop(uv_loop_t *l)                     {}
     43 static inline int   uv_loop_close(uv_loop_t *l)               { return 0; }
     44 static inline void  uv_close(uv_handle_t *h, uv_close_cb cb)  {}
     45 static inline int   uv_async_init(uv_loop_t *l, uv_async_t *a, uv_async_cb cb) { a->loop = l; return 0; }
     46 static inline int   uv_async_send(uv_async_t *a)              { return 0; }
     47 static inline int   uv_timer_init(uv_loop_t *l, uv_timer_t *t){ return 0; }
     48 static inline int   uv_timer_start(uv_timer_t *t, uv_timer_cb cb, uint64_t timeout, uint64_t repeat) { return 0; }
     49 static inline int   uv_timer_stop(uv_timer_t *t)              { return 0; }
     50 static inline int   uv_mutex_init(uv_mutex_t *m)              { return 0; }
     51 static inline void  uv_mutex_lock(uv_mutex_t *m)              {}
     52 static inline void  uv_mutex_unlock(uv_mutex_t *m)            {}
     53 static inline void  uv_mutex_destroy(uv_mutex_t *m)           {}
     54 static inline int   uv_thread_create(uv_thread_t *t, uv_thread_cb cb, void *arg) { return 0; }
     55 static inline int   uv_thread_join(uv_thread_t *t)            { return 0; }
     56 static inline uv_loop_t *uv_default_loop(void)                { return NULL; }
     57 static inline int          uv_walk(uv_loop_t *l, uv_walk_cb cb, void *arg) { return 0; }
     58 static inline const char  *uv_err_name(int err)   { return "UNKNOWN"; }
     59 static inline const char  *uv_strerror(int err)   { return "unknown error"; }