⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atomicity.h

📁 基于LWVCL开发的库
💻 H
字号:
/* Low-level functions for atomic operations.  ARM version.   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.   This file is part of the GNU C Library.   The GNU C Library is free software; you can redistribute it and/or   modify it under the terms of the GNU Lesser General Public   License as published by the Free Software Foundation; either   version 2.1 of the License, or (at your option) any later version.   The GNU C Library is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   Lesser General Public License for more details.   You should have received a copy of the GNU Lesser General Public   License along with the GNU C Library; if not, write to the Free   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA   02110-1301 USA.  */#ifndef _ATOMICITY_H#define _ATOMICITY_H    1/* Kaffe: Modified by Guilhem Lavaux to return the oldval */static inline long int__attribute__ ((unused))compare_and_swap (volatile long int *p, long int oldval, long int newval){  long int result, tmp;  __asm__ ("\n" 	   "0:\tldr\t%1,[%2]\n\t"   	   "mov\t%0,#0\n\t"   	   "cmp\t%1,%4\n\t"   	   "bne\t1f\n\t"   	   "swp\t%0,%3,[%2]\n\t"   	   "cmp\t%1,%0\n\t"   	   "swpne\t%1,%0,[%2]\n\t"  	   "bne\t0b\n\t"	   "mov\t%0,%4\n\t"	   "b\t2f\n\t"   	   "1:" 	   "mov\t%0,%1\n"	   "2:"	: "=&r" (result), "=&r" (tmp)	: "r" (p), "r" (newval), "r" (oldval)	: "cc", "memory");  return result;}#define atomic_compare_and_exchange_val_acq(mem, newval, oldval)  \    ({ __typeof (*mem) result;                                    \           if (sizeof(*mem) == 4)                                 \	     result = compare_and_swap((long int*)(mem), (long int)(oldval), (long int)(newval));      \	   else                                                   \	     {                                                    \	       result = (__typeof(*mem))0;                        \	       abort();                                           \	     }                                                    \	   result;                                                \    })#endif /* atomicity.h */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -