由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 建议大家看看interlocked
相关主题
what is the meaning of this macro in visual studio, thanks万能的买买提,请教一个jenkins的问题
文一个简单的c++size of structure
VC++ does not support strlen()Segmentation fault
c warningvisual studio 2005怎么不让自动添加#pragma once?
#ifdef _MSC_VER 是什么意思啊?C怪问题一个
Atomic operation 与 多重指针stl的map可以嵌套几层?
说的再清楚一点: 抢票机性能只和中途停靠总站数相关急!问个有关aligment的问题。
我来写个老魏的详细实现方案。(更新了缺点)visual studio 编译器怎么关掉warning?
相关话题的讨论汇总
话题: ptr话题: long话题: volatile话题: inline话题: typename
进入Programming版参与讨论
1 (共1页)
T********i
发帖数: 2416
1
#if defined(_MSC_VER)
# pragma once
#include
inline long long InterlockedIncrement(long long volatile *ptr) {
return InterlockedIncrement64(ptr);
}
inline long long InterlockedDecrement(long long volatile *ptr) {
return InterlockedDecrement64(ptr);
}
#else
#include
template
inline T InterlockedIncrement(T volatile *ptr) {
return __sync_add_and_fetch(ptr, 1);
}
template
inline T InterlockedDecrement(T volatile *ptr) {
return __sync_add_and_fetch(ptr, (T)(long long)-1);
}
template
inline T InterlockedAdd(T volatile *ptr, T value) {
return __sync_add_and_fetch(ptr, value);
}
template
inline T InterlockedCompareExchange(T volatile* Destination, T Exchange, T
Comparand) {
return __sync_val_compare_and_swap(Destination, Comparand, Exchange);
}
#endif
T********i
发帖数: 2416
2
这段代码,Windows和Linux通吃。
goodbug,看懂了一定要写读后感欧。
1 (共1页)
进入Programming版参与讨论
相关主题
visual studio 编译器怎么关掉warning?#ifdef _MSC_VER 是什么意思啊?
A helloworld OpenMP question?Atomic operation 与 多重指针
无法编译一个文件说的再清楚一点: 抢票机性能只和中途停靠总站数相关
[合集] Intel 9编译器在vc 6.0的环境里编译openmp的问题我来写个老魏的详细实现方案。(更新了缺点)
what is the meaning of this macro in visual studio, thanks万能的买买提,请教一个jenkins的问题
文一个简单的c++size of structure
VC++ does not support strlen()Segmentation fault
c warningvisual studio 2005怎么不让自动添加#pragma once?
相关话题的讨论汇总
话题: ptr话题: long话题: volatile话题: inline话题: typename