aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/cmd/lockstat
diff options
context:
space:
mode:
authorSteven Hartland <smh@FreeBSD.org>2015-01-17 14:44:59 +0000
committerSteven Hartland <smh@FreeBSD.org>2015-01-17 14:44:59 +0000
commitbc96366c864c07ef352edb92017357917c75b36c (patch)
tree09e9633064b6303a8afc6891fff761eb6e399cee /cddl/contrib/opensolaris/cmd/lockstat
parentb0b74fb366450ac61b7df38daa92bc19cbfc3ecc (diff)
downloadsrc-bc96366c864c07ef352edb92017357917c75b36c.tar.gz
src-bc96366c864c07ef352edb92017357917c75b36c.zip
Mechanically convert cddl sun #ifdef's to illumos
Since the upstream for cddl code is now illumos not sun, mechanically convert all sun #ifdef's to illumos #ifdef's which have been used in all newer code for some time. Also do a manual pass to correct the use if #ifdef comments as per style(9) as well as few uses of #if defined(__FreeBSD__) vs #ifndef illumos. MFC after: 1 month Sponsored by: Multiplay
Notes
Notes: svn path=/head/; revision=277300
Diffstat (limited to 'cddl/contrib/opensolaris/cmd/lockstat')
-rw-r--r--cddl/contrib/opensolaris/cmd/lockstat/lockstat.c24
-rw-r--r--cddl/contrib/opensolaris/cmd/lockstat/sym.c19
2 files changed, 19 insertions, 24 deletions
diff --git a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
index 0a609d773cf6..ad512c1c92c4 100644
--- a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
+++ b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
@@ -46,10 +46,9 @@
#include <signal.h>
#include <assert.h>
-#if defined(sun)
+#ifdef illumos
#define GETOPT_EOF EOF
#else
-/* FreeBSD */
#include <sys/time.h>
#include <sys/resource.h>
@@ -57,7 +56,7 @@
#define GETOPT_EOF (-1)
typedef uintptr_t pc_t;
-#endif /* defined(sun) */
+#endif
#define LOCKSTAT_OPTSTR "x:bths:n:d:i:l:f:e:ckwWgCHEATID:RpPo:V"
@@ -214,10 +213,9 @@ static ls_event_info_t g_event_info[LS_MAX_EVENTS] = {
{ 'H', "Lock", "Unknown event (type 53)", "units" },
{ 'H', "Lock", "Unknown event (type 54)", "units" },
{ 'H', "Lock", "Unknown event (type 55)", "units" },
-#if defined(sun)
+#ifdef illumos
{ 'I', "CPU+PIL", "Profiling interrupt", "nsec",
#else
- /* FreeBSD */
{ 'I', "CPU+Pri_Class", "Profiling interrupt", "nsec",
#endif
"profile:::profile-97", NULL },
@@ -231,7 +229,7 @@ static ls_event_info_t g_event_info[LS_MAX_EVENTS] = {
{ 'E', "Lock", "Lockstat record failure", "(N/A)" },
};
-#if !defined(sun)
+#ifndef illumos
static char *g_pri_class[] = {
"",
"Intr",
@@ -598,7 +596,7 @@ filter_add(char **filt, char *what, uintptr_t base, uintptr_t size)
*filt[0] = '\0';
}
-#if defined(sun)
+#ifdef illumos
(void) sprintf(c, "%s(%s >= 0x%p && %s < 0x%p)", *filt[0] != '\0' ?
" || " : "", what, (void *)base, what, (void *)(base + size));
#else
@@ -676,7 +674,7 @@ dprog_addevent(int event)
* the number of nanoseconds) is the number of nanoseconds
* late -- and it's stored in arg2.
*/
-#if defined(sun)
+#ifdef illumos
arg0 = "(uintptr_t)curthread->t_cpu + \n"
"\t curthread->t_cpu->cpu_profile_pil";
#else
@@ -824,7 +822,7 @@ dprog_compile()
}
static void
-#if defined(sun)
+#ifdef illumos
status_fire(void)
#else
status_fire(int i)
@@ -1423,7 +1421,7 @@ main(int argc, char **argv)
exit(127);
}
-#if defined(sun)
+#ifdef illumos
while (waitpid(child, &status, WEXITED) != child)
#else
while (waitpid(child, &status, 0) != child)
@@ -1468,7 +1466,7 @@ main(int argc, char **argv)
dfail("failed to walk aggregate");
}
-#if defined(sun)
+#ifdef illumos
if ((data_buf = memalign(sizeof (uint64_t),
(g_nrecs + 1) * g_recsize)) == NULL)
#else
@@ -1500,7 +1498,7 @@ main(int argc, char **argv)
if (g_gflag) {
lsrec_t *newlsp, *oldlsp;
-#if defined(sun)
+#ifdef illumos
newlsp = memalign(sizeof (uint64_t),
g_nrecs_used * LS_TIME * (g_stkdepth + 1));
#else
@@ -1664,7 +1662,7 @@ format_symbol(char *buf, uintptr_t addr, int show_size)
else if (symoff == 0)
(void) sprintf(buf, "%s", symname);
else if (symoff < 16 && bcmp(symname, "cpu[", 4) == 0) /* CPU+PIL */
-#if defined(sun)
+#ifdef illumos
(void) sprintf(buf, "%s+%ld", symname, (long)symoff);
#else
(void) sprintf(buf, "%s+%s", symname, g_pri_class[(int)symoff]);
diff --git a/cddl/contrib/opensolaris/cmd/lockstat/sym.c b/cddl/contrib/opensolaris/cmd/lockstat/sym.c
index 5940c938d96c..f3feb549c477 100644
--- a/cddl/contrib/opensolaris/cmd/lockstat/sym.c
+++ b/cddl/contrib/opensolaris/cmd/lockstat/sym.c
@@ -42,12 +42,11 @@
#include <libelf.h>
#include <link.h>
#include <elf.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/machelf.h>
#include <kstat.h>
#else
-/* FreeBSD */
#include <sys/elf.h>
#include <sys/ksyms.h>
#include <sys/param.h>
@@ -66,7 +65,7 @@ static syment_t *symbol_table;
static int nsyms, maxsyms;
static char maxsymname[64];
-#if defined(sun)
+#ifdef illumos
#ifdef _ELF64
#define elf_getshdr elf64_getshdr
#else
@@ -105,7 +104,7 @@ remove_symbol(uintptr_t addr)
sep->addr = 0;
}
-#if defined(sun)
+#ifdef illumos
static void
fake_up_certain_popular_kernel_symbols(void)
{
@@ -133,8 +132,7 @@ fake_up_certain_popular_kernel_symbols(void)
}
(void) kstat_close(kc);
}
-#else
-/* FreeBSD */
+#else /* !illumos */
static void
fake_up_certain_popular_kernel_symbols(void)
{
@@ -151,7 +149,7 @@ fake_up_certain_popular_kernel_symbols(void)
add_symbol(name, addr, sizeof (uintptr_t));
}
}
-#endif /* !defined(sun) */
+#endif /* illumos */
static int
symcmp(const void *p1, const void *p2)
@@ -177,12 +175,12 @@ symtab_init(void)
int fd;
int i;
int strindex = -1;
-#if !defined(sun)
+#ifndef illumos
void *ksyms;
size_t sz;
#endif
-#if defined(__FreeBSD__)
+#ifndef illumos
if ((fd = open("/dev/ksyms", O_RDONLY)) == -1) {
if (errno == ENOENT && modfind("ksyms") == -1) {
kldload("ksyms");
@@ -196,12 +194,11 @@ symtab_init(void)
return (-1);
#endif
-#if defined(sun)
+#ifdef illumos
(void) elf_version(EV_CURRENT);
elf = elf_begin(fd, ELF_C_READ, NULL);
#else
- /* FreeBSD */
/*
* XXX - libelf needs to be fixed so it will work with
* non 'ordinary' files like /dev/ksyms. The following