xref: /minix3/common/lib/libc/arch/m68k/atomic/atomic_and.S (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc/*	$NetBSD: atomic_and.S,v 1.11 2014/06/23 21:53:45 joerg Exp $	*/
2b6cbf720SGianluca Guida
3b6cbf720SGianluca Guida/*-
4b6cbf720SGianluca Guida * Copyright (c) 2007 The NetBSD Foundation, Inc.
5b6cbf720SGianluca Guida * All rights reserved.
6b6cbf720SGianluca Guida *
7b6cbf720SGianluca Guida * This code is derived from software contributed to The NetBSD Foundation
8b6cbf720SGianluca Guida * by Jason R. Thorpe.
9b6cbf720SGianluca Guida *
10b6cbf720SGianluca Guida * Redistribution and use in source and binary forms, with or without
11b6cbf720SGianluca Guida * modification, are permitted provided that the following conditions
12b6cbf720SGianluca Guida * are met:
13b6cbf720SGianluca Guida * 1. Redistributions of source code must retain the above copyright
14b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer.
15b6cbf720SGianluca Guida * 2. Redistributions in binary form must reproduce the above copyright
16b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer in the
17b6cbf720SGianluca Guida *    documentation and/or other materials provided with the distribution.
18b6cbf720SGianluca Guida *
19b6cbf720SGianluca Guida * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20b6cbf720SGianluca Guida * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21b6cbf720SGianluca Guida * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22b6cbf720SGianluca Guida * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23b6cbf720SGianluca Guida * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24b6cbf720SGianluca Guida * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25b6cbf720SGianluca Guida * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26b6cbf720SGianluca Guida * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27b6cbf720SGianluca Guida * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28b6cbf720SGianluca Guida * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29b6cbf720SGianluca Guida * POSSIBILITY OF SUCH DAMAGE.
30b6cbf720SGianluca Guida */
31b6cbf720SGianluca Guida
32b6cbf720SGianluca Guida#include "atomic_op_asm.h"
33b6cbf720SGianluca Guida
34b6cbf720SGianluca Guida	.text
35b6cbf720SGianluca Guida
36b6cbf720SGianluca GuidaENTRY(_atomic_and_32)
3784d9c625SLionel Sambuc	movl	4(%sp), %a0
3884d9c625SLionel Sambuc	movl	8(%sp), %d0
3984d9c625SLionel Sambuc	andl	%d0, (%a0)
40b6cbf720SGianluca Guida	rts
4184d9c625SLionel SambucEND(_atomic_and_32)
42b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
43b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32)
44b6cbf720SGianluca GuidaSTRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
45b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32)
46b6cbf720SGianluca GuidaSTRONG_ALIAS(_atomic_and_ulong,_atomic_and_32)
47b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(atomic_and_ptr,_atomic_and_32)
48b6cbf720SGianluca GuidaSTRONG_ALIAS(_atomic_and_ptr,_atomic_and_32)
49b6cbf720SGianluca Guida
50b6cbf720SGianluca GuidaENTRY(_atomic_and_32_nv)
5184d9c625SLionel Sambuc	movl	4(%sp), %a0
5284d9c625SLionel Sambuc1:	movl	(%a0), %d0
53b6cbf720SGianluca Guida	movl	%d0, %d1
5484d9c625SLionel Sambuc	andl	8(%sp), %d0
5584d9c625SLionel Sambuc	casl	%d1, %d0, (%a0)
56b6cbf720SGianluca Guida	bne	1b
57*0a6a1f1dSLionel Sambuc	movl	%d0, %a0
58b6cbf720SGianluca Guida	rts
5984d9c625SLionel SambucEND(_atomic_and_32_nv)
60b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
61b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
62b6cbf720SGianluca GuidaSTRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
63b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv)
64b6cbf720SGianluca GuidaSTRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv)
65b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(atomic_and_ptr_nv,_atomic_and_32_nv)
66b6cbf720SGianluca GuidaSTRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_32_nv)
67*0a6a1f1dSLionel SambucCRT_ALIAS(__sync_and_and_fetch_4,_atomic_and_32_nv)
68*0a6a1f1dSLionel Sambuc
69*0a6a1f1dSLionel SambucENTRY(__sync_fetch_and_and_4)
70*0a6a1f1dSLionel Sambuc	movl	4(%sp), %a0
71*0a6a1f1dSLionel Sambuc1:	movl	(%a0), %d0
72*0a6a1f1dSLionel Sambuc	movl	%d0, %d1
73*0a6a1f1dSLionel Sambuc	andl	8(%sp), %d1
74*0a6a1f1dSLionel Sambuc	casl	%d0, %d1, (%a0)
75*0a6a1f1dSLionel Sambuc	bne	1b
76*0a6a1f1dSLionel Sambuc	movl	%d0, %a0
77*0a6a1f1dSLionel Sambuc	rts
78*0a6a1f1dSLionel SambucEND(__sync_fetch_and_and_4)
79*0a6a1f1dSLionel Sambuc
80*0a6a1f1dSLionel Sambuc
81*0a6a1f1dSLionel SambucENTRY(_atomic_and_16_nv)
82*0a6a1f1dSLionel Sambuc	movl	4(%sp), %a0
83*0a6a1f1dSLionel Sambuc1:	movw	(%a0), %d0
84*0a6a1f1dSLionel Sambuc	movw	%d0, %d1
85*0a6a1f1dSLionel Sambuc	andw	8(%sp), %d0
86*0a6a1f1dSLionel Sambuc	casw	%d1, %d0, (%a0)
87*0a6a1f1dSLionel Sambuc	bne	1b
88*0a6a1f1dSLionel Sambuc	rts
89*0a6a1f1dSLionel SambucEND(_atomic_and_16_nv)
90*0a6a1f1dSLionel Sambuc
91*0a6a1f1dSLionel SambucCRT_ALIAS(__sync_and_and_fetch_2,_atomic_and_16_nv)
92*0a6a1f1dSLionel Sambuc
93*0a6a1f1dSLionel SambucENTRY(__sync_fetch_and_and_2)
94*0a6a1f1dSLionel Sambuc	movl	4(%sp), %a0
95*0a6a1f1dSLionel Sambuc1:	movw	(%a0), %d0
96*0a6a1f1dSLionel Sambuc	movw	%d0, %d1
97*0a6a1f1dSLionel Sambuc	andw	8(%sp), %d1
98*0a6a1f1dSLionel Sambuc	casw	%d0, %d1, (%a0)
99*0a6a1f1dSLionel Sambuc	bne	1b
100*0a6a1f1dSLionel Sambuc	rts
101*0a6a1f1dSLionel SambucEND(__sync_fetch_and_and_2)
102*0a6a1f1dSLionel Sambuc
103*0a6a1f1dSLionel Sambuc
104*0a6a1f1dSLionel SambucENTRY(_atomic_and_8_nv)
105*0a6a1f1dSLionel Sambuc	movl	4(%sp), %a0
106*0a6a1f1dSLionel Sambuc1:	movb	(%a0), %d0
107*0a6a1f1dSLionel Sambuc	movb	%d0, %d1
108*0a6a1f1dSLionel Sambuc	andb	8(%sp), %d0
109*0a6a1f1dSLionel Sambuc	casb	%d1, %d0, (%a0)
110*0a6a1f1dSLionel Sambuc	bne	1b
111*0a6a1f1dSLionel Sambuc	rts
112*0a6a1f1dSLionel SambucEND(_atomic_and_8_nv)
113*0a6a1f1dSLionel Sambuc
114*0a6a1f1dSLionel SambucCRT_ALIAS(__sync_and_and_fetch_1,_atomic_and_8_nv)
115*0a6a1f1dSLionel Sambuc
116*0a6a1f1dSLionel SambucENTRY(__sync_fetch_and_and_1)
117*0a6a1f1dSLionel Sambuc	movl	4(%sp), %a0
118*0a6a1f1dSLionel Sambuc1:	movb	(%a0), %d0
119*0a6a1f1dSLionel Sambuc	movb	%d0, %d1
120*0a6a1f1dSLionel Sambuc	andb	8(%sp), %d1
121*0a6a1f1dSLionel Sambuc	casb	%d0, %d1, (%a0)
122*0a6a1f1dSLionel Sambuc	bne	1b
123*0a6a1f1dSLionel Sambuc	rts
124*0a6a1f1dSLionel SambucEND(__sync_fetch_and_and_1)
125*0a6a1f1dSLionel Sambuc
126*0a6a1f1dSLionel SambucCRT_ALIAS(__atomic_fetch_and_1,__sync_fetch_and_and_1)
127*0a6a1f1dSLionel SambucCRT_ALIAS(__atomic_fetch_and_2,__sync_fetch_and_and_2)
128*0a6a1f1dSLionel SambucCRT_ALIAS(__atomic_fetch_and_4,__sync_fetch_and_and_4)
129