xref: /trunk/main/sal/osl/unx/asm/interlck_x86.s (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 .section   .text,"ax"
30  .globl   osl_incrementInterlockedCount
31 
32 osl_incrementInterlockedCount:
33 
34     push       %ebp
35     mov        %esp,%ebp
36     push       %ebx
37     call       1f
38 1:
39     pop        %ebx
40     add        $_GLOBAL_OFFSET_TABLE_+0x1,%ebx
41     mov        8(%ebp),%ecx
42     mov        $1,%eax
43     mov        osl_isSingleCPU@GOT(%ebx),%edx
44     cmp        $0,(%edx)
45     je         2f
46     xadd       %eax,(%ecx)
47     jmp        3f
48 2:
49     lock
50     xadd       %eax,(%ecx)
51 3:
52     inc        %eax
53     pop        %ebx
54     mov        %ebp,%esp
55     pop        %ebp
56     ret
57 
58  .type  osl_incrementInterlockedCount,@function
59  .size  osl_incrementInterlockedCount,.-osl_incrementInterlockedCount
60 
61 .section   .text,"ax"
62  .globl   osl_decrementInterlockedCount
63 
64 osl_decrementInterlockedCount:
65 
66     push       %ebp
67     mov        %esp,%ebp
68     push       %ebx
69     call       1f
70 1:
71     pop        %ebx
72     add        $_GLOBAL_OFFSET_TABLE_+0x1,%ebx
73     mov        8(%ebp),%ecx
74     orl        $-1,%eax
75     mov        osl_isSingleCPU@GOT(%ebx),%edx
76     cmp        $0,(%edx)
77     je         2f
78     xadd       %eax,(%ecx)
79     jmp        3f
80 2:
81     lock
82     xadd       %eax,(%ecx)
83 3:
84     dec        %eax
85     pop        %ebx
86     mov        %ebp,%esp
87     pop        %ebp
88     ret
89 
90  .type  osl_decrementInterlockedCount,@function
91  .size  osl_decrementInterlockedCount,.-osl_decrementInterlockedCount
92 
93