Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/ia64/unwind KNF
details: https://anonhg.NetBSD.org/src/rev/156781cdbc39
branches: trunk
changeset: 346747:156781cdbc39
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Jul 31 19:22:25 2016 +0000
description:
KNF
diffstat:
sys/arch/ia64/unwind/stackframe.c | 181 +++++++++++++++++++++----------------
sys/arch/ia64/unwind/stackframe.h | 14 +-
2 files changed, 109 insertions(+), 86 deletions(-)
diffs (truncated from 460 to 300 lines):
diff -r 6941659eda7c -r 156781cdbc39 sys/arch/ia64/unwind/stackframe.c
--- a/sys/arch/ia64/unwind/stackframe.c Sun Jul 31 19:12:41 2016 +0000
+++ b/sys/arch/ia64/unwind/stackframe.c Sun Jul 31 19:22:25 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: stackframe.c,v 1.7 2016/07/31 19:12:41 dholland Exp $ */
+/* $NetBSD: stackframe.c,v 1.8 2016/07/31 19:22:25 dholland Exp $ */
/* Contributed to the NetBSD foundation by Cherry G. Mathew <cherry%mahiti.org@localhost>
* This file contains routines to use decoded unwind descriptor entries
@@ -19,21 +19,21 @@
//#define UNWIND_DIAGNOSTIC
-/* Global variables:
- array of struct recordchain
- size of record chain array.
-*/
+/*
+ * Global variables:
+ * array of struct recordchain
+ * size of record chain array.
+ */
struct recordchain strc[MAXSTATERECS];
int rec_cnt = 0;
-/* Build a recordchain of a region, given the pointer to unwind table
+/*
+ * Build a recordchain of a region, given the pointer to unwind table
* entry, and the number of entries to decode.
*/
-
-void buildrecordchain(uint64_t unwind_infop, struct recordchain *xxx)
+void
+buildrecordchain(uint64_t unwind_infop, struct recordchain *xxx)
{
-
-
uint64_t unwindstart, unwindend;
uint64_t unwindlen;
uint64_t region_len = 0;
@@ -76,7 +76,8 @@
if ((nextrecp = unwind_decode_R2(recptr, &strc[rec_cnt].udesc))){
region_len = strc[rec_cnt].udesc.R2.rlen;
- region_type = false; /* R2 regions are prologue regions */
+ /* R2 regions are prologue regions */
+ region_type = false;
strc[rec_cnt].type = R2;
recptr = nextrecp;
continue;
@@ -90,7 +91,8 @@
continue;
}
- if(region_type == false) { /* Prologue Region */
+ if(region_type == false) {
+ /* Prologue Region */
if ((nextrecp = unwind_decode_P1(recptr, &strc[rec_cnt].udesc))){
strc[rec_cnt].type = P1;
recptr = nextrecp;
@@ -208,8 +210,6 @@
}
printf("Skipping body desc slot :: %d \n", rec_cnt);
-
-
}
}
@@ -220,20 +220,20 @@
}
#endif /* UNWIND_DIAGNOSTIC */
-
}
-/* Debug support: dump a record chain entry */
-void dump_recordchain(struct recordchain *rchain)
+/*
+ * Debug support: dump a record chain entry
+ */
+void
+dump_recordchain(struct recordchain *rchain)
{
switch(rchain->type) {
case R1:
-
-
printf("\t R1:");
if(rchain->udesc.R1.r)
printf("body (");
@@ -574,12 +574,14 @@
}
-/* State record stuff..... based on section 11. and Appendix A. of the
- *"Itanium Software Conventions and Runtime Architecture Guide"
+/*
+ * State record stuff..... based on section 11. and Appendix A. of the
+ * "Itanium Software Conventions and Runtime Architecture Guide"
*/
-/* Global variables:
+/*
+ * Global variables:
* 1. Two arrays of staterecords: recordstack[], recordstackcopy[]
* XXX: Since we don't use malloc, we have two arbitrary sized arrays
* providing guaranteed memory from the BSS. See the TODO file
@@ -593,12 +595,13 @@
struct staterecord *unwind_rsp, *unwind_rscp;
-uint64_t spill_base = 0; /* Base of spill area in memory stack frame as a psp relative offset */
+/* Base of spill area in memory stack frame as a psp relative offset */
+uint64_t spill_base = 0;
-/* Initialises a staterecord from a given template,
+/*
+ * Initialises a staterecord from a given template,
* with default values as described by the Runtime Spec.
*/
-
void
initrecord(struct staterecord *target)
{
@@ -617,27 +620,27 @@
}
-/* Modifies a staterecord structure by parsing
+/*
+ * Modifies a staterecord structure by parsing
* a single record chain structure.
* regionoffset is the offset within a (prologue) region
* where the stack unwinding began.
*/
-
-void modifyrecord(struct staterecord *srec, struct recordchain *rchain,
- uint64_t regionoffset)
+void
+modifyrecord(struct staterecord *srec, struct recordchain *rchain,
+ uint64_t regionoffset)
{
-
-
- uint64_t grno = 32; /* Default start save GR for prologue_save
- * GRs.
- */
-
+ /*
+ * Default start save GR for prologue_save GRs.
+ */
+ uint64_t grno = 32;
switch (rchain->type) {
case R2:
- /* R2, prologue_gr is the only region encoding
+ /*
+ * R2, prologue_gr is the only region encoding
* with register save info.
*/
@@ -689,7 +692,8 @@
break;
- /* XXX: P4 spill_mask and P7: spill_base are for GRs, FRs, and BRs.
+ /*
+ * XXX: P4 spill_mask and P7: spill_base are for GRs, FRs, and BRs.
* We're not particularly worried about those right now.
*/
@@ -816,7 +820,8 @@
}
-void dump_staterecord(struct staterecord *srec)
+void
+dump_staterecord(struct staterecord *srec)
{
printf("rp.where: ");
switch(srec->rp.where) {
@@ -866,14 +871,14 @@
printf(", pfs.when = %lu, ", srec->pfs.when);
printf("pfs.offset = %lu \n", srec->pfs.offset);
-
-
}
-/* Push a state record on the record stack. */
-
-void pushrecord(struct staterecord *srec)
+/*
+ * Push a state record on the record stack.
+ */
+void
+pushrecord(struct staterecord *srec)
{
if(unwind_rsp >= recordstack + MAXSTATERECS) {
printf("Push exceeded array size!!! \n");
@@ -885,9 +890,11 @@
}
-/* Pop n state records off the record stack. */
-
-void poprecord(struct staterecord *srec, int n)
+/*
+ * Pop n state records off the record stack.
+ */
+void
+poprecord(struct staterecord *srec, int n)
{
if(unwind_rsp == recordstack) {
printf("Popped beyond end of Stack!!! \n");
@@ -901,16 +908,22 @@
}
-/* Clone the whole record stack upto this one. */
-void clonerecordstack(u_int label)
+/*
+ * Clone the whole record stack upto this one.
+ */
+void
+clonerecordstack(u_int label)
{
memcpy(recordstackcopy, recordstack,
(unwind_rsp - recordstack) * sizeof(struct staterecord));
unwind_rscp = unwind_rsp;
}
-/* Discard the current stack, and adopt a clone. */
-void switchrecordstack(u_int label)
+/*
+ * Discard the current stack, and adopt a clone.
+ */
+void
+switchrecordstack(u_int label)
{
memcpy((void *) recordstack, (void *) recordstackcopy,
(unwind_rscp - recordstackcopy) * sizeof(struct staterecord));
@@ -918,7 +931,8 @@
}
-/* In the context of a procedure:
+/*
+ * In the context of a procedure:
* Parses through a record chain, building, pushing and/or popping staterecords,
* or cloning/destroying stacks of staterecords as required.
* Parameters are:
@@ -926,27 +940,32 @@
* procoffset: offset of point of interest, in slots, within procedure starting from slot 0
* This routine obeys [1]
*/
-struct staterecord *buildrecordstack(struct recordchain *rchain, uint64_t procoffset)
+struct staterecord *
+buildrecordstack(struct recordchain *rchain, uint64_t procoffset)
{
-
uint64_t rlen = 0; /* Current region length, defaults to zero, if not specified */
uint64_t roffset = 0; /* Accumulated region length */
uint64_t rdepth = 0; /* Offset within current region */
bool rtype;
+ int i;
- unwind_rsp = recordstack; /* Start with bottom of staterecord stack. */
+ /* Start with bottom of staterecord stack. */
+ unwind_rsp = recordstack;
initrecord(¤t_state);
- int i;
-
-
for (i = 0;i < rec_cnt;i++) {
switch (rchain[i].type) {
case R1:
rlen = rchain[i].udesc.R1.rlen;
- if (procoffset < roffset) goto out; /* Overshot Region containing procoffset. Bailout. */
+ if (procoffset < roffset) {
+ /*
+ * Overshot Region containing
+ * procoffset. Bail out.
+ */
+ goto out;
+ }
rdepth = procoffset - roffset;
roffset += rlen;
Home |
Main Index |
Thread Index |
Old Index