* Re: [PATCH] Move nested functions in backends to file scope.
@ 2015-11-03 14:24 Mark Wielaard
0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2015-11-03 14:24 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 395 bytes --]
On Wed, 2015-10-21 at 16:15 -0700, Chih-hung Hsieh wrote:
> +2015-10-21 Chih-Hung Hsieh <chh@google.com>
> +
> + * ia64_retval.c (hfa_type): Move nested function 'hfa' to file scope.
> + * aarch64_regs.c (aarch64_register_info): Move nested function 'regtype'
> + to file scope.
Pushed to master with one small tweak to ia64_retval.c so all lines fit
< 80 chars.
Cheers,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Move nested functions in backends to file scope.
@ 2015-10-21 23:15 Chih-Hung Hsieh
0 siblings, 0 replies; 3+ messages in thread
From: Chih-Hung Hsieh @ 2015-10-21 23:15 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 4337 bytes --]
Please use attached 0002*patch file,
which added my missing email address in the signed-off line.
Thanks.
On Wed, Oct 21, 2015 at 2:41 PM, Chih-Hung Hsieh <chh@google.com> wrote:
> * backends/aarch64_regs.c and backends/ia64_retval.c
> should now compile with clang.
>
> Signed-off-by: Chih-Hung Hsieh
> ---
> backends/ChangeLog | 6 ++++++
> backends/aarch64_regs.c | 38 ++++++++++++++++++++++----------------
> backends/ia64_retval.c | 20 +++++++++++---------
> 3 files changed, 39 insertions(+), 25 deletions(-)
>
> diff --git a/backends/ChangeLog b/backends/ChangeLog
> index 6ea3dc4..7f0d1c0 100644
> --- a/backends/ChangeLog
> +++ b/backends/ChangeLog
> @@ -1,3 +1,9 @@
> +2015-10-21 Chih-Hung Hsieh <chh@google.com>
> +
> + * ia64_retval.c (hfa_type): Move nested function 'hfa' to file
> scope.
> + * aarch64_regs.c (aarch64_register_info): Move nested function
> 'regtype'
> + to file scope.
> +
> 2015-10-16 Mark Wielaard <mjw@redhat.com>
>
> * ppc_symbol.c (ppc_check_special_symbol): Also allow _SDA_BASE_
> diff --git a/backends/aarch64_regs.c b/backends/aarch64_regs.c
> index 7a8a678..23014bf 100644
> --- a/backends/aarch64_regs.c
> +++ b/backends/aarch64_regs.c
> @@ -38,6 +38,25 @@
> #define BACKEND aarch64_
> #include "libebl_CPU.h"
>
> +__attribute__ ((format (printf, 7, 8)))
> +static ssize_t
> +do_regtype (const char *setname, int type,
> + const char **setnamep, int *typep,
> + char *name, size_t namelen, const char *fmt, ...)
> +{
> + *setnamep = setname;
> + *typep = type;
> +
> + va_list ap;
> + va_start (ap, fmt);
> + int s = vsnprintf (name, namelen, fmt, ap);
> + va_end(ap);
> +
> + if (s < 0 || (unsigned) s >= namelen)
> + return -1;
> + return s + 1;
> +}
> +
> ssize_t
> aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
> int regno, char *name, size_t namelen,
> @@ -47,26 +66,13 @@ aarch64_register_info (Ebl *ebl __attribute__
> ((unused)),
> if (name == NULL)
> return 128;
>
> - __attribute__ ((format (printf, 3, 4)))
> - ssize_t
> - regtype (const char *setname, int type, const char *fmt, ...)
> - {
> - *setnamep = setname;
> - *typep = type;
> -
> - va_list ap;
> - va_start (ap, fmt);
> - int s = vsnprintf (name, namelen, fmt, ap);
> - va_end(ap);
> -
> - if (s < 0 || (unsigned) s >= namelen)
> - return -1;
> - return s + 1;
> - }
>
> *prefix = "";
> *bits = 64;
>
> +#define regtype(setname, type, ...) \
> + do_regtype(setname, type, setnamep, typep, name, namelen, __VA_ARGS__)
> +
> switch (regno)
> {
> case 0 ... 30:
> diff --git a/backends/ia64_retval.c b/backends/ia64_retval.c
> index b5928c5..0bb280c 100644
> --- a/backends/ia64_retval.c
> +++ b/backends/ia64_retval.c
> @@ -89,6 +89,16 @@ static const Dwarf_Op loc_aggregate[] =
> #define nloc_aggregate 1
>
>
> +static inline int
> +compute_hfa (const Dwarf_Op *loc, int nregs, int fpregs_used, const
> Dwarf_Op **locp)
> +{
> + if (fpregs_used == 0)
> + *locp = loc;
> + else if (*locp != loc)
> + return 9;
> + return fpregs_used + nregs;
> +}
> +
> /* If this type is an HFA small enough to be returned in FP registers,
> return the number of registers to use. Otherwise 9, or -1 for
> errors. */
> static int
> @@ -100,15 +110,6 @@ hfa_type (Dwarf_Die *typedie, Dwarf_Word size,
> If we find a datum that's not the same FP type as the first datum,
> punt.
> If we count more than eight total homogeneous FP data, punt. */
>
> - inline int hfa (const Dwarf_Op *loc, int nregs)
> - {
> - if (fpregs_used == 0)
> - *locp = loc;
> - else if (*locp != loc)
> - return 9;
> - return fpregs_used + nregs;
> - }
> -
> int tag = DWARF_TAG_OR_RETURN (typedie);
> switch (tag)
> {
> @@ -123,6 +124,7 @@ hfa_type (Dwarf_Die *typedie, Dwarf_Word size,
> &attr_mem), &encoding) !=
> 0)
> return -1;
>
> +#define hfa(loc, nregs) compute_hfa(loc, nregs, fpregs_used, locp)
> switch (encoding)
> {
> case DW_ATE_float:
> --
> 2.6.0.rc2.230.g3dd15c0
>
>
[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 5289 bytes --]
[-- Attachment #3: 0002-Move-nested-functions-in-backends-to-file-scope.patch --]
[-- Type: application/octet-stream, Size: 3874 bytes --]
From 69cc789545066cc0598c003c75376369def4ba40 Mon Sep 17 00:00:00 2001
From: Chih-Hung Hsieh <chh@google.com>
Date: Wed, 21 Oct 2015 14:36:25 -0700
Subject: [PATCH] Move nested functions in backends to file scope.
* backends/aarch64_regs.c and backends/ia64_retval.c
should now compile with clang.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
---
backends/ChangeLog | 6 ++++++
backends/aarch64_regs.c | 38 ++++++++++++++++++++++----------------
backends/ia64_retval.c | 20 +++++++++++---------
3 files changed, 39 insertions(+), 25 deletions(-)
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 6ea3dc4..7f0d1c0 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-21 Chih-Hung Hsieh <chh@google.com>
+
+ * ia64_retval.c (hfa_type): Move nested function 'hfa' to file scope.
+ * aarch64_regs.c (aarch64_register_info): Move nested function 'regtype'
+ to file scope.
+
2015-10-16 Mark Wielaard <mjw@redhat.com>
* ppc_symbol.c (ppc_check_special_symbol): Also allow _SDA_BASE_
diff --git a/backends/aarch64_regs.c b/backends/aarch64_regs.c
index 7a8a678..23014bf 100644
--- a/backends/aarch64_regs.c
+++ b/backends/aarch64_regs.c
@@ -38,6 +38,25 @@
#define BACKEND aarch64_
#include "libebl_CPU.h"
+__attribute__ ((format (printf, 7, 8)))
+static ssize_t
+do_regtype (const char *setname, int type,
+ const char **setnamep, int *typep,
+ char *name, size_t namelen, const char *fmt, ...)
+{
+ *setnamep = setname;
+ *typep = type;
+
+ va_list ap;
+ va_start (ap, fmt);
+ int s = vsnprintf (name, namelen, fmt, ap);
+ va_end(ap);
+
+ if (s < 0 || (unsigned) s >= namelen)
+ return -1;
+ return s + 1;
+}
+
ssize_t
aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
int regno, char *name, size_t namelen,
@@ -47,26 +66,13 @@ aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
if (name == NULL)
return 128;
- __attribute__ ((format (printf, 3, 4)))
- ssize_t
- regtype (const char *setname, int type, const char *fmt, ...)
- {
- *setnamep = setname;
- *typep = type;
-
- va_list ap;
- va_start (ap, fmt);
- int s = vsnprintf (name, namelen, fmt, ap);
- va_end(ap);
-
- if (s < 0 || (unsigned) s >= namelen)
- return -1;
- return s + 1;
- }
*prefix = "";
*bits = 64;
+#define regtype(setname, type, ...) \
+ do_regtype(setname, type, setnamep, typep, name, namelen, __VA_ARGS__)
+
switch (regno)
{
case 0 ... 30:
diff --git a/backends/ia64_retval.c b/backends/ia64_retval.c
index b5928c5..0bb280c 100644
--- a/backends/ia64_retval.c
+++ b/backends/ia64_retval.c
@@ -89,6 +89,16 @@ static const Dwarf_Op loc_aggregate[] =
#define nloc_aggregate 1
+static inline int
+compute_hfa (const Dwarf_Op *loc, int nregs, int fpregs_used, const Dwarf_Op **locp)
+{
+ if (fpregs_used == 0)
+ *locp = loc;
+ else if (*locp != loc)
+ return 9;
+ return fpregs_used + nregs;
+}
+
/* If this type is an HFA small enough to be returned in FP registers,
return the number of registers to use. Otherwise 9, or -1 for errors. */
static int
@@ -100,15 +110,6 @@ hfa_type (Dwarf_Die *typedie, Dwarf_Word size,
If we find a datum that's not the same FP type as the first datum, punt.
If we count more than eight total homogeneous FP data, punt. */
- inline int hfa (const Dwarf_Op *loc, int nregs)
- {
- if (fpregs_used == 0)
- *locp = loc;
- else if (*locp != loc)
- return 9;
- return fpregs_used + nregs;
- }
-
int tag = DWARF_TAG_OR_RETURN (typedie);
switch (tag)
{
@@ -123,6 +124,7 @@ hfa_type (Dwarf_Die *typedie, Dwarf_Word size,
&attr_mem), &encoding) != 0)
return -1;
+#define hfa(loc, nregs) compute_hfa(loc, nregs, fpregs_used, locp)
switch (encoding)
{
case DW_ATE_float:
--
2.6.0.rc2.230.g3dd15c0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Move nested functions in backends to file scope.
@ 2015-10-21 21:41 Chih-Hung Hsieh
0 siblings, 0 replies; 3+ messages in thread
From: Chih-Hung Hsieh @ 2015-10-21 21:41 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 3774 bytes --]
* backends/aarch64_regs.c and backends/ia64_retval.c
should now compile with clang.
Signed-off-by: Chih-Hung Hsieh
---
backends/ChangeLog | 6 ++++++
backends/aarch64_regs.c | 38 ++++++++++++++++++++++----------------
backends/ia64_retval.c | 20 +++++++++++---------
3 files changed, 39 insertions(+), 25 deletions(-)
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 6ea3dc4..7f0d1c0 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-21 Chih-Hung Hsieh <chh@google.com>
+
+ * ia64_retval.c (hfa_type): Move nested function 'hfa' to file scope.
+ * aarch64_regs.c (aarch64_register_info): Move nested function 'regtype'
+ to file scope.
+
2015-10-16 Mark Wielaard <mjw@redhat.com>
* ppc_symbol.c (ppc_check_special_symbol): Also allow _SDA_BASE_
diff --git a/backends/aarch64_regs.c b/backends/aarch64_regs.c
index 7a8a678..23014bf 100644
--- a/backends/aarch64_regs.c
+++ b/backends/aarch64_regs.c
@@ -38,6 +38,25 @@
#define BACKEND aarch64_
#include "libebl_CPU.h"
+__attribute__ ((format (printf, 7, 8)))
+static ssize_t
+do_regtype (const char *setname, int type,
+ const char **setnamep, int *typep,
+ char *name, size_t namelen, const char *fmt, ...)
+{
+ *setnamep = setname;
+ *typep = type;
+
+ va_list ap;
+ va_start (ap, fmt);
+ int s = vsnprintf (name, namelen, fmt, ap);
+ va_end(ap);
+
+ if (s < 0 || (unsigned) s >= namelen)
+ return -1;
+ return s + 1;
+}
+
ssize_t
aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
int regno, char *name, size_t namelen,
@@ -47,26 +66,13 @@ aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
if (name == NULL)
return 128;
- __attribute__ ((format (printf, 3, 4)))
- ssize_t
- regtype (const char *setname, int type, const char *fmt, ...)
- {
- *setnamep = setname;
- *typep = type;
-
- va_list ap;
- va_start (ap, fmt);
- int s = vsnprintf (name, namelen, fmt, ap);
- va_end(ap);
-
- if (s < 0 || (unsigned) s >= namelen)
- return -1;
- return s + 1;
- }
*prefix = "";
*bits = 64;
+#define regtype(setname, type, ...) \
+ do_regtype(setname, type, setnamep, typep, name, namelen, __VA_ARGS__)
+
switch (regno)
{
case 0 ... 30:
diff --git a/backends/ia64_retval.c b/backends/ia64_retval.c
index b5928c5..0bb280c 100644
--- a/backends/ia64_retval.c
+++ b/backends/ia64_retval.c
@@ -89,6 +89,16 @@ static const Dwarf_Op loc_aggregate[] =
#define nloc_aggregate 1
+static inline int
+compute_hfa (const Dwarf_Op *loc, int nregs, int fpregs_used, const Dwarf_Op **locp)
+{
+ if (fpregs_used == 0)
+ *locp = loc;
+ else if (*locp != loc)
+ return 9;
+ return fpregs_used + nregs;
+}
+
/* If this type is an HFA small enough to be returned in FP registers,
return the number of registers to use. Otherwise 9, or -1 for errors. */
static int
@@ -100,15 +110,6 @@ hfa_type (Dwarf_Die *typedie, Dwarf_Word size,
If we find a datum that's not the same FP type as the first datum, punt.
If we count more than eight total homogeneous FP data, punt. */
- inline int hfa (const Dwarf_Op *loc, int nregs)
- {
- if (fpregs_used == 0)
- *locp = loc;
- else if (*locp != loc)
- return 9;
- return fpregs_used + nregs;
- }
-
int tag = DWARF_TAG_OR_RETURN (typedie);
switch (tag)
{
@@ -123,6 +124,7 @@ hfa_type (Dwarf_Die *typedie, Dwarf_Word size,
&attr_mem), &encoding) != 0)
return -1;
+#define hfa(loc, nregs) compute_hfa(loc, nregs, fpregs_used, locp)
switch (encoding)
{
case DW_ATE_float:
--
2.6.0.rc2.230.g3dd15c0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-03 14:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-03 14:24 [PATCH] Move nested functions in backends to file scope Mark Wielaard
-- strict thread matches above, loose matches on Subject: below --
2015-10-21 23:15 Chih-Hung Hsieh
2015-10-21 21:41 Chih-Hung Hsieh
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).