~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/src/md/unix/os_SunOS_x86.s

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/ -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 
2
 
3
/ The contents of this file are subject to the Mozilla Public
 
4
/ License Version 1.1 (the "License"); you may not use this file
 
5
/ except in compliance with the License. You may obtain a copy of
 
6
/ the License at http://www.mozilla.org/MPL/
 
7
 
8
/ Software distributed under the License is distributed on an "AS
 
9
/ IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
10
/ implied. See the License for the specific language governing
 
11
/ rights and limitations under the License.
 
12
 
13
/ The Original Code is the Netscape Portable Runtime (NSPR).
 
14
 
15
/ The Initial Developer of the Original Code is Netscape
 
16
/ Communications Corporation.  Portions created by Netscape are 
 
17
/ Copyright (C) 1998-2000 Netscape Communications Corporation.  All
 
18
/ Rights Reserved.
 
19
 
20
/ Contributor(s):
 
21
 
22
/ Alternatively, the contents of this file may be used under the
 
23
/ terms of the GNU General Public License Version 2 or later (the
 
24
/ "GPL"), in which case the provisions of the GPL are applicable 
 
25
/ instead of those above.  If you wish to allow use of your 
 
26
/ version of this file only under the terms of the GPL and not to
 
27
/ allow others to use your version of this file under the MPL,
 
28
/ indicate your decision by deleting the provisions above and
 
29
/ replace them with the notice and other provisions required by
 
30
/ the GPL.  If you do not delete the provisions above, a recipient
 
31
/ may use your version of this file under either the MPL or the
 
32
/ GPL.
 
33
 
34
 
 
35
        .text
 
36
 
 
37
        .globl  getedi
 
38
getedi:
 
39
        movl    %edi,%eax
 
40
        ret
 
41
        .type   getedi,@function
 
42
        .size   getedi,.-getedi
 
43
 
 
44
        .globl  setedi
 
45
setedi:
 
46
        movl    4(%esp),%edi
 
47
        ret
 
48
        .type   setedi,@function
 
49
        .size   setedi,.-setedi
 
50
 
 
51
        .globl  __MD_FlushRegisterWindows
 
52
        .globl _MD_FlushRegisterWindows
 
53
 
 
54
__MD_FlushRegisterWindows:
 
55
_MD_FlushRegisterWindows:
 
56
 
 
57
        ret
 
58
 
 
59
/
 
60
/ sol_getsp()
 
61
/
 
62
/ Return the current sp (for debugging)
 
63
/
 
64
        .globl sol_getsp
 
65
sol_getsp:
 
66
        movl    %esp, %eax
 
67
        ret
 
68
 
 
69
/
 
70
/ sol_curthread()
 
71
/
 
72
/ Return a unique identifier for the currently active thread.
 
73
/
 
74
        .globl sol_curthread
 
75
sol_curthread:
 
76
        movl    %ecx, %eax
 
77
        ret
 
78
 
 
79
/ PRInt32 _MD_AtomicIncrement(PRInt32 *val)
 
80
/
 
81
/ Atomically increment the integer pointed to by 'val' and return
 
82
/ the result of the increment.
 
83
/
 
84
    .text
 
85
    .globl _MD_AtomicIncrement
 
86
    .align 4
 
87
_MD_AtomicIncrement:
 
88
    movl 4(%esp), %ecx
 
89
    movl $1, %eax
 
90
    lock
 
91
    xaddl %eax, (%ecx)
 
92
    incl %eax
 
93
    ret
 
94
 
 
95
/ PRInt32 _MD_AtomicDecrement(PRInt32 *val)
 
96
/
 
97
/ Atomically decrement the integer pointed to by 'val' and return
 
98
/ the result of the decrement.
 
99
/
 
100
    .text
 
101
    .globl _MD_AtomicDecrement
 
102
    .align 4
 
103
_MD_AtomicDecrement:
 
104
    movl 4(%esp), %ecx
 
105
    movl $-1, %eax
 
106
    lock
 
107
    xaddl %eax, (%ecx)
 
108
    decl %eax
 
109
    ret
 
110
 
 
111
/ PRInt32 _MD_AtomicSet(PRInt32 *val, PRInt32 newval)
 
112
/
 
113
/ Atomically set the integer pointed to by 'val' to the new
 
114
/ value 'newval' and return the old value.
 
115
/
 
116
/ An alternative implementation:
 
117
/   .text
 
118
/   .globl _MD_AtomicSet
 
119
/   .align 4
 
120
/_MD_AtomicSet:
 
121
/   movl 4(%esp), %ecx
 
122
/   movl 8(%esp), %edx
 
123
/   movl (%ecx), %eax
 
124
/retry:
 
125
/   lock
 
126
/   cmpxchgl %edx, (%ecx)
 
127
/   jne retry
 
128
/   ret
 
129
/
 
130
    .text
 
131
    .globl _MD_AtomicSet
 
132
    .align 4
 
133
_MD_AtomicSet:
 
134
    movl 4(%esp), %ecx
 
135
    movl 8(%esp), %eax
 
136
    lock
 
137
    xchgl %eax, (%ecx)
 
138
    ret
 
139
 
 
140
/ PRInt32 _MD_AtomicAdd(PRInt32 *ptr, PRInt32 val)
 
141
/
 
142
/ Atomically add 'val' to the integer pointed to by 'ptr'
 
143
/ and return the result of the addition.
 
144
/
 
145
    .text
 
146
    .globl _MD_AtomicAdd
 
147
    .align 4
 
148
_MD_AtomicAdd:
 
149
    movl 4(%esp), %ecx
 
150
    movl 8(%esp), %eax
 
151
    movl %eax, %edx
 
152
    lock
 
153
    xaddl %eax, (%ecx)
 
154
    addl %edx, %eax
 
155
    ret
 
156
 
 
157
/
 
158
/ PR_StackPush(listp, elementp)
 
159
/
 
160
/ Atomically push ElementP onto linked list ListP.
 
161
/
 
162
        .text
 
163
        .globl  PR_StackPush
 
164
        .align  4
 
165
PR_StackPush:
 
166
        movl    4(%esp), %ecx
 
167
        movl    $-1,%eax
 
168
pulock:
 
169
/ Already locked?
 
170
        cmpl    %eax,(%ecx)
 
171
        je      pulock
 
172
 
 
173
/ Attempt to lock it
 
174
        lock
 
175
        xchgl   %eax, (%ecx)
 
176
 
 
177
/ Did we set the lock?
 
178
        cmpl    $-1, %eax
 
179
        je      pulock
 
180
 
 
181
/ We now have the lock.  Update pointers
 
182
        movl    8(%esp), %edx
 
183
        movl    %eax, (%edx)
 
184
        movl    %edx, (%ecx)
 
185
 
 
186
/ Done
 
187
        ret
 
188
 
 
189
 
 
190
/
 
191
/ elementp = PR_StackPop(listp)
 
192
/
 
193
/ Atomically pop ElementP off linked list ListP
 
194
/
 
195
        .text
 
196
        .globl  PR_StackPop
 
197
        .align  4
 
198
PR_StackPop:
 
199
        movl    4(%esp), %ecx
 
200
        movl    $-1, %eax
 
201
polock:
 
202
/ Already locked?
 
203
        cmpl    %eax, (%ecx)
 
204
        je      polock
 
205
 
 
206
/ Attempt to lock it
 
207
        lock
 
208
        xchgl   %eax, (%ecx)
 
209
 
 
210
/ Did we set the lock?
 
211
        cmpl    $-1, %eax
 
212
        je      polock
 
213
 
 
214
/ We set the lock so now update pointers
 
215
 
 
216
/ Was it empty?
 
217
        movl    $0, %edx
 
218
        cmpl    %eax,%edx
 
219
        je      empty
 
220
 
 
221
/ Get element "next" pointer
 
222
        movl    (%eax), %edx
 
223
 
 
224
/ Write NULL to the element "next" pointer
 
225
        movl    $0, (%eax)
 
226
 
 
227
empty:
 
228
/ Put elements previous "next" value into listp
 
229
/ NOTE: This also unlocks the listp
 
230
        movl    %edx, (%ecx)
 
231
 
 
232
/ Return previous listp value (already in eax)
 
233
        ret