Skip to content

Fix MPR#7203: expose a convenience function to allocate float vect#534

Merged
gasche merged 1 commit intoocaml:trunkfrom
braibant:expose_caml_make_float_vect
Jun 26, 2016
Merged

Fix MPR#7203: expose a convenience function to allocate float vect#534
gasche merged 1 commit intoocaml:trunkfrom
braibant:expose_caml_make_float_vect

Conversation

@braibant
Copy link
Copy Markdown
Contributor

@braibant braibant commented Apr 5, 2016

No description provided.

@damiendoligez damiendoligez added this to the 4.04 milestone Apr 11, 2016
@alainfrisch
Copy link
Copy Markdown
Contributor

Should one check that the size is not greater than Max_wosize as in caml_make_float_vect?

Also, can you add an entry to the Changes file?

@damiendoligez
Copy link
Copy Markdown
Member

IMO it should do the same as caml_alloc (i.e. call caml_alloc_shr without checking, which will raise Out_of_memory if the size is too large). This is what it does already.

BUT the name is wrong, it should be caml_alloc_float_array: we don't use the word vect in any of our exported C functions.

@alainfrisch
Copy link
Copy Markdown
Contributor

Raising an exception for a function to be used on the C side seems to be a bad idea, since there is no way to catch it on the C side, easily leading to memory leaks (if the C code has already mallocated some memory).

@braibant
Copy link
Copy Markdown
Contributor Author

braibant commented May 5, 2016

I tried to mimic the behavior of caml_alloc and other functions in alloc.c which do raise. I agree that we do not have a good way to catch those on the C side, but it seems to be a larger problem that needs to be addressed for all those functions. I will correct the name, though.

@braibant braibant force-pushed the expose_caml_make_float_vect branch from d9cf6b0 to 1082aa0 Compare May 10, 2016 07:00
@braibant braibant force-pushed the expose_caml_make_float_vect branch from 1082aa0 to 3cefcaa Compare May 10, 2016 07:21
@gasche gasche merged commit a60ce5a into ocaml:trunk Jun 26, 2016
camlspotter pushed a commit to camlspotter/ocaml that referenced this pull request Oct 17, 2017
Fix MPR#7203: expose a convenience function to allocate float vect
}

/* [len] is a number of floats */
CAMLprim value caml_alloc_float_array(mlsize_t len)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes the function to be added to the primitives table in the bytecode runtime, which I think can only be an error here? This should have been CAMLexport rather than CAMLprim, I think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dra27 is correct, this should be CAMLexport, in particular because it cannot be called from OCaml bytecode (first argument is an unboxed integer).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It'll be fixed as part of a horrific, I mean glorious, update to the caml headers coming soon to a pull request near you...

EduardoRFS pushed a commit to esy-ocaml/ocaml that referenced this pull request May 17, 2021
Move allocation size information to frame descriptors
mshinwell pushed a commit to chambart/ocaml-1 that referenced this pull request Jul 6, 2021
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Mar 22, 2022
stedolan pushed a commit to stedolan/ocaml that referenced this pull request May 24, 2022
stedolan added a commit to stedolan/ocaml that referenced this pull request May 24, 2022
64235a3 flambda-backend: Change Float.nan from sNaN to qNaN (ocaml#466)
14a8e27 flambda-backend: Track GC work for all managed bigarray allocations (upstream 11022) (ocaml#569)
c3cda96 flambda-backend: Add two new methods to targetint for dwarf (ocaml#560)
e6f1fed flambda-backend: Handle arithmetic overflow in select_addr (ocaml#570)
dab7209 flambda-backend: Add Target_system to ocaml/utils (ocaml#542)
82d5044 flambda-backend: Enhance numbers.ml with more primitive types (ocaml#544)
216be99 flambda-backend: Fix flambda_o3 and flambda_oclassic attributes (ocaml#536)
4b56e07 flambda-backend: Test naked pointer root handling (ocaml#550)
40d69ce flambda-backend: Stop local function optimisation from moving code into function bodies; opaque_identity fixes for class compilation (ocaml#537)
f08ae58 flambda-backend: Implemented inlining history and use it inside inlining reports (ocaml#365)
ac496bf flambda-backend: Disable the local keyword in typing (ocaml#540)
7d46712 flambda-backend: Bugfix for Typedtree generation of arrow types (ocaml#539)
61a7b47 flambda-backend: Insert missing page table check in roots_nat.c (ocaml#541)
323bd36 flambda-backend: Compiler error when -disable-all-extensions and -extension are used (ocaml#534)
d8956b0 flambda-backend: Persistent environment and reproducibility (ocaml#533)
4a0c89f flambda-backend: Revert "Revert bswap PRs (480 and 482)" (ocaml#506)
7803705 flambda-backend: Cause a C warning when CAMLreturn is missing in C stubs. (ocaml#376)
6199db5 flambda-backend: Improve unboxing during cmm for Flambda (ocaml#295)
96b9e1b flambda-backend: Print diagnostics at runtime for Invalid (ocaml#530)
42ab88e flambda-backend: Disable bytecode compilers in ocamltest (ocaml#504)
58c72d5 flambda-backend: Backport ocaml#10595 from upstream/trunk (ocaml#471)
1010539 flambda-backend: Use C++ name mangling convention (ocaml#483)
81881bb flambda-backend: Local allocation test no longer relies on lifting (ocaml#525)
f5c4719 flambda-backend: Fix an assertion in Closure that breaks probes (ocaml#505)
c2cf2b2 flambda-backend: Add some missing command line arguments to ocamlnat (ocaml#499)

git-subtree-dir: ocaml
git-subtree-split: 64235a3
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.

6 participants