thr_inlines.h revision 0ec5755428223b8105e488e8fddc19de4db26521
0ec5755428223b8105e488e8fddc19de4db26521raf * CDDL HEADER START
0ec5755428223b8105e488e8fddc19de4db26521raf * The contents of this file are subject to the terms of the
0ec5755428223b8105e488e8fddc19de4db26521raf * Common Development and Distribution License (the "License").
0ec5755428223b8105e488e8fddc19de4db26521raf * You may not use this file except in compliance with the License.
0ec5755428223b8105e488e8fddc19de4db26521raf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0ec5755428223b8105e488e8fddc19de4db26521raf * See the License for the specific language governing permissions
0ec5755428223b8105e488e8fddc19de4db26521raf * and limitations under the License.
0ec5755428223b8105e488e8fddc19de4db26521raf * When distributing Covered Code, include this CDDL HEADER in each
0ec5755428223b8105e488e8fddc19de4db26521raf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0ec5755428223b8105e488e8fddc19de4db26521raf * If applicable, add the following below this CDDL HEADER, with the
0ec5755428223b8105e488e8fddc19de4db26521raf * fields enclosed by brackets "[]" replaced with your own identifying
0ec5755428223b8105e488e8fddc19de4db26521raf * information: Portions Copyright [yyyy] [name of copyright owner]
0ec5755428223b8105e488e8fddc19de4db26521raf * CDDL HEADER END
0ec5755428223b8105e488e8fddc19de4db26521raf * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
0ec5755428223b8105e488e8fddc19de4db26521raf * Use is subject to license terms.
0ec5755428223b8105e488e8fddc19de4db26521raf#pragma ident "%Z%%M% %I% %E% SMI"
0ec5755428223b8105e488e8fddc19de4db26521raf/* inlines for gcc */
0ec5755428223b8105e488e8fddc19de4db26521raf#if defined(__amd64)
0ec5755428223b8105e488e8fddc19de4db26521raf __asm__ __volatile__("movq %%fs:0, %0" : "=r" (__value));
0ec5755428223b8105e488e8fddc19de4db26521raf __asm__ __volatile__("movl %%gs:0, %0" : "=r" (__value));
0ec5755428223b8105e488e8fddc19de4db26521raf#if defined(__amd64)
0ec5755428223b8105e488e8fddc19de4db26521raf "xorq %0, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "mov %%fs, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "andq %0, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "je 1f\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "movq %%fs:0, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "xorl %0, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "mov %%gs, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "andl %0, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "je 1f\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "movl %%gs:0, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf ".register %%g7, #scratch\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "tst %%g7\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "be,a,pn %%xcc, 1f\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf " mov %%g0, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "ldx [%%g7 + 80], %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf ".register %%g7, #scratch\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "tst %%g7\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "be,a 1f\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf " mov %%g0, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "ld [%%g7 + 80], %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf : : "cc");
0ec5755428223b8105e488e8fddc19de4db26521raf#if defined(__amd64)
0ec5755428223b8105e488e8fddc19de4db26521rafgethrtime(void) /* note: caller-saved registers are trashed */
0ec5755428223b8105e488e8fddc19de4db26521raf#if defined(__amd64)
0ec5755428223b8105e488e8fddc19de4db26521raf "movl $3, %%eax\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "int $0xd2"
0ec5755428223b8105e488e8fddc19de4db26521raf : : "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", "r11", "cc");
0ec5755428223b8105e488e8fddc19de4db26521raf "movl $3, %%eax\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "int $0xd2"
0ec5755428223b8105e488e8fddc19de4db26521raf "ta 0x24\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "sllx %%o0, 32, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "or %%o1, %0, %0"
0ec5755428223b8105e488e8fddc19de4db26521raf#if defined(__x86)
0ec5755428223b8105e488e8fddc19de4db26521raf "movl $1, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "xchgb %%dl, %1"
0ec5755428223b8105e488e8fddc19de4db26521raf "ldstub %1, %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "membar #LoadLoad"
0ec5755428223b8105e488e8fddc19de4db26521raf#if defined(__x86)
0ec5755428223b8105e488e8fddc19de4db26521raf "xchgl %0, %1"
0ec5755428223b8105e488e8fddc19de4db26521raf "ld [%3], %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "mov %4, %1\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "cas [%3], %0, %1\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "cmp %0, %1\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "bne,a,pn %%icc, 1b\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf " mov %1, %0"
0ec5755428223b8105e488e8fddc19de4db26521rafcas32(volatile uint32_t *__memory, uint32_t __cmp, uint32_t __newvalue)
0ec5755428223b8105e488e8fddc19de4db26521raf#if defined(__x86)
0ec5755428223b8105e488e8fddc19de4db26521raf "lock; cmpxchgl %3, %0"
0ec5755428223b8105e488e8fddc19de4db26521raf "cas [%2], %3, %1"
0ec5755428223b8105e488e8fddc19de4db26521raf#if defined(__x86)
0ec5755428223b8105e488e8fddc19de4db26521raf "lock; incl %0"
0ec5755428223b8105e488e8fddc19de4db26521raf "ld [%3], %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "add %0, 1, %1\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "cas [%3], %0, %1\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "cmp %0, %1\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "bne,a,pn %%icc, 1b\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf " mov %1, %0"
0ec5755428223b8105e488e8fddc19de4db26521raf#if defined(__x86)
0ec5755428223b8105e488e8fddc19de4db26521raf "lock; decl %0"
0ec5755428223b8105e488e8fddc19de4db26521raf "ld [%3], %0\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "sub %0, 1, %1\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "cas [%3], %0, %1\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "cmp %0, %1\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf "bne,a,pn %%icc, 1b\n\t"
0ec5755428223b8105e488e8fddc19de4db26521raf " mov %1, %0"
0ec5755428223b8105e488e8fddc19de4db26521raf#endif /* __sparc */
0ec5755428223b8105e488e8fddc19de4db26521raf#endif /* __x86 */
0ec5755428223b8105e488e8fddc19de4db26521raf#endif /* !__lint && __GNUC__ */
0ec5755428223b8105e488e8fddc19de4db26521raf#endif /* _THR_INLINES_H */