FreeBSD Bugzilla – Attachment 182374 Details for
Bug 219126
devel/gdb: Add upstream commits to get rid of min/max macros, improving C++ compatibility
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix min/max macro usage in devel/gdb
devel__gdb-fix-min-max-1.diff (text/plain), 75.90 KB, created by
Dimitry Andric
on 2017-05-07 19:43:52 UTC
(
hide
)
Description:
Fix min/max macro usage in devel/gdb
Filename:
MIME Type:
Creator:
Dimitry Andric
Created:
2017-05-07 19:43:52 UTC
Size:
75.90 KB
patch
obsolete
>Index: devel/gdb/Makefile >=================================================================== >--- devel/gdb/Makefile (revision 440206) >+++ devel/gdb/Makefile (working copy) >@@ -30,7 +30,9 @@ CFLAGS:= ${CFLAGS:C/ +$//} # blanks at EOL creep i > CFLAGS+= -DRL_NO_COMPAT -Wno-unused-function -Wno-unused-variable > EXCLUDE= dejagnu expect sim texinfo intl > EXTRACT_AFTER_ARGS= ${EXCLUDE:S/^/--exclude /} >-EXTRA_PATCHES= ${FILESDIR}/commit-387360daf9 \ >+EXTRA_PATCHES= ${FILESDIR}/commit-325fac504a \ >+ ${FILESDIR}/commit-768adc05c4 \ >+ ${FILESDIR}/commit-387360daf9 \ > ${FILESDIR}/commit-b268007c68 > LIB_DEPENDS+= libexpat.so:textproc/expat2 > >Index: devel/gdb/files/commit-325fac504a >=================================================================== >--- devel/gdb/files/commit-325fac504a (nonexistent) >+++ devel/gdb/files/commit-325fac504a (working copy) >@@ -0,0 +1,2058 @@ >+commit 325fac504a327de9c46a4e5cf9c88ece9d9d7701 >+Author: Pedro Alves <palves@redhat.com> >+Date: Fri Sep 16 19:55:17 2016 +0100 >+ >+ 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. >+ >+diff --git gdb/ChangeLog gdb/ChangeLog >+index 71c1f91..abd2e89 100644 >+--- gdb/ChangeLog >++++ gdb/ChangeLog >+@@ -264,6 +264,71 @@ >+ * rs6000-tdep.c (ppc_process_record_op31): Fix record of Store String >+ Word instructions. >+ >++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. >++ >+ 2016-09-06 Pedro Alves <palves@redhat.com> >+ >+ * top.c (wait_sync_command_done): Don't assume current_ui doesn't >+diff --git gdb/aarch64-tdep.c gdb/aarch64-tdep.c >+index e712832..7b3be02 100644 >+--- gdb/aarch64-tdep.c >++++ gdb/aarch64-tdep.c >+@@ -60,6 +60,7 @@ >+ #include "arch/aarch64-insn.h" >+ >+ #include "opcode/aarch64.h" >++#include <algorithm> >+ >+ #define submask(x) ((1L << ((x) + 1)) - 1) >+ #define bit(obj,st) (((obj) >> (st)) & 1) >+@@ -451,7 +452,7 @@ aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ } >+ >+ /* Can't determine prologue from the symbol table, need to examine >+@@ -504,7 +505,7 @@ aarch64_scan_prologue (struct frame_info *this_frame, >+ prologue_end = sal.end; >+ } >+ >+- prologue_end = min (prologue_end, prev_pc); >++ prologue_end = std::min (prologue_end, prev_pc); >+ aarch64_analyze_prologue (gdbarch, prologue_start, prologue_end, cache); >+ } >+ else >+diff --git gdb/alpha-tdep.c gdb/alpha-tdep.c >+index 45260b2..0090e94 100644 >+--- gdb/alpha-tdep.c >++++ gdb/alpha-tdep.c >+@@ -43,6 +43,7 @@ >+ #include "elf-bfd.h" >+ >+ #include "alpha-tdep.h" >++#include <algorithm> >+ >+ /* Instruction decoding. The notations for registers, immediates and >+ opcodes are the same as the one used in Compaq's Alpha architecture >+@@ -721,7 +722,7 @@ alpha_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ >+ post_prologue_pc = alpha_after_prologue (pc); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ >+ /* Can't determine prologue from the symbol table, need to examine >+ instructions. */ >+diff --git gdb/amd64-tdep.c gdb/amd64-tdep.c >+index 3bc91ae..a636742 100644 >+--- gdb/amd64-tdep.c >++++ gdb/amd64-tdep.c >+@@ -40,6 +40,7 @@ >+ #include "amd64-tdep.h" >+ #include "i387-tdep.h" >+ #include "x86-xstate.h" >++#include <algorithm> >+ >+ #include "features/i386/amd64.c" >+ #include "features/i386/amd64-avx.c" >+@@ -846,10 +847,10 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function, >+ gdb_assert (regnum != -1); >+ >+ if (readbuf) >+- regcache_raw_read_part (regcache, regnum, offset, min (len, 8), >++ regcache_raw_read_part (regcache, regnum, offset, std::min (len, 8), >+ readbuf + i * 8); >+ if (writebuf) >+- regcache_raw_write_part (regcache, regnum, offset, min (len, 8), >++ regcache_raw_write_part (regcache, regnum, offset, std::min (len, 8), >+ writebuf + i * 8); >+ } >+ >+@@ -957,7 +958,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs, >+ >+ gdb_assert (regnum != -1); >+ memset (buf, 0, sizeof buf); >+- memcpy (buf, valbuf + j * 8, min (len, 8)); >++ memcpy (buf, valbuf + j * 8, std::min (len, 8)); >+ regcache_raw_write_part (regcache, regnum, offset, 8, buf); >+ } >+ } >+@@ -2067,7 +2068,7 @@ amd64_analyze_stack_align (CORE_ADDR pc, CORE_ADDR current_pc, >+ if (current_pc > pc + offset_and) >+ cache->saved_sp_reg = amd64_arch_reg_to_regnum (reg); >+ >+- return min (pc + offset + 2, current_pc); >++ return std::min (pc + offset + 2, current_pc); >+ } >+ >+ /* Similar to amd64_analyze_stack_align for x32. */ >+@@ -2249,7 +2250,7 @@ amd64_x32_analyze_stack_align (CORE_ADDR pc, CORE_ADDR current_pc, >+ if (current_pc > pc + offset_and) >+ cache->saved_sp_reg = amd64_arch_reg_to_regnum (reg); >+ >+- return min (pc + offset + 2, current_pc); >++ return std::min (pc + offset + 2, current_pc); >+ } >+ >+ /* Do a limited analysis of the prologue at PC and update CACHE >+@@ -2438,7 +2439,7 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) >+ && (cust != NULL >+ && COMPUNIT_PRODUCER (cust) != NULL >+ && startswith (COMPUNIT_PRODUCER (cust), "clang "))) >+- return max (start_pc, post_prologue_pc); >++ return std::max (start_pc, post_prologue_pc); >+ } >+ >+ amd64_init_frame_cache (&cache); >+diff --git gdb/amd64-windows-tdep.c gdb/amd64-windows-tdep.c >+index 1a03336..73844a1 100644 >+--- gdb/amd64-windows-tdep.c >++++ gdb/amd64-windows-tdep.c >+@@ -30,6 +30,7 @@ >+ #include "coff/pe.h" >+ #include "libcoff.h" >+ #include "value.h" >++#include <algorithm> >+ >+ /* The registers used to pass integer arguments during a function call. */ >+ static int amd64_windows_dummy_call_integer_regs[] = >+@@ -141,7 +142,7 @@ amd64_windows_store_arg_in_reg (struct regcache *regcache, >+ >+ gdb_assert (TYPE_LENGTH (type) <= 8); >+ memset (buf, 0, sizeof buf); >+- memcpy (buf, valbuf, min (TYPE_LENGTH (type), 8)); >++ memcpy (buf, valbuf, std::min (TYPE_LENGTH (type), (unsigned int) 8)); >+ regcache_cooked_write (regcache, regno, buf); >+ } >+ >+@@ -1143,7 +1144,7 @@ amd64_windows_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ else if (target_read_memory (image_base + unwind_info, >+ (gdb_byte *) &ex_ui, sizeof (ex_ui)) == 0 >+ && PEX64_UWI_VERSION (ex_ui.Version_Flags) == 1) >+- return max (pc, image_base + start_rva + ex_ui.SizeOfPrologue); >++ return std::max (pc, image_base + start_rva + ex_ui.SizeOfPrologue); >+ } >+ >+ /* See if we can determine the end of the prologue via the symbol >+@@ -1155,7 +1156,7 @@ amd64_windows_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ } >+ >+ return pc; >+diff --git gdb/arm-tdep.c gdb/arm-tdep.c >+index b7b04c6..0d60b03 100644 >+--- gdb/arm-tdep.c >++++ gdb/arm-tdep.c >+@@ -58,6 +58,7 @@ >+ >+ #include "record.h" >+ #include "record-full.h" >++#include <algorithm> >+ >+ #include "features/arm-with-m.c" >+ #include "features/arm-with-m-fpa-layout.c" >+@@ -1449,7 +1450,7 @@ thumb_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR prev_pc, >+ function is. */ >+ return; >+ >+- prologue_end = min (prologue_end, prev_pc); >++ prologue_end = std::min (prologue_end, prev_pc); >+ >+ thumb_analyze_prologue (gdbarch, prologue_start, prologue_end, cache); >+ } >+@@ -4337,7 +4338,7 @@ arm_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr) >+ footwork to distinguish a real IT instruction from the second >+ half of a 32-bit instruction, but there is no need for that if >+ there's no candidate. */ >+- buf_len = min (bpaddr - boundary, MAX_IT_BLOCK_PREFIX); >++ buf_len = std::min (bpaddr - boundary, (CORE_ADDR) MAX_IT_BLOCK_PREFIX); >+ if (buf_len == 0) >+ /* No room for an IT instruction. */ >+ return bpaddr; >+diff --git gdb/avr-tdep.c gdb/avr-tdep.c >+index f8af9ac..1454fdb 100644 >+--- gdb/avr-tdep.c >++++ gdb/avr-tdep.c >+@@ -36,6 +36,7 @@ >+ #include "regcache.h" >+ #include "dis-asm.h" >+ #include "objfiles.h" >++#include <algorithm> >+ >+ /* AVR Background: >+ >+@@ -882,7 +883,7 @@ avr_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ >+ post_prologue_pc = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ >+ { >+ CORE_ADDR prologue_end = pc; >+diff --git gdb/breakpoint.c gdb/breakpoint.c >+index ec9ee6f..904b478 100644 >+--- gdb/breakpoint.c >++++ gdb/breakpoint.c >+@@ -80,6 +80,7 @@ >+ >+ #include "mi/mi-common.h" >+ #include "extension.h" >++#include <algorithm> >+ >+ /* Enums for exception-handling support. */ >+ enum exception_event_kind >+@@ -4435,8 +4436,8 @@ hardware_watchpoint_inserted_in_range (struct address_space *aspace, >+ CORE_ADDR l, h; >+ >+ /* Check for intersection. */ >+- l = max (loc->address, addr); >+- h = min (loc->address + loc->length, addr + len); >++ l = std::max (loc->address, addr); >++ h = std::min (loc->address + loc->length, addr + len); >+ if (l < h) >+ return 1; >+ } >+@@ -5996,7 +5997,7 @@ bpstat_what (bpstat bs_head) >+ _("bpstat_what: unhandled bptype %d"), (int) bptype); >+ } >+ >+- retval.main_action = max (retval.main_action, this_action); >++ retval.main_action = std::max (retval.main_action, this_action); >+ } >+ >+ return retval; >+diff --git gdb/btrace.c gdb/btrace.c >+index 2bbf54a..73700e6 100644 >+--- gdb/btrace.c >++++ gdb/btrace.c >+@@ -37,6 +37,7 @@ >+ >+ #include <inttypes.h> >+ #include <ctype.h> >++#include <algorithm> >+ >+ /* Command lists for btrace maintenance commands. */ >+ static struct cmd_list_element *maint_btrace_cmdlist; >+@@ -395,7 +396,7 @@ ftrace_new_return (struct btrace_function *prev, >+ We start at the preceding function's level in case this has >+ already been a return for which we have not seen the call. >+ We start at level 0 otherwise, to handle tail calls correctly. */ >+- bfun->level = min (0, prev->level) - 1; >++ bfun->level = std::min (0, prev->level) - 1; >+ >+ /* Fix up the call stack for PREV. */ >+ ftrace_fixup_caller (prev, bfun, BFUN_UP_LINKS_TO_RET); >+@@ -645,7 +646,7 @@ btrace_compute_ftrace_bts (struct thread_info *tp, >+ /* Maintain the function level offset. >+ For all but the last block, we do it here. */ >+ if (blk != 0) >+- level = min (level, end->level); >++ level = std::min (level, end->level); >+ >+ size = 0; >+ TRY >+@@ -691,7 +692,7 @@ btrace_compute_ftrace_bts (struct thread_info *tp, >+ and is not really part of the execution history, it shouldn't >+ affect the level. */ >+ if (blk == 0) >+- level = min (level, end->level); >++ level = std::min (level, end->level); >+ } >+ } >+ >+@@ -801,7 +802,7 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, >+ } >+ >+ /* Maintain the function level offset. */ >+- *plevel = min (*plevel, end->level); >++ *plevel = std::min (*plevel, end->level); >+ >+ btinsn.pc = (CORE_ADDR) insn.ip; >+ btinsn.size = (gdb_byte) insn.size; >+@@ -1827,7 +1828,7 @@ btrace_insn_next (struct btrace_insn_iterator *it, unsigned int stride) >+ space = end - index; >+ >+ /* Advance the iterator as far as possible within this segment. */ >+- adv = min (space, stride); >++ adv = std::min (space, stride); >+ stride -= adv; >+ index += adv; >+ steps += adv; >+@@ -1906,7 +1907,7 @@ btrace_insn_prev (struct btrace_insn_iterator *it, unsigned int stride) >+ } >+ >+ /* Advance the iterator as far as possible within this segment. */ >+- adv = min (index, stride); >++ adv = std::min (index, stride); >+ >+ stride -= adv; >+ index -= adv; >+diff --git gdb/cli/cli-cmds.c gdb/cli/cli-cmds.c >+index 9f15d3e..d8248e1 100644 >+--- gdb/cli/cli-cmds.c >++++ gdb/cli/cli-cmds.c >+@@ -56,6 +56,7 @@ >+ #endif >+ >+ #include <fcntl.h> >++#include <algorithm> >+ >+ /* Prototypes for local command functions */ >+ >+@@ -918,7 +919,7 @@ list_command (char *arg, int from_tty) >+ { >+ int first; >+ >+- first = max (cursal.line - get_lines_to_list () / 2, 1); >++ first = std::max (cursal.line - get_lines_to_list () / 2, 1); >+ >+ /* A small special case --- if listing backwards, and we >+ should list only one line, list the preceding line, >+@@ -945,8 +946,8 @@ list_command (char *arg, int from_tty) >+ error (_("Already at the start of %s."), >+ symtab_to_filename_for_display (cursal.symtab)); >+ print_source_lines (cursal.symtab, >+- max (get_first_line_listed () >+- - get_lines_to_list (), 1), >++ std::max (get_first_line_listed () >++ - get_lines_to_list (), 1), >+ get_first_line_listed (), 0); >+ } >+ >+@@ -1090,7 +1091,7 @@ list_command (char *arg, int from_tty) >+ error (_("No default source file yet. Do \"help list\".")); >+ if (dummy_beg) >+ print_source_lines (sal_end.symtab, >+- max (sal_end.line - (get_lines_to_list () - 1), 1), >++ std::max (sal_end.line - (get_lines_to_list () - 1), 1), >+ sal_end.line + 1, 0); >+ else if (sal.symtab == 0) >+ error (_("No default source file yet. Do \"help list\".")); >+diff --git gdb/compile/compile-object-load.c gdb/compile/compile-object-load.c >+index 1b42bc5..ea67eda 100644 >+--- gdb/compile/compile-object-load.c >++++ gdb/compile/compile-object-load.c >+@@ -31,6 +31,7 @@ >+ #include "compile.h" >+ #include "block.h" >+ #include "arch-utils.h" >++#include <algorithm> >+ >+ /* Track inferior memory reserved by inferior mmap. */ >+ >+@@ -186,7 +187,7 @@ setup_sections (bfd *abfd, asection *sect, void *data_voidp) >+ return; >+ >+ alignment = ((CORE_ADDR) 1) << bfd_get_section_alignment (abfd, sect); >+- data->last_max_alignment = max (data->last_max_alignment, alignment); >++ data->last_max_alignment = std::max (data->last_max_alignment, alignment); >+ >+ data->last_size = (data->last_size + alignment - 1) & -alignment; >+ >+diff --git gdb/ctf.c gdb/ctf.c >+index 019af0f..b3d7e83 100644 >+--- gdb/ctf.c >++++ gdb/ctf.c >+@@ -29,8 +29,8 @@ >+ #include "inferior.h" >+ #include "gdbthread.h" >+ #include "tracefile.h" >+- >+ #include <ctype.h> >++#include <algorithm> >+ >+ /* GDB saves trace buffers and other information (such as trace >+ status) got from the remote target into Common Trace Format (CTF). >+@@ -1397,7 +1397,7 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object, >+ and this address falls within a read-only section, fallback >+ to reading from executable, up to LOW_ADDR_AVAILABLE */ >+ if (offset < low_addr_available) >+- len = min (len, low_addr_available - offset); >++ len = std::min (len, low_addr_available - offset); >+ res = exec_read_partial_read_only (readbuf, offset, len, xfered_len); >+ >+ if (res == TARGET_XFER_OK) >+diff --git gdb/defs.h gdb/defs.h >+index 66082c0..2d292a9 100644 >+--- gdb/defs.h >++++ gdb/defs.h >+@@ -103,13 +103,6 @@ enum compile_i_scope_types >+ >+ #include "hashtab.h" >+ >+-#ifndef min >+-#define min(a, b) ((a) < (b) ? (a) : (b)) >+-#endif >+-#ifndef max >+-#define max(a, b) ((a) > (b) ? (a) : (b)) >+-#endif >+- >+ /* * Enable dbx commands if set. */ >+ extern int dbx_commands; >+ >+diff --git gdb/disasm.c gdb/disasm.c >+index f041be3..e4e6f7e 100644 >+--- gdb/disasm.c >++++ gdb/disasm.c >+@@ -25,6 +25,7 @@ >+ #include "gdbcore.h" >+ #include "dis-asm.h" >+ #include "source.h" >++#include <algorithm> >+ >+ /* Disassemble functions. >+ FIXME: We should get rid of all the duplicate code in gdb that does >+@@ -765,7 +766,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout, >+ } >+ >+ if (sal.end != 0) >+- end_pc = min (sal.end, high); >++ end_pc = std::min (sal.end, high); >+ else >+ end_pc = pc + 1; >+ num_displayed += dump_insns (gdbarch, uiout, di, pc, end_pc, >+diff --git gdb/doublest.c gdb/doublest.c >+index f06fa5e..8f4799e 100644 >+--- gdb/doublest.c >++++ gdb/doublest.c >+@@ -28,6 +28,7 @@ >+ #include "floatformat.h" >+ #include "gdbtypes.h" >+ #include <math.h> /* ldexp */ >++#include <algorithm> >+ >+ /* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not >+ going to bother with trying to muck around with whether it is defined in >+@@ -255,7 +256,7 @@ convert_floatformat_to_doublest (const struct floatformat *fmt, >+ >+ while (mant_bits_left > 0) >+ { >+- mant_bits = min (mant_bits_left, 32); >++ mant_bits = std::min (mant_bits_left, 32); >+ >+ mant = get_field (ufrom, order, fmt->totalsize, mant_off, mant_bits); >+ >+@@ -565,7 +566,7 @@ floatformat_classify (const struct floatformat *fmt, >+ mant_zero = 1; >+ while (mant_bits_left > 0) >+ { >+- mant_bits = min (mant_bits_left, 32); >++ mant_bits = std::min (mant_bits_left, 32); >+ >+ mant = get_field (uval, order, fmt->totalsize, mant_off, mant_bits); >+ >+@@ -909,7 +910,8 @@ convert_typed_floating (const void *from, const struct type *from_type, >+ comment in store_typed_floating for a discussion about >+ zeroing out remaining bytes in the target buffer. */ >+ memset (to, 0, TYPE_LENGTH (to_type)); >+- memcpy (to, from, min (TYPE_LENGTH (from_type), TYPE_LENGTH (to_type))); >++ memcpy (to, from, std::min (TYPE_LENGTH (from_type), >++ TYPE_LENGTH (to_type))); >+ } >+ else >+ { >+diff --git gdb/dwarf2loc.c gdb/dwarf2loc.c >+index d9e8eb4..41c33bd 100644 >+--- gdb/dwarf2loc.c >++++ gdb/dwarf2loc.c >+@@ -38,6 +38,7 @@ >+ #include "dwarf2loc.h" >+ #include "dwarf2-frame.h" >+ #include "compile/compile.h" >++#include <algorithm> >+ >+ extern int dwarf_always_disassemble; >+ >+@@ -862,7 +863,7 @@ chain_candidate (struct gdbarch *gdbarch, struct call_site_chain **resultp, >+ >+ /* Intersect callers. */ >+ >+- callers = min (result->callers, length); >++ callers = std::min ((long) result->callers, length); >+ for (idx = 0; idx < callers; idx++) >+ if (result->call_site[idx] != VEC_index (call_sitep, chain, idx)) >+ { >+@@ -872,7 +873,7 @@ chain_candidate (struct gdbarch *gdbarch, struct call_site_chain **resultp, >+ >+ /* Intersect callees. */ >+ >+- callees = min (result->callees, length); >++ callees = std::min ((long) result->callees, length); >+ for (idx = 0; idx < callees; idx++) >+ if (result->call_site[result->length - 1 - idx] >+ != VEC_index (call_sitep, chain, length - 1 - idx)) >+diff --git gdb/dwarf2read.c gdb/dwarf2read.c >+index ff6a3ee..2ffc00a 100644 >+--- gdb/dwarf2read.c >++++ gdb/dwarf2read.c >+@@ -73,6 +73,7 @@ >+ >+ #include <fcntl.h> >+ #include <sys/types.h> >++#include <algorithm> >+ >+ typedef struct symbol *symbolp; >+ DEF_VEC_P (symbolp); >+@@ -12156,8 +12157,8 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die, >+ >+ if (dwarf2_get_pc_bounds (die, &low, &high, cu, NULL) >= PC_BOUNDS_RANGES) >+ { >+- *lowpc = min (*lowpc, low); >+- *highpc = max (*highpc, high); >++ *lowpc = std::min (*lowpc, low); >++ *highpc = std::max (*highpc, high); >+ } >+ >+ /* If the language does not allow nested subprograms (either inside >+@@ -12221,8 +12222,8 @@ get_scope_pc_bounds (struct die_info *die, >+ >+ if (current_low != ((CORE_ADDR) -1)) >+ { >+- best_low = min (best_low, current_low); >+- best_high = max (best_high, current_high); >++ best_low = std::min (best_low, current_low); >++ best_high = std::max (best_high, current_high); >+ } >+ break; >+ default: >+diff --git gdb/environ.c gdb/environ.c >+index ac3e865..bfeabec 100644 >+--- gdb/environ.c >++++ gdb/environ.c >+@@ -15,11 +15,9 @@ >+ You should have received a copy of the GNU General Public License >+ along with this program. If not, see <http://www.gnu.org/licenses/>. */ >+ >+-#define min(a, b) ((a) < (b) ? (a) : (b)) >+-#define max(a, b) ((a) > (b) ? (a) : (b)) >+- >+ #include "defs.h" >+ #include "environ.h" >++#include <algorithm> >+ >+ >+ /* Return a new environment object. */ >+@@ -68,7 +66,7 @@ init_environ (struct gdb_environ *e) >+ >+ if (e->allocated < i) >+ { >+- e->allocated = max (i, e->allocated + 10); >++ e->allocated = std::max (i, e->allocated + 10); >+ e->vector = (char **) xrealloc ((char *) e->vector, >+ (e->allocated + 1) * sizeof (char *)); >+ } >+diff --git gdb/exec.c gdb/exec.c >+index 3cc20c7..a70e4bb 100644 >+--- gdb/exec.c >++++ gdb/exec.c >+@@ -43,6 +43,7 @@ >+ #include <ctype.h> >+ #include <sys/stat.h> >+ #include "solist.h" >++#include <algorithm> >+ >+ void (*deprecated_file_changed_hook) (char *); >+ >+@@ -761,8 +762,8 @@ section_table_available_memory (VEC(mem_range_s) *memory, >+ >+ r = VEC_safe_push (mem_range_s, memory, NULL); >+ >+- r->start = max (lo1, lo2); >+- r->length = min (hi1, hi2) - r->start; >++ r->start = std::max (lo1, lo2); >++ r->length = std::min (hi1, hi2) - r->start; >+ } >+ } >+ >+@@ -800,7 +801,7 @@ section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset, >+ enum target_xfer_status status; >+ >+ /* Get the intersection window. */ >+- end = min (offset + len, r->start + r->length); >++ end = std::min (offset + len, r->start + r->length); >+ >+ gdb_assert (end - offset <= len); >+ >+diff --git gdb/f-exp.y gdb/f-exp.y >+index 023a8ff..a791d2c 100644 >+--- gdb/f-exp.y >++++ gdb/f-exp.y >+@@ -53,6 +53,7 @@ >+ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ >+ #include "block.h" >+ #include <ctype.h> >++#include <algorithm> >+ >+ #define parse_type(ps) builtin_type (parse_gdbarch (ps)) >+ #define parse_f_type(ps) builtin_f_type (parse_gdbarch (ps)) >+@@ -866,7 +867,7 @@ growbuf_by_size (int count) >+ { >+ int growby; >+ >+- growby = max (count, GROWBY_MIN_SIZE); >++ growby = std::max (count, GROWBY_MIN_SIZE); >+ tempbufsize += growby; >+ if (tempbuf == NULL) >+ tempbuf = (char *) malloc (tempbufsize); >+diff --git gdb/findcmd.c gdb/findcmd.c >+index a916fec..9944aed 100644 >+--- gdb/findcmd.c >++++ gdb/findcmd.c >+@@ -24,6 +24,7 @@ >+ #include "value.h" >+ #include "target.h" >+ #include "cli/cli-utils.h" >++#include <algorithm> >+ >+ /* Copied from bfd_put_bits. */ >+ >+@@ -178,7 +179,8 @@ parse_find_args (char *args, ULONGEST *max_countp, >+ /* Keep it simple and assume size == 'g' when watching for when we >+ need to grow the pattern buf. */ >+ pattern_buf_size_need = (pattern_buf_end - pattern_buf >+- + max (TYPE_LENGTH (t), sizeof (int64_t))); >++ + std::max (TYPE_LENGTH (t), >++ (unsigned) sizeof (int64_t))); >+ if (pattern_buf_size_need > pattern_buf_size) >+ { >+ size_t current_offset = pattern_buf_end - pattern_buf; >+diff --git gdb/ft32-tdep.c gdb/ft32-tdep.c >+index 2ad104b..b2fb654 100644 >+--- gdb/ft32-tdep.c >++++ gdb/ft32-tdep.c >+@@ -41,6 +41,7 @@ >+ >+ #include "ft32-tdep.h" >+ #include "gdb/sim-ft32.h" >++#include <algorithm> >+ >+ #define RAM_BIAS 0x800000 /* Bias added to RAM addresses. */ >+ >+@@ -274,7 +275,7 @@ ft32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ CORE_ADDR post_prologue_pc >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ else >+ { >+ /* Can't determine prologue from the symbol table, need to examine >+diff --git gdb/gcore.c gdb/gcore.c >+index 49e4210..2c203cc 100644 >+--- gdb/gcore.c >++++ gdb/gcore.c >+@@ -34,6 +34,7 @@ >+ #include "regset.h" >+ #include "gdb_bfd.h" >+ #include "readline/tilde.h" >++#include <algorithm> >+ >+ /* The largest amount of memory to read from the target at once. We >+ must throttle it to limit the amount of memory used by GDB during >+@@ -572,7 +573,7 @@ gcore_copy_callback (bfd *obfd, asection *osec, void *ignored) >+ if (!startswith (bfd_section_name (obfd, osec), "load")) >+ return; >+ >+- size = min (total_size, MAX_COPY_BYTES); >++ size = std::min (total_size, (bfd_size_type) MAX_COPY_BYTES); >+ memhunk = (gdb_byte *) xmalloc (size); >+ old_chain = make_cleanup (xfree, memhunk); >+ >+diff --git gdb/hppa-tdep.c gdb/hppa-tdep.c >+index a5c5002..22ed364 100644 >+--- gdb/hppa-tdep.c >++++ gdb/hppa-tdep.c >+@@ -39,6 +39,7 @@ >+ #include "gdbtypes.h" >+ #include "objfiles.h" >+ #include "hppa-tdep.h" >++#include <algorithm> >+ >+ static int hppa_debug = 0; >+ >+@@ -1094,10 +1095,10 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, >+ while (regnum > HPPA_ARG0_REGNUM - 8 && len > 0) >+ { >+ regcache_cooked_write_part (regcache, regnum, >+- offset % 8, min (len, 8), valbuf); >+- offset += min (len, 8); >+- valbuf += min (len, 8); >+- len -= min (len, 8); >++ offset % 8, std::min (len, 8), valbuf); >++ offset += std::min (len, 8); >++ valbuf += std::min (len, 8); >++ len -= std::min (len, 8); >+ regnum--; >+ } >+ >+@@ -1109,7 +1110,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, >+ >+ /* Allocate the outgoing parameter area. Make sure the outgoing >+ parameter area is multiple of 16 bytes in length. */ >+- sp += max (align_up (offset, 16), 64); >++ sp += std::max (align_up (offset, 16), (ULONGEST) 64); >+ >+ /* Allocate 32-bytes of scratch space. The documentation doesn't >+ mention this, but it seems to be needed. */ >+@@ -1251,9 +1252,9 @@ hppa64_return_value (struct gdbarch *gdbarch, struct value *function, >+ while (len > 0) >+ { >+ regcache_cooked_read_part (regcache, regnum, offset, >+- min (len, 8), readbuf); >+- readbuf += min (len, 8); >+- len -= min (len, 8); >++ std::min (len, 8), readbuf); >++ readbuf += std::min (len, 8); >++ len -= std::min (len, 8); >+ regnum++; >+ } >+ } >+@@ -1263,9 +1264,9 @@ hppa64_return_value (struct gdbarch *gdbarch, struct value *function, >+ while (len > 0) >+ { >+ regcache_cooked_write_part (regcache, regnum, offset, >+- min (len, 8), writebuf); >+- writebuf += min (len, 8); >+- len -= min (len, 8); >++ std::min (len, 8), writebuf); >++ writebuf += std::min (len, 8); >++ len -= std::min (len, 8); >+ regnum++; >+ } >+ } >+@@ -1849,7 +1850,7 @@ hppa_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ may be the first instruction of the prologue. If that happens, then >+ the instruction skipping code has a bug that needs to be fixed. */ >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ else >+ return (skip_prologue_hard_way (gdbarch, pc, 1)); >+ } >+diff --git gdb/i386-darwin-tdep.c gdb/i386-darwin-tdep.c >+index 4471ea3..0c558cc 100644 >+--- gdb/i386-darwin-tdep.c >++++ gdb/i386-darwin-tdep.c >+@@ -36,6 +36,7 @@ >+ #include "solib.h" >+ #include "solib-darwin.h" >+ #include "dwarf2-frame.h" >++#include <algorithm> >+ >+ /* Offsets into the struct i386_thread_state where we'll find the saved regs. >+ From <mach/i386/thread_status.h> and i386-tdep.h. */ >+@@ -137,8 +138,12 @@ i386_darwin_arg_type_alignment (struct type *type) >+ int i; >+ int res = 4; >+ for (i = 0; i < TYPE_NFIELDS (type); i++) >+- res = max (res, >+- i386_darwin_arg_type_alignment (TYPE_FIELD_TYPE (type, i))); >++ { >++ int align >++ = i386_darwin_arg_type_alignment (TYPE_FIELD_TYPE (type, i)); >++ >++ res = std::max (res, align); >++ } >+ return res; >+ } >+ /* 2. The caller aligns nonvector arguments to 4-byte boundaries. */ >+diff --git gdb/i386-tdep.c gdb/i386-tdep.c >+index d8660ec..82680a9 100644 >+--- gdb/i386-tdep.c >++++ gdb/i386-tdep.c >+@@ -66,6 +66,7 @@ >+ #include "expression.h" >+ #include "parser-defs.h" >+ #include <ctype.h> >++#include <algorithm> >+ >+ /* Register names. */ >+ >+@@ -1365,7 +1366,7 @@ i386_analyze_stack_align (CORE_ADDR pc, CORE_ADDR current_pc, >+ if (current_pc > pc + offset_and) >+ cache->saved_sp_reg = regnums[reg]; >+ >+- return min (pc + offset + 3, current_pc); >++ return std::min (pc + offset + 3, current_pc); >+ } >+ >+ /* Maximum instruction length we need to handle. */ >+@@ -1836,7 +1837,7 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) >+ && (cust != NULL >+ && COMPUNIT_PRODUCER (cust) != NULL >+ && startswith (COMPUNIT_PRODUCER (cust), "clang "))) >+- return max (start_pc, post_prologue_pc); >++ return std::max (start_pc, post_prologue_pc); >+ } >+ >+ cache.locals = -1; >+diff --git gdb/linux-thread-db.c gdb/linux-thread-db.c >+index b6b5a1e..1cab017 100644 >+--- gdb/linux-thread-db.c >++++ gdb/linux-thread-db.c >+@@ -45,6 +45,7 @@ >+ #include <signal.h> >+ #include <ctype.h> >+ #include "nat/linux-namespaces.h" >++#include <algorithm> >+ >+ /* GNU/Linux libthread_db support. >+ >+@@ -1599,13 +1600,13 @@ info_auto_load_libthread_db (char *args, int from_tty) >+ if (i == 0 || strcmp (array[i - 1]->filename, array[i]->filename) != 0) >+ { >+ unique_filenames++; >+- max_filename_len = max (max_filename_len, >+- strlen (array[i]->filename)); >++ max_filename_len = std::max (max_filename_len, >++ strlen (array[i]->filename)); >+ >+ if (i > 0) >+ { >+ pids_len -= strlen (", "); >+- max_pids_len = max (max_pids_len, pids_len); >++ max_pids_len = std::max (max_pids_len, pids_len); >+ } >+ pids_len = 0; >+ } >+@@ -1614,7 +1615,7 @@ info_auto_load_libthread_db (char *args, int from_tty) >+ if (i) >+ { >+ pids_len -= strlen (", "); >+- max_pids_len = max (max_pids_len, pids_len); >++ max_pids_len = std::max (max_pids_len, pids_len); >+ } >+ >+ /* Table header shifted right by preceding "libthread-db: " would not match >+diff --git gdb/lm32-tdep.c gdb/lm32-tdep.c >+index e0d3ff8..393dc0b 100644 >+--- gdb/lm32-tdep.c >++++ gdb/lm32-tdep.c >+@@ -36,6 +36,7 @@ >+ #include "trad-frame.h" >+ #include "reggroups.h" >+ #include "opcodes/lm32-desc.h" >++#include <algorithm> >+ >+ /* Macros to extract fields from an instruction. */ >+ #define LM32_OPCODE(insn) ((insn >> 26) & 0x3f) >+@@ -197,7 +198,7 @@ lm32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ CORE_ADDR post_prologue_pc >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ } >+ >+ /* Can't determine prologue from the symbol table, need to examine >+diff --git gdb/m32r-tdep.c gdb/m32r-tdep.c >+index bf9076a..67c310a 100644 >+--- gdb/m32r-tdep.c >++++ gdb/m32r-tdep.c >+@@ -36,8 +36,8 @@ >+ #include "trad-frame.h" >+ #include "dis-asm.h" >+ #include "objfiles.h" >+- >+ #include "m32r-tdep.h" >++#include <algorithm> >+ >+ /* Local functions */ >+ >+@@ -484,7 +484,7 @@ m32r_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ the end of the function. In this case, there probably isn't a >+ prologue. */ >+ { >+- func_end = min (func_end, func_addr + DEFAULT_SEARCH_LIMIT); >++ func_end = std::min (func_end, func_addr + DEFAULT_SEARCH_LIMIT); >+ } >+ } >+ else >+diff --git gdb/m88k-tdep.c gdb/m88k-tdep.c >+index e0ca565..bbfe928 100644 >+--- gdb/m88k-tdep.c >++++ gdb/m88k-tdep.c >+@@ -30,6 +30,7 @@ >+ #include "symtab.h" >+ #include "trad-frame.h" >+ #include "value.h" >++#include <algorithm> >+ >+ #include "m88k-tdep.h" >+ >+@@ -558,7 +559,7 @@ m88k_analyze_prologue (struct gdbarch *gdbarch, >+ prologue. */ >+ if (cache->fp_offset != -1 >+ && cache->saved_regs[M88K_R1_REGNUM].addr != -1) >+- return min (pc, end); >++ return std::min (pc, end); >+ break; >+ >+ case M88K_PIA_NOTE_ST: >+@@ -566,7 +567,7 @@ m88k_analyze_prologue (struct gdbarch *gdbarch, >+ /* If no frame has been allocated, the stores aren't part of >+ the prologue. */ >+ if (cache->sp_offset == 0) >+- return min (pc, end); >++ return std::min (pc, end); >+ >+ /* Record location of saved registers. */ >+ { >+@@ -583,7 +584,7 @@ m88k_analyze_prologue (struct gdbarch *gdbarch, >+ /* A second stack pointer adjustment isn't part of the >+ prologue. */ >+ if (cache->sp_offset != 0) >+- return min (pc, end); >++ return std::min (pc, end); >+ >+ /* Store stack pointer adjustment. */ >+ cache->sp_offset = -SUBU_OFFSET (insn); >+@@ -593,7 +594,7 @@ m88k_analyze_prologue (struct gdbarch *gdbarch, >+ /* A second frame pointer assignment isn't part of the >+ prologue. */ >+ if (cache->fp_offset != -1) >+- return min (pc, end); >++ return std::min (pc, end); >+ >+ /* Record frame pointer assignment. */ >+ cache->fp_offset = ADDU_OFFSET (insn); >+@@ -604,12 +605,12 @@ m88k_analyze_prologue (struct gdbarch *gdbarch, >+ the instruction in the delay slot might be. Limit the >+ prologue analysis to the delay slot and record the branch >+ instruction as the end of the prologue. */ >+- limit = min (limit, pc + 2 * M88K_INSN_SIZE); >++ limit = std::min (limit, pc + 2 * M88K_INSN_SIZE); >+ end = pc; >+ break; >+ >+ case M88K_PIA_NOTE_PROLOGUE_END: >+- return min (pc, end); >++ return std::min (pc, end); >+ } >+ >+ pc += M88K_INSN_SIZE; >+diff --git gdb/memrange.c gdb/memrange.c >+index 1e77098..74da19d 100644 >+--- gdb/memrange.c >++++ gdb/memrange.c >+@@ -19,6 +19,7 @@ >+ >+ #include "defs.h" >+ #include "memrange.h" >++#include <algorithm> >+ >+ int >+ mem_ranges_overlap (CORE_ADDR start1, int len1, >+@@ -26,8 +27,8 @@ mem_ranges_overlap (CORE_ADDR start1, int len1, >+ { >+ ULONGEST h, l; >+ >+- l = max (start1, start2); >+- h = min (start1 + len1, start2 + len2); >++ l = std::max (start1, start2); >++ h = std::min (start1 + len1, start2 + len2); >+ return (l < h); >+ } >+ >+@@ -82,7 +83,7 @@ normalize_mem_ranges (VEC(mem_range_s) *ranges) >+ merge them. */ >+ if (rb->start <= ra->start + ra->length) >+ { >+- ra->length = max (ra->length, >++ ra->length = std::max ((CORE_ADDR) ra->length, >+ (rb->start - ra->start) + rb->length); >+ continue; /* next b, same a */ >+ } >+diff --git gdb/minidebug.c gdb/minidebug.c >+index 056bc73..ae58c26 100644 >+--- gdb/minidebug.c >++++ gdb/minidebug.c >+@@ -22,6 +22,7 @@ >+ #include "symfile.h" >+ #include "objfiles.h" >+ #include "gdbcore.h" >++#include <algorithm> >+ >+ #ifdef HAVE_LIBLZMA >+ >+@@ -201,7 +202,7 @@ lzma_pread (struct bfd *nbfd, void *stream, void *buf, file_ptr nbytes, >+ + iter.block.uncompressed_size); >+ } >+ >+- chunk_size = min (nbytes, lstream->data_end - offset); >++ chunk_size = std::min (nbytes, (file_ptr) lstream->data_end - offset); >+ memcpy (buf, lstream->data + offset - lstream->data_start, chunk_size); >+ buf = (gdb_byte *) buf + chunk_size; >+ offset += chunk_size; >+diff --git gdb/mips-tdep.c gdb/mips-tdep.c >+index 7534939..d170123 100644 >+--- gdb/mips-tdep.c >++++ gdb/mips-tdep.c >+@@ -55,6 +55,7 @@ >+ #include "user-regs.h" >+ #include "valprint.h" >+ #include "ax.h" >++#include <algorithm> >+ >+ static const struct objfile_data *mips_pdr_data; >+ >+@@ -3044,7 +3045,7 @@ micromips_scan_prologue (struct gdbarch *gdbarch, >+ && ((reglist >= 1 && reglist <= 9) >+ || (reglist >= 16 && reglist <= 25))) >+ { >+- int sreglist = min(reglist & 0xf, 8); >++ int sreglist = std::min(reglist & 0xf, 8); >+ >+ s = 4 << ((b12s4_op (insn) & 0x2) == 0x2); >+ for (i = 0; i < sreglist; i++) >+@@ -6650,7 +6651,7 @@ mips_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ CORE_ADDR post_prologue_pc >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ } >+ >+ /* Can't determine prologue from the symbol table, need to examine >+diff --git gdb/moxie-tdep.c gdb/moxie-tdep.c >+index c152b88..259c07d 100644 >+--- gdb/moxie-tdep.c >++++ gdb/moxie-tdep.c >+@@ -39,6 +39,7 @@ >+ #include "record-full.h" >+ >+ #include "moxie-tdep.h" >++#include <algorithm> >+ >+ /* Local functions. */ >+ >+@@ -225,7 +226,7 @@ moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ CORE_ADDR post_prologue_pc >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ else >+ { >+ /* Can't determine prologue from the symbol table, need to examine >+diff --git gdb/nds32-tdep.c gdb/nds32-tdep.c >+index 893ec20..7c81d33 100644 >+--- gdb/nds32-tdep.c >++++ gdb/nds32-tdep.c >+@@ -41,6 +41,8 @@ >+ #include "nds32-tdep.h" >+ #include "elf/nds32.h" >+ #include "opcode/nds32.h" >++#include <algorithm> >++ >+ #include "features/nds32.c" >+ >+ /* Simple macros for instruction analysis. */ >+@@ -894,7 +896,7 @@ nds32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ CORE_ADDR post_prologue_pc >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ } >+ >+ /* Can't determine prologue from the symbol table, need to examine >+diff --git gdb/nios2-tdep.c gdb/nios2-tdep.c >+index e9cbdfb..1121467 100644 >+--- gdb/nios2-tdep.c >++++ gdb/nios2-tdep.c >+@@ -44,6 +44,7 @@ >+ >+ /* To get entry_point_address. */ >+ #include "objfiles.h" >++#include <algorithm> >+ >+ /* Nios II specific header. */ >+ #include "nios2-tdep.h" >+@@ -1685,7 +1686,7 @@ nios2_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ >+ if (post_prologue_pc != 0) >+- return max (start_pc, post_prologue_pc); >++ return std::max (start_pc, post_prologue_pc); >+ } >+ >+ /* Prologue analysis does the rest.... */ >+diff --git gdb/nto-procfs.c gdb/nto-procfs.c >+index 2939916..003aeaa 100644 >+--- gdb/nto-procfs.c >++++ gdb/nto-procfs.c >+@@ -516,7 +516,7 @@ procfs_meminfo (char *args, int from_tty) >+ return; >+ } >+ >+- num = min (num, num_mapinfos); >++ num = std::min (num, num_mapinfos); >+ >+ /* Run through the list of mapinfos, and store the data and text info >+ so we can print it at the bottom of the loop. */ >+@@ -939,7 +939,7 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object, >+ tempread = nto_read_auxv_from_initial_stack (initial_stack, tempbuf, >+ sizeof_tempbuf, >+ sizeof (auxv_t)); >+- tempread = min (tempread, len) - offset; >++ tempread = std::min (tempread, len) - offset; >+ memcpy (readbuf, tempbuf + offset, tempread); >+ *xfered_len = tempread; >+ return tempread ? TARGET_XFER_OK : TARGET_XFER_EOF; >+diff --git gdb/parse.c gdb/parse.c >+index c513220..e6090ae 100644 >+--- gdb/parse.c >++++ gdb/parse.c >+@@ -49,6 +49,7 @@ >+ #include "source.h" >+ #include "objfiles.h" >+ #include "user-regs.h" >++#include <algorithm> >+ >+ /* Standard set of definitions for printing, dumping, prefixifying, >+ * and evaluating expressions. */ >+@@ -1925,7 +1926,7 @@ increase_expout_size (struct parser_state *ps, size_t lenelt) >+ { >+ if ((ps->expout_ptr + lenelt) >= ps->expout_size) >+ { >+- ps->expout_size = max (ps->expout_size * 2, >++ ps->expout_size = std::max (ps->expout_size * 2, >+ ps->expout_ptr + lenelt + 10); >+ ps->expout = (struct expression *) >+ xrealloc (ps->expout, (sizeof (struct expression) >+diff --git gdb/ppc-sysv-tdep.c gdb/ppc-sysv-tdep.c >+index 4f081fe..ecae636 100644 >+--- gdb/ppc-sysv-tdep.c >++++ gdb/ppc-sysv-tdep.c >+@@ -28,6 +28,7 @@ >+ #include "objfiles.h" >+ #include "infcall.h" >+ #include "dwarf2.h" >++#include <algorithm> >+ >+ >+ /* Check whether FTPYE is a (pointer to) function type that should use >+@@ -1189,7 +1190,7 @@ ppc64_aggregate_candidate (struct type *type, >+ if (TYPE_CODE (type) == TYPE_CODE_STRUCT) >+ count += sub_count; >+ else >+- count = max (count, sub_count); >++ count = std::max (count, sub_count); >+ } >+ >+ /* There must be no padding. */ >+diff --git gdb/probe.c gdb/probe.c >+index b1f83e1..58e1f64 100644 >+--- gdb/probe.c >++++ gdb/probe.c >+@@ -35,6 +35,7 @@ >+ #include "ax-gdb.h" >+ #include "location.h" >+ #include <ctype.h> >++#include <algorithm> >+ >+ typedef struct bound_probe bound_probe_s; >+ DEF_VEC_O (bound_probe_s); >+@@ -432,7 +433,7 @@ gen_ui_out_table_header_info (VEC (bound_probe_s) *probes, >+ if (val == NULL) >+ continue; >+ >+- size_max = max (strlen (val), size_max); >++ size_max = std::max (strlen (val), size_max); >+ } >+ do_cleanups (c2); >+ } >+@@ -644,10 +645,11 @@ info_probes_for_ops (const char *arg, int from_tty, >+ { >+ const char *probe_type = probe->probe->pops->type_name (probe->probe); >+ >+- size_type = max (strlen (probe_type), size_type); >+- size_name = max (strlen (probe->probe->name), size_name); >+- size_provider = max (strlen (probe->probe->provider), size_provider); >+- size_objname = max (strlen (objfile_name (probe->objfile)), size_objname); >++ size_type = std::max (strlen (probe_type), size_type); >++ size_name = std::max (strlen (probe->probe->name), size_name); >++ size_provider = std::max (strlen (probe->probe->provider), size_provider); >++ size_objname = std::max (strlen (objfile_name (probe->objfile)), >++ size_objname); >+ } >+ >+ ui_out_table_header (current_uiout, size_type, ui_left, "type", _("Type")); >+diff --git gdb/record-btrace.c gdb/record-btrace.c >+index 9ae0059..e9a49eb 100644 >+--- gdb/record-btrace.c >++++ gdb/record-btrace.c >+@@ -39,6 +39,7 @@ >+ #include "event-loop.h" >+ #include "inf-loop.h" >+ #include "vec.h" >++#include <algorithm> >+ >+ /* The target_ops of record-btrace. */ >+ static struct target_ops record_btrace_ops; >+@@ -1003,8 +1004,8 @@ btrace_compute_src_line_range (const struct btrace_function *bfun, >+ if (sal.symtab != symtab || sal.line == 0) >+ continue; >+ >+- begin = min (begin, sal.line); >+- end = max (end, sal.line); >++ begin = std::min (begin, sal.line); >++ end = std::max (end, sal.line); >+ } >+ >+ out: >+@@ -1380,7 +1381,7 @@ record_btrace_xfer_partial (struct target_ops *ops, enum target_object object, >+ & SEC_READONLY) != 0) >+ { >+ /* Truncate the request to fit into this section. */ >+- len = min (len, section->endaddr - offset); >++ len = std::min (len, section->endaddr - offset); >+ break; >+ } >+ } >+diff --git gdb/remote.c gdb/remote.c >+index cba5e74..20f6749 100644 >+--- gdb/remote.c >++++ gdb/remote.c >+@@ -71,6 +71,7 @@ >+ #include "agent.h" >+ #include "btrace.h" >+ #include "record-btrace.h" >++#include <algorithm> >+ >+ /* Temp hacks for tracepoint encoding migration. */ >+ static char *target_buf; >+@@ -3354,7 +3355,7 @@ remote_threads_extra_info (struct target_ops *self, struct thread_info *tp) >+ getpkt (&rs->buf, &rs->buf_size, 0); >+ if (rs->buf[0] != 0) >+ { >+- n = min (strlen (rs->buf) / 2, sizeof (display_buf)); >++ n = std::min (strlen (rs->buf) / 2, sizeof (display_buf)); >+ result = hex2bin (rs->buf, (gdb_byte *) display_buf, n); >+ display_buf [result] = '\0'; >+ return display_buf; >+@@ -7466,7 +7467,7 @@ hexnumlen (ULONGEST num) >+ for (i = 0; num != 0; i++) >+ num >>= 4; >+ >+- return max (i, 1); >++ return std::max (i, 1); >+ } >+ >+ /* Set BUF to the minimum number of hex digits representing NUM. */ >+@@ -7671,18 +7672,22 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr, >+ if (packet_format == 'X') >+ { >+ /* Best guess at number of bytes that will fit. */ >+- todo_units = min (len_units, payload_capacity_bytes / unit_size); >++ todo_units = std::min (len_units, >++ (ULONGEST) payload_capacity_bytes / unit_size); >+ if (use_length) >+ payload_capacity_bytes -= hexnumlen (todo_units); >+- todo_units = min (todo_units, payload_capacity_bytes / unit_size); >++ todo_units = std::min (todo_units, payload_capacity_bytes / unit_size); >+ } >+ else >+ { >+ /* Number of bytes that will fit. */ >+- todo_units = min (len_units, (payload_capacity_bytes / unit_size) / 2); >++ todo_units >++ = std::min (len_units, >++ (ULONGEST) (payload_capacity_bytes / unit_size) / 2); >+ if (use_length) >+ payload_capacity_bytes -= hexnumlen (todo_units); >+- todo_units = min (todo_units, (payload_capacity_bytes / unit_size) / 2); >++ todo_units = std::min (todo_units, >++ (payload_capacity_bytes / unit_size) / 2); >+ } >+ >+ if (todo_units <= 0) >+@@ -7841,7 +7846,8 @@ remote_read_bytes_1 (CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len_units, >+ get_memory_packet_size ensures this. */ >+ >+ /* Number of units that will fit. */ >+- todo_units = min (len_units, (buf_size_bytes / unit_size) / 2); >++ todo_units = std::min (len_units, >++ (ULONGEST) (buf_size_bytes / unit_size) / 2); >+ >+ /* Construct "m"<memaddr>","<len>". */ >+ memaddr = remote_address_masked (memaddr); >+@@ -9901,7 +9907,7 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name, >+ may not, since we don't know how much of it will need to be escaped; >+ the target is free to respond with slightly less data. We subtract >+ five to account for the response type and the protocol frame. */ >+- n = min (get_remote_packet_size () - 5, len); >++ n = std::min (get_remote_packet_size () - 5, len); >+ snprintf (rs->buf, get_remote_packet_size () - 4, "qXfer:%s:read:%s:%s,%s", >+ object_name, annex ? annex : "", >+ phex_nz (offset, sizeof offset), >+diff --git gdb/rs6000-tdep.c gdb/rs6000-tdep.c >+index 2def261..adaf1e8 100644 >+--- gdb/rs6000-tdep.c >++++ gdb/rs6000-tdep.c >+@@ -64,6 +64,7 @@ >+ >+ #include "ax.h" >+ #include "ax-gdb.h" >++#include <algorithm> >+ >+ #include "features/rs6000/powerpc-32.c" >+ #include "features/rs6000/powerpc-altivec32.c" >+@@ -2185,7 +2186,7 @@ rs6000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ CORE_ADDR post_prologue_pc >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ } >+ >+ /* Can't determine prologue from the symbol table, need to examine >+diff --git gdb/rx-tdep.c gdb/rx-tdep.c >+index 68ed3e0..e202b79 100644 >+--- gdb/rx-tdep.c >++++ gdb/rx-tdep.c >+@@ -36,6 +36,7 @@ >+ >+ #include "elf/rx.h" >+ #include "elf-bfd.h" >++#include <algorithm> >+ >+ /* Certain important register numbers. */ >+ enum >+@@ -957,7 +958,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, >+ && arg_size <= 4 * (RX_R4_REGNUM - arg_reg + 1) >+ && arg_size % 4 == 0) >+ { >+- int len = min (arg_size, 4); >++ int len = std::min (arg_size, (ULONGEST) 4); >+ >+ if (write_pass) >+ regcache_cooked_write_unsigned (regcache, arg_reg, >+@@ -1020,7 +1021,7 @@ rx_return_value (struct gdbarch *gdbarch, >+ >+ while (valtype_len > 0) >+ { >+- int len = min (valtype_len, 4); >++ int len = std::min (valtype_len, (ULONGEST) 4); >+ >+ regcache_cooked_read_unsigned (regcache, argreg, &u); >+ store_unsigned_integer (readbuf + offset, len, byte_order, u); >+@@ -1038,7 +1039,7 @@ rx_return_value (struct gdbarch *gdbarch, >+ >+ while (valtype_len > 0) >+ { >+- int len = min (valtype_len, 4); >++ int len = std::min (valtype_len, (ULONGEST) 4); >+ >+ u = extract_unsigned_integer (writebuf + offset, len, byte_order); >+ regcache_cooked_write_unsigned (regcache, argreg, u); >+diff --git gdb/s390-linux-nat.c gdb/s390-linux-nat.c >+index 55a3899..e343973 100644 >+--- gdb/s390-linux-nat.c >++++ gdb/s390-linux-nat.c >+@@ -501,8 +501,8 @@ s390_prepare_to_resume (struct lwp_info *lp) >+ >+ for (area = watch_base; area; area = area->next) >+ { >+- watch_lo_addr = min (watch_lo_addr, area->lo_addr); >+- watch_hi_addr = max (watch_hi_addr, area->hi_addr); >++ watch_lo_addr = std::min (watch_lo_addr, area->lo_addr); >++ watch_hi_addr = std::max (watch_hi_addr, area->hi_addr); >+ } >+ >+ parea.len = sizeof (per_info); >+diff --git gdb/s390-linux-tdep.c gdb/s390-linux-tdep.c >+index f53f82c..1b12b9a 100644 >+--- gdb/s390-linux-tdep.c >++++ gdb/s390-linux-tdep.c >+@@ -58,6 +58,7 @@ >+ #include "elf/common.h" >+ #include "elf/s390.h" >+ #include "elf-bfd.h" >++#include <algorithm> >+ >+ #include "features/s390-linux32.c" >+ #include "features/s390-linux32v1.c" >+@@ -1734,7 +1735,7 @@ s390_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ CORE_ADDR post_prologue_pc >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ } >+ >+ skip_pc = s390_analyze_prologue (gdbarch, pc, (CORE_ADDR)-1, &data); >+diff --git gdb/ser-tcp.c gdb/ser-tcp.c >+index c209cdd..57a7c55 100644 >+--- gdb/ser-tcp.c >++++ gdb/ser-tcp.c >+@@ -54,6 +54,7 @@ >+ >+ #include <signal.h> >+ #include "gdb_select.h" >++#include <algorithm> >+ >+ #ifndef HAVE_SOCKLEN_T >+ typedef int socklen_t; >+@@ -183,7 +184,7 @@ net_open (struct serial *scb, const char *name) >+ error (_("net_open: No colon in host name!")); /* Shouldn't ever >+ happen. */ >+ >+- tmp = min (port_str - name, (int) sizeof hostname - 1); >++ tmp = std::min (port_str - name, (ptrdiff_t) sizeof hostname - 1); >+ strncpy (hostname, name, tmp); /* Don't want colon. */ >+ hostname[tmp] = '\000'; /* Tie off host name. */ >+ port = atoi (port_str + 1); >+diff --git gdb/sh-tdep.c gdb/sh-tdep.c >+index 4a44355..c6c7ab4 100644 >+--- gdb/sh-tdep.c >++++ gdb/sh-tdep.c >+@@ -52,6 +52,7 @@ >+ #include "dwarf2.h" >+ /* registers numbers shared with the simulator. */ >+ #include "gdb/sim-sh.h" >++#include <algorithm> >+ >+ /* List of "set sh ..." and "show sh ..." commands. */ >+ static struct cmd_list_element *setshcmdlist = NULL; >+@@ -654,7 +655,7 @@ sh_analyze_prologue (struct gdbarch *gdbarch, >+ { >+ pc += 2; >+ /* Don't go any further than six more instructions. */ >+- limit_pc = min (limit_pc, pc + (2 * 6)); >++ limit_pc = std::min (limit_pc, pc + (2 * 6)); >+ >+ cache->uses_fp = 1; >+ /* At this point, only allow argument register moves to other >+@@ -728,7 +729,7 @@ sh_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ { >+ post_prologue_pc = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ } >+ >+ /* Can't determine prologue from the symbol table, need to examine >+@@ -745,7 +746,7 @@ sh_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ /* Do not allow limit_pc to be past the function end, if we know >+ where that end is... */ >+ if (func_end_addr != 0) >+- limit_pc = min (limit_pc, func_end_addr); >++ limit_pc = std::min (limit_pc, func_end_addr); >+ >+ cache.sp_offset = -4; >+ post_prologue_pc = sh_analyze_prologue (gdbarch, pc, limit_pc, &cache, 0); >+diff --git gdb/sh64-tdep.c gdb/sh64-tdep.c >+index 7c95497..092dc59 100644 >+--- gdb/sh64-tdep.c >++++ gdb/sh64-tdep.c >+@@ -45,6 +45,7 @@ >+ #include "gdb/sim-sh.h" >+ #include "language.h" >+ #include "sh64-tdep.h" >++#include <algorithm> >+ >+ /* Information that is dependent on the processor variant. */ >+ enum sh_abi >+@@ -685,7 +686,7 @@ sh64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) >+ /* If after_prologue returned a useful address, then use it. Else >+ fall back on the instruction skipping code. */ >+ if (post_prologue_pc != 0) >+- return max (pc, post_prologue_pc); >++ return std::max (pc, post_prologue_pc); >+ else >+ return sh64_skip_prologue_hard_way (gdbarch, pc); >+ } >+diff --git gdb/source.c gdb/source.c >+index d8cb07a..e85379e 100644 >+--- gdb/source.c >++++ gdb/source.c >+@@ -43,6 +43,7 @@ >+ #include "ui-out.h" >+ #include "readline/readline.h" >+ #include "common/enum-flags.h" >++#include <algorithm> >+ >+ #define OPEN_MODE (O_RDONLY | O_BINARY) >+ #define FDOPEN_MODE FOPEN_RB >+@@ -283,7 +284,7 @@ select_source_symtab (struct symtab *s) >+ xfree (sals.sals); >+ current_source_pspace = sal.pspace; >+ current_source_symtab = sal.symtab; >+- current_source_line = max (sal.line - (lines_to_list - 1), 1); >++ current_source_line = std::max (sal.line - (lines_to_list - 1), 1); >+ if (current_source_symtab) >+ return; >+ } >+@@ -1706,7 +1707,7 @@ forward_search_command (char *regex, int from_tty) >+ do_cleanups (cleanups); >+ print_source_lines (current_source_symtab, line, line + 1, 0); >+ set_internalvar_integer (lookup_internalvar ("_"), line); >+- current_source_line = max (line - lines_to_list / 2, 1); >++ current_source_line = std::max (line - lines_to_list / 2, 1); >+ return; >+ } >+ line++; >+@@ -1784,7 +1785,7 @@ reverse_search_command (char *regex, int from_tty) >+ do_cleanups (cleanups); >+ print_source_lines (current_source_symtab, line, line + 1, 0); >+ set_internalvar_integer (lookup_internalvar ("_"), line); >+- current_source_line = max (line - lines_to_list / 2, 1); >++ current_source_line = std::max (line - lines_to_list / 2, 1); >+ return; >+ } >+ line--; >+diff --git gdb/sparc-tdep.c gdb/sparc-tdep.c >+index a71ac55..bc19fb2 100644 >+--- gdb/sparc-tdep.c >++++ gdb/sparc-tdep.c >+@@ -37,6 +37,7 @@ >+ >+ #include "sparc-tdep.h" >+ #include "sparc-ravenscar-thread.h" >++#include <algorithm> >+ >+ struct regset; >+ >+@@ -561,7 +562,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, >+ } >+ >+ /* Always allocate at least six words. */ >+- sp -= max (6, num_elements) * 4; >++ sp -= std::max (6, num_elements) * 4; >+ >+ /* The psABI says that "Software convention requires space for the >+ struct/union return value pointer, even if the word is unused." */ >+diff --git gdb/symfile.c gdb/symfile.c >+index 08388e0..df0daa4 100644 >+--- gdb/symfile.c >++++ gdb/symfile.c >+@@ -1461,7 +1461,7 @@ find_separate_debug_file (const char *dir, >+ struct cleanup *back_to; >+ int ix; >+ >+- /* Set I to max (strlen (canon_dir), strlen (dir)). */ >++ /* Set I to std::max (strlen (canon_dir), strlen (dir)). */ >+ i = strlen (dir); >+ if (canon_dir != NULL && strlen (canon_dir) > i) >+ i = strlen (canon_dir); >+diff --git gdb/target-memory.c gdb/target-memory.c >+index 3f91c42..1c8faa8 100644 >+--- gdb/target-memory.c >++++ gdb/target-memory.c >+@@ -24,6 +24,7 @@ >+ #include "memory-map.h" >+ >+ #include "gdb_sys_time.h" >++#include <algorithm> >+ >+ static int >+ compare_block_starting_address (const void *a, const void *b) >+@@ -71,11 +72,11 @@ claim_memory (VEC(memory_write_request_s) *blocks, >+ if (end != 0 && end <= r->begin) >+ continue; >+ >+- claimed_begin = max (begin, r->begin); >++ claimed_begin = std::max (begin, r->begin); >+ if (end == 0) >+ claimed_end = r->end; >+ else >+- claimed_end = min (end, r->end); >++ claimed_end = std::min (end, r->end); >+ >+ if (claimed_begin == r->begin && claimed_end == r->end) >+ VEC_safe_push (memory_write_request_s, *result, r); >+diff --git gdb/target.c gdb/target.c >+index 1a431c0..5aab469 100644 >+--- gdb/target.c >++++ 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); >+ >+@@ -2443,7 +2444,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); >+@@ -2476,7 +2478,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, >+@@ -2848,7 +2851,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. */ >+@@ -3572,7 +3575,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, >+diff --git gdb/tic6x-tdep.c gdb/tic6x-tdep.c >+index 53f3687..4ddc31d 100644 >+--- gdb/tic6x-tdep.c >++++ gdb/tic6x-tdep.c >+@@ -48,6 +48,7 @@ >+ #include "tic6x-tdep.h" >+ #include "language.h" >+ #include "target-descriptions.h" >++#include <algorithm> >+ >+ #include "features/tic6x-c64xp.c" >+ #include "features/tic6x-c64x.c" >+@@ -308,7 +309,7 @@ tic6x_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) >+ CORE_ADDR post_prologue_pc >+ = skip_prologue_using_sal (gdbarch, func_addr); >+ if (post_prologue_pc != 0) >+- return max (start_pc, post_prologue_pc); >++ return std::max (start_pc, post_prologue_pc); >+ } >+ >+ /* Can't determine prologue from the symbol table, need to examine >+diff --git gdb/tilegx-tdep.c gdb/tilegx-tdep.c >+index 165dcb5..a55ce27 100644 >+--- gdb/tilegx-tdep.c >++++ gdb/tilegx-tdep.c >+@@ -41,6 +41,7 @@ >+ #include "solib-svr4.h" >+ #include "tilegx-tdep.h" >+ #include "opcode/tilegx.h" >++#include <algorithm> >+ >+ struct tilegx_frame_cache >+ { >+@@ -428,7 +429,8 @@ tilegx_analyze_prologue (struct gdbarch* gdbarch, >+ if (instbuf_size > size_on_same_page) >+ instbuf_size = size_on_same_page; >+ >+- instbuf_size = min (instbuf_size, (end_addr - next_addr)); >++ instbuf_size = std::min ((CORE_ADDR) instbuf_size, >++ (end_addr - next_addr)); >+ instbuf_start = next_addr; >+ >+ status = safe_frame_unwind_memory (next_frame, instbuf_start, >+@@ -752,14 +754,14 @@ tilegx_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) >+ = skip_prologue_using_sal (gdbarch, func_start); >+ >+ if (post_prologue_pc != 0) >+- return max (start_pc, post_prologue_pc); >++ return std::max (start_pc, post_prologue_pc); >+ } >+ >+ /* Don't straddle a section boundary. */ >+ s = find_pc_section (start_pc); >+ end_pc = start_pc + 8 * TILEGX_BUNDLE_SIZE_IN_BYTES; >+ if (s != NULL) >+- end_pc = min (end_pc, obj_section_endaddr (s)); >++ end_pc = std::min (end_pc, obj_section_endaddr (s)); >+ >+ /* Otherwise, try to skip prologue the hard way. */ >+ return tilegx_analyze_prologue (gdbarch, >+diff --git gdb/tracefile-tfile.c gdb/tracefile-tfile.c >+index 6597020..d1a68e9 100644 >+--- gdb/tracefile-tfile.c >++++ gdb/tracefile-tfile.c >+@@ -32,6 +32,7 @@ >+ #include "xml-tdesc.h" >+ #include "target-descriptions.h" >+ #include "buffer.h" >++#include <algorithm> >+ >+ #ifndef O_LARGEFILE >+ #define O_LARGEFILE 0 >+@@ -987,7 +988,7 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object, >+ and this address falls within a read-only section, fallback >+ to reading from executable, up to LOW_ADDR_AVAILABLE. */ >+ if (offset < low_addr_available) >+- len = min (len, low_addr_available - offset); >++ len = std::min (len, low_addr_available - offset); >+ res = exec_read_partial_read_only (readbuf, offset, len, xfered_len); >+ >+ if (res == TARGET_XFER_OK) >+diff --git gdb/tracepoint.c gdb/tracepoint.c >+index 3514c93..c81d190 100644 >+--- gdb/tracepoint.c >++++ gdb/tracepoint.c >+@@ -56,6 +56,7 @@ >+ #include "rsp-low.h" >+ #include "tracefile.h" >+ #include "location.h" >++#include <algorithm> >+ >+ /* readline include files */ >+ #include "readline/readline.h" >+@@ -4324,8 +4325,8 @@ traceframe_available_memory (VEC(mem_range_s) **result, >+ >+ nr = VEC_safe_push (mem_range_s, *result, NULL); >+ >+- nr->start = max (lo1, lo2); >+- nr->length = min (hi1, hi2) - nr->start; >++ nr->start = std::max (lo1, lo2); >++ nr->length = std::min (hi1, hi2) - nr->start; >+ } >+ >+ normalize_mem_ranges (*result); >+diff --git gdb/valprint.c gdb/valprint.c >+index 3aaf531..c4fec9d 100644 >+--- gdb/valprint.c >++++ gdb/valprint.c >+@@ -36,6 +36,7 @@ >+ #include "charset.h" >+ #include "typeprint.h" >+ #include <ctype.h> >++#include <algorithm> >+ >+ /* Maximum number of wchars returned from wchar_iterate. */ >+ #define MAX_WCHARS 4 >+@@ -2179,7 +2180,7 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit, >+ { >+ /* We want fetchlimit chars, so we might as well read them all in >+ one operation. */ >+- unsigned int fetchlen = min (len, fetchlimit); >++ unsigned int fetchlen = std::min ((unsigned) len, fetchlimit); >+ >+ *buffer = (gdb_byte *) xmalloc (fetchlen * width); >+ bufptr = *buffer; >+@@ -2203,12 +2204,12 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit, >+ So we choose the minimum of 8 and fetchlimit. We used to use 200 >+ instead of 8 but 200 is way too big for remote debugging over a >+ serial line. */ >+- chunksize = min (8, fetchlimit); >++ chunksize = std::min (8u, fetchlimit); >+ >+ do >+ { >+ QUIT; >+- nfetch = min (chunksize, fetchlimit - bufsize); >++ nfetch = std::min ((unsigned long) chunksize, fetchlimit - bufsize); >+ >+ if (*buffer == NULL) >+ *buffer = (gdb_byte *) xmalloc (nfetch * width); >+@@ -2865,8 +2866,8 @@ val_print_string (struct type *elttype, const char *encoding, >+ because finding the null byte (or available memory) is what actually >+ limits the fetch. */ >+ >+- fetchlimit = (len == -1 ? options->print_max : min (len, >+- options->print_max)); >++ fetchlimit = (len == -1 ? options->print_max : std::min ((unsigned) len, >++ options->print_max)); >+ >+ err = read_string (addr, len, width, fetchlimit, byte_order, >+ &buffer, &bytes_read); >+diff --git gdb/value.c gdb/value.c >+index 7da1e28..fc6c58e 100644 >+--- gdb/value.c >++++ 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, >+diff --git gdb/xtensa-tdep.c gdb/xtensa-tdep.c >+index 1b788ae..1d7e95d 100644 >+--- gdb/xtensa-tdep.c >++++ gdb/xtensa-tdep.c >+@@ -52,6 +52,7 @@ >+ #include "xtensa-isa.h" >+ #include "xtensa-tdep.h" >+ #include "xtensa-config.h" >++#include <algorithm> >+ >+ >+ static unsigned int xtensa_debug_level = 0; >+@@ -2417,10 +2418,10 @@ call0_analyze_prologue (struct gdbarch *gdbarch, >+ if (pc == 0) >+ { >+ find_pc_partial_function (start, 0, NULL, &end_pc); >+- body_pc = min (end_pc, body_pc); >++ body_pc = std::min (end_pc, body_pc); >+ } >+ else >+- body_pc = min (pc, body_pc); >++ body_pc = std::min (pc, body_pc); >+ >+ cache->call0 = 1; >+ rtmp = (xtensa_c0reg_t*) alloca(nregs * sizeof(xtensa_c0reg_t)); > >Property changes on: devel/gdb/files/commit-325fac504a >___________________________________________________________________ >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property >Index: devel/gdb/files/commit-768adc05c4 >=================================================================== >--- devel/gdb/files/commit-768adc05c4 (nonexistent) >+++ devel/gdb/files/commit-768adc05c4 (working copy) >@@ -0,0 +1,116 @@ >+commit 768adc05c44c7e8b5c0f9ca5ad3ca96657715293 >+Author: Pedro Alves <palves@redhat.com> >+Date: Sun Sep 18 23:56:01 2016 +0100 >+ >+ gdb: Fix std::{min, max}-related build breakage on 32-bit hosts >+ >+ Building on a 32-bit host fails currently with errors like: >+ >+ .../src/gdb/exec.c: In function âtarget_xfer_status section_table_read_available_memory(gdb_byte*, ULONGEST, ULONGEST, ULONGEST*)â: >+ .../src/gdb/exec.c:801:54: error: no matching function for call to âmin(ULONGEST, long unsigned int)â >+ end = std::min (offset + len, r->start + r->length); >+ ^ >+ In file included from /usr/include/c++/5.3.1/algorithm:61:0, >+ from .../src/gdb/exec.c:46: >+ /usr/include/c++/5.3.1/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&) >+ min(const _Tp& __a, const _Tp& __b) >+ ^ >+ /usr/include/c++/5.3.1/bits/stl_algobase.h:195:5: note: template argument deduction/substitution failed: >+ .../src/gdb/exec.c:801:54: note: deduced conflicting types for parameter âconst _Tpâ (âlong long unsigned intâ and âlong unsigned intâ) >+ end = std::min (offset + len, r->start + r->length); >+ ^ >+ In file included from /usr/include/c++/5.3.1/algorithm:61:0, >+ from .../src/gdb/exec.c:46: >+ /usr/include/c++/5.3.1/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare) >+ min(const _Tp& __a, const _Tp& __b, _Compare __comp) >+ ^ >+ >+ The problem is that the std::min/std::max function templates use the >+ same type for both parameters. When the argument types are different, >+ the compiler can't automatically deduce which template specialization >+ to pick from the arguments' types. >+ >+ Fix that by specifying the specialization we want explicitly. >+ >+ gdb/ChangeLog: >+ 2016-09-18 Pedro Alves <palves@redhat.com> >+ >+ * breakpoint.c (hardware_watchpoint_inserted_in_range): Explicitly >+ specify the std:min/std::max specialization. >+ * exec.c (section_table_read_available_memory): Likewise. >+ * remote.c (remote_read_qxfer): Likewise. >+ * target.c (simple_verify_memory): Likewise. >+ >+diff --git gdb/ChangeLog gdb/ChangeLog >+index 2c980b78dc..f86e0a43b9 100644 >+--- gdb/ChangeLog >++++ gdb/ChangeLog >+@@ -264,6 +264,14 @@ >+ * rs6000-tdep.c (ppc_process_record_op31): Fix record of Store String >+ Word instructions. >+ >++2016-09-18 Pedro Alves <palves@redhat.com> >++ >++ * breakpoint.c (hardware_watchpoint_inserted_in_range): Explicitly >++ specify the std:min/std::max specialization. >++ * exec.c (section_table_read_available_memory): Likewise. >++ * remote.c (remote_read_qxfer): Likewise. >++ * target.c (simple_verify_memory): Likewise. >++ >+ 2016-09-16 Pedro Alves <palves@redhat.com> >+ >+ * defs.h (min, max): Delete. >+diff --git gdb/breakpoint.c gdb/breakpoint.c >+index 28331f1088..1e059325aa 100644 >+--- gdb/breakpoint.c >++++ gdb/breakpoint.c >+@@ -4436,8 +4436,8 @@ hardware_watchpoint_inserted_in_range (struct address_space *aspace, >+ CORE_ADDR l, h; >+ >+ /* Check for intersection. */ >+- l = std::max (loc->address, addr); >+- h = std::min (loc->address + loc->length, addr + len); >++ l = std::max<CORE_ADDR> (loc->address, addr); >++ h = std::min<CORE_ADDR> (loc->address + loc->length, addr + len); >+ if (l < h) >+ return 1; >+ } >+diff --git gdb/exec.c gdb/exec.c >+index b18ca8b662..7435971173 100644 >+--- gdb/exec.c >++++ gdb/exec.c >+@@ -798,7 +798,7 @@ section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset, >+ enum target_xfer_status status; >+ >+ /* Get the intersection window. */ >+- end = std::min (offset + len, r->start + r->length); >++ end = std::min<CORE_ADDR> (offset + len, r->start + r->length); >+ >+ gdb_assert (end - offset <= len); >+ >+diff --git gdb/remote.c gdb/remote.c >+index 2309205ed7..e80db79b10 100644 >+--- gdb/remote.c >++++ gdb/remote.c >+@@ -9907,7 +9907,7 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name, >+ may not, since we don't know how much of it will need to be escaped; >+ the target is free to respond with slightly less data. We subtract >+ five to account for the response type and the protocol frame. */ >+- n = std::min (get_remote_packet_size () - 5, len); >++ n = std::min<LONGEST> (get_remote_packet_size () - 5, len); >+ snprintf (rs->buf, get_remote_packet_size () - 4, "qXfer:%s:read:%s:%s,%s", >+ object_name, annex ? annex : "", >+ phex_nz (offset, sizeof offset), >+diff --git gdb/target.c gdb/target.c >+index 628bceb664..b93244da2a 100644 >+--- gdb/target.c >++++ gdb/target.c >+@@ -3585,7 +3585,7 @@ simple_verify_memory (struct target_ops *ops, >+ ULONGEST xfered_len; >+ enum target_xfer_status status; >+ gdb_byte buf[1024]; >+- ULONGEST howmuch = std::min (sizeof (buf), size - total_xfered); >++ ULONGEST howmuch = std::min<ULONGEST> (sizeof (buf), size - total_xfered); >+ >+ status = target_xfer_partial (ops, TARGET_OBJECT_MEMORY, NULL, >+ buf, NULL, lma + total_xfered, howmuch, > >Property changes on: devel/gdb/files/commit-768adc05c4 >___________________________________________________________________ >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 219126
: 182374