From: John Marino Date: Sat, 29 Sep 2012 19:58:02 +0000 (+0200) Subject: GCC47: Add local modifications X-Git-Tag: v3.2.0~42 X-Git-Url: https://gitweb.dragonflybsd.org/~nant/dragonfly.git/commitdiff_plain/fdc4107c31de968b553167c368749e613eb5a448 GCC47: Add local modifications The majority of these changes are new files required to build GCC on DragonFly. They are identical to the lang/gcc-aux modifications. Of interest: 1) The modification to c-format.c is a carry-over from GCC44. It maintains support for the DragonFly-specific %b and %D conversions. 2) The modification to tree-inline.c is a carry-over from GCC44. It maintains the suppression of "unlikely call" inline warnings. 3) The gcc driver was modified to strip out all the bad paths in its search path. gcc -print-search-dirs is now short and accurate. --- diff --git a/contrib/gcc-4.7/gcc/c-family/c-format.c b/contrib/gcc-4.7/gcc/c-family/c-format.c index 9fabc39956..e184043e95 100644 --- a/contrib/gcc-4.7/gcc/c-family/c-format.c +++ b/contrib/gcc-4.7/gcc/c-family/c-format.c @@ -620,6 +620,9 @@ static const format_flag_pair strfmon_flag_pairs[] = }; +static const format_char_info dfly_ext_char_info = +{ NULL, 1, STD_EXT, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "cR", NULL }; + static const format_char_info print_char_table[] = { /* C89 conversion specifiers. */ @@ -640,6 +643,18 @@ static const format_char_info print_char_table[] = { "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R", NULL }, /* GNU conversion specifiers. */ { "m", 0, STD_EXT, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "", NULL }, + /* BSD conversion specifiers. */ + /* DragonFly kernel extensions (src/sys/kern/subr_prf.c). + The format %b is supported to decode error registers. + Its usage is: printf("reg=%b\n", regval, "*"); + which produces: reg=3 + The format %D provides a hexdump given a pointer and separator string: + ("%6D", ptr, ":") -> XX:XX:XX:XX:XX:XX + ("%*D", len, ptr, " ") -> XX XX XX XX ... + */ + { "D", 1, STD_EXT, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR", &dfly_ext_char_info }, + { "b", 0, STD_EXT, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "", &dfly_ext_char_info }, + { "ry", 0, STD_EXT, { T89_I, BADLEN, BADLEN, T89_L, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "i", NULL }, { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; @@ -1943,6 +1958,14 @@ check_format_info_main (format_check_results *res, while (fli->name != 0 && strncmp (fli->name, format_chars, strlen (fli->name))) fli++; + /* + * DragonFly's D conversion needs to have precedence + * over the DD length modifier + */ + if (fli->index == FMT_LEN_D + && fki->conversion_specs == print_char_table) + while (fli->name != 0) + fli++; if (fli->name != 0) { format_chars += strlen (fli->name); diff --git a/contrib/gcc-4.7/gcc/config/dragonfly-stdint.h b/contrib/gcc-4.7/gcc/config/dragonfly-stdint.h new file mode 100644 index 0000000000..8d4c77d567 --- /dev/null +++ b/contrib/gcc-4.7/gcc/config/dragonfly-stdint.h @@ -0,0 +1,56 @@ +/* Definitions for types for DragonFly systems. + Copyright (C) 2009 Free Software Foundation, Inc. + Contributed by Gerald Pfeifer . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#define SIG_ATOMIC_TYPE "int" + +#define INT8_TYPE "signed char" +#define INT16_TYPE "short int" +#define INT32_TYPE "int" +#define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int") +#define UINT8_TYPE "unsigned char" +#define UINT16_TYPE "short unsigned int" +#define UINT32_TYPE "unsigned int" +#define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") + +#define INT_LEAST8_TYPE INT8_TYPE +#define INT_LEAST16_TYPE INT16_TYPE +#define INT_LEAST32_TYPE INT32_TYPE +#define INT_LEAST64_TYPE INT64_TYPE +#define UINT_LEAST8_TYPE UINT8_TYPE +#define UINT_LEAST16_TYPE UINT16_TYPE +#define UINT_LEAST32_TYPE UINT32_TYPE +#define UINT_LEAST64_TYPE UINT64_TYPE + +#define INT_FAST8_TYPE INT32_TYPE +#define INT_FAST16_TYPE INT32_TYPE +#define INT_FAST32_TYPE INT32_TYPE +#define INT_FAST64_TYPE INT64_TYPE +#define UINT_FAST8_TYPE UINT32_TYPE +#define UINT_FAST16_TYPE UINT32_TYPE +#define UINT_FAST32_TYPE UINT32_TYPE +#define UINT_FAST64_TYPE UINT64_TYPE + +#define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? INT64_TYPE : INT32_TYPE) +#define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? UINT64_TYPE : UINT32_TYPE) diff --git a/contrib/gcc-4.7/gcc/config/dragonfly.h b/contrib/gcc-4.7/gcc/config/dragonfly.h new file mode 100644 index 0000000000..8139adf5cc --- /dev/null +++ b/contrib/gcc-4.7/gcc/config/dragonfly.h @@ -0,0 +1,136 @@ +/* Base configuration file for all DragonFly targets. + Copyright (C) 1999, 2000, 2001, 2007, 2008 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +/* Common DragonFly configuration. + All DragonFly architectures should include this file, which will specify + their commonalities. + Adapted from gcc/config/i386/freebsd-elf.h by + David O'Brien . + Further work by David O'Brien and + Loren J. Rittle . */ + +#undef TARGET_OS_CPP_BUILTINS +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + builtin_define_std ("unix"); \ + builtin_define ("__DragonFly__"); \ + builtin_assert ("system=unix"); \ + builtin_assert ("system=bsd"); \ + builtin_assert ("system=DragonFly"); \ + } \ + while (0) + +#undef CPP_SPEC +#define CPP_SPEC \ + "%(cpp_cpu) %(cpp_arch) %{posix:-D_POSIX_SOURCE}" + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{!shared: \ + %{pg:gcrt1.o%s} \ + %{!pg: \ + %{p:gcrt1.o%s} \ + %{!p: \ + %{profile: gcrt1.o%s} \ + %{!profile: \ + %{pie: Scrt1.o%s;:crt1.o%s}}}}} \ + crti.o%s \ + %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" + +#undef LIB_SPEC +#define LIB_SPEC \ + "%{pthread:-lpthread} -lc" + +#if defined(HAVE_LD_EH_FRAME_HDR) +#define LINK_EH_SPEC "--eh-frame-hdr" +#endif + +/* Provide a LINK_SPEC appropriate for DragonFly. Here we provide support + for the special GCC options -static and -shared, which allow us to + link things in one of these three modes by applying the appropriate + combinations of options at link-time. + + When the -shared link option is used a final link is not being + done. */ + +#define DFBSD_LINK_SPEC \ + "%{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \ + %{v:-V} \ + %{assert*} %{R*} %{rpath*} %{defsym*} \ + %{shared:-Bshareable %{h*} %{soname*}} \ + %{!shared: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ + -dynamic-linker %(dfbsd_dynamic_linker) \ + } \ + %{static:-Bstatic} \ + } \ + %{!static:--hash-style=both} \ + %{symbolic:-Bsymbolic}" + +#undef LINK_SPEC +#define LINK_SPEC DFBSD_LINK_SPEC + +#define DFBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.2" + + +/* Use --as-needed -lgcc_s for eh support. */ +#ifdef HAVE_LD_AS_NEEDED +#define USE_LD_AS_NEEDED 1 +#endif + +/************************[ Target stuff ]***********************************/ + +/* All DragonFly Architectures support the ELF object file format. */ +#undef OBJECT_FORMAT_ELF +#define OBJECT_FORMAT_ELF + +/* Don't assume anything about the header files. */ +#undef NO_IMPLICIT_EXTERN_C +#define NO_IMPLICIT_EXTERN_C 1 + +/* Follow DragonFly's standard headers (, etc...). */ + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef WINT_TYPE +#define WINT_TYPE "int" + +/* + * Profile libraries are found at /usr/lib/profile with standard names + * #define MATH_LIBRARY_PROFILE "m_p" + */ + +/* Code generation parameters. */ + +/* Use periods rather than dollar signs in special g++ assembler names. + This ensures the configuration knows our system correctly so we can link + with libraries compiled with the native cc. */ +#undef NO_DOLLAR_IN_LABEL + +/* Used by libgcc2.c. We support file locking with fcntl / F_SETLKW. + This enables the test coverage code to use file locking when exiting a + program, which avoids race conditions if the program has forked. */ +#define TARGET_POSIX_IO diff --git a/contrib/gcc-4.7/gcc/config/i386/dragonfly.h b/contrib/gcc-4.7/gcc/config/i386/dragonfly.h new file mode 100644 index 0000000000..706cc782ee --- /dev/null +++ b/contrib/gcc-4.7/gcc/config/i386/dragonfly.h @@ -0,0 +1,105 @@ +/* Definitions for Intel 386 running DragonFly with ELF format + Copyright (C) 1996, 2000, 2002, 2004, 2007, 2010, 2011 + Free Software Foundation, Inc. + Contributed by Eric Youngdale. + Modified for stabs-in-ELF by H.J. Lu. + Adapted from GNU/Linux version by John Polstra. + Continued development by David O'Brien + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + + +/* Override the default comment-starter of "/". */ +#undef ASM_COMMENT_START +#define ASM_COMMENT_START "#" + +#undef ASM_APP_ON +#define ASM_APP_ON "#APP\n" + +#undef ASM_APP_OFF +#define ASM_APP_OFF "#NO_APP\n" + +#undef DBX_REGISTER_NUMBER +#define DBX_REGISTER_NUMBER(n) \ + (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n]) + +#undef NO_PROFILE_COUNTERS +#define NO_PROFILE_COUNTERS 1 + +/* Tell final.c that we don't need a label passed to mcount. */ + +#undef MCOUNT_NAME +#define MCOUNT_NAME ".mcount" + +/* Make gcc agree with . */ + +#undef SIZE_TYPE +#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE (TARGET_64BIT ? 32 : BITS_PER_WORD) + +#undef SUBTARGET_EXTRA_SPECS /* i386.h bogusly defines it. */ +#define SUBTARGET_EXTRA_SPECS \ + { "dfbsd_dynamic_linker", DFBSD_DYNAMIC_LINKER } + + +/* A C statement to output to the stdio stream FILE an assembler + command to advance the location counter to a multiple of 1< and std::numeric_limits correct. */ +#undef TARGET_96_ROUND_53_LONG_DOUBLE +#define TARGET_96_ROUND_53_LONG_DOUBLE (!TARGET_64BIT) + +/* Put all *tf routines in libgcc. */ +#undef LIBGCC2_HAS_TF_MODE +#define LIBGCC2_HAS_TF_MODE 1 +#define LIBGCC2_TF_CEXT q +#define TF_SIZE 113 + +/* Static stack checking is supported by means of probes. */ +#define STACK_CHECK_STATIC_BUILTIN 1 + +/* Support for i386 has been removed from DragonFly for several releases */ +#define SUBTARGET32_DEFAULT_CPU "i486" + +#define TARGET_ASM_FILE_END file_end_indicate_exec_stack + diff --git a/contrib/gcc-4.7/gcc/gcc.c b/contrib/gcc-4.7/gcc/gcc.c index cc6a08eb09..d26df1e271 100644 --- a/contrib/gcc-4.7/gcc/gcc.c +++ b/contrib/gcc-4.7/gcc/gcc.c @@ -2126,6 +2126,7 @@ for_each_path (const struct path_prefix *paths, len = strlen (pl->prefix); memcpy (path, pl->prefix, len); +#if 0 /* MACHINE/VERSION isn't used anywhere DragonFly */ /* Look first in MACHINE/VERSION subdirectory. */ if (!skip_multi_dir) { @@ -2134,6 +2135,7 @@ for_each_path (const struct path_prefix *paths, if (ret) break; } +#endif /* Some paths are tried with just the machine (ie. target) subdir. This is used for finding as, ld, etc. */ @@ -3606,6 +3608,7 @@ process_command (unsigned int decoded_options_count, /* FIXME: make_relative_prefix doesn't yet work for VMS. */ if (!gcc_exec_prefix) { +#if 0 /* Never use relative prefix (not bootstrapped) */ gcc_exec_prefix = get_relative_prefix (decoded_options[0].arg, standard_bindir_prefix, standard_exec_prefix); @@ -3614,6 +3617,7 @@ process_command (unsigned int decoded_options_count, standard_libexec_prefix); if (gcc_exec_prefix) xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL)); +#endif } else { @@ -3658,11 +3662,13 @@ process_command (unsigned int decoded_options_count, len -= sizeof ("/lib/gcc/") - 1; } +#if 0 /* Bad Paths */ set_std_prefix (gcc_exec_prefix, len); add_prefix (&exec_prefixes, gcc_libexec_prefix, "GCC", PREFIX_PRIORITY_LAST, 0, 0); add_prefix (&startfile_prefixes, gcc_exec_prefix, "GCC", PREFIX_PRIORITY_LAST, 0, 0); +#endif } /* COMPILER_PATH and LIBRARY_PATH have values @@ -3894,6 +3900,9 @@ process_command (unsigned int decoded_options_count, if (!gcc_exec_prefix) { #ifndef OS2 + add_prefix (&exec_prefixes, standard_libexec_prefix, NULL, + PREFIX_PRIORITY_LAST, 0, 0); +#if 0 /* Bad paths */ add_prefix (&exec_prefixes, standard_libexec_prefix, "GCC", PREFIX_PRIORITY_LAST, 1, 0); add_prefix (&exec_prefixes, standard_libexec_prefix, "BINUTILS", @@ -3901,8 +3910,11 @@ process_command (unsigned int decoded_options_count, add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS", PREFIX_PRIORITY_LAST, 2, 0); #endif +#endif +#if 0 /* Bad paths */ add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS", PREFIX_PRIORITY_LAST, 1, 0); +#endif } gcc_assert (!IS_ABSOLUTE_PATH (tooldir_base_prefix)); @@ -3916,12 +3928,14 @@ process_command (unsigned int decoded_options_count, spec_machine, dir_separator_str, spec_version, dir_separator_str, tooldir_prefix, NULL); +#if 0 /* Bad paths */ add_prefix (&exec_prefixes, concat (tooldir_prefix, "bin", dir_separator_str, NULL), "BINUTILS", PREFIX_PRIORITY_LAST, 0, 0); add_prefix (&startfile_prefixes, concat (tooldir_prefix, "lib", dir_separator_str, NULL), "BINUTILS", PREFIX_PRIORITY_LAST, 0, 1); +#endif #if defined(TARGET_SYSTEM_ROOT_RELOCATABLE) && !defined(VMS) /* If the normal TARGET_SYSTEM_ROOT is inside of $exec_prefix, @@ -6494,9 +6508,7 @@ main (int argc, char **argv) if (print_search_dirs) { - printf (_("install: %s%s\n"), - gcc_exec_prefix ? gcc_exec_prefix : standard_exec_prefix, - gcc_exec_prefix ? "" : machine_suffix); + printf (_("install: %s\n"), STD_EXEC_PATH); printf (_("programs: %s\n"), build_search_list (&exec_prefixes, "", false, false)); printf (_("libraries: %s\n"), diff --git a/contrib/gcc-4.7/gcc/ginclude/stddef.h b/contrib/gcc-4.7/gcc/ginclude/stddef.h index 8a03948ee7..f087a41cdc 100644 --- a/contrib/gcc-4.7/gcc/ginclude/stddef.h +++ b/contrib/gcc-4.7/gcc/ginclude/stddef.h @@ -53,12 +53,21 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see one less case to deal with in the following. */ #if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__) #include +#if !defined(_MACHINE_ANSI_H_) +#if defined(_I386_ANSI_H_) || defined(_X86_64_ANSI_H_) +#define _MACHINE_ANSI_H_ +#endif +#endif #endif /* On FreeBSD 5, machine/ansi.h does not exist anymore... */ #if defined (__FreeBSD__) && (__FreeBSD__ >= 5) #include #endif +#if defined(__DragonFly__) +#include +#endif + /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are defined if the corresponding type is *not* defined. FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. @@ -136,6 +145,7 @@ _TYPE_wchar_t; #ifndef _BSD_PTRDIFF_T_ #ifndef ___int_ptrdiff_t_h #ifndef _GCC_PTRDIFF_T +#ifndef _PTRDIFF_T_DECLARED /* DragonFly */ #define _PTRDIFF_T #define _T_PTRDIFF_ #define _T_PTRDIFF @@ -144,10 +154,12 @@ _TYPE_wchar_t; #define _BSD_PTRDIFF_T_ #define ___int_ptrdiff_t_h #define _GCC_PTRDIFF_T +#define _PTRDIFF_T_DECLARED #ifndef __PTRDIFF_TYPE__ #define __PTRDIFF_TYPE__ long int #endif typedef __PTRDIFF_TYPE__ ptrdiff_t; +#endif /* _PTRDIFF_T_DECLARED */ #endif /* _GCC_PTRDIFF_T */ #endif /* ___int_ptrdiff_t_h */ #endif /* _BSD_PTRDIFF_T_ */ @@ -201,6 +213,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; #define _GCC_SIZE_T #define _SIZET_ #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ + || defined(__DragonFly__) \ || defined(__FreeBSD_kernel__) /* __size_t is a typedef on FreeBSD 5, must not trash it. */ #else @@ -307,7 +320,7 @@ typedef _BSD_RUNE_T_ rune_t; /* FreeBSD 5 can't be handled well using "traditional" logic above since it no longer defines _BSD_RUNE_T_ yet still desires to export rune_t in some cases... */ -#if defined (__FreeBSD__) && (__FreeBSD__ >= 5) +#if defined (__DragonFly__) || (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE) #if __BSD_VISIBLE #ifndef _RUNE_T_DECLARED diff --git a/contrib/gcc-4.7/gcc/tree-inline.c b/contrib/gcc-4.7/gcc/tree-inline.c index 349e0b0186..03182ad0e8 100644 --- a/contrib/gcc-4.7/gcc/tree-inline.c +++ b/contrib/gcc-4.7/gcc/tree-inline.c @@ -3854,7 +3854,8 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) /* Do not warn about not inlined recursive calls. */ && !cgraph_edge_recursive_p (cg_edge) /* Avoid warnings during early inline pass. */ - && cgraph_global_info_ready) + && cgraph_global_info_ready + && reason != CIF_UNLIKELY_CALL) { warning (OPT_Winline, "inlining failed in call to %q+F: %s", fn, _(cgraph_inline_failed_string (reason))); diff --git a/contrib/gcc-4.7/include/libiberty.h b/contrib/gcc-4.7/include/libiberty.h index cacde800ea..76909dd4ef 100644 --- a/contrib/gcc-4.7/include/libiberty.h +++ b/contrib/gcc-4.7/include/libiberty.h @@ -106,7 +106,16 @@ extern int countargv (char**); to find the declaration so provide a fully prototyped one. If it is 1, we found it so don't provide any declaration at all. */ #if !HAVE_DECL_BASENAME -#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (HAVE_DECL_BASENAME) +#if defined (__GNU_LIBRARY__ ) \ + || defined (__linux__) \ + || defined (__DragonFly__) \ + || defined (__FreeBSD__) \ + || defined (__OpenBSD__) \ + || defined (__NetBSD__) \ + || defined (__CYGWIN__) \ + || defined (__CYGWIN32__) \ + || defined (__MINGW32__) \ + || defined (HAVE_DECL_BASENAME) extern char *basename (const char *); #else /* Do not allow basename to be used if there is no prototype seen. We diff --git a/contrib/gcc-4.7/libgcc/config/i386/dragonfly-unwind.h b/contrib/gcc-4.7/libgcc/config/i386/dragonfly-unwind.h new file mode 100644 index 0000000000..b50d2b21d4 --- /dev/null +++ b/contrib/gcc-4.7/libgcc/config/i386/dragonfly-unwind.h @@ -0,0 +1,158 @@ +/* DWARF2 EH unwinding support for DragonFly BSD: AMD x86-64 and x86. + Copyright (C) 2010 John Marino */ + +/* Do code reading to identify a signal frame, and set the frame + state data appropriately. See unwind-dw2.c for the structs. */ + +#include +#include +#include +#include +#include + + +#define REG_NAME(reg) sf_uc.uc_mcontext.mc_## reg + +#ifdef __x86_64__ +#define MD_FALLBACK_FRAME_STATE_FOR x86_64_dragonfly_fallback_frame_state + + +static void +x86_64_sigtramp_range (unsigned char **start, unsigned char **end) +{ + unsigned long ps_strings; + int mib[2]; + size_t len; + + mib[0] = CTL_KERN; + mib[1] = KERN_PS_STRINGS; + len = sizeof (ps_strings); + sysctl (mib, 2, &ps_strings, &len, NULL, 0); + + *start = (unsigned char *)ps_strings - 32; + *end = (unsigned char *)ps_strings; +} + + +static _Unwind_Reason_Code +x86_64_dragonfly_fallback_frame_state +(struct _Unwind_Context *context, _Unwind_FrameState *fs) +{ + unsigned char *pc = context->ra; + unsigned char *sigtramp_start, *sigtramp_end; + struct sigframe *sf; + long new_cfa; + + x86_64_sigtramp_range(&sigtramp_start, &sigtramp_end); + if (pc >= sigtramp_end || pc < sigtramp_start) + return _URC_END_OF_STACK; + + sf = (struct sigframe *) context->cfa; + new_cfa = sf->REG_NAME(rsp); + fs->regs.cfa_how = CFA_REG_OFFSET; + /* Register 7 is rsp */ + fs->regs.cfa_reg = 7; + fs->regs.cfa_offset = new_cfa - (long) context->cfa; + + /* The SVR4 register numbering macros aren't usable in libgcc. */ + fs->regs.reg[0].how = REG_SAVED_OFFSET; + fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(rax) - new_cfa; + fs->regs.reg[1].how = REG_SAVED_OFFSET; + fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(rdx) - new_cfa; + fs->regs.reg[2].how = REG_SAVED_OFFSET; + fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(rcx) - new_cfa; + fs->regs.reg[3].how = REG_SAVED_OFFSET; + fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(rbx) - new_cfa; + fs->regs.reg[4].how = REG_SAVED_OFFSET; + fs->regs.reg[4].loc.offset = (long)&sf->REG_NAME(rsi) - new_cfa; + fs->regs.reg[5].how = REG_SAVED_OFFSET; + fs->regs.reg[5].loc.offset = (long)&sf->REG_NAME(rdi) - new_cfa; + fs->regs.reg[6].how = REG_SAVED_OFFSET; + fs->regs.reg[6].loc.offset = (long)&sf->REG_NAME(rbp) - new_cfa; + fs->regs.reg[8].how = REG_SAVED_OFFSET; + fs->regs.reg[8].loc.offset = (long)&sf->REG_NAME(r8) - new_cfa; + fs->regs.reg[9].how = REG_SAVED_OFFSET; + fs->regs.reg[9].loc.offset = (long)&sf->REG_NAME(r9) - new_cfa; + fs->regs.reg[10].how = REG_SAVED_OFFSET; + fs->regs.reg[10].loc.offset = (long)&sf->REG_NAME(r10) - new_cfa; + fs->regs.reg[11].how = REG_SAVED_OFFSET; + fs->regs.reg[11].loc.offset = (long)&sf->REG_NAME(r11) - new_cfa; + fs->regs.reg[12].how = REG_SAVED_OFFSET; + fs->regs.reg[12].loc.offset = (long)&sf->REG_NAME(r12) - new_cfa; + fs->regs.reg[13].how = REG_SAVED_OFFSET; + fs->regs.reg[13].loc.offset = (long)&sf->REG_NAME(r13) - new_cfa; + fs->regs.reg[14].how = REG_SAVED_OFFSET; + fs->regs.reg[14].loc.offset = (long)&sf->REG_NAME(r14) - new_cfa; + fs->regs.reg[15].how = REG_SAVED_OFFSET; + fs->regs.reg[15].loc.offset = (long)&sf->REG_NAME(r15) - new_cfa; + fs->regs.reg[16].how = REG_SAVED_OFFSET; + fs->regs.reg[16].loc.offset = (long)&sf->REG_NAME(rip) - new_cfa; + fs->retaddr_column = 16; + fs->signal_frame = 1; + return _URC_NO_REASON; +} + +#else /* Next section is for i386 */ + +#define MD_FALLBACK_FRAME_STATE_FOR x86_dragonfly_fallback_frame_state + + +static void +x86_sigtramp_range (unsigned char **start, unsigned char **end) +{ + unsigned long ps_strings; + int mib[2]; + size_t len; + + mib[0] = CTL_KERN; + mib[1] = KERN_PS_STRINGS; + len = sizeof (ps_strings); + sysctl (mib, 2, &ps_strings, &len, NULL, 0); + + *start = (unsigned char *)ps_strings - 128; + *end = (unsigned char *)ps_strings; +} + + +static _Unwind_Reason_Code +x86_dragonfly_fallback_frame_state +(struct _Unwind_Context *context, _Unwind_FrameState *fs) +{ + unsigned char *pc = context->ra; + unsigned char *sigtramp_start, *sigtramp_end; + struct sigframe *sf; + long new_cfa; + + x86_sigtramp_range(&sigtramp_start, &sigtramp_end); + + if (pc >= sigtramp_end || pc < sigtramp_start) + return _URC_END_OF_STACK; + + sf = (struct sigframe *) context->cfa; + new_cfa = sf->REG_NAME(esp); + fs->regs.cfa_how = CFA_REG_OFFSET; + fs->regs.cfa_reg = 4; + fs->regs.cfa_offset = new_cfa - (long) context->cfa; + + /* The SVR4 register numbering macros aren't usable in libgcc. */ + fs->regs.reg[0].how = REG_SAVED_OFFSET; + fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(eax) - new_cfa; + fs->regs.reg[3].how = REG_SAVED_OFFSET; + fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(ebx) - new_cfa; + fs->regs.reg[1].how = REG_SAVED_OFFSET; + fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(ecx) - new_cfa; + fs->regs.reg[2].how = REG_SAVED_OFFSET; + fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(edx) - new_cfa; + fs->regs.reg[6].how = REG_SAVED_OFFSET; + fs->regs.reg[6].loc.offset = (long)&sf->REG_NAME(esi) - new_cfa; + fs->regs.reg[7].how = REG_SAVED_OFFSET; + fs->regs.reg[7].loc.offset = (long)&sf->REG_NAME(edi) - new_cfa; + fs->regs.reg[5].how = REG_SAVED_OFFSET; + fs->regs.reg[5].loc.offset = (long)&sf->REG_NAME(ebp) - new_cfa; + fs->regs.reg[8].how = REG_SAVED_OFFSET; + fs->regs.reg[8].loc.offset = (long)&sf->REG_NAME(eip) - new_cfa; + fs->retaddr_column = 8; + fs->signal_frame = 1; + return _URC_NO_REASON; +} +#endif /* ifdef __x86_64__ */ diff --git a/contrib/gcc-4.7/libgcc/crtstuff.c b/contrib/gcc-4.7/libgcc/crtstuff.c index 5d820fa45a..ce57adc8ac 100644 --- a/contrib/gcc-4.7/libgcc/crtstuff.c +++ b/contrib/gcc-4.7/libgcc/crtstuff.c @@ -81,11 +81,19 @@ call_ ## FUNC (void) \ } #endif +#if defined(TARGET_DL_ITERATE_PHDR) && \ + ( defined(__FreeBSD__) \ + || defined(__OpenBSD__) \ + || defined(__NetBSD__) \ + || defined(__DragonFly__)) +#define BSD_DL_ITERATE_PHDR_AVAILABLE +#endif + #if defined(OBJECT_FORMAT_ELF) \ && !defined(OBJECT_FORMAT_FLAT) \ && defined(HAVE_LD_EH_FRAME_HDR) \ && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \ - && defined(__FreeBSD__) && __FreeBSD__ >= 7 + && defined(BSD_DL_ITERATE_PHDR_AVAILABLE) #include # define USE_PT_GNU_EH_FRAME #endif diff --git a/contrib/gcc-4.7/libgcc/enable-execute-stack-freebsd.c b/contrib/gcc-4.7/libgcc/enable-execute-stack-freebsd.c new file mode 100644 index 0000000000..c8d8c011b0 --- /dev/null +++ b/contrib/gcc-4.7/libgcc/enable-execute-stack-freebsd.c @@ -0,0 +1,58 @@ +/* Implement __enable_execute_stack using mprotect(2). + Copyright (C) 2011, 2012 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + GCC is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +#include +#include +#include + +#define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC) + +extern void __enable_execute_stack (void *); + +void +__enable_execute_stack (void *addr) +{ + static int size; + static long mask; + char *page, *ends; + long page_addr, ends_addr; + + if (size == 0) + { + size = getpagesize (); + mask = ~((long) size - 1); + } + page_addr = (long) addr; + ends_addr = (long) (addr + __LIBGCC_TRAMPOLINE_SIZE__); + + page = (char *) (page_addr & mask); + ends = (char *) ((ends_addr & mask) + size); + + /* + * Note that no errors should be emitted by mprotect; it is considered + * dangerous for library calls to send messages to stdout/stderr. + */ + if (mprotect (page, ends - page, STACK_PROT_RWX) < 0) + abort (); +} diff --git a/contrib/gcc-4.7/libgcc/unwind-dw2-fde-dip.c b/contrib/gcc-4.7/libgcc/unwind-dw2-fde-dip.c index f57dc8c392..266053a2dd 100644 --- a/contrib/gcc-4.7/libgcc/unwind-dw2-fde-dip.c +++ b/contrib/gcc-4.7/libgcc/unwind-dw2-fde-dip.c @@ -54,11 +54,19 @@ #endif #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ - && defined(__FreeBSD__) && __FreeBSD__ >= 7 + && defined(TARGET_DL_ITERATE_PHDR) \ + && (defined(__FreeBSD__) || defined(__DragonFly__)) # define ElfW __ElfN # define USE_PT_GNU_EH_FRAME #endif +#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ + && defined(TARGET_DL_ITERATE_PHDR) \ + && (defined(__OpenBSD__) || defined(__NetBSD__)) +# define ElfW(n) Elf_##n +# define USE_PT_GNU_EH_FRAME +#endif + #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ && defined(TARGET_DL_ITERATE_PHDR) \ && defined(__sun__) && defined(__svr4__) diff --git a/contrib/gcc-4.7/libstdc++-v3/config/locale/dragonfly/c_locale.cc b/contrib/gcc-4.7/libstdc++-v3/config/locale/dragonfly/c_locale.cc new file mode 100644 index 0000000000..0629f256a6 --- /dev/null +++ b/contrib/gcc-4.7/libstdc++-v3/config/locale/dragonfly/c_locale.cc @@ -0,0 +1,300 @@ +// Wrapper for underlying C-language localization -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// +// ISO C++ 14882: 22.8 Standard locale categories. +// + +// Written by Benjamin Kosnik + +#include // For errno +#include // For isinf, finite, finitef, fabs +#include // For strof, strtold +#include +#include +#include +#include + +#ifdef _GLIBCXX_HAVE_IEEEFP_H +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template<> + void + __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err, + const __c_locale&) throw() + { + // Assumes __s formatted for "C" locale. + char* __old = setlocale(LC_ALL, 0); + const size_t __len = strlen(__old) + 1; + char* __sav = new char[__len]; + memcpy(__sav, __old, __len); + setlocale(LC_ALL, "C"); + char* __sanity; + bool __overflow = false; + +#if !__FLT_HAS_INFINITY__ + errno = 0; +#endif + +#ifdef _GLIBCXX_HAVE_STRTOF + __v = strtof(__s, &__sanity); +#else + double __d = strtod(__s, &__sanity); + __v = static_cast(__d); +#ifdef _GLIBCXX_HAVE_FINITEF + if (!finitef (__v)) + __overflow = true; +#elif defined (_GLIBCXX_HAVE_FINITE) + if (!finite (static_cast (__v))) + __overflow = true; +#elif defined (_GLIBCXX_HAVE_ISINF) + if (isinf (static_cast (__v))) + __overflow = true; +#else + if (fabs(__d) > numeric_limits::max()) + __overflow = true; +#endif +#endif // _GLIBCXX_HAVE_STRTOF + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + if (__sanity == __s || *__sanity != '\0') + { + __v = 0.0f; + __err = ios_base::failbit; + } + else if (__overflow +#if __FLT_HAS_INFINITY__ + || __v == numeric_limits::infinity() + || __v == -numeric_limits::infinity() +#else + || ((__v > 1.0f || __v < -1.0f) && errno == ERANGE) +#endif + ) + { + if (__v > 0.0f) + __v = numeric_limits::max(); + else + __v = -numeric_limits::max(); + __err = ios_base::failbit; + } + + setlocale(LC_ALL, __sav); + delete [] __sav; + } + + template<> + void + __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err, + const __c_locale&) throw() + { + // Assumes __s formatted for "C" locale. + char* __old = setlocale(LC_ALL, 0); + const size_t __len = strlen(__old) + 1; + char* __sav = new char[__len]; + memcpy(__sav, __old, __len); + setlocale(LC_ALL, "C"); + char* __sanity; + +#if !__DBL_HAS_INFINITY__ + errno = 0; +#endif + + __v = strtod(__s, &__sanity); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + if (__sanity == __s || *__sanity != '\0') + { + __v = 0.0; + __err = ios_base::failbit; + } + else if ( +#if __DBL_HAS_INFINITY__ + __v == numeric_limits::infinity() + || __v == -numeric_limits::infinity()) +#else + (__v > 1.0 || __v < -1.0) && errno == ERANGE) +#endif + { + if (__v > 0.0) + __v = numeric_limits::max(); + else + __v = -numeric_limits::max(); + __err = ios_base::failbit; + } + + setlocale(LC_ALL, __sav); + delete [] __sav; + } + + template<> + void + __convert_to_v(const char* __s, long double& __v, + ios_base::iostate& __err, const __c_locale&) throw() + { + // Assumes __s formatted for "C" locale. + char* __old = setlocale(LC_ALL, 0); + const size_t __len = strlen(__old) + 1; + char* __sav = new char[__len]; + memcpy(__sav, __old, __len); + setlocale(LC_ALL, "C"); + +#if !__LDBL_HAS_INFINITY__ + errno = 0; +#endif + +#if defined(_GLIBCXX_HAVE_STRTOLD) && !defined(_GLIBCXX_HAVE_BROKEN_STRTOLD) + char* __sanity; + __v = strtold(__s, &__sanity); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + if (__sanity == __s || *__sanity != '\0') +#else + typedef char_traits::int_type int_type; + int __p = sscanf(__s, "%Lf", &__v); + + if (!__p || static_cast(__p) == char_traits::eof()) +#endif + { + __v = 0.0l; + __err = ios_base::failbit; + } + else if ( +#if __LDBL_HAS_INFINITY__ + __v == numeric_limits::infinity() + || __v == -numeric_limits::infinity()) +#else + (__v > 1.0l || __v < -1.0l) && errno == ERANGE) +#endif + { + if (__v > 0.0l) + __v = numeric_limits::max(); + else + __v = -numeric_limits::max(); + __err = ios_base::failbit; + } + + setlocale(LC_ALL, __sav); + delete [] __sav; + } + + + /* DragonFly's implementation of setlocale won't accept something like + "de_DE". According to nls manpage, the expected format is: + language[_territory][.codeset][@modifier], but it seems that both + the _territory and .codeset components are required. + + As an attempt to correct for this, we'll tack on ".UTF-8" if + a period is not detected in the locale string. + + There are no locales with modifiers on DragonFly so if found, they + will just be stripped off silently. e.g "de_DE@euro" will be reduced + to "de_DE". The UTF-8 default would be added after that. + */ + + void + locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s, + __c_locale) + { + const size_t size__s = (__s == NULL) ? 1 : strlen (__s); + const char UTF8[] = ".UTF-8"; + char localspec[size__s + 6 + 1]; + + if (__s == NULL) { + localspec[0] = NULL; + } else { + strcpy (localspec, __s); + char * pch = strchr (localspec, '@'); + if (pch != NULL) + *pch = 0; + + if ( (strchr (__s, '.') == NULL) + && (strcmp (__s, "C") != 0) + && (strcmp (__s, "POSIX") != 0)) + strncat (localspec, UTF8, 6); + } + + const char * result = std::setlocale(LC_ALL, localspec); + + if ((strcmp(result, "C") != 0) && (strcmp (result, localspec) != 0)) + __throw_runtime_error(__N("locale::facet::_S_create_c_locale " + "name not valid")); + __cloc = 0; + } + + void + locale::facet::_S_destroy_c_locale(__c_locale& __cloc) + { __cloc = 0; } + + __c_locale + locale::facet::_S_clone_c_locale(__c_locale&) throw() + { return __c_locale(); } + + __c_locale + locale::facet::_S_lc_ctype_c_locale(__c_locale, const char*) + { return __c_locale(); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] = + { + "LC_CTYPE", + "LC_NUMERIC", + "LC_TIME", + "LC_COLLATE", + "LC_MONETARY", + "LC_MESSAGES" + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + const char* const* const locale::_S_categories = __gnu_cxx::category_names; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +// XXX GLIBCXX_ABI Deprecated +#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT +#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \ + extern "C" void ldbl (void) __attribute__ ((alias (#dbl))) +_GLIBCXX_LDBL_COMPAT(_ZSt14__convert_to_vIdEvPKcRT_RSt12_Ios_IostateRKPi, _ZSt14__convert_to_vIeEvPKcRT_RSt12_Ios_IostateRKPi); +#endif // _GLIBCXX_LONG_DOUBLE_COMPAT diff --git a/contrib/gcc-4.7/libstdc++-v3/config/locale/dragonfly/ctype_members.cc b/contrib/gcc-4.7/libstdc++-v3/config/locale/dragonfly/ctype_members.cc new file mode 100644 index 0000000000..7d06ac7f5c --- /dev/null +++ b/contrib/gcc-4.7/libstdc++-v3/config/locale/dragonfly/ctype_members.cc @@ -0,0 +1,174 @@ +// std::ctype implementation details, GNU version -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// +// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions. +// + +// Written by Benjamin Kosnik + +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ + // NB: The other ctype specializations are in src/locale.cc and + // various /config/os/* files. + + ctype_byname::ctype_byname(const char* __s, size_t __refs) + : ctype(0, false, __refs) + { + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_ctype); + this->_S_create_c_locale(this->_M_c_locale_ctype, __s); + } + } + + ctype_byname::~ctype_byname() + { } + +#ifdef _GLIBCXX_USE_WCHAR_T + ctype::__wmask_type + ctype::_M_convert_to_wmask( + const mask __attribute__((__unused__)) __m) const throw() + { + // DragonFly uses the same codes for 'char' as 'wchar_t', so this routine + // never gets called. + return __wmask_type(); + }; + + wchar_t + ctype::do_toupper(wchar_t __c) const + { return towupper(__c); } + + const wchar_t* + ctype::do_toupper(wchar_t* __lo, const wchar_t* __hi) const + { + while (__lo < __hi) + { + *__lo = towupper(*__lo); + ++__lo; + } + return __hi; + } + + wchar_t + ctype::do_tolower(wchar_t __c) const + { return towlower(__c); } + + const wchar_t* + ctype::do_tolower(wchar_t* __lo, const wchar_t* __hi) const + { + while (__lo < __hi) + { + *__lo = towlower(*__lo); + ++__lo; + } + return __hi; + } + + wchar_t + ctype:: + do_widen(char __c) const + { return _M_widen[static_cast(__c)]; } + + const char* + ctype:: + do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const + { + while (__lo < __hi) + { + *__dest = _M_widen[static_cast(*__lo)]; + ++__lo; + ++__dest; + } + return __hi; + } + + char + ctype:: + do_narrow(wchar_t __wc, char __dfault) const + { + if (__wc >= 0 && __wc < 128 && _M_narrow_ok) + return _M_narrow[__wc]; + const int __c = wctob(__wc); + return (__c == EOF ? __dfault : static_cast(__c)); + } + + const wchar_t* + ctype:: + do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault, + char* __dest) const + { + if (_M_narrow_ok) + while (__lo < __hi) + { + if (*__lo >= 0 && *__lo < 128) + *__dest = _M_narrow[*__lo]; + else + { + const int __c = wctob(*__lo); + *__dest = (__c == EOF ? __dfault : static_cast(__c)); + } + ++__lo; + ++__dest; + } + else + while (__lo < __hi) + { + const int __c = wctob(*__lo); + *__dest = (__c == EOF ? __dfault : static_cast(__c)); + ++__lo; + ++__dest; + } + return __hi; + } + + void + ctype::_M_initialize_ctype() throw() + { + wint_t __i; + for (__i = 0; __i < 128; ++__i) + { + const int __c = wctob(__i); + if (__c == EOF) + break; + else + _M_narrow[__i] = static_cast(__c); + } + if (__i == 128) + _M_narrow_ok = true; + else + _M_narrow_ok = false; + for (size_t __i = 0; + __i < sizeof(_M_widen) / sizeof(wint_t); ++__i) + _M_widen[__i] = btowc(__i); + } +#endif // _GLIBCXX_USE_WCHAR_T +} diff --git a/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/ctype_base.h b/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/ctype_base.h new file mode 100644 index 0000000000..1eeb1932d3 --- /dev/null +++ b/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/ctype_base.h @@ -0,0 +1,60 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2000, 2003, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// +// ISO C++ 14882: 22.1 Locales +// + +// Information as gleaned from /usr/include/ctype.h on DragonFly. +// Full details can be found from git repo at: +// http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/include/ctype.h + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// @brief Base class for ctype. + struct ctype_base + { + // Non-standard typedefs. + typedef const unsigned char* __to_type; + + // NB: Offsets into ctype::_M_table force a particular size + // on the mask type. Because of this, we don't use an enum. + typedef uint16_t mask; + static const mask upper = _CTYPEMASK_U; + static const mask lower = _CTYPEMASK_L; + static const mask alpha = _CTYPEMASK_A; + static const mask digit = _CTYPEMASK_D; + static const mask xdigit = _CTYPEMASK_X; + static const mask space = _CTYPEMASK_S; + static const mask print = _CTYPEMASK_R; + static const mask graph = _CTYPEMASK_G; + static const mask cntrl = _CTYPEMASK_C; + static const mask punct = _CTYPEMASK_P; + static const mask alnum = _CTYPEMASK_A | _CTYPEMASK_D; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/ctype_configure_char.cc b/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/ctype_configure_char.cc new file mode 100644 index 0000000000..30cf4ad6a0 --- /dev/null +++ b/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/ctype_configure_char.cc @@ -0,0 +1,99 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ctype_configure_char.cc */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +// Information as gleaned from /usr/include/ctype.h + + const ctype_base::mask* + ctype::classic_table() throw() + { return 0; } + + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } + + ctype::ctype(const mask* __table, bool __del, size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } + + char + ctype::do_toupper(char __c) const + { return ::toupper((int) __c); } + + const char* + ctype::do_toupper(char* __low, const char* __high) const + { + while (__low < __high) + { + *__low = ::toupper((int) *__low); + ++__low; + } + return __high; + } + + char + ctype::do_tolower(char __c) const + { return ::tolower((int) __c); } + + const char* + ctype::do_tolower(char* __low, const char* __high) const + { + while (__low < __high) + { + *__low = ::tolower((int) *__low); + ++__low; + } + return __high; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/ctype_inline.h b/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/ctype_inline.h new file mode 100644 index 0000000000..96257c8270 --- /dev/null +++ b/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/ctype_inline.h @@ -0,0 +1,127 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2000, 2003, 2004, 2005, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ctype_inline.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) +// functions go in ctype.cc + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + bool + ctype:: + is(mask __m, char __c) const + { return _M_table[(unsigned char)(__c)] & __m; } + + const char* + ctype:: + is(const char* __low, const char* __high, mask* __vec) const + { + while (__low < __high) + *__vec++ = _M_table[*__low++]; + return __high; + } + + const char* + ctype:: + scan_is(mask __m, const char* __low, const char* __high) const + { + while (__low < __high && !this->is(__m, *__low)) + ++__low; + return __low; + } + + const char* + ctype:: + scan_not(mask __m, const char* __low, const char* __high) const + { + while (__low < __high && this->is(__m, *__low) != 0) + ++__low; + return __low; + } + +#ifdef _GLIBCXX_USE_WCHAR_T + inline bool + ctype:: + do_is(mask __m, wchar_t __c) const + { + return __libc_ctype_ [__c + 1] & __m; + } + + inline const wchar_t* + ctype:: + do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const + { + for (; __lo < __hi; ++__vec, ++__lo) + { + mask __m = 0; + if (isupper (*__lo)) __m |= _CTYPEMASK_U; + if (islower (*__lo)) __m |= _CTYPEMASK_L; + if (isdigit (*__lo)) __m |= _CTYPEMASK_D; + if (isspace (*__lo)) __m |= _CTYPEMASK_S; + if (ispunct (*__lo)) __m |= _CTYPEMASK_P; + if (isblank (*__lo)) __m |= _CTYPEMASK_B; + if (iscntrl (*__lo)) __m |= _CTYPEMASK_C; + if (isalpha (*__lo)) __m |= _CTYPEMASK_A; + if (isgraph (*__lo)) __m |= _CTYPEMASK_G; + if (isprint (*__lo)) __m |= _CTYPEMASK_R; + if (isxdigit(*__lo)) __m |= _CTYPEMASK_X; + /* alnum already covered = alpha | digit */ + + *__vec = __m; + } + return __hi; + } + + inline const wchar_t* + ctype:: + do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const + { + while (__lo < __hi && !(__libc_ctype_ [*__lo + 1] & __m)) + ++__lo; + return __lo; + } + + inline const wchar_t* + ctype:: + do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const + { + while (__lo < __hi && (__libc_ctype_ [*__lo + 1] & __m)) + ++__lo; + return __lo; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h b/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h new file mode 100644 index 0000000000..8937490038 --- /dev/null +++ b/contrib/gcc-4.7/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h @@ -0,0 +1,41 @@ +// Specific definitions for BSD -*- C++ -*- + +// Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + + +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 + +// System-specific #define, typedefs, corrections, etc, go here. This +// file will come before all others. + +/* FreeBSD approach, likely a mistake for DragonFly. +#define _GLIBCXX_USE_C99_CHECK 1 +#define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999)) +#define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1 +#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED) +#define _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_CHECK 1 +#define _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC defined _XOPEN_SOURCE +*/ + +#endif