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

page pointers portable to 32bit platforms #700

Merged
merged 1 commit into from
Mar 1, 2016

Conversation

comotion
Copy link

Use the appropriate pointer type uintptr_t.

A 32bit build will fail with the following error due to -Werror:

core/memory.c: In function 'virtual_to_physical':
core/memory.c:36:16: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
   virt_page = ((uint64_t)ptr) / 4096;
                ^
...
core/memory.c:51:5: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t' [-Werror=format=]
core/memory.c: In function 'allocate_huge_page':
core/memory.c:93:26: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   realptr = shmat(shmid, (void*)virtual_address, 0);
                          ^

This patch is split out from #483, and fixes the problem by using an int type that changes size with the page size.

@eugeneia
Copy link
Member

I am merging this into max-next as its a change regarding general correctness of C code.

Cc @lukego

@eugeneia eugeneia self-assigned this Feb 17, 2016
@eugeneia eugeneia merged commit 080fba5 into snabbco:master Mar 1, 2016
dpino pushed a commit to dpino/snabb that referenced this pull request Feb 14, 2017
This allows you to miss out optional arguments where there is a
container without any required leaves in it. Previous you would often
get a casting error when they were left empty of omitted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants