source: patches/gcc-4.8.2-branch_update-1.patch@ 0cb4668e

clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 0cb4668e was 2e59d11, checked in by William Harrington <kb0iic@…>, 11 years ago

Rename gcc 4.8.1 patches to gcc-4.8.2 and create new gcc 4.8.2 branch update patch.

  • Property mode set to 100644
File size: 218.2 KB
RevLine 
[2e59d11]1Submitted By: Jim Gifford (jim at cross-lfs dot org)
2Date: 10-24-2013
3Initial Package Version: 4.8.2
4Origin: Upstream
5Upstream Status: Applied
6Description: This is a branch update for gcc-4.8.2, and should be
7 rechecked periodically.
8
9This patch was made from Revision # 204009.
10
11diff -Naur gcc-4.8.2.orig/contrib/gcc_update gcc-4.8.2/contrib/gcc_update
12--- gcc-4.8.2.orig/contrib/gcc_update 2012-11-14 05:09:00.000000000 -0600
13+++ gcc-4.8.2/contrib/gcc_update 2013-10-21 05:38:03.471259000 -0500
14@@ -382,7 +382,7 @@
15 fi
16
17 revision=`$GCC_SVN info | awk '/Revision:/ { print $2 }'`
18- branch=`$GCC_SVN info | sed -ne "/URL:/ {
19+ branch=`$GCC_SVN info | sed -ne "/^URL:/ {
20 s,.*/trunk,trunk,
21 s,.*/branches/,,
22 s,.*/tags/,,
23diff -Naur gcc-4.8.2.orig/gcc/ada/gcc-interface/utils.c gcc-4.8.2/gcc/ada/gcc-interface/utils.c
24--- gcc-4.8.2.orig/gcc/ada/gcc-interface/utils.c 2013-06-13 02:51:32.000000000 -0500
25+++ gcc-4.8.2/gcc/ada/gcc-interface/utils.c 2013-10-19 06:11:47.006516000 -0500
26@@ -232,6 +232,7 @@
27 static tree split_plus (tree, tree *);
28 static tree float_type_for_precision (int, enum machine_mode);
29 static tree convert_to_fat_pointer (tree, tree);
30+static unsigned int scale_by_factor_of (tree, unsigned int);
31 static bool potential_alignment_gap (tree, tree, tree);
32 static void process_attributes (tree, struct attrib *);
33
34
35@@ -532,6 +533,22 @@
36 free_binding_level = level;
37 }
38
39
40+/* Set the context of TYPE and its parallel types (if any) to CONTEXT. */
41+
42+static void
43+gnat_set_type_context (tree type, tree context)
44+{
45+ tree decl = TYPE_STUB_DECL (type);
46+
47+ TYPE_CONTEXT (type) = context;
48+
49+ while (decl && DECL_PARALLEL_TYPE (decl))
50+ {
51+ TYPE_CONTEXT (DECL_PARALLEL_TYPE (decl)) = context;
52+ decl = TYPE_STUB_DECL (DECL_PARALLEL_TYPE (decl));
53+ }
54+}
55+
56 /* Record DECL as belonging to the current lexical scope and use GNAT_NODE
57 for location information and flag propagation. */
58
59@@ -613,7 +630,7 @@
60 if (TREE_CODE (t) == POINTER_TYPE)
61 TYPE_NEXT_PTR_TO (t) = tt;
62 TYPE_NAME (tt) = DECL_NAME (decl);
63- TYPE_CONTEXT (tt) = DECL_CONTEXT (decl);
64+ gnat_set_type_context (tt, DECL_CONTEXT (decl));
65 TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (t);
66 DECL_ORIGINAL_TYPE (decl) = tt;
67 }
68@@ -623,7 +640,7 @@
69 /* We need a variant for the placeholder machinery to work. */
70 tree tt = build_variant_type_copy (t);
71 TYPE_NAME (tt) = decl;
72- TYPE_CONTEXT (tt) = DECL_CONTEXT (decl);
73+ gnat_set_type_context (tt, DECL_CONTEXT (decl));
74 TREE_USED (tt) = TREE_USED (t);
75 TREE_TYPE (decl) = tt;
76 if (DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
77@@ -645,7 +662,7 @@
78 if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL))
79 {
80 TYPE_NAME (t) = decl;
81- TYPE_CONTEXT (t) = DECL_CONTEXT (decl);
82+ gnat_set_type_context (t, DECL_CONTEXT (decl));
83 }
84 }
85 }
86@@ -1692,93 +1709,74 @@
87 TYPE_SIZE_UNIT (new_record_type)
88 = size_int (TYPE_ALIGN (record_type) / BITS_PER_UNIT);
89
90- /* Now scan all the fields, replacing each field with a new
91- field corresponding to the new encoding. */
92+ /* Now scan all the fields, replacing each field with a new field
93+ corresponding to the new encoding. */
94 for (old_field = TYPE_FIELDS (record_type); old_field;
95 old_field = DECL_CHAIN (old_field))
96 {
97 tree field_type = TREE_TYPE (old_field);
98 tree field_name = DECL_NAME (old_field);
99- tree new_field;
100 tree curpos = bit_position (old_field);
101+ tree pos, new_field;
102 bool var = false;
103 unsigned int align = 0;
104- tree pos;
105-
106- /* See how the position was modified from the last position.
107
108- There are two basic cases we support: a value was added
109- to the last position or the last position was rounded to
110- a boundary and they something was added. Check for the
111- first case first. If not, see if there is any evidence
112- of rounding. If so, round the last position and try
113- again.
114+ /* We're going to do some pattern matching below so remove as many
115+ conversions as possible. */
116+ curpos = remove_conversions (curpos, true);
117
118- If this is a union, the position can be taken as zero. */
119+ /* See how the position was modified from the last position.
120
121- /* Some computations depend on the shape of the position expression,
122- so strip conversions to make sure it's exposed. */
123- curpos = remove_conversions (curpos, true);
124+ There are two basic cases we support: a value was added
125+ to the last position or the last position was rounded to
126+ a boundary and they something was added. Check for the
127+ first case first. If not, see if there is any evidence
128+ of rounding. If so, round the last position and retry.
129
130+ If this is a union, the position can be taken as zero. */
131 if (TREE_CODE (new_record_type) == UNION_TYPE)
132- pos = bitsize_zero_node, align = 0;
133+ pos = bitsize_zero_node;
134 else
135 pos = compute_related_constant (curpos, last_pos);
136
137- if (!pos && TREE_CODE (curpos) == MULT_EXPR
138+ if (!pos
139+ && TREE_CODE (curpos) == MULT_EXPR
140 && host_integerp (TREE_OPERAND (curpos, 1), 1))
141 {
142 tree offset = TREE_OPERAND (curpos, 0);
143 align = tree_low_cst (TREE_OPERAND (curpos, 1), 1);
144-
145- /* An offset which is a bitwise AND with a mask increases the
146- alignment according to the number of trailing zeros. */
147- offset = remove_conversions (offset, true);
148- if (TREE_CODE (offset) == BIT_AND_EXPR
149- && TREE_CODE (TREE_OPERAND (offset, 1)) == INTEGER_CST)
150- {
151- unsigned HOST_WIDE_INT mask
152- = TREE_INT_CST_LOW (TREE_OPERAND (offset, 1));
153- unsigned int i;
154-
155- for (i = 0; i < HOST_BITS_PER_WIDE_INT; i++)
156- {
157- if (mask & 1)
158- break;
159- mask >>= 1;
160- align *= 2;
161- }
162- }
163-
164- pos = compute_related_constant (curpos,
165- round_up (last_pos, align));
166+ align = scale_by_factor_of (offset, align);
167+ last_pos = round_up (last_pos, align);
168+ pos = compute_related_constant (curpos, last_pos);
169 }
170- else if (!pos && TREE_CODE (curpos) == PLUS_EXPR
171- && TREE_CODE (TREE_OPERAND (curpos, 1)) == INTEGER_CST
172+ else if (!pos
173+ && TREE_CODE (curpos) == PLUS_EXPR
174+ && host_integerp (TREE_OPERAND (curpos, 1), 1)
175 && TREE_CODE (TREE_OPERAND (curpos, 0)) == MULT_EXPR
176- && host_integerp (TREE_OPERAND
177- (TREE_OPERAND (curpos, 0), 1),
178- 1))
179+ && host_integerp
180+ (TREE_OPERAND (TREE_OPERAND (curpos, 0), 1), 1))
181 {
182+ tree offset = TREE_OPERAND (TREE_OPERAND (curpos, 0), 0);
183+ unsigned HOST_WIDE_INT addend
184+ = tree_low_cst (TREE_OPERAND (curpos, 1), 1);
185 align
186- = tree_low_cst
187- (TREE_OPERAND (TREE_OPERAND (curpos, 0), 1), 1);
188- pos = compute_related_constant (curpos,
189- round_up (last_pos, align));
190+ = tree_low_cst (TREE_OPERAND (TREE_OPERAND (curpos, 0), 1), 1);
191+ align = scale_by_factor_of (offset, align);
192+ align = MIN (align, addend & -addend);
193+ last_pos = round_up (last_pos, align);
194+ pos = compute_related_constant (curpos, last_pos);
195 }
196- else if (potential_alignment_gap (prev_old_field, old_field,
197- pos))
198+ else if (potential_alignment_gap (prev_old_field, old_field, pos))
199 {
200 align = TYPE_ALIGN (field_type);
201- pos = compute_related_constant (curpos,
202- round_up (last_pos, align));
203+ last_pos = round_up (last_pos, align);
204+ pos = compute_related_constant (curpos, last_pos);
205 }
206
207 /* If we can't compute a position, set it to zero.
208
209- ??? We really should abort here, but it's too much work
210- to get this correct for all cases. */
211-
212+ ??? We really should abort here, but it's too much work
213+ to get this correct for all cases. */
214 if (!pos)
215 pos = bitsize_zero_node;
216
217@@ -2553,6 +2551,32 @@
218 return false;
219 }
220
221+/* Return VALUE scaled by the biggest power-of-2 factor of EXPR. */
222+
223+static unsigned int
224+scale_by_factor_of (tree expr, unsigned int value)
225+{
226+ expr = remove_conversions (expr, true);
227+
228+ /* An expression which is a bitwise AND with a mask has a power-of-2 factor
229+ corresponding to the number of trailing zeros of the mask. */
230+ if (TREE_CODE (expr) == BIT_AND_EXPR
231+ && TREE_CODE (TREE_OPERAND (expr, 1)) == INTEGER_CST)
232+ {
233+ unsigned HOST_WIDE_INT mask = TREE_INT_CST_LOW (TREE_OPERAND (expr, 1));
234+ unsigned int i = 0;
235+
236+ while ((mask & 1) == 0 && i < HOST_BITS_PER_WIDE_INT)
237+ {
238+ mask >>= 1;
239+ value *= 2;
240+ i++;
241+ }
242+ }
243+
244+ return value;
245+}
246+
247 /* Given two consecutive field decls PREV_FIELD and CURR_FIELD, return true
248 unless we can prove these 2 fields are laid out in such a way that no gap
249 exist between the end of PREV_FIELD and the beginning of CURR_FIELD. OFFSET
250diff -Naur gcc-4.8.2.orig/gcc/config/i386/i386.c gcc-4.8.2/gcc/config/i386/i386.c
251--- gcc-4.8.2.orig/gcc/config/i386/i386.c 2013-08-23 05:01:34.000000000 -0500
252+++ gcc-4.8.2/gcc/config/i386/i386.c 2013-10-16 05:47:13.444609000 -0500
253@@ -2983,7 +2983,7 @@
254 {"bdver3", PROCESSOR_BDVER3, CPU_BDVER3,
255 PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3
256 | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1
257- | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX
258+ | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_FMA4
259 | PTA_XOP | PTA_LWP | PTA_BMI | PTA_TBM | PTA_F16C
260 | PTA_FMA | PTA_PRFCHW | PTA_FXSR | PTA_XSAVE
261 | PTA_XSAVEOPT},
262diff -Naur gcc-4.8.2.orig/gcc/config/rs6000/rs6000.md gcc-4.8.2/gcc/config/rs6000/rs6000.md
263--- gcc-4.8.2.orig/gcc/config/rs6000/rs6000.md 2013-09-23 09:27:06.000000000 -0500
264+++ gcc-4.8.2/gcc/config/rs6000/rs6000.md 2013-10-24 07:53:51.516366000 -0500
265@@ -2412,7 +2412,7 @@
266 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
267 (const_int 0)))
268 (clobber (match_scratch:SI 3 "=r,r"))]
269- ""
270+ "TARGET_32BIT"
271 "@
272 mullw. %3,%1,%2
273 #"
274@@ -2425,7 +2425,7 @@
275 (match_operand:SI 2 "gpc_reg_operand" ""))
276 (const_int 0)))
277 (clobber (match_scratch:SI 3 ""))]
278- "reload_completed"
279+ "TARGET_32BIT && reload_completed"
280 [(set (match_dup 3)
281 (mult:SI (match_dup 1) (match_dup 2)))
282 (set (match_dup 0)
283@@ -2440,7 +2440,7 @@
284 (const_int 0)))
285 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
286 (mult:SI (match_dup 1) (match_dup 2)))]
287- ""
288+ "TARGET_32BIT"
289 "@
290 mullw. %0,%1,%2
291 #"
292@@ -2454,7 +2454,7 @@
293 (const_int 0)))
294 (set (match_operand:SI 0 "gpc_reg_operand" "")
295 (mult:SI (match_dup 1) (match_dup 2)))]
296- "reload_completed"
297+ "TARGET_32BIT && reload_completed"
298 [(set (match_dup 0)
299 (mult:SI (match_dup 1) (match_dup 2)))
300 (set (match_dup 3)
301diff -Naur gcc-4.8.2.orig/gcc/config/sh/sh.opt gcc-4.8.2/gcc/config/sh/sh.opt
302--- gcc-4.8.2.orig/gcc/config/sh/sh.opt 2013-03-13 13:09:10.000000000 -0500
303+++ gcc-4.8.2/gcc/config/sh/sh.opt 2013-10-17 08:49:40.145734000 -0500
304@@ -21,7 +21,7 @@
305 ;; Used for various architecture options.
306 Mask(SH_E)
307
308-;; Set if the default precision of th FPU is single.
309+;; Set if the default precision of the FPU is single.
310 Mask(FPU_SINGLE)
311
312 ;; Set if the a double-precision FPU is present but is restricted to
313diff -Naur gcc-4.8.2.orig/gcc/cp/decl2.c gcc-4.8.2/gcc/cp/decl2.c
314--- gcc-4.8.2.orig/gcc/cp/decl2.c 2013-05-20 08:37:44.000000000 -0500
315+++ gcc-4.8.2/gcc/cp/decl2.c 2013-10-16 16:58:58.729529000 -0500
316@@ -3960,6 +3960,22 @@
317 expand_or_defer_fn (finish_function (0));
318 }
319
320+/* The entire file is now complete. If requested, dump everything
321+ to a file. */
322+
323+static void
324+dump_tu (void)
325+{
326+ int flags;
327+ FILE *stream = dump_begin (TDI_tu, &flags);
328+
329+ if (stream)
330+ {
331+ dump_node (global_namespace, flags & ~TDF_SLIM, stream);
332+ dump_end (TDI_tu, stream);
333+ }
334+}
335+
336 /* This routine is called at the end of compilation.
337 Its job is to create all the code needed to initialize and
338 destroy the global aggregates. We do the destruction
339@@ -3990,6 +4006,7 @@
340 if (pch_file)
341 {
342 c_common_write_pch ();
343+ dump_tu ();
344 return;
345 }
346
347@@ -4359,16 +4376,7 @@
348
349 /* The entire file is now complete. If requested, dump everything
350 to a file. */
351- {
352- int flags;
353- FILE *stream = dump_begin (TDI_tu, &flags);
354-
355- if (stream)
356- {
357- dump_node (global_namespace, flags & ~TDF_SLIM, stream);
358- dump_end (TDI_tu, stream);
359- }
360- }
361+ dump_tu ();
362
363 if (flag_detailed_statistics)
364 {
365diff -Naur gcc-4.8.2.orig/gcc/cp/parser.c gcc-4.8.2/gcc/cp/parser.c
366--- gcc-4.8.2.orig/gcc/cp/parser.c 2013-10-02 13:27:30.000000000 -0500
367+++ gcc-4.8.2/gcc/cp/parser.c 2013-10-16 17:19:18.772609000 -0500
368@@ -6421,10 +6421,6 @@
369 /* Look for the `~'. */
370 cp_parser_require (parser, CPP_COMPL, RT_COMPL);
371
372- /* Once we see the ~, this has to be a pseudo-destructor. */
373- if (!processing_template_decl && !cp_parser_error_occurred (parser))
374- cp_parser_commit_to_tentative_parse (parser);
375-
376 /* Look for the type-name again. We are not responsible for
377 checking that it matches the first type-name. */
378 *type = cp_parser_nonclass_name (parser);
379diff -Naur gcc-4.8.2.orig/gcc/cp/semantics.c gcc-4.8.2/gcc/cp/semantics.c
380--- gcc-4.8.2.orig/gcc/cp/semantics.c 2013-10-08 17:29:49.000000000 -0500
381+++ gcc-4.8.2/gcc/cp/semantics.c 2013-10-17 12:15:46.188630000 -0500
382@@ -9481,7 +9481,14 @@
383 /* In unevaluated context this isn't an odr-use, so just return the
384 nearest 'this'. */
385 if (cp_unevaluated_operand)
386- return lookup_name (this_identifier);
387+ {
388+ /* In an NSDMI the fake 'this' pointer that we're using for
389+ parsing is in scope_chain. */
390+ if (LAMBDA_EXPR_EXTRA_SCOPE (lambda)
391+ && TREE_CODE (LAMBDA_EXPR_EXTRA_SCOPE (lambda)) == FIELD_DECL)
392+ return scope_chain->x_current_class_ptr;
393+ return lookup_name (this_identifier);
394+ }
395
396 /* Try to default capture 'this' if we can. */
397 if (!this_capture
398diff -Naur gcc-4.8.2.orig/gcc/DATESTAMP gcc-4.8.2/gcc/DATESTAMP
399--- gcc-4.8.2.orig/gcc/DATESTAMP 2013-10-15 19:16:34.000000000 -0500
400+++ gcc-4.8.2/gcc/DATESTAMP 2013-10-23 19:16:46.751448000 -0500
401@@ -1 +1 @@
402-20131016
403+20131024
404diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/backend.h gcc-4.8.2/gcc/go/gofrontend/backend.h
405--- gcc-4.8.2.orig/gcc/go/gofrontend/backend.h 2013-10-04 13:07:35.000000000 -0500
406+++ gcc-4.8.2/gcc/go/gofrontend/backend.h 2013-10-16 12:27:53.564070000 -0500
407@@ -23,7 +23,7 @@
408 // The backend representation of a statement.
409 class Bstatement;
410
411-// The backend representation of a function definition.
412+// The backend representation of a function definition or declaration.
413 class Bfunction;
414
415 // The backend representation of a block.
416@@ -266,6 +266,11 @@
417 virtual Bexpression*
418 convert_expression(Btype* type, Bexpression* expr, Location) = 0;
419
420+ // Create an expression for the address of a function. This is used to
421+ // get the address of the code for a function.
422+ virtual Bexpression*
423+ function_code_expression(Bfunction*, Location) = 0;
424+
425 // Statements.
426
427 // Create an error statement. This is used for cases which should
428@@ -498,6 +503,32 @@
429 // recover.
430 virtual Bexpression*
431 label_address(Blabel*, Location) = 0;
432+
433+ // Functions.
434+
435+ // Create an error function. This is used for cases which should
436+ // not occur in a correct program, in order to keep the compilation
437+ // going without crashing.
438+ virtual Bfunction*
439+ error_function() = 0;
440+
441+ // Declare or define a function of FNTYPE.
442+ // NAME is the Go name of the function. ASM_NAME, if not the empty string, is
443+ // the name that should be used in the symbol table; this will be non-empty if
444+ // a magic extern comment is used.
445+ // IS_VISIBLE is true if this function should be visible outside of the
446+ // current compilation unit. IS_DECLARATION is true if this is a function
447+ // declaration rather than a definition; the function definition will be in
448+ // another compilation unit.
449+ // IS_INLINABLE is true if the function can be inlined.
450+ // DISABLE_SPLIT_STACK is true if this function may not split the stack; this
451+ // is used for the implementation of recover.
452+ // IN_UNIQUE_SECTION is true if this function should be put into a unique
453+ // location if possible; this is used for field tracking.
454+ virtual Bfunction*
455+ function(Btype* fntype, const std::string& name, const std::string& asm_name,
456+ bool is_visible, bool is_declaration, bool is_inlinable,
457+ bool disable_split_stack, bool in_unique_section, Location) = 0;
458 };
459
460 // The backend interface has to define this function.
461@@ -517,5 +548,6 @@
462 extern tree stat_to_tree(Bstatement*);
463 extern tree block_to_tree(Bblock*);
464 extern tree var_to_tree(Bvariable*);
465+extern tree function_to_tree(Bfunction*);
466
467 #endif // !defined(GO_BACKEND_H)
468diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/expressions.cc gcc-4.8.2/gcc/go/gofrontend/expressions.cc
469--- gcc-4.8.2.orig/gcc/go/gofrontend/expressions.cc 2013-10-08 18:54:31.000000000 -0500
470+++ gcc-4.8.2/gcc/go/gofrontend/expressions.cc 2013-10-16 12:27:53.564070000 -0500
471@@ -1219,7 +1219,7 @@
472
473 // Get the tree for the code of a function expression.
474
475-tree
476+Bexpression*
477 Func_expression::get_code_pointer(Gogo* gogo, Named_object* no, Location loc)
478 {
479 Function_type* fntype;
480@@ -1237,25 +1237,18 @@
481 error_at(loc,
482 "invalid use of special builtin function %qs; must be called",
483 no->message_name().c_str());
484- return error_mark_node;
485+ return gogo->backend()->error_expression();
486 }
487
488- tree id = no->get_id(gogo);
489- if (id == error_mark_node)
490- return error_mark_node;
491-
492- tree fndecl;
493+ Bfunction* fndecl;
494 if (no->is_function())
495- fndecl = no->func_value()->get_or_make_decl(gogo, no, id);
496+ fndecl = no->func_value()->get_or_make_decl(gogo, no);
497 else if (no->is_function_declaration())
498- fndecl = no->func_declaration_value()->get_or_make_decl(gogo, no, id);
499+ fndecl = no->func_declaration_value()->get_or_make_decl(gogo, no);
500 else
501 go_unreachable();
502
503- if (fndecl == error_mark_node)
504- return error_mark_node;
505-
506- return build_fold_addr_expr_loc(loc.gcc_location(), fndecl);
507+ return gogo->backend()->function_code_expression(fndecl, loc);
508 }
509
510 // Get the tree for a function expression. This is used when we take
511@@ -1492,8 +1485,10 @@
512 tree
513 Func_code_reference_expression::do_get_tree(Translate_context* context)
514 {
515- return Func_expression::get_code_pointer(context->gogo(), this->function_,
516- this->location());
517+ Bexpression* ret =
518+ Func_expression::get_code_pointer(context->gogo(), this->function_,
519+ this->location());
520+ return expr_to_tree(ret);
521 }
522
523 // Make a reference to the code of a function.
524@@ -3055,8 +3050,7 @@
525 do_lower(Gogo*, Named_object*, Statement_inserter*, int);
526
527 bool
528- do_is_constant() const
529- { return this->expr_->is_constant(); }
530+ do_is_constant() const;
531
532 bool
533 do_numeric_constant_value(Numeric_constant*) const;
534@@ -3198,6 +3192,27 @@
535 return this;
536 }
537
538+// Return whether a type conversion is a constant.
539+
540+bool
541+Type_conversion_expression::do_is_constant() const
542+{
543+ if (!this->expr_->is_constant())
544+ return false;
545+
546+ // A conversion to a type that may not be used as a constant is not
547+ // a constant. For example, []byte(nil).
548+ Type* type = this->type_;
549+ if (type->integer_type() == NULL
550+ && type->float_type() == NULL
551+ && type->complex_type() == NULL
552+ && !type->is_boolean_type()
553+ && !type->is_string_type())
554+ return false;
555+
556+ return true;
557+}
558+
559 // Return the constant numeric value if there is one.
560
561 bool
562@@ -5586,6 +5601,15 @@
563 subcontext.type = NULL;
564 }
565
566+ if (this->op_ == OPERATOR_ANDAND || this->op_ == OPERATOR_OROR)
567+ {
568+ // For a logical operation, the context does not determine the
569+ // types of the operands. The operands must be some boolean
570+ // type but if the context has a boolean type they do not
571+ // inherit it. See http://golang.org/issue/3924.
572+ subcontext.type = NULL;
573+ }
574+
575 // Set the context for the left hand operand.
576 if (is_shift_op)
577 {
578@@ -5967,6 +5991,43 @@
579 right);
580 }
581
582+ // For complex division Go wants slightly different results than the
583+ // GCC library provides, so we have our own runtime routine.
584+ if (this->op_ == OPERATOR_DIV && this->left_->type()->complex_type() != NULL)
585+ {
586+ const char *name;
587+ tree *pdecl;
588+ Type* ctype;
589+ static tree complex64_div_decl;
590+ static tree complex128_div_decl;
591+ switch (this->left_->type()->complex_type()->bits())
592+ {
593+ case 64:
594+ name = "__go_complex64_div";
595+ pdecl = &complex64_div_decl;
596+ ctype = Type::lookup_complex_type("complex64");
597+ break;
598+ case 128:
599+ name = "__go_complex128_div";
600+ pdecl = &complex128_div_decl;
601+ ctype = Type::lookup_complex_type("complex128");
602+ break;
603+ default:
604+ go_unreachable();
605+ }
606+ Btype* cbtype = ctype->get_backend(gogo);
607+ tree ctype_tree = type_to_tree(cbtype);
608+ return Gogo::call_builtin(pdecl,
609+ this->location(),
610+ name,
611+ 2,
612+ ctype_tree,
613+ ctype_tree,
614+ fold_convert_loc(gccloc, ctype_tree, left),
615+ type,
616+ fold_convert_loc(gccloc, ctype_tree, right));
617+ }
618+
619 tree compute_type = excess_precision_type(type);
620 if (compute_type != NULL_TREE)
621 {
622@@ -7191,6 +7252,15 @@
623 if (this->code_ == BUILTIN_OFFSETOF)
624 {
625 Expression* arg = this->one_arg();
626+
627+ if (arg->bound_method_expression() != NULL
628+ || arg->interface_field_reference_expression() != NULL)
629+ {
630+ this->report_error(_("invalid use of method value as argument "
631+ "of Offsetof"));
632+ return this;
633+ }
634+
635 Field_reference_expression* farg = arg->field_reference_expression();
636 while (farg != NULL)
637 {
638@@ -7200,7 +7270,8 @@
639 // it must not be reached through pointer indirections.
640 if (farg->expr()->deref() != farg->expr())
641 {
642- this->report_error(_("argument of Offsetof implies indirection of an embedded field"));
643+ this->report_error(_("argument of Offsetof implies "
644+ "indirection of an embedded field"));
645 return this;
646 }
647 // Go up until we reach the original base.
648@@ -7476,7 +7547,7 @@
649 switch (nc.to_unsigned_long(&v))
650 {
651 case Numeric_constant::NC_UL_VALID:
652- return true;
653+ break;
654 case Numeric_constant::NC_UL_NOTINT:
655 error_at(e->location(), "non-integer %s argument to make",
656 is_length ? "len" : "cap");
657@@ -7488,8 +7559,23 @@
658 case Numeric_constant::NC_UL_BIG:
659 // We don't want to give a compile-time error for a 64-bit
660 // value on a 32-bit target.
661- return true;
662+ break;
663 }
664+
665+ mpz_t val;
666+ if (!nc.to_int(&val))
667+ go_unreachable();
668+ int bits = mpz_sizeinbase(val, 2);
669+ mpz_clear(val);
670+ Type* int_type = Type::lookup_integer_type("int");
671+ if (bits >= int_type->integer_type()->bits())
672+ {
673+ error_at(e->location(), "%s argument too large for make",
674+ is_length ? "len" : "cap");
675+ return false;
676+ }
677+
678+ return true;
679 }
680
681 if (e->type()->integer_type() != NULL)
682@@ -7595,6 +7681,8 @@
683 bool
684 Builtin_call_expression::do_is_constant() const
685 {
686+ if (this->is_error_expression())
687+ return true;
688 switch (this->code_)
689 {
690 case BUILTIN_LEN:
691@@ -9744,14 +9832,8 @@
692 }
693
694 tree fntype_tree = type_to_tree(fntype->get_backend(gogo));
695- if (fntype_tree == error_mark_node)
696- return error_mark_node;
697- go_assert(POINTER_TYPE_P(fntype_tree));
698- if (TREE_TYPE(fntype_tree) == error_mark_node)
699- return error_mark_node;
700- go_assert(TREE_CODE(TREE_TYPE(fntype_tree)) == RECORD_TYPE);
701- tree fnfield_type = TREE_TYPE(TYPE_FIELDS(TREE_TYPE(fntype_tree)));
702- if (fnfield_type == error_mark_node)
703+ tree fnfield_type = type_to_tree(fntype->get_backend_fntype(gogo));
704+ if (fntype_tree == error_mark_node || fnfield_type == error_mark_node)
705 return error_mark_node;
706 go_assert(FUNCTION_POINTER_TYPE_P(fnfield_type));
707 tree rettype = TREE_TYPE(TREE_TYPE(fnfield_type));
708@@ -9763,7 +9845,7 @@
709 if (func != NULL)
710 {
711 Named_object* no = func->named_object();
712- fn = Func_expression::get_code_pointer(gogo, no, location);
713+ fn = expr_to_tree(Func_expression::get_code_pointer(gogo, no, location));
714 if (!has_closure)
715 closure_tree = NULL_TREE;
716 else
717@@ -10817,11 +10899,20 @@
718 void
719 String_index_expression::do_check_types(Gogo*)
720 {
721- if (this->start_->type()->integer_type() == NULL)
722+ Numeric_constant nc;
723+ unsigned long v;
724+ if (this->start_->type()->integer_type() == NULL
725+ && !this->start_->type()->is_error()
726+ && (!this->start_->numeric_constant_value(&nc)
727+ || nc.to_unsigned_long(&v) == Numeric_constant::NC_UL_NOTINT))
728 this->report_error(_("index must be integer"));
729 if (this->end_ != NULL
730 && this->end_->type()->integer_type() == NULL
731- && !this->end_->is_nil_expression())
732+ && !this->end_->type()->is_error()
733+ && !this->end_->is_nil_expression()
734+ && !this->end_->is_error_expression()
735+ && (!this->end_->numeric_constant_value(&nc)
736+ || nc.to_unsigned_long(&v) == Numeric_constant::NC_UL_NOTINT))
737 this->report_error(_("slice end must be integer"));
738
739 std::string sval;
740diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/expressions.h gcc-4.8.2/gcc/go/gofrontend/expressions.h
741--- gcc-4.8.2.orig/gcc/go/gofrontend/expressions.h 2013-10-08 18:54:31.000000000 -0500
742+++ gcc-4.8.2/gcc/go/gofrontend/expressions.h 2013-10-16 12:27:53.564070000 -0500
743@@ -1514,8 +1514,8 @@
744 closure()
745 { return this->closure_; }
746
747- // Return a tree for the code for a function.
748- static tree
749+ // Return a backend expression for the code of a function.
750+ static Bexpression*
751 get_code_pointer(Gogo*, Named_object* function, Location loc);
752
753 protected:
754diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/gogo.cc gcc-4.8.2/gcc/go/gofrontend/gogo.cc
755--- gcc-4.8.2.orig/gcc/go/gofrontend/gogo.cc 2013-09-28 15:23:56.000000000 -0500
756+++ gcc-4.8.2/gcc/go/gofrontend/gogo.cc 2013-10-16 12:27:53.564070000 -0500
757@@ -3320,7 +3320,8 @@
758 closure_var_(NULL), block_(block), location_(location), labels_(),
759 local_type_count_(0), descriptor_(NULL), fndecl_(NULL), defer_stack_(NULL),
760 is_sink_(false), results_are_named_(false), nointerface_(false),
761- calls_recover_(false), is_recover_thunk_(false), has_recover_thunk_(false),
762+ is_unnamed_type_stub_method_(false), calls_recover_(false),
763+ is_recover_thunk_(false), has_recover_thunk_(false),
764 in_unique_section_(false)
765 {
766 }
767@@ -3819,6 +3820,81 @@
768 *presults = results;
769 }
770
771+// Get the backend representation.
772+
773+Bfunction*
774+Function::get_or_make_decl(Gogo* gogo, Named_object* no)
775+{
776+ if (this->fndecl_ == NULL)
777+ {
778+ std::string asm_name;
779+ bool is_visible = false;
780+ if (no->package() != NULL)
781+ ;
782+ else if (this->enclosing_ != NULL || Gogo::is_thunk(no))
783+ ;
784+ else if (Gogo::unpack_hidden_name(no->name()) == "init"
785+ && !this->type_->is_method())
786+ ;
787+ else if (Gogo::unpack_hidden_name(no->name()) == "main"
788+ && gogo->is_main_package())
789+ is_visible = true;
790+ // Methods have to be public even if they are hidden because
791+ // they can be pulled into type descriptors when using
792+ // anonymous fields.
793+ else if (!Gogo::is_hidden_name(no->name())
794+ || this->type_->is_method())
795+ {
796+ if (!this->is_unnamed_type_stub_method_)
797+ is_visible = true;
798+ std::string pkgpath = gogo->pkgpath_symbol();
799+ if (this->type_->is_method()
800+ && Gogo::is_hidden_name(no->name())
801+ && Gogo::hidden_name_pkgpath(no->name()) != gogo->pkgpath())
802+ {
803+ // This is a method we created for an unexported
804+ // method of an imported embedded type. We need to
805+ // use the pkgpath of the imported package to avoid
806+ // a possible name collision. See bug478 for a test
807+ // case.
808+ pkgpath = Gogo::hidden_name_pkgpath(no->name());
809+ pkgpath = Gogo::pkgpath_for_symbol(pkgpath);
810+ }
811+
812+ asm_name = pkgpath;
813+ asm_name.append(1, '.');
814+ asm_name.append(Gogo::unpack_hidden_name(no->name()));
815+ if (this->type_->is_method())
816+ {
817+ asm_name.append(1, '.');
818+ Type* rtype = this->type_->receiver()->type();
819+ asm_name.append(rtype->mangled_name(gogo));
820+ }
821+ }
822+
823+ // If a function calls the predeclared recover function, we
824+ // can't inline it, because recover behaves differently in a
825+ // function passed directly to defer. If this is a recover
826+ // thunk that we built to test whether a function can be
827+ // recovered, we can't inline it, because that will mess up
828+ // our return address comparison.
829+ bool is_inlinable = !(this->calls_recover_ || this->is_recover_thunk_);
830+
831+ // If this is a thunk created to call a function which calls
832+ // the predeclared recover function, we need to disable
833+ // stack splitting for the thunk.
834+ bool disable_split_stack = this->is_recover_thunk_;
835+
836+ Btype* functype = this->type_->get_backend_fntype(gogo);
837+ this->fndecl_ =
838+ gogo->backend()->function(functype, no->get_id(gogo), asm_name,
839+ is_visible, false, is_inlinable,
840+ disable_split_stack,
841+ this->in_unique_section_, this->location());
842+ }
843+ return this->fndecl_;
844+}
845+
846 // Class Block.
847
848 Block::Block(Block* enclosing, Location location)
849@@ -5110,6 +5186,75 @@
850 go_unreachable();
851 }
852
853+
854+// Return the external identifier for this object.
855+
856+std::string
857+Named_object::get_id(Gogo* gogo)
858+{
859+ go_assert(!this->is_variable() && !this->is_result_variable());
860+ std::string decl_name;
861+ if (this->is_function_declaration()
862+ && !this->func_declaration_value()->asm_name().empty())
863+ decl_name = this->func_declaration_value()->asm_name();
864+ else if (this->is_type()
865+ && Linemap::is_predeclared_location(this->type_value()->location()))
866+ {
867+ // We don't need the package name for builtin types.
868+ decl_name = Gogo::unpack_hidden_name(this->name_);
869+ }
870+ else
871+ {
872+ std::string package_name;
873+ if (this->package_ == NULL)
874+ package_name = gogo->package_name();
875+ else
876+ package_name = this->package_->package_name();
877+
878+ // Note that this will be misleading if this is an unexported
879+ // method generated for an embedded imported type. In that case
880+ // the unexported method should have the package name of the
881+ // package from which it is imported, but we are going to give
882+ // it our package name. Fixing this would require knowing the
883+ // package name, but we only know the package path. It might be
884+ // better to use package paths here anyhow. This doesn't affect
885+ // the assembler code, because we always set that name in
886+ // Function::get_or_make_decl anyhow. FIXME.
887+
888+ decl_name = package_name + '.' + Gogo::unpack_hidden_name(this->name_);
889+
890+ Function_type* fntype;
891+ if (this->is_function())
892+ fntype = this->func_value()->type();
893+ else if (this->is_function_declaration())
894+ fntype = this->func_declaration_value()->type();
895+ else
896+ fntype = NULL;
897+ if (fntype != NULL && fntype->is_method())
898+ {
899+ decl_name.push_back('.');
900+ decl_name.append(fntype->receiver()->type()->mangled_name(gogo));
901+ }
902+ }
903+ if (this->is_type())
904+ {
905+ unsigned int index;
906+ const Named_object* in_function = this->type_value()->in_function(&index);
907+ if (in_function != NULL)
908+ {
909+ decl_name += '$' + Gogo::unpack_hidden_name(in_function->name());
910+ if (index > 0)
911+ {
912+ char buf[30];
913+ snprintf(buf, sizeof buf, "%u", index);
914+ decl_name += '$';
915+ decl_name += buf;
916+ }
917+ }
918+ }
919+ return decl_name;
920+}
921+
922 // Class Bindings.
923
924 Bindings::Bindings(Bindings* enclosing)
925diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/gogo.h gcc-4.8.2/gcc/go/gofrontend/gogo.h
926--- gcc-4.8.2.orig/gcc/go/gofrontend/gogo.h 2013-09-28 15:23:56.000000000 -0500
927+++ gcc-4.8.2/gcc/go/gofrontend/gogo.h 2013-10-16 12:27:53.564070000 -0500
928@@ -48,6 +48,7 @@
929 class Bblock;
930 class Bvariable;
931 class Blabel;
932+class Bfunction;
933
934 // This file declares the basic classes used to hold the internal
935 // representation of Go which is built by the parser.
936@@ -952,6 +953,15 @@
937 this->nointerface_ = true;
938 }
939
940+ // Record that this function is a stub method created for an unnamed
941+ // type.
942+ void
943+ set_is_unnamed_type_stub_method()
944+ {
945+ go_assert(this->is_method());
946+ this->is_unnamed_type_stub_method_ = true;
947+ }
948+
949 // Add a new field to the closure variable.
950 void
951 add_closure_field(Named_object* var, Location loc)
952@@ -1089,17 +1099,13 @@
953 this->descriptor_ = descriptor;
954 }
955
956- // Return the function's decl given an identifier.
957- tree
958- get_or_make_decl(Gogo*, Named_object*, tree id);
959+ // Return the backend representation.
960+ Bfunction*
961+ get_or_make_decl(Gogo*, Named_object*);
962
963 // Return the function's decl after it has been built.
964 tree
965- get_decl() const
966- {
967- go_assert(this->fndecl_ != NULL);
968- return this->fndecl_;
969- }
970+ get_decl() const;
971
972 // Set the function decl to hold a tree of the function code.
973 void
974@@ -1170,7 +1176,7 @@
975 // The function descriptor, if any.
976 Expression* descriptor_;
977 // The function decl.
978- tree fndecl_;
979+ Bfunction* fndecl_;
980 // The defer stack variable. A pointer to this variable is used to
981 // distinguish the defer stack for one function from another. This
982 // is NULL unless we actually need a defer stack.
983@@ -1181,6 +1187,9 @@
984 bool results_are_named_ : 1;
985 // True if this method should not be included in the type descriptor.
986 bool nointerface_ : 1;
987+ // True if this function is a stub method created for an unnamed
988+ // type.
989+ bool is_unnamed_type_stub_method_ : 1;
990 // True if this function calls the predeclared recover function.
991 bool calls_recover_ : 1;
992 // True if this a thunk built for a function which calls recover.
993@@ -1265,9 +1274,9 @@
994 has_descriptor() const
995 { return this->descriptor_ != NULL; }
996
997- // Return a decl for the function given an identifier.
998- tree
999- get_or_make_decl(Gogo*, Named_object*, tree id);
1000+ // Return a backend representation.
1001+ Bfunction*
1002+ get_or_make_decl(Gogo*, Named_object*);
1003
1004 // If there is a descriptor, build it into the backend
1005 // representation.
1006@@ -1290,7 +1299,7 @@
1007 // The function descriptor, if any.
1008 Expression* descriptor_;
1009 // The function decl if needed.
1010- tree fndecl_;
1011+ Bfunction* fndecl_;
1012 };
1013
1014 // A variable.
1015@@ -2181,8 +2190,8 @@
1016 Bvariable*
1017 get_backend_variable(Gogo*, Named_object* function);
1018
1019- // Return a tree for the external identifier for this object.
1020- tree
1021+ // Return the external identifier for this object.
1022+ std::string
1023 get_id(Gogo*);
1024
1025 // Return a tree representing this object.
1026diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/gogo-tree.cc gcc-4.8.2/gcc/go/gofrontend/gogo-tree.cc
1027--- gcc-4.8.2.orig/gcc/go/gofrontend/gogo-tree.cc 2013-09-28 15:23:56.000000000 -0500
1028+++ gcc-4.8.2/gcc/go/gofrontend/gogo-tree.cc 2013-10-16 12:27:53.564070000 -0500
1029@@ -985,74 +985,6 @@
1030 delete[] vec;
1031 }
1032
1033-// Get a tree for the identifier for a named object.
1034-
1035-tree
1036-Named_object::get_id(Gogo* gogo)
1037-{
1038- go_assert(!this->is_variable() && !this->is_result_variable());
1039- std::string decl_name;
1040- if (this->is_function_declaration()
1041- && !this->func_declaration_value()->asm_name().empty())
1042- decl_name = this->func_declaration_value()->asm_name();
1043- else if (this->is_type()
1044- && Linemap::is_predeclared_location(this->type_value()->location()))
1045- {
1046- // We don't need the package name for builtin types.
1047- decl_name = Gogo::unpack_hidden_name(this->name_);
1048- }
1049- else
1050- {
1051- std::string package_name;
1052- if (this->package_ == NULL)
1053- package_name = gogo->package_name();
1054- else
1055- package_name = this->package_->package_name();
1056-
1057- // Note that this will be misleading if this is an unexported
1058- // method generated for an embedded imported type. In that case
1059- // the unexported method should have the package name of the
1060- // package from which it is imported, but we are going to give
1061- // it our package name. Fixing this would require knowing the
1062- // package name, but we only know the package path. It might be
1063- // better to use package paths here anyhow. This doesn't affect
1064- // the assembler code, because we always set that name in
1065- // Function::get_or_make_decl anyhow. FIXME.
1066-
1067- decl_name = package_name + '.' + Gogo::unpack_hidden_name(this->name_);
1068-
1069- Function_type* fntype;
1070- if (this->is_function())
1071- fntype = this->func_value()->type();
1072- else if (this->is_function_declaration())
1073- fntype = this->func_declaration_value()->type();
1074- else
1075- fntype = NULL;
1076- if (fntype != NULL && fntype->is_method())
1077- {
1078- decl_name.push_back('.');
1079- decl_name.append(fntype->receiver()->type()->mangled_name(gogo));
1080- }
1081- }
1082- if (this->is_type())
1083- {
1084- unsigned int index;
1085- const Named_object* in_function = this->type_value()->in_function(&index);
1086- if (in_function != NULL)
1087- {
1088- decl_name += '$' + Gogo::unpack_hidden_name(in_function->name());
1089- if (index > 0)
1090- {
1091- char buf[30];
1092- snprintf(buf, sizeof buf, "%u", index);
1093- decl_name += '$';
1094- decl_name += buf;
1095- }
1096- }
1097- }
1098- return get_identifier_from_string(decl_name);
1099-}
1100-
1101 // Get a tree for a named object.
1102
1103 tree
1104@@ -1067,11 +999,6 @@
1105 return error_mark_node;
1106 }
1107
1108- tree name;
1109- if (this->classification_ == NAMED_OBJECT_TYPE)
1110- name = NULL_TREE;
1111- else
1112- name = this->get_id(gogo);
1113 tree decl;
1114 switch (this->classification_)
1115 {
1116@@ -1099,6 +1026,7 @@
1117 decl = error_mark_node;
1118 else if (INTEGRAL_TYPE_P(TREE_TYPE(expr_tree)))
1119 {
1120+ tree name = get_identifier_from_string(this->get_id(gogo));
1121 decl = build_decl(named_constant->location().gcc_location(),
1122 CONST_DECL, name, TREE_TYPE(expr_tree));
1123 DECL_INITIAL(decl) = expr_tree;
1124@@ -1161,7 +1089,7 @@
1125 case NAMED_OBJECT_FUNC:
1126 {
1127 Function* func = this->u_.func_value;
1128- decl = func->get_or_make_decl(gogo, this, name);
1129+ decl = function_to_tree(func->get_or_make_decl(gogo, this));
1130 if (decl != error_mark_node)
1131 {
1132 if (func->block() != NULL)
1133@@ -1286,123 +1214,12 @@
1134 return block_tree;
1135 }
1136
1137-// Get a tree for a function decl.
1138+// Get the backend representation.
1139
1140-tree
1141-Function::get_or_make_decl(Gogo* gogo, Named_object* no, tree id)
1142+Bfunction*
1143+Function_declaration::get_or_make_decl(Gogo* gogo, Named_object* no)
1144 {
1145- if (this->fndecl_ == NULL_TREE)
1146- {
1147- tree functype = type_to_tree(this->type_->get_backend(gogo));
1148-
1149- if (functype != error_mark_node)
1150- {
1151- // The type of a function comes back as a pointer to a
1152- // struct whose first field is the function, but we want the
1153- // real function type for a function declaration.
1154- go_assert(POINTER_TYPE_P(functype)
1155- && TREE_CODE(TREE_TYPE(functype)) == RECORD_TYPE);
1156- functype = TREE_TYPE(TYPE_FIELDS(TREE_TYPE(functype)));
1157- go_assert(FUNCTION_POINTER_TYPE_P(functype));
1158- functype = TREE_TYPE(functype);
1159- }
1160-
1161- if (functype == error_mark_node)
1162- this->fndecl_ = error_mark_node;
1163- else
1164- {
1165- tree decl = build_decl(this->location().gcc_location(), FUNCTION_DECL,
1166- id, functype);
1167-
1168- this->fndecl_ = decl;
1169-
1170- if (no->package() != NULL)
1171- ;
1172- else if (this->enclosing_ != NULL || Gogo::is_thunk(no))
1173- ;
1174- else if (Gogo::unpack_hidden_name(no->name()) == "init"
1175- && !this->type_->is_method())
1176- ;
1177- else if (Gogo::unpack_hidden_name(no->name()) == "main"
1178- && gogo->is_main_package())
1179- TREE_PUBLIC(decl) = 1;
1180- // Methods have to be public even if they are hidden because
1181- // they can be pulled into type descriptors when using
1182- // anonymous fields.
1183- else if (!Gogo::is_hidden_name(no->name())
1184- || this->type_->is_method())
1185- {
1186- TREE_PUBLIC(decl) = 1;
1187- std::string pkgpath = gogo->pkgpath_symbol();
1188- if (this->type_->is_method()
1189- && Gogo::is_hidden_name(no->name())
1190- && Gogo::hidden_name_pkgpath(no->name()) != gogo->pkgpath())
1191- {
1192- // This is a method we created for an unexported
1193- // method of an imported embedded type. We need to
1194- // use the pkgpath of the imported package to avoid
1195- // a possible name collision. See bug478 for a test
1196- // case.
1197- pkgpath = Gogo::hidden_name_pkgpath(no->name());
1198- pkgpath = Gogo::pkgpath_for_symbol(pkgpath);
1199- }
1200-
1201- std::string asm_name = pkgpath;
1202- asm_name.append(1, '.');
1203- asm_name.append(Gogo::unpack_hidden_name(no->name()));
1204- if (this->type_->is_method())
1205- {
1206- asm_name.append(1, '.');
1207- Type* rtype = this->type_->receiver()->type();
1208- asm_name.append(rtype->mangled_name(gogo));
1209- }
1210- SET_DECL_ASSEMBLER_NAME(decl,
1211- get_identifier_from_string(asm_name));
1212- }
1213-
1214- // Why do we have to do this in the frontend?
1215- tree restype = TREE_TYPE(functype);
1216- tree resdecl =
1217- build_decl(this->location().gcc_location(), RESULT_DECL, NULL_TREE,
1218- restype);
1219- DECL_ARTIFICIAL(resdecl) = 1;
1220- DECL_IGNORED_P(resdecl) = 1;
1221- DECL_CONTEXT(resdecl) = decl;
1222- DECL_RESULT(decl) = resdecl;
1223-
1224- // If a function calls the predeclared recover function, we
1225- // can't inline it, because recover behaves differently in a
1226- // function passed directly to defer. If this is a recover
1227- // thunk that we built to test whether a function can be
1228- // recovered, we can't inline it, because that will mess up
1229- // our return address comparison.
1230- if (this->calls_recover_ || this->is_recover_thunk_)
1231- DECL_UNINLINABLE(decl) = 1;
1232-
1233- // If this is a thunk created to call a function which calls
1234- // the predeclared recover function, we need to disable
1235- // stack splitting for the thunk.
1236- if (this->is_recover_thunk_)
1237- {
1238- tree attr = get_identifier("__no_split_stack__");
1239- DECL_ATTRIBUTES(decl) = tree_cons(attr, NULL_TREE, NULL_TREE);
1240- }
1241-
1242- if (this->in_unique_section_)
1243- resolve_unique_section (decl, 0, 1);
1244-
1245- go_preserve_from_gc(decl);
1246- }
1247- }
1248- return this->fndecl_;
1249-}
1250-
1251-// Get a tree for a function declaration.
1252-
1253-tree
1254-Function_declaration::get_or_make_decl(Gogo* gogo, Named_object* no, tree id)
1255-{
1256- if (this->fndecl_ == NULL_TREE)
1257+ if (this->fndecl_ == NULL)
1258 {
1259 // Let Go code use an asm declaration to pick up a builtin
1260 // function.
1261@@ -1412,56 +1229,44 @@
1262 builtin_functions.find(this->asm_name_);
1263 if (p != builtin_functions.end())
1264 {
1265- this->fndecl_ = p->second;
1266+ this->fndecl_ = tree_to_function(p->second);
1267 return this->fndecl_;
1268 }
1269 }
1270
1271- tree functype = type_to_tree(this->fntype_->get_backend(gogo));
1272+ std::string asm_name;
1273+ if (this->asm_name_.empty())
1274+ {
1275+ asm_name = (no->package() == NULL
1276+ ? gogo->pkgpath_symbol()
1277+ : no->package()->pkgpath_symbol());
1278+ asm_name.append(1, '.');
1279+ asm_name.append(Gogo::unpack_hidden_name(no->name()));
1280+ if (this->fntype_->is_method())
1281+ {
1282+ asm_name.append(1, '.');
1283+ Type* rtype = this->fntype_->receiver()->type();
1284+ asm_name.append(rtype->mangled_name(gogo));
1285+ }
1286+ }
1287+
1288+ Btype* functype = this->fntype_->get_backend_fntype(gogo);
1289+ this->fndecl_ =
1290+ gogo->backend()->function(functype, no->get_id(gogo), asm_name,
1291+ true, true, true, false, false,
1292+ this->location());
1293+ }
1294
1295- if (functype != error_mark_node)
1296- {
1297- // The type of a function comes back as a pointer to a
1298- // struct whose first field is the function, but we want the
1299- // real function type for a function declaration.
1300- go_assert(POINTER_TYPE_P(functype)
1301- && TREE_CODE(TREE_TYPE(functype)) == RECORD_TYPE);
1302- functype = TREE_TYPE(TYPE_FIELDS(TREE_TYPE(functype)));
1303- go_assert(FUNCTION_POINTER_TYPE_P(functype));
1304- functype = TREE_TYPE(functype);
1305- }
1306+ return this->fndecl_;
1307+}
1308
1309- tree decl;
1310- if (functype == error_mark_node)
1311- decl = error_mark_node;
1312- else
1313- {
1314- decl = build_decl(this->location().gcc_location(), FUNCTION_DECL, id,
1315- functype);
1316- TREE_PUBLIC(decl) = 1;
1317- DECL_EXTERNAL(decl) = 1;
1318+// Return the function's decl after it has been built.
1319
1320- if (this->asm_name_.empty())
1321- {
1322- std::string asm_name = (no->package() == NULL
1323- ? gogo->pkgpath_symbol()
1324- : no->package()->pkgpath_symbol());
1325- asm_name.append(1, '.');
1326- asm_name.append(Gogo::unpack_hidden_name(no->name()));
1327- if (this->fntype_->is_method())
1328- {
1329- asm_name.append(1, '.');
1330- Type* rtype = this->fntype_->receiver()->type();
1331- asm_name.append(rtype->mangled_name(gogo));
1332- }
1333- SET_DECL_ASSEMBLER_NAME(decl,
1334- get_identifier_from_string(asm_name));
1335- }
1336- }
1337- this->fndecl_ = decl;
1338- go_preserve_from_gc(decl);
1339- }
1340- return this->fndecl_;
1341+tree
1342+Function::get_decl() const
1343+{
1344+ go_assert(this->fndecl_ != NULL);
1345+ return function_to_tree(this->fndecl_);
1346 }
1347
1348 // We always pass the receiver to a method as a pointer. If the
1349@@ -1558,7 +1363,7 @@
1350 void
1351 Function::build_tree(Gogo* gogo, Named_object* named_function)
1352 {
1353- tree fndecl = this->fndecl_;
1354+ tree fndecl = this->get_decl();
1355 go_assert(fndecl != NULL_TREE);
1356
1357 tree params = NULL_TREE;
1358@@ -1796,7 +1601,7 @@
1359 set = NULL_TREE;
1360 else
1361 set = fold_build2_loc(end_loc.gcc_location(), MODIFY_EXPR, void_type_node,
1362- DECL_RESULT(this->fndecl_), retval);
1363+ DECL_RESULT(this->get_decl()), retval);
1364 tree ret_stmt = fold_build1_loc(end_loc.gcc_location(), RETURN_EXPR,
1365 void_type_node, set);
1366 append_to_statement_list(ret_stmt, &stmt_list);
1367@@ -1851,7 +1656,7 @@
1368 retval = this->return_value(gogo, named_function, end_loc,
1369 &stmt_list);
1370 set = fold_build2_loc(end_loc.gcc_location(), MODIFY_EXPR, void_type_node,
1371- DECL_RESULT(this->fndecl_), retval);
1372+ DECL_RESULT(this->get_decl()), retval);
1373 ret_stmt = fold_build1_loc(end_loc.gcc_location(), RETURN_EXPR,
1374 void_type_node, set);
1375
1376@@ -1869,7 +1674,7 @@
1377 *fini = stmt_list;
1378 }
1379
1380-// Return the value to assign to DECL_RESULT(this->fndecl_). This may
1381+// Return the value to assign to DECL_RESULT(this->get_decl()). This may
1382 // also add statements to STMT_LIST, which need to be executed before
1383 // the assignment. This is used for a return statement with no
1384 // explicit values.
1385@@ -1902,7 +1707,7 @@
1386 }
1387 else
1388 {
1389- tree rettype = TREE_TYPE(DECL_RESULT(this->fndecl_));
1390+ tree rettype = TREE_TYPE(DECL_RESULT(this->get_decl()));
1391 retval = create_tmp_var(rettype, "RESULT");
1392 tree field = TYPE_FIELDS(rettype);
1393 int index = 0;
1394@@ -2323,18 +2128,14 @@
1395 go_assert(m != NULL);
1396
1397 Named_object* no = m->named_object();
1398-
1399- tree fnid = no->get_id(this);
1400-
1401- tree fndecl;
1402+ Bfunction* bf;
1403 if (no->is_function())
1404- fndecl = no->func_value()->get_or_make_decl(this, no, fnid);
1405+ bf = no->func_value()->get_or_make_decl(this, no);
1406 else if (no->is_function_declaration())
1407- fndecl = no->func_declaration_value()->get_or_make_decl(this, no,
1408- fnid);
1409+ bf = no->func_declaration_value()->get_or_make_decl(this, no);
1410 else
1411 go_unreachable();
1412- fndecl = build_fold_addr_expr(fndecl);
1413+ tree fndecl = build_fold_addr_expr(function_to_tree(bf));
1414
1415 elt = pointers->quick_push(empty);
1416 elt->index = size_int(i);
1417@@ -2353,10 +2154,11 @@
1418 TREE_CONSTANT(decl) = 1;
1419 DECL_INITIAL(decl) = constructor;
1420
1421- // If the interface type has hidden methods, then this is the only
1422- // definition of the table. Otherwise it is a comdat table which
1423- // may be defined in multiple packages.
1424- if (has_hidden_methods)
1425+ // If the interface type has hidden methods, and the table is for a
1426+ // named type, then this is the only definition of the table.
1427+ // Otherwise it is a comdat table which may be defined in multiple
1428+ // packages.
1429+ if (has_hidden_methods && type->named_type() != NULL)
1430 TREE_PUBLIC(decl) = 1;
1431 else
1432 {
1433diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/import.h gcc-4.8.2/gcc/go/gofrontend/import.h
1434--- gcc-4.8.2.orig/gcc/go/gofrontend/import.h 2012-10-30 19:38:49.000000000 -0500
1435+++ gcc-4.8.2/gcc/go/gofrontend/import.h 2013-10-16 12:27:53.564070000 -0500
1436@@ -149,6 +149,11 @@
1437 location() const
1438 { return this->location_; }
1439
1440+ // Return the package we are importing.
1441+ Package*
1442+ package() const
1443+ { return this->package_; }
1444+
1445 // Return the next character.
1446 int
1447 peek_char()
1448diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/lex.cc gcc-4.8.2/gcc/go/gofrontend/lex.cc
1449--- gcc-4.8.2.orig/gcc/go/gofrontend/lex.cc 2012-12-03 00:57:04.000000000 -0600
1450+++ gcc-4.8.2/gcc/go/gofrontend/lex.cc 2013-10-16 12:27:53.564070000 -0500
1451@@ -873,7 +873,28 @@
1452 && (cc < 'a' || cc > 'z')
1453 && cc != '_'
1454 && (cc < '0' || cc > '9'))
1455- break;
1456+ {
1457+ // Check for an invalid character here, as we get better
1458+ // error behaviour if we swallow them as part of the
1459+ // identifier we are building.
1460+ if ((cc >= ' ' && cc < 0x7f)
1461+ || cc == '\t'
1462+ || cc == '\r'
1463+ || cc == '\n')
1464+ break;
1465+
1466+ this->lineoff_ = p - this->linebuf_;
1467+ error_at(this->location(),
1468+ "invalid character 0x%x in identifier",
1469+ cc);
1470+ if (!has_non_ascii_char)
1471+ {
1472+ buf.assign(pstart, p - pstart);
1473+ has_non_ascii_char = true;
1474+ }
1475+ if (!Lex::is_invalid_identifier(buf))
1476+ buf.append("$INVALID$");
1477+ }
1478 ++p;
1479 if (is_first)
1480 {
1481diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/parse.cc gcc-4.8.2/gcc/go/gofrontend/parse.cc
1482--- gcc-4.8.2.orig/gcc/go/gofrontend/parse.cc 2013-10-08 18:54:31.000000000 -0500
1483+++ gcc-4.8.2/gcc/go/gofrontend/parse.cc 2013-10-16 12:27:53.564070000 -0500
1484@@ -744,6 +744,8 @@
1485 return NULL;
1486
1487 Parse::Names names;
1488+ if (receiver != NULL)
1489+ names[receiver->name()] = receiver;
1490 if (params != NULL)
1491 this->check_signature_names(params, &names);
1492 if (results != NULL)
1493diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/runtime.cc gcc-4.8.2/gcc/go/gofrontend/runtime.cc
1494--- gcc-4.8.2.orig/gcc/go/gofrontend/runtime.cc 2012-12-21 09:59:27.000000000 -0600
1495+++ gcc-4.8.2/gcc/go/gofrontend/runtime.cc 2013-10-16 12:27:53.564070000 -0500
1496@@ -42,6 +42,8 @@
1497 RFT_RUNE,
1498 // Go type float64, C type double.
1499 RFT_FLOAT64,
1500+ // Go type complex64, C type __complex float.
1501+ RFT_COMPLEX64,
1502 // Go type complex128, C type __complex double.
1503 RFT_COMPLEX128,
1504 // Go type string, C type struct __go_string.
1505@@ -126,6 +128,10 @@
1506 t = Type::lookup_float_type("float64");
1507 break;
1508
1509+ case RFT_COMPLEX64:
1510+ t = Type::lookup_complex_type("complex64");
1511+ break;
1512+
1513 case RFT_COMPLEX128:
1514 t = Type::lookup_complex_type("complex128");
1515 break;
1516@@ -216,6 +222,7 @@
1517 case RFT_UINTPTR:
1518 case RFT_RUNE:
1519 case RFT_FLOAT64:
1520+ case RFT_COMPLEX64:
1521 case RFT_COMPLEX128:
1522 case RFT_STRING:
1523 case RFT_POINTER:
1524diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/runtime.def gcc-4.8.2/gcc/go/gofrontend/runtime.def
1525--- gcc-4.8.2.orig/gcc/go/gofrontend/runtime.def 2013-06-18 18:50:42.000000000 -0500
1526+++ gcc-4.8.2/gcc/go/gofrontend/runtime.def 2013-10-16 12:27:53.564070000 -0500
1527@@ -68,6 +68,12 @@
1528 P1(STRING), R1(SLICE))
1529
1530
1531+// Complex division.
1532+DEF_GO_RUNTIME(COMPLEX64_DIV, "__go_complex64_div",
1533+ P2(COMPLEX64, COMPLEX64), R1(COMPLEX64))
1534+DEF_GO_RUNTIME(COMPLEX128_DIV, "__go_complex128_div",
1535+ P2(COMPLEX128, COMPLEX128), R1(COMPLEX128))
1536+
1537 // Make a slice.
1538 DEF_GO_RUNTIME(MAKESLICE1, "__go_make_slice1", P2(TYPE, UINTPTR), R1(SLICE))
1539 DEF_GO_RUNTIME(MAKESLICE2, "__go_make_slice2", P3(TYPE, UINTPTR, UINTPTR),
1540diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/types.cc gcc-4.8.2/gcc/go/gofrontend/types.cc
1541--- gcc-4.8.2.orig/gcc/go/gofrontend/types.cc 2013-10-02 14:22:30.000000000 -0500
1542+++ gcc-4.8.2/gcc/go/gofrontend/types.cc 2013-10-17 15:08:21.970831000 -0500
1543@@ -3383,6 +3383,68 @@
1544 // Get the backend representation for a function type.
1545
1546 Btype*
1547+Function_type::get_backend_fntype(Gogo* gogo)
1548+{
1549+ if (this->fnbtype_ == NULL)
1550+ {
1551+ Backend::Btyped_identifier breceiver;
1552+ if (this->receiver_ != NULL)
1553+ {
1554+ breceiver.name = Gogo::unpack_hidden_name(this->receiver_->name());
1555+
1556+ // We always pass the address of the receiver parameter, in
1557+ // order to make interface calls work with unknown types.
1558+ Type* rtype = this->receiver_->type();
1559+ if (rtype->points_to() == NULL)
1560+ rtype = Type::make_pointer_type(rtype);
1561+ breceiver.btype = rtype->get_backend(gogo);
1562+ breceiver.location = this->receiver_->location();
1563+ }
1564+
1565+ std::vector<Backend::Btyped_identifier> bparameters;
1566+ if (this->parameters_ != NULL)
1567+ {
1568+ bparameters.resize(this->parameters_->size());
1569+ size_t i = 0;
1570+ for (Typed_identifier_list::const_iterator p =
1571+ this->parameters_->begin(); p != this->parameters_->end();
1572+ ++p, ++i)
1573+ {
1574+ bparameters[i].name = Gogo::unpack_hidden_name(p->name());
1575+ bparameters[i].btype = p->type()->get_backend(gogo);
1576+ bparameters[i].location = p->location();
1577+ }
1578+ go_assert(i == bparameters.size());
1579+ }
1580+
1581+ std::vector<Backend::Btyped_identifier> bresults;
1582+ if (this->results_ != NULL)
1583+ {
1584+ bresults.resize(this->results_->size());
1585+ size_t i = 0;
1586+ for (Typed_identifier_list::const_iterator p =
1587+ this->results_->begin(); p != this->results_->end();
1588+ ++p, ++i)
1589+ {
1590+ bresults[i].name = Gogo::unpack_hidden_name(p->name());
1591+ bresults[i].btype = p->type()->get_backend(gogo);
1592+ bresults[i].location = p->location();
1593+ }
1594+ go_assert(i == bresults.size());
1595+ }
1596+
1597+ this->fnbtype_ = gogo->backend()->function_type(breceiver, bparameters,
1598+ bresults,
1599+ this->location());
1600+
1601+ }
1602+
1603+ return this->fnbtype_;
1604+}
1605+
1606+// Get the backend representation for a Go function type.
1607+
1608+Btype*
1609 Function_type::do_get_backend(Gogo* gogo)
1610 {
1611 // When we do anything with a function value other than call it, it
1612@@ -3395,57 +3457,9 @@
1613 gogo->backend()->placeholder_struct_type("__go_descriptor", loc);
1614 Btype* ptr_struct_type = gogo->backend()->pointer_type(struct_type);
1615
1616- Backend::Btyped_identifier breceiver;
1617- if (this->receiver_ != NULL)
1618- {
1619- breceiver.name = Gogo::unpack_hidden_name(this->receiver_->name());
1620-
1621- // We always pass the address of the receiver parameter, in
1622- // order to make interface calls work with unknown types.
1623- Type* rtype = this->receiver_->type();
1624- if (rtype->points_to() == NULL)
1625- rtype = Type::make_pointer_type(rtype);
1626- breceiver.btype = rtype->get_backend(gogo);
1627- breceiver.location = this->receiver_->location();
1628- }
1629-
1630- std::vector<Backend::Btyped_identifier> bparameters;
1631- if (this->parameters_ != NULL)
1632- {
1633- bparameters.resize(this->parameters_->size());
1634- size_t i = 0;
1635- for (Typed_identifier_list::const_iterator p = this->parameters_->begin();
1636- p != this->parameters_->end();
1637- ++p, ++i)
1638- {
1639- bparameters[i].name = Gogo::unpack_hidden_name(p->name());
1640- bparameters[i].btype = p->type()->get_backend(gogo);
1641- bparameters[i].location = p->location();
1642- }
1643- go_assert(i == bparameters.size());
1644- }
1645-
1646- std::vector<Backend::Btyped_identifier> bresults;
1647- if (this->results_ != NULL)
1648- {
1649- bresults.resize(this->results_->size());
1650- size_t i = 0;
1651- for (Typed_identifier_list::const_iterator p = this->results_->begin();
1652- p != this->results_->end();
1653- ++p, ++i)
1654- {
1655- bresults[i].name = Gogo::unpack_hidden_name(p->name());
1656- bresults[i].btype = p->type()->get_backend(gogo);
1657- bresults[i].location = p->location();
1658- }
1659- go_assert(i == bresults.size());
1660- }
1661-
1662- Btype* fntype = gogo->backend()->function_type(breceiver, bparameters,
1663- bresults, loc);
1664 std::vector<Backend::Btyped_identifier> fields(1);
1665 fields[0].name = "code";
1666- fields[0].btype = fntype;
1667+ fields[0].btype = this->get_backend_fntype(gogo);
1668 fields[0].location = loc;
1669 if (!gogo->backend()->set_placeholder_struct_type(struct_type, fields))
1670 return gogo->backend()->error_type();
1671@@ -4195,7 +4209,8 @@
1672
1673 // This is a horrible hack caused by the fact that we don't pack
1674 // the names of builtin types. FIXME.
1675- if (nt != NULL
1676+ if (!this->is_imported_
1677+ && nt != NULL
1678 && nt->is_builtin()
1679 && nt->name() == Gogo::unpack_hidden_name(name))
1680 return true;
1681@@ -4204,6 +4219,36 @@
1682 }
1683 }
1684
1685+// Return whether this field is an unexported field named NAME.
1686+
1687+bool
1688+Struct_field::is_unexported_field_name(Gogo* gogo,
1689+ const std::string& name) const
1690+{
1691+ const std::string& field_name(this->field_name());
1692+ if (Gogo::is_hidden_name(field_name)
1693+ && name == Gogo::unpack_hidden_name(field_name)
1694+ && gogo->pack_hidden_name(name, false) != field_name)
1695+ return true;
1696+
1697+ // Check for the name of a builtin type. This is like the test in
1698+ // is_field_name, only there we return false if this->is_imported_,
1699+ // and here we return true.
1700+ if (this->is_imported_ && this->is_anonymous())
1701+ {
1702+ Type* t = this->typed_identifier_.type();
1703+ if (t->points_to() != NULL)
1704+ t = t->points_to();
1705+ Named_type* nt = t->named_type();
1706+ if (nt != NULL
1707+ && nt->is_builtin()
1708+ && nt->name() == Gogo::unpack_hidden_name(name))
1709+ return true;
1710+ }
1711+
1712+ return false;
1713+}
1714+
1715 // Return whether this field is an embedded built-in type.
1716
1717 bool
1718@@ -4264,12 +4309,7 @@
1719 ++p)
1720 {
1721 Type* t = p->type();
1722- if (t->is_undefined())
1723- {
1724- error_at(p->location(), "struct field type is incomplete");
1725- p->set_type(Type::make_error_type());
1726- }
1727- else if (p->is_anonymous())
1728+ if (p->is_anonymous())
1729 {
1730 if (t->named_type() != NULL && t->points_to() != NULL)
1731 {
1732@@ -4641,13 +4681,8 @@
1733 for (Struct_field_list::const_iterator pf = fields->begin();
1734 pf != fields->end();
1735 ++pf)
1736- {
1737- const std::string& field_name(pf->field_name());
1738- if (Gogo::is_hidden_name(field_name)
1739- && name == Gogo::unpack_hidden_name(field_name)
1740- && gogo->pack_hidden_name(name, false) != field_name)
1741- return true;
1742- }
1743+ if (pf->is_unexported_field_name(gogo, name))
1744+ return true;
1745 }
1746 return false;
1747 }
1748@@ -5250,6 +5285,7 @@
1749 Type* ftype = imp->read_type();
1750
1751 Struct_field sf(Typed_identifier(name, ftype, imp->location()));
1752+ sf.set_is_imported();
1753
1754 if (imp->peek_char() == ' ')
1755 {
1756@@ -9022,6 +9058,8 @@
1757 fntype->is_varargs(), location);
1758 gogo->finish_function(fntype->location());
1759
1760+ if (type->named_type() == NULL && stub->is_function())
1761+ stub->func_value()->set_is_unnamed_type_stub_method();
1762 if (m->nointerface() && stub->is_function())
1763 stub->func_value()->set_nointerface();
1764 }
1765@@ -9289,7 +9327,9 @@
1766 else
1767 {
1768 bool is_unexported;
1769- if (!Gogo::is_hidden_name(name))
1770+ // The test for 'a' and 'z' is to handle builtin names,
1771+ // which are not hidden.
1772+ if (!Gogo::is_hidden_name(name) && (name[0] < 'a' || name[0] > 'z'))
1773 is_unexported = false;
1774 else
1775 {
1776diff -Naur gcc-4.8.2.orig/gcc/go/gofrontend/types.h gcc-4.8.2/gcc/go/gofrontend/types.h
1777--- gcc-4.8.2.orig/gcc/go/gofrontend/types.h 2013-09-18 16:54:08.000000000 -0500
1778+++ gcc-4.8.2/gcc/go/gofrontend/types.h 2013-10-17 15:08:21.970831000 -0500
1779@@ -1717,7 +1717,8 @@
1780 Typed_identifier_list* results, Location location)
1781 : Type(TYPE_FUNCTION),
1782 receiver_(receiver), parameters_(parameters), results_(results),
1783- location_(location), is_varargs_(false), is_builtin_(false)
1784+ location_(location), is_varargs_(false), is_builtin_(false),
1785+ fnbtype_(NULL)
1786 { }
1787
1788 // Get the receiver.
1789@@ -1798,6 +1799,11 @@
1790 static Type*
1791 make_function_type_descriptor_type();
1792
1793+ // Return the backend representation of this function type. This is used
1794+ // as the real type of a backend function declaration or defintion.
1795+ Btype*
1796+ get_backend_fntype(Gogo*);
1797+
1798 protected:
1799 int
1800 do_traverse(Traverse*);
1801@@ -1851,6 +1857,9 @@
1802 // Whether this is a special builtin function which can not simply
1803 // be called. This is used for len, cap, etc.
1804 bool is_builtin_;
1805+ // The backend representation of this type for backend function
1806+ // declarations and definitions.
1807+ Btype* fnbtype_;
1808 };
1809
1810 // The type of a pointer.
1811@@ -1915,7 +1924,7 @@
1812 {
1813 public:
1814 explicit Struct_field(const Typed_identifier& typed_identifier)
1815- : typed_identifier_(typed_identifier), tag_(NULL)
1816+ : typed_identifier_(typed_identifier), tag_(NULL), is_imported_(false)
1817 { }
1818
1819 // The field name.
1820@@ -1926,6 +1935,10 @@
1821 bool
1822 is_field_name(const std::string& name) const;
1823
1824+ // Return whether this struct field is an unexported field named NAME.
1825+ bool
1826+ is_unexported_field_name(Gogo*, const std::string& name) const;
1827+
1828 // Return whether this struct field is an embedded built-in type.
1829 bool
1830 is_embedded_builtin(Gogo*) const;
1831@@ -1963,6 +1976,11 @@
1832 set_tag(const std::string& tag)
1833 { this->tag_ = new std::string(tag); }
1834
1835+ // Record that this field is defined in an imported struct.
1836+ void
1837+ set_is_imported()
1838+ { this->is_imported_ = true; }
1839+
1840 // Set the type. This is only used in error cases.
1841 void
1842 set_type(Type* type)
1843@@ -1973,6 +1991,8 @@
1844 Typed_identifier typed_identifier_;
1845 // The field tag. This is NULL if the field has no tag.
1846 std::string* tag_;
1847+ // Whether this field is defined in an imported struct.
1848+ bool is_imported_;
1849 };
1850
1851 // A list of struct fields.
1852diff -Naur gcc-4.8.2.orig/gcc/go/go-gcc.cc gcc-4.8.2/gcc/go/go-gcc.cc
1853--- gcc-4.8.2.orig/gcc/go/go-gcc.cc 2013-10-04 13:07:35.000000000 -0500
1854+++ gcc-4.8.2/gcc/go/go-gcc.cc 2013-10-16 12:27:53.564070000 -0500
1855@@ -232,6 +232,9 @@
1856 Bexpression*
1857 convert_expression(Btype* type, Bexpression* expr, Location);
1858
1859+ Bexpression*
1860+ function_code_expression(Bfunction*, Location);
1861+
1862 // Statements.
1863
1864 Bstatement*
1865@@ -334,6 +337,17 @@
1866 Bexpression*
1867 label_address(Blabel*, Location);
1868
1869+ // Functions.
1870+
1871+ Bfunction*
1872+ error_function()
1873+ { return this->make_function(error_mark_node); }
1874+
1875+ Bfunction*
1876+ function(Btype* fntype, const std::string& name, const std::string& asm_name,
1877+ bool is_visible, bool is_declaration, bool is_inlinable,
1878+ bool disable_split_stack, bool in_unique_section, Location);
1879+
1880 private:
1881 // Make a Bexpression from a tree.
1882 Bexpression*
1883@@ -350,6 +364,10 @@
1884 make_type(tree t)
1885 { return new Btype(t); }
1886
1887+ Bfunction*
1888+ make_function(tree t)
1889+ { return new Bfunction(t); }
1890+
1891 Btype*
1892 fill_in_struct(Btype*, const std::vector<Btyped_identifier>&);
1893
1894@@ -966,6 +984,19 @@
1895 return tree_to_expr(ret);
1896 }
1897
1898+// Get the address of a function.
1899+
1900+Bexpression*
1901+Gcc_backend::function_code_expression(Bfunction* bfunc, Location location)
1902+{
1903+ tree func = bfunc->get_tree();
1904+ if (func == error_mark_node)
1905+ return this->error_expression();
1906+
1907+ tree ret = build_fold_addr_expr_loc(location.gcc_location(), func);
1908+ return this->make_expression(ret);
1909+}
1910+
1911 // An expression as a statement.
1912
1913 Bstatement*
1914@@ -1724,6 +1755,56 @@
1915 return this->make_expression(ret);
1916 }
1917
1918+// Declare or define a new function.
1919+
1920+Bfunction*
1921+Gcc_backend::function(Btype* fntype, const std::string& name,
1922+ const std::string& asm_name, bool is_visible,
1923+ bool is_declaration, bool is_inlinable,
1924+ bool disable_split_stack, bool in_unique_section,
1925+ Location location)
1926+{
1927+ tree functype = fntype->get_tree();
1928+ if (functype != error_mark_node)
1929+ {
1930+ gcc_assert(FUNCTION_POINTER_TYPE_P(functype));
1931+ functype = TREE_TYPE(functype);
1932+ }
1933+ tree id = get_identifier_from_string(name);
1934+ if (functype == error_mark_node || id == error_mark_node)
1935+ return this->error_function();
1936+
1937+ tree decl = build_decl(location.gcc_location(), FUNCTION_DECL, id, functype);
1938+ if (!asm_name.empty())
1939+ SET_DECL_ASSEMBLER_NAME(decl, get_identifier_from_string(asm_name));
1940+ if (is_visible)
1941+ TREE_PUBLIC(decl) = 1;
1942+ if (is_declaration)
1943+ DECL_EXTERNAL(decl) = 1;
1944+ else
1945+ {
1946+ tree restype = TREE_TYPE(functype);
1947+ tree resdecl =
1948+ build_decl(location.gcc_location(), RESULT_DECL, NULL_TREE, restype);
1949+ DECL_ARTIFICIAL(resdecl) = 1;
1950+ DECL_IGNORED_P(resdecl) = 1;
1951+ DECL_CONTEXT(resdecl) = decl;
1952+ DECL_RESULT(decl) = resdecl;
1953+ }
1954+ if (!is_inlinable)
1955+ DECL_UNINLINABLE(decl) = 1;
1956+ if (disable_split_stack)
1957+ {
1958+ tree attr = get_identifier("__no_split_stack__");
1959+ DECL_ATTRIBUTES(decl) = tree_cons(attr, NULL_TREE, NULL_TREE);
1960+ }
1961+ if (in_unique_section)
1962+ resolve_unique_section(decl, 0, 1);
1963+
1964+ go_preserve_from_gc(decl);
1965+ return new Bfunction(decl);
1966+}
1967+
1968 // The single backend.
1969
1970 static Gcc_backend gcc_backend;
1971@@ -1799,3 +1880,9 @@
1972 {
1973 return bv->get_tree();
1974 }
1975+
1976+tree
1977+function_to_tree(Bfunction* bf)
1978+{
1979+ return bf->get_tree();
1980+}
1981diff -Naur gcc-4.8.2.orig/gcc/testsuite/gcc.dg/pr58805.c gcc-4.8.2/gcc/testsuite/gcc.dg/pr58805.c
1982--- gcc-4.8.2.orig/gcc/testsuite/gcc.dg/pr58805.c 1969-12-31 18:00:00.000000000 -0600
1983+++ gcc-4.8.2/gcc/testsuite/gcc.dg/pr58805.c 2013-10-23 14:16:55.651450000 -0500
1984@@ -0,0 +1,24 @@
1985+/* { dg-do compile } */
1986+/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */
1987+
1988+/* Type that matches the 'p' constraint. */
1989+#define TYPE void *
1990+
1991+static inline
1992+void bar (TYPE *r)
1993+{
1994+ TYPE t;
1995+ __asm__ ("" : "=&p" (t), "=p" (*r));
1996+}
1997+
1998+void
1999+foo (int n, TYPE *x, TYPE *y)
2000+{
2001+ if (n == 0)
2002+ bar (x);
2003+ else
2004+ bar (y);
2005+}
2006+
2007+/* { dg-final { scan-tree-dump-times "__asm__" 2 "pre"} } */
2008+/* { dg-final { cleanup-tree-dump "pre" } } */
2009diff -Naur gcc-4.8.2.orig/gcc/testsuite/gcc.dg/torture/pr57488.c gcc-4.8.2/gcc/testsuite/gcc.dg/torture/pr57488.c
2010--- gcc-4.8.2.orig/gcc/testsuite/gcc.dg/torture/pr57488.c 1969-12-31 18:00:00.000000000 -0600
2011+++ gcc-4.8.2/gcc/testsuite/gcc.dg/torture/pr57488.c 2013-10-23 06:59:05.236596000 -0500
2012@@ -0,0 +1,58 @@
2013+/* { dg-do run } */
2014+
2015+extern void abort (void);
2016+
2017+int i, j, *pj = &j, **ppj = &pj;
2018+int x, *px = &x;
2019+
2020+short s, *ps = &s, k;
2021+
2022+unsigned short u, *pu = &u, **ppu = &pu;
2023+
2024+char c, *pc = &c;
2025+
2026+unsigned char v = 48;
2027+
2028+static int
2029+bar (int p)
2030+{
2031+ p = k;
2032+ *px = **ppu = i;
2033+ *ppj = &p;
2034+ if (**ppj)
2035+ *pj = p;
2036+ return p;
2037+}
2038+
2039+void __attribute__((noinline))
2040+foo ()
2041+{
2042+ for (; i <= 3; i++)
2043+ for (; j; j--);
2044+
2045+ u ^= bar (*pj);
2046+
2047+ for (k = 1; k >= 0; k--)
2048+ {
2049+ int l;
2050+ bar (0);
2051+ for (l = 1; l < 5; l++)
2052+ {
2053+ int m;
2054+ for (m = 6; m; m--)
2055+ {
2056+ v--;
2057+ *ps = *pc;
2058+ }
2059+ }
2060+ }
2061+}
2062+
2063+int
2064+main ()
2065+{
2066+ foo ();
2067+ if (v != 0)
2068+ abort ();
2069+ return 0;
2070+}
2071diff -Naur gcc-4.8.2.orig/gcc/testsuite/gcc.dg/torture/pr58830.c gcc-4.8.2/gcc/testsuite/gcc.dg/torture/pr58830.c
2072--- gcc-4.8.2.orig/gcc/testsuite/gcc.dg/torture/pr58830.c 1969-12-31 18:00:00.000000000 -0600
2073+++ gcc-4.8.2/gcc/testsuite/gcc.dg/torture/pr58830.c 2013-10-23 06:59:05.236596000 -0500
2074@@ -0,0 +1,42 @@
2075+/* { dg-do run } */
2076+/* { dg-additional-options "-ftree-pre -ftree-partial-pre" } */
2077+
2078+extern void abort (void);
2079+
2080+int b, c, d, f, g, h, i, j[6], *l = &b, *m, n, *o, r;
2081+char k;
2082+
2083+static int
2084+foo ()
2085+{
2086+ char *p = &k;
2087+
2088+ for (; d; d++)
2089+ if (i)
2090+ h = 0;
2091+ else
2092+ h = c || (r = 0);
2093+
2094+ for (f = 0; f < 2; f++)
2095+ {
2096+ unsigned int q;
2097+ *l = 0;
2098+ if (n)
2099+ *m = g;
2100+ if (g)
2101+ o = 0;
2102+ for (q = -8; q >= 5; q++)
2103+ (*p)--;
2104+ }
2105+
2106+ return 0;
2107+}
2108+
2109+int
2110+main ()
2111+{
2112+ foo ();
2113+ if (j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[j[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] ^ (k & 15)] != 0)
2114+ abort ();
2115+ return 0;
2116+}
2117diff -Naur gcc-4.8.2.orig/gcc/testsuite/gcc.target/sh/pr54089-3.c gcc-4.8.2/gcc/testsuite/gcc.target/sh/pr54089-3.c
2118--- gcc-4.8.2.orig/gcc/testsuite/gcc.target/sh/pr54089-3.c 2012-09-10 15:35:25.000000000 -0500
2119+++ gcc-4.8.2/gcc/testsuite/gcc.target/sh/pr54089-3.c 2013-10-19 08:27:49.531298000 -0500
2120@@ -5,7 +5,7 @@
2121 /* { dg-options "-O1" } */
2122 /* { dg-skip-if "" { "sh*-*-*" } { "*" } { "-m1*" "-m2" "-m2e*" } } */
2123 /* { dg-final { scan-assembler-not "and" } } */
2124-/* { dg-final { scan-assembler-not "31" } } */
2125+/* { dg-final { scan-assembler-not "#31" } } */
2126
2127 int
2128 test00 (unsigned int a, int* b, int c, int* d, unsigned int e)
2129diff -Naur gcc-4.8.2.orig/gcc/testsuite/g++.dg/cpp0x/decltype57.C gcc-4.8.2/gcc/testsuite/g++.dg/cpp0x/decltype57.C
2130--- gcc-4.8.2.orig/gcc/testsuite/g++.dg/cpp0x/decltype57.C 1969-12-31 18:00:00.000000000 -0600
2131+++ gcc-4.8.2/gcc/testsuite/g++.dg/cpp0x/decltype57.C 2013-10-16 17:19:18.772609000 -0500
2132@@ -0,0 +1,8 @@
2133+// PR c++/58633
2134+// { dg-do compile { target c++11 } }
2135+
2136+void foo(int i)
2137+{
2138+ typedef int I;
2139+ decltype(i.I::~I())* p;
2140+}
2141diff -Naur gcc-4.8.2.orig/gcc/testsuite/g++.dg/cpp0x/enum18.C gcc-4.8.2/gcc/testsuite/g++.dg/cpp0x/enum18.C
2142--- gcc-4.8.2.orig/gcc/testsuite/g++.dg/cpp0x/enum18.C 2011-05-28 17:01:28.000000000 -0500
2143+++ gcc-4.8.2/gcc/testsuite/g++.dg/cpp0x/enum18.C 2013-10-16 17:19:18.772609000 -0500
2144@@ -4,5 +4,5 @@
2145 int main(void) {
2146 enum e {};
2147 e ev;
2148- ev.e::~e_u(); // { dg-error "e_u. has not been declared" }
2149+ ev.e::~e_u(); // { dg-error "" }
2150 }
2151diff -Naur gcc-4.8.2.orig/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C gcc-4.8.2/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C
2152--- gcc-4.8.2.orig/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C 1969-12-31 18:00:00.000000000 -0600
2153+++ gcc-4.8.2/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C 2013-10-17 12:15:46.188630000 -0500
2154@@ -0,0 +1,7 @@
2155+// PR c++/58596
2156+// { dg-do compile { target c++11 } }
2157+
2158+struct A
2159+{
2160+ int i = [] { return decltype(i)(); }();
2161+};
2162diff -Naur gcc-4.8.2.orig/gcc/tree-ssa-pre.c gcc-4.8.2/gcc/tree-ssa-pre.c
2163--- gcc-4.8.2.orig/gcc/tree-ssa-pre.c 2013-02-19 00:43:34.000000000 -0600
2164+++ gcc-4.8.2/gcc/tree-ssa-pre.c 2013-10-23 06:59:05.236596000 -0500
2165@@ -3664,6 +3664,12 @@
2166 if (dump_file && dump_flags & TDF_DETAILS)
2167 fprintf (dump_file, "Starting insert iteration %d\n", num_iterations);
2168 new_stuff = insert_aux (ENTRY_BLOCK_PTR);
2169+
2170+ /* Clear the NEW sets before the next iteration. We have already
2171+ fully propagated its contents. */
2172+ if (new_stuff)
2173+ FOR_ALL_BB (bb)
2174+ bitmap_set_free (NEW_SETS (bb));
2175 }
2176 statistics_histogram_event (cfun, "insert iterations", num_iterations);
2177 }
2178diff -Naur gcc-4.8.2.orig/gcc/tree-ssa-tail-merge.c gcc-4.8.2/gcc/tree-ssa-tail-merge.c
2179--- gcc-4.8.2.orig/gcc/tree-ssa-tail-merge.c 2013-01-31 02:52:56.000000000 -0600
2180+++ gcc-4.8.2/gcc/tree-ssa-tail-merge.c 2013-10-23 14:16:55.651450000 -0500
2181@@ -297,7 +297,8 @@
2182 tree val;
2183 def_operand_p def_p;
2184
2185- if (gimple_has_side_effects (stmt))
2186+ if (gimple_has_side_effects (stmt)
2187+ || gimple_vdef (stmt) != NULL_TREE)
2188 return false;
2189
2190 def_p = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_DEF);
2191diff -Naur gcc-4.8.2.orig/gcc/version.c gcc-4.8.2/gcc/version.c
2192--- gcc-4.8.2.orig/gcc/version.c 2013-01-10 14:38:27.000000000 -0600
2193+++ gcc-4.8.2/gcc/version.c 2013-10-24 10:18:17.893329498 -0500
2194@@ -32,4 +32,4 @@
2195 Makefile. */
2196
2197 const char version_string[] = BASEVER DATESTAMP DEVPHASE REVISION;
2198-const char pkgversion_string[] = PKGVERSION;
2199+const char pkgversion_string[] = "(GCC for Cross-LFS 4.8.2.20131024) ";
2200diff -Naur gcc-4.8.2.orig/libffi/doc/libffi.info gcc-4.8.2/libffi/doc/libffi.info
2201--- gcc-4.8.2.orig/libffi/doc/libffi.info 2013-10-16 03:21:34.000000000 -0500
2202+++ gcc-4.8.2/libffi/doc/libffi.info 1969-12-31 18:00:00.000000000 -0600
2203@@ -1,614 +0,0 @@
2204-This is libffi.info, produced by makeinfo version 5.1 from libffi.texi.
2205-
2206-This manual is for Libffi, a portable foreign-function interface
2207-library.
2208-
2209- Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
2210-
2211- Permission is granted to copy, distribute and/or modify this
2212- document under the terms of the GNU General Public License as
2213- published by the Free Software Foundation; either version 2, or (at
2214- your option) any later version. A copy of the license is included
2215- in the section entitled "GNU General Public License".
2216-
2217-INFO-DIR-SECTION Development
2218-START-INFO-DIR-ENTRY
2219-* libffi: (libffi). Portable foreign-function interface library.
2220-END-INFO-DIR-ENTRY
2221-
2222-
2223-File: libffi.info, Node: Top, Next: Introduction, Up: (dir)
2224-
2225-libffi
2226-******
2227-
2228-This manual is for Libffi, a portable foreign-function interface
2229-library.
2230-
2231- Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
2232-
2233- Permission is granted to copy, distribute and/or modify this
2234- document under the terms of the GNU General Public License as
2235- published by the Free Software Foundation; either version 2, or (at
2236- your option) any later version. A copy of the license is included
2237- in the section entitled "GNU General Public License".
2238-
2239-* Menu:
2240-
2241-* Introduction:: What is libffi?
2242-* Using libffi:: How to use libffi.
2243-* Missing Features:: Things libffi can't do.
2244-* Index:: Index.
2245-
2246-
2247-File: libffi.info, Node: Introduction, Next: Using libffi, Prev: Top, Up: Top
2248-
2249-1 What is libffi?
2250-*****************
2251-
2252-Compilers for high level languages generate code that follow certain
2253-conventions. These conventions are necessary, in part, for separate
2254-compilation to work. One such convention is the "calling convention".
2255-The calling convention is a set of assumptions made by the compiler
2256-about where function arguments will be found on entry to a function. A
2257-calling convention also specifies where the return value for a function
2258-is found. The calling convention is also sometimes called the "ABI" or
2259-"Application Binary Interface".
2260-
2261- Some programs may not know at the time of compilation what arguments
2262-are to be passed to a function. For instance, an interpreter may be
2263-told at run-time about the number and types of arguments used to call a
2264-given function. 'Libffi' can be used in such programs to provide a
2265-bridge from the interpreter program to compiled code.
2266-
2267- The 'libffi' library provides a portable, high level programming
2268-interface to various calling conventions. This allows a programmer to
2269-call any function specified by a call interface description at run time.
2270-
2271- FFI stands for Foreign Function Interface. A foreign function
2272-interface is the popular name for the interface that allows code written
2273-in one language to call code written in another language. The 'libffi'
2274-library really only provides the lowest, machine dependent layer of a
2275-fully featured foreign function interface. A layer must exist above
2276-'libffi' that handles type conversions for values passed between the two
2277-languages.
2278-
2279-
2280-File: libffi.info, Node: Using libffi, Next: Missing Features, Prev: Introduction, Up: Top
2281-
2282-2 Using libffi
2283-**************
2284-
2285-* Menu:
2286-
2287-* The Basics:: The basic libffi API.
2288-* Simple Example:: A simple example.
2289-* Types:: libffi type descriptions.
2290-* Multiple ABIs:: Different passing styles on one platform.
2291-* The Closure API:: Writing a generic function.
2292-* Closure Example:: A closure example.
2293-
2294-
2295-File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
2296-
2297-2.1 The Basics
2298-==============
2299-
2300-'Libffi' assumes that you have a pointer to the function you wish to
2301-call and that you know the number and types of arguments to pass it, as
2302-well as the return type of the function.
2303-
2304- The first thing you must do is create an 'ffi_cif' object that
2305-matches the signature of the function you wish to call. This is a
2306-separate step because it is common to make multiple calls using a single
2307-'ffi_cif'. The "cif" in 'ffi_cif' stands for Call InterFace. To
2308-prepare a call interface object, use the function 'ffi_prep_cif'.
2309-
2310- -- Function: ffi_status ffi_prep_cif (ffi_cif *CIF, ffi_abi ABI,
2311- unsigned int NARGS, ffi_type *RTYPE, ffi_type **ARGTYPES)
2312- This initializes CIF according to the given parameters.
2313-
2314- ABI is the ABI to use; normally 'FFI_DEFAULT_ABI' is what you want.
2315- *note Multiple ABIs:: for more information.
2316-
2317- NARGS is the number of arguments that this function accepts.
2318-
2319- RTYPE is a pointer to an 'ffi_type' structure that describes the
2320- return type of the function. *Note Types::.
2321-
2322- ARGTYPES is a vector of 'ffi_type' pointers. ARGTYPES must have
2323- NARGS elements. If NARGS is 0, this argument is ignored.
2324-
2325- 'ffi_prep_cif' returns a 'libffi' status code, of type
2326- 'ffi_status'. This will be either 'FFI_OK' if everything worked
2327- properly; 'FFI_BAD_TYPEDEF' if one of the 'ffi_type' objects is
2328- incorrect; or 'FFI_BAD_ABI' if the ABI parameter is invalid.
2329-
2330- If the function being called is variadic (varargs) then
2331-'ffi_prep_cif_var' must be used instead of 'ffi_prep_cif'.
2332-
2333- -- Function: ffi_status ffi_prep_cif_var (ffi_cif *CIF, ffi_abi varabi,
2334- unsigned int NFIXEDARGS, unsigned int varntotalargs, ffi_type
2335- *RTYPE, ffi_type **ARGTYPES)
2336- This initializes CIF according to the given parameters for a call
2337- to a variadic function. In general it's operation is the same as
2338- for 'ffi_prep_cif' except that:
2339-
2340- NFIXEDARGS is the number of fixed arguments, prior to any variadic
2341- arguments. It must be greater than zero.
2342-
2343- NTOTALARGS the total number of arguments, including variadic and
2344- fixed arguments.
2345-
2346- Note that, different cif's must be prepped for calls to the same
2347- function when different numbers of arguments are passed.
2348-
2349- Also note that a call to 'ffi_prep_cif_var' with
2350- NFIXEDARGS=NOTOTALARGS is NOT equivalent to a call to
2351- 'ffi_prep_cif'.
2352-
2353- To call a function using an initialized 'ffi_cif', use the 'ffi_call'
2354-function:
2355-
2356- -- Function: void ffi_call (ffi_cif *CIF, void *FN, void *RVALUE, void
2357- **AVALUES)
2358- This calls the function FN according to the description given in
2359- CIF. CIF must have already been prepared using 'ffi_prep_cif'.
2360-
2361- RVALUE is a pointer to a chunk of memory that will hold the result
2362- of the function call. This must be large enough to hold the result
2363- and must be suitably aligned; it is the caller's responsibility to
2364- ensure this. If CIF declares that the function returns 'void'
2365- (using 'ffi_type_void'), then RVALUE is ignored. If RVALUE is
2366- 'NULL', then the return value is discarded.
2367-
2368- AVALUES is a vector of 'void *' pointers that point to the memory
2369- locations holding the argument values for a call. If CIF declares
2370- that the function has no arguments (i.e., NARGS was 0), then
2371- AVALUES is ignored. Note that argument values may be modified by
2372- the callee (for instance, structs passed by value); the burden of
2373- copying pass-by-value arguments is placed on the caller.
2374-
2375-
2376-File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up: Using libffi
2377-
2378-2.2 Simple Example
2379-==================
2380-
2381-Here is a trivial example that calls 'puts' a few times.
2382-
2383- #include <stdio.h>
2384- #include <ffi.h>
2385-
2386- int main()
2387- {
2388- ffi_cif cif;
2389- ffi_type *args[1];
2390- void *values[1];
2391- char *s;
2392- int rc;
2393-
2394- /* Initialize the argument info vectors */
2395- args[0] = &ffi_type_pointer;
2396- values[0] = &s;
2397-
2398- /* Initialize the cif */
2399- if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
2400- &ffi_type_uint, args) == FFI_OK)
2401- {
2402- s = "Hello World!";
2403- ffi_call(&cif, puts, &rc, values);
2404- /* rc now holds the result of the call to puts */
2405-
2406- /* values holds a pointer to the function's arg, so to
2407- call puts() again all we need to do is change the
2408- value of s */
2409- s = "This is cool!";
2410- ffi_call(&cif, puts, &rc, values);
2411- }
2412-
2413- return 0;
2414- }
2415-
2416-
2417-File: libffi.info, Node: Types, Next: Multiple ABIs, Prev: Simple Example, Up: Using libffi
2418-
2419-2.3 Types
2420-=========
2421-
2422-* Menu:
2423-
2424-* Primitive Types:: Built-in types.
2425-* Structures:: Structure types.
2426-* Type Example:: Structure type example.
2427-
2428-
2429-File: libffi.info, Node: Primitive Types, Next: Structures, Up: Types
2430-
2431-2.3.1 Primitive Types
2432----------------------
2433-
2434-'Libffi' provides a number of built-in type descriptors that can be used
2435-to describe argument and return types:
2436-
2437-'ffi_type_void'
2438- The type 'void'. This cannot be used for argument types, only for
2439- return values.
2440-
2441-'ffi_type_uint8'
2442- An unsigned, 8-bit integer type.
2443-
2444-'ffi_type_sint8'
2445- A signed, 8-bit integer type.
2446-
2447-'ffi_type_uint16'
2448- An unsigned, 16-bit integer type.
2449-
2450-'ffi_type_sint16'
2451- A signed, 16-bit integer type.
2452-
2453-'ffi_type_uint32'
2454- An unsigned, 32-bit integer type.
2455-
2456-'ffi_type_sint32'
2457- A signed, 32-bit integer type.
2458-
2459-'ffi_type_uint64'
2460- An unsigned, 64-bit integer type.
2461-
2462-'ffi_type_sint64'
2463- A signed, 64-bit integer type.
2464-
2465-'ffi_type_float'
2466- The C 'float' type.
2467-
2468-'ffi_type_double'
2469- The C 'double' type.
2470-
2471-'ffi_type_uchar'
2472- The C 'unsigned char' type.
2473-
2474-'ffi_type_schar'
2475- The C 'signed char' type. (Note that there is not an exact
2476- equivalent to the C 'char' type in 'libffi'; ordinarily you should
2477- either use 'ffi_type_schar' or 'ffi_type_uchar' depending on
2478- whether 'char' is signed.)
2479-
2480-'ffi_type_ushort'
2481- The C 'unsigned short' type.
2482-
2483-'ffi_type_sshort'
2484- The C 'short' type.
2485-
2486-'ffi_type_uint'
2487- The C 'unsigned int' type.
2488-
2489-'ffi_type_sint'
2490- The C 'int' type.
2491-
2492-'ffi_type_ulong'
2493- The C 'unsigned long' type.
2494-
2495-'ffi_type_slong'
2496- The C 'long' type.
2497-
2498-'ffi_type_longdouble'
2499- On platforms that have a C 'long double' type, this is defined. On
2500- other platforms, it is not.
2501-
2502-'ffi_type_pointer'
2503- A generic 'void *' pointer. You should use this for all pointers,
2504- regardless of their real type.
2505-
2506- Each of these is of type 'ffi_type', so you must take the address
2507-when passing to 'ffi_prep_cif'.
2508-
2509-
2510-File: libffi.info, Node: Structures, Next: Type Example, Prev: Primitive Types, Up: Types
2511-
2512-2.3.2 Structures
2513-----------------
2514-
2515-Although 'libffi' has no special support for unions or bit-fields, it is
2516-perfectly happy passing structures back and forth. You must first
2517-describe the structure to 'libffi' by creating a new 'ffi_type' object
2518-for it.
2519-
2520- -- ffi_type:
2521- The 'ffi_type' has the following members:
2522- 'size_t size'
2523- This is set by 'libffi'; you should initialize it to zero.
2524-
2525- 'unsigned short alignment'
2526- This is set by 'libffi'; you should initialize it to zero.
2527-
2528- 'unsigned short type'
2529- For a structure, this should be set to 'FFI_TYPE_STRUCT'.
2530-
2531- 'ffi_type **elements'
2532- This is a 'NULL'-terminated array of pointers to 'ffi_type'
2533- objects. There is one element per field of the struct.
2534-
2535-
2536-File: libffi.info, Node: Type Example, Prev: Structures, Up: Types
2537-
2538-2.3.3 Type Example
2539-------------------
2540-
2541-The following example initializes a 'ffi_type' object representing the
2542-'tm' struct from Linux's 'time.h'.
2543-
2544- Here is how the struct is defined:
2545-
2546- struct tm {
2547- int tm_sec;
2548- int tm_min;
2549- int tm_hour;
2550- int tm_mday;
2551- int tm_mon;
2552- int tm_year;
2553- int tm_wday;
2554- int tm_yday;
2555- int tm_isdst;
2556- /* Those are for future use. */
2557- long int __tm_gmtoff__;
2558- __const char *__tm_zone__;
2559- };
2560-
2561- Here is the corresponding code to describe this struct to 'libffi':
2562-
2563- {
2564- ffi_type tm_type;
2565- ffi_type *tm_type_elements[12];
2566- int i;
2567-
2568- tm_type.size = tm_type.alignment = 0;
2569- tm_type.elements = &tm_type_elements;
2570-
2571- for (i = 0; i < 9; i++)
2572- tm_type_elements[i] = &ffi_type_sint;
2573-
2574- tm_type_elements[9] = &ffi_type_slong;
2575- tm_type_elements[10] = &ffi_type_pointer;
2576- tm_type_elements[11] = NULL;
2577-
2578- /* tm_type can now be used to represent tm argument types and
2579- return types for ffi_prep_cif() */
2580- }
2581-
2582-
2583-File: libffi.info, Node: Multiple ABIs, Next: The Closure API, Prev: Types, Up: Using libffi
2584-
2585-2.4 Multiple ABIs
2586-=================
2587-
2588-A given platform may provide multiple different ABIs at once. For
2589-instance, the x86 platform has both 'stdcall' and 'fastcall' functions.
2590-
2591- 'libffi' provides some support for this. However, this is
2592-necessarily platform-specific.
2593-
2594-
2595-File: libffi.info, Node: The Closure API, Next: Closure Example, Prev: Multiple ABIs, Up: Using libffi
2596-
2597-2.5 The Closure API
2598-===================
2599-
2600-'libffi' also provides a way to write a generic function - a function
2601-that can accept and decode any combination of arguments. This can be
2602-useful when writing an interpreter, or to provide wrappers for arbitrary
2603-functions.
2604-
2605- This facility is called the "closure API". Closures are not supported
2606-on all platforms; you can check the 'FFI_CLOSURES' define to determine
2607-whether they are supported on the current platform.
2608-
2609- Because closures work by assembling a tiny function at runtime, they
2610-require special allocation on platforms that have a non-executable heap.
2611-Memory management for closures is handled by a pair of functions:
2612-
2613- -- Function: void *ffi_closure_alloc (size_t SIZE, void **CODE)
2614- Allocate a chunk of memory holding SIZE bytes. This returns a
2615- pointer to the writable address, and sets *CODE to the
2616- corresponding executable address.
2617-
2618- SIZE should be sufficient to hold a 'ffi_closure' object.
2619-
2620- -- Function: void ffi_closure_free (void *WRITABLE)
2621- Free memory allocated using 'ffi_closure_alloc'. The argument is
2622- the writable address that was returned.
2623-
2624- Once you have allocated the memory for a closure, you must construct
2625-a 'ffi_cif' describing the function call. Finally you can prepare the
2626-closure function:
2627-
2628- -- Function: ffi_status ffi_prep_closure_loc (ffi_closure *CLOSURE,
2629- ffi_cif *CIF, void (*FUN) (ffi_cif *CIF, void *RET, void
2630- **ARGS, void *USER_DATA), void *USER_DATA, void *CODELOC)
2631- Prepare a closure function.
2632-
2633- CLOSURE is the address of a 'ffi_closure' object; this is the
2634- writable address returned by 'ffi_closure_alloc'.
2635-
2636- CIF is the 'ffi_cif' describing the function parameters.
2637-
2638- USER_DATA is an arbitrary datum that is passed, uninterpreted, to
2639- your closure function.
2640-
2641- CODELOC is the executable address returned by 'ffi_closure_alloc'.
2642-
2643- FUN is the function which will be called when the closure is
2644- invoked. It is called with the arguments:
2645- CIF
2646- The 'ffi_cif' passed to 'ffi_prep_closure_loc'.
2647-
2648- RET
2649- A pointer to the memory used for the function's return value.
2650- FUN must fill this, unless the function is declared as
2651- returning 'void'.
2652-
2653- ARGS
2654- A vector of pointers to memory holding the arguments to the
2655- function.
2656-
2657- USER_DATA
2658- The same USER_DATA that was passed to 'ffi_prep_closure_loc'.
2659-
2660- 'ffi_prep_closure_loc' will return 'FFI_OK' if everything went ok,
2661- and something else on error.
2662-
2663- After calling 'ffi_prep_closure_loc', you can cast CODELOC to the
2664- appropriate pointer-to-function type.
2665-
2666- You may see old code referring to 'ffi_prep_closure'. This function
2667-is deprecated, as it cannot handle the need for separate writable and
2668-executable addresses.
2669-
2670-
2671-File: libffi.info, Node: Closure Example, Prev: The Closure API, Up: Using libffi
2672-
2673-2.6 Closure Example
2674-===================
2675-
2676-A trivial example that creates a new 'puts' by binding 'fputs' with
2677-'stdin'.
2678-
2679- #include <stdio.h>
2680- #include <ffi.h>
2681-
2682- /* Acts like puts with the file given at time of enclosure. */
2683- void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[],
2684- FILE *stream)
2685- {
2686- *ret = fputs(*(char **)args[0], stream);
2687- }
2688-
2689- int main()
2690- {
2691- ffi_cif cif;
2692- ffi_type *args[1];
2693- ffi_closure *closure;
2694-
2695- int (*bound_puts)(char *);
2696- int rc;
2697-
2698- /* Allocate closure and bound_puts */
2699- closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
2700-
2701- if (closure)
2702- {
2703- /* Initialize the argument info vectors */
2704- args[0] = &ffi_type_pointer;
2705-
2706- /* Initialize the cif */
2707- if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
2708- &ffi_type_uint, args) == FFI_OK)
2709- {
2710- /* Initialize the closure, setting stream to stdout */
2711- if (ffi_prep_closure_loc(closure, &cif, puts_binding,
2712- stdout, bound_puts) == FFI_OK)
2713- {
2714- rc = bound_puts("Hello World!");
2715- /* rc now holds the result of the call to fputs */
2716- }
2717- }
2718- }
2719-
2720- /* Deallocate both closure, and bound_puts */
2721- ffi_closure_free(closure);
2722-
2723- return 0;
2724- }
2725-
2726-
2727-File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
2728-
2729-3 Missing Features
2730-******************
2731-
2732-'libffi' is missing a few features. We welcome patches to add support
2733-for these.
2734-
2735- * Variadic closures.
2736-
2737- * There is no support for bit fields in structures.
2738-
2739- * The closure API is
2740-
2741- * The "raw" API is undocumented.
2742-
2743- Note that variadic support is very new and tested on a relatively
2744-small number of platforms.
2745-
2746-
2747-File: libffi.info, Node: Index, Prev: Missing Features, Up: Top
2748-
2749-Index
2750-*****
2751-
2752-[index]
2753-* Menu:
2754-
2755-* ABI: Introduction. (line 13)
2756-* Application Binary Interface: Introduction. (line 13)
2757-* calling convention: Introduction. (line 13)
2758-* cif: The Basics. (line 14)
2759-* closure API: The Closure API. (line 13)
2760-* closures: The Closure API. (line 13)
2761-* FFI: Introduction. (line 31)
2762-* ffi_call: The Basics. (line 62)
2763-* FFI_CLOSURES: The Closure API. (line 13)
2764-* ffi_closure_alloc: The Closure API. (line 19)
2765-* ffi_closure_free: The Closure API. (line 26)
2766-* ffi_prep_cif: The Basics. (line 16)
2767-* ffi_prep_cif_var: The Basics. (line 39)
2768-* ffi_prep_closure_loc: The Closure API. (line 34)
2769-* ffi_status: The Basics. (line 16)
2770-* ffi_status <1>: The Basics. (line 39)
2771-* ffi_status <2>: The Closure API. (line 34)
2772-* ffi_type: Structures. (line 11)
2773-* ffi_type_double: Primitive Types. (line 41)
2774-* ffi_type_float: Primitive Types. (line 38)
2775-* ffi_type_longdouble: Primitive Types. (line 71)
2776-* ffi_type_pointer: Primitive Types. (line 75)
2777-* ffi_type_schar: Primitive Types. (line 47)
2778-* ffi_type_sint: Primitive Types. (line 62)
2779-* ffi_type_sint16: Primitive Types. (line 23)
2780-* ffi_type_sint32: Primitive Types. (line 29)
2781-* ffi_type_sint64: Primitive Types. (line 35)
2782-* ffi_type_sint8: Primitive Types. (line 17)
2783-* ffi_type_slong: Primitive Types. (line 68)
2784-* ffi_type_sshort: Primitive Types. (line 56)
2785-* ffi_type_uchar: Primitive Types. (line 44)
2786-* ffi_type_uint: Primitive Types. (line 59)
2787-* ffi_type_uint16: Primitive Types. (line 20)
2788-* ffi_type_uint32: Primitive Types. (line 26)
2789-* ffi_type_uint64: Primitive Types. (line 32)
2790-* ffi_type_uint8: Primitive Types. (line 14)
2791-* ffi_type_ulong: Primitive Types. (line 65)
2792-* ffi_type_ushort: Primitive Types. (line 53)
2793-* ffi_type_void: Primitive Types. (line 10)
2794-* Foreign Function Interface: Introduction. (line 31)
2795-* void: The Basics. (line 62)
2796-* void <1>: The Closure API. (line 19)
2797-* void <2>: The Closure API. (line 26)
2798-
2799-
2800-
2801-Tag Table:
2802-Node: Top682
2803-Node: Introduction1429
2804-Node: Using libffi3061
2805-Node: The Basics3547
2806-Node: Simple Example7187
2807-Node: Types8214
2808-Node: Primitive Types8497
2809-Node: Structures10318
2810-Node: Type Example11182
2811-Node: Multiple ABIs12405
2812-Node: The Closure API12776
2813-Node: Closure Example15720
2814-Node: Missing Features17279
2815-Node: Index17732
2816-
2817-End Tag Table
2818diff -Naur gcc-4.8.2.orig/libgo/config.h.in gcc-4.8.2/libgo/config.h.in
2819--- gcc-4.8.2.orig/libgo/config.h.in 2013-10-02 12:32:00.000000000 -0500
2820+++ gcc-4.8.2/libgo/config.h.in 2013-10-17 13:41:40.134537000 -0500
2821@@ -39,6 +39,9 @@
2822 /* Define to 1 if you have the `dl_iterate_phdr' function. */
2823 #undef HAVE_DL_ITERATE_PHDR
2824
2825+/* Define to 1 if you have the `dup3' function. */
2826+#undef HAVE_DUP3
2827+
2828 /* Define to 1 if you have the `epoll_create1' function. */
2829 #undef HAVE_EPOLL_CREATE1
2830
2831@@ -66,6 +69,9 @@
2832 /* Define if _Unwind_GetIPInfo is available. */
2833 #undef HAVE_GETIPINFO
2834
2835+/* Define to 1 if you have the `getxattr' function. */
2836+#undef HAVE_GETXATTR
2837+
2838 /* Define to 1 if you have the `inotify_add_watch' function. */
2839 #undef HAVE_INOTIFY_ADD_WATCH
2840
2841@@ -111,6 +117,9 @@
2842 /* Define to 1 if you have the <linux/rtnetlink.h> header file. */
2843 #undef HAVE_LINUX_RTNETLINK_H
2844
2845+/* Define to 1 if you have the `listxattr' function. */
2846+#undef HAVE_LISTXATTR
2847+
2848 /* Define to 1 if the system has the type `loff_t'. */
2849 #undef HAVE_LOFF_T
2850
2851@@ -171,6 +180,9 @@
2852 /* Define to 1 if you have the `pipe2' function. */
2853 #undef HAVE_PIPE2
2854
2855+/* Define to 1 if you have the `removexattr' function. */
2856+#undef HAVE_REMOVEXATTR
2857+
2858 /* Define to 1 if you have the `renameat' function. */
2859 #undef HAVE_RENAMEAT
2860
2861@@ -180,6 +192,9 @@
2862 /* Define to 1 if you have the `setenv' function. */
2863 #undef HAVE_SETENV
2864
2865+/* Define to 1 if you have the `setxattr' function. */
2866+#undef HAVE_SETXATTR
2867+
2868 /* Define to 1 if you have the `sinl' function. */
2869 #undef HAVE_SINL
2870
2871diff -Naur gcc-4.8.2.orig/libgo/configure gcc-4.8.2/libgo/configure
2872--- gcc-4.8.2.orig/libgo/configure 2013-10-02 12:32:00.000000000 -0500
2873+++ gcc-4.8.2/libgo/configure 2013-10-17 13:41:40.134537000 -0500
2874@@ -14700,7 +14700,7 @@
2875 fi
2876
2877
2878-for ac_func in accept4 epoll_create1 faccessat fallocate fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_init1 inotify_rm_watch mkdirat mknodat openat pipe2 renameat sync_file_range splice tee unlinkat unshare utimensat
2879+for ac_func in accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat openat pipe2 removexattr renameat setxattr sync_file_range splice tee unlinkat unshare utimensat
2880 do :
2881 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
2882 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
2883diff -Naur gcc-4.8.2.orig/libgo/configure.ac gcc-4.8.2/libgo/configure.ac
2884--- gcc-4.8.2.orig/libgo/configure.ac 2013-10-02 12:32:00.000000000 -0500
2885+++ gcc-4.8.2/libgo/configure.ac 2013-10-17 13:41:40.134537000 -0500
2886@@ -503,7 +503,7 @@
2887 AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
2888 AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
2889
2890-AC_CHECK_FUNCS(accept4 epoll_create1 faccessat fallocate fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_init1 inotify_rm_watch mkdirat mknodat openat pipe2 renameat sync_file_range splice tee unlinkat unshare utimensat)
2891+AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat openat pipe2 removexattr renameat setxattr sync_file_range splice tee unlinkat unshare utimensat)
2892 AC_TYPE_OFF_T
2893 AC_CHECK_TYPES([loff_t])
2894
2895diff -Naur gcc-4.8.2.orig/libgo/go/syscall/libcall_linux.go gcc-4.8.2/libgo/go/syscall/libcall_linux.go
2896--- gcc-4.8.2.orig/libgo/go/syscall/libcall_linux.go 2013-02-08 13:24:26.000000000 -0600
2897+++ gcc-4.8.2/libgo/go/syscall/libcall_linux.go 2013-10-17 13:41:40.134537000 -0500
2898@@ -190,6 +190,9 @@
2899 //sys Adjtimex(buf *Timex) (state int, err error)
2900 //adjtimex(buf *Timex) _C_int
2901
2902+//sysnb Dup3(oldfd int, newfd int, flags int) (err error)
2903+//dup3(oldfd _C_int, newfd _C_int, flags _C_int) _C_int
2904+
2905 //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
2906 //faccessat(dirfd _C_int, pathname *byte, mode _C_int, flags _C_int) _C_int
2907
2908@@ -268,6 +271,9 @@
2909 return origlen - len(buf), count, names
2910 }
2911
2912+//sys Getxattr(path string, attr string, dest []byte) (sz int, err error)
2913+//getxattr(path *byte, attr *byte, buf *byte, count Size_t) Ssize_t
2914+
2915 //sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error)
2916 //inotify_add_watch(fd _C_int, pathname *byte, mask uint32) _C_int
2917
2918@@ -283,6 +289,9 @@
2919 //sys Klogctl(typ int, buf []byte) (n int, err error)
2920 //klogctl(typ _C_int, bufp *byte, len _C_int) _C_int
2921
2922+//sys Listxattr(path string, dest []byte) (sz int, err error)
2923+//listxattr(path *byte, list *byte, size Size_t) Ssize_t
2924+
2925 //sys Mkdirat(dirfd int, path string, mode uint32) (err error)
2926 //mkdirat(dirfd _C_int, path *byte, mode Mode_t) _C_int
2927
2928@@ -305,6 +314,9 @@
2929 //sys PivotRoot(newroot string, putold string) (err error)
2930 //pivot_root(newroot *byte, putold *byte) _C_int
2931
2932+//sys Removexattr(path string, attr string) (err error)
2933+//removexattr(path *byte, name *byte) _C_int
2934+
2935 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
2936 //renameat(olddirfd _C_int, oldpath *byte, newdirfd _C_int, newpath *byte) _C_int
2937
2938@@ -338,6 +350,9 @@
2939 //sysnb Setresuid(ruid int, eguid int, suid int) (err error)
2940 //setresuid(ruid Uid_t, euid Uid_t, suid Uid_t) _C_int
2941
2942+//sys Setxattr(path string, attr string, data []byte, flags int) (err error)
2943+//setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
2944+
2945 //sys splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
2946 //splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
2947 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
2948diff -Naur gcc-4.8.2.orig/libgo/go/syscall/libcall_posix.go gcc-4.8.2/libgo/go/syscall/libcall_posix.go
2949--- gcc-4.8.2.orig/libgo/go/syscall/libcall_posix.go 2013-02-08 13:24:26.000000000 -0600
2950+++ gcc-4.8.2/libgo/go/syscall/libcall_posix.go 2013-10-17 13:41:40.134537000 -0500
2951@@ -238,6 +238,9 @@
2952 //sysnb Getppid() (ppid int)
2953 //getppid() Pid_t
2954
2955+//sys Getpriority(which int, who int) (prio int, err error)
2956+//getpriority(which _C_int, who _C_int) _C_int
2957+
2958 //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
2959 //getrlimit(resource _C_int, rlim *Rlimit) _C_int
2960
2961@@ -307,6 +310,9 @@
2962 //sysnb Setpgid(pid int, pgid int) (err error)
2963 //setpgid(pid Pid_t, pgid Pid_t) _C_int
2964
2965+//sys Setpriority(which int, who int, prio int) (err error)
2966+//setpriority(which _C_int, who _C_int, prio _C_int) _C_int
2967+
2968 //sysnb Setreuid(ruid int, euid int) (err error)
2969 //setreuid(ruid Uid_t, euid Uid_t) _C_int
2970
2971diff -Naur gcc-4.8.2.orig/libgo/Makefile.am gcc-4.8.2/libgo/Makefile.am
2972--- gcc-4.8.2.orig/libgo/Makefile.am 2013-09-27 16:34:43.000000000 -0500
2973+++ gcc-4.8.2/libgo/Makefile.am 2013-10-16 12:27:53.564070000 -0500
2974@@ -424,6 +424,7 @@
2975 runtime/go-caller.c \
2976 runtime/go-callers.c \
2977 runtime/go-can-convert-interface.c \
2978+ runtime/go-cdiv.c \
2979 runtime/go-cgo.c \
2980 runtime/go-check-interface.c \
2981 runtime/go-construct-map.c \
2982diff -Naur gcc-4.8.2.orig/libgo/Makefile.in gcc-4.8.2/libgo/Makefile.in
2983--- gcc-4.8.2.orig/libgo/Makefile.in 2013-09-27 16:34:43.000000000 -0500
2984+++ gcc-4.8.2/libgo/Makefile.in 2013-10-16 12:27:53.564070000 -0500
2985@@ -195,7 +195,7 @@
2986 @LIBGO_IS_LINUX_TRUE@am__objects_5 = getncpu-linux.lo
2987 am__objects_6 = go-append.lo go-assert.lo go-assert-interface.lo \
2988 go-byte-array-to-string.lo go-breakpoint.lo go-caller.lo \
2989- go-callers.lo go-can-convert-interface.lo go-cgo.lo \
2990+ go-callers.lo go-can-convert-interface.lo go-cdiv.lo go-cgo.lo \
2991 go-check-interface.lo go-construct-map.lo \
2992 go-convert-interface.lo go-copy.lo go-defer.lo \
2993 go-deferred-recover.lo go-eface-compare.lo \
2994@@ -757,6 +757,7 @@
2995 runtime/go-caller.c \
2996 runtime/go-callers.c \
2997 runtime/go-can-convert-interface.c \
2998+ runtime/go-cdiv.c \
2999 runtime/go-cgo.c \
3000 runtime/go-check-interface.c \
3001 runtime/go-construct-map.c \
3002@@ -2368,6 +2369,7 @@
3003 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-caller.Plo@am__quote@
3004 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-callers.Plo@am__quote@
3005 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-can-convert-interface.Plo@am__quote@
3006+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-cdiv.Plo@am__quote@
3007 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-cgo.Plo@am__quote@
3008 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-check-interface.Plo@am__quote@
3009 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-construct-map.Plo@am__quote@
3010@@ -2554,6 +2556,13 @@
3011 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
3012 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o go-can-convert-interface.lo `test -f 'runtime/go-can-convert-interface.c' || echo '$(srcdir)/'`runtime/go-can-convert-interface.c
3013
3014+go-cdiv.lo: runtime/go-cdiv.c
3015+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT go-cdiv.lo -MD -MP -MF $(DEPDIR)/go-cdiv.Tpo -c -o go-cdiv.lo `test -f 'runtime/go-cdiv.c' || echo '$(srcdir)/'`runtime/go-cdiv.c
3016+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/go-cdiv.Tpo $(DEPDIR)/go-cdiv.Plo
3017+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runtime/go-cdiv.c' object='go-cdiv.lo' libtool=yes @AMDEPBACKSLASH@
3018+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
3019+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o go-cdiv.lo `test -f 'runtime/go-cdiv.c' || echo '$(srcdir)/'`runtime/go-cdiv.c
3020+
3021 go-cgo.lo: runtime/go-cgo.c
3022 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT go-cgo.lo -MD -MP -MF $(DEPDIR)/go-cgo.Tpo -c -o go-cgo.lo `test -f 'runtime/go-cgo.c' || echo '$(srcdir)/'`runtime/go-cgo.c
3023 @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/go-cgo.Tpo $(DEPDIR)/go-cgo.Plo
3024diff -Naur gcc-4.8.2.orig/libgo/mksysinfo.sh gcc-4.8.2/libgo/mksysinfo.sh
3025--- gcc-4.8.2.orig/libgo/mksysinfo.sh 2013-02-11 13:03:04.000000000 -0600
3026+++ gcc-4.8.2/libgo/mksysinfo.sh 2013-10-17 13:41:40.134537000 -0500
3027@@ -1035,6 +1035,10 @@
3028 grep '^const _LOCK_' gen-sysinfo.go |
3029 sed -e 's/^\(const \)_\(LOCK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
3030
3031+# The PRIO constants.
3032+grep '^const _PRIO_' gen-sysinfo.go | \
3033+ sed -e 's/^\(const \)_\(PRIO_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
3034+
3035 # The GNU/Linux LINUX_REBOOT flags.
3036 grep '^const _LINUX_REBOOT_' gen-sysinfo.go |
3037 sed -e 's/^\(const \)_\(LINUX_REBOOT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
3038diff -Naur gcc-4.8.2.orig/libgo/runtime/go-cdiv.c gcc-4.8.2/libgo/runtime/go-cdiv.c
3039--- gcc-4.8.2.orig/libgo/runtime/go-cdiv.c 1969-12-31 18:00:00.000000000 -0600
3040+++ gcc-4.8.2/libgo/runtime/go-cdiv.c 2013-10-16 12:27:53.564070000 -0500
3041@@ -0,0 +1,46 @@
3042+/* go-cdiv.c -- complex division routines
3043+
3044+ Copyright 2013 The Go Authors. All rights reserved.
3045+ Use of this source code is governed by a BSD-style
3046+ license that can be found in the LICENSE file. */
3047+
3048+/* Calls to these functions are generated by the Go frontend for
3049+ division of complex64 or complex128. We use these because Go's
3050+ complex division expects slightly different results from the GCC
3051+ default. When dividing NaN+1.0i / 0+0i, Go expects NaN+NaNi but
3052+ GCC generates NaN+Infi. NaN+Infi seems wrong seems the rules of
3053+ C99 Annex G specify that if either side of a complex number is Inf,
3054+ the the whole number is Inf, but an operation involving NaN ought
3055+ to result in NaN, not Inf. */
3056+
3057+__complex float
3058+__go_complex64_div (__complex float a, __complex float b)
3059+{
3060+ if (__builtin_expect (b == 0+0i, 0))
3061+ {
3062+ if (!__builtin_isinff (__real__ a)
3063+ && !__builtin_isinff (__imag__ a)
3064+ && (__builtin_isnanf (__real__ a) || __builtin_isnanf (__imag__ a)))
3065+ {
3066+ /* Pass "1" to nanf to match math/bits.go. */
3067+ return __builtin_nanf("1") + __builtin_nanf("1")*1i;
3068+ }
3069+ }
3070+ return a / b;
3071+}
3072+
3073+__complex double
3074+__go_complex128_div (__complex double a, __complex double b)
3075+{
3076+ if (__builtin_expect (b == 0+0i, 0))
3077+ {
3078+ if (!__builtin_isinf (__real__ a)
3079+ && !__builtin_isinf (__imag__ a)
3080+ && (__builtin_isnan (__real__ a) || __builtin_isnan (__imag__ a)))
3081+ {
3082+ /* Pass "1" to nan to match math/bits.go. */
3083+ return __builtin_nan("1") + __builtin_nan("1")*1i;
3084+ }
3085+ }
3086+ return a / b;
3087+}
3088diff -Naur gcc-4.8.2.orig/libgo/runtime/go-make-slice.c gcc-4.8.2/libgo/runtime/go-make-slice.c
3089--- gcc-4.8.2.orig/libgo/runtime/go-make-slice.c 2012-11-21 01:03:38.000000000 -0600
3090+++ gcc-4.8.2/libgo/runtime/go-make-slice.c 2013-10-16 12:27:53.564070000 -0500
3091@@ -34,7 +34,10 @@
3092 std = (const struct __go_slice_type *) td;
3093
3094 ilen = (intgo) len;
3095- if (ilen < 0 || (uintptr_t) ilen != len)
3096+ if (ilen < 0
3097+ || (uintptr_t) ilen != len
3098+ || (std->__element_type->__size > 0
3099+ && len > MaxMem / std->__element_type->__size))
3100 runtime_panicstring ("makeslice: len out of range");
3101
3102 icap = (intgo) cap;
3103diff -Naur gcc-4.8.2.orig/libgo/runtime/go-nosys.c gcc-4.8.2/libgo/runtime/go-nosys.c
3104--- gcc-4.8.2.orig/libgo/runtime/go-nosys.c 2013-01-29 14:52:43.000000000 -0600
3105+++ gcc-4.8.2/libgo/runtime/go-nosys.c 2013-10-18 08:26:14.115640000 -0500
3106@@ -43,6 +43,17 @@
3107 }
3108 #endif
3109
3110+#ifndef HAVE_DUP3
3111+int
3112+dup3 (int oldfd __attribute__ ((unused)),
3113+ int newfd __attribute__ ((unused)),
3114+ int flags __attribute__ ((unused)))
3115+{
3116+ errno = ENOSYS;
3117+ return -1;
3118+}
3119+#endif
3120+
3121 #ifndef HAVE_EPOLL_CREATE1
3122 int
3123 epoll_create1 (int flags __attribute__ ((unused)))
3124@@ -112,6 +123,18 @@
3125 }
3126 #endif
3127
3128+#ifndef HAVE_GETXATTR
3129+ssize_t
3130+getxattr (const char *path __attribute__ ((unused)),
3131+ const char *name __attribute__ ((unused)),
3132+ void *value __attribute__ ((unused)),
3133+ size_t size __attribute__ ((unused)))
3134+{
3135+ errno = ENOSYS;
3136+ return -1;
3137+}
3138+#endif
3139+
3140 #ifndef HAVE_INOTIFY_ADD_WATCH
3141 int
3142 inotify_add_watch (int fd __attribute__ ((unused)),
3143@@ -151,6 +174,17 @@
3144 }
3145 #endif
3146
3147+#ifndef HAVE_LISTXATTR
3148+ssize_t
3149+listxattr (const char *path __attribute__ ((unused)),
3150+ char *list __attribute__ ((unused)),
3151+ size_t size __attribute__ ((unused)))
3152+{
3153+ errno = ENOSYS;
3154+ return -1;
3155+}
3156+#endif
3157+
3158 #ifndef HAVE_MKDIRAT
3159 int
3160 mkdirat (int dirfd __attribute__ ((unused)),
3161@@ -196,6 +230,16 @@
3162 }
3163 #endif
3164
3165+#ifndef HAVE_REMOVEXATTR
3166+int
3167+removexattr (const char *path __attribute__ ((unused)),
3168+ const char *name __attribute__ ((unused)))
3169+{
3170+ errno = ENOSYS;
3171+ return -1;
3172+}
3173+#endif
3174+
3175 #ifndef HAVE_RENAMEAT
3176 int
3177 renameat (int olddirfd __attribute__ ((unused)),
3178@@ -205,6 +249,19 @@
3179 {
3180 errno = ENOSYS;
3181 return -1;
3182+}
3183+#endif
3184+
3185+#ifndef HAVE_SETXATTR
3186+int
3187+setxattr (const char *path __attribute__ ((unused)),
3188+ const char *name __attribute__ ((unused)),
3189+ const void *value __attribute__ ((unused)),
3190+ size_t size __attribute__ ((unused)),
3191+ int flags __attribute__ ((unused)))
3192+{
3193+ errno = ENOSYS;
3194+ return -1;
3195 }
3196 #endif
3197
3198diff -Naur gcc-4.8.2.orig/libgo/runtime/go-signal.c gcc-4.8.2/libgo/runtime/go-signal.c
3199--- gcc-4.8.2.orig/libgo/runtime/go-signal.c 2013-07-22 23:42:18.000000000 -0500
3200+++ gcc-4.8.2/libgo/runtime/go-signal.c 2013-10-16 12:27:53.564070000 -0500
3201@@ -399,6 +399,9 @@
3202 {
3203 G *gp;
3204 M *mp;
3205+#ifdef USING_SPLIT_STACK
3206+ void *stack_context[10];
3207+#endif
3208
3209 /* We are now running on the stack registered via sigaltstack.
3210 (Actually there is a small span of time between runtime_siginit
3211@@ -409,7 +412,7 @@
3212 if (gp != NULL)
3213 {
3214 #ifdef USING_SPLIT_STACK
3215- __splitstack_getcontext (&gp->stack_context[0]);
3216+ __splitstack_getcontext (&stack_context[0]);
3217 #endif
3218 }
3219
3220@@ -432,7 +435,7 @@
3221 if (gp != NULL)
3222 {
3223 #ifdef USING_SPLIT_STACK
3224- __splitstack_setcontext (&gp->stack_context[0]);
3225+ __splitstack_setcontext (&stack_context[0]);
3226 #endif
3227 }
3228 }
3229diff -Naur gcc-4.8.2.orig/libitm/libitm.info gcc-4.8.2/libitm/libitm.info
3230--- gcc-4.8.2.orig/libitm/libitm.info 2013-10-16 03:29:00.000000000 -0500
3231+++ gcc-4.8.2/libitm/libitm.info 1969-12-31 18:00:00.000000000 -0600
3232@@ -1,1293 +0,0 @@
3233-This is libitm.info, produced by makeinfo version 5.1 from libitm.texi.
3234-
3235-Copyright (C) 2011-2013 Free Software Foundation, Inc.
3236-
3237- Permission is granted to copy, distribute and/or modify this document
3238-under the terms of the GNU Free Documentation License, Version 1.2 or
3239-any later version published by the Free Software Foundation; with no
3240-Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
3241-copy of the license is included in the section entitled "GNU Free
3242-Documentation License".
3243-INFO-DIR-SECTION GNU Libraries
3244-START-INFO-DIR-ENTRY
3245-* libitm: (libitm). GNU Transactional Memory Library
3246-END-INFO-DIR-ENTRY
3247-
3248- This manual documents the GNU Transactional Memory Library.
3249-
3250- Copyright (C) 2011-2013 Free Software Foundation, Inc.
3251-
3252- Permission is granted to copy, distribute and/or modify this document
3253-under the terms of the GNU Free Documentation License, Version 1.2 or
3254-any later version published by the Free Software Foundation; with no
3255-Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
3256-copy of the license is included in the section entitled "GNU Free
3257-Documentation License".
3258-
3259-
3260-File: libitm.info, Node: Top, Next: Enabling libitm, Up: (dir)
3261-
3262-Introduction
3263-************
3264-
3265-This manual documents the usage and internals of libitm, the GNU
3266-Transactional Memory Library. It provides transaction support for
3267-accesses to a process' memory, enabling easy-to-use synchronization of
3268-accesses to shared memory by several threads.
3269-
3270-* Menu:
3271-
3272-* Enabling libitm:: How to enable libitm for your applications.
3273-* C/C++ Language Constructs for TM::
3274- Notes on the language-level interface supported
3275- by gcc.
3276-* The libitm ABI:: Notes on the external ABI provided by libitm.
3277-* Internals:: Notes on libitm's internal synchronization.
3278-* GNU Free Documentation License::
3279- How you can copy and share this manual.
3280-* Index:: Index of this documentation.
3281-
3282-
3283-File: libitm.info, Node: Enabling libitm, Next: C/C++ Language Constructs for TM, Prev: Top, Up: Top
3284-
3285-1 Enabling libitm
3286-*****************
3287-
3288-To activate support for TM in C/C++, the compile-time flag '-fgnu-tm'
3289-must be specified. This enables TM language-level constructs such as
3290-transaction statements (e.g., '__transaction_atomic', *note C/C++
3291-Language Constructs for TM:: for details).
3292-
3293-
3294-File: libitm.info, Node: C/C++ Language Constructs for TM, Next: The libitm ABI, Prev: Enabling libitm, Up: Top
3295-
3296-2 C/C++ Language Constructs for TM
3297-**********************************
3298-
3299-Transactions are supported in C++ and C in the form of transaction
3300-statements, transaction expressions, and function transactions. In the
3301-following example, both 'a' and 'b' will be read and the difference will
3302-be written to 'c', all atomically and isolated from other transactions:
3303-
3304- __transaction_atomic { c = a - b; }
3305-
3306- Therefore, another thread can use the following code to concurrently
3307-update 'b' without ever causing 'c' to hold a negative value (and
3308-without having to use other synchronization constructs such as locks or
3309-C++11 atomics):
3310-
3311- __transaction_atomic { if (a > b) b++; }
3312-
3313- GCC follows the Draft Specification of Transactional Language
3314-Constructs for C++ (v1.1)
3315-(https://sites.google.com/site/tmforcplusplus/) in its implementation of
3316-transactions.
3317-
3318- The precise semantics of transactions are defined in terms of the
3319-C++11/C11 memory model (see the specification). Roughly, transactions
3320-provide synchronization guarantees that are similar to what would be
3321-guaranteed when using a single global lock as a guard for all
3322-transactions. Note that like other synchronization constructs in C/C++,
3323-transactions rely on a data-race-free program (e.g., a nontransactional
3324-write that is concurrent with a transactional read to the same memory
3325-location is a data race).
3326-
3327-
3328-File: libitm.info, Node: The libitm ABI, Next: Internals, Prev: C/C++ Language Constructs for TM, Up: Top
3329-
3330-3 The libitm ABI
3331-****************
3332-
3333-The ABI provided by libitm is basically equal to the Linux variant of
3334-Intel's current TM ABI specification document (Revision 1.1, May 6 2009)
3335-but with the differences listed in this chapter. It would be good if
3336-these changes would eventually be merged into a future version of this
3337-specification. To ease look-up, the following subsections mirror the
3338-structure of this specification.
3339-
3340-3.1 [No changes] Objectives
3341-===========================
3342-
3343-3.2 [No changes] Non-objectives
3344-===============================
3345-
3346-3.3 Library design principles
3347-=============================
3348-
3349-3.3.1 [No changes] Calling conventions
3350---------------------------------------
3351-
3352-3.3.2 [No changes] TM library algorithms
3353-----------------------------------------
3354-
3355-3.3.3 [No changes] Optimized load and store routines
3356-----------------------------------------------------
3357-
3358-3.3.4 [No changes] Aligned load and store routines
3359---------------------------------------------------
3360-
3361-3.3.5 Data logging functions
3362-----------------------------
3363-
3364-The memory locations accessed with transactional loads and stores and
3365-the memory locations whose values are logged must not overlap. This
3366-required separation only extends to the scope of the execution of one
3367-transaction including all the executions of all nested transactions.
3368-
3369- The compiler must be consistent (within the scope of a single
3370-transaction) about which memory locations are shared and which are not
3371-shared with other threads (i.e., data must be accessed either
3372-transactionally or nontransactionally). Otherwise, non-write-through TM
3373-algorithms would not work.
3374-
3375- For memory locations on the stack, this requirement extends to only
3376-the lifetime of the stack frame that the memory location belongs to (or
3377-the lifetime of the transaction, whichever is shorter). Thus, memory
3378-that is reused for several stack frames could be target of both data
3379-logging and transactional accesses; however, this is harmless because
3380-these stack frames' lifetimes will end before the transaction finishes.
3381-
3382-3.3.6 [No changes] Scatter/gather calls
3383----------------------------------------
3384-
3385-3.3.7 [No changes] Serial and irrevocable mode
3386-----------------------------------------------
3387-
3388-3.3.8 [No changes] Transaction descriptor
3389------------------------------------------
3390-
3391-3.3.9 Store allocation
3392-----------------------
3393-
3394-There is no 'getTransaction' function.
3395-
3396-3.3.10 [No changes] Naming conventions
3397---------------------------------------
3398-
3399-3.3.11 Function pointer encryption
3400-----------------------------------
3401-
3402-Currently, this is not implemented.
3403-
3404-3.4 Types and macros list
3405-=========================
3406-
3407-'_ITM_codeProperties' has changed, *note Starting a transaction:
3408-txn-code-properties. '_ITM_srcLocation' is not used.
3409-
3410-3.5 Function list
3411-=================
3412-
3413-3.5.1 Initialization and finalization functions
3414------------------------------------------------
3415-
3416-These functions are not part of the ABI.
3417-
3418-3.5.2 [No changes] Version checking
3419------------------------------------
3420-
3421-3.5.3 [No changes] Error reporting
3422-----------------------------------
3423-
3424-3.5.4 [No changes] inTransaction call
3425--------------------------------------
3426-
3427-3.5.5 State manipulation functions
3428-----------------------------------
3429-
3430-There is no 'getTransaction' function. Transaction identifiers for
3431-nested transactions will be ordered but not necessarily sequential
3432-(i.e., for a nested transaction's identifier IN and its enclosing
3433-transaction's identifier IE, it is guaranteed that IN >= IE).
3434-
3435-3.5.6 [No changes] Source locations
3436------------------------------------
3437-
3438-3.5.7 Starting a transaction
3439-----------------------------
3440-
3441-3.5.7.1 Transaction code properties
3442-...................................
3443-
3444-The bit 'hasNoXMMUpdate' is instead called 'hasNoVectorUpdate'. Iff it
3445-is set, vector register save/restore is not necessary for any target
3446-machine.
3447-
3448- The 'hasNoFloatUpdate' bit ('0x0010') is new. Iff it is set,
3449-floating point register save/restore is not necessary for any target
3450-machine.
3451-
3452- 'undoLogCode' is not supported and a fatal runtime error will be
3453-raised if this bit is set. It is not properly defined in the ABI why
3454-barriers other than undo logging are not present; Are they not necessary
3455-(e.g., a transaction operating purely on thread-local data) or have they
3456-been omitted by the compiler because it thinks that some kind of global
3457-synchronization (e.g., serial mode) might perform better? The
3458-specification suggests that the latter might be the case, but the former
3459-seems to be more useful.
3460-
3461- The 'readOnly' bit ('0x4000') is new. *TODO* Lexical or dynamic
3462-scope?
3463-
3464- 'hasNoRetry' is not supported. If this bit is not set, but
3465-'hasNoAbort' is set, the library can assume that transaction rollback
3466-will not be requested.
3467-
3468- It would be useful if the absence of externally-triggered rollbacks
3469-would be reported for the dynamic scope as well, not just for the
3470-lexical scope ('hasNoAbort'). Without this, a library cannot exploit
3471-this together with flat nesting.
3472-
3473- 'exceptionBlock' is not supported because exception blocks are not
3474-used.
3475-
3476-3.5.7.2 [No changes] Windows exception state
3477-............................................
3478-
3479-3.5.7.3 [No changes] Other machine state
3480-........................................
3481-
3482-3.5.7.4 [No changes] Results from beginTransaction
3483-..................................................
3484-
3485-3.5.8 Aborting a transaction
3486-----------------------------
3487-
3488-'_ITM_rollbackTransaction' is not supported. '_ITM_abortTransaction' is
3489-supported but the abort reasons 'exceptionBlockAbort', 'TMConflict', and
3490-'userRetry' are not supported. There are no exception blocks in
3491-general, so the related cases also do not have to be considered. To
3492-encode '__transaction_cancel [[outer]]', compilers must set the new
3493-'outerAbort' bit ('0x10') additionally to the 'userAbort' bit in the
3494-abort reason.
3495-
3496-3.5.9 Committing a transaction
3497-------------------------------
3498-
3499-The exception handling (EH) scheme is different. The Intel ABI requires
3500-the '_ITM_tryCommitTransaction' function that will return even when the
3501-commit failed and will have to be matched with calls to either
3502-'_ITM_abortTransaction' or '_ITM_commitTransaction'. In contrast, gcc
3503-relies on transactional wrappers for the functions of the Exception
3504-Handling ABI and on one additional commit function (shown below). This
3505-allows the TM to keep track of EH internally and thus it does not have
3506-to embed the cleanup of EH state into the existing EH code in the
3507-program. '_ITM_tryCommitTransaction' is not supported.
3508-'_ITM_commitTransactionToId' is also not supported because the
3509-propagation of thrown exceptions will not bypass commits of nested
3510-transactions.
3511-
3512- void _ITM_commitTransactionEH(void *exc_ptr) ITM_REGPARM;
3513- void *_ITM_cxa_allocate_exception (size_t);
3514- void _ITM_cxa_throw (void *obj, void *tinfo, void *dest);
3515- void *_ITM_cxa_begin_catch (void *exc_ptr);
3516- void _ITM_cxa_end_catch (void);
3517-
3518- '_ITM_commitTransactionEH' must be called to commit a transaction if
3519-an exception could be in flight at this position in the code. 'exc_ptr'
3520-is the current exception or zero if there is no current exception. The
3521-'_ITM_cxa...' functions are transactional wrappers for the respective
3522-'__cxa...' functions and must be called instead of these in
3523-transactional code.
3524-
3525- To support this EH scheme, libstdc++ needs to provide one additional
3526-function ('_cxa_tm_cleanup'), which is used by the TM to clean up the
3527-exception handling state while rolling back a transaction:
3528-
3529- void __cxa_tm_cleanup (void *unthrown_obj, void *cleanup_exc,
3530- unsigned int caught_count);
3531-
3532- 'unthrown_obj' is non-null if the program called
3533-'__cxa_allocate_exception' for this exception but did not yet called
3534-'__cxa_throw' for it. 'cleanup_exc' is non-null if the program is
3535-currently processing a cleanup along an exception path but has not
3536-caught this exception yet. 'caught_count' is the nesting depth of
3537-'__cxa_begin_catch' within the transaction (which can be counted by the
3538-TM using '_ITM_cxa_begin_catch' and '_ITM_cxa_end_catch');
3539-'__cxa_tm_cleanup' then performs rollback by essentially performing
3540-'__cxa_end_catch' that many times.
3541-
3542-3.5.10 Exception handling support
3543----------------------------------
3544-
3545-Currently, there is no support for functionality like
3546-'__transaction_cancel throw' as described in the C++ TM specification.
3547-Supporting this should be possible with the EH scheme explained
3548-previously because via the transactional wrappers for the EH ABI, the TM
3549-is able to observe and intercept EH.
3550-
3551-3.5.11 [No changes] Transition to serial-irrevocable mode
3552----------------------------------------------------------
3553-
3554-3.5.12 [No changes] Data transfer functions
3555--------------------------------------------
3556-
3557-3.5.13 [No changes] Transactional memory copies
3558------------------------------------------------
3559-
3560-3.5.14 Transactional versions of memmove
3561-----------------------------------------
3562-
3563-If either the source or destination memory region is to be accessed
3564-nontransactionally, then source and destination regions must not be
3565-overlapping. The respective '_ITM_memmove' functions are still
3566-available but a fatal runtime error will be raised if such regions do
3567-overlap. To support this functionality, the ABI would have to specify
3568-how the intersection of the regions has to be accessed (i.e.,
3569-transactionally or nontransactionally).
3570-
3571-3.5.15 [No changes] Transactional versions of memset
3572-----------------------------------------------------
3573-
3574-3.5.16 [No changes] Logging functions
3575--------------------------------------
3576-
3577-3.5.17 User-registered commit and undo actions
3578-----------------------------------------------
3579-
3580-Commit actions will get executed in the same order in which the
3581-respective calls to '_ITM_addUserCommitAction' happened. Only
3582-'_ITM_noTransactionId' is allowed as value for the
3583-'resumingTransactionId' argument. Commit actions get executed after
3584-privatization safety has been ensured.
3585-
3586- Undo actions will get executed in reverse order compared to the order
3587-in which the respective calls to '_ITM_addUserUndoAction' happened. The
3588-ordering of undo actions w.r.t. the roll-back of other actions (e.g.,
3589-data transfers or memory allocations) is undefined.
3590-
3591- '_ITM_getThreadnum' is not supported currently because its only
3592-purpose is to provide a thread ID that matches some assumed performance
3593-tuning output, but this output is not part of the ABI nor further
3594-defined by it.
3595-
3596- '_ITM_dropReferences' is not supported currently because its
3597-semantics and the intention behind it is not entirely clear. The
3598-specification suggests that this function is necessary because of
3599-certain orderings of data transfer undos and the releasing of memory
3600-regions (i.e., privatization). However, this ordering is never defined,
3601-nor is the ordering of dropping references w.r.t. other events.
3602-
3603-3.5.18 [New] Transactional indirect calls
3604------------------------------------------
3605-
3606-Indirect calls (i.e., calls through a function pointer) within
3607-transactions should execute the transactional clone of the original
3608-function (i.e., a clone of the original that has been fully instrumented
3609-to use the TM runtime), if such a clone is available. The runtime
3610-provides two functions to register/deregister clone tables:
3611-
3612- struct clone_entry
3613- {
3614- void *orig, *clone;
3615- };
3616-
3617- void _ITM_registerTMCloneTable (clone_entry *table, size_t entries);
3618- void _ITM_deregisterTMCloneTable (clone_entry *table);
3619-
3620- Registered tables must be writable by the TM runtime, and must be
3621-live throughout the life-time of the TM runtime.
3622-
3623- *TODO* The intention was always to drop the registration functions
3624-entirely, and create a new ELF Phdr describing the linker-sorted table.
3625-Much like what currently happens for 'PT_GNU_EH_FRAME'. This work kept
3626-getting bogged down in how to represent the N different code generation
3627-variants. We clearly needed at least two--SW and HW transactional
3628-clones--but there was always a suggestion of more variants for different
3629-TM assumptions/invariants.
3630-
3631- The compiler can then use two TM runtime functions to perform
3632-indirect calls in transactions:
3633- void *_ITM_getTMCloneOrIrrevocable (void *function) ITM_REGPARM;
3634- void *_ITM_getTMCloneSafe (void *function) ITM_REGPARM;
3635-
3636- If there is a registered clone for supplied function, both will
3637-return a pointer to the clone. If not, the first runtime function will
3638-attempt to switch to serial-irrevocable mode and return the original
3639-pointer, whereas the second will raise a fatal runtime error.
3640-
3641-3.5.19 [New] Transactional dynamic memory management
3642-----------------------------------------------------
3643-
3644- void *_ITM_malloc (size_t)
3645- __attribute__((__malloc__)) ITM_PURE;
3646- void *_ITM_calloc (size_t, size_t)
3647- __attribute__((__malloc__)) ITM_PURE;
3648- void _ITM_free (void *) ITM_PURE;
3649-
3650- These functions are essentially transactional wrappers for 'malloc',
3651-'calloc', and 'free'. Within transactions, the compiler should replace
3652-calls to the original functions with calls to the wrapper functions.
3653-
3654-3.6 [No changes] Future Enhancements to the ABI
3655-===============================================
3656-
3657-3.7 Sample code
3658-===============
3659-
3660-The code examples might not be correct w.r.t. the current version of
3661-the ABI, especially everything related to exception handling.
3662-
3663-3.8 [New] Memory model
3664-======================
3665-
3666-The ABI should define a memory model and the ordering that is guaranteed
3667-for data transfers and commit/undo actions, or at least refer to another
3668-memory model that needs to be preserved. Without that, the compiler
3669-cannot ensure the memory model specified on the level of the programming
3670-language (e.g., by the C++ TM specification).
3671-
3672- For example, if a transactional load is ordered before another
3673-load/store, then the TM runtime must also ensure this ordering when
3674-accessing shared state. If not, this might break the kind of
3675-publication safety used in the C++ TM specification. Likewise, the TM
3676-runtime must ensure privatization safety.
3677-
3678-
3679-File: libitm.info, Node: Internals, Next: GNU Free Documentation License, Prev: The libitm ABI, Up: Top
3680-
3681-4 Internals
3682-***********
3683-
3684-4.1 TM methods and method groups
3685-================================
3686-
3687-libitm supports several ways of synchronizing transactions with each
3688-other. These TM methods (or TM algorithms) are implemented in the form
3689-of subclasses of 'abi_dispatch', which provide methods for transactional
3690-loads and stores as well as callbacks for rollback and commit. All
3691-methods that are compatible with each other (i.e., that let concurrently
3692-running transactions still synchronize correctly even if different
3693-methods are used) belong to the same TM method group. Pointers to TM
3694-methods can be obtained using the factory methods prefixed with
3695-'dispatch_' in 'libitm_i.h'. There are two special methods,
3696-'dispatch_serial' and 'dispatch_serialirr', that are compatible with all
3697-methods because they run transactions completely in serial mode.
3698-
3699-4.1.1 TM method life cycle
3700---------------------------
3701-
3702-The state of TM methods does not change after construction, but they do
3703-alter the state of transactions that use this method. However, because
3704-per-transaction data gets used by several methods, 'gtm_thread' is
3705-responsible for setting an initial state that is useful for all methods.
3706-After that, methods are responsible for resetting/clearing this state on
3707-each rollback or commit (of outermost transactions), so that the
3708-transaction executed next is not affected by the previous transaction.
3709-
3710- There is also global state associated with each method group, which
3711-is initialized and shut down ('method_group::init()' and 'fini()') when
3712-switching between method groups (see 'retry.cc').
3713-
3714-4.1.2 Selecting the default method
3715-----------------------------------
3716-
3717-The default method that libitm uses for freshly started transactions
3718-(but not necessarily for restarted transactions) can be set via an
3719-environment variable ('ITM_DEFAULT_METHOD'), whose value should be equal
3720-to the name of one of the factory methods returning abi_dispatch
3721-subclasses but without the "dispatch_" prefix (e.g., "serialirr" instead
3722-of 'GTM::dispatch_serialirr()').
3723-
3724- Note that this environment variable is only a hint for libitm and
3725-might not be supported in the future.
3726-
3727-4.2 Nesting: flat vs. closed
3728-============================
3729-
3730-We support two different kinds of nesting of transactions. In the case
3731-of _flat nesting_, the nesting structure is flattened and all nested
3732-transactions are subsumed by the enclosing transaction. In contrast,
3733-with _closed nesting_, nested transactions that have not yet committed
3734-can be rolled back separately from the enclosing transactions; when they
3735-commit, they are subsumed by the enclosing transaction, and their
3736-effects will be finally committed when the outermost transaction
3737-commits. _Open nesting_ (where nested transactions can commit
3738-independently of the enclosing transactions) are not supported.
3739-
3740- Flat nesting is the default nesting mode, but closed nesting is
3741-supported and used when transactions contain user-controlled aborts
3742-('__transaction_cancel' statements). We assume that user-controlled
3743-aborts are rare in typical code and used mostly in exceptional
3744-situations. Thus, it makes more sense to use flat nesting by default to
3745-avoid the performance overhead of the additional checkpoints required
3746-for closed nesting. User-controlled aborts will correctly abort the
3747-innermost enclosing transaction, whereas the whole (i.e., outermost)
3748-transaction will be restarted otherwise (e.g., when a transaction
3749-encounters data conflicts during optimistic execution).
3750-
3751-4.3 Locking conventions
3752-=======================
3753-
3754-This section documents the locking scheme and rules for all uses of
3755-locking in libitm. We have to support serial(-irrevocable) mode, which
3756-is implemented using a global lock as explained next (called the _serial
3757-lock_). To simplify the overall design, we use the same lock as
3758-catch-all locking mechanism for other infrequent tasks such as
3759-(de)registering clone tables or threads. Besides the serial lock, there
3760-are _per-method-group locks_ that are managed by specific method groups
3761-(i.e., groups of similar TM concurrency control algorithms), and
3762-lock-like constructs for quiescence-based operations such as ensuring
3763-privatization safety.
3764-
3765- Thus, the actions that participate in the libitm-internal locking are
3766-either _active transactions_ that do not run in serial mode, _serial
3767-transactions_ (which (are about to) run in serial mode), and management
3768-tasks that do not execute within a transaction but have acquired the
3769-serial mode like a serial transaction would do (e.g., to be able to
3770-register threads with libitm). Transactions become active as soon as
3771-they have successfully used the serial lock to announce this globally
3772-(*note Serial lock implementation: serial-lock-impl.). Likewise,
3773-transactions become serial transactions as soon as they have acquired
3774-the exclusive rights provided by the serial lock (i.e., serial mode,
3775-which also means that there are no other concurrent active or serial
3776-transactions). Note that active transactions can become serial
3777-transactions when they enter serial mode during the runtime of the
3778-transaction.
3779-
3780-4.3.1 State-to-lock mapping
3781----------------------------
3782-
3783-Application data is protected by the serial lock if there is a serial
3784-transaction and no concurrently running active transaction (i.e.,
3785-non-serial). Otherwise, application data is protected by the currently
3786-selected method group, which might use per-method-group locks or other
3787-mechanisms. Also note that application data that is about to be
3788-privatized might not be allowed to be accessed by nontransactional code
3789-until privatization safety has been ensured; the details of this are
3790-handled by the current method group.
3791-
3792- libitm-internal state is either protected by the serial lock or
3793-accessed through custom concurrent code. The latter applies to the
3794-public/shared part of a transaction object and most typical
3795-method-group-specific state.
3796-
3797- The former category (protected by the serial lock) includes:
3798- * The list of active threads that have used transactions.
3799- * The tables that map functions to their transactional clones.
3800- * The current selection of which method group to use.
3801- * Some method-group-specific data, or invariants of this data. For
3802- example, resetting a method group to its initial state is handled
3803- by switching to the same method group, so the serial lock protects
3804- such resetting as well.
3805- In general, such state is immutable whenever there exists an active
3806-(non-serial) transaction. If there is no active transaction, a serial
3807-transaction (or a thread that is not currently executing a transaction
3808-but has acquired the serial lock) is allowed to modify this state (but
3809-must of course be careful to not surprise the current method group's
3810-implementation with such modifications).
3811-
3812-4.3.2 Lock acquisition order
3813-----------------------------
3814-
3815-To prevent deadlocks, locks acquisition must happen in a globally
3816-agreed-upon order. Note that this applies to other forms of blocking
3817-too, but does not necessarily apply to lock acquisitions that do not
3818-block (e.g., trylock() calls that do not get retried forever). Note
3819-that serial transactions are never return back to active transactions
3820-until the transaction has committed. Likewise, active transactions stay
3821-active until they have committed. Per-method-group locks are typically
3822-also not released before commit.
3823-
3824- Lock acquisition / blocking rules:
3825-
3826- * Transactions must become active or serial before they are allowed
3827- to use method-group-specific locks or blocking (i.e., the serial
3828- lock must be acquired before those other locks, either in serial or
3829- nonserial mode).
3830-
3831- * Any number of threads that do not currently run active transactions
3832- can block while trying to get the serial lock in exclusive mode.
3833- Note that active transactions must not block when trying to upgrade
3834- to serial mode unless there is no other transaction that is trying
3835- that (the latter is ensured by the serial lock implementation.
3836-
3837- * Method groups must prevent deadlocks on their locks. In
3838- particular, they must also be prepared for another active
3839- transaction that has acquired method-group-specific locks but is
3840- blocked during an attempt to upgrade to being a serial transaction.
3841- See below for details.
3842-
3843- * Serial transactions can acquire method-group-specific locks because
3844- there will be no other active nor serial transaction.
3845-
3846- There is no single rule for per-method-group blocking because this
3847-depends on when a TM method might acquire locks. If no active
3848-transaction can upgrade to being a serial transaction after it has
3849-acquired per-method-group locks (e.g., when those locks are only
3850-acquired during an attempt to commit), then the TM method does not need
3851-to consider a potential deadlock due to serial mode.
3852-
3853- If there can be upgrades to serial mode after the acquisition of
3854-per-method-group locks, then TM methods need to avoid those deadlocks:
3855- * When upgrading to a serial transaction, after acquiring exclusive
3856- rights to the serial lock but before waiting for concurrent active
3857- transactions to finish (*note Serial lock implementation:
3858- serial-lock-impl. for details), we have to wake up all active
3859- transactions waiting on the upgrader's per-method-group locks.
3860- * Active transactions blocking on per-method-group locks need to
3861- check the serial lock and abort if there is a pending serial
3862- transaction.
3863- * Lost wake-ups have to be prevented (e.g., by changing a bit in each
3864- per-method-group lock before doing the wake-up, and only blocking
3865- on this lock using a futex if this bit is not group).
3866-
3867- *TODO*: Can reuse serial lock for gl-*? And if we can, does it make
3868-sense to introduce further complexity in the serial lock? For gl-*, we
3869-can really only avoid an abort if we do -wb and -vbv.
3870-
3871-4.3.3 Serial lock implementation
3872---------------------------------
3873-
3874-The serial lock implementation is optimized towards assuming that serial
3875-transactions are infrequent and not the common case. However, the
3876-performance of entering serial mode can matter because when only few
3877-transactions are run concurrently or if there are few threads, then it
3878-can be efficient to run transactions serially.
3879-
3880- The serial lock is similar to a multi-reader-single-writer lock in
3881-that there can be several active transactions but only one serial
3882-transaction. However, we do want to avoid contention (in the lock
3883-implementation) between active transactions, so we split up the reader
3884-side of the lock into per-transaction flags that are true iff the
3885-transaction is active. The exclusive writer side remains a shared
3886-single flag, which is acquired using a CAS, for example. On the
3887-fast-path, the serial lock then works similar to Dekker's algorithm but
3888-with several reader flags that a serial transaction would have to check.
3889-A serial transaction thus requires a list of all threads with
3890-potentially active transactions; we can use the serial lock itself to
3891-protect this list (i.e., only threads that have acquired the serial lock
3892-can modify this list).
3893-
3894- We want starvation-freedom for the serial lock to allow for using it
3895-to ensure progress for potentially starved transactions (*note Progress
3896-Guarantees: progress-guarantees. for details). However, this is
3897-currently not enforced by the implementation of the serial lock.
3898-
3899- Here is pseudo-code for the read/write fast paths of acquiring the
3900-serial lock (read-to-write upgrade is similar to write_lock:
3901- // read_lock:
3902- tx->shared_state |= active;
3903- __sync_synchronize(); // or STLD membar, or C++0x seq-cst fence
3904- while (!serial_lock.exclusive)
3905- if (spinning_for_too_long) goto slowpath;
3906-
3907- // write_lock:
3908- if (CAS(&serial_lock.exclusive, 0, this) != 0)
3909- goto slowpath; // writer-writer contention
3910- // need a membar here, but CAS already has full membar semantics
3911- bool need_blocking = false;
3912- for (t: all txns)
3913- {
3914- for (;t->shared_state & active;)
3915- if (spinning_for_too_long) { need_blocking = true; break; }
3916- }
3917- if (need_blocking) goto slowpath;
3918-
3919- Releasing a lock in this spin-lock version then just consists of
3920-resetting 'tx->shared_state' to inactive or clearing
3921-'serial_lock.exclusive'.
3922-
3923- However, we can't rely on a pure spinlock because we need to get the
3924-OS involved at some time (e.g., when there are more threads than CPUs to
3925-run on). Therefore, the real implementation falls back to a blocking
3926-slow path, either based on pthread mutexes or Linux futexes.
3927-
3928-4.3.4 Reentrancy
3929-----------------
3930-
3931-libitm has to consider the following cases of reentrancy:
3932-
3933- * Transaction calls unsafe code that starts a new transaction: The
3934- outer transaction will become a serial transaction before executing
3935- unsafe code. Therefore, nesting within serial transactions must
3936- work, even if the nested transaction is called from within
3937- uninstrumented code.
3938-
3939- * Transaction calls either a transactional wrapper or safe code,
3940- which in turn starts a new transaction: It is not yet defined in
3941- the specification whether this is allowed. Thus, it is undefined
3942- whether libitm supports this.
3943-
3944- * Code that starts new transactions might be called from within any
3945- part of libitm: This kind of reentrancy would likely be rather
3946- complex and can probably be avoided. Therefore, it is not
3947- supported.
3948-
3949-4.3.5 Privatization safety
3950---------------------------
3951-
3952-Privatization safety is ensured by libitm using a quiescence-based
3953-approach. Basically, a privatizing transaction waits until all
3954-concurrent active transactions will either have finished (are not active
3955-anymore) or operate on a sufficiently recent snapshot to not access the
3956-privatized data anymore. This happens after the privatizing transaction
3957-has stopped being an active transaction, so waiting for quiescence does
3958-not contribute to deadlocks.
3959-
3960- In method groups that need to ensure publication safety explicitly,
3961-active transactions maintain a flag or timestamp in the public/shared
3962-part of the transaction descriptor. Before blocking, privatizers need
3963-to let the other transactions know that they should wake up the
3964-privatizer.
3965-
3966- *TODO* Ho to implement the waiters? Should those flags be
3967-per-transaction or at a central place? We want to avoid one wake/wait
3968-call per active transactions, so we might want to use either a tree or
3969-combining to reduce the syscall overhead, or rather spin for a long
3970-amount of time instead of doing blocking. Also, it would be good if
3971-only the last transaction that the privatizer waits for would do the
3972-wake-up.
3973-
3974-4.3.6 Progress guarantees
3975--------------------------
3976-
3977-Transactions that do not make progress when using the current TM method
3978-will eventually try to execute in serial mode. Thus, the serial lock's
3979-progress guarantees determine the progress guarantees of the whole TM.
3980-Obviously, we at least need deadlock-freedom for the serial lock, but it
3981-would also be good to provide starvation-freedom (informally, all
3982-threads will finish executing a transaction eventually iff they get
3983-enough cycles).
3984-
3985- However, the scheduling of transactions (e.g., thread scheduling by
3986-the OS) also affects the handling of progress guarantees by the TM.
3987-First, the TM can only guarantee deadlock-freedom if threads do not get
3988-stopped. Likewise, low-priority threads can starve if they do not get
3989-scheduled when other high-priority threads get those cycles instead.
3990-
3991- If all threads get scheduled eventually, correct lock implementations
3992-will provide deadlock-freedom, but might not provide starvation-freedom.
3993-We can either enforce the latter in the TM's lock implementation, or
3994-assume that the scheduling is sufficiently random to yield a
3995-probabilistic guarantee that no thread will starve (because eventually,
3996-a transaction will encounter a scheduling that will allow it to run).
3997-This can indeed work well in practice but is not necessarily guaranteed
3998-to work (e.g., simple spin locks can be pretty efficient).
3999-
4000- Because enforcing stronger progress guarantees in the TM has a higher
4001-runtime overhead, we focus on deadlock-freedom right now and assume that
4002-the threads will get scheduled eventually by the OS (but don't consider
4003-threads with different priorities). We should support
4004-starvation-freedom for serial transactions in the future. Everything
4005-beyond that is highly related to proper contention management across all
4006-of the TM (including with TM method to choose), and is future work.
4007-
4008- *TODO* Handling thread priorities: We want to avoid priority
4009-inversion but it's unclear how often that actually matters in practice.
4010-Workloads that have threads with different priorities will likely also
4011-require lower latency or higher throughput for high-priority threads.
4012-Therefore, it probably makes not that much sense (except for eventual
4013-progress guarantees) to use priority inheritance until the TM has
4014-priority-aware contention management.
4015-
4016-
4017-File: libitm.info, Node: GNU Free Documentation License, Next: Index, Prev: Internals, Up: Top
4018-
4019-GNU Free Documentation License
4020-******************************
4021-
4022- Version 1.3, 3 November 2008
4023-
4024- Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
4025- <http://fsf.org/>
4026-
4027- Everyone is permitted to copy and distribute verbatim copies
4028- of this license document, but changing it is not allowed.
4029-
4030- 0. PREAMBLE
4031-
4032- The purpose of this License is to make a manual, textbook, or other
4033- functional and useful document "free" in the sense of freedom: to
4034- assure everyone the effective freedom to copy and redistribute it,
4035- with or without modifying it, either commercially or
4036- noncommercially. Secondarily, this License preserves for the
4037- author and publisher a way to get credit for their work, while not
4038- being considered responsible for modifications made by others.
4039-
4040- This License is a kind of "copyleft", which means that derivative
4041- works of the document must themselves be free in the same sense.
4042- It complements the GNU General Public License, which is a copyleft
4043- license designed for free software.
4044-
4045- We have designed this License in order to use it for manuals for
4046- free software, because free software needs free documentation: a
4047- free program should come with manuals providing the same freedoms
4048- that the software does. But this License is not limited to
4049- software manuals; it can be used for any textual work, regardless
4050- of subject matter or whether it is published as a printed book. We
4051- recommend this License principally for works whose purpose is
4052- instruction or reference.
4053-
4054- 1. APPLICABILITY AND DEFINITIONS
4055-
4056- This License applies to any manual or other work, in any medium,
4057- that contains a notice placed by the copyright holder saying it can
4058- be distributed under the terms of this License. Such a notice
4059- grants a world-wide, royalty-free license, unlimited in duration,
4060- to use that work under the conditions stated herein. The
4061- "Document", below, refers to any such manual or work. Any member
4062- of the public is a licensee, and is addressed as "you". You accept
4063- the license if you copy, modify or distribute the work in a way
4064- requiring permission under copyright law.
4065-
4066- A "Modified Version" of the Document means any work containing the
4067- Document or a portion of it, either copied verbatim, or with
4068- modifications and/or translated into another language.
4069-
4070- A "Secondary Section" is a named appendix or a front-matter section
4071- of the Document that deals exclusively with the relationship of the
4072- publishers or authors of the Document to the Document's overall
4073- subject (or to related matters) and contains nothing that could
4074- fall directly within that overall subject. (Thus, if the Document
4075- is in part a textbook of mathematics, a Secondary Section may not
4076- explain any mathematics.) The relationship could be a matter of
4077- historical connection with the subject or with related matters, or
4078- of legal, commercial, philosophical, ethical or political position
4079- regarding them.
4080-
4081- The "Invariant Sections" are certain Secondary Sections whose
4082- titles are designated, as being those of Invariant Sections, in the
4083- notice that says that the Document is released under this License.
4084- If a section does not fit the above definition of Secondary then it
4085- is not allowed to be designated as Invariant. The Document may
4086- contain zero Invariant Sections. If the Document does not identify
4087- any Invariant Sections then there are none.
4088-
4089- The "Cover Texts" are certain short passages of text that are
4090- listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4091- that says that the Document is released under this License. A
4092- Front-Cover Text may be at most 5 words, and a Back-Cover Text may
4093- be at most 25 words.
4094-
4095- A "Transparent" copy of the Document means a machine-readable copy,
4096- represented in a format whose specification is available to the
4097- general public, that is suitable for revising the document
4098- straightforwardly with generic text editors or (for images composed
4099- of pixels) generic paint programs or (for drawings) some widely
4100- available drawing editor, and that is suitable for input to text
4101- formatters or for automatic translation to a variety of formats
4102- suitable for input to text formatters. A copy made in an otherwise
4103- Transparent file format whose markup, or absence of markup, has
4104- been arranged to thwart or discourage subsequent modification by
4105- readers is not Transparent. An image format is not Transparent if
4106- used for any substantial amount of text. A copy that is not
4107- "Transparent" is called "Opaque".
4108-
4109- Examples of suitable formats for Transparent copies include plain
4110- ASCII without markup, Texinfo input format, LaTeX input format,
4111- SGML or XML using a publicly available DTD, and standard-conforming
4112- simple HTML, PostScript or PDF designed for human modification.
4113- Examples of transparent image formats include PNG, XCF and JPG.
4114- Opaque formats include proprietary formats that can be read and
4115- edited only by proprietary word processors, SGML or XML for which
4116- the DTD and/or processing tools are not generally available, and
4117- the machine-generated HTML, PostScript or PDF produced by some word
4118- processors for output purposes only.
4119-
4120- The "Title Page" means, for a printed book, the title page itself,
4121- plus such following pages as are needed to hold, legibly, the
4122- material this License requires to appear in the title page. For
4123- works in formats which do not have any title page as such, "Title
4124- Page" means the text near the most prominent appearance of the
4125- work's title, preceding the beginning of the body of the text.
4126-
4127- The "publisher" means any person or entity that distributes copies
4128- of the Document to the public.
4129-
4130- A section "Entitled XYZ" means a named subunit of the Document
4131- whose title either is precisely XYZ or contains XYZ in parentheses
4132- following text that translates XYZ in another language. (Here XYZ
4133- stands for a specific section name mentioned below, such as
4134- "Acknowledgements", "Dedications", "Endorsements", or "History".)
4135- To "Preserve the Title" of such a section when you modify the
4136- Document means that it remains a section "Entitled XYZ" according
4137- to this definition.
4138-
4139- The Document may include Warranty Disclaimers next to the notice
4140- which states that this License applies to the Document. These
4141- Warranty Disclaimers are considered to be included by reference in
4142- this License, but only as regards disclaiming warranties: any other
4143- implication that these Warranty Disclaimers may have is void and
4144- has no effect on the meaning of this License.
4145-
4146- 2. VERBATIM COPYING
4147-
4148- You may copy and distribute the Document in any medium, either
4149- commercially or noncommercially, provided that this License, the
4150- copyright notices, and the license notice saying this License
4151- applies to the Document are reproduced in all copies, and that you
4152- add no other conditions whatsoever to those of this License. You
4153- may not use technical measures to obstruct or control the reading
4154- or further copying of the copies you make or distribute. However,
4155- you may accept compensation in exchange for copies. If you
4156- distribute a large enough number of copies you must also follow the
4157- conditions in section 3.
4158-
4159- You may also lend copies, under the same conditions stated above,
4160- and you may publicly display copies.
4161-
4162- 3. COPYING IN QUANTITY
4163-
4164- If you publish printed copies (or copies in media that commonly
4165- have printed covers) of the Document, numbering more than 100, and
4166- the Document's license notice requires Cover Texts, you must
4167- enclose the copies in covers that carry, clearly and legibly, all
4168- these Cover Texts: Front-Cover Texts on the front cover, and
4169- Back-Cover Texts on the back cover. Both covers must also clearly
4170- and legibly identify you as the publisher of these copies. The
4171- front cover must present the full title with all words of the title
4172- equally prominent and visible. You may add other material on the
4173- covers in addition. Copying with changes limited to the covers, as
4174- long as they preserve the title of the Document and satisfy these
4175- conditions, can be treated as verbatim copying in other respects.
4176-
4177- If the required texts for either cover are too voluminous to fit
4178- legibly, you should put the first ones listed (as many as fit
4179- reasonably) on the actual cover, and continue the rest onto
4180- adjacent pages.
4181-
4182- If you publish or distribute Opaque copies of the Document
4183- numbering more than 100, you must either include a machine-readable
4184- Transparent copy along with each Opaque copy, or state in or with
4185- each Opaque copy a computer-network location from which the general
4186- network-using public has access to download using public-standard
4187- network protocols a complete Transparent copy of the Document, free
4188- of added material. If you use the latter option, you must take
4189- reasonably prudent steps, when you begin distribution of Opaque
4190- copies in quantity, to ensure that this Transparent copy will
4191- remain thus accessible at the stated location until at least one
4192- year after the last time you distribute an Opaque copy (directly or
4193- through your agents or retailers) of that edition to the public.
4194-
4195- It is requested, but not required, that you contact the authors of
4196- the Document well before redistributing any large number of copies,
4197- to give them a chance to provide you with an updated version of the
4198- Document.
4199-
4200- 4. MODIFICATIONS
4201-
4202- You may copy and distribute a Modified Version of the Document
4203- under the conditions of sections 2 and 3 above, provided that you
4204- release the Modified Version under precisely this License, with the
4205- Modified Version filling the role of the Document, thus licensing
4206- distribution and modification of the Modified Version to whoever
4207- possesses a copy of it. In addition, you must do these things in
4208- the Modified Version:
4209-
4210- A. Use in the Title Page (and on the covers, if any) a title
4211- distinct from that of the Document, and from those of previous
4212- versions (which should, if there were any, be listed in the
4213- History section of the Document). You may use the same title
4214- as a previous version if the original publisher of that
4215- version gives permission.
4216-
4217- B. List on the Title Page, as authors, one or more persons or
4218- entities responsible for authorship of the modifications in
4219- the Modified Version, together with at least five of the
4220- principal authors of the Document (all of its principal
4221- authors, if it has fewer than five), unless they release you
4222- from this requirement.
4223-
4224- C. State on the Title page the name of the publisher of the
4225- Modified Version, as the publisher.
4226-
4227- D. Preserve all the copyright notices of the Document.
4228-
4229- E. Add an appropriate copyright notice for your modifications
4230- adjacent to the other copyright notices.
4231-
4232- F. Include, immediately after the copyright notices, a license
4233- notice giving the public permission to use the Modified
4234- Version under the terms of this License, in the form shown in
4235- the Addendum below.
4236-
4237- G. Preserve in that license notice the full lists of Invariant
4238- Sections and required Cover Texts given in the Document's
4239- license notice.
4240-
4241- H. Include an unaltered copy of this License.
4242-
4243- I. Preserve the section Entitled "History", Preserve its Title,
4244- and add to it an item stating at least the title, year, new
4245- authors, and publisher of the Modified Version as given on the
4246- Title Page. If there is no section Entitled "History" in the
4247- Document, create one stating the title, year, authors, and
4248- publisher of the Document as given on its Title Page, then add
4249- an item describing the Modified Version as stated in the
4250- previous sentence.
4251-
4252- J. Preserve the network location, if any, given in the Document
4253- for public access to a Transparent copy of the Document, and
4254- likewise the network locations given in the Document for
4255- previous versions it was based on. These may be placed in the
4256- "History" section. You may omit a network location for a work
4257- that was published at least four years before the Document
4258- itself, or if the original publisher of the version it refers
4259- to gives permission.
4260-
4261- K. For any section Entitled "Acknowledgements" or "Dedications",
4262- Preserve the Title of the section, and preserve in the section
4263- all the substance and tone of each of the contributor
4264- acknowledgements and/or dedications given therein.
4265-
4266- L. Preserve all the Invariant Sections of the Document, unaltered
4267- in their text and in their titles. Section numbers or the
4268- equivalent are not considered part of the section titles.
4269-
4270- M. Delete any section Entitled "Endorsements". Such a section
4271- may not be included in the Modified Version.
4272-
4273- N. Do not retitle any existing section to be Entitled
4274- "Endorsements" or to conflict in title with any Invariant
4275- Section.
4276-
4277- O. Preserve any Warranty Disclaimers.
4278-
4279- If the Modified Version includes new front-matter sections or
4280- appendices that qualify as Secondary Sections and contain no
4281- material copied from the Document, you may at your option designate
4282- some or all of these sections as invariant. To do this, add their
4283- titles to the list of Invariant Sections in the Modified Version's
4284- license notice. These titles must be distinct from any other
4285- section titles.
4286-
4287- You may add a section Entitled "Endorsements", provided it contains
4288- nothing but endorsements of your Modified Version by various
4289- parties--for example, statements of peer review or that the text
4290- has been approved by an organization as the authoritative
4291- definition of a standard.
4292-
4293- You may add a passage of up to five words as a Front-Cover Text,
4294- and a passage of up to 25 words as a Back-Cover Text, to the end of
4295- the list of Cover Texts in the Modified Version. Only one passage
4296- of Front-Cover Text and one of Back-Cover Text may be added by (or
4297- through arrangements made by) any one entity. If the Document
4298- already includes a cover text for the same cover, previously added
4299- by you or by arrangement made by the same entity you are acting on
4300- behalf of, you may not add another; but you may replace the old
4301- one, on explicit permission from the previous publisher that added
4302- the old one.
4303-
4304- The author(s) and publisher(s) of the Document do not by this
4305- License give permission to use their names for publicity for or to
4306- assert or imply endorsement of any Modified Version.
4307-
4308- 5. COMBINING DOCUMENTS
4309-
4310- You may combine the Document with other documents released under
4311- this License, under the terms defined in section 4 above for
4312- modified versions, provided that you include in the combination all
4313- of the Invariant Sections of all of the original documents,
4314- unmodified, and list them all as Invariant Sections of your
4315- combined work in its license notice, and that you preserve all
4316- their Warranty Disclaimers.
4317-
4318- The combined work need only contain one copy of this License, and
4319- multiple identical Invariant Sections may be replaced with a single
4320- copy. If there are multiple Invariant Sections with the same name
4321- but different contents, make the title of each such section unique
4322- by adding at the end of it, in parentheses, the name of the
4323- original author or publisher of that section if known, or else a
4324- unique number. Make the same adjustment to the section titles in
4325- the list of Invariant Sections in the license notice of the
4326- combined work.
4327-
4328- In the combination, you must combine any sections Entitled
4329- "History" in the various original documents, forming one section
4330- Entitled "History"; likewise combine any sections Entitled
4331- "Acknowledgements", and any sections Entitled "Dedications". You
4332- must delete all sections Entitled "Endorsements."
4333-
4334- 6. COLLECTIONS OF DOCUMENTS
4335-
4336- You may make a collection consisting of the Document and other
4337- documents released under this License, and replace the individual
4338- copies of this License in the various documents with a single copy
4339- that is included in the collection, provided that you follow the
4340- rules of this License for verbatim copying of each of the documents
4341- in all other respects.
4342-
4343- You may extract a single document from such a collection, and
4344- distribute it individually under this License, provided you insert
4345- a copy of this License into the extracted document, and follow this
4346- License in all other respects regarding verbatim copying of that
4347- document.
4348-
4349- 7. AGGREGATION WITH INDEPENDENT WORKS
4350-
4351- A compilation of the Document or its derivatives with other
4352- separate and independent documents or works, in or on a volume of a
4353- storage or distribution medium, is called an "aggregate" if the
4354- copyright resulting from the compilation is not used to limit the
4355- legal rights of the compilation's users beyond what the individual
4356- works permit. When the Document is included in an aggregate, this
4357- License does not apply to the other works in the aggregate which
4358- are not themselves derivative works of the Document.
4359-
4360- If the Cover Text requirement of section 3 is applicable to these
4361- copies of the Document, then if the Document is less than one half
4362- of the entire aggregate, the Document's Cover Texts may be placed
4363- on covers that bracket the Document within the aggregate, or the
4364- electronic equivalent of covers if the Document is in electronic
4365- form. Otherwise they must appear on printed covers that bracket
4366- the whole aggregate.
4367-
4368- 8. TRANSLATION
4369-
4370- Translation is considered a kind of modification, so you may
4371- distribute translations of the Document under the terms of section
4372- 4. Replacing Invariant Sections with translations requires special
4373- permission from their copyright holders, but you may include
4374- translations of some or all Invariant Sections in addition to the
4375- original versions of these Invariant Sections. You may include a
4376- translation of this License, and all the license notices in the
4377- Document, and any Warranty Disclaimers, provided that you also
4378- include the original English version of this License and the
4379- original versions of those notices and disclaimers. In case of a
4380- disagreement between the translation and the original version of
4381- this License or a notice or disclaimer, the original version will
4382- prevail.
4383-
4384- If a section in the Document is Entitled "Acknowledgements",
4385- "Dedications", or "History", the requirement (section 4) to
4386- Preserve its Title (section 1) will typically require changing the
4387- actual title.
4388-
4389- 9. TERMINATION
4390-
4391- You may not copy, modify, sublicense, or distribute the Document
4392- except as expressly provided under this License. Any attempt
4393- otherwise to copy, modify, sublicense, or distribute it is void,
4394- and will automatically terminate your rights under this License.
4395-
4396- However, if you cease all violation of this License, then your
4397- license from a particular copyright holder is reinstated (a)
4398- provisionally, unless and until the copyright holder explicitly and
4399- finally terminates your license, and (b) permanently, if the
4400- copyright holder fails to notify you of the violation by some
4401- reasonable means prior to 60 days after the cessation.
4402-
4403- Moreover, your license from a particular copyright holder is
4404- reinstated permanently if the copyright holder notifies you of the
4405- violation by some reasonable means, this is the first time you have
4406- received notice of violation of this License (for any work) from
4407- that copyright holder, and you cure the violation prior to 30 days
4408- after your receipt of the notice.
4409-
4410- Termination of your rights under this section does not terminate
4411- the licenses of parties who have received copies or rights from you
4412- under this License. If your rights have been terminated and not
4413- permanently reinstated, receipt of a copy of some or all of the
4414- same material does not give you any rights to use it.
4415-
4416- 10. FUTURE REVISIONS OF THIS LICENSE
4417-
4418- The Free Software Foundation may publish new, revised versions of
4419- the GNU Free Documentation License from time to time. Such new
4420- versions will be similar in spirit to the present version, but may
4421- differ in detail to address new problems or concerns. See
4422- <http://www.gnu.org/copyleft/>.
4423-
4424- Each version of the License is given a distinguishing version
4425- number. If the Document specifies that a particular numbered
4426- version of this License "or any later version" applies to it, you
4427- have the option of following the terms and conditions either of
4428- that specified version or of any later version that has been
4429- published (not as a draft) by the Free Software Foundation. If the
4430- Document does not specify a version number of this License, you may
4431- choose any version ever published (not as a draft) by the Free
4432- Software Foundation. If the Document specifies that a proxy can
4433- decide which future versions of this License can be used, that
4434- proxy's public statement of acceptance of a version permanently
4435- authorizes you to choose that version for the Document.
4436-
4437- 11. RELICENSING
4438-
4439- "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
4440- World Wide Web server that publishes copyrightable works and also
4441- provides prominent facilities for anybody to edit those works. A
4442- public wiki that anybody can edit is an example of such a server.
4443- A "Massive Multiauthor Collaboration" (or "MMC") contained in the
4444- site means any set of copyrightable works thus published on the MMC
4445- site.
4446-
4447- "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
4448- license published by Creative Commons Corporation, a not-for-profit
4449- corporation with a principal place of business in San Francisco,
4450- California, as well as future copyleft versions of that license
4451- published by that same organization.
4452-
4453- "Incorporate" means to publish or republish a Document, in whole or
4454- in part, as part of another Document.
4455-
4456- An MMC is "eligible for relicensing" if it is licensed under this
4457- License, and if all works that were first published under this
4458- License somewhere other than this MMC, and subsequently
4459- incorporated in whole or in part into the MMC, (1) had no cover
4460- texts or invariant sections, and (2) were thus incorporated prior
4461- to November 1, 2008.
4462-
4463- The operator of an MMC Site may republish an MMC contained in the
4464- site under CC-BY-SA on the same site at any time before August 1,
4465- 2009, provided the MMC is eligible for relicensing.
4466-
4467-ADDENDUM: How to use this License for your documents
4468-====================================================
4469-
4470-To use this License in a document you have written, include a copy of
4471-the License in the document and put the following copyright and license
4472-notices just after the title page:
4473-
4474- Copyright (C) YEAR YOUR NAME.
4475- Permission is granted to copy, distribute and/or modify this document
4476- under the terms of the GNU Free Documentation License, Version 1.3
4477- or any later version published by the Free Software Foundation;
4478- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
4479- Texts. A copy of the license is included in the section entitled ``GNU
4480- Free Documentation License''.
4481-
4482- If you have Invariant Sections, Front-Cover Texts and Back-Cover
4483-Texts, replace the "with...Texts." line with this:
4484-
4485- with the Invariant Sections being LIST THEIR TITLES, with
4486- the Front-Cover Texts being LIST, and with the Back-Cover Texts
4487- being LIST.
4488-
4489- If you have Invariant Sections without Cover Texts, or some other
4490-combination of the three, merge those two alternatives to suit the
4491-situation.
4492-
4493- If your document contains nontrivial examples of program code, we
4494-recommend releasing these examples in parallel under your choice of free
4495-software license, such as the GNU General Public License, to permit
4496-their use in free software.
4497-
4498-
4499-File: libitm.info, Node: Index, Prev: GNU Free Documentation License, Up: Top
4500-
4501-Index
4502-*****
4503-
4504-[index]
4505-* Menu:
4506-
4507-* FDL, GNU Free Documentation License: GNU Free Documentation License.
4508- (line 6)
4509-* Introduction: Top. (line 6)
4510-
4511-
4512-
4513-Tag Table:
4514-Node: Top1141
4515-Node: Enabling libitm2045
4516-Node: C/C++ Language Constructs for TM2440
4517-Node: The libitm ABI3923
4518-Ref: txn-code-properties7721
4519-Node: Internals18026
4520-Ref: serial-lock-impl28064
4521-Ref: progress-guarantees32825
4522-Node: GNU Free Documentation License35103
4523-Node: Index60224
4524-
4525-End Tag Table
4526diff -Naur gcc-4.8.2.orig/libquadmath/libquadmath.info gcc-4.8.2/libquadmath/libquadmath.info
4527--- gcc-4.8.2.orig/libquadmath/libquadmath.info 2013-10-16 03:18:56.000000000 -0500
4528+++ gcc-4.8.2/libquadmath/libquadmath.info 1969-12-31 18:00:00.000000000 -0600
4529@@ -1,808 +0,0 @@
4530-This is libquadmath.info, produced by makeinfo version 5.1 from
4531-libquadmath.texi.
4532-
4533-Copyright (C) 2010-2013 Free Software Foundation, Inc.
4534-
4535- Permission is granted to copy, distribute and/or modify this
4536- document under the terms of the GNU Free Documentation License,
4537- Version 1.2 or any later version published by the Free Software
4538- Foundation; with no Invariant Sections, with the Front-Cover Texts
4539- being "A GNU Manual," and with the Back-Cover Texts as in (a)
4540- below. A copy of the license is included in the section entitled
4541- "GNU Free Documentation License."
4542-
4543- (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
4544- modify this GNU manual.
4545-INFO-DIR-SECTION GNU Libraries
4546-START-INFO-DIR-ENTRY
4547-* libquadmath: (libquadmath). GCC Quad-Precision Math Library
4548-END-INFO-DIR-ENTRY
4549-
4550- This manual documents the GCC Quad-Precision Math Library API.
4551-
4552- Published by the Free Software Foundation 51 Franklin Street, Fifth
4553-Floor Boston, MA 02110-1301 USA
4554-
4555- Copyright (C) 2010-2013 Free Software Foundation, Inc.
4556-
4557- Permission is granted to copy, distribute and/or modify this
4558- document under the terms of the GNU Free Documentation License,
4559- Version 1.2 or any later version published by the Free Software
4560- Foundation; with no Invariant Sections, with the Front-Cover Texts
4561- being "A GNU Manual," and with the Back-Cover Texts as in (a)
4562- below. A copy of the license is included in the section entitled
4563- "GNU Free Documentation License."
4564-
4565- (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
4566- modify this GNU manual.
4567-
4568-
4569-File: libquadmath.info, Node: Top, Next: Typedef and constants, Up: (dir)
4570-
4571-Introduction
4572-************
4573-
4574-This manual documents the usage of libquadmath, the GCC Quad-Precision
4575-Math Library Application Programming Interface (API).
4576-
4577-* Menu:
4578-
4579-* Typedef and constants:: Defined data types and constants
4580-* Math Library Routines:: The Libquadmath math runtime application
4581- programming interface.
4582-* I/O Library Routines:: The Libquadmath I/O runtime application
4583- programming interface.
4584-* GNU Free Documentation License::
4585- How you can copy and share this manual.
4586-* Reporting Bugs:: How to report bugs in GCC Libquadmath.
4587-
4588-
4589-File: libquadmath.info, Node: Typedef and constants, Next: Math Library Routines, Prev: Top, Up: Top
4590-
4591-1 Typedef and constants
4592-***********************
4593-
4594-The following data type has been defined via 'typedef'.
4595-
4596-'__complex128': '__float128'-based complex number
4597-
4598- The following macros are defined, which give the numeric limits of
4599-the '__float128' data type.
4600-
4601-'FLT128_MAX': largest finite number
4602-'FLT128_MIN': smallest positive number with full precision
4603-'FLT128_EPSILON': difference between 1 and the next larger
4604- representable number
4605-'FLT128_DENORM_MIN': smallest positive denormalized number
4606-'FLT128_MANT_DIG': number of digits in the mantissa (bit precision)
4607-'FLT128_MIN_EXP': maximal negative exponent
4608-'FLT128_MAX_EXP': maximal positive exponent
4609-'FLT128_DIG': number of decimal digits in the mantissa
4610-'FLT128_MIN_10_EXP': maximal negative decimal exponent
4611-'FLT128_MAX_10_EXP': maximal positive decimal exponent
4612-
4613- The following mathematical constants of type '__float128' are
4614-defined.
4615-
4616-'M_Eq': the constant e (Euler's number)
4617-'M_LOG2Eq': binary logarithm of 2
4618-'M_LOG10Eq': common, decimal logarithm of 2
4619-'M_LN2q': natural logarithm of 2
4620-'M_LN10q': natural logarithm of 10
4621-'M_PIq': pi
4622-'M_PI_2q': pi divided by two
4623-'M_PI_4q': pi divided by four
4624-'M_1_PIq': one over pi
4625-'M_2_PIq': one over two pi
4626-'M_2_SQRTPIq': two over square root of pi
4627-'M_SQRT2q': square root of 2
4628-'M_SQRT1_2q': one over square root of 2
4629-
4630-
4631-File: libquadmath.info, Node: Math Library Routines, Next: I/O Library Routines, Prev: Typedef and constants, Up: Top
4632-
4633-2 Math Library Routines
4634-***********************
4635-
4636-The following mathematical functions are available:
4637-
4638-'acosq': arc cosine function
4639-'acoshq': inverse hyperbolic cosine function
4640-'asinq': arc sine function
4641-'asinhq': inverse hyperbolic sine function
4642-'atanq': arc tangent function
4643-'atanhq': inverse hyperbolic tangent function
4644-'atan2q': arc tangent function
4645-'cbrtq': cube root function
4646-'ceilq': ceiling value function
4647-'copysignq': copy sign of a number
4648-'coshq': hyperbolic cosine function
4649-'cosq': cosine function
4650-'erfq': error function
4651-'erfcq': complementary error function
4652-'expq': exponential function
4653-'expm1q': exponential minus 1 function
4654-'fabsq': absolute value function
4655-'fdimq': positive difference function
4656-'finiteq': check finiteness of value
4657-'floorq': floor value function
4658-'fmaq': fused multiply and add
4659-'fmaxq': determine maximum of two values
4660-'fminq': determine minimum of two values
4661-'fmodq': remainder value function
4662-'frexpq': extract mantissa and exponent
4663-'hypotq': Eucledian distance function
4664-'ilogbq': get exponent of the value
4665-'isinfq': check for infinity
4666-'isnanq': check for not a number
4667-'j0q': Bessel function of the first kind, first order
4668-'j1q': Bessel function of the first kind, second order
4669-'jnq': Bessel function of the first kind, N-th order
4670-'ldexpq': load exponent of the value
4671-'lgammaq': logarithmic gamma function
4672-'llrintq': round to nearest integer value
4673-'llroundq': round to nearest integer value away from zero
4674-'logq': natural logarithm function
4675-'log10q': base 10 logarithm function
4676-'log1pq': compute natural logarithm of the value plus one
4677-'log2q': base 2 logarithm function
4678-'lrintq': round to nearest integer value
4679-'lroundq': round to nearest integer value away from zero
4680-'modfq': decompose the floating-point number
4681-'nanq': return quiet NaN
4682-'nearbyintq': round to nearest integer
4683-'nextafterq': next representable floating-point number
4684-'powq': power function
4685-'remainderq': remainder function
4686-'remquoq': remainder and part of quotient
4687-'rintq': round-to-nearest integral value
4688-'roundq': round-to-nearest integral value, return '__float128'
4689-'scalblnq': compute exponent using 'FLT_RADIX'
4690-'scalbnq': compute exponent using 'FLT_RADIX'
4691-'signbitq': return sign bit
4692-'sincosq': calculate sine and cosine simulataneously
4693-'sinhq': hyperbolic sine function
4694-'sinq': sine function
4695-'sqrtq': square root function
4696-'tanq': tangent function
4697-'tanhq': hyperbolic tangent function
4698-'tgammaq': true gamma function
4699-'truncq': round to integer, towards zero
4700-'y0q': Bessel function of the second kind, first order
4701-'y1q': Bessel function of the second kind, second order
4702-'ynq': Bessel function of the second kind, N-th order
4703-'cabsq' complex absolute value function
4704-'cargq': calculate the argument
4705-'cimagq' imaginary part of complex number
4706-'crealq': real part of complex number
4707-'cacoshq': complex arc hyperbolic cosine function
4708-'cacosq': complex arc cosine function
4709-'casinhq': complex arc hyperbolic sine function
4710-'casinq': complex arc sine function
4711-'catanhq': complex arc hyperbolic tangent function
4712-'catanq': complex arc tangent function
4713-'ccosq' complex cosine function:
4714-'ccoshq': complex hyperbolic cosine function
4715-'cexpq': complex exponential function
4716-'cexpiq': computes the exponential function of "i" times a
4717- real value
4718-'clogq': complex natural logarithm
4719-'clog10q': complex base 10 logarithm
4720-'conjq': complex conjugate function
4721-'cpowq': complex power function
4722-'cprojq': project into Riemann Sphere
4723-'csinq': complex sine function
4724-'csinhq': complex hyperbolic sine function
4725-'csqrtq': complex square root
4726-'ctanq': complex tangent function
4727-'ctanhq': complex hyperbolic tangent function
4728-
4729-
4730-File: libquadmath.info, Node: I/O Library Routines, Next: GNU Free Documentation License, Prev: Math Library Routines, Up: Top
4731-
4732-3 I/O Library Routines
4733-**********************
4734-
4735-* Menu:
4736-
4737-* 'strtoflt128': strtoflt128, Convert from string
4738-* 'quadmath_snprintf': quadmath_snprintf, Convert to string
4739-
4740-
4741-File: libquadmath.info, Node: strtoflt128, Next: quadmath_snprintf, Up: I/O Library Routines
4742-
4743-3.1 'strtoflt128' -- Convert from string
4744-========================================
4745-
4746-The function 'strtoflt128' converts a string into a '__float128' number.
4747-
4748-Syntax
4749- '__float128 strtoflt128 (const char *s, char **sp)'
4750-
4751-_Arguments_:
4752- S input string
4753- SP the address of the next character in the string
4754-
4755- The argument SP contains, if not 'NULL', the address of the next
4756- character following the parts of the string, which have been read.
4757-
4758-Example
4759- #include <quadmath.h>
4760-
4761- int main ()
4762- {
4763- __float128 r;
4764-
4765- r = strtoflt128 ("1.2345678", NULL);
4766-
4767- return 0;
4768- }
4769-
4770-
4771-File: libquadmath.info, Node: quadmath_snprintf, Prev: strtoflt128, Up: I/O Library Routines
4772-
4773-3.2 'quadmath_snprintf' -- Convert to string
4774-============================================
4775-
4776-The function 'quadmath_snprintf' converts a '__float128' floating-point
4777-number into a string. It is a specialized alternative to 'snprintf',
4778-where the format string is restricted to a single conversion specifier
4779-with 'Q' modifier and conversion specifier 'e', 'E', 'f', 'F', 'g', 'G',
4780-'a' or 'A', with no extra characters before or after the conversion
4781-specifier. The '%m$' or '*m$' style must not be used in the format.
4782-
4783-Syntax
4784- 'int quadmath_snprintf (char *s, size_t size, const char *format,
4785- ...)'
4786-
4787-_Arguments_:
4788- S output string
4789- SIZE byte size of the string, including tailing NUL
4790- FORMAT conversion specifier string
4791-
4792-Note
4793- On some targets when supported by the C library hooks are installed
4794- for 'printf' family of functions, so that 'printf ("%Qe", 1.2Q);'
4795- etc. works too.
4796-
4797-Example
4798- #include <quadmath.h>
4799- #include <stdlib.h>
4800- #include <stdio.h>
4801-
4802- int main ()
4803- {
4804- __float128 r;
4805- int prec = 20;
4806- int width = 46;
4807- char buf[128];
4808-
4809- r = 2.0q;
4810- r = sqrtq (r);
4811- int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r);
4812- if ((size_t) n < sizeof buf)
4813- printf ("%s\n", buf);
4814- /* Prints: +1.41421356237309504880e+00 */
4815- quadmath_snprintf (buf, sizeof buf, "%Qa", r);
4816- if ((size_t) n < sizeof buf)
4817- printf ("%s\n", buf);
4818- /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */
4819- n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r);
4820- if (n > -1)
4821- {
4822- char *str = malloc (n + 1);
4823- if (str)
4824- {
4825- quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r);
4826- printf ("%s\n", str);
4827- /* Prints: +1.41421356237309504880e+00 */
4828- }
4829- free (str);
4830- }
4831- return 0;
4832- }
4833-
4834-
4835-File: libquadmath.info, Node: GNU Free Documentation License, Next: Reporting Bugs, Prev: I/O Library Routines, Up: Top
4836-
4837-GNU Free Documentation License
4838-******************************
4839-
4840- Version 1.3, 3 November 2008
4841-
4842- Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
4843- <http://fsf.org/>
4844-
4845- Everyone is permitted to copy and distribute verbatim copies
4846- of this license document, but changing it is not allowed.
4847-
4848- 0. PREAMBLE
4849-
4850- The purpose of this License is to make a manual, textbook, or other
4851- functional and useful document "free" in the sense of freedom: to
4852- assure everyone the effective freedom to copy and redistribute it,
4853- with or without modifying it, either commercially or
4854- noncommercially. Secondarily, this License preserves for the
4855- author and publisher a way to get credit for their work, while not
4856- being considered responsible for modifications made by others.
4857-
4858- This License is a kind of "copyleft", which means that derivative
4859- works of the document must themselves be free in the same sense.
4860- It complements the GNU General Public License, which is a copyleft
4861- license designed for free software.
4862-
4863- We have designed this License in order to use it for manuals for
4864- free software, because free software needs free documentation: a
4865- free program should come with manuals providing the same freedoms
4866- that the software does. But this License is not limited to
4867- software manuals; it can be used for any textual work, regardless
4868- of subject matter or whether it is published as a printed book. We
4869- recommend this License principally for works whose purpose is
4870- instruction or reference.
4871-
4872- 1. APPLICABILITY AND DEFINITIONS
4873-
4874- This License applies to any manual or other work, in any medium,
4875- that contains a notice placed by the copyright holder saying it can
4876- be distributed under the terms of this License. Such a notice
4877- grants a world-wide, royalty-free license, unlimited in duration,
4878- to use that work under the conditions stated herein. The
4879- "Document", below, refers to any such manual or work. Any member
4880- of the public is a licensee, and is addressed as "you". You accept
4881- the license if you copy, modify or distribute the work in a way
4882- requiring permission under copyright law.
4883-
4884- A "Modified Version" of the Document means any work containing the
4885- Document or a portion of it, either copied verbatim, or with
4886- modifications and/or translated into another language.
4887-
4888- A "Secondary Section" is a named appendix or a front-matter section
4889- of the Document that deals exclusively with the relationship of the
4890- publishers or authors of the Document to the Document's overall
4891- subject (or to related matters) and contains nothing that could
4892- fall directly within that overall subject. (Thus, if the Document
4893- is in part a textbook of mathematics, a Secondary Section may not
4894- explain any mathematics.) The relationship could be a matter of
4895- historical connection with the subject or with related matters, or
4896- of legal, commercial, philosophical, ethical or political position
4897- regarding them.
4898-
4899- The "Invariant Sections" are certain Secondary Sections whose
4900- titles are designated, as being those of Invariant Sections, in the
4901- notice that says that the Document is released under this License.
4902- If a section does not fit the above definition of Secondary then it
4903- is not allowed to be designated as Invariant. The Document may
4904- contain zero Invariant Sections. If the Document does not identify
4905- any Invariant Sections then there are none.
4906-
4907- The "Cover Texts" are certain short passages of text that are
4908- listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4909- that says that the Document is released under this License. A
4910- Front-Cover Text may be at most 5 words, and a Back-Cover Text may
4911- be at most 25 words.
4912-
4913- A "Transparent" copy of the Document means a machine-readable copy,
4914- represented in a format whose specification is available to the
4915- general public, that is suitable for revising the document
4916- straightforwardly with generic text editors or (for images composed
4917- of pixels) generic paint programs or (for drawings) some widely
4918- available drawing editor, and that is suitable for input to text
4919- formatters or for automatic translation to a variety of formats
4920- suitable for input to text formatters. A copy made in an otherwise
4921- Transparent file format whose markup, or absence of markup, has
4922- been arranged to thwart or discourage subsequent modification by
4923- readers is not Transparent. An image format is not Transparent if
4924- used for any substantial amount of text. A copy that is not
4925- "Transparent" is called "Opaque".
4926-
4927- Examples of suitable formats for Transparent copies include plain
4928- ASCII without markup, Texinfo input format, LaTeX input format,
4929- SGML or XML using a publicly available DTD, and standard-conforming
4930- simple HTML, PostScript or PDF designed for human modification.
4931- Examples of transparent image formats include PNG, XCF and JPG.
4932- Opaque formats include proprietary formats that can be read and
4933- edited only by proprietary word processors, SGML or XML for which
4934- the DTD and/or processing tools are not generally available, and
4935- the machine-generated HTML, PostScript or PDF produced by some word
4936- processors for output purposes only.
4937-
4938- The "Title Page" means, for a printed book, the title page itself,
4939- plus such following pages as are needed to hold, legibly, the
4940- material this License requires to appear in the title page. For
4941- works in formats which do not have any title page as such, "Title
4942- Page" means the text near the most prominent appearance of the
4943- work's title, preceding the beginning of the body of the text.
4944-
4945- The "publisher" means any person or entity that distributes copies
4946- of the Document to the public.
4947-
4948- A section "Entitled XYZ" means a named subunit of the Document
4949- whose title either is precisely XYZ or contains XYZ in parentheses
4950- following text that translates XYZ in another language. (Here XYZ
4951- stands for a specific section name mentioned below, such as
4952- "Acknowledgements", "Dedications", "Endorsements", or "History".)
4953- To "Preserve the Title" of such a section when you modify the
4954- Document means that it remains a section "Entitled XYZ" according
4955- to this definition.
4956-
4957- The Document may include Warranty Disclaimers next to the notice
4958- which states that this License applies to the Document. These
4959- Warranty Disclaimers are considered to be included by reference in
4960- this License, but only as regards disclaiming warranties: any other
4961- implication that these Warranty Disclaimers may have is void and
4962- has no effect on the meaning of this License.
4963-
4964- 2. VERBATIM COPYING
4965-
4966- You may copy and distribute the Document in any medium, either
4967- commercially or noncommercially, provided that this License, the
4968- copyright notices, and the license notice saying this License
4969- applies to the Document are reproduced in all copies, and that you
4970- add no other conditions whatsoever to those of this License. You
4971- may not use technical measures to obstruct or control the reading
4972- or further copying of the copies you make or distribute. However,
4973- you may accept compensation in exchange for copies. If you
4974- distribute a large enough number of copies you must also follow the
4975- conditions in section 3.
4976-
4977- You may also lend copies, under the same conditions stated above,
4978- and you may publicly display copies.
4979-
4980- 3. COPYING IN QUANTITY
4981-
4982- If you publish printed copies (or copies in media that commonly
4983- have printed covers) of the Document, numbering more than 100, and
4984- the Document's license notice requires Cover Texts, you must
4985- enclose the copies in covers that carry, clearly and legibly, all
4986- these Cover Texts: Front-Cover Texts on the front cover, and
4987- Back-Cover Texts on the back cover. Both covers must also clearly
4988- and legibly identify you as the publisher of these copies. The
4989- front cover must present the full title with all words of the title
4990- equally prominent and visible. You may add other material on the
4991- covers in addition. Copying with changes limited to the covers, as
4992- long as they preserve the title of the Document and satisfy these
4993- conditions, can be treated as verbatim copying in other respects.
4994-
4995- If the required texts for either cover are too voluminous to fit
4996- legibly, you should put the first ones listed (as many as fit
4997- reasonably) on the actual cover, and continue the rest onto
4998- adjacent pages.
4999-
5000- If you publish or distribute Opaque copies of the Document
5001- numbering more than 100, you must either include a machine-readable
5002- Transparent copy along with each Opaque copy, or state in or with
5003- each Opaque copy a computer-network location from which the general
5004- network-using public has access to download using public-standard
5005- network protocols a complete Transparent copy of the Document, free
5006- of added material. If you use the latter option, you must take
5007- reasonably prudent steps, when you begin distribution of Opaque
5008- copies in quantity, to ensure that this Transparent copy will
5009- remain thus accessible at the stated location until at least one
5010- year after the last time you distribute an Opaque copy (directly or
5011- through your agents or retailers) of that edition to the public.
5012-
5013- It is requested, but not required, that you contact the authors of
5014- the Document well before redistributing any large number of copies,
5015- to give them a chance to provide you with an updated version of the
5016- Document.
5017-
5018- 4. MODIFICATIONS
5019-
5020- You may copy and distribute a Modified Version of the Document
5021- under the conditions of sections 2 and 3 above, provided that you
5022- release the Modified Version under precisely this License, with the
5023- Modified Version filling the role of the Document, thus licensing
5024- distribution and modification of the Modified Version to whoever
5025- possesses a copy of it. In addition, you must do these things in
5026- the Modified Version:
5027-
5028- A. Use in the Title Page (and on the covers, if any) a title
5029- distinct from that of the Document, and from those of previous
5030- versions (which should, if there were any, be listed in the
5031- History section of the Document). You may use the same title
5032- as a previous version if the original publisher of that
5033- version gives permission.
5034-
5035- B. List on the Title Page, as authors, one or more persons or
5036- entities responsible for authorship of the modifications in
5037- the Modified Version, together with at least five of the
5038- principal authors of the Document (all of its principal
5039- authors, if it has fewer than five), unless they release you
5040- from this requirement.
5041-
5042- C. State on the Title page the name of the publisher of the
5043- Modified Version, as the publisher.
5044-
5045- D. Preserve all the copyright notices of the Document.
5046-
5047- E. Add an appropriate copyright notice for your modifications
5048- adjacent to the other copyright notices.
5049-
5050- F. Include, immediately after the copyright notices, a license
5051- notice giving the public permission to use the Modified
5052- Version under the terms of this License, in the form shown in
5053- the Addendum below.
5054-
5055- G. Preserve in that license notice the full lists of Invariant
5056- Sections and required Cover Texts given in the Document's
5057- license notice.
5058-
5059- H. Include an unaltered copy of this License.
5060-
5061- I. Preserve the section Entitled "History", Preserve its Title,
5062- and add to it an item stating at least the title, year, new
5063- authors, and publisher of the Modified Version as given on the
5064- Title Page. If there is no section Entitled "History" in the
5065- Document, create one stating the title, year, authors, and
5066- publisher of the Document as given on its Title Page, then add
5067- an item describing the Modified Version as stated in the
5068- previous sentence.
5069-
5070- J. Preserve the network location, if any, given in the Document
5071- for public access to a Transparent copy of the Document, and
5072- likewise the network locations given in the Document for
5073- previous versions it was based on. These may be placed in the
5074- "History" section. You may omit a network location for a work
5075- that was published at least four years before the Document
5076- itself, or if the original publisher of the version it refers
5077- to gives permission.
5078-
5079- K. For any section Entitled "Acknowledgements" or "Dedications",
5080- Preserve the Title of the section, and preserve in the section
5081- all the substance and tone of each of the contributor
5082- acknowledgements and/or dedications given therein.
5083-
5084- L. Preserve all the Invariant Sections of the Document, unaltered
5085- in their text and in their titles. Section numbers or the
5086- equivalent are not considered part of the section titles.
5087-
5088- M. Delete any section Entitled "Endorsements". Such a section
5089- may not be included in the Modified Version.
5090-
5091- N. Do not retitle any existing section to be Entitled
5092- "Endorsements" or to conflict in title with any Invariant
5093- Section.
5094-
5095- O. Preserve any Warranty Disclaimers.
5096-
5097- If the Modified Version includes new front-matter sections or
5098- appendices that qualify as Secondary Sections and contain no
5099- material copied from the Document, you may at your option designate
5100- some or all of these sections as invariant. To do this, add their
5101- titles to the list of Invariant Sections in the Modified Version's
5102- license notice. These titles must be distinct from any other
5103- section titles.
5104-
5105- You may add a section Entitled "Endorsements", provided it contains
5106- nothing but endorsements of your Modified Version by various
5107- parties--for example, statements of peer review or that the text
5108- has been approved by an organization as the authoritative
5109- definition of a standard.
5110-
5111- You may add a passage of up to five words as a Front-Cover Text,
5112- and a passage of up to 25 words as a Back-Cover Text, to the end of
5113- the list of Cover Texts in the Modified Version. Only one passage
5114- of Front-Cover Text and one of Back-Cover Text may be added by (or
5115- through arrangements made by) any one entity. If the Document
5116- already includes a cover text for the same cover, previously added
5117- by you or by arrangement made by the same entity you are acting on
5118- behalf of, you may not add another; but you may replace the old
5119- one, on explicit permission from the previous publisher that added
5120- the old one.
5121-
5122- The author(s) and publisher(s) of the Document do not by this
5123- License give permission to use their names for publicity for or to
5124- assert or imply endorsement of any Modified Version.
5125-
5126- 5. COMBINING DOCUMENTS
5127-
5128- You may combine the Document with other documents released under
5129- this License, under the terms defined in section 4 above for
5130- modified versions, provided that you include in the combination all
5131- of the Invariant Sections of all of the original documents,
5132- unmodified, and list them all as Invariant Sections of your
5133- combined work in its license notice, and that you preserve all
5134- their Warranty Disclaimers.
5135-
5136- The combined work need only contain one copy of this License, and
5137- multiple identical Invariant Sections may be replaced with a single
5138- copy. If there are multiple Invariant Sections with the same name
5139- but different contents, make the title of each such section unique
5140- by adding at the end of it, in parentheses, the name of the
5141- original author or publisher of that section if known, or else a
5142- unique number. Make the same adjustment to the section titles in
5143- the list of Invariant Sections in the license notice of the
5144- combined work.
5145-
5146- In the combination, you must combine any sections Entitled
5147- "History" in the various original documents, forming one section
5148- Entitled "History"; likewise combine any sections Entitled
5149- "Acknowledgements", and any sections Entitled "Dedications". You
5150- must delete all sections Entitled "Endorsements."
5151-
5152- 6. COLLECTIONS OF DOCUMENTS
5153-
5154- You may make a collection consisting of the Document and other
5155- documents released under this License, and replace the individual
5156- copies of this License in the various documents with a single copy
5157- that is included in the collection, provided that you follow the
5158- rules of this License for verbatim copying of each of the documents
5159- in all other respects.
5160-
5161- You may extract a single document from such a collection, and
5162- distribute it individually under this License, provided you insert
5163- a copy of this License into the extracted document, and follow this
5164- License in all other respects regarding verbatim copying of that
5165- document.
5166-
5167- 7. AGGREGATION WITH INDEPENDENT WORKS
5168-
5169- A compilation of the Document or its derivatives with other
5170- separate and independent documents or works, in or on a volume of a
5171- storage or distribution medium, is called an "aggregate" if the
5172- copyright resulting from the compilation is not used to limit the
5173- legal rights of the compilation's users beyond what the individual
5174- works permit. When the Document is included in an aggregate, this
5175- License does not apply to the other works in the aggregate which
5176- are not themselves derivative works of the Document.
5177-
5178- If the Cover Text requirement of section 3 is applicable to these
5179- copies of the Document, then if the Document is less than one half
5180- of the entire aggregate, the Document's Cover Texts may be placed
5181- on covers that bracket the Document within the aggregate, or the
5182- electronic equivalent of covers if the Document is in electronic
5183- form. Otherwise they must appear on printed covers that bracket
5184- the whole aggregate.
5185-
5186- 8. TRANSLATION
5187-
5188- Translation is considered a kind of modification, so you may
5189- distribute translations of the Document under the terms of section
5190- 4. Replacing Invariant Sections with translations requires special
5191- permission from their copyright holders, but you may include
5192- translations of some or all Invariant Sections in addition to the
5193- original versions of these Invariant Sections. You may include a
5194- translation of this License, and all the license notices in the
5195- Document, and any Warranty Disclaimers, provided that you also
5196- include the original English version of this License and the
5197- original versions of those notices and disclaimers. In case of a
5198- disagreement between the translation and the original version of
5199- this License or a notice or disclaimer, the original version will
5200- prevail.
5201-
5202- If a section in the Document is Entitled "Acknowledgements",
5203- "Dedications", or "History", the requirement (section 4) to
5204- Preserve its Title (section 1) will typically require changing the
5205- actual title.
5206-
5207- 9. TERMINATION
5208-
5209- You may not copy, modify, sublicense, or distribute the Document
5210- except as expressly provided under this License. Any attempt
5211- otherwise to copy, modify, sublicense, or distribute it is void,
5212- and will automatically terminate your rights under this License.
5213-
5214- However, if you cease all violation of this License, then your
5215- license from a particular copyright holder is reinstated (a)
5216- provisionally, unless and until the copyright holder explicitly and
5217- finally terminates your license, and (b) permanently, if the
5218- copyright holder fails to notify you of the violation by some
5219- reasonable means prior to 60 days after the cessation.
5220-
5221- Moreover, your license from a particular copyright holder is
5222- reinstated permanently if the copyright holder notifies you of the
5223- violation by some reasonable means, this is the first time you have
5224- received notice of violation of this License (for any work) from
5225- that copyright holder, and you cure the violation prior to 30 days
5226- after your receipt of the notice.
5227-
5228- Termination of your rights under this section does not terminate
5229- the licenses of parties who have received copies or rights from you
5230- under this License. If your rights have been terminated and not
5231- permanently reinstated, receipt of a copy of some or all of the
5232- same material does not give you any rights to use it.
5233-
5234- 10. FUTURE REVISIONS OF THIS LICENSE
5235-
5236- The Free Software Foundation may publish new, revised versions of
5237- the GNU Free Documentation License from time to time. Such new
5238- versions will be similar in spirit to the present version, but may
5239- differ in detail to address new problems or concerns. See
5240- <http://www.gnu.org/copyleft/>.
5241-
5242- Each version of the License is given a distinguishing version
5243- number. If the Document specifies that a particular numbered
5244- version of this License "or any later version" applies to it, you
5245- have the option of following the terms and conditions either of
5246- that specified version or of any later version that has been
5247- published (not as a draft) by the Free Software Foundation. If the
5248- Document does not specify a version number of this License, you may
5249- choose any version ever published (not as a draft) by the Free
5250- Software Foundation. If the Document specifies that a proxy can
5251- decide which future versions of this License can be used, that
5252- proxy's public statement of acceptance of a version permanently
5253- authorizes you to choose that version for the Document.
5254-
5255- 11. RELICENSING
5256-
5257- "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
5258- World Wide Web server that publishes copyrightable works and also
5259- provides prominent facilities for anybody to edit those works. A
5260- public wiki that anybody can edit is an example of such a server.
5261- A "Massive Multiauthor Collaboration" (or "MMC") contained in the
5262- site means any set of copyrightable works thus published on the MMC
5263- site.
5264-
5265- "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
5266- license published by Creative Commons Corporation, a not-for-profit
5267- corporation with a principal place of business in San Francisco,
5268- California, as well as future copyleft versions of that license
5269- published by that same organization.
5270-
5271- "Incorporate" means to publish or republish a Document, in whole or
5272- in part, as part of another Document.
5273-
5274- An MMC is "eligible for relicensing" if it is licensed under this
5275- License, and if all works that were first published under this
5276- License somewhere other than this MMC, and subsequently
5277- incorporated in whole or in part into the MMC, (1) had no cover
5278- texts or invariant sections, and (2) were thus incorporated prior
5279- to November 1, 2008.
5280-
5281- The operator of an MMC Site may republish an MMC contained in the
5282- site under CC-BY-SA on the same site at any time before August 1,
5283- 2009, provided the MMC is eligible for relicensing.
5284-
5285-ADDENDUM: How to use this License for your documents
5286-====================================================
5287-
5288-To use this License in a document you have written, include a copy of
5289-the License in the document and put the following copyright and license
5290-notices just after the title page:
5291-
5292- Copyright (C) YEAR YOUR NAME.
5293- Permission is granted to copy, distribute and/or modify this document
5294- under the terms of the GNU Free Documentation License, Version 1.3
5295- or any later version published by the Free Software Foundation;
5296- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
5297- Texts. A copy of the license is included in the section entitled ``GNU
5298- Free Documentation License''.
5299-
5300- If you have Invariant Sections, Front-Cover Texts and Back-Cover
5301-Texts, replace the "with...Texts." line with this:
5302-
5303- with the Invariant Sections being LIST THEIR TITLES, with
5304- the Front-Cover Texts being LIST, and with the Back-Cover Texts
5305- being LIST.
5306-
5307- If you have Invariant Sections without Cover Texts, or some other
5308-combination of the three, merge those two alternatives to suit the
5309-situation.
5310-
5311- If your document contains nontrivial examples of program code, we
5312-recommend releasing these examples in parallel under your choice of free
5313-software license, such as the GNU General Public License, to permit
5314-their use in free software.
5315-
5316-
5317-File: libquadmath.info, Node: Reporting Bugs, Prev: GNU Free Documentation License, Up: Top
5318-
5319-4 Reporting Bugs
5320-****************
5321-
5322-Bugs in the GCC Quad-Precision Math Library implementation should be
5323-reported via <http://gcc.gnu.org/bugs.html>.
5324-
5325-
5326-
5327-Tag Table:
5328-Node: Top1633
5329-Node: Typedef and constants2367
5330-Node: Math Library Routines3786
5331-Node: I/O Library Routines7503
5332-Node: strtoflt1287828
5333-Node: quadmath_snprintf8588
5334-Node: GNU Free Documentation License10798
5335-Node: Reporting Bugs35944
5336-
5337-End Tag Table
5338diff -Naur gcc-4.8.2.orig/libstdc++-v3/include/bits/stl_algo.h gcc-4.8.2/libstdc++-v3/include/bits/stl_algo.h
5339--- gcc-4.8.2.orig/libstdc++-v3/include/bits/stl_algo.h 2013-09-30 12:42:52.000000000 -0500
5340+++ gcc-4.8.2/libstdc++-v3/include/bits/stl_algo.h 2013-10-20 04:08:12.578223000 -0500
5341@@ -2279,7 +2279,7 @@
5342 _RandomAccessIterator __last)
5343 {
5344 _RandomAccessIterator __mid = __first + (__last - __first) / 2;
5345- std::__move_median_to_first(__first, __first + 1, __mid, (__last - 2));
5346+ std::__move_median_to_first(__first, __first + 1, __mid, __last - 1);
5347 return std::__unguarded_partition(__first + 1, __last, *__first);
5348 }
5349
5350@@ -2291,7 +2291,7 @@
5351 _RandomAccessIterator __last, _Compare __comp)
5352 {
5353 _RandomAccessIterator __mid = __first + (__last - __first) / 2;
5354- std::__move_median_to_first(__first, __first + 1, __mid, (__last - 2),
5355+ std::__move_median_to_first(__first, __first + 1, __mid, __last - 1,
5356 __comp);
5357 return std::__unguarded_partition(__first + 1, __last, *__first, __comp);
5358 }
5359diff -Naur gcc-4.8.2.orig/libstdc++-v3/include/debug/functions.h gcc-4.8.2/libstdc++-v3/include/debug/functions.h
5360--- gcc-4.8.2.orig/libstdc++-v3/include/debug/functions.h 2013-02-03 11:54:05.000000000 -0600
5361+++ gcc-4.8.2/libstdc++-v3/include/debug/functions.h 2013-10-16 15:09:18.884767000 -0500
5362@@ -345,11 +345,13 @@
5363 return __check_sorted_set_aux(__first, __last, __pred, _SameType());
5364 }
5365
5366+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
5367+ // 270. Binary search requirements overly strict
5368+ // Determine if a sequence is partitioned w.r.t. this element.
5369 template<typename _ForwardIterator, typename _Tp>
5370 inline bool
5371- __check_partitioned_lower_aux(_ForwardIterator __first,
5372- _ForwardIterator __last, const _Tp& __value,
5373- std::forward_iterator_tag)
5374+ __check_partitioned_lower(_ForwardIterator __first,
5375+ _ForwardIterator __last, const _Tp& __value)
5376 {
5377 while (__first != __last && *__first < __value)
5378 ++__first;
5379@@ -362,38 +364,11 @@
5380 return __first == __last;
5381 }
5382
5383- // For performance reason, as the iterator range has been validated, check on
5384- // random access safe iterators is done using the base iterator.
5385- template<typename _Iterator, typename _Sequence, typename _Tp>
5386- inline bool
5387- __check_partitioned_lower_aux(
5388- const _Safe_iterator<_Iterator, _Sequence>& __first,
5389- const _Safe_iterator<_Iterator, _Sequence>& __last,
5390- const _Tp& __value,
5391- std::random_access_iterator_tag __tag)
5392- {
5393- return __check_partitioned_lower_aux(__first.base(), __last.base(),
5394- __value, __tag);
5395- }
5396-
5397- // _GLIBCXX_RESOLVE_LIB_DEFECTS
5398- // 270. Binary search requirements overly strict
5399- // Determine if a sequence is partitioned w.r.t. this element.
5400 template<typename _ForwardIterator, typename _Tp>
5401 inline bool
5402- __check_partitioned_lower(_ForwardIterator __first,
5403+ __check_partitioned_upper(_ForwardIterator __first,
5404 _ForwardIterator __last, const _Tp& __value)
5405 {
5406- return __check_partitioned_lower_aux(__first, __last, __value,
5407- std::__iterator_category(__first));
5408- }
5409-
5410- template<typename _ForwardIterator, typename _Tp>
5411- inline bool
5412- __check_partitioned_upper_aux(_ForwardIterator __first,
5413- _ForwardIterator __last, const _Tp& __value,
5414- std::forward_iterator_tag)
5415- {
5416 while (__first != __last && !(__value < *__first))
5417 ++__first;
5418 if (__first != __last)
5419@@ -405,35 +380,12 @@
5420 return __first == __last;
5421 }
5422
5423- // For performance reason, as the iterator range has been validated, check on
5424- // random access safe iterators is done using the base iterator.
5425- template<typename _Iterator, typename _Sequence, typename _Tp>
5426- inline bool
5427- __check_partitioned_upper_aux(
5428- const _Safe_iterator<_Iterator, _Sequence>& __first,
5429- const _Safe_iterator<_Iterator, _Sequence>& __last,
5430- const _Tp& __value,
5431- std::random_access_iterator_tag __tag)
5432- {
5433- return __check_partitioned_upper_aux(__first.base(), __last.base(),
5434- __value, __tag);
5435- }
5436-
5437- template<typename _ForwardIterator, typename _Tp>
5438- inline bool
5439- __check_partitioned_upper(_ForwardIterator __first,
5440- _ForwardIterator __last, const _Tp& __value)
5441- {
5442- return __check_partitioned_upper_aux(__first, __last, __value,
5443- std::__iterator_category(__first));
5444- }
5445-
5446+ // Determine if a sequence is partitioned w.r.t. this element.
5447 template<typename _ForwardIterator, typename _Tp, typename _Pred>
5448 inline bool
5449- __check_partitioned_lower_aux(_ForwardIterator __first,
5450- _ForwardIterator __last, const _Tp& __value,
5451- _Pred __pred,
5452- std::forward_iterator_tag)
5453+ __check_partitioned_lower(_ForwardIterator __first,
5454+ _ForwardIterator __last, const _Tp& __value,
5455+ _Pred __pred)
5456 {
5457 while (__first != __last && bool(__pred(*__first, __value)))
5458 ++__first;
5459@@ -446,39 +398,12 @@
5460 return __first == __last;
5461 }
5462
5463- // For performance reason, as the iterator range has been validated, check on
5464- // random access safe iterators is done using the base iterator.
5465- template<typename _Iterator, typename _Sequence,
5466- typename _Tp, typename _Pred>
5467- inline bool
5468- __check_partitioned_lower_aux(
5469- const _Safe_iterator<_Iterator, _Sequence>& __first,
5470- const _Safe_iterator<_Iterator, _Sequence>& __last,
5471- const _Tp& __value, _Pred __pred,
5472- std::random_access_iterator_tag __tag)
5473- {
5474- return __check_partitioned_lower_aux(__first.base(), __last.base(),
5475- __value, __pred, __tag);
5476- }
5477-
5478- // Determine if a sequence is partitioned w.r.t. this element.
5479 template<typename _ForwardIterator, typename _Tp, typename _Pred>
5480 inline bool
5481- __check_partitioned_lower(_ForwardIterator __first,
5482+ __check_partitioned_upper(_ForwardIterator __first,
5483 _ForwardIterator __last, const _Tp& __value,
5484 _Pred __pred)
5485 {
5486- return __check_partitioned_lower_aux(__first, __last, __value, __pred,
5487- std::__iterator_category(__first));
5488- }
5489-
5490- template<typename _ForwardIterator, typename _Tp, typename _Pred>
5491- inline bool
5492- __check_partitioned_upper_aux(_ForwardIterator __first,
5493- _ForwardIterator __last, const _Tp& __value,
5494- _Pred __pred,
5495- std::forward_iterator_tag)
5496- {
5497 while (__first != __last && !bool(__pred(__value, *__first)))
5498 ++__first;
5499 if (__first != __last)
5500@@ -490,31 +415,6 @@
5501 return __first == __last;
5502 }
5503
5504- // For performance reason, as the iterator range has been validated, check on
5505- // random access safe iterators is done using the base iterator.
5506- template<typename _Iterator, typename _Sequence,
5507- typename _Tp, typename _Pred>
5508- inline bool
5509- __check_partitioned_upper_aux(
5510- const _Safe_iterator<_Iterator, _Sequence>& __first,
5511- const _Safe_iterator<_Iterator, _Sequence>& __last,
5512- const _Tp& __value, _Pred __pred,
5513- std::random_access_iterator_tag __tag)
5514- {
5515- return __check_partitioned_upper_aux(__first.base(), __last.base(),
5516- __value, __pred, __tag);
5517- }
5518-
5519- template<typename _ForwardIterator, typename _Tp, typename _Pred>
5520- inline bool
5521- __check_partitioned_upper(_ForwardIterator __first,
5522- _ForwardIterator __last, const _Tp& __value,
5523- _Pred __pred)
5524- {
5525- return __check_partitioned_upper_aux(__first, __last, __value, __pred,
5526- std::__iterator_category(__first));
5527- }
5528-
5529 // Helper struct to detect random access safe iterators.
5530 template<typename _Iterator>
5531 struct __is_safe_random_iterator
5532diff -Naur gcc-4.8.2.orig/libstdc++-v3/include/debug/macros.h gcc-4.8.2/libstdc++-v3/include/debug/macros.h
5533--- gcc-4.8.2.orig/libstdc++-v3/include/debug/macros.h 2013-02-03 11:54:05.000000000 -0600
5534+++ gcc-4.8.2/libstdc++-v3/include/debug/macros.h 2013-10-16 15:09:18.884767000 -0500
5535@@ -261,8 +261,9 @@
5536 w.r.t. the value _Value. */
5537 #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
5538 __glibcxx_check_valid_range(_First,_Last); \
5539-_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
5540- _Value), \
5541+_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
5542+ __gnu_debug::__base(_First), \
5543+ __gnu_debug::__base(_Last), _Value), \
5544 _M_message(__gnu_debug::__msg_unpartitioned) \
5545 ._M_iterator(_First, #_First) \
5546 ._M_iterator(_Last, #_Last) \
5547@@ -270,8 +271,9 @@
5548
5549 #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
5550 __glibcxx_check_valid_range(_First,_Last); \
5551-_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
5552- _Value), \
5553+_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
5554+ __gnu_debug::__base(_First), \
5555+ __gnu_debug::__base(_Last), _Value), \
5556 _M_message(__gnu_debug::__msg_unpartitioned) \
5557 ._M_iterator(_First, #_First) \
5558 ._M_iterator(_Last, #_Last) \
5559@@ -281,8 +283,9 @@
5560 w.r.t. the value _Value and predicate _Pred. */
5561 #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
5562 __glibcxx_check_valid_range(_First,_Last); \
5563-_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
5564- _Value, _Pred), \
5565+_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
5566+ __gnu_debug::__base(_First), \
5567+ __gnu_debug::__base(_Last), _Value, _Pred), \
5568 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
5569 ._M_iterator(_First, #_First) \
5570 ._M_iterator(_Last, #_Last) \
5571@@ -293,8 +296,9 @@
5572 w.r.t. the value _Value and predicate _Pred. */
5573 #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
5574 __glibcxx_check_valid_range(_First,_Last); \
5575-_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
5576- _Value, _Pred), \
5577+_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
5578+ __gnu_debug::__base(_First), \
5579+ __gnu_debug::__base(_Last), _Value, _Pred), \
5580 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
5581 ._M_iterator(_First, #_First) \
5582 ._M_iterator(_Last, #_Last) \
5583diff -Naur gcc-4.8.2.orig/libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc gcc-4.8.2/libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc
5584--- gcc-4.8.2.orig/libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc 1969-12-31 18:00:00.000000000 -0600
5585+++ gcc-4.8.2/libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc 2013-10-20 04:08:12.578223000 -0500
5586@@ -0,0 +1,52 @@
5587+// Copyright (C) 2013 Free Software Foundation, Inc.
5588+//
5589+// This file is part of the GNU ISO C++ Library. This library is free
5590+// software; you can redistribute it and/or modify it under the
5591+// terms of the GNU General Public License as published by the
5592+// Free Software Foundation; either version 3, or (at your option)
5593+// any later version.
5594+
5595+// This library is distributed in the hope that it will be useful,
5596+// but WITHOUT ANY WARRANTY; without even the implied warranty of
5597+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5598+// GNU General Public License for more details.
5599+
5600+// You should have received a copy of the GNU General Public License along
5601+// with this library; see the file COPYING3. If not see
5602+// <http://www.gnu.org/licenses/>.
5603+
5604+// 25.3.2 [lib.alg.nth.element]
5605+
5606+// { dg-options "-std=gnu++11" }
5607+
5608+#include <algorithm>
5609+#include <testsuite_hooks.h>
5610+#include <testsuite_iterators.h>
5611+
5612+using __gnu_test::test_container;
5613+using __gnu_test::random_access_iterator_wrapper;
5614+
5615+typedef test_container<int, random_access_iterator_wrapper> Container;
5616+
5617+void test01()
5618+{
5619+ std::vector<int> v = {
5620+ 207089,
5621+ 202585,
5622+ 180067,
5623+ 157549,
5624+ 211592,
5625+ 216096,
5626+ 207089
5627+ };
5628+
5629+ Container con(v.data(), v.data() + 7);
5630+
5631+ std::nth_element(con.begin(), con.begin() + 3, con.end());
5632+}
5633+
5634+int main()
5635+{
5636+ test01();
5637+ return 0;
5638+}
Note: See TracBrowser for help on using the repository browser.