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

Proposal: Alignment of embedFile()'s destination storage address should be the Target's pointer size. #4680

Open
JesseRMeyer opened this issue Mar 8, 2020 · 1 comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@JesseRMeyer
Copy link

JesseRMeyer commented Mar 8, 2020

This allows binary blobs to be ingested, and interpreted correctly as types of size > 1 without the need to manually shift the allocation at runtime (or comp-time) for re-alignment.

@JesseRMeyer JesseRMeyer changed the title Proposal: Alignment of embedFile() Proposal: Alignment of embedFile()'s destination address should be the Target's pointer size. Mar 8, 2020
@JesseRMeyer JesseRMeyer changed the title Proposal: Alignment of embedFile()'s destination address should be the Target's pointer size. Proposal: Alignment of embedFile()'s destination storage address should be the Target's pointer size. Mar 8, 2020
@andrewrk andrewrk added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Mar 8, 2020
@andrewrk andrewrk added this to the 0.7.0 milestone Mar 8, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 27, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 May 19, 2021
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 Nov 23, 2021
@andrewrk andrewrk modified the milestones: 0.10.0, 0.11.0 Apr 16, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.12.0 Apr 9, 2023
tw4452852 pushed a commit to tw4452852/zig that referenced this issue Apr 24, 2023
@andrewrk andrewrk modified the milestones: 0.13.0, 0.12.0 Jul 9, 2023
@rohlem
Copy link
Contributor

rohlem commented Nov 9, 2023

Has changing the return type from pointer to value been considered?
I.e. making @embedFile return [N:0]u8 instead of *const [N:0]u8.

That way the user could explicitly provide the required alignment in the (result) location that is being assigned,
f.e. const contents align(64) = @embedFile("f.txt");.
Status-quo behavior is achievable by explicitly constructing a pointer &contents.

EDIT: Actually the following already works for me in 0.12.0-dev.1139+4d106076c:

const storage align(64) = @embedFile("data.bin").*;
const storagePointer = &storage;

But please point out if this is somehow less optimal for certain use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants