Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add natives to work with 64 bit Protobuf values #943

Merged
merged 6 commits into from Mar 4, 2019
Merged

Add natives to work with 64 bit Protobuf values #943

merged 6 commits into from Mar 4, 2019

Conversation

@komashchenko
Copy link
Contributor

@komashchenko komashchenko commented Dec 29, 2018

No description provided.

Copy link
Member

@asherkin asherkin left a comment

This looks pretty good - one inline about alignment requirements that would be good to address (but isn't strictly required.)

GET_FIELD_NAME_OR_ERR();

int64 *ret;
pCtx->LocalToPhysAddr(params[3], reinterpret_cast<cell_t **>(&ret));
Copy link
Member

@asherkin asherkin Dec 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't strictly legal as cell_t and int64 have differing alignment requirements (4 and 8 bytes respectively) and this could end up unaligned. (Which is just a perf penalty on x86, but can be fatal on other architectures.)

It would be better to use a temporary int64 variable and combine manually.

This comment applies generally throughout the PR.

@komashchenko
Copy link
Contributor Author

@komashchenko komashchenko commented Jan 4, 2019

@asherkin As I understand, do not need to add legacy API ?
#946 (comment)

@@ -747,6 +827,7 @@ static cell_t smn_PbAddMessage(IPluginContext *pCtx, const cell_t *params)
REGISTER_NATIVES(protobufnatives)
{
{"PbReadInt", smn_PbReadInt},
{"PbReadInt64", smn_PbReadInt64},
Copy link
Member

@peace-maker peace-maker Jan 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed those from the non-methodmap api.

@HILER01
Copy link

@HILER01 HILER01 commented Mar 3, 2019

Add this function is very necessary

Copy link
Member

@KyleSanderson KyleSanderson left a comment

I don't run this game anymore unfortunately but this looks good if the code works. I don't like the macro hell but that's existing so: not your problem. If you can use c++ casting instead of c that would be appreciated but beyond that this looks good bud and I'll merge in a day regardless.

Thanks for being patient.

cell_t *value;
pCtx->LocalToPhysAddr(params[3], &value);
int64 temp;
((cell_t *)&temp)[0] = value[0];
Copy link
Member

@KyleSanderson KyleSanderson Mar 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: static_cast please.

@KyleSanderson KyleSanderson merged commit 8031e42 into alliedmodders:master Mar 4, 2019
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants