src/os/unix/ngx_os.h - nginx-1.7.10

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_chain_pt  send_chain;
  22.     ngx_uint_t         flags;
  23. } ngx_os_io_t;


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


  30. ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
  31. ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry, off_t limit);
  32. ssize_t ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
  33. ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
  34. ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in,
  35.     off_t limit);

  36. #if (NGX_HAVE_AIO)
  37. ssize_t ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size);
  38. ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit);
  39. ssize_t ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size);
  40. ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in,
  41.     off_t limit);
  42. #endif


  43. #if (IOV_MAX > 64)
  44. #define NGX_IOVS_PREALLOCATE  64
  45. #else
  46. #define NGX_IOVS_PREALLOCATE  IOV_MAX
  47. #endif


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

  54. ngx_chain_t *ngx_output_chain_to_iovec(ngx_iovec_t *vec, ngx_chain_t *in,
  55.     size_t limit, ngx_log_t *log);


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


  57. extern ngx_os_io_t  ngx_os_io;
  58. extern ngx_int_t    ngx_ncpu;
  59. extern ngx_int_t    ngx_max_sockets;
  60. extern ngx_uint_t   ngx_inherited_nonblocking;
  61. extern ngx_uint_t   ngx_tcp_nodelay_and_tcp_nopush;


  62. #if (NGX_FREEBSD)
  63. #include <ngx_freebsd.h>


  64. #elif (NGX_LINUX)
  65. #include <ngx_linux.h>


  66. #elif (NGX_SOLARIS)
  67. #include <ngx_solaris.h>


  68. #elif (NGX_DARWIN)
  69. #include <ngx_darwin.h>
  70. #endif


  71. #endif /* _NGX_OS_H_INCLUDED_ */