Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / sal / osl / unx / asm / interlck_sparc.s
blob7b971a50a4b2718aa22a562b2a6b1eeafe400fce
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 * Implements osl_[increment|decrement]InterlockedCount:
22 * sparcv9/sparcv8plus architecture: use the "cas" instruction
24 * 32 bit mode with v8plus support or 64 bit mode:
25 * sparcv9 mode is implied. Assemble with -xarch=v8plus (32 bit) or
26 * -xarch=v9 (64 bit).
30 #if !defined(__sparcv8plus) && !defined(__sparcv9) && !defined(__sparc_v9__)
32 #error LibreOffice requires SPARCv8plus or SPARCv9 CPU with "cas" instruction
34 #endif
36 .section ".text"
37 .global osl_incrementInterlockedCount
38 .align 8
40 ! Implements osl_[increment|decrement]InterlockedCount with sparcv9(sparcv8plus) "cas"
41 ! instruction.
43 osl_incrementInterlockedCount:
45 1: ld [%o0], %o1
46 add %o1, 1, %o2
47 ! allow linux to build for v8
48 .word 0xD5E21009
49 ! cas [%o0], %o1, %o2
50 cmp %o1, %o2
51 bne 1b
52 nop ! delay slot
53 retl
54 add %o2, 1, %o0 ! delay slot
56 .type osl_incrementInterlockedCount,#function
57 .size osl_incrementInterlockedCount,.-osl_incrementInterlockedCount
60 .section ".text"
61 .global osl_decrementInterlockedCount
62 .align 8
64 osl_decrementInterlockedCount:
66 1: ld [%o0], %o1
67 sub %o1, 1, %o2
68 ! allow linux to build for v8
69 .word 0xD5E21009
70 ! cas [%o0], %o1, %o2
71 cmp %o1, %o2
72 bne 1b
73 nop ! delay slot
74 retl
75 sub %o2, 1, %o0 ! delay slot
77 .type osl_decrementInterlockedCount,#function
78 .size osl_decrementInterlockedCount,.-osl_decrementInterlockedCount