Commit Graph

12 Commits

Author SHA1 Message Date
Wez Furlong
4a59f3b701 c-extensions: fixup some compiler/environment portability concerns
Summary:
I sync'd a copy of this code into the eden repository.
I had to adjust a couple of include paths to get the code to
compile correctly in the hermetic build environment that is
in use there.

In addition, our linter suite over there found a couple of C++ nits
to be fixed up.

Test Plan: make local

Reviewers: simpkins, ikostia, simonfar, durham

Reviewed By: durham

Subscribers: net-systems-diffs@fb.com, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4879285

Signature: t1:4879285:1492039044:8cb1e033e35ee568806de94dda3d2f6f8e78f5cb
2017-04-12 16:34:53 -07:00
Kostia Balytskyi
918e1011b3 portability: use COMPOUND_LITERAL macro in place of actual compound literals
Summary:
This is a s//g replacement of all the `return (type_name) {` with
`return COMPOUND_LITERAL(type_name) {`.
This is the command which produced the diff:
`egrep 'return \(\w*\) \{' -Ir . --exclude='*.py*' --exclude-dir=.hg -l | xargs sed 's/return (\(\w*\)) {/return COMPOUND_LITERAL(\1) {/g' -i `

After I've done this, I checked:
`egrep '\(\w+\) \{' -Ir . --exclude='*.py*' --exclude-dir=.hg | egrep -v '(switch|while)' | grep -v 'if (' | grep -v 'COMPOUND_LITERAL' | less`
and it looks like the only things of `(something) {` syntax are function definitions, adding space before `(` in search pattern yields no results.

This is needed to make this compile on Windows under MSVC2015.

Depends on: D4843230

Test Plan:
- run `python setup.py build -f`, see it compile
- run all the tests, see them pass

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4843240

Signature: t1:4843240:1491495690:a097bfab403805052d5ac25d1db7bb32af3bca28
2017-04-06 09:34:40 -07:00
Kostia Balytskyi
67b7f56ddb portability: add a portability header
Summary:
Proposed header (or its dir) is a single place to put MSVC/GCC hacks. So
far it only includes the COMPOUND_LITERAL macro which behaves differently
depending on MSVC mode.
When MSVC2015 is used in C++ mode, it does not support things like:
`(my_type) {initializers}`, but in C mode it does.

To clarify: I am not even sure whether we need to have the ability to compile in a purely C mode, but I did not want to figure out.

Test Plan: - on Linux, run `python setup.py build`, run all the tests, see them passing

Reviewers: #sourcecontrol, tja

Reviewed By: tja

Subscribers: tja, jsgf, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4843230

Signature: t1:4843230:1491496062:3fa10ae5a5aac850689991de1ca6ee1ac86d9dce
2017-04-06 09:33:34 -07:00
Kostia Balytskyi
18c695ce6a portability: replace variably-sized C arrays with explicit mallocs
Summary:
This is an RFC kind of diff, so I am looking for comments. I am not very
familiar with either C or C++.
The goal is to make all this stuff compile on Windows under MSVC2015. MSVC
does not support variable-sized arrays in C++ out-of-the-box (not sure
whether there are tricks to make it do so), so my proposal is to use
explicit `malloc`s in place.

Test Plan:
Only tested on Linux for now. `python setup.py build` works,
tests pass, seems to make sense.

Reviewers: #sourcecontrol, jsgf

Reviewed By: jsgf

Subscribers: jsgf, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4839968

Signature: t1:4839968:1491492552:c80fac6990aaee78e6bb18522ff13e02eb9521e4
2017-04-06 09:30:26 -07:00
Durham Goode
4fd00d751a cstore: C++ implementation of datapackstore
Summary:
The remaining python parts of the store are a perf bottleneck when accessing
hundreds of thousands of pack file entries (like in treemanifest). Let's
implement them in C++.

This first patch just add the basic boiler plate, and implements a single
function getdeltachain(), with a test. Future patches will add more
functionality and other parts of the store.

Since cstore depends on cdatapack and ctreemanifest (the pythonutils.h part for
now), we need to tweak our setup.py to enforce a certain build order too.

Test Plan: Added a test, yo

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, stash, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4547929

Signature: t1:4547929:1487181318:21c146cf370d26cb97efe6a883868b85b4e32f49
2017-02-23 14:03:03 -08:00
Durham Goode
e1b1c470e6 cstore: move py-cdatapack to be part of py-cstore
Summary:
As part of unifying our storage layer into a single library, let's move
py-cdatapack into the new cstore directory. Future patches will move
ctreemanifest and the upcoming datapackstore into here as well.

py-cdatapack.h required some reordering since it seems forward declarations work
a little differently between C and C++. There were no code changes though,
except one int->size_t fix.

Test Plan: Ran the tests

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4581320

Signature: t1:4581320:1487788968:e8a34c7a03a16db282214c7dd476b749b92a1bfa
2017-02-23 14:03:02 -08:00
Durham Goode
a808c980f0 Backed out changeset c84de4b54530
The cstore changes are breaking the build in some unusual ways and I will need
some time to fix them. Let's back it out for now.
2017-02-16 14:37:23 -08:00
Durham Goode
41486c3f47 cstore: C++ implementation of datapackstore
Summary:
The remaining python parts of the store are a perf bottleneck when accessing
hundreds of thousands of pack file entries (like in treemanifest). Let's
implement them in C++.

This first patch just add the basic boiler plate, and implements a single
function getdeltachain(), with a test. Future patches will add more
functionality and other parts of the store.

Since cstore depends on cdatapack and ctreemanifest (the pythonutils.h part for
now), we need to tweak our setup.py to enforce a certain build order too.

Test Plan: Added a test, yo

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, stash, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4547929

Signature: t1:4547929:1487181318:21c146cf370d26cb97efe6a883868b85b4e32f49
2017-02-15 15:19:36 -08:00
Augie Fackler
22653c7629 cdatapack: include sys/types.h for off_t
This isn't required on all systems, but I ran into one where it
was. Sigh. I've struggled a bit to find proper documentation of this,
and this is the best I could do:
http://pubs.opengroup.org/onlinepubs/009696799/basedefs/sys/types.h.html
2016-11-28 17:24:45 -05:00
Tony Tung
525b3024a2 cdatapack: clear the counter after we madvise away
Test Plan: visual inspection.

Reviewers: durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4185510

Tasks: 14574117

Signature: t1:4185510:1479252916:6477e9c1708e6bf74fa3c2668ce222597ab4c8ae
2016-11-15 18:19:08 -06:00
Rodrigo Damazio Bovendorp
06f51febad Fixing integer size conversions.
On 32-bit OSX, size_t and off_t have different sizes.
2016-10-13 09:15:15 -07:00
Durham Goode
50d6b599f4 Move ctreemanifest and cdatapack out of remotefilelog
These don't really have any dependencies on remotefilelog, so let's move them
out.
2016-09-21 13:55:12 -07:00