Skip to content

Commit

Permalink
Extirpate longlong_t and u_longlong_t from C
Browse files Browse the repository at this point in the history
These constants have to stay in the D layer (like all the other
obsolescent integral *_t constants, people might be relying on them) but
on the C layer DTrace builds with -std=gnu99, so we can absolutely
guarantee that both long long and unsigned long long already exist (and
the codebase already uses them, and GCC has supported them for many
years longer in any case).

So drop them as redundant.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
nickalcock authored and kvanhees committed Jul 27, 2022
1 parent c2be27a commit 2479ce9
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 77 deletions.
5 changes: 2 additions & 3 deletions cmd/Build
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Oracle Linux DTrace.
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.

cmds: $(objdir)/run-dtrace

CMDS += dtrace bpf_dump
dtrace_CPPFLAGS = -Ilibdtrace -Ilibproc -D_LONGLONG_TYPE \
-DDTRACE_LIBDIR="\"$(LIBDIR)/dtrace\""
dtrace_CPPFLAGS = -Ilibdtrace -Ilibproc -DDTRACE_LIBDIR="\"$(LIBDIR)/dtrace\""
dtrace_TARGET = dtrace
dtrace_DIR := $(current-dir)
dtrace_SOURCES = dtrace.c
Expand Down
4 changes: 2 additions & 2 deletions libdtrace/Build
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Oracle Linux DTrace.
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.

BUILDLIBS += libdtrace-build
libdtrace-build_CPPFLAGS = -Ilibdtrace -Ilibproc -Iuts/intel -Ilibdtrace/$(ARCHINC) -D_LONGLONG_TYPE \
libdtrace-build_CPPFLAGS = -Ilibdtrace -Ilibproc -Iuts/intel -Ilibdtrace/$(ARCHINC) \
-DDTRACE_LIBDIR="\"$(LIBDIR)/dtrace\"" -DDTRACE_USER_UID=$(USER_UID) \
-DUNPRIV_UID=$(UNPRIV_UID) -DDUMPCAP_GROUP=\"$(DUMPCAP_GROUP)\" \
-DUNPRIV_HOME=\"$(UNPRIV_HOME)\"
Expand Down
18 changes: 9 additions & 9 deletions libdtrace/dt_consume.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,11 +1194,11 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
offset = pc[i] - pmap->pr_vaddr;

snprintf(c, sizeof(c), "%s:0x%llx",
dt_basename(objname), (u_longlong_t)offset);
dt_basename(objname), (unsigned long long)offset);

} else
snprintf(c, sizeof(c), "0x%llx",
(u_longlong_t)pc[i]);
(unsigned long long)pc[i]);

} else if (pid >= 0 && dt_Plookup_by_addr(dtp, pid, pc[i],
&name, &sym) == 0) {
Expand All @@ -1207,7 +1207,7 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
if (pc[i] > sym.st_value)
snprintf(c, sizeof(c), "%s`%s+0x%llx",
dt_basename(objname), name,
(u_longlong_t)(pc[i] - sym.st_value));
(unsigned long long)(pc[i] - sym.st_value));
else
snprintf(c, sizeof(c), "%s`%s",
dt_basename(objname), name);
Expand Down Expand Up @@ -1236,10 +1236,10 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
if (pid >= 0 && dt_Pobjname(dtp, pid, pc[i], objname,
sizeof(objname)) != NULL)
snprintf(c, sizeof(c), "%s`0x%llx",
dt_basename(objname), (u_longlong_t)pc[i]);
dt_basename(objname), (unsigned long long)pc[i]);
else
snprintf(c, sizeof(c), "0x%llx",
(u_longlong_t)pc[i]);
(unsigned long long)pc[i]);
}

if ((err = dt_printf(dtp, fp, format, c)) < 0)
Expand Down Expand Up @@ -1341,7 +1341,7 @@ dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr)
sizeof(objname)) != NULL)
snprintf(c, sizeof(c), "%s", dt_basename(objname));
else
snprintf(c, sizeof(c), "0x%llx", (u_longlong_t)pc);
snprintf(c, sizeof(c), "0x%llx", (unsigned long long)pc);

err = dt_printf(dtp, fp, format, c);

Expand Down Expand Up @@ -1373,9 +1373,9 @@ dt_print_sym(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr)
*/
if (dtrace_lookup_by_addr(dtp, pc, NULL, &dts) == 0)
snprintf(c, sizeof(c), "%s`0x%llx",
dts.object, (u_longlong_t)pc);
dts.object, (unsigned long long)pc);
else
snprintf(c, sizeof(c), "0x%llx", (u_longlong_t)pc);
snprintf(c, sizeof(c), "0x%llx", (unsigned long long)pc);
}

if (dt_printf(dtp, fp, format, c) < 0)
Expand All @@ -1398,7 +1398,7 @@ dt_print_mod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr)
if (dtrace_lookup_by_addr(dtp, pc, NULL, &dts) == 0)
snprintf(c, sizeof(c), "%s", dts.object);
else
snprintf(c, sizeof(c), "0x%llx", (u_longlong_t)pc);
snprintf(c, sizeof(c), "0x%llx", (unsigned long long)pc);

if (dt_printf(dtp, fp, format, c) < 0)
return -1;
Expand Down
8 changes: 4 additions & 4 deletions libdtrace/dt_dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,14 @@ dt_dis_rtab(const char *rtag, const dtrace_difo_t *dp, FILE *fp,
tstr = "R_???";
}

if ((u_longlong_t)rp->dofr_data != DT_IDENT_UNDEF)
if ((unsigned long long)rp->dofr_data != DT_IDENT_UNDEF)
fprintf(fp, "%-17s %-8llu %-8llu %s\n", tstr,
(u_longlong_t)rp->dofr_offset,
(u_longlong_t)rp->dofr_data,
(unsigned long long)rp->dofr_offset,
(unsigned long long)rp->dofr_data,
dt_difo_getstr(dp, rp->dofr_name));
else
fprintf(fp, "%-17s %-8llu %-8s %s\n", tstr,
(u_longlong_t)rp->dofr_offset,
(unsigned long long)rp->dofr_offset,
"*UND*",
dt_difo_getstr(dp, rp->dofr_name));
}
Expand Down
2 changes: 1 addition & 1 deletion libdtrace/dt_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ dt_handle_err(dtrace_hdl_t *dtp, dtrace_probedata_t *data)
case DTRACEFLT_BADALIGN:
case DTRACEFLT_BADSTACK:
case DTRACEFLT_BADSIZE:
sprintf(details, " (0x%llx)", (u_longlong_t)err.dteda_addr);
sprintf(details, " (0x%llx)", (unsigned long long)err.dteda_addr);
break;

default:
Expand Down
10 changes: 5 additions & 5 deletions libdtrace/dt_ident.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ dt_idcook_args(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *ap)

if (ap->dn_value >= prp->argc)
xyerror(D_ARGS_IDX, "index %lld is out of range for %s %s[ ]\n",
(longlong_t)ap->dn_value, dtrace_desc2str(yypcb->pcb_pdesc,
(long long)ap->dn_value, dtrace_desc2str(yypcb->pcb_pdesc,
n1, sizeof(n1)), idp->di_name);

/*
Expand All @@ -360,11 +360,11 @@ dt_idcook_args(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *ap)

if (xnp->dn_type == CTF_ERR)
xyerror(D_ARGS_TYPE, "failed to resolve translated type for "
"%s[%lld]\n", idp->di_name, (longlong_t)ap->dn_value);
"%s[%lld]\n", idp->di_name, (long long)ap->dn_value);

if (nnp->dn_type == CTF_ERR)
xyerror(D_ARGS_TYPE, "failed to resolve native type for "
"%s[%lld]\n", idp->di_name, (longlong_t)ap->dn_value);
"%s[%lld]\n", idp->di_name, (long long)ap->dn_value);

if (idp->di_type == CTF_ERR) {
idp->di_ctfp = DT_DYN_CTFP(dtp);
Expand Down Expand Up @@ -414,7 +414,7 @@ dt_idcook_args(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *ap)

} else {
xyerror(D_ARGS_XLATOR, "translator for %s[%lld] from %s to %s "
"is not defined\n", idp->di_name, (longlong_t)ap->dn_value,
"is not defined\n", idp->di_name, (long long)ap->dn_value,
dt_node_type_name(nnp, n1, sizeof(n1)),
dt_node_type_name(xnp, n2, sizeof(n2)));
}
Expand Down Expand Up @@ -443,7 +443,7 @@ dt_idcook_regs(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *ap)

if ((ap->dn_flags & DT_NF_SIGNED) && (int64_t)ap->dn_value < 0)
xyerror(D_REGS_IDX, "index %lld is out of range for array %s\n",
(longlong_t)ap->dn_value, idp->di_name);
(long long)ap->dn_value, idp->di_name);

if (dt_type_lookup("uint64_t", &dtt) == -1)
xyerror(D_UNKNOWN, "failed to resolve type of %s: %s\n",
Expand Down
10 changes: 5 additions & 5 deletions libdtrace/dt_link.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -828,7 +828,7 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
*/
if (ip[0] != DT_OP_CALL) {
dt_dprintf("found %x instead of a call instruction at %llx\n",
ip[0], (u_longlong_t)rela->r_offset);
ip[0], (unsigned long long)rela->r_offset);
return -1;
}

Expand All @@ -841,7 +841,7 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
*/
if (DT_IS_RESTORE(ip[1]) || DT_IS_MOV_O7(ip[1])) {
dt_dprintf("tail call to is-enabled probe at %llx\n",
(u_longlong_t)rela->r_offset);
(unsigned long long)rela->r_offset);
return -1;
}

Expand Down Expand Up @@ -962,7 +962,7 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
*/
if (ip[0] != DT_OP_CALL && ip[0] != DT_OP_JMP32) {
dt_dprintf("found %x instead of a call or jmp instruction at "
"%llx\n", ip[0], (u_longlong_t)rela->r_offset);
"%llx\n", ip[0], (unsigned long long)rela->r_offset);
return -1;
}

Expand Down Expand Up @@ -1045,7 +1045,7 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
*/
if (ip[0] != DT_OP_CALL26 && ip[0] != DT_OP_JUMP26) {
dt_dprintf("found %x instead of a call or jmp instruction at "
"%llx\n", ip[0], (u_longlong_t)rela->r_offset);
"%llx\n", ip[0], (unsigned long long)rela->r_offset);
return -1;
}

Expand Down
12 changes: 6 additions & 6 deletions libdtrace/dt_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ dt_node_name(const dt_node_t *dnp, char *buf, size_t len)
switch (dnp->dn_kind) {
case DT_NODE_INT:
snprintf(buf, len, "integer constant 0x%llx",
(u_longlong_t)dnp->dn_value);
(unsigned long long)dnp->dn_value);
break;
case DT_NODE_STRING:
s = strchr2esc(dnp->dn_string, strlen(dnp->dn_string));
Expand Down Expand Up @@ -1262,7 +1262,7 @@ dt_node_int(uintmax_t value)
}

xyerror(D_INT_OFLOW, "integer constant 0x%llx cannot be represented "
"in any built-in integral type\n", (u_longlong_t)value);
"in any built-in integral type\n", (unsigned long long)value);
/*NOTREACHED*/
return NULL; /* keep gcc happy */
}
Expand Down Expand Up @@ -2194,18 +2194,18 @@ dt_node_pdesc_by_id(uintmax_t id)

if (id > UINT_MAX) {
xyerror(D_PDESC_INVAL, "identifier %llu exceeds maximum "
"probe id\n", (u_longlong_t)id);
"probe id\n", (unsigned long long)id);
}

if (yypcb->pcb_pspec != DTRACE_PROBESPEC_NAME) {
xyerror(D_PDESC_INVAL, "probe identifier %llu not permitted "
"when specifying %s\n", (u_longlong_t)id,
"when specifying %s\n", (unsigned long long)id,
names[yypcb->pcb_pspec]);
}

if (dtrace_id2desc(dtp, (dtrace_id_t)id, dnp->dn_desc) != 0) {
xyerror(D_PDESC_INVAL, "invalid probe identifier %llu: %s\n",
(u_longlong_t)id, dtrace_errmsg(dtp, dtrace_errno(dtp)));
(unsigned long long)id, dtrace_errmsg(dtp, dtrace_errno(dtp)));
}

return dnp;
Expand Down Expand Up @@ -4866,7 +4866,7 @@ dt_node_printr(dt_node_t *dnp, FILE *fp, int depth)

case DT_NODE_INT:
fprintf(fp, "INT 0x%llx (%s)\n",
(u_longlong_t)dnp->dn_value, buf);
(unsigned long long)dnp->dn_value, buf);
break;

case DT_NODE_STRING:
Expand Down
14 changes: 7 additions & 7 deletions libdtrace/dt_pid.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -214,7 +214,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
rc = dt_pid_error(
dtp, pcb, dpr, D_PROC_OFF,
"offset 0x%llx outside of function '%s'",
(u_longlong_t)off, func);
(unsigned long long)off, func);
goto out;
}

Expand All @@ -223,7 +223,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
rc = dt_pid_error(
dtp, pcb, dpr, D_PROC_CREATEFAIL,
"failed to create probes at '%s+0x%llx': %s",
func, (u_longlong_t)off,
func, (unsigned long long)off,
dtrace_errmsg(dtp, dtrace_errno(dtp)));
goto out;
}
Expand Down Expand Up @@ -346,10 +346,10 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)
pp->dpp_stret[3] = 0;

dt_dprintf("%s stret %llx %llx %llx %llx\n", obj,
(u_longlong_t)pp->dpp_stret[0],
(u_longlong_t)pp->dpp_stret[1],
(u_longlong_t)pp->dpp_stret[2],
(u_longlong_t)pp->dpp_stret[3]);
(unsigned long long)pp->dpp_stret[0],
(unsigned long long)pp->dpp_stret[1],
(unsigned long long)pp->dpp_stret[2],
(unsigned long long)pp->dpp_stret[3]);

/*
* If pp->dpp_func contains any globbing meta-characters, we need
Expand Down
4 changes: 2 additions & 2 deletions libdtrace/dt_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ pfprint_uaddr(dtrace_hdl_t *dtp, FILE *fp, const char *format,

switch (size) {
case sizeof(uint32_t):
val = (u_longlong_t)*((uint32_t *)addr);
val = (unsigned long long)*((uint32_t *)addr);
break;
case sizeof(uint64_t):
val = (u_longlong_t)*((uint64_t *)addr);
val = (unsigned long long)*((uint64_t *)addr);
break;
case sizeof(uint64_t) * 3:
tgid = ((uint64_t *)(uintptr_t)addr)[1];
Expand Down
18 changes: 9 additions & 9 deletions libdtrace/dt_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ dtrace_addr2str(dtrace_hdl_t *dtp, uint64_t addr, char *str, int nbytes)

if (err == 0 && addr != sym.st_value) {
snprintf(s, n, "%s`%s+0x%llx", dts.object, dts.name,
(u_longlong_t)addr - sym.st_value);
(unsigned long long)addr - sym.st_value);
} else if (err == 0) {
snprintf(s, n, "%s`%s", dts.object, dts.name);
} else {
Expand All @@ -867,9 +867,9 @@ dtrace_addr2str(dtrace_hdl_t *dtp, uint64_t addr, char *str, int nbytes)
*/
if (dtrace_lookup_by_addr(dtp, addr, NULL, &dts) == 0)
snprintf(s, n, "%s`0x%llx", dts.object,
(u_longlong_t)addr);
(unsigned long long)addr);
else
snprintf(s, n, "0x%llx", (u_longlong_t)addr);
snprintf(s, n, "0x%llx", (unsigned long long)addr);
}

return dt_string2str(s, str, nbytes);
Expand All @@ -889,7 +889,7 @@ dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, uint64_t addr, char *str,
DTRACE_PROC_SHORTLIVED);

if (pid < 0) {
snprintf(c, sizeof(c), "0x%llx", (u_longlong_t)addr);
snprintf(c, sizeof(c), "0x%llx", (unsigned long long)addr);
return dt_string2str(c, str, nbytes);
}

Expand All @@ -906,9 +906,9 @@ dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, uint64_t addr, char *str,
offset = addr - pmap->pr_vaddr;

snprintf(c, sizeof(c), "%s:0x%llx",
dt_basename(objname), (u_longlong_t)offset);
dt_basename(objname), (unsigned long long)offset);
} else
snprintf(c, sizeof(c), "0x%llx", (u_longlong_t)addr);
snprintf(c, sizeof(c), "0x%llx", (unsigned long long)addr);

} else if (dt_Plookup_by_addr(dtp, pid, addr, &name, &sym) == 0) {
dt_Pobjname(dtp, pid, addr, objname, sizeof(objname));
Expand All @@ -917,7 +917,7 @@ dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, uint64_t addr, char *str,

if (addr > sym.st_value)
snprintf(c, sizeof(c), "%s`%s+0x%llx", obj, name,
(u_longlong_t)(addr - sym.st_value));
(unsigned long long)(addr - sym.st_value));
else
snprintf(c, sizeof(c), "%s`%s", obj, name);

Expand All @@ -926,9 +926,9 @@ dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, uint64_t addr, char *str,
} else if (dt_Pobjname(dtp, pid, addr,
objname, sizeof(objname)) != NULL) {
snprintf(c, sizeof(c), "%s`0x%llx",
dt_basename(objname), (u_longlong_t)addr);
dt_basename(objname), (unsigned long long)addr);
} else
snprintf(c, sizeof(c), "0x%llx", (u_longlong_t)addr);
snprintf(c, sizeof(c), "0x%llx", (unsigned long long)addr);

dt_proc_release_unlock(dtp, pid);

Expand Down
4 changes: 2 additions & 2 deletions libproc/Build
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Oracle Linux DTrace.
# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.

BUILDLIBS += libproc
libproc_CPPFLAGS = -Ilibproc -Ilibdtrace -I$(objdir) -Iuts/intel -Ilibproc/$(ARCHINC) -D_LONGLONG_TYPE
libproc_CPPFLAGS = -Ilibproc -Ilibdtrace -I$(objdir) -Iuts/intel -Ilibproc/$(ARCHINC)
libproc_TARGET = libproc
libproc_DIR := $(current-dir)
libproc_SOURCES = Pcontrol.c elfish.c elfish_64.c elfish_32.c Psymtab.c rtld_db.c rtld_offsets.c wrap.c isadep_dispatch.c $(ARCHINC)/isadep.c
Expand Down

0 comments on commit 2479ce9

Please sign in to comment.