10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #ifndef _SYS_ATOMIC_H
28 #define _SYS_ATOMIC_H
29
30 #pragma ident "%Z%%M% %I% %E% SMI"
31
32 #include <sys/types.h>
33 #include <sys/inttypes.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #if defined(_KERNEL) && defined(__GNUC__) && defined(_ASM_INLINES) && \
40 (defined(__i386) || defined(__amd64))
41 #include <asm/atomic.h>
42 #endif
43
44 #if defined(_KERNEL) || defined(__STDC__)
45 /*
46 * Increment target.
47 */
48 extern void atomic_inc_8(volatile uint8_t *);
49 extern void atomic_inc_uchar(volatile uchar_t *);
50 extern void atomic_inc_16(volatile uint16_t *);
51 extern void atomic_inc_ushort(volatile ushort_t *);
398
399 extern void membar_enter();
400 extern void membar_exit();
401 extern void membar_producer();
402 extern void membar_consumer();
403
404 #endif
405
406 #if defined(_KERNEL)
407
408 #if defined(_LP64) || defined(_ILP32)
409 #define atomic_add_ip atomic_add_long
410 #define atomic_add_ip_nv atomic_add_long_nv
411 #define casip atomic_cas_ulong
412 #endif
413
414 #if defined(__sparc)
415 extern uint8_t ldstub(uint8_t *);
416 #endif
417
418 /*
419 * Legacy kernel interfaces; they will go away (eventually).
420 */
421 extern uint8_t cas8(uint8_t *, uint8_t, uint8_t);
422 extern uint32_t cas32(uint32_t *, uint32_t, uint32_t);
423 extern uint64_t cas64(uint64_t *, uint64_t, uint64_t);
424 extern ulong_t caslong(ulong_t *, ulong_t, ulong_t);
425 extern void *casptr(void *, void *, void *);
426 extern void atomic_and_long(ulong_t *, ulong_t);
427 extern void atomic_or_long(ulong_t *, ulong_t);
428 #if defined(__sparc)
429 extern uint32_t swapl(uint32_t *, uint32_t);
430 #endif
431
432 #endif /* _KERNEL */
433
434 #ifdef __cplusplus
435 }
436 #endif
437
438 #endif /* _SYS_ATOMIC_H */
|
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #ifndef _SYS_ATOMIC_H
28 #define _SYS_ATOMIC_H
29
30 #include <sys/types.h>
31 #include <sys/inttypes.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #if defined(_KERNEL) && defined(__GNUC__) && defined(_ASM_INLINES) && \
38 (defined(__i386) || defined(__amd64))
39 #include <asm/atomic.h>
40 #endif
41
42 #if defined(_KERNEL) || defined(__STDC__)
43 /*
44 * Increment target.
45 */
46 extern void atomic_inc_8(volatile uint8_t *);
47 extern void atomic_inc_uchar(volatile uchar_t *);
48 extern void atomic_inc_16(volatile uint16_t *);
49 extern void atomic_inc_ushort(volatile ushort_t *);
396
397 extern void membar_enter();
398 extern void membar_exit();
399 extern void membar_producer();
400 extern void membar_consumer();
401
402 #endif
403
404 #if defined(_KERNEL)
405
406 #if defined(_LP64) || defined(_ILP32)
407 #define atomic_add_ip atomic_add_long
408 #define atomic_add_ip_nv atomic_add_long_nv
409 #define casip atomic_cas_ulong
410 #endif
411
412 #if defined(__sparc)
413 extern uint8_t ldstub(uint8_t *);
414 #endif
415
416 #endif /* _KERNEL */
417
418 #ifdef __cplusplus
419 }
420 #endif
421
422 #endif /* _SYS_ATOMIC_H */
|