Monday, August 06, 2018

Re: python types, ino_t and off_t

#include <sys/types.h>
#include <stdio.h>
int main()
{
ino_t ino;
off_t off;

printf("Size of ino: %ld bytes\n",sizeof(ino));
printf("Size of off: %ld bytes\n",sizeof(off));

return 0;
}

Both are 64 bits.
But still cant figure out why the struct seems to be out of alignment.

Cheers.
Elias.

2018-08-04 21:10 GMT-03:00 Elias M. Mariani <marianielias@gmail.com>:
> Hi ports@,
> I'm tying to port a python package that uses the dirent struct
> defining the fields like this:
>
> _fields_ = (
> ('d_ino', ctypes.c_uint32), # must be uint32, not ulong
> ('d_off', ctypes.c_long),
> ('d_reclen', ctypes.c_ushort),
> ('d_type', ctypes.c_ubyte),
> ('d_namlen', ctypes.c_ubyte),
> ('d_name', ctypes.c_char * 256),
> )
>
> Now, aren't ino_t and off_t architecture dependent ? If not, how do I
> find the length of each types ?
> The others are defined in the dirent description.
> If dependent of the architecture, I should find a way of using the
> real definitions in python...
>
> Cheers.
> Elias.

No comments:

Post a Comment