Page MenuHomeWildfire Games

Remove UniqueRange custom code in favour of unique_ptr typedef (Atomic code upgrade step 1)
Needs ReviewPublic

Authored by wraitii on Jun 8 2017, 10:19 AM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Owners Package(Owns No Changed Paths)
Summary

So I noticed that on OSX 12.0 we get warnings about deprecated custom atomic code (CPU_CAS, cpu_atomic_add). Since C++11 provides <atomic>, we should replace occurrences of those with the new library where relevant.

Sadly, that code is used in lib/ which has mostly remained untouched since 2010 when jan stopped codding, and it's generally written in C-style and it's honestly full of weird uncommented design decisions (there's actually a lot of comments but I find them rather unuseful…)

I have a patch that seems to work for that, but there's one first commit I'd like separately: removing UniqueRange. It seems it's supposed to replace unique_ptr with a custom deleter, but for some reason jan used a bit-trick to get a pointer to the custom deleter instead of something straightforward (all to save one dword of memory??). Anyways the VM code also seems unused... And there was a weird atomic call in the middle.

Anyways. What I did is typedef this to unique_ptr with a custom deleter, and replaced appropriate code.

Test Plan

Check that code still works as expected, would be nice if somebody actually understood the original code and could comment too…

Event Timeline

wraitii created this revision.Jun 8 2017, 10:19 AM
Vulcan added a subscriber: Vulcan.Jun 8 2017, 11:17 AM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1503/ for more details.

Executing section Default...
Executing section Source...

source/lib/file/io/io.h
|  72| »   »   ,·offset(offset),·size(size),·buf((void*)buf)
|    | [MAJOR] CPPCheckBear (selfInitialization):
|    | Member variable 'offset' is initialized by itself.

source/lib/file/io/io.h
|  72| »   »   ,·offset(offset),·size(size),·buf((void*)buf)
|    | [MAJOR] CPPCheckBear (selfInitialization):
|    | Member variable 'size' is initialized by itself.

source/lib/file/io/io.h
|  72| »   »   ,·offset(offset),·size(size),·buf((void*)buf)
|    | [MAJOR] CPPCheckBear (selfInitialization):
|    | Member variable 'buf' is initialized by itself.
Executing section JS...
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/150/ for more details.

Maybe it needs some unit tests?

source/lib/allocators/unique_ptr_aligned.h
1

Bump year.