src/os/unix/ngx_os.h - nginx source code

Data types defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #ifndef _NGX_OS_H_INCLUDED_
  6. #define _NGX_OS_H_INCLUDED_


  7. #include <ngx_config.h>
  8. #include <ngx_core.h>


  9. #define NGX_IO_SENDFILE    1


  10. typedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size);
  11. typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in,
  12.     off_t limit);
  13. typedef ssize_t (*ngx_send_pt)(ngx_connection_t *c, u_char *buf, size_t size);
  14. typedef ngx_chain_t *(*ngx_send_chain_pt)(ngx_connection_t *c, ngx_chain_t *in,
  15.     off_t limit);

  16. typedef struct {
  17.     ngx_recv_pt        recv;
  18.     ngx_recv_chain_pt  recv_chain;
  19.     ngx_recv_pt        udp_recv;
  20.     ngx_send_pt        send;
  21.     ngx_send_pt        udp_send;
  22.     ngx_send_chain_pt  udp_send_chain;
  23.     ngx_send_chain_pt  send_chain;
  24.     ngx_uint_t         flags;
  25. } ngx_os_io_t;


  26. ngx_int_t ngx_os_init(ngx_log_t *log);
  27. void ngx_os_status(ngx_log_t *log);
  28. ngx_int_t ngx_os_specific_init(ngx_log_t *log);
  29. void ngx_os_specific_status(ngx_log_t *log);
  30. ngx_int_t ngx_daemon(ngx_log_t *log);
  31. ngx_int_t ngx_os_signal_process(ngx_cycle_t *cycle, char *sig, ngx_pid_t pid);


  32. ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
  33. ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry, off_t limit);
  34. ssize_t ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
  35. ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
  36. ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in,
  37.     off_t limit);
  38. ssize_t ngx_udp_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
  39. ngx_chain_t *ngx_udp_unix_sendmsg_chain(ngx_connection_t *c, ngx_chain_t *in,
  40.     off_t limit);


  41. #if (IOV_MAX > 64)
  42. #define NGX_IOVS_PREALLOCATE  64
  43. #else
  44. #define NGX_IOVS_PREALLOCATE  IOV_MAX
  45. #endif


  46. typedef struct {
  47.     struct iovec  *iovs;
  48.     ngx_uint_t     count;
  49.     size_t         size;
  50.     ngx_uint_t     nalloc;
  51. } ngx_iovec_t;

  52. ngx_chain_t *ngx_output_chain_to_iovec(ngx_iovec_t *vec, ngx_chain_t *in,
  53.     size_t limit, ngx_log_t *log);


  54. ssize_t ngx_writev(ngx_connection_t *c, ngx_iovec_t *vec);


  55. extern ngx_os_io_t  ngx_os_io;
  56. extern ngx_int_t    ngx_ncpu;
  57. extern ngx_int_t    ngx_max_sockets;
  58. extern ngx_uint_t   ngx_inherited_nonblocking;
  59. extern ngx_uint_t   ngx_tcp_nodelay_and_tcp_nopush;


  60. #if (NGX_FREEBSD)
  61. #include <ngx_freebsd.h>


  62. #elif (NGX_LINUX)
  63. #include <ngx_linux.h>


  64. #elif (NGX_SOLARIS)
  65. #include <ngx_solaris.h>


  66. #elif (NGX_DARWIN)
  67. #include <ngx_darwin.h>
  68. #endif


  69. #endif /* _NGX_OS_H_INCLUDED_ */