Sorry Petro, I missed that files! Maybe Greg could explain why it is missing or if it is not necessary.
Should be nice if we could find a wait to instruct the compiler (or the building system) to include the typedefed CODE to the pointer functions automatically, but I don't know if it is possible. BR, Alan On 1/26/22, Petro Karashchenko <petro.karashche...@gmail.com> wrote: > Hello Alan, > > Maybe you misread the header file. Here are few examples of what is in > include/nuttx/fs/fs.h > struct file_operations > { > /* The device driver open method differs from the mountpoint open method > */ > > int (*open)(FAR struct file *filep); > > /* The following methods must be identical in signature and position > * because the struct file_operations and struct mountp_operations are > * treated like unions. > */ > > int (*close)(FAR struct file *filep); > ssize_t (*read)(FAR struct file *filep, FAR char *buffer, size_t buflen); > ssize_t (*write)(FAR struct file *filep, FAR const char *buffer, > size_t buflen); > off_t (*seek)(FAR struct file *filep, off_t offset, int whence); > int (*ioctl)(FAR struct file *filep, int cmd, unsigned long arg); > > /* The two structures need not be common after this point */ > > int (*poll)(FAR struct file *filep, struct pollfd *fds, bool setup); > #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS > int (*unlink)(FAR struct inode *inode); > #endif > }; > > struct block_operations > { > int (*open)(FAR struct inode *inode); > int (*close)(FAR struct inode *inode); > ssize_t (*read)(FAR struct inode *inode, FAR unsigned char *buffer, > blkcnt_t start_sector, unsigned int nsectors); > ssize_t (*write)(FAR struct inode *inode, FAR const unsigned char > *buffer, > blkcnt_t start_sector, unsigned int nsectors); > int (*geometry)(FAR struct inode *inode, FAR struct geometry > *geometry); > int (*ioctl)(FAR struct inode *inode, int cmd, unsigned long arg); > #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS > int (*unlink)(FAR struct inode *inode); > #endif > }; > > struct mountpt_operations > { > /* The mountpoint open method differs from the driver open method > * because it receives (1) the inode that contains the mountpoint > * private data, (2) the relative path into the mountpoint, and (3) > * information to manage privileges. > */ > > int (*open)(FAR struct file *filep, FAR const char *relpath, > int oflags, mode_t mode); > > /* The following methods must be identical in signature and position > * because the struct file_operations and struct mountpt_operations are > * treated like unions. > */ > > int (*close)(FAR struct file *filep); > ssize_t (*read)(FAR struct file *filep, FAR char *buffer, size_t buflen); > ssize_t (*write)(FAR struct file *filep, FAR const char *buffer, > size_t buflen); > off_t (*seek)(FAR struct file *filep, off_t offset, int whence); > int (*ioctl)(FAR struct file *filep, int cmd, unsigned long arg); > > /* The two structures need not be common after this point. The following > * are extended methods needed to deal with the unique needs of mounted > * file systems. > * > * Additional open-file-specific mountpoint operations: > */ > > int (*sync)(FAR struct file *filep); > int (*dup)(FAR const struct file *oldp, FAR struct file *newp); > int (*fstat)(FAR const struct file *filep, FAR struct stat *buf); > int (*fchstat)(FAR const struct file *filep, > FAR const struct stat *buf, int flags); > int (*truncate)(FAR struct file *filep, off_t length); > > /* Directory operations */ > > int (*opendir)(FAR struct inode *mountpt, FAR const char *relpath, > FAR struct fs_dirent_s *dir); > int (*closedir)(FAR struct inode *mountpt, > FAR struct fs_dirent_s *dir); > int (*readdir)(FAR struct inode *mountpt, > FAR struct fs_dirent_s *dir); > int (*rewinddir)(FAR struct inode *mountpt, > FAR struct fs_dirent_s *dir); > > /* General volume-related mountpoint operations: */ > > int (*bind)(FAR struct inode *blkdriver, FAR const void *data, > FAR void **handle); > int (*unbind)(FAR void *handle, FAR struct inode **blkdriver, > unsigned int flags); > int (*statfs)(FAR struct inode *mountpt, FAR struct statfs *buf); > > /* Operations on paths */ > > int (*unlink)(FAR struct inode *mountpt, FAR const char *relpath); > int (*mkdir)(FAR struct inode *mountpt, FAR const char *relpath, > mode_t mode); > int (*rmdir)(FAR struct inode *mountpt, FAR const char *relpath); > int (*rename)(FAR struct inode *mountpt, FAR const char *oldrelpath, > FAR const char *newrelpath); > int (*stat)(FAR struct inode *mountpt, FAR const char *relpath, > FAR struct stat *buf); > int (*chstat)(FAR struct inode *mountpt, FAR const char *relpath, > FAR const struct stat *buf, int flags); > }; > > Those structures contain exactly function pointers. > > Best regards, > Petro > > ср, 26 січ. 2022 р. о 16:05 Alan Carvalho de Assis <acas...@gmail.com> > пише: >> >> Hey Petro, >> >> The CODE is used on function pointers, so I think it is ok in the FS >> code. >> >> BR, >> >> Alan >> >> On 1/26/22, Petro Karashchenko <petro.karashche...@gmail.com> wrote: >> > Hello Alan, >> > >> > Yeah, I see that. But since CODE is missing for the most of the >> > pointers to functions in common code I just wonder how that platform >> > works. >> > None of FS operations in include/nuttx/fs/fs.h have CODE. Does this >> > mean that Z80, Z180 and Z16/ZNEO do not use FS as all? >> > >> > And another question is: Should we add CODE to function pointers in >> > common >> > code? >> > >> > Best regards, >> > Petro >> > >> > ср, 26 січ. 2022 р. о 15:21 Alan Carvalho de Assis <acas...@gmail.com> >> > пише: >> >> >> >> Hi Petro, >> >> >> >> It is used by Z80, Z180 and Z16/ZNEO, see include/nuttx/compiler.h for >> >> reference. >> >> >> >> BR, >> >> >> >> Alan >> >> >> >> On 1/26/22, Petro Karashchenko <petro.karashche...@gmail.com> wrote: >> >> > Hello team, >> >> > >> >> > Recently I noticed that some structures in common code use CODE >> >> > keyword for pointers to functions and some do not, so I have the >> >> > question: is CODE keyword still supported? >> >> > Here are few examples: >> >> > struct automount_lower_s >> >> > { >> >> > ... >> >> > CODE int (*attach)(FAR const struct automount_lower_s *lower, >> >> > automount_handler_t isr, FAR void *arg); >> >> > CODE void (*enable)(FAR const struct automount_lower_s *lower, >> >> > bool enable); >> >> > CODE bool (*inserted)(FAR const struct automount_lower_s *lower); >> >> > }; >> >> > vs >> >> > struct file_operations >> >> > { >> >> > int (*open)(FAR struct file *filep); >> >> > int (*close)(FAR struct file *filep); >> >> > ssize_t (*read)(FAR struct file *filep, FAR char *buffer, size_t >> >> > buflen); >> >> > ssize_t (*write)(FAR struct file *filep, FAR const char *buffer, >> >> > size_t buflen); >> >> > off_t (*seek)(FAR struct file *filep, off_t offset, int whence); >> >> > int (*ioctl)(FAR struct file *filep, int cmd, unsigned long >> >> > arg); >> >> > >> >> > /* The two structures need not be common after this point */ >> >> > >> >> > int (*poll)(FAR struct file *filep, struct pollfd *fds, bool >> >> > setup); >> >> > #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS >> >> > int (*unlink)(FAR struct inode *inode); >> >> > #endif >> >> > }; >> >> > >> >> > Will appreciate your feedback. >> >> > >> >> > Best regards, >> >> > Petro >> >> > >> > >