Skip to content

Rename plugin pointer types#2813

Merged
stevenengler merged 4 commits intoshadow:mainfrom
stevenengler:ptr-types
Mar 29, 2023
Merged

Rename plugin pointer types#2813
stevenengler merged 4 commits intoshadow:mainfrom
stevenengler:ptr-types

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

  • renamed PluginPtr to ForeignPtr
  • removed PluginVirtualPtr typedef
  • renamed TypedPluginPtr to TypedArrayForeignPtr
  • renamed PluginPhysicalPtr to ManagedPhysicalMemoryAddr

This also renames some variables and function names to match.

@sporksmith If this ends up conflicting with your managed thread PR, let me know and I'll wait since it's probably easier for me to redo this than for you to deal with merge conflicts.

@stevenengler stevenengler self-assigned this Mar 29, 2023
@github-actions github-actions bot added Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable labels Mar 29, 2023
@stevenengler stevenengler requested a review from sporksmith March 29, 2023 02:46
@sporksmith
Copy link
Copy Markdown
Contributor

@sporksmith If this ends up conflicting with your managed thread PR, let me know and I'll wait since it's probably easier for me to redo this than for you to deal with merge conflicts.

It's ok - mine still needs a little work, and I don't think the conflicts will be too bad

Used the following commands, and a few manual fixes:

```
rg 'PluginPtr' --files-with-matches | xargs sed -i '/TypedPluginPtr/!s/PluginPtr/ForeignPtr/g'
rg 'pluginPtr' --files-with-matches | xargs sed -i 's/pluginPtr/foreignPtr/g'
rg 'plugin_ptr' --files-with-matches | xargs sed -i 's/plugin_ptr/foreign_ptr/g'
rg 'pluginBufPtr' --files-with-matches | xargs sed -i 's/pluginBufPtr/foreignBufPtr/g'
rg 'plugin pointer' --files-with-matches | xargs sed -i 's/plugin pointer/foreign pointer/g'
```
Used the following commands:

```
rg 'PluginVirtualPtr' --files-with-matches | xargs sed -i 's/PluginVirtualPtr/ForeignPtr/g'
rg 'c::ForeignPtr' --files-with-matches | xargs sed -i 's/c::ForeignPtr/ForeignPtr/g'
```
Used the following command:

```
rg 'TypedPluginPtr' --files-with-matches | xargs sed -i 's/TypedPluginPtr/TypedArrayForeignPtr/g'
```
Used the following command:

```
rg 'PluginPhysicalPtr' --files-with-matches | xargs sed -i 's/PluginPhysicalPtr/ManagedPhysicalMemoryAddr/g'
```
@stevenengler stevenengler enabled auto-merge March 29, 2023 17:23
@stevenengler stevenengler merged commit 91eacc2 into shadow:main Mar 29, 2023
@stevenengler stevenengler deleted the ptr-types branch March 29, 2023 17:54
stevenengler added a commit that referenced this pull request Apr 3, 2023
Follow-up to #2813.

This makes `ForeignPtr` typed. There aren't many places where we need
untyped pointers in Shadow, so making pointers typed should be the
default. This also means that for a lot of pointers, we can define their
type directly in the syscall handler. Pointer types should now be
self-documenting, and it should be harder to accidentally access the
pointers as the wrong type. An `UntypedForeignPtr` was added for
compatibility with the C code.

- added a generic type to `ForeignPtr`
- added `UntypedForeignPtr` for C code which maps to `ForeignPtr<()>` in
rust code
- renamed `TypedArrayForeignPtr` to `ForeignArrayPtr`

The intermediate commits have a lot of casts between pointer types so
that each commit would build and run, but the final code should have
only a few pointer type conversions.

There are still some things that can be cleaned up, but I think this
gets most of the code in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants