diff options
| author | Koen Kooi <koen@dominion.thruhere.net> | 2010-11-02 22:03:58 +0100 |
|---|---|---|
| committer | Koen Kooi <koen@dominion.thruhere.net> | 2010-11-02 22:12:02 +0100 |
| commit | be10a6b1321f250b1034c7d9d0a8ef18b296eef1 (patch) | |
| tree | 9249025cbfbfbee4cc430d62b27f75301dd4dfde /recipes-devtools/gcc/gcc-4.5/fedora | |
| parent | 93b28937ac67ba46d65f55637e42552e224aa7e2 (diff) | |
| download | meta-openembedded-be10a6b1321f250b1034c7d9d0a8ef18b296eef1.tar.gz | |
angstrom-layers: meta-openembedded: replace poky gcc 4.5 sources with OE ones
This needs further investigation, but for now we can get the tested sources into the poky gcc harness
Signed-off-by: Koen Kooi <k-kooi@ti.com>
Diffstat (limited to 'recipes-devtools/gcc/gcc-4.5/fedora')
14 files changed, 4313 insertions, 0 deletions
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-c++-builtin-redecl.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-c++-builtin-redecl.patch new file mode 100644 index 0000000000..a149eae98e --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-c++-builtin-redecl.patch | |||
| @@ -0,0 +1,114 @@ | |||
| 1 | 2007-10-02 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | * decl.c (duplicate_decls): When redeclaring a builtin function, | ||
| 4 | keep the merged decl builtin whenever types match, even if new | ||
| 5 | decl defines a function. | ||
| 6 | |||
| 7 | * gcc.dg/builtins-65.c: New test. | ||
| 8 | * g++.dg/ext/builtin10.C: New test. | ||
| 9 | |||
| 10 | Index: gcc/cp/decl.c | ||
| 11 | =================================================================== | ||
| 12 | --- gcc/cp/decl.c.orig 2010-04-01 11:48:46.000000000 -0700 | ||
| 13 | +++ gcc/cp/decl.c 2010-06-25 10:10:54.749131719 -0700 | ||
| 14 | @@ -2021,23 +2021,21 @@ | ||
| 15 | DECL_ARGUMENTS (olddecl) = DECL_ARGUMENTS (newdecl); | ||
| 16 | DECL_RESULT (olddecl) = DECL_RESULT (newdecl); | ||
| 17 | } | ||
| 18 | + /* If redeclaring a builtin function, it stays built in. */ | ||
| 19 | + if (types_match && DECL_BUILT_IN (olddecl)) | ||
| 20 | + { | ||
| 21 | + DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl); | ||
| 22 | + DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl); | ||
| 23 | + /* If we're keeping the built-in definition, keep the rtl, | ||
| 24 | + regardless of declaration matches. */ | ||
| 25 | + COPY_DECL_RTL (olddecl, newdecl); | ||
| 26 | + } | ||
| 27 | if (new_defines_function) | ||
| 28 | /* If defining a function declared with other language | ||
| 29 | linkage, use the previously declared language linkage. */ | ||
| 30 | SET_DECL_LANGUAGE (newdecl, DECL_LANGUAGE (olddecl)); | ||
| 31 | else if (types_match) | ||
| 32 | { | ||
| 33 | - /* If redeclaring a builtin function, and not a definition, | ||
| 34 | - it stays built in. */ | ||
| 35 | - if (DECL_BUILT_IN (olddecl)) | ||
| 36 | - { | ||
| 37 | - DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl); | ||
| 38 | - DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl); | ||
| 39 | - /* If we're keeping the built-in definition, keep the rtl, | ||
| 40 | - regardless of declaration matches. */ | ||
| 41 | - COPY_DECL_RTL (olddecl, newdecl); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | DECL_RESULT (newdecl) = DECL_RESULT (olddecl); | ||
| 45 | /* Don't clear out the arguments if we're just redeclaring a | ||
| 46 | function. */ | ||
| 47 | Index: gcc/testsuite/gcc.dg/builtins-65.c | ||
| 48 | =================================================================== | ||
| 49 | --- gcc/testsuite/gcc.dg/builtins-65.c.orig 2009-06-26 02:02:04.000000000 -0700 | ||
| 50 | +++ gcc/testsuite/gcc.dg/builtins-65.c 2010-06-25 10:10:54.784464429 -0700 | ||
| 51 | @@ -1,3 +1,28 @@ | ||
| 52 | +/* { dg-do compile } */ | ||
| 53 | +/* { dg-options "-O2" } */ | ||
| 54 | + | ||
| 55 | +typedef __SIZE_TYPE__ size_t; | ||
| 56 | +extern void __chk_fail (void); | ||
| 57 | +extern int snprintf (char *, size_t, const char *, ...); | ||
| 58 | +extern inline __attribute__((gnu_inline, always_inline)) int snprintf (char *a, size_t b, const char *fmt, ...) | ||
| 59 | +{ | ||
| 60 | + if (__builtin_object_size (a, 0) != -1UL && __builtin_object_size (a, 0) < b) | ||
| 61 | + __chk_fail (); | ||
| 62 | + return __builtin_snprintf (a, b, fmt, __builtin_va_arg_pack ()); | ||
| 63 | +} | ||
| 64 | +extern int snprintf (char *, size_t, const char *, ...) __asm ("mysnprintf"); | ||
| 65 | + | ||
| 66 | +char buf[10]; | ||
| 67 | + | ||
| 68 | +int | ||
| 69 | +main (void) | ||
| 70 | +{ | ||
| 71 | + snprintf (buf, 10, "%d%d\n", 10, 10); | ||
| 72 | + return 0; | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +/* { dg-final { scan-assembler "mysnprintf" } } */ | ||
| 76 | +/* { dg-final { scan-assembler-not "__chk_fail" } } */ | ||
| 77 | /* { dg-do link } */ | ||
| 78 | /* { dg-options "-O2 -ffast-math" } */ | ||
| 79 | /* { dg-require-effective-target c99_runtime } */ | ||
| 80 | Index: gcc/testsuite/g++.dg/ext/builtin10.C | ||
| 81 | =================================================================== | ||
| 82 | --- gcc/testsuite/g++.dg/ext/builtin10.C.orig 2009-02-02 03:27:50.000000000 -0800 | ||
| 83 | +++ gcc/testsuite/g++.dg/ext/builtin10.C 2010-06-25 10:10:54.816467202 -0700 | ||
| 84 | @@ -1,3 +1,30 @@ | ||
| 85 | +// { dg-do compile } | ||
| 86 | +// { dg-options "-O2" } | ||
| 87 | + | ||
| 88 | +typedef __SIZE_TYPE__ size_t; | ||
| 89 | +extern "C" { | ||
| 90 | +extern void __chk_fail (void); | ||
| 91 | +extern int snprintf (char *, size_t, const char *, ...); | ||
| 92 | +extern inline __attribute__((gnu_inline, always_inline)) int snprintf (char *a, size_t b, const char *fmt, ...) | ||
| 93 | +{ | ||
| 94 | + if (__builtin_object_size (a, 0) != -1UL && __builtin_object_size (a, 0) < b) | ||
| 95 | + __chk_fail (); | ||
| 96 | + return __builtin_snprintf (a, b, fmt, __builtin_va_arg_pack ()); | ||
| 97 | +} | ||
| 98 | +extern int snprintf (char *, size_t, const char *, ...) __asm ("mysnprintf"); | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +char buf[10]; | ||
| 102 | + | ||
| 103 | +int | ||
| 104 | +main (void) | ||
| 105 | +{ | ||
| 106 | + snprintf (buf, 10, "%d%d\n", 10, 10); | ||
| 107 | + return 0; | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +// { dg-final { scan-assembler "mysnprintf" } } | ||
| 111 | +// { dg-final { scan-assembler-not "__chk_fail" } } | ||
| 112 | // { dg-do compile { target correct_iso_cpp_string_wchar_protos } } | ||
| 113 | // { dg-options "-O2 -fdump-tree-optimized" } | ||
| 114 | |||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-cpp-pragma.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-cpp-pragma.patch new file mode 100644 index 0000000000..00d37bd7ce --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-cpp-pragma.patch | |||
| @@ -0,0 +1,284 @@ | |||
| 1 | 2008-02-26 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | * c-ppoutput.c (scan_translation_unit): Handle CPP_PRAGMA | ||
| 4 | and CPP_PRAGMA_EOL. | ||
| 5 | * c-pragma.c (pragma_ns_name): New typedef. | ||
| 6 | (registered_pp_pragmas): New variable. | ||
| 7 | (c_pp_lookup_pragma): New function. | ||
| 8 | (c_register_pragma_1): If flag_preprocess_only, do nothing | ||
| 9 | for non-expanded pragmas, for expanded ones push pragma's | ||
| 10 | namespace and name into registered_pp_pragmas vector. | ||
| 11 | (c_invoke_pragma_handler): Register OpenMP pragmas even when | ||
| 12 | flag_preprocess_only, don't register GCC pch_preprocess | ||
| 13 | pragma if flag_preprocess_only. | ||
| 14 | * c-opts.c (c_common_init): Call init_pragma even if | ||
| 15 | flag_preprocess_only. | ||
| 16 | * c-pragma.c (c_pp_lookup_pragma): New prototype. | ||
| 17 | * config/darwin.h (DARWIN_REGISTER_TARGET_PRAGMAS): Don't call | ||
| 18 | cpp_register_pragma if flag_preprocess_only. | ||
| 19 | |||
| 20 | * gcc.dg/gomp/preprocess-1.c: New test. | ||
| 21 | |||
| 22 | --- gcc/c-ppoutput.c.jj 2008-01-26 18:01:16.000000000 +0100 | ||
| 23 | +++ gcc/c-ppoutput.c 2008-02-26 22:54:57.000000000 +0100 | ||
| 24 | @@ -1,6 +1,6 @@ | ||
| 25 | /* Preprocess only, using cpplib. | ||
| 26 | - Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007 | ||
| 27 | - Free Software Foundation, Inc. | ||
| 28 | + Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, | ||
| 29 | + 2008 Free Software Foundation, Inc. | ||
| 30 | Written by Per Bothner, 1994-95. | ||
| 31 | |||
| 32 | This program is free software; you can redistribute it and/or modify it | ||
| 33 | @@ -177,7 +177,24 @@ scan_translation_unit (cpp_reader *pfile | ||
| 34 | avoid_paste = false; | ||
| 35 | print.source = NULL; | ||
| 36 | print.prev = token; | ||
| 37 | - cpp_output_token (token, print.outf); | ||
| 38 | + if (token->type == CPP_PRAGMA) | ||
| 39 | + { | ||
| 40 | + const char *space; | ||
| 41 | + const char *name; | ||
| 42 | + | ||
| 43 | + maybe_print_line (token->src_loc); | ||
| 44 | + fputs ("#pragma ", print.outf); | ||
| 45 | + c_pp_lookup_pragma (token->val.pragma, &space, &name); | ||
| 46 | + if (space) | ||
| 47 | + fprintf (print.outf, "%s %s", space, name); | ||
| 48 | + else | ||
| 49 | + fprintf (print.outf, "%s", name); | ||
| 50 | + print.printed = 1; | ||
| 51 | + } | ||
| 52 | + else if (token->type == CPP_PRAGMA_EOL) | ||
| 53 | + maybe_print_line (token->src_loc); | ||
| 54 | + else | ||
| 55 | + cpp_output_token (token, print.outf); | ||
| 56 | |||
| 57 | if (token->type == CPP_COMMENT) | ||
| 58 | account_for_newlines (token->val.str.text, token->val.str.len); | ||
| 59 | --- gcc/c-pragma.c.jj 2008-02-15 18:43:03.000000000 +0100 | ||
| 60 | +++ gcc/c-pragma.c 2008-02-26 22:59:44.000000000 +0100 | ||
| 61 | @@ -1,6 +1,6 @@ | ||
| 62 | /* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack. | ||
| 63 | Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, | ||
| 64 | - 2006, 2007 Free Software Foundation, Inc. | ||
| 65 | + 2006, 2007, 2008 Free Software Foundation, Inc. | ||
| 66 | |||
| 67 | This file is part of GCC. | ||
| 68 | |||
| 69 | @@ -872,6 +872,61 @@ DEF_VEC_ALLOC_O (pragma_handler, heap); | ||
| 70 | |||
| 71 | static VEC(pragma_handler, heap) *registered_pragmas; | ||
| 72 | |||
| 73 | +typedef struct | ||
| 74 | +{ | ||
| 75 | + const char *space; | ||
| 76 | + const char *name; | ||
| 77 | +} pragma_ns_name; | ||
| 78 | + | ||
| 79 | +DEF_VEC_O (pragma_ns_name); | ||
| 80 | +DEF_VEC_ALLOC_O (pragma_ns_name, heap); | ||
| 81 | + | ||
| 82 | +static VEC(pragma_ns_name, heap) *registered_pp_pragmas; | ||
| 83 | + | ||
| 84 | +struct omp_pragma_def { const char *name; unsigned int id; }; | ||
| 85 | +static const struct omp_pragma_def omp_pragmas[] = { | ||
| 86 | + { "atomic", PRAGMA_OMP_ATOMIC }, | ||
| 87 | + { "barrier", PRAGMA_OMP_BARRIER }, | ||
| 88 | + { "critical", PRAGMA_OMP_CRITICAL }, | ||
| 89 | + { "flush", PRAGMA_OMP_FLUSH }, | ||
| 90 | + { "for", PRAGMA_OMP_FOR }, | ||
| 91 | + { "master", PRAGMA_OMP_MASTER }, | ||
| 92 | + { "ordered", PRAGMA_OMP_ORDERED }, | ||
| 93 | + { "parallel", PRAGMA_OMP_PARALLEL }, | ||
| 94 | + { "section", PRAGMA_OMP_SECTION }, | ||
| 95 | + { "sections", PRAGMA_OMP_SECTIONS }, | ||
| 96 | + { "single", PRAGMA_OMP_SINGLE }, | ||
| 97 | + { "threadprivate", PRAGMA_OMP_THREADPRIVATE } | ||
| 98 | +}; | ||
| 99 | + | ||
| 100 | +void | ||
| 101 | +c_pp_lookup_pragma (unsigned int id, const char **space, const char **name) | ||
| 102 | +{ | ||
| 103 | + const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas); | ||
| 104 | + int i; | ||
| 105 | + | ||
| 106 | + for (i = 0; i < n_omp_pragmas; ++i) | ||
| 107 | + if (omp_pragmas[i].id == id) | ||
| 108 | + { | ||
| 109 | + *space = "omp"; | ||
| 110 | + *name = omp_pragmas[i].name; | ||
| 111 | + return; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + if (id >= PRAGMA_FIRST_EXTERNAL | ||
| 115 | + && (id < PRAGMA_FIRST_EXTERNAL | ||
| 116 | + + VEC_length (pragma_ns_name, registered_pp_pragmas))) | ||
| 117 | + { | ||
| 118 | + *space = VEC_index (pragma_ns_name, registered_pp_pragmas, | ||
| 119 | + id - PRAGMA_FIRST_EXTERNAL)->space; | ||
| 120 | + *name = VEC_index (pragma_ns_name, registered_pp_pragmas, | ||
| 121 | + id - PRAGMA_FIRST_EXTERNAL)->name; | ||
| 122 | + return; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + gcc_unreachable (); | ||
| 126 | +} | ||
| 127 | + | ||
| 128 | /* Front-end wrappers for pragma registration to avoid dragging | ||
| 129 | cpplib.h in almost everywhere. */ | ||
| 130 | |||
| 131 | @@ -881,13 +936,29 @@ c_register_pragma_1 (const char *space, | ||
| 132 | { | ||
| 133 | unsigned id; | ||
| 134 | |||
| 135 | - VEC_safe_push (pragma_handler, heap, registered_pragmas, &handler); | ||
| 136 | - id = VEC_length (pragma_handler, registered_pragmas); | ||
| 137 | - id += PRAGMA_FIRST_EXTERNAL - 1; | ||
| 138 | - | ||
| 139 | - /* The C++ front end allocates 6 bits in cp_token; the C front end | ||
| 140 | - allocates 7 bits in c_token. At present this is sufficient. */ | ||
| 141 | - gcc_assert (id < 64); | ||
| 142 | + if (flag_preprocess_only) | ||
| 143 | + { | ||
| 144 | + pragma_ns_name ns_name; | ||
| 145 | + | ||
| 146 | + if (!allow_expansion) | ||
| 147 | + return; | ||
| 148 | + | ||
| 149 | + ns_name.space = space; | ||
| 150 | + ns_name.name = name; | ||
| 151 | + VEC_safe_push (pragma_ns_name, heap, registered_pp_pragmas, &ns_name); | ||
| 152 | + id = VEC_length (pragma_ns_name, registered_pp_pragmas); | ||
| 153 | + id += PRAGMA_FIRST_EXTERNAL - 1; | ||
| 154 | + } | ||
| 155 | + else | ||
| 156 | + { | ||
| 157 | + VEC_safe_push (pragma_handler, heap, registered_pragmas, &handler); | ||
| 158 | + id = VEC_length (pragma_handler, registered_pragmas); | ||
| 159 | + id += PRAGMA_FIRST_EXTERNAL - 1; | ||
| 160 | + | ||
| 161 | + /* The C++ front end allocates 6 bits in cp_token; the C front end | ||
| 162 | + allocates 7 bits in c_token. At present this is sufficient. */ | ||
| 163 | + gcc_assert (id < 64); | ||
| 164 | + } | ||
| 165 | |||
| 166 | cpp_register_deferred_pragma (parse_in, space, name, id, | ||
| 167 | allow_expansion, false); | ||
| 168 | @@ -921,24 +992,8 @@ c_invoke_pragma_handler (unsigned int id | ||
| 169 | void | ||
| 170 | init_pragma (void) | ||
| 171 | { | ||
| 172 | - if (flag_openmp && !flag_preprocess_only) | ||
| 173 | + if (flag_openmp) | ||
| 174 | { | ||
| 175 | - struct omp_pragma_def { const char *name; unsigned int id; }; | ||
| 176 | - static const struct omp_pragma_def omp_pragmas[] = { | ||
| 177 | - { "atomic", PRAGMA_OMP_ATOMIC }, | ||
| 178 | - { "barrier", PRAGMA_OMP_BARRIER }, | ||
| 179 | - { "critical", PRAGMA_OMP_CRITICAL }, | ||
| 180 | - { "flush", PRAGMA_OMP_FLUSH }, | ||
| 181 | - { "for", PRAGMA_OMP_FOR }, | ||
| 182 | - { "master", PRAGMA_OMP_MASTER }, | ||
| 183 | - { "ordered", PRAGMA_OMP_ORDERED }, | ||
| 184 | - { "parallel", PRAGMA_OMP_PARALLEL }, | ||
| 185 | - { "section", PRAGMA_OMP_SECTION }, | ||
| 186 | - { "sections", PRAGMA_OMP_SECTIONS }, | ||
| 187 | - { "single", PRAGMA_OMP_SINGLE }, | ||
| 188 | - { "threadprivate", PRAGMA_OMP_THREADPRIVATE } | ||
| 189 | - }; | ||
| 190 | - | ||
| 191 | const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas); | ||
| 192 | int i; | ||
| 193 | |||
| 194 | @@ -947,8 +1002,9 @@ init_pragma (void) | ||
| 195 | omp_pragmas[i].id, true, true); | ||
| 196 | } | ||
| 197 | |||
| 198 | - cpp_register_deferred_pragma (parse_in, "GCC", "pch_preprocess", | ||
| 199 | - PRAGMA_GCC_PCH_PREPROCESS, false, false); | ||
| 200 | + if (!flag_preprocess_only) | ||
| 201 | + cpp_register_deferred_pragma (parse_in, "GCC", "pch_preprocess", | ||
| 202 | + PRAGMA_GCC_PCH_PREPROCESS, false, false); | ||
| 203 | |||
| 204 | #ifdef HANDLE_PRAGMA_PACK | ||
| 205 | #ifdef HANDLE_PRAGMA_PACK_WITH_EXPANSION | ||
| 206 | --- gcc/c-opts.c.jj 2008-02-26 22:53:23.000000000 +0100 | ||
| 207 | +++ gcc/c-opts.c 2008-02-26 22:54:57.000000000 +0100 | ||
| 208 | @@ -1,5 +1,5 @@ | ||
| 209 | /* C/ObjC/C++ command line option handling. | ||
| 210 | - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 | ||
| 211 | + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | ||
| 212 | Free Software Foundation, Inc. | ||
| 213 | Contributed by Neil Booth. | ||
| 214 | |||
| 215 | @@ -1239,6 +1239,9 @@ c_common_init (void) | ||
| 216 | if (version_flag) | ||
| 217 | c_common_print_pch_checksum (stderr); | ||
| 218 | |||
| 219 | + /* Has to wait until now so that cpplib has its hash table. */ | ||
| 220 | + init_pragma (); | ||
| 221 | + | ||
| 222 | if (flag_preprocess_only) | ||
| 223 | { | ||
| 224 | finish_options (); | ||
| 225 | @@ -1246,9 +1249,6 @@ c_common_init (void) | ||
| 226 | return false; | ||
| 227 | } | ||
| 228 | |||
| 229 | - /* Has to wait until now so that cpplib has its hash table. */ | ||
| 230 | - init_pragma (); | ||
| 231 | - | ||
| 232 | return true; | ||
| 233 | } | ||
| 234 | |||
| 235 | --- gcc/c-pragma.h.jj 2008-01-26 18:01:16.000000000 +0100 | ||
| 236 | +++ gcc/c-pragma.h 2008-02-26 22:54:57.000000000 +0100 | ||
| 237 | @@ -1,6 +1,6 @@ | ||
| 238 | /* Pragma related interfaces. | ||
| 239 | Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, | ||
| 240 | - 2007 Free Software Foundation, Inc. | ||
| 241 | + 2007, 2008 Free Software Foundation, Inc. | ||
| 242 | |||
| 243 | This file is part of GCC. | ||
| 244 | |||
| 245 | @@ -124,4 +124,6 @@ extern enum cpp_ttype pragma_lex (tree * | ||
| 246 | extern enum cpp_ttype c_lex_with_flags (tree *, location_t *, unsigned char *, | ||
| 247 | int); | ||
| 248 | |||
| 249 | +extern void c_pp_lookup_pragma (unsigned int, const char **, const char **); | ||
| 250 | + | ||
| 251 | #endif /* GCC_C_PRAGMA_H */ | ||
| 252 | --- gcc/config/darwin.h.jj 2008-02-11 14:48:12.000000000 +0100 | ||
| 253 | +++ gcc/config/darwin.h 2008-02-26 22:54:57.000000000 +0100 | ||
| 254 | @@ -892,8 +892,9 @@ enum machopic_addr_class { | ||
| 255 | |||
| 256 | #define DARWIN_REGISTER_TARGET_PRAGMAS() \ | ||
| 257 | do { \ | ||
| 258 | - cpp_register_pragma (parse_in, NULL, "mark", \ | ||
| 259 | - darwin_pragma_ignore, false); \ | ||
| 260 | + if (!flag_preprocess_only) \ | ||
| 261 | + cpp_register_pragma (parse_in, NULL, "mark", \ | ||
| 262 | + darwin_pragma_ignore, false); \ | ||
| 263 | c_register_pragma (0, "options", darwin_pragma_options); \ | ||
| 264 | c_register_pragma (0, "segment", darwin_pragma_ignore); \ | ||
| 265 | c_register_pragma (0, "unused", darwin_pragma_unused); \ | ||
| 266 | --- gcc/testsuite/gcc.dg/gomp/preprocess-1.c.jj 2008-02-26 22:54:57.000000000 +0100 | ||
| 267 | +++ gcc/testsuite/gcc.dg/gomp/preprocess-1.c 2008-02-26 22:54:57.000000000 +0100 | ||
| 268 | @@ -0,0 +1,16 @@ | ||
| 269 | +/* { dg-do preprocess } */ | ||
| 270 | + | ||
| 271 | +void foo (void) | ||
| 272 | +{ | ||
| 273 | + int i1, j1, k1; | ||
| 274 | +#define p parallel | ||
| 275 | +#define P(x) private (x##1) | ||
| 276 | +#define S(x) shared (x##1) | ||
| 277 | +#define F(x) firstprivate (x##1) | ||
| 278 | +#pragma omp p P(i) \ | ||
| 279 | + S(j) \ | ||
| 280 | + F(k) | ||
| 281 | + ; | ||
| 282 | +} | ||
| 283 | + | ||
| 284 | +/* { dg-final { scan-file preprocess-1.i "(^|\n)#pragma omp parallel private \\(i1\\) shared \\(j1\\) firstprivate \\(k1\\)($|\n)" } } */ | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-i386-libgomp.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-i386-libgomp.patch new file mode 100644 index 0000000000..a588db28e8 --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-i386-libgomp.patch | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | Build i386.rpm libgomp and libsupc++.a(guard.o) as i486+, pre-i486 | ||
| 2 | hardware isn't supported because NPTL doesn't support it anyway. | ||
| 3 | |||
| 4 | Index: libgomp/configure.tgt | ||
| 5 | =================================================================== | ||
| 6 | --- libgomp/configure.tgt.orig 2010-01-28 13:47:59.000000000 -0800 | ||
| 7 | +++ libgomp/configure.tgt 2010-06-25 10:32:26.706135558 -0700 | ||
| 8 | @@ -48,14 +48,14 @@ | ||
| 9 | ;; | ||
| 10 | |||
| 11 | # Note that bare i386 is not included here. We need cmpxchg. | ||
| 12 | - i[456]86-*-linux*) | ||
| 13 | + i[3456]86-*-linux*) | ||
| 14 | config_path="linux/x86 linux posix" | ||
| 15 | case " ${CC} ${CFLAGS} " in | ||
| 16 | *" -m64 "*) | ||
| 17 | ;; | ||
| 18 | *) | ||
| 19 | if test -z "$with_arch"; then | ||
| 20 | - XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}" | ||
| 21 | + XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic" | ||
| 22 | fi | ||
| 23 | esac | ||
| 24 | ;; | ||
| 25 | @@ -67,7 +67,7 @@ | ||
| 26 | config_path="linux/x86 linux posix" | ||
| 27 | case " ${CC} ${CFLAGS} " in | ||
| 28 | *" -m32 "*) | ||
| 29 | - XCFLAGS="${XCFLAGS} -march=i486 -mtune=i686" | ||
| 30 | + XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic" | ||
| 31 | ;; | ||
| 32 | esac | ||
| 33 | ;; | ||
| 34 | Index: libstdc++-v3/libsupc++/guard.cc | ||
| 35 | =================================================================== | ||
| 36 | --- libstdc++-v3/libsupc++/guard.cc.orig 2009-11-09 14:09:30.000000000 -0800 | ||
| 37 | +++ libstdc++-v3/libsupc++/guard.cc 2010-06-25 10:32:26.710135964 -0700 | ||
| 38 | @@ -30,6 +30,27 @@ | ||
| 39 | #include <new> | ||
| 40 | #include <ext/atomicity.h> | ||
| 41 | #include <ext/concurrence.h> | ||
| 42 | +#if defined __i386__ && !defined _GLIBCXX_ATOMIC_BUILTINS | ||
| 43 | +# define _GLIBCXX_ATOMIC_BUILTINS 1 | ||
| 44 | +# define __sync_val_compare_and_swap(a, b, c) \ | ||
| 45 | + ({ \ | ||
| 46 | + typedef char sltast[sizeof (*a) == sizeof (int) ? 1 : -1]; \ | ||
| 47 | + int sltas; \ | ||
| 48 | + __asm __volatile ("lock; cmpxchgl %3, (%1)" \ | ||
| 49 | + : "=a" (sltas) \ | ||
| 50 | + : "r" (a), "0" (b), "r" (c) : "memory"); \ | ||
| 51 | + sltas; \ | ||
| 52 | + }) | ||
| 53 | +# define __sync_lock_test_and_set(a, b) \ | ||
| 54 | + ({ \ | ||
| 55 | + typedef char sltast[sizeof (*a) == sizeof (int) ? 1 : -1]; \ | ||
| 56 | + int sltas; \ | ||
| 57 | + __asm __volatile ("xchgl (%1), %0" \ | ||
| 58 | + : "=r" (sltas) \ | ||
| 59 | + : "r" (a), "0" (b) : "memory"); \ | ||
| 60 | + sltas; \ | ||
| 61 | + }) | ||
| 62 | +#endif | ||
| 63 | #if defined(__GTHREADS) && defined(__GTHREAD_HAS_COND) \ | ||
| 64 | && defined(_GLIBCXX_ATOMIC_BUILTINS_4) && defined(_GLIBCXX_HAVE_LINUX_FUTEX) | ||
| 65 | # include <climits> | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-ia64-libunwind.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-ia64-libunwind.patch new file mode 100644 index 0000000000..cad13d1228 --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-ia64-libunwind.patch | |||
| @@ -0,0 +1,550 @@ | |||
| 1 | 2004-11-27 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | * config.gcc (ia64*-*-linux*): If native and libelf is installed, | ||
| 4 | use ia64/t-glibc-no-libunwind instead of the other t-*unwind* | ||
| 5 | fragments. | ||
| 6 | * config/ia64/t-glibc-no-libunwind: New file. | ||
| 7 | * config/ia64/change-symver.c: New file. | ||
| 8 | * config/ia64/unwind-ia64.c: If USE_SYMVER_GLOBAL and SHARED, | ||
| 9 | define _Unwind_* to __symverglobal_Unwind_*. | ||
| 10 | (alias): Undefine. | ||
| 11 | (symverglobal): Define. Use it on _Unwind_*. | ||
| 12 | * config/ia64/mkmap-symver-multi.awk: New file. | ||
| 13 | * config/ia64/libgcc-ia64-no-libunwind.ver: New file. | ||
| 14 | |||
| 15 | Index: gcc/config.gcc | ||
| 16 | =================================================================== | ||
| 17 | --- gcc/config.gcc.orig 2010-04-07 03:34:00.000000000 -0700 | ||
| 18 | +++ gcc/config.gcc 2010-06-25 10:15:25.133131055 -0700 | ||
| 19 | @@ -1457,9 +1457,16 @@ | ||
| 20 | ;; | ||
| 21 | ia64*-*-linux*) | ||
| 22 | tm_file="${tm_file} dbxelf.h elfos.h svr4.h linux.h glibc-stdint.h ia64/sysv4.h ia64/linux.h" | ||
| 23 | - tmake_file="${tmake_file} ia64/t-ia64 t-libunwind ia64/t-glibc" | ||
| 24 | - if test x$with_system_libunwind != xyes ; then | ||
| 25 | - tmake_file="${tmake_file} t-libunwind-elf ia64/t-glibc-libunwind" | ||
| 26 | + tmake_file="${tmake_file} ia64/t-ia64" | ||
| 27 | + if test x${target} = x${host} && test x${target} = x${build} \ | ||
| 28 | + && grep gelf_getverdef /usr/include/gelf.h > /dev/null 2>&1 \ | ||
| 29 | + && test -f /usr/lib/libelf.so; then | ||
| 30 | + tmake_file="${tmake_file} ia64/t-glibc-no-libunwind" | ||
| 31 | + else | ||
| 32 | + tmake_file="${tmake_file} t-libunwind ia64/t-glibc" | ||
| 33 | + if test x$with_system_libunwind != xyes ; then | ||
| 34 | + tmake_file="${tmake_file} t-libunwind-elf ia64/t-glibc-libunwind" | ||
| 35 | + fi | ||
| 36 | fi | ||
| 37 | target_cpu_default="MASK_GNU_AS|MASK_GNU_LD" | ||
| 38 | extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtfastmath.o" | ||
| 39 | Index: gcc/config/ia64/t-glibc-no-libunwind | ||
| 40 | =================================================================== | ||
| 41 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
| 42 | +++ gcc/config/ia64/t-glibc-no-libunwind 2010-06-25 10:14:32.521880765 -0700 | ||
| 43 | @@ -0,0 +1,30 @@ | ||
| 44 | +# Don't use system libunwind library on IA-64 GLIBC based system, | ||
| 45 | +# but make _Unwind_* symbols unversioned, so that created programs | ||
| 46 | +# are usable even when libgcc_s uses libunwind. | ||
| 47 | +LIB2ADDEH += $(srcdir)/config/ia64/fde-glibc.c | ||
| 48 | +SHLIB_MAPFILES += $(srcdir)/config/ia64/libgcc-ia64-no-libunwind.ver | ||
| 49 | +SHLIB_MKMAP = $(srcdir)/config/ia64/mkmap-symver-multi.awk | ||
| 50 | + | ||
| 51 | +SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \ | ||
| 52 | + -Wl,--soname=$(SHLIB_SONAME) \ | ||
| 53 | + -Wl,--version-script=$(SHLIB_MAP) \ | ||
| 54 | + -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ $(SHLIB_OBJS) -lc && \ | ||
| 55 | + rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \ | ||
| 56 | + if [ -f $(SHLIB_DIR)/$(SHLIB_SONAME) ]; then \ | ||
| 57 | + mv -f $(SHLIB_DIR)/$(SHLIB_SONAME) \ | ||
| 58 | + $(SHLIB_DIR)/$(SHLIB_SONAME).backup; \ | ||
| 59 | + else true; fi && \ | ||
| 60 | + gcc -O2 -o $(SHLIB_DIR)/$(SHLIB_SONAME).tweak \ | ||
| 61 | + $$(gcc_srcdir)/config/ia64/change-symver.c -lelf && \ | ||
| 62 | + $(SHLIB_DIR)/$(SHLIB_SONAME).tweak $(SHLIB_DIR)/$(SHLIB_SONAME).tmp \ | ||
| 63 | + GCC_3.4.2 _GLOBAL_ \ | ||
| 64 | + _Unwind_GetGR _Unwind_RaiseException _Unwind_GetRegionStart _Unwind_SetIP \ | ||
| 65 | + _Unwind_GetIP _Unwind_GetLanguageSpecificData _Unwind_Resume \ | ||
| 66 | + _Unwind_DeleteException _Unwind_SetGR _Unwind_ForcedUnwind \ | ||
| 67 | + _Unwind_Backtrace _Unwind_FindEnclosingFunction _Unwind_GetCFA \ | ||
| 68 | + _Unwind_Resume_or_Rethrow _Unwind_GetBSP && \ | ||
| 69 | + rm -f $(SHLIB_DIR)/$(SHLIB_SONAME).tweak && \ | ||
| 70 | + mv $(SHLIB_DIR)/$(SHLIB_SONAME).tmp $(SHLIB_DIR)/$(SHLIB_SONAME) && \ | ||
| 71 | + $(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK) | ||
| 72 | + | ||
| 73 | +TARGET_LIBGCC2_CFLAGS += -DUSE_SYMVER_GLOBAL | ||
| 74 | Index: gcc/config/ia64/change-symver.c | ||
| 75 | =================================================================== | ||
| 76 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
| 77 | +++ gcc/config/ia64/change-symver.c 2010-06-25 10:14:32.521880765 -0700 | ||
| 78 | @@ -0,0 +1,211 @@ | ||
| 79 | +#define _GNU_SOURCE 1 | ||
| 80 | +#define _FILE_OFFSET_BITS 64 | ||
| 81 | +#include <endian.h> | ||
| 82 | +#include <errno.h> | ||
| 83 | +#include <error.h> | ||
| 84 | +#include <fcntl.h> | ||
| 85 | +#include <fnmatch.h> | ||
| 86 | +#include <gelf.h> | ||
| 87 | +#include <stdlib.h> | ||
| 88 | +#include <string.h> | ||
| 89 | +#include <unistd.h> | ||
| 90 | + | ||
| 91 | +int | ||
| 92 | +compute_veridx (const char *name, Elf *elf, Elf_Data *verd, GElf_Shdr *verd_shdr) | ||
| 93 | +{ | ||
| 94 | + if (strcmp (name, "_GLOBAL_") == 0) | ||
| 95 | + return 1; | ||
| 96 | + | ||
| 97 | + int cnt; | ||
| 98 | + size_t offset = 0; | ||
| 99 | + for (cnt = verd_shdr->sh_info; --cnt >= 0; ) | ||
| 100 | + { | ||
| 101 | + GElf_Verdef defmem; | ||
| 102 | + GElf_Verdef *def; | ||
| 103 | + GElf_Verdaux auxmem; | ||
| 104 | + GElf_Verdaux *aux; | ||
| 105 | + unsigned int auxoffset; | ||
| 106 | + | ||
| 107 | + /* Get the data at the next offset. */ | ||
| 108 | + def = gelf_getverdef (verd, offset, &defmem); | ||
| 109 | + if (def == NULL) | ||
| 110 | + break; | ||
| 111 | + | ||
| 112 | + auxoffset = offset + def->vd_aux; | ||
| 113 | + aux = gelf_getverdaux (verd, auxoffset, &auxmem); | ||
| 114 | + if (aux == NULL) | ||
| 115 | + break; | ||
| 116 | + | ||
| 117 | + if (strcmp (name, elf_strptr (elf, verd_shdr->sh_link, | ||
| 118 | + aux->vda_name)) == 0) | ||
| 119 | + return def->vd_ndx; | ||
| 120 | + | ||
| 121 | + /* Find the next offset. */ | ||
| 122 | + offset += def->vd_next; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + return -1; | ||
| 126 | +} | ||
| 127 | + | ||
| 128 | +int | ||
| 129 | +main (int argc, char **argv) | ||
| 130 | +{ | ||
| 131 | + if (argc < 4) | ||
| 132 | + error (1, 0, "Usage: change_symver library from_symver to_symver symbol...\nExample: change_symver libfoo.so FOO_1.0 *global* bar baz"); | ||
| 133 | + | ||
| 134 | + const char *fname = argv[1]; | ||
| 135 | + | ||
| 136 | + /* Open the file. */ | ||
| 137 | + int fd; | ||
| 138 | + fd = open (fname, O_RDWR); | ||
| 139 | + if (fd == -1) | ||
| 140 | + error (1, errno, fname); | ||
| 141 | + | ||
| 142 | + elf_version (EV_CURRENT); | ||
| 143 | + | ||
| 144 | + /* Now get the ELF descriptor. */ | ||
| 145 | + Elf *elf = elf_begin (fd, ELF_C_READ_MMAP, NULL); | ||
| 146 | + if (elf == NULL || elf_kind (elf) != ELF_K_ELF) | ||
| 147 | + error (1, 0, "Couldn't open %s: %s", fname, elf_errmsg (-1)); | ||
| 148 | + | ||
| 149 | + size_t shstrndx; | ||
| 150 | + /* Get the section header string table index. */ | ||
| 151 | + if (elf_getshstrndx (elf, &shstrndx) < 0) | ||
| 152 | + error (1, 0, "cannot get shstrndx from %s", fname); | ||
| 153 | + | ||
| 154 | + GElf_Ehdr ehdr_mem; | ||
| 155 | + GElf_Ehdr *ehdr; | ||
| 156 | + | ||
| 157 | + /* We need the ELF header in a few places. */ | ||
| 158 | + ehdr = gelf_getehdr (elf, &ehdr_mem); | ||
| 159 | + if (ehdr == NULL) | ||
| 160 | + error (1, 0, "couldn't get ELF headers %s: %s", fname, elf_errmsg (-1)); | ||
| 161 | + | ||
| 162 | + Elf_Scn *scn = NULL; | ||
| 163 | + GElf_Shdr shdr_mem, verd_shdr, ver_shdr, dynsym_shdr; | ||
| 164 | + Elf_Data *ver = NULL, *verd = NULL, *dynsym = NULL; | ||
| 165 | + | ||
| 166 | + while ((scn = elf_nextscn (elf, scn)) != NULL) | ||
| 167 | + { | ||
| 168 | + GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); | ||
| 169 | + | ||
| 170 | + if (shdr == NULL) | ||
| 171 | + error (1, 0, "couldn't get shdr from %s", fname); | ||
| 172 | + | ||
| 173 | + if ((shdr->sh_flags & SHF_ALLOC) != 0) | ||
| 174 | + { | ||
| 175 | + const char *name = elf_strptr (elf, shstrndx, shdr->sh_name); | ||
| 176 | + Elf_Data **p; | ||
| 177 | + | ||
| 178 | + if (strcmp (name, ".gnu.version") == 0) | ||
| 179 | + { | ||
| 180 | + p = &ver; | ||
| 181 | + ver_shdr = *shdr; | ||
| 182 | + } | ||
| 183 | + else if (strcmp (name, ".gnu.version_d") == 0) | ||
| 184 | + { | ||
| 185 | + p = &verd; | ||
| 186 | + verd_shdr = *shdr; | ||
| 187 | + } | ||
| 188 | + else if (strcmp (name, ".dynsym") == 0) | ||
| 189 | + { | ||
| 190 | + p = &dynsym; | ||
| 191 | + dynsym_shdr = *shdr; | ||
| 192 | + } | ||
| 193 | + else | ||
| 194 | + continue; | ||
| 195 | + | ||
| 196 | + if (*p != NULL) | ||
| 197 | + error (1, 0, "Two %s sections in %s", name, fname); | ||
| 198 | + *p = elf_getdata (scn, NULL); | ||
| 199 | + if (*p == NULL || elf_getdata (scn, *p) != NULL) | ||
| 200 | + error (1, 0, "No data or non-contiguous data in %s section in %s", | ||
| 201 | + name, fname); | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + if (ver == NULL || verd == NULL || dynsym == NULL) | ||
| 206 | + error (1, 0, "Couldn't find one of the needed sections in %s", fname); | ||
| 207 | + | ||
| 208 | + int from_idx = compute_veridx (argv[2], elf, verd, &verd_shdr); | ||
| 209 | + if (from_idx == -1) | ||
| 210 | + error (1, 0, "Could not find symbol version %s in %s", argv[2], fname); | ||
| 211 | + | ||
| 212 | + int to_idx = compute_veridx (argv[3], elf, verd, &verd_shdr); | ||
| 213 | + if (to_idx == -1) | ||
| 214 | + error (1, 0, "Could not find symbol version %s in %s", argv[3], fname); | ||
| 215 | + | ||
| 216 | + if (dynsym_shdr.sh_entsize != gelf_fsize (elf, ELF_T_SYM, 1, ehdr->e_version) | ||
| 217 | + || dynsym_shdr.sh_size % dynsym_shdr.sh_entsize | ||
| 218 | + || ver_shdr.sh_entsize != 2 | ||
| 219 | + || (ver_shdr.sh_size & 1) | ||
| 220 | + || dynsym_shdr.sh_size / dynsym_shdr.sh_entsize != ver_shdr.sh_size / 2) | ||
| 221 | + error (1, 0, "Unexpected sh_size or sh_entsize in %s", fname); | ||
| 222 | + | ||
| 223 | + size_t nentries = ver_shdr.sh_size / 2; | ||
| 224 | + size_t cnt; | ||
| 225 | + GElf_Versym array[nentries]; | ||
| 226 | + for (cnt = 0; cnt < nentries; ++cnt) | ||
| 227 | + { | ||
| 228 | + GElf_Versym vsymmem; | ||
| 229 | + GElf_Versym *vsym; | ||
| 230 | + | ||
| 231 | + vsym = gelf_getversym (ver, cnt, &vsymmem); | ||
| 232 | + if (vsym == NULL) | ||
| 233 | + error (1, 0, "gelt_getversym failed in %s: %s", fname, elf_errmsg (-1)); | ||
| 234 | + | ||
| 235 | + array[cnt] = *vsym; | ||
| 236 | + if (*vsym != from_idx) | ||
| 237 | + continue; | ||
| 238 | + | ||
| 239 | + GElf_Sym sym_mem; | ||
| 240 | + GElf_Sym *sym; | ||
| 241 | + sym = gelf_getsym (dynsym, cnt, &sym_mem); | ||
| 242 | + if (sym == NULL) | ||
| 243 | + error (1, 0, "gelt_getsym failed in %s: %s", fname, elf_errmsg (-1)); | ||
| 244 | + | ||
| 245 | + const char *name = elf_strptr (elf, dynsym_shdr.sh_link, sym->st_name); | ||
| 246 | + | ||
| 247 | + int argn; | ||
| 248 | + for (argn = 4; argn < argc; ++argn) | ||
| 249 | + if (fnmatch (argv[argn], name, 0) == 0) | ||
| 250 | + { | ||
| 251 | + array[cnt] = to_idx; | ||
| 252 | + break; | ||
| 253 | + } | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | + if (sizeof (array[0]) != 2) | ||
| 257 | + abort (); | ||
| 258 | + | ||
| 259 | +#if __BYTE_ORDER == __LITTLE_ENDIAN | ||
| 260 | + if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) | ||
| 261 | + ; | ||
| 262 | + else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) | ||
| 263 | +#elif __BYTE_ORDER == __BIG_ENDIAN | ||
| 264 | + if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) | ||
| 265 | + ; | ||
| 266 | + else if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) | ||
| 267 | +#else | ||
| 268 | +# error Unsupported endianity | ||
| 269 | +#endif | ||
| 270 | + { | ||
| 271 | + for (cnt = 0; cnt < nentries; ++cnt) | ||
| 272 | + array[cnt] = ((array[cnt] & 0xff) << 8) | ((array[cnt] & 0xff00) >> 8); | ||
| 273 | + } | ||
| 274 | + else | ||
| 275 | + error (1, 0, "Unknown EI_DATA %d in %s", ehdr->e_ident[EI_DATA], fname); | ||
| 276 | + | ||
| 277 | + if (elf_end (elf) != 0) | ||
| 278 | + error (1, 0, "couldn't close %s: %s", fname, elf_errmsg (-1)); | ||
| 279 | + | ||
| 280 | + if (lseek (fd, ver_shdr.sh_offset, SEEK_SET) != (off_t) ver_shdr.sh_offset) | ||
| 281 | + error (1, 0, "failed to seek to %zd in %s", (size_t) ver_shdr.sh_offset, | ||
| 282 | + fname); | ||
| 283 | + | ||
| 284 | + if (write (fd, array, 2 * nentries) != (ssize_t) (2 * nentries)) | ||
| 285 | + error (1, 0, "failed to write .gnu.version section into %s", fname); | ||
| 286 | + | ||
| 287 | + close (fd); | ||
| 288 | + return 0; | ||
| 289 | +} | ||
| 290 | Index: gcc/config/ia64/unwind-ia64.c | ||
| 291 | =================================================================== | ||
| 292 | --- gcc/config/ia64/unwind-ia64.c.orig 2009-09-07 08:41:52.000000000 -0700 | ||
| 293 | +++ gcc/config/ia64/unwind-ia64.c 2010-06-25 10:14:32.521880765 -0700 | ||
| 294 | @@ -48,6 +48,51 @@ | ||
| 295 | #define MD_UNW_COMPATIBLE_PERSONALITY_P(HEADER) 1 | ||
| 296 | #endif | ||
| 297 | |||
| 298 | +#if defined (USE_SYMVER_GLOBAL) && defined (SHARED) | ||
| 299 | +extern _Unwind_Reason_Code __symverglobal_Unwind_Backtrace | ||
| 300 | + (_Unwind_Trace_Fn, void *); | ||
| 301 | +extern void __symverglobal_Unwind_DeleteException | ||
| 302 | + (struct _Unwind_Exception *); | ||
| 303 | +extern void * __symverglobal_Unwind_FindEnclosingFunction (void *); | ||
| 304 | +extern _Unwind_Reason_Code __symverglobal_Unwind_ForcedUnwind | ||
| 305 | + (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *); | ||
| 306 | +extern _Unwind_Word __symverglobal_Unwind_GetCFA | ||
| 307 | + (struct _Unwind_Context *); | ||
| 308 | +extern _Unwind_Word __symverglobal_Unwind_GetBSP | ||
| 309 | + (struct _Unwind_Context *); | ||
| 310 | +extern _Unwind_Word __symverglobal_Unwind_GetGR | ||
| 311 | + (struct _Unwind_Context *, int ); | ||
| 312 | +extern _Unwind_Ptr __symverglobal_Unwind_GetIP (struct _Unwind_Context *); | ||
| 313 | +extern void *__symverglobal_Unwind_GetLanguageSpecificData | ||
| 314 | + (struct _Unwind_Context *); | ||
| 315 | +extern _Unwind_Ptr __symverglobal_Unwind_GetRegionStart | ||
| 316 | + (struct _Unwind_Context *); | ||
| 317 | +extern _Unwind_Reason_Code __symverglobal_Unwind_RaiseException | ||
| 318 | + (struct _Unwind_Exception *); | ||
| 319 | +extern void __symverglobal_Unwind_Resume (struct _Unwind_Exception *); | ||
| 320 | +extern _Unwind_Reason_Code __symverglobal_Unwind_Resume_or_Rethrow | ||
| 321 | + (struct _Unwind_Exception *); | ||
| 322 | +extern void __symverglobal_Unwind_SetGR | ||
| 323 | + (struct _Unwind_Context *, int, _Unwind_Word); | ||
| 324 | +extern void __symverglobal_Unwind_SetIP | ||
| 325 | + (struct _Unwind_Context *, _Unwind_Ptr); | ||
| 326 | +#define _Unwind_Backtrace __symverglobal_Unwind_Backtrace | ||
| 327 | +#define _Unwind_DeleteException __symverglobal_Unwind_DeleteException | ||
| 328 | +#define _Unwind_FindEnclosingFunction __symverglobal_Unwind_FindEnclosingFunction | ||
| 329 | +#define _Unwind_ForcedUnwind __symverglobal_Unwind_ForcedUnwind | ||
| 330 | +#define _Unwind_GetBSP __symverglobal_Unwind_GetBSP | ||
| 331 | +#define _Unwind_GetCFA __symverglobal_Unwind_GetCFA | ||
| 332 | +#define _Unwind_GetGR __symverglobal_Unwind_GetGR | ||
| 333 | +#define _Unwind_GetIP __symverglobal_Unwind_GetIP | ||
| 334 | +#define _Unwind_GetLanguageSpecificData __symverglobal_Unwind_GetLanguageSpecificData | ||
| 335 | +#define _Unwind_GetRegionStart __symverglobal_Unwind_GetRegionStart | ||
| 336 | +#define _Unwind_RaiseException __symverglobal_Unwind_RaiseException | ||
| 337 | +#define _Unwind_Resume __symverglobal_Unwind_Resume | ||
| 338 | +#define _Unwind_Resume_or_Rethrow __symverglobal_Unwind_Resume_or_Rethrow | ||
| 339 | +#define _Unwind_SetGR __symverglobal_Unwind_SetGR | ||
| 340 | +#define _Unwind_SetIP __symverglobal_Unwind_SetIP | ||
| 341 | +#endif | ||
| 342 | + | ||
| 343 | enum unw_application_register | ||
| 344 | { | ||
| 345 | UNW_AR_BSP, | ||
| 346 | @@ -2457,4 +2502,44 @@ | ||
| 347 | alias (_Unwind_SetIP); | ||
| 348 | #endif | ||
| 349 | |||
| 350 | +#if defined (USE_SYMVER_GLOBAL) && defined (SHARED) | ||
| 351 | +#undef alias | ||
| 352 | +#define symverglobal(name, version) \ | ||
| 353 | +__typeof (__symverglobal##name) __symverlocal##name \ | ||
| 354 | + __attribute__ ((alias ("__symverglobal" #name))); \ | ||
| 355 | +__asm__ (".symver __symverglobal" #name"," #name "@@GCC_3.4.2");\ | ||
| 356 | +__asm__ (".symver __symverlocal" #name"," #name "@" #version) | ||
| 357 | + | ||
| 358 | +#undef _Unwind_Backtrace | ||
| 359 | +#undef _Unwind_DeleteException | ||
| 360 | +#undef _Unwind_FindEnclosingFunction | ||
| 361 | +#undef _Unwind_ForcedUnwind | ||
| 362 | +#undef _Unwind_GetBSP | ||
| 363 | +#undef _Unwind_GetCFA | ||
| 364 | +#undef _Unwind_GetGR | ||
| 365 | +#undef _Unwind_GetIP | ||
| 366 | +#undef _Unwind_GetLanguageSpecificData | ||
| 367 | +#undef _Unwind_GetRegionStart | ||
| 368 | +#undef _Unwind_RaiseException | ||
| 369 | +#undef _Unwind_Resume | ||
| 370 | +#undef _Unwind_Resume_or_Rethrow | ||
| 371 | +#undef _Unwind_SetGR | ||
| 372 | +#undef _Unwind_SetIP | ||
| 373 | +symverglobal (_Unwind_Backtrace, GCC_3.3); | ||
| 374 | +symverglobal (_Unwind_DeleteException, GCC_3.0); | ||
| 375 | +symverglobal (_Unwind_FindEnclosingFunction, GCC_3.3); | ||
| 376 | +symverglobal (_Unwind_ForcedUnwind, GCC_3.0); | ||
| 377 | +symverglobal (_Unwind_GetBSP, GCC_3.3.2); | ||
| 378 | +symverglobal (_Unwind_GetCFA, GCC_3.3); | ||
| 379 | +symverglobal (_Unwind_GetGR, GCC_3.0); | ||
| 380 | +symverglobal (_Unwind_GetIP, GCC_3.0); | ||
| 381 | +symverglobal (_Unwind_GetLanguageSpecificData, GCC_3.0); | ||
| 382 | +symverglobal (_Unwind_GetRegionStart, GCC_3.0); | ||
| 383 | +symverglobal (_Unwind_RaiseException, GCC_3.0); | ||
| 384 | +symverglobal (_Unwind_Resume, GCC_3.0); | ||
| 385 | +symverglobal (_Unwind_Resume_or_Rethrow, GCC_3.3); | ||
| 386 | +symverglobal (_Unwind_SetGR, GCC_3.0); | ||
| 387 | +symverglobal (_Unwind_SetIP, GCC_3.0); | ||
| 388 | +#endif | ||
| 389 | + | ||
| 390 | #endif | ||
| 391 | Index: gcc/config/ia64/mkmap-symver-multi.awk | ||
| 392 | =================================================================== | ||
| 393 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
| 394 | +++ gcc/config/ia64/mkmap-symver-multi.awk 2010-06-25 10:14:32.521880765 -0700 | ||
| 395 | @@ -0,0 +1,133 @@ | ||
| 396 | +# Generate an ELF symbol version map a-la Solaris and GNU ld. | ||
| 397 | +# Contributed by Richard Henderson <rth@cygnus.com> | ||
| 398 | +# | ||
| 399 | +# This file is part of GCC. | ||
| 400 | +# | ||
| 401 | +# GCC is free software; you can redistribute it and/or modify it under | ||
| 402 | +# the terms of the GNU General Public License as published by the Free | ||
| 403 | +# Software Foundation; either version 2, or (at your option) any later | ||
| 404 | +# version. | ||
| 405 | +# | ||
| 406 | +# GCC is distributed in the hope that it will be useful, but WITHOUT | ||
| 407 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| 408 | +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | ||
| 409 | +# License for more details. | ||
| 410 | +# | ||
| 411 | +# You should have received a copy of the GNU General Public License | ||
| 412 | +# along with GCC; see the file COPYING. If not, write to the Free | ||
| 413 | +# Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA | ||
| 414 | +# 02110-1301, USA. | ||
| 415 | + | ||
| 416 | +BEGIN { | ||
| 417 | + state = "nm"; | ||
| 418 | + sawsymbol = 0; | ||
| 419 | +} | ||
| 420 | + | ||
| 421 | +# Remove comment and blank lines. | ||
| 422 | +/^ *#/ || /^ *$/ { | ||
| 423 | + next; | ||
| 424 | +} | ||
| 425 | + | ||
| 426 | +# We begin with nm input. Collect the set of symbols that are present | ||
| 427 | +# so that we can not emit them into the final version script -- Solaris | ||
| 428 | +# complains at us if we do. | ||
| 429 | + | ||
| 430 | +state == "nm" && /^%%/ { | ||
| 431 | + state = "ver"; | ||
| 432 | + next; | ||
| 433 | +} | ||
| 434 | + | ||
| 435 | +state == "nm" && ($1 == "U" || $2 == "U") { | ||
| 436 | + next; | ||
| 437 | +} | ||
| 438 | + | ||
| 439 | +state == "nm" && NF == 3 { | ||
| 440 | + if ($3 ~ /^[^@]*@GCC_[0-9.]*$/) { | ||
| 441 | + def[$3] = 1 | ||
| 442 | + tl=$3 | ||
| 443 | + sub(/^.*@/,"",tl) | ||
| 444 | + ver[$3] = tl | ||
| 445 | + } else { | ||
| 446 | + sub(/@@?GCC_[0-9.]*$/,"",$3) | ||
| 447 | + def[$3] = 1; | ||
| 448 | + } | ||
| 449 | + sawsymbol = 1; | ||
| 450 | + next; | ||
| 451 | +} | ||
| 452 | + | ||
| 453 | +state == "nm" { | ||
| 454 | + next; | ||
| 455 | +} | ||
| 456 | + | ||
| 457 | +# Now we process a simplified variant of the Solaris symbol version | ||
| 458 | +# script. We have one symbol per line, no semicolons, simple markers | ||
| 459 | +# for beginning and ending each section, and %inherit markers for | ||
| 460 | +# describing version inheritence. A symbol may appear in more than | ||
| 461 | +# one symbol version, and the last seen takes effect. | ||
| 462 | + | ||
| 463 | +NF == 3 && $1 == "%inherit" { | ||
| 464 | + inherit[$2] = $3; | ||
| 465 | + next; | ||
| 466 | +} | ||
| 467 | + | ||
| 468 | +NF == 2 && $2 == "{" { | ||
| 469 | + libs[$1] = 1; | ||
| 470 | + thislib = $1; | ||
| 471 | + next; | ||
| 472 | +} | ||
| 473 | + | ||
| 474 | +$1 == "}" { | ||
| 475 | + thislib = ""; | ||
| 476 | + next; | ||
| 477 | +} | ||
| 478 | + | ||
| 479 | +{ | ||
| 480 | + ver[$1] = thislib; | ||
| 481 | + next; | ||
| 482 | +} | ||
| 483 | + | ||
| 484 | +END { | ||
| 485 | + if (!sawsymbol) | ||
| 486 | + { | ||
| 487 | + print "No symbols seen -- broken or mis-installed nm?" | "cat 1>&2"; | ||
| 488 | + exit 1; | ||
| 489 | + } | ||
| 490 | + for (l in libs) | ||
| 491 | + output(l); | ||
| 492 | +} | ||
| 493 | + | ||
| 494 | +function output(lib) { | ||
| 495 | + if (done[lib]) | ||
| 496 | + return; | ||
| 497 | + done[lib] = 1; | ||
| 498 | + if (inherit[lib]) | ||
| 499 | + output(inherit[lib]); | ||
| 500 | + | ||
| 501 | + empty=1 | ||
| 502 | + for (sym in ver) | ||
| 503 | + if ((ver[sym] == lib) && (sym in def)) | ||
| 504 | + { | ||
| 505 | + if (empty) | ||
| 506 | + { | ||
| 507 | + printf("%s {\n", lib); | ||
| 508 | + printf(" global:\n"); | ||
| 509 | + empty = 0; | ||
| 510 | + } | ||
| 511 | + symp = sym; | ||
| 512 | + sub(/@GCC_[0-9.]*$/,"",symp); | ||
| 513 | + printf("\t%s;\n", symp); | ||
| 514 | + if (dotsyms) | ||
| 515 | + printf("\t.%s;\n", symp); | ||
| 516 | + } | ||
| 517 | + | ||
| 518 | + if (empty) | ||
| 519 | + { | ||
| 520 | + for (l in libs) | ||
| 521 | + if (inherit[l] == lib) | ||
| 522 | + inherit[l] = inherit[lib]; | ||
| 523 | + } | ||
| 524 | + else if (inherit[lib]) | ||
| 525 | + printf("} %s;\n", inherit[lib]); | ||
| 526 | + else | ||
| 527 | + printf ("\n local:\n\t*;\n};\n"); | ||
| 528 | +} | ||
| 529 | Index: gcc/config/ia64/libgcc-ia64-no-libunwind.ver | ||
| 530 | =================================================================== | ||
| 531 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
| 532 | +++ gcc/config/ia64/libgcc-ia64-no-libunwind.ver 2010-06-25 10:14:32.525880902 -0700 | ||
| 533 | @@ -0,0 +1,17 @@ | ||
| 534 | +GCC_3.4.2 { | ||
| 535 | + _Unwind_GetGR | ||
| 536 | + _Unwind_RaiseException | ||
| 537 | + _Unwind_GetRegionStart | ||
| 538 | + _Unwind_SetIP | ||
| 539 | + _Unwind_GetIP | ||
| 540 | + _Unwind_GetLanguageSpecificData | ||
| 541 | + _Unwind_Resume | ||
| 542 | + _Unwind_DeleteException | ||
| 543 | + _Unwind_SetGR | ||
| 544 | + _Unwind_ForcedUnwind | ||
| 545 | + _Unwind_Backtrace | ||
| 546 | + _Unwind_FindEnclosingFunction | ||
| 547 | + _Unwind_GetCFA | ||
| 548 | + _Unwind_Resume_or_Rethrow | ||
| 549 | + _Unwind_GetBSP | ||
| 550 | +} | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-java-debug-iface-type.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-java-debug-iface-type.patch new file mode 100644 index 0000000000..de14a50018 --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-java-debug-iface-type.patch | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | 2008-01-25 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | * lang.c (java_classify_record): Revert 2007-12-20 change. | ||
| 4 | |||
| 5 | Index: gcc/java/lang.c | ||
| 6 | =================================================================== | ||
| 7 | --- gcc/java/lang.c.orig 2010-01-20 00:17:00.000000000 -0800 | ||
| 8 | +++ gcc/java/lang.c 2010-06-25 10:28:46.569383189 -0700 | ||
| 9 | @@ -881,9 +881,7 @@ | ||
| 10 | if (! CLASS_P (type)) | ||
| 11 | return RECORD_IS_STRUCT; | ||
| 12 | |||
| 13 | - /* ??? GDB does not support DW_TAG_interface_type as of December, | ||
| 14 | - 2007. Re-enable this at a later time. */ | ||
| 15 | - if (0 && CLASS_INTERFACE (TYPE_NAME (type))) | ||
| 16 | + if (CLASS_INTERFACE (TYPE_NAME (type))) | ||
| 17 | return RECORD_IS_INTERFACE; | ||
| 18 | |||
| 19 | return RECORD_IS_CLASS; | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-java-nomulti.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-java-nomulti.patch new file mode 100644 index 0000000000..3cb10f3c23 --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-java-nomulti.patch | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | Index: libjava/configure.ac | ||
| 2 | =================================================================== | ||
| 3 | --- libjava/configure.ac.orig 2010-03-21 12:41:37.000000000 -0700 | ||
| 4 | +++ libjava/configure.ac 2010-06-25 10:17:47.489886278 -0700 | ||
| 5 | @@ -139,6 +139,13 @@ | ||
| 6 | [allow rebuilding of .class and .h files])) | ||
| 7 | AM_CONDITIONAL(JAVA_MAINTAINER_MODE, test "$enable_java_maintainer_mode" = yes) | ||
| 8 | |||
| 9 | +AC_ARG_ENABLE(libjava-multilib, | ||
| 10 | + AS_HELP_STRING([--enable-libjava-multilib], [build libjava as multilib])) | ||
| 11 | +if test "$enable_libjava_multilib" = no; then | ||
| 12 | + multilib=no | ||
| 13 | + ac_configure_args="$ac_configure_args --disable-multilib" | ||
| 14 | +fi | ||
| 15 | + | ||
| 16 | # It may not be safe to run linking tests in AC_PROG_CC/AC_PROG_CXX. | ||
| 17 | GCC_NO_EXECUTABLES | ||
| 18 | |||
| 19 | Index: libjava/configure | ||
| 20 | =================================================================== | ||
| 21 | --- libjava/configure.orig 2010-04-02 11:18:06.000000000 -0700 | ||
| 22 | +++ libjava/configure 2010-06-25 10:17:47.516381209 -0700 | ||
| 23 | @@ -1609,6 +1609,8 @@ | ||
| 24 | default=yes | ||
| 25 | --enable-java-maintainer-mode | ||
| 26 | allow rebuilding of .class and .h files | ||
| 27 | + --enable-libjava-multilib | ||
| 28 | + build libjava as multilib | ||
| 29 | --disable-dependency-tracking speeds up one-time build | ||
| 30 | --enable-dependency-tracking do not reject slow dependency extractors | ||
| 31 | --enable-maintainer-mode enable make rules and dependencies not useful | ||
| 32 | @@ -3346,6 +3348,16 @@ | ||
| 33 | fi | ||
| 34 | |||
| 35 | |||
| 36 | +# Check whether --enable-libjava-multilib was given. | ||
| 37 | +if test "${enable_libjava_multilib+set}" = set; then | ||
| 38 | + enableval=$enable_libjava_multilib; | ||
| 39 | +fi | ||
| 40 | + | ||
| 41 | +if test "$enable_libjava_multilib" = no; then | ||
| 42 | + multilib=no | ||
| 43 | + ac_configure_args="$ac_configure_args --disable-multilib" | ||
| 44 | +fi | ||
| 45 | + | ||
| 46 | # It may not be safe to run linking tests in AC_PROG_CC/AC_PROG_CXX. | ||
| 47 | |||
| 48 | |||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-libgomp-speedup.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-libgomp-speedup.patch new file mode 100644 index 0000000000..da85e556ec --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-libgomp-speedup.patch | |||
| @@ -0,0 +1,2797 @@ | |||
| 1 | 2008-03-28 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | * config/linux/sparc/futex.h (atomic_write_barrier): Fix membar | ||
| 4 | argument. | ||
| 5 | |||
| 6 | 2008-03-27 Jakub Jelinek <jakub@redhat.com> | ||
| 7 | |||
| 8 | * libgomp.h (struct gomp_team_state): Remove single_count field | ||
| 9 | ifndef HAVE_SYNC_BUILTINS. | ||
| 10 | (struct gomp_team): Likewise. Add work_share_list_free_lock | ||
| 11 | ifndef HAVE_SYNC_BUILTINS. | ||
| 12 | * team.c (gomp_new_team): If HAVE_SYNC_BUILTINS is not defined, | ||
| 13 | don't initialize single_count, but instead initialize | ||
| 14 | work_share_list_free_lock. | ||
| 15 | (free_team): Destroy work_share_list_free_lock ifndef | ||
| 16 | HAVE_SYNC_BUILTINS. | ||
| 17 | (gomp_team_start): Don't initialize ts.single_count ifndef | ||
| 18 | HAVE_SYNC_BUILTINS. | ||
| 19 | * work.c (alloc_work_share, free_work_share): Use | ||
| 20 | work_share_list_free_lock instead of atomic chaining ifndef | ||
| 21 | HAVE_SYNC_BUILTINS. | ||
| 22 | |||
| 23 | 2008-03-26 Jakub Jelinek <jakub@redhat.com> | ||
| 24 | |||
| 25 | * loop.c (gomp_loop_init): Fix GFS_DYNAMIC ws->mode setting. | ||
| 26 | * testsuite/libgomp.c/loop-4.c: New test. | ||
| 27 | |||
| 28 | * libgomp.h (struct gomp_team_state): Add single_count field. | ||
| 29 | (struct gomp_team): Likewise. | ||
| 30 | * team.c (gomp_new_team): Clear single_count. | ||
| 31 | (gomp_team_start): Likewise. | ||
| 32 | * single.c (GOMP_single_start): Rewritten if HAVE_SYNC_BUILTINS. | ||
| 33 | |||
| 34 | 2008-03-25 Jakub Jelinek <jakub@redhat.com> | ||
| 35 | |||
| 36 | * team.c (gomp_thread_start): Don't clear ts.static_trip here. | ||
| 37 | * loop.c (gomp_loop_static_start, gomp_loop_dynamic_start): Clear | ||
| 38 | ts.static_trip here. | ||
| 39 | * work.c (gomp_work_share_start): Don't clear ts.static_trip here. | ||
| 40 | |||
| 41 | 2008-03-21 Jakub Jelinek <jakub@redhat.com> | ||
| 42 | |||
| 43 | * libgomp.h: Include ptrlock.h. | ||
| 44 | (struct gomp_work_share): Reshuffle fields. Add next_alloc, | ||
| 45 | next_ws, next_free and inline_ordered_team_ids fields, change | ||
| 46 | ordered_team_ids into pointer from flexible array member. | ||
| 47 | (struct gomp_team_state): Add last_work_share field, remove | ||
| 48 | work_share_generation. | ||
| 49 | (struct gomp_team): Remove work_share_lock, generation_mask, | ||
| 50 | oldest_live_gen, num_live_gen and init_work_shares fields, add | ||
| 51 | work work_share_list_alloc, work_share_list_free and work_share_chunk | ||
| 52 | fields. Change work_shares from pointer to pointers into an array. | ||
| 53 | (gomp_new_team): New prototype. | ||
| 54 | (gomp_team_start): Change type of last argument. | ||
| 55 | (gomp_new_work_share): Removed. | ||
| 56 | (gomp_init_work_share, gomp_fini_work_share): New prototypes. | ||
| 57 | (gomp_work_share_init_done): New static inline. | ||
| 58 | * team.c (gomp_thread_start): Clear ts.last_work_share, don't clear | ||
| 59 | ts.work_share_generation. | ||
| 60 | (new_team): Removed. | ||
| 61 | (gomp_new_team): New function. | ||
| 62 | (free_team): Free gomp_work_share blocks chained through next_alloc, | ||
| 63 | instead of freeing work_shares and destroying work_share_lock. | ||
| 64 | (gomp_team_start): Change last argument from ws to team, don't create | ||
| 65 | new team, set ts.work_share to &team->work_shares[0] and clear | ||
| 66 | ts.last_work_share. Don't clear ts.work_share_generation. | ||
| 67 | (gomp_team_end): Call gomp_fini_work_share. | ||
| 68 | * work.c (gomp_new_work_share): Removed. | ||
| 69 | (alloc_work_share, gomp_init_work_share, gomp_fini_work_share): New | ||
| 70 | functions. | ||
| 71 | (free_work_share): Add team argument. Call gomp_fini_work_share | ||
| 72 | and then either free ws if orphaned, or put it into | ||
| 73 | work_share_list_free list of the current team. | ||
| 74 | (gomp_work_share_start, gomp_work_share_end, | ||
| 75 | gomp_work_share_end_nowait): Rewritten. | ||
| 76 | * sections.c (GOMP_sections_start): Call gomp_work_share_init_done | ||
| 77 | after gomp_sections_init. If HAVE_SYNC_BUILTINS, call | ||
| 78 | gomp_iter_dynamic_next instead of the _locked variant and don't take | ||
| 79 | lock around it, otherwise acquire it before calling | ||
| 80 | gomp_iter_dynamic_next_locked. | ||
| 81 | (GOMP_sections_next): If HAVE_SYNC_BUILTINS, call | ||
| 82 | gomp_iter_dynamic_next instead of the _locked variant and don't take | ||
| 83 | lock around it. | ||
| 84 | (GOMP_parallel_sections_start): Call gomp_new_team instead of | ||
| 85 | gomp_new_work_share. Call gomp_sections_init on &team->work_shares[0]. | ||
| 86 | Adjust gomp_team_start caller. | ||
| 87 | * loop.c (gomp_loop_static_start, gomp_loop_ordered_static_start): Call | ||
| 88 | gomp_work_share_init_done after gomp_loop_init. Don't unlock ws->lock. | ||
| 89 | (gomp_loop_dynamic_start, gomp_loop_guided_start): Call | ||
| 90 | gomp_work_share_init_done after gomp_loop_init. If HAVE_SYNC_BUILTINS, | ||
| 91 | don't unlock ws->lock, otherwise lock it. | ||
| 92 | (gomp_loop_ordered_dynamic_start, gomp_loop_ordered_guided_start): Call | ||
| 93 | gomp_work_share_init_done after gomp_loop_init. Lock ws->lock. | ||
| 94 | (gomp_parallel_loop_start): Call gomp_new_team instead of | ||
| 95 | gomp_new_work_share. Call gomp_loop_init on &team->work_shares[0]. | ||
| 96 | Adjust gomp_team_start caller. | ||
| 97 | * single.c (GOMP_single_start, GOMP_single_copy_start): Call | ||
| 98 | gomp_work_share_init_done if gomp_work_share_start returned true. | ||
| 99 | Don't unlock ws->lock. | ||
| 100 | * parallel.c (GOMP_parallel_start): Call gomp_new_team and pass that | ||
| 101 | as last argument to gomp_team_start. | ||
| 102 | * config/linux/ptrlock.c: New file. | ||
| 103 | * config/linux/ptrlock.h: New file. | ||
| 104 | * config/posix/ptrlock.c: New file. | ||
| 105 | * config/posix/ptrlock.h: New file. | ||
| 106 | * Makefile.am (libgomp_la_SOURCES): Add ptrlock.c. | ||
| 107 | * Makefile.in: Regenerated. | ||
| 108 | * testsuite/Makefile.in: Regenerated. | ||
| 109 | |||
| 110 | 2008-03-19 Jakub Jelinek <jakub@redhat.com> | ||
| 111 | |||
| 112 | * libgomp.h (gomp_active_wait_policy): Remove decl. | ||
| 113 | (gomp_throttled_spin_count_var, gomp_available_cpus, | ||
| 114 | gomp_managed_threads): New extern decls. | ||
| 115 | * team.c (gomp_team_start, gomp_team_end): If number of threads | ||
| 116 | changed, adjust atomically gomp_managed_threads. | ||
| 117 | * env.c (gomp_active_wait_policy, gomp_block_time_var): Remove. | ||
| 118 | (gomp_throttled_spin_count_var, gomp_available_cpus, | ||
| 119 | gomp_managed_threads): New variables. | ||
| 120 | (parse_millis): Removed. | ||
| 121 | (parse_spincount): New function. | ||
| 122 | (parse_wait_policy): Return -1/0/1 instead of setting | ||
| 123 | gomp_active_wait_policy. | ||
| 124 | (initialize_env): Call gomp_init_num_threads unconditionally. | ||
| 125 | Initialize gomp_available_cpus. Call parse_spincount instead | ||
| 126 | of parse_millis, initialize gomp_{,throttled_}spin_count_var | ||
| 127 | depending on presence and value of OMP_WAIT_POLICY and | ||
| 128 | GOMP_SPINCOUNT env vars. | ||
| 129 | * config/linux/wait.h (do_wait): Use gomp_throttled_spin_count_var | ||
| 130 | instead of gomp_spin_count_var if gomp_managed_threads > | ||
| 131 | gomp_available_cpus. | ||
| 132 | |||
| 133 | * config/linux/wait.h: Include errno.h. | ||
| 134 | (FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Define. | ||
| 135 | (gomp_futex_wake, gomp_futex_wait): New extern decls. | ||
| 136 | * config/linux/mutex.c (gomp_futex_wake, gomp_futex_wait): New | ||
| 137 | variables. | ||
| 138 | * config/linux/powerpc/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove. | ||
| 139 | (sys_futex0): Return error code. | ||
| 140 | (futex_wake, futex_wait): If ENOSYS was returned, clear | ||
| 141 | FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry. | ||
| 142 | * config/linux/alpha/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove. | ||
| 143 | (futex_wake, futex_wait): If ENOSYS was returned, clear | ||
| 144 | FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry. | ||
| 145 | * config/linux/x86/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove. | ||
| 146 | (sys_futex0): Return error code. | ||
| 147 | (futex_wake, futex_wait): If ENOSYS was returned, clear | ||
| 148 | FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry. | ||
| 149 | * config/linux/s390/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove. | ||
| 150 | (sys_futex0): Return error code. | ||
| 151 | (futex_wake, futex_wait): If ENOSYS was returned, clear | ||
| 152 | FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry. | ||
| 153 | * config/linux/ia64/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove. | ||
| 154 | (sys_futex0): Return error code. | ||
| 155 | (futex_wake, futex_wait): If ENOSYS was returned, clear | ||
| 156 | FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry. | ||
| 157 | * config/linux/sparc/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove. | ||
| 158 | (sys_futex0): Return error code. | ||
| 159 | (futex_wake, futex_wait): If ENOSYS was returned, clear | ||
| 160 | FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry. | ||
| 161 | |||
| 162 | 2008-03-18 Jakub Jelinek <jakub@redhat.com> | ||
| 163 | |||
| 164 | * libgomp.h (struct gomp_work_share): Add mode field. Put lock and | ||
| 165 | next into a different cache line from most of the write-once fields. | ||
| 166 | * loop.c: Include limits.h. | ||
| 167 | (gomp_loop_init): For GFS_DYNAMIC, multiply ws->chunk_size by incr. | ||
| 168 | If adding ws->chunk_size nthreads + 1 times after end won't | ||
| 169 | overflow, set ws->mode to 1. | ||
| 170 | * iter.c (gomp_iter_dynamic_next_locked): Don't multiply | ||
| 171 | ws->chunk_size by incr. | ||
| 172 | (gomp_iter_dynamic_next): Likewise. If ws->mode, use more efficient | ||
| 173 | code. | ||
| 174 | * work.c: Include stddef.h. | ||
| 175 | (gomp_new_work_share): Use offsetof rather than sizeof. | ||
| 176 | |||
| 177 | 2008-03-17 Jakub Jelinek <jakub@redhat.com> | ||
| 178 | |||
| 179 | * libgomp.h (struct gomp_team): Change ordered_release field | ||
| 180 | into gomp_sem_t ** from flexible array member. Add implicit_task | ||
| 181 | and initial_work_shares fields. | ||
| 182 | (gomp_new_task): Removed. | ||
| 183 | (gomp_init_task): New prototype. | ||
| 184 | * team.c (new_team): Allocate implicit_task for each thread | ||
| 185 | and initial work_shares together with gomp_team allocation. | ||
| 186 | (free_team): Only free work_shares if it is not init_work_shares. | ||
| 187 | (gomp_team_start): Use gomp_init_task instead of gomp_new_task, | ||
| 188 | set thr->task to the corresponding implicit_task array entry. | ||
| 189 | * task.c (gomp_new_task): Removed. | ||
| 190 | (gomp_init_task): New function. | ||
| 191 | (gomp_end_task): Don't free the task. | ||
| 192 | (GOMP_task): Allocate struct gomp_task on the stack, call | ||
| 193 | gomp_init_task rather than gomp_new_task. | ||
| 194 | * work.c (gomp_work_share_start): If work_shares == | ||
| 195 | init_work_shares, gomp_malloc + memcpy rather than gomp_realloc. | ||
| 196 | |||
| 197 | 2008-03-15 Jakub Jelinek <jakub@redhat.com> | ||
| 198 | Ulrich Drepper <drepper@redhat.com> | ||
| 199 | |||
| 200 | * config/linux/bar.h (gomp_barrier_state_t): Rewritten. | ||
| 201 | (gomp_barrier_state_t): Change to unsigned int. | ||
| 202 | (gomp_barrier_init, gomp_barrier_reinit, gomp_barrier_destroy, | ||
| 203 | gomp_barrier_wait_start, gomp_barrier_last_thread): Rewritten. | ||
| 204 | (gomp_barrier_wait_last): Prototype rather than inline. | ||
| 205 | * config/linux/bar.c (gomp_barrier_wait_end): Rewritten. | ||
| 206 | (gomp_barrier_wait_last): New function. | ||
| 207 | |||
| 208 | 2008-03-15 Jakub Jelinek <jakub@redhat.com> | ||
| 209 | |||
| 210 | * team.c (gomp_thread_start): Use gomp_barrier_wait_last instead | ||
| 211 | of gomp_barrier_wait. | ||
| 212 | * env.c (gomp_block_time_var, gomp_spin_count_var): New variables. | ||
| 213 | (parse_millis): New function. | ||
| 214 | (initialize_env): Handle GOMP_BLOCKTIME env var. | ||
| 215 | * libgomp.h (struct gomp_team): Move close to the end of the struct. | ||
| 216 | (gomp_spin_count_var): New extern var decl. | ||
| 217 | * work.c (gomp_work_share_end): Use gomp_barrier_state_t bstate | ||
| 218 | var instead of bool last, call gomp_barrier_last_thread to check | ||
| 219 | for last thread, pass bstate to gomp_barrier_wait_end. | ||
| 220 | * config/linux/wait.h: New file. | ||
| 221 | * config/linux/mutex.c: Include wait.h instead of libgomp.h and | ||
| 222 | futex.h. | ||
| 223 | (gomp_mutex_lock_slow): Call do_wait instead of futex_wait. | ||
| 224 | * config/linux/bar.c: Include wait.h instead of libgomp.h and | ||
| 225 | futex.h. | ||
| 226 | (gomp_barrier_wait_end): Change second argument to | ||
| 227 | gomp_barrier_state_t. Call do_wait instead of futex_wait. | ||
| 228 | * config/linux/sem.c: Include wait.h instead of libgomp.h and | ||
| 229 | futex.h. | ||
| 230 | (gomp_sem_wait_slow): Call do_wait instead of futex_wait. | ||
| 231 | * config/linux/lock.c: Include wait.h instead of libgomp.h and | ||
| 232 | futex.h. | ||
| 233 | (gomp_set_nest_lock_25): Call do_wait instead of futex_wait. | ||
| 234 | * config/linux/affinity.c: Assume HAVE_SYNC_BUILTINS. | ||
| 235 | * config/linux/bar.h (gomp_barrier_state_t): New typedef. | ||
| 236 | (gomp_barrier_wait_end): Change second argument to | ||
| 237 | gomp_barrier_state_t. | ||
| 238 | (gomp_barrier_wait_start): Return gomp_barrier_state_t. | ||
| 239 | (gomp_barrier_last_thread, gomp_barrier_wait_last): New static | ||
| 240 | inlines. | ||
| 241 | * config/linux/powerpc/futex.h (cpu_relax, atomic_write_barrier): New | ||
| 242 | static inlines. | ||
| 243 | * config/linux/alpha/futex.h (cpu_relax, atomic_write_barrier): | ||
| 244 | Likewise. | ||
| 245 | * config/linux/x86/futex.h (cpu_relax, atomic_write_barrier): | ||
| 246 | Likewise. | ||
| 247 | * config/linux/s390/futex.h (cpu_relax, atomic_write_barrier): | ||
| 248 | Likewise. | ||
| 249 | * config/linux/ia64/futex.h (cpu_relax, atomic_write_barrier): | ||
| 250 | Likewise. | ||
| 251 | * config/linux/sparc/futex.h (cpu_relax, atomic_write_barrier): | ||
| 252 | Likewise. | ||
| 253 | * config/posix/bar.c (gomp_barrier_wait_end): Change second argument | ||
| 254 | to gomp_barrier_state_t. | ||
| 255 | * config/posix/bar.h (gomp_barrier_state_t): New typedef. | ||
| 256 | (gomp_barrier_wait_end): Change second argument to | ||
| 257 | gomp_barrier_state_t. | ||
| 258 | (gomp_barrier_wait_start): Return gomp_barrier_state_t. | ||
| 259 | (gomp_barrier_last_thread, gomp_barrier_wait_last): New static | ||
| 260 | inlines. | ||
| 261 | |||
| 262 | --- libgomp/parallel.c.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 263 | +++ libgomp/parallel.c 2008-03-26 15:32:06.000000000 +0100 | ||
| 264 | @@ -68,7 +68,7 @@ void | ||
| 265 | GOMP_parallel_start (void (*fn) (void *), void *data, unsigned num_threads) | ||
| 266 | { | ||
| 267 | num_threads = gomp_resolve_num_threads (num_threads); | ||
| 268 | - gomp_team_start (fn, data, num_threads, NULL); | ||
| 269 | + gomp_team_start (fn, data, num_threads, gomp_new_team (num_threads)); | ||
| 270 | } | ||
| 271 | |||
| 272 | void | ||
| 273 | --- libgomp/sections.c.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 274 | +++ libgomp/sections.c 2008-03-26 15:33:06.000000000 +0100 | ||
| 275 | @@ -59,14 +59,24 @@ GOMP_sections_start (unsigned count) | ||
| 276 | long s, e, ret; | ||
| 277 | |||
| 278 | if (gomp_work_share_start (false)) | ||
| 279 | - gomp_sections_init (thr->ts.work_share, count); | ||
| 280 | + { | ||
| 281 | + gomp_sections_init (thr->ts.work_share, count); | ||
| 282 | + gomp_work_share_init_done (); | ||
| 283 | + } | ||
| 284 | |||
| 285 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 286 | + if (gomp_iter_dynamic_next (&s, &e)) | ||
| 287 | + ret = s; | ||
| 288 | + else | ||
| 289 | + ret = 0; | ||
| 290 | +#else | ||
| 291 | + gomp_mutex_lock (&thr->ts.work_share->lock); | ||
| 292 | if (gomp_iter_dynamic_next_locked (&s, &e)) | ||
| 293 | ret = s; | ||
| 294 | else | ||
| 295 | ret = 0; | ||
| 296 | - | ||
| 297 | gomp_mutex_unlock (&thr->ts.work_share->lock); | ||
| 298 | +#endif | ||
| 299 | |||
| 300 | return ret; | ||
| 301 | } | ||
| 302 | @@ -83,15 +93,23 @@ GOMP_sections_start (unsigned count) | ||
| 303 | unsigned | ||
| 304 | GOMP_sections_next (void) | ||
| 305 | { | ||
| 306 | - struct gomp_thread *thr = gomp_thread (); | ||
| 307 | long s, e, ret; | ||
| 308 | |||
| 309 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 310 | + if (gomp_iter_dynamic_next (&s, &e)) | ||
| 311 | + ret = s; | ||
| 312 | + else | ||
| 313 | + ret = 0; | ||
| 314 | +#else | ||
| 315 | + struct gomp_thread *thr = gomp_thread (); | ||
| 316 | + | ||
| 317 | gomp_mutex_lock (&thr->ts.work_share->lock); | ||
| 318 | if (gomp_iter_dynamic_next_locked (&s, &e)) | ||
| 319 | ret = s; | ||
| 320 | else | ||
| 321 | ret = 0; | ||
| 322 | gomp_mutex_unlock (&thr->ts.work_share->lock); | ||
| 323 | +#endif | ||
| 324 | |||
| 325 | return ret; | ||
| 326 | } | ||
| 327 | @@ -103,15 +121,15 @@ void | ||
| 328 | GOMP_parallel_sections_start (void (*fn) (void *), void *data, | ||
| 329 | unsigned num_threads, unsigned count) | ||
| 330 | { | ||
| 331 | - struct gomp_work_share *ws; | ||
| 332 | + struct gomp_team *team; | ||
| 333 | |||
| 334 | num_threads = gomp_resolve_num_threads (num_threads); | ||
| 335 | if (gomp_dyn_var && num_threads > count) | ||
| 336 | num_threads = count; | ||
| 337 | |||
| 338 | - ws = gomp_new_work_share (false, num_threads); | ||
| 339 | - gomp_sections_init (ws, count); | ||
| 340 | - gomp_team_start (fn, data, num_threads, ws); | ||
| 341 | + team = gomp_new_team (num_threads); | ||
| 342 | + gomp_sections_init (&team->work_shares[0], count); | ||
| 343 | + gomp_team_start (fn, data, num_threads, team); | ||
| 344 | } | ||
| 345 | |||
| 346 | /* The GOMP_section_end* routines are called after the thread is told | ||
| 347 | --- libgomp/env.c.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 348 | +++ libgomp/env.c 2008-03-26 16:40:26.000000000 +0100 | ||
| 349 | @@ -44,6 +44,11 @@ enum gomp_schedule_type gomp_run_sched_v | ||
| 350 | unsigned long gomp_run_sched_chunk = 1; | ||
| 351 | unsigned short *gomp_cpu_affinity; | ||
| 352 | size_t gomp_cpu_affinity_len; | ||
| 353 | +#ifndef HAVE_SYNC_BUILTINS | ||
| 354 | +gomp_mutex_t gomp_remaining_threads_lock; | ||
| 355 | +#endif | ||
| 356 | +unsigned long gomp_available_cpus = 1, gomp_managed_threads = 1; | ||
| 357 | +unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var; | ||
| 358 | |||
| 359 | /* Parse the OMP_SCHEDULE environment variable. */ | ||
| 360 | |||
| 361 | @@ -147,6 +152,79 @@ parse_unsigned_long (const char *name, u | ||
| 362 | return false; | ||
| 363 | } | ||
| 364 | |||
| 365 | +/* Parse the GOMP_SPINCOUNT environment varible. Return true if one was | ||
| 366 | + present and it was successfully parsed. */ | ||
| 367 | + | ||
| 368 | +static bool | ||
| 369 | +parse_spincount (const char *name, unsigned long long *pvalue) | ||
| 370 | +{ | ||
| 371 | + char *env, *end; | ||
| 372 | + unsigned long long value, mult = 1; | ||
| 373 | + | ||
| 374 | + env = getenv (name); | ||
| 375 | + if (env == NULL) | ||
| 376 | + return false; | ||
| 377 | + | ||
| 378 | + while (isspace ((unsigned char) *env)) | ||
| 379 | + ++env; | ||
| 380 | + if (*env == '\0') | ||
| 381 | + goto invalid; | ||
| 382 | + | ||
| 383 | + if (strncasecmp (env, "infinite", 8) == 0 | ||
| 384 | + || strncasecmp (env, "infinity", 8) == 0) | ||
| 385 | + { | ||
| 386 | + value = ~0ULL; | ||
| 387 | + end = env + 8; | ||
| 388 | + goto check_tail; | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + errno = 0; | ||
| 392 | + value = strtoull (env, &end, 10); | ||
| 393 | + if (errno) | ||
| 394 | + goto invalid; | ||
| 395 | + | ||
| 396 | + while (isspace ((unsigned char) *end)) | ||
| 397 | + ++end; | ||
| 398 | + if (*end != '\0') | ||
| 399 | + { | ||
| 400 | + switch (tolower (*end)) | ||
| 401 | + { | ||
| 402 | + case 'k': | ||
| 403 | + mult = 1000LL; | ||
| 404 | + break; | ||
| 405 | + case 'm': | ||
| 406 | + mult = 1000LL * 1000LL; | ||
| 407 | + break; | ||
| 408 | + case 'g': | ||
| 409 | + mult = 1000LL * 1000LL * 1000LL; | ||
| 410 | + break; | ||
| 411 | + case 't': | ||
| 412 | + mult = 1000LL * 1000LL * 1000LL * 1000LL; | ||
| 413 | + break; | ||
| 414 | + default: | ||
| 415 | + goto invalid; | ||
| 416 | + } | ||
| 417 | + ++end; | ||
| 418 | + check_tail: | ||
| 419 | + while (isspace ((unsigned char) *end)) | ||
| 420 | + ++end; | ||
| 421 | + if (*end != '\0') | ||
| 422 | + goto invalid; | ||
| 423 | + } | ||
| 424 | + | ||
| 425 | + if (value > ~0ULL / mult) | ||
| 426 | + value = ~0ULL; | ||
| 427 | + else | ||
| 428 | + value *= mult; | ||
| 429 | + | ||
| 430 | + *pvalue = value; | ||
| 431 | + return true; | ||
| 432 | + | ||
| 433 | + invalid: | ||
| 434 | + gomp_error ("Invalid value for environment variable %s", name); | ||
| 435 | + return false; | ||
| 436 | +} | ||
| 437 | + | ||
| 438 | /* Parse a boolean value for environment variable NAME and store the | ||
| 439 | result in VALUE. */ | ||
| 440 | |||
| 441 | @@ -281,10 +359,25 @@ initialize_env (void) | ||
| 442 | parse_schedule (); | ||
| 443 | parse_boolean ("OMP_DYNAMIC", &gomp_dyn_var); | ||
| 444 | parse_boolean ("OMP_NESTED", &gomp_nest_var); | ||
| 445 | + gomp_init_num_threads (); | ||
| 446 | + gomp_available_cpus = gomp_nthreads_var; | ||
| 447 | if (!parse_unsigned_long ("OMP_NUM_THREADS", &gomp_nthreads_var)) | ||
| 448 | - gomp_init_num_threads (); | ||
| 449 | + gomp_nthreads_var = gomp_available_cpus; | ||
| 450 | if (parse_affinity ()) | ||
| 451 | gomp_init_affinity (); | ||
| 452 | + if (!parse_spincount ("GOMP_SPINCOUNT", &gomp_spin_count_var)) | ||
| 453 | + { | ||
| 454 | + /* Using a rough estimation of 100000 spins per msec, | ||
| 455 | + use 200 msec blocking. | ||
| 456 | + Depending on the CPU speed, this can be e.g. 5 times longer | ||
| 457 | + or 5 times shorter. */ | ||
| 458 | + gomp_spin_count_var = 20000000LL; | ||
| 459 | + } | ||
| 460 | + /* gomp_throttled_spin_count_var is used when there are more libgomp | ||
| 461 | + managed threads than available CPUs. Use very short spinning. */ | ||
| 462 | + gomp_throttled_spin_count_var = 100LL; | ||
| 463 | + if (gomp_throttled_spin_count_var > gomp_spin_count_var) | ||
| 464 | + gomp_throttled_spin_count_var = gomp_spin_count_var; | ||
| 465 | |||
| 466 | /* Not strictly environment related, but ordering constructors is tricky. */ | ||
| 467 | pthread_attr_init (&gomp_thread_attr); | ||
| 468 | --- libgomp/libgomp.h.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 469 | +++ libgomp/libgomp.h 2008-03-27 12:21:51.000000000 +0100 | ||
| 470 | @@ -50,6 +50,7 @@ | ||
| 471 | #include "sem.h" | ||
| 472 | #include "mutex.h" | ||
| 473 | #include "bar.h" | ||
| 474 | +#include "ptrlock.h" | ||
| 475 | |||
| 476 | |||
| 477 | /* This structure contains the data to control one work-sharing construct, | ||
| 478 | @@ -70,6 +71,8 @@ struct gomp_work_share | ||
| 479 | If this is a SECTIONS construct, this value will always be DYNAMIC. */ | ||
| 480 | enum gomp_schedule_type sched; | ||
| 481 | |||
| 482 | + int mode; | ||
| 483 | + | ||
| 484 | /* This is the chunk_size argument to the SCHEDULE clause. */ | ||
| 485 | long chunk_size; | ||
| 486 | |||
| 487 | @@ -81,17 +84,38 @@ struct gomp_work_share | ||
| 488 | is always 1. */ | ||
| 489 | long incr; | ||
| 490 | |||
| 491 | - /* This lock protects the update of the following members. */ | ||
| 492 | - gomp_mutex_t lock; | ||
| 493 | + /* This is a circular queue that details which threads will be allowed | ||
| 494 | + into the ordered region and in which order. When a thread allocates | ||
| 495 | + iterations on which it is going to work, it also registers itself at | ||
| 496 | + the end of the array. When a thread reaches the ordered region, it | ||
| 497 | + checks to see if it is the one at the head of the queue. If not, it | ||
| 498 | + blocks on its RELEASE semaphore. */ | ||
| 499 | + unsigned *ordered_team_ids; | ||
| 500 | |||
| 501 | - union { | ||
| 502 | - /* This is the next iteration value to be allocated. In the case of | ||
| 503 | - GFS_STATIC loops, this the iteration start point and never changes. */ | ||
| 504 | - long next; | ||
| 505 | + /* This is the number of threads that have registered themselves in | ||
| 506 | + the circular queue ordered_team_ids. */ | ||
| 507 | + unsigned ordered_num_used; | ||
| 508 | |||
| 509 | - /* This is the returned data structure for SINGLE COPYPRIVATE. */ | ||
| 510 | - void *copyprivate; | ||
| 511 | - }; | ||
| 512 | + /* This is the team_id of the currently acknowledged owner of the ordered | ||
| 513 | + section, or -1u if the ordered section has not been acknowledged by | ||
| 514 | + any thread. This is distinguished from the thread that is *allowed* | ||
| 515 | + to take the section next. */ | ||
| 516 | + unsigned ordered_owner; | ||
| 517 | + | ||
| 518 | + /* This is the index into the circular queue ordered_team_ids of the | ||
| 519 | + current thread that's allowed into the ordered reason. */ | ||
| 520 | + unsigned ordered_cur; | ||
| 521 | + | ||
| 522 | + /* This is a chain of allocated gomp_work_share blocks, valid only | ||
| 523 | + in the first gomp_work_share struct in the block. */ | ||
| 524 | + struct gomp_work_share *next_alloc; | ||
| 525 | + | ||
| 526 | + /* The above fields are written once during workshare initialization, | ||
| 527 | + or related to ordered worksharing. Make sure the following fields | ||
| 528 | + are in a different cache line. */ | ||
| 529 | + | ||
| 530 | + /* This lock protects the update of the following members. */ | ||
| 531 | + gomp_mutex_t lock __attribute__((aligned (64))); | ||
| 532 | |||
| 533 | /* This is the count of the number of threads that have exited the work | ||
| 534 | share construct. If the construct was marked nowait, they have moved on | ||
| 535 | @@ -99,27 +123,28 @@ struct gomp_work_share | ||
| 536 | of the team to exit the work share construct must deallocate it. */ | ||
| 537 | unsigned threads_completed; | ||
| 538 | |||
| 539 | - /* This is the index into the circular queue ordered_team_ids of the | ||
| 540 | - current thread that's allowed into the ordered reason. */ | ||
| 541 | - unsigned ordered_cur; | ||
| 542 | + union { | ||
| 543 | + /* This is the next iteration value to be allocated. In the case of | ||
| 544 | + GFS_STATIC loops, this the iteration start point and never changes. */ | ||
| 545 | + long next; | ||
| 546 | |||
| 547 | - /* This is the number of threads that have registered themselves in | ||
| 548 | - the circular queue ordered_team_ids. */ | ||
| 549 | - unsigned ordered_num_used; | ||
| 550 | + /* This is the returned data structure for SINGLE COPYPRIVATE. */ | ||
| 551 | + void *copyprivate; | ||
| 552 | + }; | ||
| 553 | |||
| 554 | - /* This is the team_id of the currently acknoledged owner of the ordered | ||
| 555 | - section, or -1u if the ordered section has not been acknowledged by | ||
| 556 | - any thread. This is distinguished from the thread that is *allowed* | ||
| 557 | - to take the section next. */ | ||
| 558 | - unsigned ordered_owner; | ||
| 559 | + union { | ||
| 560 | + /* Link to gomp_work_share struct for next work sharing construct | ||
| 561 | + encountered after this one. */ | ||
| 562 | + gomp_ptrlock_t next_ws; | ||
| 563 | + | ||
| 564 | + /* gomp_work_share structs are chained in the free work share cache | ||
| 565 | + through this. */ | ||
| 566 | + struct gomp_work_share *next_free; | ||
| 567 | + }; | ||
| 568 | |||
| 569 | - /* This is a circular queue that details which threads will be allowed | ||
| 570 | - into the ordered region and in which order. When a thread allocates | ||
| 571 | - iterations on which it is going to work, it also registers itself at | ||
| 572 | - the end of the array. When a thread reaches the ordered region, it | ||
| 573 | - checks to see if it is the one at the head of the queue. If not, it | ||
| 574 | - blocks on its RELEASE semaphore. */ | ||
| 575 | - unsigned ordered_team_ids[]; | ||
| 576 | + /* If only few threads are in the team, ordered_team_ids can point | ||
| 577 | + to this array which fills the padding at the end of this struct. */ | ||
| 578 | + unsigned inline_ordered_team_ids[0]; | ||
| 579 | }; | ||
| 580 | |||
| 581 | /* This structure contains all of the thread-local data associated with | ||
| 582 | @@ -133,21 +158,24 @@ struct gomp_team_state | ||
| 583 | |||
| 584 | /* This is the work share construct which this thread is currently | ||
| 585 | processing. Recall that with NOWAIT, not all threads may be | ||
| 586 | - processing the same construct. This value is NULL when there | ||
| 587 | - is no construct being processed. */ | ||
| 588 | + processing the same construct. */ | ||
| 589 | struct gomp_work_share *work_share; | ||
| 590 | |||
| 591 | + /* This is the previous work share construct or NULL if there wasn't any. | ||
| 592 | + When all threads are done with the current work sharing construct, | ||
| 593 | + the previous one can be freed. The current one can't, as its | ||
| 594 | + next_ws field is used. */ | ||
| 595 | + struct gomp_work_share *last_work_share; | ||
| 596 | + | ||
| 597 | /* This is the ID of this thread within the team. This value is | ||
| 598 | guaranteed to be between 0 and N-1, where N is the number of | ||
| 599 | threads in the team. */ | ||
| 600 | unsigned team_id; | ||
| 601 | |||
| 602 | - /* The work share "generation" is a number that increases by one for | ||
| 603 | - each work share construct encountered in the dynamic flow of the | ||
| 604 | - program. It is used to find the control data for the work share | ||
| 605 | - when encountering it for the first time. This particular number | ||
| 606 | - reflects the generation of the work_share member of this struct. */ | ||
| 607 | - unsigned work_share_generation; | ||
| 608 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 609 | + /* Number of single stmts encountered. */ | ||
| 610 | + unsigned long single_count; | ||
| 611 | +#endif | ||
| 612 | |||
| 613 | /* For GFS_RUNTIME loops that resolved to GFS_STATIC, this is the | ||
| 614 | trip number through the loop. So first time a particular loop | ||
| 615 | @@ -163,41 +191,53 @@ struct gomp_team_state | ||
| 616 | |||
| 617 | struct gomp_team | ||
| 618 | { | ||
| 619 | - /* This lock protects access to the following work shares data structures. */ | ||
| 620 | - gomp_mutex_t work_share_lock; | ||
| 621 | - | ||
| 622 | - /* This is a dynamically sized array containing pointers to the control | ||
| 623 | - structs for all "live" work share constructs. Here "live" means that | ||
| 624 | - the construct has been encountered by at least one thread, and not | ||
| 625 | - completed by all threads. */ | ||
| 626 | - struct gomp_work_share **work_shares; | ||
| 627 | - | ||
| 628 | - /* The work_shares array is indexed by "generation & generation_mask". | ||
| 629 | - The mask will be 2**N - 1, where 2**N is the size of the array. */ | ||
| 630 | - unsigned generation_mask; | ||
| 631 | - | ||
| 632 | - /* These two values define the bounds of the elements of the work_shares | ||
| 633 | - array that are currently in use. */ | ||
| 634 | - unsigned oldest_live_gen; | ||
| 635 | - unsigned num_live_gen; | ||
| 636 | - | ||
| 637 | /* This is the number of threads in the current team. */ | ||
| 638 | unsigned nthreads; | ||
| 639 | |||
| 640 | + /* This is number of gomp_work_share structs that have been allocated | ||
| 641 | + as a block last time. */ | ||
| 642 | + unsigned work_share_chunk; | ||
| 643 | + | ||
| 644 | /* This is the saved team state that applied to a master thread before | ||
| 645 | the current thread was created. */ | ||
| 646 | struct gomp_team_state prev_ts; | ||
| 647 | |||
| 648 | - /* This barrier is used for most synchronization of the team. */ | ||
| 649 | - gomp_barrier_t barrier; | ||
| 650 | - | ||
| 651 | /* This semaphore should be used by the master thread instead of its | ||
| 652 | "native" semaphore in the thread structure. Required for nested | ||
| 653 | parallels, as the master is a member of two teams. */ | ||
| 654 | gomp_sem_t master_release; | ||
| 655 | |||
| 656 | - /* This array contains pointers to the release semaphore of the threads | ||
| 657 | - in the team. */ | ||
| 658 | + /* List of gomp_work_share structs chained through next_free fields. | ||
| 659 | + This is populated and taken off only by the first thread in the | ||
| 660 | + team encountering a new work sharing construct, in a critical | ||
| 661 | + section. */ | ||
| 662 | + struct gomp_work_share *work_share_list_alloc; | ||
| 663 | + | ||
| 664 | + /* List of gomp_work_share structs freed by free_work_share. New | ||
| 665 | + entries are atomically added to the start of the list, and | ||
| 666 | + alloc_work_share can safely only move all but the first entry | ||
| 667 | + to work_share_list alloc, as free_work_share can happen concurrently | ||
| 668 | + with alloc_work_share. */ | ||
| 669 | + struct gomp_work_share *work_share_list_free; | ||
| 670 | + | ||
| 671 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 672 | + /* Number of simple single regions encountered by threads in this | ||
| 673 | + team. */ | ||
| 674 | + unsigned long single_count; | ||
| 675 | +#else | ||
| 676 | + /* Mutex protecting addition of workshares to work_share_list_free. */ | ||
| 677 | + gomp_mutex_t work_share_list_free_lock; | ||
| 678 | +#endif | ||
| 679 | + | ||
| 680 | + /* This barrier is used for most synchronization of the team. */ | ||
| 681 | + gomp_barrier_t barrier; | ||
| 682 | + | ||
| 683 | + /* Initial work shares, to avoid allocating any gomp_work_share | ||
| 684 | + structs in the common case. */ | ||
| 685 | + struct gomp_work_share work_shares[8]; | ||
| 686 | + | ||
| 687 | + /* This is an array with pointers to the release semaphore | ||
| 688 | + of the threads in the team. */ | ||
| 689 | gomp_sem_t *ordered_release[]; | ||
| 690 | }; | ||
| 691 | |||
| 692 | @@ -242,6 +282,11 @@ extern bool gomp_dyn_var; | ||
| 693 | extern bool gomp_nest_var; | ||
| 694 | extern enum gomp_schedule_type gomp_run_sched_var; | ||
| 695 | extern unsigned long gomp_run_sched_chunk; | ||
| 696 | +#ifndef HAVE_SYNC_BUILTINS | ||
| 697 | +extern gomp_mutex_t gomp_remaining_threads_lock; | ||
| 698 | +#endif | ||
| 699 | +extern unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var; | ||
| 700 | +extern unsigned long gomp_available_cpus, gomp_managed_threads; | ||
| 701 | |||
| 702 | /* The attributes to be used during thread creation. */ | ||
| 703 | extern pthread_attr_t gomp_thread_attr; | ||
| 704 | @@ -306,17 +351,27 @@ extern unsigned gomp_dynamic_max_threads | ||
| 705 | |||
| 706 | /* team.c */ | ||
| 707 | |||
| 708 | +extern struct gomp_team *gomp_new_team (unsigned); | ||
| 709 | extern void gomp_team_start (void (*) (void *), void *, unsigned, | ||
| 710 | - struct gomp_work_share *); | ||
| 711 | + struct gomp_team *); | ||
| 712 | extern void gomp_team_end (void); | ||
| 713 | |||
| 714 | /* work.c */ | ||
| 715 | |||
| 716 | -extern struct gomp_work_share * gomp_new_work_share (bool, unsigned); | ||
| 717 | +extern void gomp_init_work_share (struct gomp_work_share *, bool, unsigned); | ||
| 718 | +extern void gomp_fini_work_share (struct gomp_work_share *); | ||
| 719 | extern bool gomp_work_share_start (bool); | ||
| 720 | extern void gomp_work_share_end (void); | ||
| 721 | extern void gomp_work_share_end_nowait (void); | ||
| 722 | |||
| 723 | +static inline void | ||
| 724 | +gomp_work_share_init_done (void) | ||
| 725 | +{ | ||
| 726 | + struct gomp_thread *thr = gomp_thread (); | ||
| 727 | + if (__builtin_expect (thr->ts.last_work_share != NULL, 1)) | ||
| 728 | + gomp_ptrlock_set (&thr->ts.last_work_share->next_ws, thr->ts.work_share); | ||
| 729 | +} | ||
| 730 | + | ||
| 731 | #ifdef HAVE_ATTRIBUTE_VISIBILITY | ||
| 732 | # pragma GCC visibility pop | ||
| 733 | #endif | ||
| 734 | --- libgomp/iter.c.jj 2008-03-26 14:48:34.000000000 +0100 | ||
| 735 | +++ libgomp/iter.c 2008-03-26 15:11:23.000000000 +0100 | ||
| 736 | @@ -1,4 +1,4 @@ | ||
| 737 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 738 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 739 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 740 | |||
| 741 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 742 | @@ -154,7 +154,7 @@ gomp_iter_dynamic_next_locked (long *pst | ||
| 743 | if (start == ws->end) | ||
| 744 | return false; | ||
| 745 | |||
| 746 | - chunk = ws->chunk_size * ws->incr; | ||
| 747 | + chunk = ws->chunk_size; | ||
| 748 | left = ws->end - start; | ||
| 749 | if (ws->incr < 0) | ||
| 750 | { | ||
| 751 | @@ -186,11 +186,38 @@ gomp_iter_dynamic_next (long *pstart, lo | ||
| 752 | struct gomp_work_share *ws = thr->ts.work_share; | ||
| 753 | long start, end, nend, chunk, incr; | ||
| 754 | |||
| 755 | - start = ws->next; | ||
| 756 | end = ws->end; | ||
| 757 | incr = ws->incr; | ||
| 758 | - chunk = ws->chunk_size * incr; | ||
| 759 | + chunk = ws->chunk_size; | ||
| 760 | + | ||
| 761 | + if (__builtin_expect (ws->mode, 1)) | ||
| 762 | + { | ||
| 763 | + long tmp = __sync_fetch_and_add (&ws->next, chunk); | ||
| 764 | + if (incr > 0) | ||
| 765 | + { | ||
| 766 | + if (tmp >= end) | ||
| 767 | + return false; | ||
| 768 | + nend = tmp + chunk; | ||
| 769 | + if (nend > end) | ||
| 770 | + nend = end; | ||
| 771 | + *pstart = tmp; | ||
| 772 | + *pend = nend; | ||
| 773 | + return true; | ||
| 774 | + } | ||
| 775 | + else | ||
| 776 | + { | ||
| 777 | + if (tmp <= end) | ||
| 778 | + return false; | ||
| 779 | + nend = tmp + chunk; | ||
| 780 | + if (nend < end) | ||
| 781 | + nend = end; | ||
| 782 | + *pstart = tmp; | ||
| 783 | + *pend = nend; | ||
| 784 | + return true; | ||
| 785 | + } | ||
| 786 | + } | ||
| 787 | |||
| 788 | + start = ws->next; | ||
| 789 | while (1) | ||
| 790 | { | ||
| 791 | long left = end - start; | ||
| 792 | --- libgomp/work.c.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 793 | +++ libgomp/work.c 2008-03-27 12:21:51.000000000 +0100 | ||
| 794 | @@ -1,4 +1,4 @@ | ||
| 795 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 796 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 797 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 798 | |||
| 799 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 800 | @@ -29,39 +29,138 @@ | ||
| 801 | of threads. */ | ||
| 802 | |||
| 803 | #include "libgomp.h" | ||
| 804 | +#include <stddef.h> | ||
| 805 | #include <stdlib.h> | ||
| 806 | #include <string.h> | ||
| 807 | |||
| 808 | |||
| 809 | -/* Create a new work share structure. */ | ||
| 810 | +/* Allocate a new work share structure, preferably from current team's | ||
| 811 | + free gomp_work_share cache. */ | ||
| 812 | |||
| 813 | -struct gomp_work_share * | ||
| 814 | -gomp_new_work_share (bool ordered, unsigned nthreads) | ||
| 815 | +static struct gomp_work_share * | ||
| 816 | +alloc_work_share (struct gomp_team *team) | ||
| 817 | { | ||
| 818 | struct gomp_work_share *ws; | ||
| 819 | - size_t size; | ||
| 820 | + unsigned int i; | ||
| 821 | |||
| 822 | - size = sizeof (*ws); | ||
| 823 | - if (ordered) | ||
| 824 | - size += nthreads * sizeof (ws->ordered_team_ids[0]); | ||
| 825 | + /* This is called in a critical section. */ | ||
| 826 | + if (team->work_share_list_alloc != NULL) | ||
| 827 | + { | ||
| 828 | + ws = team->work_share_list_alloc; | ||
| 829 | + team->work_share_list_alloc = ws->next_free; | ||
| 830 | + return ws; | ||
| 831 | + } | ||
| 832 | |||
| 833 | - ws = gomp_malloc_cleared (size); | ||
| 834 | - gomp_mutex_init (&ws->lock); | ||
| 835 | - ws->ordered_owner = -1; | ||
| 836 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 837 | + ws = team->work_share_list_free; | ||
| 838 | + /* We need atomic read from work_share_list_free, | ||
| 839 | + as free_work_share can be called concurrently. */ | ||
| 840 | + __asm ("" : "+r" (ws)); | ||
| 841 | + | ||
| 842 | + if (ws && ws->next_free) | ||
| 843 | + { | ||
| 844 | + struct gomp_work_share *next = ws->next_free; | ||
| 845 | + ws->next_free = NULL; | ||
| 846 | + team->work_share_list_alloc = next->next_free; | ||
| 847 | + return next; | ||
| 848 | + } | ||
| 849 | +#else | ||
| 850 | + gomp_mutex_lock (&team->work_share_list_free_lock); | ||
| 851 | + ws = team->work_share_list_free; | ||
| 852 | + if (ws) | ||
| 853 | + { | ||
| 854 | + team->work_share_list_alloc = ws->next_free; | ||
| 855 | + team->work_share_list_free = NULL; | ||
| 856 | + gomp_mutex_unlock (&team->work_share_list_free_lock); | ||
| 857 | + return ws; | ||
| 858 | + } | ||
| 859 | + gomp_mutex_unlock (&team->work_share_list_free_lock); | ||
| 860 | +#endif | ||
| 861 | |||
| 862 | + team->work_share_chunk *= 2; | ||
| 863 | + ws = gomp_malloc (team->work_share_chunk * sizeof (struct gomp_work_share)); | ||
| 864 | + ws->next_alloc = team->work_shares[0].next_alloc; | ||
| 865 | + team->work_shares[0].next_alloc = ws; | ||
| 866 | + team->work_share_list_alloc = &ws[1]; | ||
| 867 | + for (i = 1; i < team->work_share_chunk - 1; i++) | ||
| 868 | + ws[i].next_free = &ws[i + 1]; | ||
| 869 | + ws[i].next_free = NULL; | ||
| 870 | return ws; | ||
| 871 | } | ||
| 872 | |||
| 873 | +/* Initialize an already allocated struct gomp_work_share. | ||
| 874 | + This shouldn't touch the next_alloc field. */ | ||
| 875 | + | ||
| 876 | +void | ||
| 877 | +gomp_init_work_share (struct gomp_work_share *ws, bool ordered, | ||
| 878 | + unsigned nthreads) | ||
| 879 | +{ | ||
| 880 | + gomp_mutex_init (&ws->lock); | ||
| 881 | + if (__builtin_expect (ordered, 0)) | ||
| 882 | + { | ||
| 883 | +#define INLINE_ORDERED_TEAM_IDS_CNT \ | ||
| 884 | + ((sizeof (struct gomp_work_share) \ | ||
| 885 | + - offsetof (struct gomp_work_share, inline_ordered_team_ids)) \ | ||
| 886 | + / sizeof (((struct gomp_work_share *) 0)->inline_ordered_team_ids[0])) | ||
| 887 | + | ||
| 888 | + if (nthreads > INLINE_ORDERED_TEAM_IDS_CNT) | ||
| 889 | + ws->ordered_team_ids | ||
| 890 | + = gomp_malloc (nthreads * sizeof (*ws->ordered_team_ids)); | ||
| 891 | + else | ||
| 892 | + ws->ordered_team_ids = ws->inline_ordered_team_ids; | ||
| 893 | + memset (ws->ordered_team_ids, '\0', | ||
| 894 | + nthreads * sizeof (*ws->ordered_team_ids)); | ||
| 895 | + ws->ordered_num_used = 0; | ||
| 896 | + ws->ordered_owner = -1; | ||
| 897 | + ws->ordered_cur = 0; | ||
| 898 | + } | ||
| 899 | + else | ||
| 900 | + ws->ordered_team_ids = NULL; | ||
| 901 | + gomp_ptrlock_init (&ws->next_ws, NULL); | ||
| 902 | + ws->threads_completed = 0; | ||
| 903 | +} | ||
| 904 | |||
| 905 | -/* Free a work share structure. */ | ||
| 906 | +/* Do any needed destruction of gomp_work_share fields before it | ||
| 907 | + is put back into free gomp_work_share cache or freed. */ | ||
| 908 | |||
| 909 | -static void | ||
| 910 | -free_work_share (struct gomp_work_share *ws) | ||
| 911 | +void | ||
| 912 | +gomp_fini_work_share (struct gomp_work_share *ws) | ||
| 913 | { | ||
| 914 | gomp_mutex_destroy (&ws->lock); | ||
| 915 | - free (ws); | ||
| 916 | + if (ws->ordered_team_ids != ws->inline_ordered_team_ids) | ||
| 917 | + free (ws->ordered_team_ids); | ||
| 918 | + gomp_ptrlock_destroy (&ws->next_ws); | ||
| 919 | } | ||
| 920 | |||
| 921 | +/* Free a work share struct, if not orphaned, put it into current | ||
| 922 | + team's free gomp_work_share cache. */ | ||
| 923 | + | ||
| 924 | +static inline void | ||
| 925 | +free_work_share (struct gomp_team *team, struct gomp_work_share *ws) | ||
| 926 | +{ | ||
| 927 | + gomp_fini_work_share (ws); | ||
| 928 | + if (__builtin_expect (team == NULL, 0)) | ||
| 929 | + free (ws); | ||
| 930 | + else | ||
| 931 | + { | ||
| 932 | + struct gomp_work_share *next_ws; | ||
| 933 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 934 | + do | ||
| 935 | + { | ||
| 936 | + next_ws = team->work_share_list_free; | ||
| 937 | + ws->next_free = next_ws; | ||
| 938 | + } | ||
| 939 | + while (!__sync_bool_compare_and_swap (&team->work_share_list_free, | ||
| 940 | + next_ws, ws)); | ||
| 941 | +#else | ||
| 942 | + gomp_mutex_lock (&team->work_share_list_free_lock); | ||
| 943 | + next_ws = team->work_share_list_free; | ||
| 944 | + ws->next_free = next_ws; | ||
| 945 | + team->work_share_list_free = ws; | ||
| 946 | + gomp_mutex_unlock (&team->work_share_list_free_lock); | ||
| 947 | +#endif | ||
| 948 | + } | ||
| 949 | +} | ||
| 950 | |||
| 951 | /* The current thread is ready to begin the next work sharing construct. | ||
| 952 | In all cases, thr->ts.work_share is updated to point to the new | ||
| 953 | @@ -74,71 +173,34 @@ gomp_work_share_start (bool ordered) | ||
| 954 | struct gomp_thread *thr = gomp_thread (); | ||
| 955 | struct gomp_team *team = thr->ts.team; | ||
| 956 | struct gomp_work_share *ws; | ||
| 957 | - unsigned ws_index, ws_gen; | ||
| 958 | |||
| 959 | /* Work sharing constructs can be orphaned. */ | ||
| 960 | if (team == NULL) | ||
| 961 | { | ||
| 962 | - ws = gomp_new_work_share (ordered, 1); | ||
| 963 | + ws = gomp_malloc (sizeof (*ws)); | ||
| 964 | + gomp_init_work_share (ws, ordered, 1); | ||
| 965 | thr->ts.work_share = ws; | ||
| 966 | - thr->ts.static_trip = 0; | ||
| 967 | - gomp_mutex_lock (&ws->lock); | ||
| 968 | - return true; | ||
| 969 | + return ws; | ||
| 970 | } | ||
| 971 | |||
| 972 | - gomp_mutex_lock (&team->work_share_lock); | ||
| 973 | - | ||
| 974 | - /* This thread is beginning its next generation. */ | ||
| 975 | - ws_gen = ++thr->ts.work_share_generation; | ||
| 976 | - | ||
| 977 | - /* If this next generation is not newer than any other generation in | ||
| 978 | - the team, then simply reference the existing construct. */ | ||
| 979 | - if (ws_gen - team->oldest_live_gen < team->num_live_gen) | ||
| 980 | + ws = thr->ts.work_share; | ||
| 981 | + thr->ts.last_work_share = ws; | ||
| 982 | + ws = gomp_ptrlock_get (&ws->next_ws); | ||
| 983 | + if (ws == NULL) | ||
| 984 | { | ||
| 985 | - ws_index = ws_gen & team->generation_mask; | ||
| 986 | - ws = team->work_shares[ws_index]; | ||
| 987 | + /* This thread encountered a new ws first. */ | ||
| 988 | + struct gomp_work_share *ws = alloc_work_share (team); | ||
| 989 | + gomp_init_work_share (ws, ordered, team->nthreads); | ||
| 990 | thr->ts.work_share = ws; | ||
| 991 | - thr->ts.static_trip = 0; | ||
| 992 | - | ||
| 993 | - gomp_mutex_lock (&ws->lock); | ||
| 994 | - gomp_mutex_unlock (&team->work_share_lock); | ||
| 995 | - | ||
| 996 | - return false; | ||
| 997 | + return true; | ||
| 998 | } | ||
| 999 | - | ||
| 1000 | - /* Resize the work shares queue if we've run out of space. */ | ||
| 1001 | - if (team->num_live_gen++ == team->generation_mask) | ||
| 1002 | + else | ||
| 1003 | { | ||
| 1004 | - team->work_shares = gomp_realloc (team->work_shares, | ||
| 1005 | - 2 * team->num_live_gen | ||
| 1006 | - * sizeof (*team->work_shares)); | ||
| 1007 | - | ||
| 1008 | - /* Unless oldest_live_gen is zero, the sequence of live elements | ||
| 1009 | - wraps around the end of the array. If we do nothing, we break | ||
| 1010 | - lookup of the existing elements. Fix that by unwrapping the | ||
| 1011 | - data from the front to the end. */ | ||
| 1012 | - if (team->oldest_live_gen > 0) | ||
| 1013 | - memcpy (team->work_shares + team->num_live_gen, | ||
| 1014 | - team->work_shares, | ||
| 1015 | - (team->oldest_live_gen & team->generation_mask) | ||
| 1016 | - * sizeof (*team->work_shares)); | ||
| 1017 | - | ||
| 1018 | - team->generation_mask = team->generation_mask * 2 + 1; | ||
| 1019 | - } | ||
| 1020 | - | ||
| 1021 | - ws_index = ws_gen & team->generation_mask; | ||
| 1022 | - ws = gomp_new_work_share (ordered, team->nthreads); | ||
| 1023 | - thr->ts.work_share = ws; | ||
| 1024 | - thr->ts.static_trip = 0; | ||
| 1025 | - team->work_shares[ws_index] = ws; | ||
| 1026 | - | ||
| 1027 | - gomp_mutex_lock (&ws->lock); | ||
| 1028 | - gomp_mutex_unlock (&team->work_share_lock); | ||
| 1029 | - | ||
| 1030 | - return true; | ||
| 1031 | + thr->ts.work_share = ws; | ||
| 1032 | + return false; | ||
| 1033 | + } | ||
| 1034 | } | ||
| 1035 | |||
| 1036 | - | ||
| 1037 | /* The current thread is done with its current work sharing construct. | ||
| 1038 | This version does imply a barrier at the end of the work-share. */ | ||
| 1039 | |||
| 1040 | @@ -147,36 +209,28 @@ gomp_work_share_end (void) | ||
| 1041 | { | ||
| 1042 | struct gomp_thread *thr = gomp_thread (); | ||
| 1043 | struct gomp_team *team = thr->ts.team; | ||
| 1044 | - struct gomp_work_share *ws = thr->ts.work_share; | ||
| 1045 | - bool last; | ||
| 1046 | - | ||
| 1047 | - thr->ts.work_share = NULL; | ||
| 1048 | + gomp_barrier_state_t bstate; | ||
| 1049 | |||
| 1050 | /* Work sharing constructs can be orphaned. */ | ||
| 1051 | if (team == NULL) | ||
| 1052 | { | ||
| 1053 | - free_work_share (ws); | ||
| 1054 | + free_work_share (NULL, thr->ts.work_share); | ||
| 1055 | + thr->ts.work_share = NULL; | ||
| 1056 | return; | ||
| 1057 | } | ||
| 1058 | |||
| 1059 | - last = gomp_barrier_wait_start (&team->barrier); | ||
| 1060 | + bstate = gomp_barrier_wait_start (&team->barrier); | ||
| 1061 | |||
| 1062 | - if (last) | ||
| 1063 | + if (gomp_barrier_last_thread (bstate)) | ||
| 1064 | { | ||
| 1065 | - unsigned ws_index; | ||
| 1066 | - | ||
| 1067 | - ws_index = thr->ts.work_share_generation & team->generation_mask; | ||
| 1068 | - team->work_shares[ws_index] = NULL; | ||
| 1069 | - team->oldest_live_gen++; | ||
| 1070 | - team->num_live_gen = 0; | ||
| 1071 | - | ||
| 1072 | - free_work_share (ws); | ||
| 1073 | + if (__builtin_expect (thr->ts.last_work_share != NULL, 1)) | ||
| 1074 | + free_work_share (team, thr->ts.last_work_share); | ||
| 1075 | } | ||
| 1076 | |||
| 1077 | - gomp_barrier_wait_end (&team->barrier, last); | ||
| 1078 | + gomp_barrier_wait_end (&team->barrier, bstate); | ||
| 1079 | + thr->ts.last_work_share = NULL; | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | - | ||
| 1083 | /* The current thread is done with its current work sharing construct. | ||
| 1084 | This version does NOT imply a barrier at the end of the work-share. */ | ||
| 1085 | |||
| 1086 | @@ -188,15 +242,17 @@ gomp_work_share_end_nowait (void) | ||
| 1087 | struct gomp_work_share *ws = thr->ts.work_share; | ||
| 1088 | unsigned completed; | ||
| 1089 | |||
| 1090 | - thr->ts.work_share = NULL; | ||
| 1091 | - | ||
| 1092 | /* Work sharing constructs can be orphaned. */ | ||
| 1093 | if (team == NULL) | ||
| 1094 | { | ||
| 1095 | - free_work_share (ws); | ||
| 1096 | + free_work_share (NULL, ws); | ||
| 1097 | + thr->ts.work_share = NULL; | ||
| 1098 | return; | ||
| 1099 | } | ||
| 1100 | |||
| 1101 | + if (__builtin_expect (thr->ts.last_work_share == NULL, 0)) | ||
| 1102 | + return; | ||
| 1103 | + | ||
| 1104 | #ifdef HAVE_SYNC_BUILTINS | ||
| 1105 | completed = __sync_add_and_fetch (&ws->threads_completed, 1); | ||
| 1106 | #else | ||
| 1107 | @@ -206,18 +262,6 @@ gomp_work_share_end_nowait (void) | ||
| 1108 | #endif | ||
| 1109 | |||
| 1110 | if (completed == team->nthreads) | ||
| 1111 | - { | ||
| 1112 | - unsigned ws_index; | ||
| 1113 | - | ||
| 1114 | - gomp_mutex_lock (&team->work_share_lock); | ||
| 1115 | - | ||
| 1116 | - ws_index = thr->ts.work_share_generation & team->generation_mask; | ||
| 1117 | - team->work_shares[ws_index] = NULL; | ||
| 1118 | - team->oldest_live_gen++; | ||
| 1119 | - team->num_live_gen--; | ||
| 1120 | - | ||
| 1121 | - gomp_mutex_unlock (&team->work_share_lock); | ||
| 1122 | - | ||
| 1123 | - free_work_share (ws); | ||
| 1124 | - } | ||
| 1125 | + free_work_share (team, thr->ts.last_work_share); | ||
| 1126 | + thr->ts.last_work_share = NULL; | ||
| 1127 | } | ||
| 1128 | --- libgomp/single.c.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 1129 | +++ libgomp/single.c 2008-03-26 15:11:32.000000000 +0100 | ||
| 1130 | @@ -1,4 +1,4 @@ | ||
| 1131 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 1132 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 1133 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 1134 | |||
| 1135 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 1136 | @@ -37,10 +37,24 @@ | ||
| 1137 | bool | ||
| 1138 | GOMP_single_start (void) | ||
| 1139 | { | ||
| 1140 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 1141 | + struct gomp_thread *thr = gomp_thread (); | ||
| 1142 | + struct gomp_team *team = thr->ts.team; | ||
| 1143 | + unsigned long single_count; | ||
| 1144 | + | ||
| 1145 | + if (__builtin_expect (team == NULL, 0)) | ||
| 1146 | + return true; | ||
| 1147 | + | ||
| 1148 | + single_count = thr->ts.single_count++; | ||
| 1149 | + return __sync_bool_compare_and_swap (&team->single_count, single_count, | ||
| 1150 | + single_count + 1L); | ||
| 1151 | +#else | ||
| 1152 | bool ret = gomp_work_share_start (false); | ||
| 1153 | - gomp_mutex_unlock (&gomp_thread ()->ts.work_share->lock); | ||
| 1154 | + if (ret) | ||
| 1155 | + gomp_work_share_init_done (); | ||
| 1156 | gomp_work_share_end_nowait (); | ||
| 1157 | return ret; | ||
| 1158 | +#endif | ||
| 1159 | } | ||
| 1160 | |||
| 1161 | /* This routine is called when first encountering a SINGLE construct that | ||
| 1162 | @@ -57,10 +71,12 @@ GOMP_single_copy_start (void) | ||
| 1163 | void *ret; | ||
| 1164 | |||
| 1165 | first = gomp_work_share_start (false); | ||
| 1166 | - gomp_mutex_unlock (&thr->ts.work_share->lock); | ||
| 1167 | |||
| 1168 | if (first) | ||
| 1169 | - ret = NULL; | ||
| 1170 | + { | ||
| 1171 | + gomp_work_share_init_done (); | ||
| 1172 | + ret = NULL; | ||
| 1173 | + } | ||
| 1174 | else | ||
| 1175 | { | ||
| 1176 | gomp_barrier_wait (&thr->ts.team->barrier); | ||
| 1177 | --- libgomp/loop.c.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 1178 | +++ libgomp/loop.c 2008-03-26 18:47:04.000000000 +0100 | ||
| 1179 | @@ -27,8 +27,9 @@ | ||
| 1180 | |||
| 1181 | /* This file handles the LOOP (FOR/DO) construct. */ | ||
| 1182 | |||
| 1183 | -#include "libgomp.h" | ||
| 1184 | +#include <limits.h> | ||
| 1185 | #include <stdlib.h> | ||
| 1186 | +#include "libgomp.h" | ||
| 1187 | |||
| 1188 | |||
| 1189 | /* Initialize the given work share construct from the given arguments. */ | ||
| 1190 | @@ -44,6 +45,39 @@ gomp_loop_init (struct gomp_work_share * | ||
| 1191 | ? start : end; | ||
| 1192 | ws->incr = incr; | ||
| 1193 | ws->next = start; | ||
| 1194 | + if (sched == GFS_DYNAMIC) | ||
| 1195 | + { | ||
| 1196 | + ws->chunk_size *= incr; | ||
| 1197 | + | ||
| 1198 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 1199 | + { | ||
| 1200 | + /* For dynamic scheduling prepare things to make each iteration | ||
| 1201 | + faster. */ | ||
| 1202 | + struct gomp_thread *thr = gomp_thread (); | ||
| 1203 | + struct gomp_team *team = thr->ts.team; | ||
| 1204 | + long nthreads = team ? team->nthreads : 1; | ||
| 1205 | + | ||
| 1206 | + if (__builtin_expect (incr > 0, 1)) | ||
| 1207 | + { | ||
| 1208 | + /* Cheap overflow protection. */ | ||
| 1209 | + if (__builtin_expect ((nthreads | ws->chunk_size) | ||
| 1210 | + >= 1UL << (sizeof (long) | ||
| 1211 | + * __CHAR_BIT__ / 2 - 1), 0)) | ||
| 1212 | + ws->mode = 0; | ||
| 1213 | + else | ||
| 1214 | + ws->mode = ws->end < (LONG_MAX | ||
| 1215 | + - (nthreads + 1) * ws->chunk_size); | ||
| 1216 | + } | ||
| 1217 | + /* Cheap overflow protection. */ | ||
| 1218 | + else if (__builtin_expect ((nthreads | -ws->chunk_size) | ||
| 1219 | + >= 1UL << (sizeof (long) | ||
| 1220 | + * __CHAR_BIT__ / 2 - 1), 0)) | ||
| 1221 | + ws->mode = 0; | ||
| 1222 | + else | ||
| 1223 | + ws->mode = ws->end > (nthreads + 1) * -ws->chunk_size - LONG_MAX; | ||
| 1224 | + } | ||
| 1225 | +#endif | ||
| 1226 | + } | ||
| 1227 | } | ||
| 1228 | |||
| 1229 | /* The *_start routines are called when first encountering a loop construct | ||
| 1230 | @@ -68,10 +102,13 @@ gomp_loop_static_start (long start, long | ||
| 1231 | { | ||
| 1232 | struct gomp_thread *thr = gomp_thread (); | ||
| 1233 | |||
| 1234 | + thr->ts.static_trip = 0; | ||
| 1235 | if (gomp_work_share_start (false)) | ||
| 1236 | - gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1237 | - GFS_STATIC, chunk_size); | ||
| 1238 | - gomp_mutex_unlock (&thr->ts.work_share->lock); | ||
| 1239 | + { | ||
| 1240 | + gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1241 | + GFS_STATIC, chunk_size); | ||
| 1242 | + gomp_work_share_init_done (); | ||
| 1243 | + } | ||
| 1244 | |||
| 1245 | return !gomp_iter_static_next (istart, iend); | ||
| 1246 | } | ||
| 1247 | @@ -84,13 +121,16 @@ gomp_loop_dynamic_start (long start, lon | ||
| 1248 | bool ret; | ||
| 1249 | |||
| 1250 | if (gomp_work_share_start (false)) | ||
| 1251 | - gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1252 | - GFS_DYNAMIC, chunk_size); | ||
| 1253 | + { | ||
| 1254 | + gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1255 | + GFS_DYNAMIC, chunk_size); | ||
| 1256 | + gomp_work_share_init_done (); | ||
| 1257 | + } | ||
| 1258 | |||
| 1259 | #ifdef HAVE_SYNC_BUILTINS | ||
| 1260 | - gomp_mutex_unlock (&thr->ts.work_share->lock); | ||
| 1261 | ret = gomp_iter_dynamic_next (istart, iend); | ||
| 1262 | #else | ||
| 1263 | + gomp_mutex_lock (&thr->ts.work_share->lock); | ||
| 1264 | ret = gomp_iter_dynamic_next_locked (istart, iend); | ||
| 1265 | gomp_mutex_unlock (&thr->ts.work_share->lock); | ||
| 1266 | #endif | ||
| 1267 | @@ -106,13 +146,16 @@ gomp_loop_guided_start (long start, long | ||
| 1268 | bool ret; | ||
| 1269 | |||
| 1270 | if (gomp_work_share_start (false)) | ||
| 1271 | - gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1272 | - GFS_GUIDED, chunk_size); | ||
| 1273 | + { | ||
| 1274 | + gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1275 | + GFS_GUIDED, chunk_size); | ||
| 1276 | + gomp_work_share_init_done (); | ||
| 1277 | + } | ||
| 1278 | |||
| 1279 | #ifdef HAVE_SYNC_BUILTINS | ||
| 1280 | - gomp_mutex_unlock (&thr->ts.work_share->lock); | ||
| 1281 | ret = gomp_iter_guided_next (istart, iend); | ||
| 1282 | #else | ||
| 1283 | + gomp_mutex_lock (&thr->ts.work_share->lock); | ||
| 1284 | ret = gomp_iter_guided_next_locked (istart, iend); | ||
| 1285 | gomp_mutex_unlock (&thr->ts.work_share->lock); | ||
| 1286 | #endif | ||
| 1287 | @@ -149,13 +192,14 @@ gomp_loop_ordered_static_start (long sta | ||
| 1288 | { | ||
| 1289 | struct gomp_thread *thr = gomp_thread (); | ||
| 1290 | |||
| 1291 | + thr->ts.static_trip = 0; | ||
| 1292 | if (gomp_work_share_start (true)) | ||
| 1293 | { | ||
| 1294 | gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1295 | GFS_STATIC, chunk_size); | ||
| 1296 | gomp_ordered_static_init (); | ||
| 1297 | + gomp_work_share_init_done (); | ||
| 1298 | } | ||
| 1299 | - gomp_mutex_unlock (&thr->ts.work_share->lock); | ||
| 1300 | |||
| 1301 | return !gomp_iter_static_next (istart, iend); | ||
| 1302 | } | ||
| 1303 | @@ -168,8 +212,14 @@ gomp_loop_ordered_dynamic_start (long st | ||
| 1304 | bool ret; | ||
| 1305 | |||
| 1306 | if (gomp_work_share_start (true)) | ||
| 1307 | - gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1308 | - GFS_DYNAMIC, chunk_size); | ||
| 1309 | + { | ||
| 1310 | + gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1311 | + GFS_DYNAMIC, chunk_size); | ||
| 1312 | + gomp_mutex_lock (&thr->ts.work_share->lock); | ||
| 1313 | + gomp_work_share_init_done (); | ||
| 1314 | + } | ||
| 1315 | + else | ||
| 1316 | + gomp_mutex_lock (&thr->ts.work_share->lock); | ||
| 1317 | |||
| 1318 | ret = gomp_iter_dynamic_next_locked (istart, iend); | ||
| 1319 | if (ret) | ||
| 1320 | @@ -187,8 +237,14 @@ gomp_loop_ordered_guided_start (long sta | ||
| 1321 | bool ret; | ||
| 1322 | |||
| 1323 | if (gomp_work_share_start (true)) | ||
| 1324 | - gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1325 | - GFS_GUIDED, chunk_size); | ||
| 1326 | + { | ||
| 1327 | + gomp_loop_init (thr->ts.work_share, start, end, incr, | ||
| 1328 | + GFS_GUIDED, chunk_size); | ||
| 1329 | + gomp_mutex_lock (&thr->ts.work_share->lock); | ||
| 1330 | + gomp_work_share_init_done (); | ||
| 1331 | + } | ||
| 1332 | + else | ||
| 1333 | + gomp_mutex_lock (&thr->ts.work_share->lock); | ||
| 1334 | |||
| 1335 | ret = gomp_iter_guided_next_locked (istart, iend); | ||
| 1336 | if (ret) | ||
| 1337 | @@ -375,12 +431,12 @@ gomp_parallel_loop_start (void (*fn) (vo | ||
| 1338 | long incr, enum gomp_schedule_type sched, | ||
| 1339 | long chunk_size) | ||
| 1340 | { | ||
| 1341 | - struct gomp_work_share *ws; | ||
| 1342 | + struct gomp_team *team; | ||
| 1343 | |||
| 1344 | num_threads = gomp_resolve_num_threads (num_threads); | ||
| 1345 | - ws = gomp_new_work_share (false, num_threads); | ||
| 1346 | - gomp_loop_init (ws, start, end, incr, sched, chunk_size); | ||
| 1347 | - gomp_team_start (fn, data, num_threads, ws); | ||
| 1348 | + team = gomp_new_team (num_threads); | ||
| 1349 | + gomp_loop_init (&team->work_shares[0], start, end, incr, sched, chunk_size); | ||
| 1350 | + gomp_team_start (fn, data, num_threads, team); | ||
| 1351 | } | ||
| 1352 | |||
| 1353 | void | ||
| 1354 | --- libgomp/Makefile.in.jj 2008-01-10 20:53:47.000000000 +0100 | ||
| 1355 | +++ libgomp/Makefile.in 2008-03-26 18:51:01.000000000 +0100 | ||
| 1356 | @@ -83,7 +83,7 @@ libgomp_la_LIBADD = | ||
| 1357 | am_libgomp_la_OBJECTS = alloc.lo barrier.lo critical.lo env.lo \ | ||
| 1358 | error.lo iter.lo loop.lo ordered.lo parallel.lo sections.lo \ | ||
| 1359 | single.lo team.lo work.lo lock.lo mutex.lo proc.lo sem.lo \ | ||
| 1360 | - bar.lo time.lo fortran.lo affinity.lo | ||
| 1361 | + bar.lo ptrlock.lo time.lo fortran.lo affinity.lo | ||
| 1362 | libgomp_la_OBJECTS = $(am_libgomp_la_OBJECTS) | ||
| 1363 | DEFAULT_INCLUDES = -I. -I$(srcdir) -I. | ||
| 1364 | depcomp = $(SHELL) $(top_srcdir)/../depcomp | ||
| 1365 | @@ -292,7 +292,7 @@ libgomp_version_info = -version-info $(l | ||
| 1366 | libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) | ||
| 1367 | libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \ | ||
| 1368 | loop.c ordered.c parallel.c sections.c single.c team.c work.c \ | ||
| 1369 | - lock.c mutex.c proc.c sem.c bar.c time.c fortran.c affinity.c | ||
| 1370 | + lock.c mutex.c proc.c sem.c bar.c ptrlock.c time.c fortran.c affinity.c | ||
| 1371 | |||
| 1372 | nodist_noinst_HEADERS = libgomp_f.h | ||
| 1373 | nodist_libsubinclude_HEADERS = omp.h | ||
| 1374 | @@ -434,6 +434,7 @@ distclean-compile: | ||
| 1375 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ordered.Plo@am__quote@ | ||
| 1376 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parallel.Plo@am__quote@ | ||
| 1377 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proc.Plo@am__quote@ | ||
| 1378 | +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptrlock.Plo@am__quote@ | ||
| 1379 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sections.Plo@am__quote@ | ||
| 1380 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sem.Plo@am__quote@ | ||
| 1381 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/single.Plo@am__quote@ | ||
| 1382 | --- libgomp/testsuite/libgomp.c/loop-4.c.jj 2008-03-26 18:47:04.000000000 +0100 | ||
| 1383 | +++ libgomp/testsuite/libgomp.c/loop-4.c 2008-03-26 18:47:04.000000000 +0100 | ||
| 1384 | @@ -0,0 +1,28 @@ | ||
| 1385 | +/* { dg-do run } */ | ||
| 1386 | + | ||
| 1387 | +extern void abort (void); | ||
| 1388 | + | ||
| 1389 | +int | ||
| 1390 | +main (void) | ||
| 1391 | +{ | ||
| 1392 | + int e = 0; | ||
| 1393 | +#pragma omp parallel num_threads (4) reduction(+:e) | ||
| 1394 | + { | ||
| 1395 | + long i; | ||
| 1396 | + #pragma omp for schedule(dynamic,1) | ||
| 1397 | + for (i = __LONG_MAX__ - 30001; i <= __LONG_MAX__ - 10001; i += 10000) | ||
| 1398 | + if (i != __LONG_MAX__ - 30001 | ||
| 1399 | + && i != __LONG_MAX__ - 20001 | ||
| 1400 | + && i != __LONG_MAX__ - 10001) | ||
| 1401 | + e = 1; | ||
| 1402 | + #pragma omp for schedule(dynamic,1) | ||
| 1403 | + for (i = -__LONG_MAX__ + 30000; i >= -__LONG_MAX__ + 10000; i -= 10000) | ||
| 1404 | + if (i != -__LONG_MAX__ + 30000 | ||
| 1405 | + && i != -__LONG_MAX__ + 20000 | ||
| 1406 | + && i != -__LONG_MAX__ + 10000) | ||
| 1407 | + e = 1; | ||
| 1408 | + } | ||
| 1409 | + if (e) | ||
| 1410 | + abort (); | ||
| 1411 | + return 0; | ||
| 1412 | +} | ||
| 1413 | --- libgomp/Makefile.am.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 1414 | +++ libgomp/Makefile.am 2008-03-26 15:15:19.000000000 +0100 | ||
| 1415 | @@ -31,7 +31,7 @@ libgomp_la_LDFLAGS = $(libgomp_version_i | ||
| 1416 | |||
| 1417 | libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \ | ||
| 1418 | loop.c ordered.c parallel.c sections.c single.c team.c work.c \ | ||
| 1419 | - lock.c mutex.c proc.c sem.c bar.c time.c fortran.c affinity.c | ||
| 1420 | + lock.c mutex.c proc.c sem.c bar.c ptrlock.c time.c fortran.c affinity.c | ||
| 1421 | |||
| 1422 | nodist_noinst_HEADERS = libgomp_f.h | ||
| 1423 | nodist_libsubinclude_HEADERS = omp.h | ||
| 1424 | --- libgomp/team.c.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 1425 | +++ libgomp/team.c 2008-03-27 12:22:26.000000000 +0100 | ||
| 1426 | @@ -94,7 +94,7 @@ gomp_thread_start (void *xdata) | ||
| 1427 | { | ||
| 1428 | gomp_barrier_wait (&thr->ts.team->barrier); | ||
| 1429 | local_fn (local_data); | ||
| 1430 | - gomp_barrier_wait (&thr->ts.team->barrier); | ||
| 1431 | + gomp_barrier_wait_last (&thr->ts.team->barrier); | ||
| 1432 | } | ||
| 1433 | else | ||
| 1434 | { | ||
| 1435 | @@ -114,11 +114,10 @@ gomp_thread_start (void *xdata) | ||
| 1436 | thr->data = NULL; | ||
| 1437 | thr->ts.team = NULL; | ||
| 1438 | thr->ts.work_share = NULL; | ||
| 1439 | + thr->ts.last_work_share = NULL; | ||
| 1440 | thr->ts.team_id = 0; | ||
| 1441 | - thr->ts.work_share_generation = 0; | ||
| 1442 | - thr->ts.static_trip = 0; | ||
| 1443 | |||
| 1444 | - gomp_barrier_wait (&team->barrier); | ||
| 1445 | + gomp_barrier_wait_last (&team->barrier); | ||
| 1446 | gomp_barrier_wait (&gomp_threads_dock); | ||
| 1447 | |||
| 1448 | local_fn = thr->fn; | ||
| 1449 | @@ -133,21 +132,29 @@ gomp_thread_start (void *xdata) | ||
| 1450 | |||
| 1451 | /* Create a new team data structure. */ | ||
| 1452 | |||
| 1453 | -static struct gomp_team * | ||
| 1454 | -new_team (unsigned nthreads, struct gomp_work_share *work_share) | ||
| 1455 | +struct gomp_team * | ||
| 1456 | +gomp_new_team (unsigned nthreads) | ||
| 1457 | { | ||
| 1458 | struct gomp_team *team; | ||
| 1459 | size_t size; | ||
| 1460 | + int i; | ||
| 1461 | |||
| 1462 | size = sizeof (*team) + nthreads * sizeof (team->ordered_release[0]); | ||
| 1463 | team = gomp_malloc (size); | ||
| 1464 | - gomp_mutex_init (&team->work_share_lock); | ||
| 1465 | |||
| 1466 | - team->work_shares = gomp_malloc (4 * sizeof (struct gomp_work_share *)); | ||
| 1467 | - team->generation_mask = 3; | ||
| 1468 | - team->oldest_live_gen = work_share == NULL; | ||
| 1469 | - team->num_live_gen = work_share != NULL; | ||
| 1470 | - team->work_shares[0] = work_share; | ||
| 1471 | + team->work_share_chunk = 8; | ||
| 1472 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 1473 | + team->single_count = 0; | ||
| 1474 | +#else | ||
| 1475 | + gomp_mutex_init (&team->work_share_list_free_lock); | ||
| 1476 | +#endif | ||
| 1477 | + gomp_init_work_share (&team->work_shares[0], false, nthreads); | ||
| 1478 | + team->work_shares[0].next_alloc = NULL; | ||
| 1479 | + team->work_share_list_free = NULL; | ||
| 1480 | + team->work_share_list_alloc = &team->work_shares[1]; | ||
| 1481 | + for (i = 1; i < 7; i++) | ||
| 1482 | + team->work_shares[i].next_free = &team->work_shares[i + 1]; | ||
| 1483 | + team->work_shares[i].next_free = NULL; | ||
| 1484 | |||
| 1485 | team->nthreads = nthreads; | ||
| 1486 | gomp_barrier_init (&team->barrier, nthreads); | ||
| 1487 | @@ -164,10 +171,22 @@ new_team (unsigned nthreads, struct gomp | ||
| 1488 | static void | ||
| 1489 | free_team (struct gomp_team *team) | ||
| 1490 | { | ||
| 1491 | - free (team->work_shares); | ||
| 1492 | - gomp_mutex_destroy (&team->work_share_lock); | ||
| 1493 | + if (__builtin_expect (team->work_shares[0].next_alloc != NULL, 0)) | ||
| 1494 | + { | ||
| 1495 | + struct gomp_work_share *ws = team->work_shares[0].next_alloc; | ||
| 1496 | + do | ||
| 1497 | + { | ||
| 1498 | + struct gomp_work_share *next_ws = ws->next_alloc; | ||
| 1499 | + free (ws); | ||
| 1500 | + ws = next_ws; | ||
| 1501 | + } | ||
| 1502 | + while (ws != NULL); | ||
| 1503 | + } | ||
| 1504 | gomp_barrier_destroy (&team->barrier); | ||
| 1505 | gomp_sem_destroy (&team->master_release); | ||
| 1506 | +#ifndef HAVE_SYNC_BUILTINS | ||
| 1507 | + gomp_mutex_destroy (&team->work_share_list_free_lock); | ||
| 1508 | +#endif | ||
| 1509 | free (team); | ||
| 1510 | } | ||
| 1511 | |||
| 1512 | @@ -176,11 +195,10 @@ free_team (struct gomp_team *team) | ||
| 1513 | |||
| 1514 | void | ||
| 1515 | gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, | ||
| 1516 | - struct gomp_work_share *work_share) | ||
| 1517 | + struct gomp_team *team) | ||
| 1518 | { | ||
| 1519 | struct gomp_thread_start_data *start_data; | ||
| 1520 | struct gomp_thread *thr, *nthr; | ||
| 1521 | - struct gomp_team *team; | ||
| 1522 | bool nested; | ||
| 1523 | unsigned i, n, old_threads_used = 0; | ||
| 1524 | pthread_attr_t thread_attr, *attr; | ||
| 1525 | @@ -188,17 +206,18 @@ gomp_team_start (void (*fn) (void *), vo | ||
| 1526 | thr = gomp_thread (); | ||
| 1527 | nested = thr->ts.team != NULL; | ||
| 1528 | |||
| 1529 | - team = new_team (nthreads, work_share); | ||
| 1530 | - | ||
| 1531 | /* Always save the previous state, even if this isn't a nested team. | ||
| 1532 | In particular, we should save any work share state from an outer | ||
| 1533 | orphaned work share construct. */ | ||
| 1534 | team->prev_ts = thr->ts; | ||
| 1535 | |||
| 1536 | thr->ts.team = team; | ||
| 1537 | - thr->ts.work_share = work_share; | ||
| 1538 | thr->ts.team_id = 0; | ||
| 1539 | - thr->ts.work_share_generation = 0; | ||
| 1540 | + thr->ts.work_share = &team->work_shares[0]; | ||
| 1541 | + thr->ts.last_work_share = NULL; | ||
| 1542 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 1543 | + thr->ts.single_count = 0; | ||
| 1544 | +#endif | ||
| 1545 | thr->ts.static_trip = 0; | ||
| 1546 | |||
| 1547 | if (nthreads == 1) | ||
| 1548 | @@ -241,9 +260,12 @@ gomp_team_start (void (*fn) (void *), vo | ||
| 1549 | { | ||
| 1550 | nthr = gomp_threads[i]; | ||
| 1551 | nthr->ts.team = team; | ||
| 1552 | - nthr->ts.work_share = work_share; | ||
| 1553 | + nthr->ts.work_share = &team->work_shares[0]; | ||
| 1554 | + nthr->ts.last_work_share = NULL; | ||
| 1555 | nthr->ts.team_id = i; | ||
| 1556 | - nthr->ts.work_share_generation = 0; | ||
| 1557 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 1558 | + nthr->ts.single_count = 0; | ||
| 1559 | +#endif | ||
| 1560 | nthr->ts.static_trip = 0; | ||
| 1561 | nthr->fn = fn; | ||
| 1562 | nthr->data = data; | ||
| 1563 | @@ -266,8 +288,24 @@ gomp_team_start (void (*fn) (void *), vo | ||
| 1564 | } | ||
| 1565 | } | ||
| 1566 | |||
| 1567 | + if (__builtin_expect (nthreads > old_threads_used, 0)) | ||
| 1568 | + { | ||
| 1569 | + long diff = (long) nthreads - (long) old_threads_used; | ||
| 1570 | + | ||
| 1571 | + if (old_threads_used == 0) | ||
| 1572 | + --diff; | ||
| 1573 | + | ||
| 1574 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 1575 | + __sync_fetch_and_add (&gomp_managed_threads, diff); | ||
| 1576 | +#else | ||
| 1577 | + gomp_mutex_lock (&gomp_remaining_threads_lock); | ||
| 1578 | + gomp_managed_threads += diff; | ||
| 1579 | + gomp_mutex_unlock (&gomp_remaining_threads_lock); | ||
| 1580 | +#endif | ||
| 1581 | + } | ||
| 1582 | + | ||
| 1583 | attr = &gomp_thread_attr; | ||
| 1584 | - if (gomp_cpu_affinity != NULL) | ||
| 1585 | + if (__builtin_expect (gomp_cpu_affinity != NULL, 0)) | ||
| 1586 | { | ||
| 1587 | size_t stacksize; | ||
| 1588 | pthread_attr_init (&thread_attr); | ||
| 1589 | @@ -287,9 +325,12 @@ gomp_team_start (void (*fn) (void *), vo | ||
| 1590 | int err; | ||
| 1591 | |||
| 1592 | start_data->ts.team = team; | ||
| 1593 | - start_data->ts.work_share = work_share; | ||
| 1594 | + start_data->ts.work_share = &team->work_shares[0]; | ||
| 1595 | + start_data->ts.last_work_share = NULL; | ||
| 1596 | start_data->ts.team_id = i; | ||
| 1597 | - start_data->ts.work_share_generation = 0; | ||
| 1598 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 1599 | + start_data->ts.single_count = 0; | ||
| 1600 | +#endif | ||
| 1601 | start_data->ts.static_trip = 0; | ||
| 1602 | start_data->fn = fn; | ||
| 1603 | start_data->fn_data = data; | ||
| 1604 | @@ -303,7 +344,7 @@ gomp_team_start (void (*fn) (void *), vo | ||
| 1605 | gomp_fatal ("Thread creation failed: %s", strerror (err)); | ||
| 1606 | } | ||
| 1607 | |||
| 1608 | - if (gomp_cpu_affinity != NULL) | ||
| 1609 | + if (__builtin_expect (gomp_cpu_affinity != NULL, 0)) | ||
| 1610 | pthread_attr_destroy (&thread_attr); | ||
| 1611 | |||
| 1612 | do_release: | ||
| 1613 | @@ -313,8 +354,20 @@ gomp_team_start (void (*fn) (void *), vo | ||
| 1614 | that should arrive back at the end of this team. The extra | ||
| 1615 | threads should be exiting. Note that we arrange for this test | ||
| 1616 | to never be true for nested teams. */ | ||
| 1617 | - if (nthreads < old_threads_used) | ||
| 1618 | - gomp_barrier_reinit (&gomp_threads_dock, nthreads); | ||
| 1619 | + if (__builtin_expect (nthreads < old_threads_used, 0)) | ||
| 1620 | + { | ||
| 1621 | + long diff = (long) nthreads - (long) old_threads_used; | ||
| 1622 | + | ||
| 1623 | + gomp_barrier_reinit (&gomp_threads_dock, nthreads); | ||
| 1624 | + | ||
| 1625 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 1626 | + __sync_fetch_and_add (&gomp_managed_threads, diff); | ||
| 1627 | +#else | ||
| 1628 | + gomp_mutex_lock (&gomp_remaining_threads_lock); | ||
| 1629 | + gomp_managed_threads += diff; | ||
| 1630 | + gomp_mutex_unlock (&gomp_remaining_threads_lock); | ||
| 1631 | +#endif | ||
| 1632 | + } | ||
| 1633 | } | ||
| 1634 | |||
| 1635 | |||
| 1636 | @@ -329,8 +382,21 @@ gomp_team_end (void) | ||
| 1637 | |||
| 1638 | gomp_barrier_wait (&team->barrier); | ||
| 1639 | |||
| 1640 | + gomp_fini_work_share (thr->ts.work_share); | ||
| 1641 | + | ||
| 1642 | thr->ts = team->prev_ts; | ||
| 1643 | |||
| 1644 | + if (__builtin_expect (thr->ts.team != NULL, 0)) | ||
| 1645 | + { | ||
| 1646 | +#ifdef HAVE_SYNC_BUILTINS | ||
| 1647 | + __sync_fetch_and_add (&gomp_managed_threads, 1L - team->nthreads); | ||
| 1648 | +#else | ||
| 1649 | + gomp_mutex_lock (&gomp_remaining_threads_lock); | ||
| 1650 | + gomp_managed_threads -= team->nthreads - 1L; | ||
| 1651 | + gomp_mutex_unlock (&gomp_remaining_threads_lock); | ||
| 1652 | +#endif | ||
| 1653 | + } | ||
| 1654 | + | ||
| 1655 | free_team (team); | ||
| 1656 | } | ||
| 1657 | |||
| 1658 | --- libgomp/config/posix/bar.h.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 1659 | +++ libgomp/config/posix/bar.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 1660 | @@ -1,4 +1,4 @@ | ||
| 1661 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 1662 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 1663 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 1664 | |||
| 1665 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 1666 | @@ -46,18 +46,32 @@ typedef struct | ||
| 1667 | unsigned total; | ||
| 1668 | unsigned arrived; | ||
| 1669 | } gomp_barrier_t; | ||
| 1670 | +typedef bool gomp_barrier_state_t; | ||
| 1671 | |||
| 1672 | extern void gomp_barrier_init (gomp_barrier_t *, unsigned); | ||
| 1673 | extern void gomp_barrier_reinit (gomp_barrier_t *, unsigned); | ||
| 1674 | extern void gomp_barrier_destroy (gomp_barrier_t *); | ||
| 1675 | |||
| 1676 | extern void gomp_barrier_wait (gomp_barrier_t *); | ||
| 1677 | -extern void gomp_barrier_wait_end (gomp_barrier_t *, bool); | ||
| 1678 | +extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t); | ||
| 1679 | |||
| 1680 | -static inline bool gomp_barrier_wait_start (gomp_barrier_t *bar) | ||
| 1681 | +static inline gomp_barrier_state_t | ||
| 1682 | +gomp_barrier_wait_start (gomp_barrier_t *bar) | ||
| 1683 | { | ||
| 1684 | gomp_mutex_lock (&bar->mutex1); | ||
| 1685 | return ++bar->arrived == bar->total; | ||
| 1686 | } | ||
| 1687 | |||
| 1688 | +static inline bool | ||
| 1689 | +gomp_barrier_last_thread (gomp_barrier_state_t state) | ||
| 1690 | +{ | ||
| 1691 | + return state; | ||
| 1692 | +} | ||
| 1693 | + | ||
| 1694 | +static inline void | ||
| 1695 | +gomp_barrier_wait_last (gomp_barrier_t *bar) | ||
| 1696 | +{ | ||
| 1697 | + gomp_barrier_wait (bar); | ||
| 1698 | +} | ||
| 1699 | + | ||
| 1700 | #endif /* GOMP_BARRIER_H */ | ||
| 1701 | --- libgomp/config/posix/ptrlock.h.jj 2008-03-26 15:11:32.000000000 +0100 | ||
| 1702 | +++ libgomp/config/posix/ptrlock.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 1703 | @@ -0,0 +1,69 @@ | ||
| 1704 | +/* Copyright (C) 2008 Free Software Foundation, Inc. | ||
| 1705 | + Contributed by Jakub Jelinek <jakub@redhat.com>. | ||
| 1706 | + | ||
| 1707 | + This file is part of the GNU OpenMP Library (libgomp). | ||
| 1708 | + | ||
| 1709 | + Libgomp is free software; you can redistribute it and/or modify it | ||
| 1710 | + under the terms of the GNU Lesser General Public License as published by | ||
| 1711 | + the Free Software Foundation; either version 2.1 of the License, or | ||
| 1712 | + (at your option) any later version. | ||
| 1713 | + | ||
| 1714 | + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 1715 | + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 1716 | + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for | ||
| 1717 | + more details. | ||
| 1718 | + | ||
| 1719 | + You should have received a copy of the GNU Lesser General Public License | ||
| 1720 | + along with libgomp; see the file COPYING.LIB. If not, write to the | ||
| 1721 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
| 1722 | + MA 02110-1301, USA. */ | ||
| 1723 | + | ||
| 1724 | +/* As a special exception, if you link this library with other files, some | ||
| 1725 | + of which are compiled with GCC, to produce an executable, this library | ||
| 1726 | + does not by itself cause the resulting executable to be covered by the | ||
| 1727 | + GNU General Public License. This exception does not however invalidate | ||
| 1728 | + any other reasons why the executable file might be covered by the GNU | ||
| 1729 | + General Public License. */ | ||
| 1730 | + | ||
| 1731 | +/* This is a Linux specific implementation of a mutex synchronization | ||
| 1732 | + mechanism for libgomp. This type is private to the library. This | ||
| 1733 | + implementation uses atomic instructions and the futex syscall. */ | ||
| 1734 | + | ||
| 1735 | +#ifndef GOMP_PTRLOCK_H | ||
| 1736 | +#define GOMP_PTRLOCK_H 1 | ||
| 1737 | + | ||
| 1738 | +typedef struct { void *ptr; gomp_mutex_t lock; } gomp_ptrlock_t; | ||
| 1739 | + | ||
| 1740 | +static inline void gomp_ptrlock_init (gomp_ptrlock_t *ptrlock, void *ptr) | ||
| 1741 | +{ | ||
| 1742 | + ptrlock->ptr = ptr; | ||
| 1743 | + gomp_mutex_init (&ptrlock->lock); | ||
| 1744 | +} | ||
| 1745 | + | ||
| 1746 | +static inline void *gomp_ptrlock_get (gomp_ptrlock_t *ptrlock) | ||
| 1747 | +{ | ||
| 1748 | + if (ptrlock->ptr != NULL) | ||
| 1749 | + return ptrlock->ptr; | ||
| 1750 | + | ||
| 1751 | + gomp_mutex_lock (&ptrlock->lock); | ||
| 1752 | + if (ptrlock->ptr != NULL) | ||
| 1753 | + { | ||
| 1754 | + gomp_mutex_unlock (&ptrlock->lock); | ||
| 1755 | + return ptrlock->ptr; | ||
| 1756 | + } | ||
| 1757 | + | ||
| 1758 | + return NULL; | ||
| 1759 | +} | ||
| 1760 | + | ||
| 1761 | +static inline void gomp_ptrlock_set (gomp_ptrlock_t *ptrlock, void *ptr) | ||
| 1762 | +{ | ||
| 1763 | + ptrlock->ptr = ptr; | ||
| 1764 | + gomp_mutex_unlock (&ptrlock->lock); | ||
| 1765 | +} | ||
| 1766 | + | ||
| 1767 | +static inline void gomp_ptrlock_destroy (gomp_ptrlock_t *ptrlock) | ||
| 1768 | +{ | ||
| 1769 | + gomp_mutex_destroy (&ptrlock->lock); | ||
| 1770 | +} | ||
| 1771 | + | ||
| 1772 | +#endif /* GOMP_PTRLOCK_H */ | ||
| 1773 | --- libgomp/config/posix/ptrlock.c.jj 2008-03-26 15:11:32.000000000 +0100 | ||
| 1774 | +++ libgomp/config/posix/ptrlock.c 2008-03-26 15:11:32.000000000 +0100 | ||
| 1775 | @@ -0,0 +1 @@ | ||
| 1776 | +/* Everything is in the header. */ | ||
| 1777 | --- libgomp/config/posix/bar.c.jj 2007-12-07 14:41:01.000000000 +0100 | ||
| 1778 | +++ libgomp/config/posix/bar.c 2008-03-26 15:11:32.000000000 +0100 | ||
| 1779 | @@ -1,4 +1,4 @@ | ||
| 1780 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 1781 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 1782 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 1783 | |||
| 1784 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 1785 | @@ -70,7 +70,7 @@ gomp_barrier_reinit (gomp_barrier_t *bar | ||
| 1786 | } | ||
| 1787 | |||
| 1788 | void | ||
| 1789 | -gomp_barrier_wait_end (gomp_barrier_t *bar, bool last) | ||
| 1790 | +gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t last) | ||
| 1791 | { | ||
| 1792 | unsigned int n; | ||
| 1793 | |||
| 1794 | --- libgomp/config/linux/alpha/futex.h.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 1795 | +++ libgomp/config/linux/alpha/futex.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 1796 | @@ -1,4 +1,4 @@ | ||
| 1797 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 1798 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 1799 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 1800 | |||
| 1801 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 1802 | @@ -30,8 +30,6 @@ | ||
| 1803 | #ifndef SYS_futex | ||
| 1804 | #define SYS_futex 394 | ||
| 1805 | #endif | ||
| 1806 | -#define FUTEX_WAIT 0 | ||
| 1807 | -#define FUTEX_WAKE 1 | ||
| 1808 | |||
| 1809 | |||
| 1810 | static inline void | ||
| 1811 | @@ -45,7 +43,7 @@ futex_wait (int *addr, int val) | ||
| 1812 | |||
| 1813 | sc_0 = SYS_futex; | ||
| 1814 | sc_16 = (long) addr; | ||
| 1815 | - sc_17 = FUTEX_WAIT; | ||
| 1816 | + sc_17 = gomp_futex_wait; | ||
| 1817 | sc_18 = val; | ||
| 1818 | sc_19 = 0; | ||
| 1819 | __asm volatile ("callsys" | ||
| 1820 | @@ -53,6 +51,20 @@ futex_wait (int *addr, int val) | ||
| 1821 | : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18), "1"(sc_19) | ||
| 1822 | : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", | ||
| 1823 | "$22", "$23", "$24", "$25", "$27", "$28", "memory"); | ||
| 1824 | + if (__builtin_expect (sc_19, 0) && sc_0 == ENOSYS) | ||
| 1825 | + { | ||
| 1826 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 1827 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 1828 | + sc_0 = SYS_futex; | ||
| 1829 | + sc_17 &= ~FUTEX_PRIVATE_FLAG; | ||
| 1830 | + sc_19 = 0; | ||
| 1831 | + __asm volatile ("callsys" | ||
| 1832 | + : "=r" (sc_0), "=r"(sc_19) | ||
| 1833 | + : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18), | ||
| 1834 | + "1"(sc_19) | ||
| 1835 | + : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", | ||
| 1836 | + "$22", "$23", "$24", "$25", "$27", "$28", "memory"); | ||
| 1837 | + } | ||
| 1838 | } | ||
| 1839 | |||
| 1840 | static inline void | ||
| 1841 | @@ -66,11 +78,35 @@ futex_wake (int *addr, int count) | ||
| 1842 | |||
| 1843 | sc_0 = SYS_futex; | ||
| 1844 | sc_16 = (long) addr; | ||
| 1845 | - sc_17 = FUTEX_WAKE; | ||
| 1846 | + sc_17 = gomp_futex_wake; | ||
| 1847 | sc_18 = count; | ||
| 1848 | __asm volatile ("callsys" | ||
| 1849 | : "=r" (sc_0), "=r"(sc_19) | ||
| 1850 | : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18) | ||
| 1851 | : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", | ||
| 1852 | "$22", "$23", "$24", "$25", "$27", "$28", "memory"); | ||
| 1853 | + if (__builtin_expect (sc_19, 0) && sc_0 == ENOSYS) | ||
| 1854 | + { | ||
| 1855 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 1856 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 1857 | + sc_0 = SYS_futex; | ||
| 1858 | + sc_17 &= ~FUTEX_PRIVATE_FLAG; | ||
| 1859 | + __asm volatile ("callsys" | ||
| 1860 | + : "=r" (sc_0), "=r"(sc_19) | ||
| 1861 | + : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18) | ||
| 1862 | + : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", | ||
| 1863 | + "$22", "$23", "$24", "$25", "$27", "$28", "memory"); | ||
| 1864 | + } | ||
| 1865 | +} | ||
| 1866 | + | ||
| 1867 | +static inline void | ||
| 1868 | +cpu_relax (void) | ||
| 1869 | +{ | ||
| 1870 | + __asm volatile ("" : : : "memory"); | ||
| 1871 | +} | ||
| 1872 | + | ||
| 1873 | +static inline void | ||
| 1874 | +atomic_write_barrier (void) | ||
| 1875 | +{ | ||
| 1876 | + __asm volatile ("wmb" : : : "memory"); | ||
| 1877 | } | ||
| 1878 | --- libgomp/config/linux/affinity.c.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 1879 | +++ libgomp/config/linux/affinity.c 2008-03-26 15:11:32.000000000 +0100 | ||
| 1880 | @@ -1,4 +1,4 @@ | ||
| 1881 | -/* Copyright (C) 2006, 2007 Free Software Foundation, Inc. | ||
| 1882 | +/* Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. | ||
| 1883 | Contributed by Jakub Jelinek <jakub@redhat.com>. | ||
| 1884 | |||
| 1885 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 1886 | @@ -38,9 +38,6 @@ | ||
| 1887 | #ifdef HAVE_PTHREAD_AFFINITY_NP | ||
| 1888 | |||
| 1889 | static unsigned int affinity_counter; | ||
| 1890 | -#ifndef HAVE_SYNC_BUILTINS | ||
| 1891 | -static gomp_mutex_t affinity_lock; | ||
| 1892 | -#endif | ||
| 1893 | |||
| 1894 | void | ||
| 1895 | gomp_init_affinity (void) | ||
| 1896 | @@ -76,9 +73,6 @@ gomp_init_affinity (void) | ||
| 1897 | CPU_SET (gomp_cpu_affinity[0], &cpuset); | ||
| 1898 | pthread_setaffinity_np (pthread_self (), sizeof (cpuset), &cpuset); | ||
| 1899 | affinity_counter = 1; | ||
| 1900 | -#ifndef HAVE_SYNC_BUILTINS | ||
| 1901 | - gomp_mutex_init (&affinity_lock); | ||
| 1902 | -#endif | ||
| 1903 | } | ||
| 1904 | |||
| 1905 | void | ||
| 1906 | @@ -87,13 +81,7 @@ gomp_init_thread_affinity (pthread_attr_ | ||
| 1907 | unsigned int cpu; | ||
| 1908 | cpu_set_t cpuset; | ||
| 1909 | |||
| 1910 | -#ifdef HAVE_SYNC_BUILTINS | ||
| 1911 | cpu = __sync_fetch_and_add (&affinity_counter, 1); | ||
| 1912 | -#else | ||
| 1913 | - gomp_mutex_lock (&affinity_lock); | ||
| 1914 | - cpu = affinity_counter++; | ||
| 1915 | - gomp_mutex_unlock (&affinity_lock); | ||
| 1916 | -#endif | ||
| 1917 | cpu %= gomp_cpu_affinity_len; | ||
| 1918 | CPU_ZERO (&cpuset); | ||
| 1919 | CPU_SET (gomp_cpu_affinity[cpu], &cpuset); | ||
| 1920 | --- libgomp/config/linux/bar.h.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 1921 | +++ libgomp/config/linux/bar.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 1922 | @@ -1,4 +1,4 @@ | ||
| 1923 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 1924 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 1925 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 1926 | |||
| 1927 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 1928 | @@ -36,40 +36,49 @@ | ||
| 1929 | |||
| 1930 | typedef struct | ||
| 1931 | { | ||
| 1932 | - gomp_mutex_t mutex; | ||
| 1933 | - unsigned total; | ||
| 1934 | - unsigned arrived; | ||
| 1935 | - int generation; | ||
| 1936 | + /* Make sure total/generation is in a mostly read cacheline, while | ||
| 1937 | + awaited in a separate cacheline. */ | ||
| 1938 | + unsigned total __attribute__((aligned (64))); | ||
| 1939 | + unsigned generation; | ||
| 1940 | + unsigned awaited __attribute__((aligned (64))); | ||
| 1941 | } gomp_barrier_t; | ||
| 1942 | +typedef unsigned int gomp_barrier_state_t; | ||
| 1943 | |||
| 1944 | static inline void gomp_barrier_init (gomp_barrier_t *bar, unsigned count) | ||
| 1945 | { | ||
| 1946 | - gomp_mutex_init (&bar->mutex); | ||
| 1947 | bar->total = count; | ||
| 1948 | - bar->arrived = 0; | ||
| 1949 | + bar->awaited = count; | ||
| 1950 | bar->generation = 0; | ||
| 1951 | } | ||
| 1952 | |||
| 1953 | static inline void gomp_barrier_reinit (gomp_barrier_t *bar, unsigned count) | ||
| 1954 | { | ||
| 1955 | - gomp_mutex_lock (&bar->mutex); | ||
| 1956 | + __sync_fetch_and_add (&bar->awaited, count - bar->total); | ||
| 1957 | bar->total = count; | ||
| 1958 | - gomp_mutex_unlock (&bar->mutex); | ||
| 1959 | } | ||
| 1960 | |||
| 1961 | static inline void gomp_barrier_destroy (gomp_barrier_t *bar) | ||
| 1962 | { | ||
| 1963 | - /* Before destroying, make sure all threads have left the barrier. */ | ||
| 1964 | - gomp_mutex_lock (&bar->mutex); | ||
| 1965 | } | ||
| 1966 | |||
| 1967 | extern void gomp_barrier_wait (gomp_barrier_t *); | ||
| 1968 | -extern void gomp_barrier_wait_end (gomp_barrier_t *, bool); | ||
| 1969 | +extern void gomp_barrier_wait_last (gomp_barrier_t *); | ||
| 1970 | +extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t); | ||
| 1971 | |||
| 1972 | -static inline bool gomp_barrier_wait_start (gomp_barrier_t *bar) | ||
| 1973 | +static inline gomp_barrier_state_t | ||
| 1974 | +gomp_barrier_wait_start (gomp_barrier_t *bar) | ||
| 1975 | { | ||
| 1976 | - gomp_mutex_lock (&bar->mutex); | ||
| 1977 | - return ++bar->arrived == bar->total; | ||
| 1978 | + unsigned int ret = bar->generation; | ||
| 1979 | + /* Do we need any barrier here or is __sync_add_and_fetch acting | ||
| 1980 | + as the needed LoadLoad barrier already? */ | ||
| 1981 | + ret += __sync_add_and_fetch (&bar->awaited, -1) == 0; | ||
| 1982 | + return ret; | ||
| 1983 | +} | ||
| 1984 | + | ||
| 1985 | +static inline bool | ||
| 1986 | +gomp_barrier_last_thread (gomp_barrier_state_t state) | ||
| 1987 | +{ | ||
| 1988 | + return state & 1; | ||
| 1989 | } | ||
| 1990 | |||
| 1991 | #endif /* GOMP_BARRIER_H */ | ||
| 1992 | --- libgomp/config/linux/ptrlock.h.jj 2008-03-26 15:11:32.000000000 +0100 | ||
| 1993 | +++ libgomp/config/linux/ptrlock.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 1994 | @@ -0,0 +1,65 @@ | ||
| 1995 | +/* Copyright (C) 2008 Free Software Foundation, Inc. | ||
| 1996 | + Contributed by Jakub Jelinek <jakub@redhat.com>. | ||
| 1997 | + | ||
| 1998 | + This file is part of the GNU OpenMP Library (libgomp). | ||
| 1999 | + | ||
| 2000 | + Libgomp is free software; you can redistribute it and/or modify it | ||
| 2001 | + under the terms of the GNU Lesser General Public License as published by | ||
| 2002 | + the Free Software Foundation; either version 2.1 of the License, or | ||
| 2003 | + (at your option) any later version. | ||
| 2004 | + | ||
| 2005 | + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 2006 | + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 2007 | + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for | ||
| 2008 | + more details. | ||
| 2009 | + | ||
| 2010 | + You should have received a copy of the GNU Lesser General Public License | ||
| 2011 | + along with libgomp; see the file COPYING.LIB. If not, write to the | ||
| 2012 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
| 2013 | + MA 02110-1301, USA. */ | ||
| 2014 | + | ||
| 2015 | +/* As a special exception, if you link this library with other files, some | ||
| 2016 | + of which are compiled with GCC, to produce an executable, this library | ||
| 2017 | + does not by itself cause the resulting executable to be covered by the | ||
| 2018 | + GNU General Public License. This exception does not however invalidate | ||
| 2019 | + any other reasons why the executable file might be covered by the GNU | ||
| 2020 | + General Public License. */ | ||
| 2021 | + | ||
| 2022 | +/* This is a Linux specific implementation of a mutex synchronization | ||
| 2023 | + mechanism for libgomp. This type is private to the library. This | ||
| 2024 | + implementation uses atomic instructions and the futex syscall. */ | ||
| 2025 | + | ||
| 2026 | +#ifndef GOMP_PTRLOCK_H | ||
| 2027 | +#define GOMP_PTRLOCK_H 1 | ||
| 2028 | + | ||
| 2029 | +typedef void *gomp_ptrlock_t; | ||
| 2030 | + | ||
| 2031 | +static inline void gomp_ptrlock_init (gomp_ptrlock_t *ptrlock, void *ptr) | ||
| 2032 | +{ | ||
| 2033 | + *ptrlock = ptr; | ||
| 2034 | +} | ||
| 2035 | + | ||
| 2036 | +extern void *gomp_ptrlock_get_slow (gomp_ptrlock_t *ptrlock); | ||
| 2037 | +static inline void *gomp_ptrlock_get (gomp_ptrlock_t *ptrlock) | ||
| 2038 | +{ | ||
| 2039 | + if ((uintptr_t) *ptrlock > 2) | ||
| 2040 | + return *ptrlock; | ||
| 2041 | + | ||
| 2042 | + if (__sync_bool_compare_and_swap (ptrlock, NULL, (uintptr_t) 1)) | ||
| 2043 | + return NULL; | ||
| 2044 | + | ||
| 2045 | + return gomp_ptrlock_get_slow (ptrlock); | ||
| 2046 | +} | ||
| 2047 | + | ||
| 2048 | +extern void gomp_ptrlock_set_slow (gomp_ptrlock_t *ptrlock, void *ptr); | ||
| 2049 | +static inline void gomp_ptrlock_set (gomp_ptrlock_t *ptrlock, void *ptr) | ||
| 2050 | +{ | ||
| 2051 | + if (!__sync_bool_compare_and_swap (ptrlock, (uintptr_t) 1, ptr)) | ||
| 2052 | + gomp_ptrlock_set_slow (ptrlock, ptr); | ||
| 2053 | +} | ||
| 2054 | + | ||
| 2055 | +static inline void gomp_ptrlock_destroy (gomp_ptrlock_t *ptrlock) | ||
| 2056 | +{ | ||
| 2057 | +} | ||
| 2058 | + | ||
| 2059 | +#endif /* GOMP_PTRLOCK_H */ | ||
| 2060 | --- libgomp/config/linux/lock.c.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 2061 | +++ libgomp/config/linux/lock.c 2008-03-26 15:11:32.000000000 +0100 | ||
| 2062 | @@ -29,11 +29,10 @@ | ||
| 2063 | primitives. This implementation uses atomic instructions and the futex | ||
| 2064 | syscall. */ | ||
| 2065 | |||
| 2066 | -#include "libgomp.h" | ||
| 2067 | #include <string.h> | ||
| 2068 | #include <unistd.h> | ||
| 2069 | #include <sys/syscall.h> | ||
| 2070 | -#include "futex.h" | ||
| 2071 | +#include "wait.h" | ||
| 2072 | |||
| 2073 | |||
| 2074 | /* The internal gomp_mutex_t and the external non-recursive omp_lock_t | ||
| 2075 | @@ -137,7 +136,7 @@ omp_set_nest_lock (omp_nest_lock_t *lock | ||
| 2076 | return; | ||
| 2077 | } | ||
| 2078 | |||
| 2079 | - futex_wait (&lock->owner, otid); | ||
| 2080 | + do_wait (&lock->owner, otid); | ||
| 2081 | } | ||
| 2082 | } | ||
| 2083 | |||
| 2084 | --- libgomp/config/linux/ptrlock.c.jj 2008-03-26 15:11:32.000000000 +0100 | ||
| 2085 | +++ libgomp/config/linux/ptrlock.c 2008-03-26 15:11:32.000000000 +0100 | ||
| 2086 | @@ -0,0 +1,70 @@ | ||
| 2087 | +/* Copyright (C) 2008 Free Software Foundation, Inc. | ||
| 2088 | + Contributed by Jakub Jelinek <jakub@redhat.com>. | ||
| 2089 | + | ||
| 2090 | + This file is part of the GNU OpenMP Library (libgomp). | ||
| 2091 | + | ||
| 2092 | + Libgomp is free software; you can redistribute it and/or modify it | ||
| 2093 | + under the terms of the GNU Lesser General Public License as published by | ||
| 2094 | + the Free Software Foundation; either version 2.1 of the License, or | ||
| 2095 | + (at your option) any later version. | ||
| 2096 | + | ||
| 2097 | + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 2098 | + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 2099 | + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for | ||
| 2100 | + more details. | ||
| 2101 | + | ||
| 2102 | + You should have received a copy of the GNU Lesser General Public License | ||
| 2103 | + along with libgomp; see the file COPYING.LIB. If not, write to the | ||
| 2104 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
| 2105 | + MA 02110-1301, USA. */ | ||
| 2106 | + | ||
| 2107 | +/* As a special exception, if you link this library with other files, some | ||
| 2108 | + of which are compiled with GCC, to produce an executable, this library | ||
| 2109 | + does not by itself cause the resulting executable to be covered by the | ||
| 2110 | + GNU General Public License. This exception does not however invalidate | ||
| 2111 | + any other reasons why the executable file might be covered by the GNU | ||
| 2112 | + General Public License. */ | ||
| 2113 | + | ||
| 2114 | +/* This is a Linux specific implementation of a mutex synchronization | ||
| 2115 | + mechanism for libgomp. This type is private to the library. This | ||
| 2116 | + implementation uses atomic instructions and the futex syscall. */ | ||
| 2117 | + | ||
| 2118 | +#include <endian.h> | ||
| 2119 | +#include <limits.h> | ||
| 2120 | +#include "wait.h" | ||
| 2121 | + | ||
| 2122 | +void * | ||
| 2123 | +gomp_ptrlock_get_slow (gomp_ptrlock_t *ptrlock) | ||
| 2124 | +{ | ||
| 2125 | + int *intptr; | ||
| 2126 | + __sync_bool_compare_and_swap (ptrlock, 1, 2); | ||
| 2127 | + | ||
| 2128 | + /* futex works on ints, not pointers. | ||
| 2129 | + But a valid work share pointer will be at least | ||
| 2130 | + 8 byte aligned, so it is safe to assume the low | ||
| 2131 | + 32-bits of the pointer won't contain values 1 or 2. */ | ||
| 2132 | + __asm volatile ("" : "=r" (intptr) : "0" (ptrlock)); | ||
| 2133 | +#if __BYTE_ORDER == __BIG_ENDIAN | ||
| 2134 | + if (sizeof (*ptrlock) > sizeof (int)) | ||
| 2135 | + intptr += (sizeof (*ptrlock) / sizeof (int)) - 1; | ||
| 2136 | +#endif | ||
| 2137 | + do | ||
| 2138 | + do_wait (intptr, 2); | ||
| 2139 | + while (*intptr == 2); | ||
| 2140 | + __asm volatile ("" : : : "memory"); | ||
| 2141 | + return *ptrlock; | ||
| 2142 | +} | ||
| 2143 | + | ||
| 2144 | +void | ||
| 2145 | +gomp_ptrlock_set_slow (gomp_ptrlock_t *ptrlock, void *ptr) | ||
| 2146 | +{ | ||
| 2147 | + int *intptr; | ||
| 2148 | + | ||
| 2149 | + *ptrlock = ptr; | ||
| 2150 | + __asm volatile ("" : "=r" (intptr) : "0" (ptrlock)); | ||
| 2151 | +#if __BYTE_ORDER == __BIG_ENDIAN | ||
| 2152 | + if (sizeof (*ptrlock) > sizeof (int)) | ||
| 2153 | + intptr += (sizeof (*ptrlock) / sizeof (int)) - 1; | ||
| 2154 | +#endif | ||
| 2155 | + futex_wake (intptr, INT_MAX); | ||
| 2156 | +} | ||
| 2157 | --- libgomp/config/linux/x86/futex.h.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 2158 | +++ libgomp/config/linux/x86/futex.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 2159 | @@ -1,4 +1,4 @@ | ||
| 2160 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 2161 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 2162 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 2163 | |||
| 2164 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 2165 | @@ -27,9 +27,6 @@ | ||
| 2166 | |||
| 2167 | /* Provide target-specific access to the futex system call. */ | ||
| 2168 | |||
| 2169 | -#define FUTEX_WAIT 0 | ||
| 2170 | -#define FUTEX_WAKE 1 | ||
| 2171 | - | ||
| 2172 | #ifdef __LP64__ | ||
| 2173 | # ifndef SYS_futex | ||
| 2174 | # define SYS_futex 202 | ||
| 2175 | @@ -38,14 +35,26 @@ | ||
| 2176 | static inline void | ||
| 2177 | futex_wait (int *addr, int val) | ||
| 2178 | { | ||
| 2179 | - register long r10 __asm__("%r10") = 0; | ||
| 2180 | + register long r10 __asm__("%r10"); | ||
| 2181 | long res; | ||
| 2182 | |||
| 2183 | + r10 = 0; | ||
| 2184 | __asm volatile ("syscall" | ||
| 2185 | : "=a" (res) | ||
| 2186 | - : "0"(SYS_futex), "D" (addr), "S"(FUTEX_WAIT), | ||
| 2187 | - "d"(val), "r"(r10) | ||
| 2188 | + : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wait), | ||
| 2189 | + "d" (val), "r" (r10) | ||
| 2190 | : "r11", "rcx", "memory"); | ||
| 2191 | + if (__builtin_expect (res == -ENOSYS, 0)) | ||
| 2192 | + { | ||
| 2193 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2194 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2195 | + r10 = 0; | ||
| 2196 | + __asm volatile ("syscall" | ||
| 2197 | + : "=a" (res) | ||
| 2198 | + : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wait), | ||
| 2199 | + "d" (val), "r" (r10) | ||
| 2200 | + : "r11", "rcx", "memory"); | ||
| 2201 | + } | ||
| 2202 | } | ||
| 2203 | |||
| 2204 | static inline void | ||
| 2205 | @@ -55,8 +64,19 @@ futex_wake (int *addr, int count) | ||
| 2206 | |||
| 2207 | __asm volatile ("syscall" | ||
| 2208 | : "=a" (res) | ||
| 2209 | - : "0"(SYS_futex), "D" (addr), "S"(FUTEX_WAKE), "d"(count) | ||
| 2210 | + : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wake), | ||
| 2211 | + "d" (count) | ||
| 2212 | : "r11", "rcx", "memory"); | ||
| 2213 | + if (__builtin_expect (res == -ENOSYS, 0)) | ||
| 2214 | + { | ||
| 2215 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2216 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2217 | + __asm volatile ("syscall" | ||
| 2218 | + : "=a" (res) | ||
| 2219 | + : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wake), | ||
| 2220 | + "d" (count) | ||
| 2221 | + : "r11", "rcx", "memory"); | ||
| 2222 | + } | ||
| 2223 | } | ||
| 2224 | #else | ||
| 2225 | # ifndef SYS_futex | ||
| 2226 | @@ -65,7 +85,7 @@ futex_wake (int *addr, int count) | ||
| 2227 | |||
| 2228 | # ifdef __PIC__ | ||
| 2229 | |||
| 2230 | -static inline void | ||
| 2231 | +static inline long | ||
| 2232 | sys_futex0 (int *addr, int op, int val) | ||
| 2233 | { | ||
| 2234 | long res; | ||
| 2235 | @@ -77,11 +97,12 @@ sys_futex0 (int *addr, int op, int val) | ||
| 2236 | : "0"(SYS_futex), "r" (addr), "c"(op), | ||
| 2237 | "d"(val), "S"(0) | ||
| 2238 | : "memory"); | ||
| 2239 | + return res; | ||
| 2240 | } | ||
| 2241 | |||
| 2242 | # else | ||
| 2243 | |||
| 2244 | -static inline void | ||
| 2245 | +static inline long | ||
| 2246 | sys_futex0 (int *addr, int op, int val) | ||
| 2247 | { | ||
| 2248 | long res; | ||
| 2249 | @@ -91,6 +112,7 @@ sys_futex0 (int *addr, int op, int val) | ||
| 2250 | : "0"(SYS_futex), "b" (addr), "c"(op), | ||
| 2251 | "d"(val), "S"(0) | ||
| 2252 | : "memory"); | ||
| 2253 | + return res; | ||
| 2254 | } | ||
| 2255 | |||
| 2256 | # endif /* __PIC__ */ | ||
| 2257 | @@ -98,13 +120,37 @@ sys_futex0 (int *addr, int op, int val) | ||
| 2258 | static inline void | ||
| 2259 | futex_wait (int *addr, int val) | ||
| 2260 | { | ||
| 2261 | - sys_futex0 (addr, FUTEX_WAIT, val); | ||
| 2262 | + long res = sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2263 | + if (__builtin_expect (res == -ENOSYS, 0)) | ||
| 2264 | + { | ||
| 2265 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2266 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2267 | + sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2268 | + } | ||
| 2269 | } | ||
| 2270 | |||
| 2271 | static inline void | ||
| 2272 | futex_wake (int *addr, int count) | ||
| 2273 | { | ||
| 2274 | - sys_futex0 (addr, FUTEX_WAKE, count); | ||
| 2275 | + long res = sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2276 | + if (__builtin_expect (res == -ENOSYS, 0)) | ||
| 2277 | + { | ||
| 2278 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2279 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2280 | + sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2281 | + } | ||
| 2282 | } | ||
| 2283 | |||
| 2284 | #endif /* __LP64__ */ | ||
| 2285 | + | ||
| 2286 | +static inline void | ||
| 2287 | +cpu_relax (void) | ||
| 2288 | +{ | ||
| 2289 | + __asm volatile ("rep; nop" : : : "memory"); | ||
| 2290 | +} | ||
| 2291 | + | ||
| 2292 | +static inline void | ||
| 2293 | +atomic_write_barrier (void) | ||
| 2294 | +{ | ||
| 2295 | + __sync_synchronize (); | ||
| 2296 | +} | ||
| 2297 | --- libgomp/config/linux/wait.h.jj 2008-03-26 15:11:32.000000000 +0100 | ||
| 2298 | +++ libgomp/config/linux/wait.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 2299 | @@ -0,0 +1,68 @@ | ||
| 2300 | +/* Copyright (C) 2008 Free Software Foundation, Inc. | ||
| 2301 | + Contributed by Jakub Jelinek <jakub@redhat.com>. | ||
| 2302 | + | ||
| 2303 | + This file is part of the GNU OpenMP Library (libgomp). | ||
| 2304 | + | ||
| 2305 | + Libgomp is free software; you can redistribute it and/or modify it | ||
| 2306 | + under the terms of the GNU Lesser General Public License as published by | ||
| 2307 | + the Free Software Foundation; either version 2.1 of the License, or | ||
| 2308 | + (at your option) any later version. | ||
| 2309 | + | ||
| 2310 | + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 2311 | + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 2312 | + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for | ||
| 2313 | + more details. | ||
| 2314 | + | ||
| 2315 | + You should have received a copy of the GNU Lesser General Public License | ||
| 2316 | + along with libgomp; see the file COPYING.LIB. If not, write to the | ||
| 2317 | + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
| 2318 | + MA 02110-1301, USA. */ | ||
| 2319 | + | ||
| 2320 | +/* As a special exception, if you link this library with other files, some | ||
| 2321 | + of which are compiled with GCC, to produce an executable, this library | ||
| 2322 | + does not by itself cause the resulting executable to be covered by the | ||
| 2323 | + GNU General Public License. This exception does not however invalidate | ||
| 2324 | + any other reasons why the executable file might be covered by the GNU | ||
| 2325 | + General Public License. */ | ||
| 2326 | + | ||
| 2327 | +/* This is a Linux specific implementation of a mutex synchronization | ||
| 2328 | + mechanism for libgomp. This type is private to the library. This | ||
| 2329 | + implementation uses atomic instructions and the futex syscall. */ | ||
| 2330 | + | ||
| 2331 | +#ifndef GOMP_WAIT_H | ||
| 2332 | +#define GOMP_WAIT_H 1 | ||
| 2333 | + | ||
| 2334 | +#include "libgomp.h" | ||
| 2335 | +#include <errno.h> | ||
| 2336 | + | ||
| 2337 | +#define FUTEX_WAIT 0 | ||
| 2338 | +#define FUTEX_WAKE 1 | ||
| 2339 | +#define FUTEX_PRIVATE_FLAG 128L | ||
| 2340 | + | ||
| 2341 | +#ifdef HAVE_ATTRIBUTE_VISIBILITY | ||
| 2342 | +# pragma GCC visibility push(hidden) | ||
| 2343 | +#endif | ||
| 2344 | + | ||
| 2345 | +extern long int gomp_futex_wait, gomp_futex_wake; | ||
| 2346 | + | ||
| 2347 | +#include "futex.h" | ||
| 2348 | + | ||
| 2349 | +static inline void do_wait (int *addr, int val) | ||
| 2350 | +{ | ||
| 2351 | + unsigned long long i, count = gomp_spin_count_var; | ||
| 2352 | + | ||
| 2353 | + if (__builtin_expect (gomp_managed_threads > gomp_available_cpus, 0)) | ||
| 2354 | + count = gomp_throttled_spin_count_var; | ||
| 2355 | + for (i = 0; i < count; i++) | ||
| 2356 | + if (__builtin_expect (*addr != val, 0)) | ||
| 2357 | + return; | ||
| 2358 | + else | ||
| 2359 | + cpu_relax (); | ||
| 2360 | + futex_wait (addr, val); | ||
| 2361 | +} | ||
| 2362 | + | ||
| 2363 | +#ifdef HAVE_ATTRIBUTE_VISIBILITY | ||
| 2364 | +# pragma GCC visibility pop | ||
| 2365 | +#endif | ||
| 2366 | + | ||
| 2367 | +#endif /* GOMP_WAIT_H */ | ||
| 2368 | --- libgomp/config/linux/sparc/futex.h.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 2369 | +++ libgomp/config/linux/sparc/futex.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 2370 | @@ -1,4 +1,4 @@ | ||
| 2371 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 2372 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 2373 | Contributed by Jakub Jelinek <jakub@redhat.com>. | ||
| 2374 | |||
| 2375 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 2376 | @@ -28,10 +28,8 @@ | ||
| 2377 | /* Provide target-specific access to the futex system call. */ | ||
| 2378 | |||
| 2379 | #include <sys/syscall.h> | ||
| 2380 | -#define FUTEX_WAIT 0 | ||
| 2381 | -#define FUTEX_WAKE 1 | ||
| 2382 | |||
| 2383 | -static inline void | ||
| 2384 | +static inline long | ||
| 2385 | sys_futex0 (int *addr, int op, int val) | ||
| 2386 | { | ||
| 2387 | register long int g1 __asm__ ("g1"); | ||
| 2388 | @@ -47,9 +45,9 @@ sys_futex0 (int *addr, int op, int val) | ||
| 2389 | o3 = 0; | ||
| 2390 | |||
| 2391 | #ifdef __arch64__ | ||
| 2392 | -# define SYSCALL_STRING "ta\t0x6d" | ||
| 2393 | +# define SYSCALL_STRING "ta\t0x6d; bcs,a,pt %%xcc, 1f; sub %%g0, %%o0, %%o0; 1:" | ||
| 2394 | #else | ||
| 2395 | -# define SYSCALL_STRING "ta\t0x10" | ||
| 2396 | +# define SYSCALL_STRING "ta\t0x10; bcs,a 1f; sub %%g0, %%o0, %%o0; 1:" | ||
| 2397 | #endif | ||
| 2398 | |||
| 2399 | __asm volatile (SYSCALL_STRING | ||
| 2400 | @@ -65,16 +63,49 @@ sys_futex0 (int *addr, int op, int val) | ||
| 2401 | "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", | ||
| 2402 | #endif | ||
| 2403 | "cc", "memory"); | ||
| 2404 | + return o0; | ||
| 2405 | } | ||
| 2406 | |||
| 2407 | static inline void | ||
| 2408 | futex_wait (int *addr, int val) | ||
| 2409 | { | ||
| 2410 | - sys_futex0 (addr, FUTEX_WAIT, val); | ||
| 2411 | + long err = sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2412 | + if (__builtin_expect (err == ENOSYS, 0)) | ||
| 2413 | + { | ||
| 2414 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2415 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2416 | + sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2417 | + } | ||
| 2418 | } | ||
| 2419 | |||
| 2420 | static inline void | ||
| 2421 | futex_wake (int *addr, int count) | ||
| 2422 | { | ||
| 2423 | - sys_futex0 (addr, FUTEX_WAKE, count); | ||
| 2424 | + long err = sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2425 | + if (__builtin_expect (err == ENOSYS, 0)) | ||
| 2426 | + { | ||
| 2427 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2428 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2429 | + sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2430 | + } | ||
| 2431 | +} | ||
| 2432 | + | ||
| 2433 | +static inline void | ||
| 2434 | +cpu_relax (void) | ||
| 2435 | +{ | ||
| 2436 | +#if defined __arch64__ || defined __sparc_v9__ | ||
| 2437 | + __asm volatile ("membar #LoadLoad" : : : "memory"); | ||
| 2438 | +#else | ||
| 2439 | + __asm volatile ("" : : : "memory"); | ||
| 2440 | +#endif | ||
| 2441 | +} | ||
| 2442 | + | ||
| 2443 | +static inline void | ||
| 2444 | +atomic_write_barrier (void) | ||
| 2445 | +{ | ||
| 2446 | +#if defined __arch64__ || defined __sparc_v9__ | ||
| 2447 | + __asm volatile ("membar #StoreStore" : : : "memory"); | ||
| 2448 | +#else | ||
| 2449 | + __sync_synchronize (); | ||
| 2450 | +#endif | ||
| 2451 | } | ||
| 2452 | --- libgomp/config/linux/ia64/futex.h.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 2453 | +++ libgomp/config/linux/ia64/futex.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 2454 | @@ -1,4 +1,4 @@ | ||
| 2455 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 2456 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 2457 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 2458 | |||
| 2459 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 2460 | @@ -29,23 +29,24 @@ | ||
| 2461 | |||
| 2462 | #include <sys/syscall.h> | ||
| 2463 | |||
| 2464 | -#define FUTEX_WAIT 0 | ||
| 2465 | -#define FUTEX_WAKE 1 | ||
| 2466 | |||
| 2467 | |||
| 2468 | -static inline void | ||
| 2469 | -sys_futex0(int *addr, int op, int val) | ||
| 2470 | +static inline long | ||
| 2471 | +sys_futex0(int *addr, long op, int val) | ||
| 2472 | { | ||
| 2473 | register long out0 asm ("out0") = (long) addr; | ||
| 2474 | register long out1 asm ("out1") = op; | ||
| 2475 | register long out2 asm ("out2") = val; | ||
| 2476 | register long out3 asm ("out3") = 0; | ||
| 2477 | + register long r8 asm ("r8"); | ||
| 2478 | + register long r10 asm ("r10"); | ||
| 2479 | register long r15 asm ("r15") = SYS_futex; | ||
| 2480 | |||
| 2481 | __asm __volatile ("break 0x100000" | ||
| 2482 | - : "=r"(r15), "=r"(out0), "=r"(out1), "=r"(out2), "=r"(out3) | ||
| 2483 | + : "=r"(r15), "=r"(out0), "=r"(out1), "=r"(out2), "=r"(out3), | ||
| 2484 | + "=r"(r8), "=r"(r10) | ||
| 2485 | : "r"(r15), "r"(out0), "r"(out1), "r"(out2), "r"(out3) | ||
| 2486 | - : "memory", "r8", "r10", "out4", "out5", "out6", "out7", | ||
| 2487 | + : "memory", "out4", "out5", "out6", "out7", | ||
| 2488 | /* Non-stacked integer registers, minus r8, r10, r15. */ | ||
| 2489 | "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18", | ||
| 2490 | "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", | ||
| 2491 | @@ -56,16 +57,41 @@ sys_futex0(int *addr, int op, int val) | ||
| 2492 | "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", | ||
| 2493 | /* Branch registers. */ | ||
| 2494 | "b6"); | ||
| 2495 | + return r8 & r10; | ||
| 2496 | } | ||
| 2497 | |||
| 2498 | static inline void | ||
| 2499 | futex_wait (int *addr, int val) | ||
| 2500 | { | ||
| 2501 | - sys_futex0 (addr, FUTEX_WAIT, val); | ||
| 2502 | + long err = sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2503 | + if (__builtin_expect (err == ENOSYS, 0)) | ||
| 2504 | + { | ||
| 2505 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2506 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2507 | + sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2508 | + } | ||
| 2509 | } | ||
| 2510 | |||
| 2511 | static inline void | ||
| 2512 | futex_wake (int *addr, int count) | ||
| 2513 | { | ||
| 2514 | - sys_futex0 (addr, FUTEX_WAKE, count); | ||
| 2515 | + long err = sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2516 | + if (__builtin_expect (err == ENOSYS, 0)) | ||
| 2517 | + { | ||
| 2518 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2519 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2520 | + sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2521 | + } | ||
| 2522 | +} | ||
| 2523 | + | ||
| 2524 | +static inline void | ||
| 2525 | +cpu_relax (void) | ||
| 2526 | +{ | ||
| 2527 | + __asm volatile ("hint @pause" : : : "memory"); | ||
| 2528 | +} | ||
| 2529 | + | ||
| 2530 | +static inline void | ||
| 2531 | +atomic_write_barrier (void) | ||
| 2532 | +{ | ||
| 2533 | + __sync_synchronize (); | ||
| 2534 | } | ||
| 2535 | --- libgomp/config/linux/s390/futex.h.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 2536 | +++ libgomp/config/linux/s390/futex.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 2537 | @@ -1,4 +1,4 @@ | ||
| 2538 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 2539 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 2540 | Contributed by Jakub Jelinek <jakub@redhat.com>. | ||
| 2541 | |||
| 2542 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 2543 | @@ -28,10 +28,8 @@ | ||
| 2544 | /* Provide target-specific access to the futex system call. */ | ||
| 2545 | |||
| 2546 | #include <sys/syscall.h> | ||
| 2547 | -#define FUTEX_WAIT 0 | ||
| 2548 | -#define FUTEX_WAKE 1 | ||
| 2549 | |||
| 2550 | -static inline void | ||
| 2551 | +static inline long | ||
| 2552 | sys_futex0 (int *addr, int op, int val) | ||
| 2553 | { | ||
| 2554 | register long int gpr2 __asm__ ("2"); | ||
| 2555 | @@ -49,16 +47,41 @@ sys_futex0 (int *addr, int op, int val) | ||
| 2556 | : "i" (SYS_futex), | ||
| 2557 | "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5) | ||
| 2558 | : "memory"); | ||
| 2559 | + return gpr2; | ||
| 2560 | } | ||
| 2561 | |||
| 2562 | static inline void | ||
| 2563 | futex_wait (int *addr, int val) | ||
| 2564 | { | ||
| 2565 | - sys_futex0 (addr, FUTEX_WAIT, val); | ||
| 2566 | + long err = sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2567 | + if (__builtin_expect (err == -ENOSYS, 0)) | ||
| 2568 | + { | ||
| 2569 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2570 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2571 | + sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2572 | + } | ||
| 2573 | } | ||
| 2574 | |||
| 2575 | static inline void | ||
| 2576 | futex_wake (int *addr, int count) | ||
| 2577 | { | ||
| 2578 | - sys_futex0 (addr, FUTEX_WAKE, count); | ||
| 2579 | + long err = sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2580 | + if (__builtin_expect (err == -ENOSYS, 0)) | ||
| 2581 | + { | ||
| 2582 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2583 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2584 | + sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2585 | + } | ||
| 2586 | +} | ||
| 2587 | + | ||
| 2588 | +static inline void | ||
| 2589 | +cpu_relax (void) | ||
| 2590 | +{ | ||
| 2591 | + __asm volatile ("" : : : "memory"); | ||
| 2592 | +} | ||
| 2593 | + | ||
| 2594 | +static inline void | ||
| 2595 | +atomic_write_barrier (void) | ||
| 2596 | +{ | ||
| 2597 | + __sync_synchronize (); | ||
| 2598 | } | ||
| 2599 | --- libgomp/config/linux/mutex.c.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 2600 | +++ libgomp/config/linux/mutex.c 2008-03-26 15:11:32.000000000 +0100 | ||
| 2601 | @@ -1,4 +1,4 @@ | ||
| 2602 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 2603 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 2604 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 2605 | |||
| 2606 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 2607 | @@ -29,9 +29,10 @@ | ||
| 2608 | mechanism for libgomp. This type is private to the library. This | ||
| 2609 | implementation uses atomic instructions and the futex syscall. */ | ||
| 2610 | |||
| 2611 | -#include "libgomp.h" | ||
| 2612 | -#include "futex.h" | ||
| 2613 | +#include "wait.h" | ||
| 2614 | |||
| 2615 | +long int gomp_futex_wake = FUTEX_WAKE | FUTEX_PRIVATE_FLAG; | ||
| 2616 | +long int gomp_futex_wait = FUTEX_WAIT | FUTEX_PRIVATE_FLAG; | ||
| 2617 | |||
| 2618 | void | ||
| 2619 | gomp_mutex_lock_slow (gomp_mutex_t *mutex) | ||
| 2620 | @@ -40,7 +41,7 @@ gomp_mutex_lock_slow (gomp_mutex_t *mute | ||
| 2621 | { | ||
| 2622 | int oldval = __sync_val_compare_and_swap (mutex, 1, 2); | ||
| 2623 | if (oldval != 0) | ||
| 2624 | - futex_wait (mutex, 2); | ||
| 2625 | + do_wait (mutex, 2); | ||
| 2626 | } | ||
| 2627 | while (!__sync_bool_compare_and_swap (mutex, 0, 2)); | ||
| 2628 | } | ||
| 2629 | --- libgomp/config/linux/sem.c.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 2630 | +++ libgomp/config/linux/sem.c 2008-03-26 15:11:32.000000000 +0100 | ||
| 2631 | @@ -1,4 +1,4 @@ | ||
| 2632 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 2633 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 2634 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 2635 | |||
| 2636 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 2637 | @@ -29,8 +29,7 @@ | ||
| 2638 | mechanism for libgomp. This type is private to the library. This | ||
| 2639 | implementation uses atomic instructions and the futex syscall. */ | ||
| 2640 | |||
| 2641 | -#include "libgomp.h" | ||
| 2642 | -#include "futex.h" | ||
| 2643 | +#include "wait.h" | ||
| 2644 | |||
| 2645 | |||
| 2646 | void | ||
| 2647 | @@ -44,7 +43,7 @@ gomp_sem_wait_slow (gomp_sem_t *sem) | ||
| 2648 | if (__sync_bool_compare_and_swap (sem, val, val - 1)) | ||
| 2649 | return; | ||
| 2650 | } | ||
| 2651 | - futex_wait (sem, -1); | ||
| 2652 | + do_wait (sem, -1); | ||
| 2653 | } | ||
| 2654 | } | ||
| 2655 | |||
| 2656 | --- libgomp/config/linux/powerpc/futex.h.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 2657 | +++ libgomp/config/linux/powerpc/futex.h 2008-03-26 15:11:32.000000000 +0100 | ||
| 2658 | @@ -1,4 +1,4 @@ | ||
| 2659 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 2660 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 2661 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 2662 | |||
| 2663 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 2664 | @@ -28,10 +28,8 @@ | ||
| 2665 | /* Provide target-specific access to the futex system call. */ | ||
| 2666 | |||
| 2667 | #include <sys/syscall.h> | ||
| 2668 | -#define FUTEX_WAIT 0 | ||
| 2669 | -#define FUTEX_WAKE 1 | ||
| 2670 | |||
| 2671 | -static inline void | ||
| 2672 | +static inline long | ||
| 2673 | sys_futex0 (int *addr, int op, int val) | ||
| 2674 | { | ||
| 2675 | register long int r0 __asm__ ("r0"); | ||
| 2676 | @@ -50,21 +48,48 @@ sys_futex0 (int *addr, int op, int val) | ||
| 2677 | doesn't. It doesn't much matter for us. In the interest of unity, | ||
| 2678 | go ahead and clobber it always. */ | ||
| 2679 | |||
| 2680 | - __asm volatile ("sc" | ||
| 2681 | + __asm volatile ("sc; mfcr %0" | ||
| 2682 | : "=r"(r0), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6) | ||
| 2683 | : "r"(r0), "r"(r3), "r"(r4), "r"(r5), "r"(r6) | ||
| 2684 | : "r7", "r8", "r9", "r10", "r11", "r12", | ||
| 2685 | "cr0", "ctr", "memory"); | ||
| 2686 | + if (__builtin_expect (r0 & (1 << 28), 0)) | ||
| 2687 | + return r3; | ||
| 2688 | + return 0; | ||
| 2689 | } | ||
| 2690 | |||
| 2691 | static inline void | ||
| 2692 | futex_wait (int *addr, int val) | ||
| 2693 | { | ||
| 2694 | - sys_futex0 (addr, FUTEX_WAIT, val); | ||
| 2695 | + long err = sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2696 | + if (__builtin_expect (err == ENOSYS, 0)) | ||
| 2697 | + { | ||
| 2698 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2699 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2700 | + sys_futex0 (addr, gomp_futex_wait, val); | ||
| 2701 | + } | ||
| 2702 | } | ||
| 2703 | |||
| 2704 | static inline void | ||
| 2705 | futex_wake (int *addr, int count) | ||
| 2706 | { | ||
| 2707 | - sys_futex0 (addr, FUTEX_WAKE, count); | ||
| 2708 | + long err = sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2709 | + if (__builtin_expect (err == ENOSYS, 0)) | ||
| 2710 | + { | ||
| 2711 | + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; | ||
| 2712 | + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; | ||
| 2713 | + sys_futex0 (addr, gomp_futex_wake, count); | ||
| 2714 | + } | ||
| 2715 | +} | ||
| 2716 | + | ||
| 2717 | +static inline void | ||
| 2718 | +cpu_relax (void) | ||
| 2719 | +{ | ||
| 2720 | + __asm volatile ("" : : : "memory"); | ||
| 2721 | +} | ||
| 2722 | + | ||
| 2723 | +static inline void | ||
| 2724 | +atomic_write_barrier (void) | ||
| 2725 | +{ | ||
| 2726 | + __asm volatile ("eieio" : : : "memory"); | ||
| 2727 | } | ||
| 2728 | --- libgomp/config/linux/bar.c.jj 2007-12-07 14:41:00.000000000 +0100 | ||
| 2729 | +++ libgomp/config/linux/bar.c 2008-03-26 15:11:32.000000000 +0100 | ||
| 2730 | @@ -1,4 +1,4 @@ | ||
| 2731 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | ||
| 2732 | +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. | ||
| 2733 | Contributed by Richard Henderson <rth@redhat.com>. | ||
| 2734 | |||
| 2735 | This file is part of the GNU OpenMP Library (libgomp). | ||
| 2736 | @@ -29,32 +29,29 @@ | ||
| 2737 | mechanism for libgomp. This type is private to the library. This | ||
| 2738 | implementation uses atomic instructions and the futex syscall. */ | ||
| 2739 | |||
| 2740 | -#include "libgomp.h" | ||
| 2741 | -#include "futex.h" | ||
| 2742 | #include <limits.h> | ||
| 2743 | +#include "wait.h" | ||
| 2744 | |||
| 2745 | |||
| 2746 | void | ||
| 2747 | -gomp_barrier_wait_end (gomp_barrier_t *bar, bool last) | ||
| 2748 | +gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) | ||
| 2749 | { | ||
| 2750 | - if (last) | ||
| 2751 | + if (__builtin_expect ((state & 1) != 0, 0)) | ||
| 2752 | { | ||
| 2753 | - bar->generation++; | ||
| 2754 | - futex_wake (&bar->generation, INT_MAX); | ||
| 2755 | + /* Next time we'll be awaiting TOTAL threads again. */ | ||
| 2756 | + bar->awaited = bar->total; | ||
| 2757 | + atomic_write_barrier (); | ||
| 2758 | + bar->generation += 2; | ||
| 2759 | + futex_wake ((int *) &bar->generation, INT_MAX); | ||
| 2760 | } | ||
| 2761 | else | ||
| 2762 | { | ||
| 2763 | - unsigned int generation = bar->generation; | ||
| 2764 | - | ||
| 2765 | - gomp_mutex_unlock (&bar->mutex); | ||
| 2766 | + unsigned int generation = state; | ||
| 2767 | |||
| 2768 | do | ||
| 2769 | - futex_wait (&bar->generation, generation); | ||
| 2770 | + do_wait ((int *) &bar->generation, generation); | ||
| 2771 | while (bar->generation == generation); | ||
| 2772 | } | ||
| 2773 | - | ||
| 2774 | - if (__sync_add_and_fetch (&bar->arrived, -1) == 0) | ||
| 2775 | - gomp_mutex_unlock (&bar->mutex); | ||
| 2776 | } | ||
| 2777 | |||
| 2778 | void | ||
| 2779 | @@ -62,3 +59,18 @@ gomp_barrier_wait (gomp_barrier_t *barri | ||
| 2780 | { | ||
| 2781 | gomp_barrier_wait_end (barrier, gomp_barrier_wait_start (barrier)); | ||
| 2782 | } | ||
| 2783 | + | ||
| 2784 | +/* Like gomp_barrier_wait, except that if the encountering thread | ||
| 2785 | + is not the last one to hit the barrier, it returns immediately. | ||
| 2786 | + The intended usage is that a thread which intends to gomp_barrier_destroy | ||
| 2787 | + this barrier calls gomp_barrier_wait, while all other threads | ||
| 2788 | + call gomp_barrier_wait_last. When gomp_barrier_wait returns, | ||
| 2789 | + the barrier can be safely destroyed. */ | ||
| 2790 | + | ||
| 2791 | +void | ||
| 2792 | +gomp_barrier_wait_last (gomp_barrier_t *barrier) | ||
| 2793 | +{ | ||
| 2794 | + gomp_barrier_state_t state = gomp_barrier_wait_start (barrier); | ||
| 2795 | + if (state & 1) | ||
| 2796 | + gomp_barrier_wait_end (barrier, state); | ||
| 2797 | +} | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-ppc32-retaddr.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-ppc32-retaddr.patch new file mode 100644 index 0000000000..3de4158eb0 --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-ppc32-retaddr.patch | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | 2005-11-28 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | * config/rs6000/rs6000.c (rs6000_return_addr): If COUNT == 0, | ||
| 4 | read word RETURN_ADDRESS_OFFSET bytes above arg_pointer_rtx | ||
| 5 | instead of doing an extran indirection from frame_pointer_rtx. | ||
| 6 | |||
| 7 | * gcc.dg/20051128-1.c: New test. | ||
| 8 | |||
| 9 | Index: gcc/config/rs6000/rs6000.c | ||
| 10 | =================================================================== | ||
| 11 | --- gcc/config/rs6000/rs6000.c.orig 2010-03-27 03:27:39.000000000 -0700 | ||
| 12 | +++ gcc/config/rs6000/rs6000.c 2010-06-25 10:18:04.053381930 -0700 | ||
| 13 | @@ -17646,17 +17646,22 @@ | ||
| 14 | don't try to be too clever here. */ | ||
| 15 | if (count != 0 || (DEFAULT_ABI != ABI_AIX && flag_pic)) | ||
| 16 | { | ||
| 17 | + rtx x; | ||
| 18 | cfun->machine->ra_needs_full_frame = 1; | ||
| 19 | |||
| 20 | - return | ||
| 21 | - gen_rtx_MEM | ||
| 22 | - (Pmode, | ||
| 23 | - memory_address | ||
| 24 | - (Pmode, | ||
| 25 | - plus_constant (copy_to_reg | ||
| 26 | - (gen_rtx_MEM (Pmode, | ||
| 27 | - memory_address (Pmode, frame))), | ||
| 28 | - RETURN_ADDRESS_OFFSET))); | ||
| 29 | + if (count == 0) | ||
| 30 | + { | ||
| 31 | + gcc_assert (frame == frame_pointer_rtx); | ||
| 32 | + x = arg_pointer_rtx; | ||
| 33 | + } | ||
| 34 | + else | ||
| 35 | + { | ||
| 36 | + x = memory_address (Pmode, frame); | ||
| 37 | + x = copy_to_reg (gen_rtx_MEM (Pmode, x)); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + x = plus_constant (x, RETURN_ADDRESS_OFFSET); | ||
| 41 | + return gen_rtx_MEM (Pmode, memory_address (Pmode, x)); | ||
| 42 | } | ||
| 43 | |||
| 44 | cfun->machine->ra_need_lr = 1; | ||
| 45 | Index: gcc/testsuite/gcc.dg/20051128-1.c | ||
| 46 | =================================================================== | ||
| 47 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
| 48 | +++ gcc/testsuite/gcc.dg/20051128-1.c 2010-06-25 10:18:04.061382856 -0700 | ||
| 49 | @@ -0,0 +1,41 @@ | ||
| 50 | +/* { dg-do run } */ | ||
| 51 | +/* { dg-options "-O2 -fpic" } */ | ||
| 52 | + | ||
| 53 | +extern void exit (int); | ||
| 54 | +extern void abort (void); | ||
| 55 | + | ||
| 56 | +int b; | ||
| 57 | + | ||
| 58 | +struct A | ||
| 59 | +{ | ||
| 60 | + void *pad[147]; | ||
| 61 | + void *ra, *h; | ||
| 62 | + long o; | ||
| 63 | +}; | ||
| 64 | + | ||
| 65 | +void | ||
| 66 | +__attribute__((noinline)) | ||
| 67 | +foo (struct A *a, void *x) | ||
| 68 | +{ | ||
| 69 | + __builtin_memset (a, 0, sizeof (a)); | ||
| 70 | + if (!b) | ||
| 71 | + exit (0); | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +void | ||
| 75 | +__attribute__((noinline)) | ||
| 76 | +bar (void) | ||
| 77 | +{ | ||
| 78 | + struct A a; | ||
| 79 | + | ||
| 80 | + __builtin_unwind_init (); | ||
| 81 | + foo (&a, __builtin_return_address (0)); | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +int | ||
| 85 | +main (void) | ||
| 86 | +{ | ||
| 87 | + bar (); | ||
| 88 | + abort (); | ||
| 89 | + return 0; | ||
| 90 | +} | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-pr27898.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-pr27898.patch new file mode 100644 index 0000000000..172bb81171 --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-pr27898.patch | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | 2006-08-18 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | PR c/27898 | ||
| 4 | * gcc.dg/pr27898.c: New test. | ||
| 5 | |||
| 6 | --- gcc/testsuite/gcc.dg/pr27898.c.jj 2006-08-18 09:19:33.000000000 +0200 | ||
| 7 | +++ gcc/testsuite/gcc.dg/pr27898.c 2006-08-18 09:19:27.000000000 +0200 | ||
| 8 | @@ -0,0 +1,8 @@ | ||
| 9 | +/* PR c/27898 */ | ||
| 10 | +/* { dg-do compile } */ | ||
| 11 | +/* { dg-options "--combine" } */ | ||
| 12 | +/* { dg-additional-sources "pr27898.c" } */ | ||
| 13 | + | ||
| 14 | +union u { struct { int i; }; }; | ||
| 15 | + | ||
| 16 | +extern int foo (union u *); | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-pr32139.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-pr32139.patch new file mode 100644 index 0000000000..f35696703d --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-pr32139.patch | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | 2007-06-01 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | PR tree-optimization/32139 | ||
| 4 | * gcc.c-torture/compile/20070531-1.c: New test. | ||
| 5 | |||
| 6 | --- gcc/testsuite/gcc.c-torture/compile/20070531-1.c.jj 2007-05-31 13:47:22.000000000 +0200 | ||
| 7 | +++ gcc/testsuite/gcc.c-torture/compile/20070531-1.c 2007-06-01 10:57:15.000000000 +0200 | ||
| 8 | @@ -0,0 +1,11 @@ | ||
| 9 | +/* PR tree-optimization/32139 */ | ||
| 10 | +int foo (void); | ||
| 11 | +int bar (void) __attribute__ ((const)); | ||
| 12 | + | ||
| 13 | +int | ||
| 14 | +test (int x) | ||
| 15 | +{ | ||
| 16 | + int a = (x == 10000 ? foo : bar) (); | ||
| 17 | + int b = (x == 10000 ? foo : bar) (); | ||
| 18 | + return a + b; | ||
| 19 | +} | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-pr33763.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-pr33763.patch new file mode 100644 index 0000000000..68c30650ff --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-pr33763.patch | |||
| @@ -0,0 +1,159 @@ | |||
| 1 | 2007-11-06 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | PR tree-optimization/33763 | ||
| 4 | * gcc.dg/pr33763.c: New test. | ||
| 5 | * g++.dg/opt/inline13.C: New test. | ||
| 6 | |||
| 7 | 2007-11-06 Jan Hubicka <jh@suse.cz> | ||
| 8 | |||
| 9 | PR tree-optimization/33763 | ||
| 10 | * tree-inline.c (expand_call_inline): Silently ignore always_inline | ||
| 11 | attribute for redefined extern inline functions. | ||
| 12 | |||
| 13 | Index: gcc/tree-inline.c | ||
| 14 | =================================================================== | ||
| 15 | --- gcc/tree-inline.c.orig 2010-03-18 13:07:13.000000000 -0700 | ||
| 16 | +++ gcc/tree-inline.c 2010-06-25 10:18:51.230139825 -0700 | ||
| 17 | @@ -3545,6 +3545,12 @@ | ||
| 18 | goto egress; | ||
| 19 | |||
| 20 | if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) | ||
| 21 | + /* For extern inline functions that get redefined we always | ||
| 22 | + silently ignored alway_inline flag. Better behaviour would | ||
| 23 | + be to be able to keep both bodies and use extern inline body | ||
| 24 | + for inlining, but we can't do that because frontends overwrite | ||
| 25 | + the body. */ | ||
| 26 | + && !cg_edge->callee->local.redefined_extern_inline | ||
| 27 | /* Avoid warnings during early inline pass. */ | ||
| 28 | && cgraph_global_info_ready) | ||
| 29 | { | ||
| 30 | Index: gcc/testsuite/gcc.dg/pr33763.c | ||
| 31 | =================================================================== | ||
| 32 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
| 33 | +++ gcc/testsuite/gcc.dg/pr33763.c 2010-06-25 10:18:51.234141302 -0700 | ||
| 34 | @@ -0,0 +1,60 @@ | ||
| 35 | +/* PR tree-optimization/33763 */ | ||
| 36 | +/* { dg-do compile } */ | ||
| 37 | +/* { dg-options "-O2" } */ | ||
| 38 | + | ||
| 39 | +typedef struct | ||
| 40 | +{ | ||
| 41 | + void *a; | ||
| 42 | + void *b; | ||
| 43 | +} T; | ||
| 44 | +extern void *foo (const char *, const char *); | ||
| 45 | +extern void *bar (void *, const char *, T); | ||
| 46 | +extern int baz (const char *, int); | ||
| 47 | + | ||
| 48 | +extern inline __attribute__ ((always_inline, gnu_inline)) int | ||
| 49 | +baz (const char *x, int y) | ||
| 50 | +{ | ||
| 51 | + return 2; | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +int | ||
| 55 | +baz (const char *x, int y) | ||
| 56 | +{ | ||
| 57 | + return 1; | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +int xa, xb; | ||
| 61 | + | ||
| 62 | +static void * | ||
| 63 | +inl (const char *x, const char *y) | ||
| 64 | +{ | ||
| 65 | + T t = { &xa, &xb }; | ||
| 66 | + int *f = (int *) __builtin_malloc (sizeof (int)); | ||
| 67 | + const char *z; | ||
| 68 | + int o = 0; | ||
| 69 | + void *r = 0; | ||
| 70 | + | ||
| 71 | + for (z = y; *z; z++) | ||
| 72 | + { | ||
| 73 | + if (*z == 'r') | ||
| 74 | + o |= 1; | ||
| 75 | + if (*z == 'w') | ||
| 76 | + o |= 2; | ||
| 77 | + } | ||
| 78 | + if (o == 1) | ||
| 79 | + *f = baz (x, 0); | ||
| 80 | + if (o == 2) | ||
| 81 | + *f = baz (x, 1); | ||
| 82 | + if (o == 3) | ||
| 83 | + *f = baz (x, 2); | ||
| 84 | + | ||
| 85 | + if (o && *f > 0) | ||
| 86 | + r = bar (f, "w", t); | ||
| 87 | + return r; | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +void * | ||
| 91 | +foo (const char *x, const char *y) | ||
| 92 | +{ | ||
| 93 | + return inl (x, y); | ||
| 94 | +} | ||
| 95 | Index: gcc/testsuite/g++.dg/opt/inline13.C | ||
| 96 | =================================================================== | ||
| 97 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
| 98 | +++ gcc/testsuite/g++.dg/opt/inline13.C 2010-06-25 10:18:51.261052137 -0700 | ||
| 99 | @@ -0,0 +1,60 @@ | ||
| 100 | +// PR tree-optimization/33763 | ||
| 101 | +// { dg-do compile } | ||
| 102 | +// { dg-options "-O2" } | ||
| 103 | + | ||
| 104 | +typedef struct | ||
| 105 | +{ | ||
| 106 | + void *a; | ||
| 107 | + void *b; | ||
| 108 | +} T; | ||
| 109 | +extern void *foo (const char *, const char *); | ||
| 110 | +extern void *bar (void *, const char *, T); | ||
| 111 | +extern int baz (const char *, int); | ||
| 112 | + | ||
| 113 | +extern inline __attribute__ ((always_inline, gnu_inline)) int | ||
| 114 | +baz (const char *x, int y) | ||
| 115 | +{ | ||
| 116 | + return 2; | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +int | ||
| 120 | +baz (const char *x, int y) | ||
| 121 | +{ | ||
| 122 | + return 1; | ||
| 123 | +} | ||
| 124 | + | ||
| 125 | +int xa, xb; | ||
| 126 | + | ||
| 127 | +static void * | ||
| 128 | +inl (const char *x, const char *y) | ||
| 129 | +{ | ||
| 130 | + T t = { &xa, &xb }; | ||
| 131 | + int *f = (int *) __builtin_malloc (sizeof (int)); | ||
| 132 | + const char *z; | ||
| 133 | + int o = 0; | ||
| 134 | + void *r = 0; | ||
| 135 | + | ||
| 136 | + for (z = y; *z; z++) | ||
| 137 | + { | ||
| 138 | + if (*z == 'r') | ||
| 139 | + o |= 1; | ||
| 140 | + if (*z == 'w') | ||
| 141 | + o |= 2; | ||
| 142 | + } | ||
| 143 | + if (o == 1) | ||
| 144 | + *f = baz (x, 0); | ||
| 145 | + if (o == 2) | ||
| 146 | + *f = baz (x, 1); | ||
| 147 | + if (o == 3) | ||
| 148 | + *f = baz (x, 2); | ||
| 149 | + | ||
| 150 | + if (o && *f > 0) | ||
| 151 | + r = bar (f, "w", t); | ||
| 152 | + return r; | ||
| 153 | +} | ||
| 154 | + | ||
| 155 | +void * | ||
| 156 | +foo (const char *x, const char *y) | ||
| 157 | +{ | ||
| 158 | + return inl (x, y); | ||
| 159 | +} | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-rh251682.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-rh251682.patch new file mode 100644 index 0000000000..e96ae6f134 --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-rh251682.patch | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | 2008-04-01 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | PR pch/13675 | ||
| 4 | * files.c (struct _cpp_file): Remove pch field. | ||
| 5 | (pch_open_file): Don't set file->pch, just file->pchname. | ||
| 6 | (should_stack_file): After pfile->cb.read_pch call | ||
| 7 | free pchname and clear pchname, don't close file->fd. | ||
| 8 | Test file->pchname instead of file->pch. Don't close fd after cb. | ||
| 9 | (_cpp_stack_include): Test file->pchname instead of file->pch. | ||
| 10 | |||
| 11 | * c-pch.c (c_common_read_pch): On error close (fd) resp. fclose (f). | ||
| 12 | |||
| 13 | --- libcpp/files.c.jj 2008-02-18 23:50:17.000000000 +0100 | ||
| 14 | +++ libcpp/files.c 2008-03-31 15:59:01.000000000 +0200 | ||
| 15 | @@ -106,9 +106,6 @@ struct _cpp_file | ||
| 16 | |||
| 17 | /* If BUFFER above contains the true contents of the file. */ | ||
| 18 | bool buffer_valid; | ||
| 19 | - | ||
| 20 | - /* File is a PCH (on return from find_include_file). */ | ||
| 21 | - bool pch; | ||
| 22 | }; | ||
| 23 | |||
| 24 | /* A singly-linked list for all searches for a given file name, with | ||
| 25 | @@ -322,9 +319,7 @@ pch_open_file (cpp_reader *pfile, _cpp_f | ||
| 26 | } | ||
| 27 | closedir (pchdir); | ||
| 28 | } | ||
| 29 | - if (valid) | ||
| 30 | - file->pch = true; | ||
| 31 | - else | ||
| 32 | + if (!valid) | ||
| 33 | *invalid_pch = true; | ||
| 34 | } | ||
| 35 | |||
| 36 | @@ -703,11 +698,12 @@ should_stack_file (cpp_reader *pfile, _c | ||
| 37 | return false; | ||
| 38 | |||
| 39 | /* Handle PCH files immediately; don't stack them. */ | ||
| 40 | - if (file->pch) | ||
| 41 | + if (file->pchname) | ||
| 42 | { | ||
| 43 | pfile->cb.read_pch (pfile, file->pchname, file->fd, file->path); | ||
| 44 | - close (file->fd); | ||
| 45 | file->fd = -1; | ||
| 46 | + free ((void *) file->pchname); | ||
| 47 | + file->pchname = NULL; | ||
| 48 | return false; | ||
| 49 | } | ||
| 50 | |||
| 51 | @@ -916,7 +912,7 @@ _cpp_stack_include (cpp_reader *pfile, c | ||
| 52 | complicates LAST_SOURCE_LINE_LOCATION. This does not apply if we | ||
| 53 | found a PCH file (in which case linemap_add is not called) or we | ||
| 54 | were included from the command-line. */ | ||
| 55 | - if (! file->pch && file->err_no == 0 && type != IT_CMDLINE) | ||
| 56 | + if (file->pchname == NULL && file->err_no == 0 && type != IT_CMDLINE) | ||
| 57 | pfile->line_table->highest_location--; | ||
| 58 | |||
| 59 | return _cpp_stack_file (pfile, file, type == IT_IMPORT); | ||
| 60 | --- gcc/c-pch.c.jj 2008-02-18 23:46:08.000000000 +0100 | ||
| 61 | +++ gcc/c-pch.c 2008-03-31 15:56:00.000000000 +0200 | ||
| 62 | @@ -372,6 +372,7 @@ c_common_read_pch (cpp_reader *pfile, co | ||
| 63 | if (f == NULL) | ||
| 64 | { | ||
| 65 | cpp_errno (pfile, CPP_DL_ERROR, "calling fdopen"); | ||
| 66 | + close (fd); | ||
| 67 | return; | ||
| 68 | } | ||
| 69 | |||
| 70 | @@ -380,6 +381,7 @@ c_common_read_pch (cpp_reader *pfile, co | ||
| 71 | if (fread (&h, sizeof (h), 1, f) != 1) | ||
| 72 | { | ||
| 73 | cpp_errno (pfile, CPP_DL_ERROR, "reading"); | ||
| 74 | + fclose (f); | ||
| 75 | return; | ||
| 76 | } | ||
| 77 | |||
| 78 | @@ -425,7 +427,10 @@ c_common_read_pch (cpp_reader *pfile, co | ||
| 79 | gt_pch_restore (f); | ||
| 80 | |||
| 81 | if (cpp_read_state (pfile, name, f, smd) != 0) | ||
| 82 | - return; | ||
| 83 | + { | ||
| 84 | + fclose (f); | ||
| 85 | + return; | ||
| 86 | + } | ||
| 87 | |||
| 88 | fclose (f); | ||
| 89 | |||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-rh330771.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-rh330771.patch new file mode 100644 index 0000000000..4888ac47dd --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-rh330771.patch | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | 2007-10-16 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | * Makefile.am (libgcj_tools_la_LIBADD): Add. | ||
| 4 | * Makefile.in: Regenerated. | ||
| 5 | |||
| 6 | Index: libjava/Makefile.am | ||
| 7 | =================================================================== | ||
| 8 | --- libjava/Makefile.am.orig 2010-03-21 12:41:37.000000000 -0700 | ||
| 9 | +++ libjava/Makefile.am 2010-06-25 10:22:11.394130458 -0700 | ||
| 10 | @@ -507,6 +507,8 @@ | ||
| 11 | libgcj_tools_la_GCJFLAGS = $(AM_GCJFLAGS) -findirect-dispatch \ | ||
| 12 | -fno-bootstrap-classes -fno-indirect-classes \ | ||
| 13 | -fsource-filename=$(here)/classpath/tools/all-classes.lst | ||
| 14 | +## See jv_convert_LDADD. | ||
| 15 | +libgcj_tools_la_LIBADD = -L$(here)/.libs libgcj.la | ||
| 16 | libgcj_tools_la_LDFLAGS = -rpath $(toolexeclibdir) \ | ||
| 17 | -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ | ||
| 18 | $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBJAVA_LDFLAGS_NOUNDEF) | ||
| 19 | Index: libjava/Makefile.in | ||
| 20 | =================================================================== | ||
| 21 | --- libjava/Makefile.in.orig 2010-04-02 11:18:06.000000000 -0700 | ||
| 22 | +++ libjava/Makefile.in 2010-06-25 10:27:41.841708512 -0700 | ||
| 23 | @@ -1190,7 +1190,7 @@ | ||
| 24 | -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ | ||
| 25 | $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBJAVA_LDFLAGS_NOUNDEF) | ||
| 26 | |||
| 27 | -libgcj_tools_la_LIBADD = libgcj.la -lm | ||
| 28 | +libgcj_tools_la_LIBADD = -L$(here)/.libs libgcj.la -lm | ||
| 29 | libgcj_tools_la_DEPENDENCIES = libgcj.la libgcj.spec $(am__append_22) | ||
| 30 | libgcj_tools_la_LINK = $(LIBLINK) $(libgcj_tools_la_LDFLAGS) | ||
| 31 | libjvm_la_SOURCES = jni-libjvm.cc | ||
diff --git a/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-rh341221.patch b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-rh341221.patch new file mode 100644 index 0000000000..7e2801b99b --- /dev/null +++ b/recipes-devtools/gcc/gcc-4.5/fedora/gcc43-rh341221.patch | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | 2007-10-21 Jakub Jelinek <jakub@redhat.com> | ||
| 2 | |||
| 3 | * doc/Makefile.am (POD2MAN): Set date from cp-tools.texinfo | ||
| 4 | timestamp rather than from current date. | ||
| 5 | * doc/Makefile.in: Regenerated. | ||
| 6 | |||
| 7 | Index: libjava/classpath/doc/Makefile.am | ||
| 8 | =================================================================== | ||
| 9 | --- libjava/classpath/doc/Makefile.am.orig 2008-10-21 10:55:01.000000000 -0700 | ||
| 10 | +++ libjava/classpath/doc/Makefile.am 2010-06-25 10:28:30.237631599 -0700 | ||
| 11 | @@ -31,7 +31,7 @@ | ||
| 12 | gtnameserv.1 \ | ||
| 13 | gjdoc.1 | ||
| 14 | |||
| 15 | -POD2MAN = pod2man --center="GNU" --release="$(VERSION)" | ||
| 16 | +POD2MAN = pod2man --center="GNU" --release="$(VERSION)" --date="$(shell ls --time-style=+%F -l $(srcdir)/cp-tools.texinfo | awk '{print $$6}')" | ||
| 17 | TEXI2POD = perl $(srcdir)/texi2pod.pl | ||
| 18 | STAMP = echo timestamp > | ||
| 19 | |||
| 20 | Index: libjava/classpath/doc/Makefile.in | ||
| 21 | =================================================================== | ||
| 22 | --- libjava/classpath/doc/Makefile.in.orig 2010-04-02 11:18:06.000000000 -0700 | ||
| 23 | +++ libjava/classpath/doc/Makefile.in 2010-06-25 10:28:30.245635728 -0700 | ||
| 24 | @@ -376,7 +376,7 @@ | ||
| 25 | gtnameserv.1 \ | ||
| 26 | gjdoc.1 | ||
| 27 | |||
| 28 | -POD2MAN = pod2man --center="GNU" --release="$(VERSION)" | ||
| 29 | +POD2MAN = pod2man --center="GNU" --release="$(VERSION)" --date="$(shell ls --time-style=+%F -l $(srcdir)/cp-tools.texinfo | awk '{print $$6}')" | ||
| 30 | TEXI2POD = perl $(srcdir)/texi2pod.pl | ||
| 31 | STAMP = echo timestamp > | ||
| 32 | @GENINSRC_FALSE@STAMP_GENINSRC = | ||
