Skip to content

Fix a bug in cptr_to_u64 in emulation#2172

Closed
certik wants to merge 2 commits into
lcompilers:mainfrom
certik:cptr_to_u64_emu
Closed

Fix a bug in cptr_to_u64 in emulation#2172
certik wants to merge 2 commits into
lcompilers:mainfrom
certik:cptr_to_u64_emu

Conversation

@certik

@certik certik commented Jul 17, 2023

Copy link
Copy Markdown
Contributor

No description provided.

@certik

certik commented Jul 17, 2023

Copy link
Copy Markdown
Contributor Author

Let's write a test for this as well, and investigate if the other function also needs this (update: it does, see commit below).

@ronnuriel

Copy link
Copy Markdown
Collaborator

Let's write a test for this as well, and investigate if the other function also needs this (update: it does, see commit below).

Hey I tested it and its not working,
return ctypes.addressof(cptr)
TypeError: invalid type

@ronnuriel

ronnuriel commented Jul 18, 2023

Copy link
Copy Markdown
Collaborator

Proposal:
@certik

def cptr_to_u64(cptr):
    return u64(ctypes.cast(cptr, ctypes.c_void_p).value)

def u64_to_cptr(ivalue):
    return ctypes.c_void_p(i64(ivalue))

Tested and works

@certik

certik commented Jul 19, 2023

Copy link
Copy Markdown
Contributor Author

@ronnuriel, awesome thanks. I submitted it here with you as an author: #2186. It would be nice to figure out an isolated test for this but it's more important to fix it, so if it passes, we'll merge it. Closing in favor of #2186.

@certik certik closed this Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants