Skip to content

Conversation

@tahina-pro
Copy link
Member

In FStarLang/pulse#326, I am introducing Pulse mutable slices, and I am turning slices into immutable slices. For their C implementation, I am introducing const array pointers.
Then, I tried to refine the signature of corresponding memcpy operations so that the source pointer can be const. However, Karamel rejects me with:

blit requires a non-const pointer

This PR solves this issue by weakening the checks in lib/Check.ml to allow immutable source buffers. The destination buffer must still be mutable, though.

Everest green CI: https://github.com/project-everest/everest/actions/runs/13336176953

@tahina-pro tahina-pro requested a review from msprotz February 14, 2025 23:25
@msprotz
Copy link
Contributor

msprotz commented Feb 15, 2025

Looks good to me! Thanks so much.

You might want to check other buffer operations like EBufFill to see if they require the same treatment.

tahina-pro added a commit to FStarLang/pulse that referenced this pull request Feb 18, 2025
this commit should go hand-in-hand with FStarLang/karamel#537
@tahina-pro
Copy link
Member Author

tahina-pro commented Feb 18, 2025

Thanks Jonathan!
EBufFill requires no source buffer, only a destination buffer, and as far as I understand, Checker.check still requires it to be non-const, as expected:

karamel/lib/Checker.ml

Lines 398 to 402 in 481d456

| EBufFill (e1, e2, e3) ->
let t1, c1 = infer_buffer env e1 in
check env t1 e2;
check_mut env "fill" c1;
check_array_index env e3;

(and similarly for infer')

@msprotz msprotz enabled auto-merge February 19, 2025 00:12
@msprotz msprotz merged commit a46da20 into master Feb 19, 2025
1 check passed
@msprotz msprotz deleted the _taramana_const_source_blit branch February 19, 2025 00:57
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.

3 participants