diff mbox

Avoid using constructor attribute in libcpp (PR bootstrap/50237)

Message ID 20111207202031.GE1957@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Dec. 7, 2011, 8:20 p.m. UTC
Hi!

While this isn't real fix for this PR, which should be fixed in configury,
I think avoiding ctors in host code is useful for portability and Eric
agreed with that in the PR.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2011-12-07  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/50237
	* internal.h (_cpp_init_lexer): New prototype.
	* init.c (init_library): Call it.
	* lex.c (init_vectorized_lexer): Remove constructor attribute,
	add inline keyword.
	(HAVE_init_vectorized_lexer): Define.
	(_cpp_init_lexer): New function.


	Jakub

Comments

Richard Henderson Dec. 7, 2011, 9:41 p.m. UTC | #1
On 12/07/2011 12:20 PM, Jakub Jelinek wrote:
> 	PR bootstrap/50237
> 	* internal.h (_cpp_init_lexer): New prototype.
> 	* init.c (init_library): Call it.
> 	* lex.c (init_vectorized_lexer): Remove constructor attribute,
> 	add inline keyword.
> 	(HAVE_init_vectorized_lexer): Define.
> 	(_cpp_init_lexer): New function.

Ok.


r~
diff mbox

Patch

--- libcpp/internal.h.jj	2011-11-04 07:49:56.000000000 +0100
+++ libcpp/internal.h	2011-11-28 16:01:13.467831488 +0100
@@ -653,6 +653,7 @@  extern int _cpp_equiv_tokens (const cpp_
 extern void _cpp_init_tokenrun (tokenrun *, unsigned int);
 extern cpp_hashnode *_cpp_lex_identifier (cpp_reader *, const char *);
 extern int _cpp_remaining_tokens_num_in_context (cpp_context *);
+extern void _cpp_init_lexer (void);
 
 /* In init.c.  */
 extern void _cpp_maybe_push_include_file (cpp_reader *);
--- libcpp/init.c.jj	2011-10-31 20:44:15.000000000 +0100
+++ libcpp/init.c	2011-11-28 16:01:42.168044257 +0100
@@ -134,6 +134,8 @@  init_library (void)
     {
       initialized = 1;
 
+      _cpp_init_lexer ();
+
       /* Set up the trigraph map.  This doesn't need to do anything if
 	 we were compiled with a compiler that supports C99 designated
 	 initializers.  */
--- libcpp/lex.c.jj	2011-10-27 08:43:10.000000000 +0200
+++ libcpp/lex.c	2011-11-28 16:04:42.624703698 +0100
@@ -477,7 +477,8 @@  search_line_sse42 (const uchar *s, const
 typedef const uchar * (*search_line_fast_type) (const uchar *, const uchar *);
 static search_line_fast_type search_line_fast;
 
-static void __attribute__((constructor))
+#define HAVE_init_vectorized_lexer 1
+static inline void
 init_vectorized_lexer (void)
 {
   unsigned dummy, ecx = 0, edx = 0;
@@ -638,6 +639,16 @@  search_line_fast (const uchar *s, const
 
 #endif
 
+/* Initialize the lexer if needed.  */
+
+void
+_cpp_init_lexer (void)
+{
+#ifdef HAVE_init_vectorized_lexer
+  init_vectorized_lexer ();
+#endif
+}
+
 /* Returns with a logical line that contains no escaped newlines or
    trigraphs.  This is a time-critical inner loop.  */
 void