annotate src/os/unix/ngx_sunpro_x86.il @ 6949:ff0c8e11edbc

Simplified and improved sendfile() code on Linux. The ngx_linux_sendfile() function is now used for both normal sendfile() and sendfile in threads. The ngx_linux_sendfile_thread() function was modified to use the same interface as ngx_linux_sendfile(), and is simply called from ngx_linux_sendfile() when threads are enabled. Special return code NGX_DONE is used to indicate that a thread task was posted and no further actions are needed. If number of bytes sent is less that what we were sending, we now always retry sending. This is needed for sendfile() in threads as the number of bytes we are sending might have been changed since the thread task was posted. And this is also needed for Linux 4.3+, as sendfile() might be interrupted at any time and provides no indication if it was interrupted or not (ticket #1174).
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 28 Mar 2017 18:15:39 +0300
parents 2cd019520210
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
561
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1 /
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 / Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 2818
diff changeset
3 / Copyright (C) Nginx, Inc.
561
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4 /
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6 / ngx_atomic_uint_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7 / ngx_atomic_uint_t old, ngx_atomic_uint_t set);
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 /
2818
7e02df612521 preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents: 1309
diff changeset
9 / the arguments are passed on stack (%esp), 4(%esp), 8(%esp)
561
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11 .inline ngx_atomic_cmp_set,0
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12 movl (%esp), %ecx
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13 movl 4(%esp), %eax
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14 movl 8(%esp), %edx
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15 lock
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 cmpxchgl %edx, (%ecx)
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17 setz %al
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18 movzbl %al, %eax
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19 .end
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
21
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22 / ngx_atomic_int_t ngx_atomic_fetch_add(ngx_atomic_t *value,
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 / ngx_atomic_int_t add);
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
24 /
2818
7e02df612521 preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents: 1309
diff changeset
25 / the arguments are passed on stack (%esp), 4(%esp)
561
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 .inline ngx_atomic_fetch_add,0
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 movl (%esp), %ecx
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29 movl 4(%esp), %eax
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 lock
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31 xaddl %eax, (%ecx)
e48ebafc6939 nginx-0.3.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 .end
1309
08c6ee7a1b11 Sun Studio 12 compatibility
Igor Sysoev <igor@sysoev.ru>
parents: 561
diff changeset
33
08c6ee7a1b11 Sun Studio 12 compatibility
Igor Sysoev <igor@sysoev.ru>
parents: 561
diff changeset
34
08c6ee7a1b11 Sun Studio 12 compatibility
Igor Sysoev <igor@sysoev.ru>
parents: 561
diff changeset
35 / ngx_cpu_pause()
2818
7e02df612521 preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents: 1309
diff changeset
36 /
7e02df612521 preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents: 1309
diff changeset
37 / the "rep; nop" is used instead of "pause" to avoid the "[ PAUSE ]" hardware
7e02df612521 preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents: 1309
diff changeset
38 / capability added by linker because Solaris/i386 does not know about it:
7e02df612521 preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents: 1309
diff changeset
39 /
7e02df612521 preserve Solaris binary hardware capabilities
Igor Sysoev <igor@sysoev.ru>
parents: 1309
diff changeset
40 / ld.so.1: nginx: fatal: hardware capability unsupported: 0x2000 [ PAUSE ]
1309
08c6ee7a1b11 Sun Studio 12 compatibility
Igor Sysoev <igor@sysoev.ru>
parents: 561
diff changeset
41
6474
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
42 .inline ngx_cpu_pause,0
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
43 rep; nop
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
44 .end