From: Doug Evans <dje@google.com>
To: binutils@sourceware.org
Subject: [PATCH] Add typedefs for bfd_openr_iovec functions
Date: Tue, 05 Aug 2014 17:00:00 -0000 [thread overview]
Message-ID: <yjt2oavyj2i9.fsf@ruffy.mtv.corp.google.com> (raw)
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);
next reply other threads:[~2014-08-05 17:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-05 17:00 Doug Evans [this message]
2014-08-07 8:17 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yjt2oavyj2i9.fsf@ruffy.mtv.corp.google.com \
--to=dje@google.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).