#include <setjmp.h>
#include <string.h>
#include <alloc.h>
+#include <stdlib.h>
#include "asm.h"
/*)Module aslist.c
}
}
+/* Used for qsort call in lstsym */
+static int _cmpSym(const void *p1, const void *p2)
+{
+ struct sym **s1 = (struct sym **)(p1);
+ struct sym **s2 = (struct sym **)(p2);
+ return strcmp((*s1)->s_id,(*s2)->s_id);
+}
+
/*)Function VOID lstsym(fp)
*
* FILE * fp file handle for output
}
}
+#if 0
+ /* BUBBLE SORT?? WTF??? */
/*
* Bubble Sort on Symbol Table Array
*/
}
}
}
+#else
+
+ qsort(p, nmsym, sizeof(struct sym *), _cmpSym);
+#endif
/*
* Symbol Table Output
#include <stdio.h>
#include <string.h>
#include <alloc.h>
+#include <stdlib.h>
#include "aslink.h"
/*)Module lklist.c
lop = 1;
}
+/* Used for qsort call in lstsym */
+static int _cmpSymByAddr(const void *p1, const void *p2)
+{
+ struct sym **s1 = (struct sym **)(p1);
+ struct sym **s2 = (struct sym **)(p2);
+ int delta = ((*s1)->s_addr + (*s1)->s_axp->a_addr) -
+ ((*s2)->s_addr + (*s2)->s_axp->a_addr);
+
+ /* Sort first by address, then by name. */
+ if (delta)
+ {
+ return delta;
+ }
+ return strcmp((*s1)->s_id,(*s2)->s_id);
+}
+
+
#if NCPS-8
/* NCPS != 8 */
struct area *xp;
{
register struct areax *oxp;
- register int i, j;
+ register int i;
+ /* int j; */
register char *ptr;
int nmsym;
- addr_t a0, ai, aj;
+ /* addr_t a0; */
+ addr_t ai, aj;
struct sym *sp;
struct sym **p;
int memPage;
oxp = oxp->a_axp;
}
+#if 0
/*
* Bubble Sort of Addresses in Symbol Table Array
*/
a0 = ai;
}
}
+#else
+ qsort(p, nmsym, sizeof(struct sym *), _cmpSymByAddr);
+#endif
/*
* Symbol Table Output
oxp = oxp->a_axp;
}
+#if 0
/*
* Bubble Sort of Addresses in Symbol Table Array
*/
a0 = ai;
}
}
+#else
+ qsort(p, nmsym, sizeof(struct sym *), _cmpSymByAddr);
+#endif
/*
* Symbol Table Output