chrsmithdemos / leveldb

Automatically exported from code.google.com/p/leveldb
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Use native memory barriers on OSX #218

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. compile for osx

What is the expected output? What do you see instead?
Native memory barriers are expected, gcc-style are used instead.

What version of the product are you using? On what operating system?
1.13. OSX (all versions)

Please provide any additional information below.

I'm unsure if there is any significance, but I noticed it while debugging 
another issue.

During atomics selection, OSX falls into the (ARCH_CPU_X86_FAMILY) && 
defined(__GNUC__) condition before it can reach the elif defined(OS_MACOSX) 
condition.

This means that Darwin's OSMemoryBarrier() is never used for x86.

In the upstream version, APPLE is searched first, presumably for the above 
reason: 
https://code.google.com/p/gperftools/source/browse/src/base/atomicops.h#102

This is easily tested by adding some garbage in the "(ARCH_CPU_X86_FAMILY) && 
defined(__GNUC__)" condition and noting the compile failure.

Reversing the order here ensures that OSMemoryBarrier() is used instead.

See attached patch. 

Original issue reported on code.google.com by c...@atlastechnologiesinc.com on 28 Nov 2013 at 4:26

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in 1.15

Original comment by dgrogan@chromium.org on 10 Dec 2013 at 7:49