Daniel Melo Jorge da Cunha
2014-May-22 14:37 UTC
[Nouveau] nouveau_object_new beginner question
I'm sorry for this beginner question but I can't understand. File ../nouveau/nouveau.c, function nouveau_object_new. Assuming data has content. First, obj->data = obj + 1. This is perfect after the memcpy call. But when: *(struct nouveau_object **)obj->data = obj; I can't understand because now obj and obj->data has the same address, while previously obj->data pointed exactly to the contents of data. What am I missing? Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freedesktop.org/archives/nouveau/attachments/20140522/c4366fa0/attachment.html>
On Thu, May 22, 2014 at 10:37 AM, Daniel Melo Jorge da Cunha <dmjcunha at gmail.com> wrote:> I'm sorry for this beginner question but I can't understand. > File ../nouveau/nouveau.c, function nouveau_object_new. > Assuming data has content. First, obj->data = obj + 1. This is perfect > after the memcpy call. > But when: *(struct nouveau_object **)obj->data = obj; > I can't understand because now obj and obj->data has the same address, > while previously obj->data pointed exactly to the contents of data. > What am I missing?You're a little off in your analysis. That line does *obj->data = obj not obj->data = obj. Basically it makes the assumption that the first field of the data is a pointer, and then sets it to the newly-created obj structure. It's a little fragile, but all the objects assigned to data do indeed start with a nouveau_object pointer (nouveau_fifo and its derivatives, nv04_notify). Hope this helps, -ilia
Reasonably Related Threads
- [libdrm 01/13] nouveau: move more abi16-specific logic into abi16.c
- [libdrm v2 01/14] nouveau: import and install a selection of nvif headers from the kernel
- [libdrm v3 01/14] nouveau: import and install a selection of nvif headers from the kernel
- [PATCH try 2 1/2] gallium/nouveau: decouple nouveau_fence implementation from screen
- [PATCH 1/2] gallium/nouveau: decouple nouveau_fence implementation from screen