3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
8 #include <ngx_config.h>
12 ngx_uint_t ngx_pagesize
;
13 ngx_uint_t ngx_pagesize_shift
;
14 ngx_uint_t ngx_cacheline_size
;
18 ngx_alloc(size_t size
, ngx_log_t
*log
)
24 ngx_log_error(NGX_LOG_EMERG
, log
, ngx_errno
,
25 "malloc(%uz) failed", size
);
28 ngx_log_debug2(NGX_LOG_DEBUG_ALLOC
, log
, 0, "malloc: %p:%uz", p
, size
);
35 ngx_calloc(size_t size
, ngx_log_t
*log
)
39 p
= ngx_alloc(size
, log
);
49 #if (NGX_HAVE_POSIX_MEMALIGN)
52 ngx_memalign(size_t alignment
, size_t size
, ngx_log_t
*log
)
57 err
= posix_memalign(&p
, alignment
, size
);
60 ngx_log_error(NGX_LOG_EMERG
, log
, err
,
61 "posix_memalign(%uz, %uz) failed", alignment
, size
);
65 ngx_log_debug3(NGX_LOG_DEBUG_ALLOC
, log
, 0,
66 "posix_memalign: %p:%uz @%uz", p
, size
, alignment
);
71 #elif (NGX_HAVE_MEMALIGN)
74 ngx_memalign(size_t alignment
, size_t size
, ngx_log_t
*log
)
78 p
= memalign(alignment
, size
);
80 ngx_log_error(NGX_LOG_EMERG
, log
, ngx_errno
,
81 "memalign(%uz, %uz) failed", alignment
, size
);
84 ngx_log_debug3(NGX_LOG_DEBUG_ALLOC
, log
, 0,
85 "memalign: %p:%uz @%uz", p
, size
, alignment
);