georges-duperon
2017-5-28 15:46:58

@mflatt user mrm on IRC asked yesterday if there were any explanation of how linklets work. Do you have something within hyperlink’s reach ? I had a quick look at your racket7 repo, but didn’t see any obvious pointers.


mflatt
2017-5-28 16:18:16

@georges-duperon I guess this is as close as it gets to web-accessible: https://github.com/racket/racket7/blob/master/pkgs/racket-doc/scribblings/reference/linklet.scrbl


georges-duperon
2017-5-28 16:19:49

@mflatt Thanks! I had explicitly searched for files containing “linklet” in the repo, and somehow managed to miss that one :slightly_smiling_face:


leif
2017-5-28 16:24:17

Does anyone know how to ‘collapse’ the padding in two cstructs in the FFI?


leif
2017-5-28 16:24:59

Like, I have a struct with a lot of fields, and in the middle, I have for a list size, followed by a pointer to that list.


leif
2017-5-28 16:25:24

I want to make a ctype that will give me a safe list given those two values.


leif
2017-5-28 16:26:02

And I can do that in another cstruct, but because the padding is now larger, it messes up the offsets for the rest of the struct.


leif
2017-5-28 16:26:30

So, is there any way I can insert a cstruct into another cstruct such that it takes the paddings of the element in the inner cstruct?


leif
2017-5-28 16:26:37

Either way, thank you.


mflatt
2017-5-28 16:36:35

@leif You be able to achieve the effect you want by declaring #:alignment


leif
2017-5-28 16:37:00

Okay cool. In which cstruct?


leif
2017-5-28 16:38:17

Like, it seems like I’d need to set it in the outer one, and then manually calculate the allignment for the rest of the struct, is tht correct @mflatt ?


mflatt
2017-5-28 16:39:38

I was thinking that you’d set it for the inner one


leif
2017-5-28 16:47:42

Oh, okay. In that case the docs kind of confused me what it does. As I thought you attached it to specific fields?


leif
2017-5-28 16:48:16

(I mean, I know you can attach it to the whole struct, but in this case, I only want one field to be alligned differently.)


leif
2017-5-28 16:49:10

Oh, I see what you mean, #:alignment 1 worked, thank you @mflatt


zenspider
2017-5-28 20:11:03

@zenspider has joined the channel


leif
2017-5-28 21:33:04

@mflatt Actually, after thinking about it a bit more, I don’t think #:alignment 1 would work, or any ‘alignment’ on the inside struct would be good enough.


leif
2017-5-28 21:33:28

Because this is going to be context sensitive on the placement of the outside struct and its alignment.


leif
2017-5-28 21:35:27

Like, if I had: struct{ char prefix, char count, void *data }, I would want it to be compacted (on 32-bit x86 for simplicity) as: [prefix][count][padding][padding][padding][data][data][data][data]


leif
2017-5-28 21:35:56

(Where I have specified each byte in [...])


leif
2017-5-28 21:37:04

But when I do #:alignment 1 on the inner struct, the layout is going to be:

[prefix][count][data][data][data][data]

which removes the padding.


leif
2017-5-28 21:37:09

Any thoughts @mflatt ?


mflatt
2017-5-28 21:55:29

@leif I think you’d have to add the padding back manually in that case. There’s not much in between “do the default thing” and “let me control layout completely”.


leif
2017-5-28 21:58:04

@mflatt Ah fair. Well thank you.