troubleshooting Question

Portable Atomic operation

Avatar of shiningram
shiningram asked on
AssemblyUnix OSWindows OS
4 Comments1 Solution549 ViewsLast Modified:
These things are very important. Can some point me neccesary changes to make it portable?
1. What type it works on ? Let me explicitly state that.
   a. Does it work on int32
   b  Does it work on uint32
   c. Does it work on int64
   d  Does it work on uint64
   e. Does it work on unsigned long?
   f. Does it work on signed long?
2. What architecture 32 or 64 bit.?
   a. Will same code work on both if not then what changes are required?
3. What is the return value (old or updated one)? It must return a value. So that old and new value can be compare later.
4. What OS it will support? If not then what changes or API to use if available.
   a. Will it work on windows 32 and 64 bit?
   b. Will it work linux 32 or 64 bit
   c. Will it work Sun Solaris
   d. will it work on HP AIX
int32 func()
{
   int32 val = 1;
 
    asm volatile ("lock; xaddl %0,%1"
              : "=r" (val), "=m" (*mem)
              : "0" (val), "m" (*mem)
              : "memory", "cc");
 return val;
}
ASKER CERTIFIED SOLUTION
sdcz

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros