summaryrefslogtreecommitdiffstats
path: root/arch/i386/lib/semaphore.S
blob: faddbf4ec07936b58c2e51efbca3b5d9e2c63ae7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 *  linux/arch/i386/lib/semaphore.S
 *
 *  Copyright (C) 1996  Linus Torvalds
 */

#include <linux/linkage.h>

/*
 * The semaphore operations have a special calling sequence that
 * allow us to do a simpler in-line version of them. These routines
 * need to convert that sequence back into the C sequence when
 * there is contention on the semaphore.
 */
ENTRY(__down_failed)
	pushl %eax	/* save %eax */
	pushl %edx	/* save %edx */
	pushl %ecx	/* save %ecx (and argument) */
	call SYMBOL_NAME(__down)
	popl %ecx	/* restore %ecx (count on __down not changing it) */
	popl %edx	/* restore %edx */
	popl %eax	/* restore %eax */
	ret

/* Don't save/restore %eax, because that will be our return value */
ENTRY(__down_failed_interruptible)
	pushl %edx	/* save %edx */
	pushl %ecx	/* save %ecx (and argument) */
	call SYMBOL_NAME(__down_interruptible)
	popl %ecx	/* restore %ecx (count on __down_interruptible not changing it) */
	popl %edx	/* restore %edx */
	ret

ENTRY(__up_wakeup)
	pushl %eax	/* save %eax */
	pushl %edx	/* save %edx */
	pushl %ecx	/* save %ecx (and argument) */
	call SYMBOL_NAME(__up)
	popl %ecx	/* restore %ecx (count on __up not changing it) */
	popl %edx	/* restore %edx */
	popl %eax	/* restore %eax */
	ret