This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: AIX C++ fixinc
- From: Bruce Korb <bkorb at veritas dot com>
- To: David Edelsohn <dje at watson dot ibm dot com>
- Cc: Bruce Korb <bkorb at gnu dot org>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 30 Dec 2002 10:40:26 -0800
- Subject: Re: AIX C++ fixinc
- References: <200212301815.NAA24386@makai.watson.ibm.com>
- Reply-to: bkorb at gnu dot org
David Edelsohn wrote:
> I followed the type of fix that IBM Visual Age C++ installs.
Your call. 'course, remember that I copied these fixes from the
original script and I confess I only scrutinize changes... :-)
> Bruce> I don't see any issues with aix_extern_c. It will ensure that every
> Bruce> assert.h on every platform is wrapped with the ``extern "C"'' stuff.
> Bruce> The fix is bypassed on Solaris, Linux and HP/UX. However, please
>
> I discovered that fixinc places a guard using the same fix name in
> all files. This means if both assert.h and sys/atomic.h are included, the
> second file is skipped. :-(. I need a separate fix for each file?
No, we need to fix wrap_fix. I guess no wrap fix had been used for multiple
files on a single platform before. Attached is a fix for that. :-)
Please include it with your fixes when you've tested it. It ought to work,
but I have real work to do and it would be several days before I could
get to it.... Thanks! - Bruce
--- fixfixes.c.ori Sun Oct 21 14:32:15 2001
+++ fixfixes.c Mon Dec 30 10:35:33 2002
@@ -597,47 +597,41 @@
tSCC z_no_wrap_pat[] = "^#if.*__need_";
static regex_t no_wrapping_re; /* assume zeroed data */
- char z_fixname[ 64 ];
- tCC* pz_src = p_fixd->fix_name;
- tCC* pz_name = z_fixname;
- char* pz_dst = z_fixname;
- int do_end = 0;
- size_t len = 0;
- IGNORE_ARG(filname);
+ tCC* pz_name = NULL;
if (no_wrapping_re.allocated == 0)
compile_re( z_no_wrap_pat, &no_wrapping_re, 0, "no-wrap pattern",
"wrap-fix" );
- for (;;) {
- char ch = *pz_src++;
-
- if (ch == NUL) {
- *pz_dst++ = ch;
- break;
- } else if (! ISALNUM (ch)) {
- *pz_dst++ = '_';
- } else {
- *pz_dst++ = TOUPPER (ch);
- }
-
- if (++len >= sizeof( z_fixname )) {
- void* p = xmalloc( len + strlen( pz_src ) + 1 );
- memcpy( p, (void*)z_fixname, len );
- pz_name = (tCC*)p;
- pz_dst = (char*)pz_name + len;
- }
- }
-
/*
* IF we do *not* match the no-wrap re, then we have a double negative.
* A double negative means YES.
*/
if (regexec (&no_wrapping_re, text, 0, NULL, 0) != 0)
{
- printf( "#ifndef FIXINC_%s_CHECK\n", pz_name );
- printf( "#define FIXINC_%s_CHECK 1\n\n", pz_name );
- do_end = 1;
+ char* pz;
+ size_t len = strlen( filname ) + 1;
+
+ pz = xmalloc( len );
+ strcpy( pz, filname );
+ pz_name = pz;
+
+ for (;;) {
+ char ch = *pz;
+
+ if (ch == NUL)
+ break;
+
+ if (! ISALNUM (ch)) {
+ *pz++ = '_';
+ }
+ else {
+ *pz++ = TOUPPER (ch);
+ }
+ }
+
+ printf( "#ifndef FIXINC_WRAP_%s\n", pz_name );
+ printf( "#define FIXINC_WRAP_%s 1\n\n", pz_name );
}
if (p_fixd->patch_args[1] == (tCC*)NULL)
@@ -650,11 +644,10 @@
fputs( p_fixd->patch_args[2], stdout );
}
- if (do_end != 0)
- printf( "\n#endif /* FIXINC_%s_CHECK */\n", pz_name );
-
- if (pz_name != z_fixname)
+ if (pz_name != NULL) {
+ printf( "\n#endif /* FIXINC_WRAP_%s */\n", pz_name );
free( (void*)pz_name );
+ }
}