* [PATCH] Add typedefs for bfd_openr_iovec functions
@ 2014-08-05 17:00 Doug Evans
2014-08-07 8:17 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: Doug Evans @ 2014-08-05 17:00 UTC (permalink / raw)
To: binutils
Hi.
This patch adds typedefs for the functions passed to bfd_openr_iovec.
I'm working on a patch to use them in gdb, but this is a clean up in
its own right so I'm submitting it now.
Ok to check in?
Notes:
- gdb uses _ftype suffix as a convention for function typedefs,
but I gather bfd uses _type so I went with that.
- I put the CODE_FRAGMENT in its own comment, not sure whether there
were any conventions to do otherwise. Let me know if/how you'd like
this done differently.
2014-08-05 Doug Evans <dje@google.com>
* opncls.c (bfd_openr_iovec_open_type): New typedef.
(bfd_openr_iovec_close_type): New typedef.
(bfd_openr_iovec_pread_type): New typedef.
(bfd_openr_iovec_stat_type): New typedef.
(struct opncls, bfd_openr_iovec): Update to use them.
* bfd-in2.h: Regenerate.
diff --git a/bfd/opncls.c b/bfd/opncls.c
index a2a35f4..2e09c70 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -408,24 +408,34 @@ bfd_openstreamr (const char *filename, const char *target, void *streamarg)
}
/*
+CODE_FRAGMENT
+.{* The type of the "open" function to pass to bfd_openr_iovec. *}
+.typedef void *(bfd_openr_iovec_open_type) (struct bfd *nbfd,
+. void *open_closure);
+.{* The type of the "close" function to pass to bfd_openr_iovec. *}
+.typedef int (bfd_openr_iovec_close_type) (struct bfd *nbfd, void *stream);
+.{* The type of the "pread" function to pass to bfd_openr_iovec. *}
+.typedef file_ptr (bfd_openr_iovec_pread_type) (struct bfd *nbfd, void *stream,
+. void *buf,
+. file_ptr nbytes,
+. file_ptr offset);
+.{* The type of the "stat" function to pass to bfd_openr_iovec. *}
+.typedef int (bfd_openr_iovec_stat_type) (struct bfd *nbfd, void *stream,
+. struct stat *sb);
+.
+*/
+
+/*
FUNCTION
bfd_openr_iovec
SYNOPSIS
bfd *bfd_openr_iovec (const char *filename, const char *target,
- void *(*open_func) (struct bfd *nbfd,
- void *open_closure),
+ bfd_openr_iovec_open_type *open_func,
void *open_closure,
- file_ptr (*pread_func) (struct bfd *nbfd,
- void *stream,
- void *buf,
- file_ptr nbytes,
- file_ptr offset),
- int (*close_func) (struct bfd *nbfd,
- void *stream),
- int (*stat_func) (struct bfd *abfd,
- void *stream,
- struct stat *sb));
+ bfd_openr_iovec_pread_type *pread_func,
+ bfd_openr_iovec_close_type *close_func,
+ bfd_openr_iovec_stat_type *stat_func);
DESCRIPTION
@@ -467,10 +477,9 @@ DESCRIPTION
struct opncls
{
void *stream;
- file_ptr (*pread) (struct bfd *abfd, void *stream, void *buf,
- file_ptr nbytes, file_ptr offset);
- int (*close) (struct bfd *abfd, void *stream);
- int (*stat) (struct bfd *abfd, void *stream, struct stat *sb);
+ bfd_openr_iovec_pread_type *pread;
+ bfd_openr_iovec_close_type *close;
+ bfd_openr_iovec_stat_type *stat;
file_ptr where;
};
@@ -564,12 +573,11 @@ static const struct bfd_iovec opncls_iovec = {
bfd *
bfd_openr_iovec (const char *filename, const char *target,
- void *(*open_p) (struct bfd *, void *),
+ bfd_openr_iovec_open_type *open_p,
void *open_closure,
- file_ptr (*pread_p) (struct bfd *, void *, void *,
- file_ptr, file_ptr),
- int (*close_p) (struct bfd *, void *),
- int (*stat_p) (struct bfd *, void *, struct stat *))
+ bfd_openr_iovec_pread_type *pread_p,
+ bfd_openr_iovec_close_type *close_p,
+ bfd_openr_iovec_stat_type *stat_p)
{
bfd *nbfd;
const bfd_target *target_vec;
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 8c77c81..83a569f 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1033,20 +1033,26 @@ bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
bfd *bfd_openstreamr (const char * filename, const char * target, void * stream);
+/* The type of the "open" function to pass to bfd_openr_iovec. */
+typedef void *(bfd_openr_iovec_open_type) (struct bfd *nbfd,
+ void *open_closure);
+/* The type of the "close" function to pass to bfd_openr_iovec. */
+typedef int (bfd_openr_iovec_close_type) (struct bfd *nbfd, void *stream);
+/* The type of the "pread" function to pass to bfd_openr_iovec. */
+typedef file_ptr (bfd_openr_iovec_pread_type) (struct bfd *nbfd, void *stream,
+ void *buf,
+ file_ptr nbytes,
+ file_ptr offset);
+/* The type of the "stat" function to pass to bfd_openr_iovec. */
+typedef int (bfd_openr_iovec_stat_type) (struct bfd *nbfd, void *stream,
+ struct stat *sb);
+
bfd *bfd_openr_iovec (const char *filename, const char *target,
- void *(*open_func) (struct bfd *nbfd,
- void *open_closure),
+ bfd_openr_iovec_open_type *open_func,
void *open_closure,
- file_ptr (*pread_func) (struct bfd *nbfd,
- void *stream,
- void *buf,
- file_ptr nbytes,
- file_ptr offset),
- int (*close_func) (struct bfd *nbfd,
- void *stream),
- int (*stat_func) (struct bfd *abfd,
- void *stream,
- struct stat *sb));
+ bfd_openr_iovec_pread_type *pread_func,
+ bfd_openr_iovec_close_type *close_func,
+ bfd_openr_iovec_stat_type *stat_func);
bfd *bfd_openw (const char *filename, const char *target);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Add typedefs for bfd_openr_iovec functions
2014-08-05 17:00 [PATCH] Add typedefs for bfd_openr_iovec functions Doug Evans
@ 2014-08-07 8:17 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2014-08-07 8:17 UTC (permalink / raw)
To: Doug Evans; +Cc: binutils
On Tue, Aug 05, 2014 at 09:59:58AM -0700, Doug Evans wrote:
> - I put the CODE_FRAGMENT in its own comment, not sure whether there
> were any conventions to do otherwise. Let me know if/how you'd like
> this done differently.
Putting the typedefs in a CODE_FRAGMENT doesn't look very nice in
opncls.texi or bfd.info. I believe they would be best placed in the
synopsis of bfd_openr_iovec, and without comments.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-07 8:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-05 17:00 [PATCH] Add typedefs for bfd_openr_iovec functions Doug Evans
2014-08-07 8:17 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).