diff options
author | Pedro Alves <palves@redhat.com> | 2016-09-16 19:55:17 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-09-16 19:55:17 +0100 |
commit | 325fac504a327de9c46a4e5cf9c88ece9d9d7701 (patch) | |
tree | 70abe40fe0c2332f96acbc01cd4e2c841593f0bd /gdb/target.c | |
parent | 8193adea2f86e37423a5d0acffb69b80bde05d52 (diff) | |
download | gdb-325fac504a327de9c46a4e5cf9c88ece9d9d7701.zip gdb-325fac504a327de9c46a4e5cf9c88ece9d9d7701.tar.gz gdb-325fac504a327de9c46a4e5cf9c88ece9d9d7701.tar.bz2 |
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.
Diffstat (limited to 'gdb/target.c')
-rw-r--r-- | gdb/target.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gdb/target.c b/gdb/target.c index bca25bd..628bceb 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -45,6 +45,7 @@ #include "target-debug.h" #include "top.h" #include "event-top.h" +#include <algorithm> static void target_info (char *, int); @@ -1292,7 +1293,7 @@ memory_xfer_partial (struct target_ops *ops, enum target_object object, shadow handling even though we only end up writing a small subset of it. Cap writes to a limit specified by the target to mitigate this. */ - len = min (ops->to_get_memory_xfer_limit (ops), len); + len = std::min (ops->to_get_memory_xfer_limit (ops), len); buf = (gdb_byte *) xmalloc (len); old_chain = make_cleanup (xfree, buf); @@ -1858,7 +1859,7 @@ read_memory_robust (struct target_ops *ops, } else { - LONGEST to_read = min (len - xfered_total, region_len); + LONGEST to_read = std::min (len - xfered_total, region_len); gdb_byte *buffer = (gdb_byte *) xmalloc (to_read * unit_size); struct cleanup *inner_cleanup = make_cleanup (xfree, buffer); @@ -2445,7 +2446,8 @@ simple_search_memory (struct target_ops *ops, while (search_space_len >= pattern_len) { gdb_byte *found_ptr; - unsigned nr_search_bytes = min (search_space_len, search_buf_size); + unsigned nr_search_bytes + = std::min (search_space_len, (ULONGEST) search_buf_size); found_ptr = (gdb_byte *) memmem (search_buf, nr_search_bytes, pattern, pattern_len); @@ -2478,7 +2480,8 @@ simple_search_memory (struct target_ops *ops, gdb_assert (keep_len == pattern_len - 1); memcpy (search_buf, search_buf + chunk_size, keep_len); - nr_to_read = min (search_space_len - keep_len, chunk_size); + nr_to_read = std::min (search_space_len - keep_len, + (ULONGEST) chunk_size); if (target_read (ops, TARGET_OBJECT_MEMORY, NULL, search_buf + keep_len, read_addr, @@ -2850,7 +2853,7 @@ static void release_fileio_fd (int fd, fileio_fh_t *fh) { fh->fd = -1; - lowest_closed_fd = min (lowest_closed_fd, fd); + lowest_closed_fd = std::min (lowest_closed_fd, fd); } /* Return a pointer to the fileio_fhandle_t corresponding to FD. */ @@ -3582,7 +3585,7 @@ simple_verify_memory (struct target_ops *ops, ULONGEST xfered_len; enum target_xfer_status status; gdb_byte buf[1024]; - ULONGEST howmuch = min (sizeof (buf), size - total_xfered); + ULONGEST howmuch = std::min (sizeof (buf), size - total_xfered); status = target_xfer_partial (ops, TARGET_OBJECT_MEMORY, NULL, buf, NULL, lma + total_xfered, howmuch, |