mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 03:29:47 +08:00
gdb: Use std::min and std::max throughout
Otherwise including <string> or some other C++ header is broken. E.g.: In file included from /opt/gcc/include/c++/7.0.0/bits/char_traits.h:39:0, from /opt/gcc/include/c++/7.0.0/string:40, from /home/pedro/gdb/mygit/cxx-convertion/src/gdb/infrun.c:68: /opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2 min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2 max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ In file included from .../src/gdb/infrun.c:21:0: To the best of my grepping abilities, I believe I adjusted all min/max calls. gdb/ChangeLog: 2016-09-16 Pedro Alves <palves@redhat.com> * defs.h (min, max): Delete. * aarch64-tdep.c: Include <algorithm> and use std::min and std::max throughout. * aarch64-tdep.c: Likewise. * alpha-tdep.c: Likewise. * amd64-tdep.c: Likewise. * amd64-windows-tdep.c: Likewise. * arm-tdep.c: Likewise. * avr-tdep.c: Likewise. * breakpoint.c: Likewise. * btrace.c: Likewise. * ctf.c: Likewise. * disasm.c: Likewise. * doublest.c: Likewise. * dwarf2loc.c: Likewise. * dwarf2read.c: Likewise. * environ.c: Likewise. * exec.c: Likewise. * f-exp.y: Likewise. * findcmd.c: Likewise. * ft32-tdep.c: Likewise. * gcore.c: Likewise. * hppa-tdep.c: Likewise. * i386-darwin-tdep.c: Likewise. * i386-tdep.c: Likewise. * linux-thread-db.c: Likewise. * lm32-tdep.c: Likewise. * m32r-tdep.c: Likewise. * m88k-tdep.c: Likewise. * memrange.c: Likewise. * minidebug.c: Likewise. * mips-tdep.c: Likewise. * moxie-tdep.c: Likewise. * nds32-tdep.c: Likewise. * nios2-tdep.c: Likewise. * nto-procfs.c: Likewise. * parse.c: Likewise. * ppc-sysv-tdep.c: Likewise. * probe.c: Likewise. * record-btrace.c: Likewise. * remote.c: Likewise. * rs6000-tdep.c: Likewise. * rx-tdep.c: Likewise. * s390-linux-nat.c: Likewise. * s390-linux-tdep.c: Likewise. * ser-tcp.c: Likewise. * sh-tdep.c: Likewise. * sh64-tdep.c: Likewise. * source.c: Likewise. * sparc-tdep.c: Likewise. * symfile.c: Likewise. * target-memory.c: Likewise. * target.c: Likewise. * tic6x-tdep.c: Likewise. * tilegx-tdep.c: Likewise. * tracefile-tfile.c: Likewise. * tracepoint.c: Likewise. * valprint.c: Likewise. * value.c: Likewise. * xtensa-tdep.c: Likewise. * cli/cli-cmds.c: Likewise. * compile/compile-object-load.c: Likewise.
This commit is contained in:
26
gdb/value.c
26
gdb/value.c
@ -40,6 +40,7 @@
|
||||
#include "tracepoint.h"
|
||||
#include "cp-abi.h"
|
||||
#include "user-regs.h"
|
||||
#include <algorithm>
|
||||
|
||||
/* Prototypes for exported functions. */
|
||||
|
||||
@ -84,8 +85,8 @@ ranges_overlap (LONGEST offset1, LONGEST len1,
|
||||
{
|
||||
ULONGEST h, l;
|
||||
|
||||
l = max (offset1, offset2);
|
||||
h = min (offset1 + len1, offset2 + len2);
|
||||
l = std::max (offset1, offset2);
|
||||
h = std::min (offset1 + len1, offset2 + len2);
|
||||
return (l < h);
|
||||
}
|
||||
|
||||
@ -528,8 +529,8 @@ insert_into_bit_range_vector (VEC(range_s) **vectorp,
|
||||
if (ranges_overlap (bef->offset, bef->length, offset, length))
|
||||
{
|
||||
/* #1 */
|
||||
ULONGEST l = min (bef->offset, offset);
|
||||
ULONGEST h = max (bef->offset + bef->length, offset + length);
|
||||
ULONGEST l = std::min (bef->offset, offset);
|
||||
ULONGEST h = std::max (bef->offset + bef->length, offset + length);
|
||||
|
||||
bef->offset = l;
|
||||
bef->length = h - l;
|
||||
@ -572,8 +573,8 @@ insert_into_bit_range_vector (VEC(range_s) **vectorp,
|
||||
{
|
||||
ULONGEST l, h;
|
||||
|
||||
l = min (t->offset, r->offset);
|
||||
h = max (t->offset + t->length, r->offset + r->length);
|
||||
l = std::min (t->offset, r->offset);
|
||||
h = std::max (t->offset + t->length, r->offset + r->length);
|
||||
|
||||
t->offset = l;
|
||||
t->length = h - l;
|
||||
@ -780,11 +781,11 @@ find_first_range_overlap_and_match (struct ranges_and_idx *rp1,
|
||||
/* Get the unavailable windows intersected by the incoming
|
||||
ranges. The first and last ranges that overlap the argument
|
||||
range may be wider than said incoming arguments ranges. */
|
||||
l1 = max (offset1, r1->offset);
|
||||
h1 = min (offset1 + length, r1->offset + r1->length);
|
||||
l1 = std::max (offset1, r1->offset);
|
||||
h1 = std::min (offset1 + length, r1->offset + r1->length);
|
||||
|
||||
l2 = max (offset2, r2->offset);
|
||||
h2 = min (offset2 + length, offset2 + r2->length);
|
||||
l2 = std::max (offset2, r2->offset);
|
||||
h2 = std::min (offset2 + length, offset2 + r2->length);
|
||||
|
||||
/* Make them relative to the respective start offsets, so we can
|
||||
compare them for equality. */
|
||||
@ -1297,8 +1298,9 @@ ranges_copy_adjusted (VEC (range_s) **dst_range, int dst_bit_offset,
|
||||
{
|
||||
ULONGEST h, l;
|
||||
|
||||
l = max (r->offset, src_bit_offset);
|
||||
h = min (r->offset + r->length, src_bit_offset + bit_length);
|
||||
l = std::max (r->offset, (LONGEST) src_bit_offset);
|
||||
h = std::min (r->offset + r->length,
|
||||
(LONGEST) src_bit_offset + bit_length);
|
||||
|
||||
if (l < h)
|
||||
insert_into_bit_range_vector (dst_range,
|
||||
|
Reference in New Issue
Block a user