Bug 50167 - gmp memory functions are extern "C" (graphite)
Summary: gmp memory functions are extern "C" (graphite)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-23 15:51 UTC by Marc Glisse
Modified: 2013-01-03 20:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-08-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Glisse 2011-08-23 15:51:21 UTC
Hello,

with gcc moving to C++, a few things need adapting. In particular, when asking for the gmp memory functions, this:

      void (*gmp_free) (void *, size_t);
      mp_get_memory_functions (NULL, NULL, &gmp_free);

becomes wrong. One should have somewhere (protected by tests on __cplusplus since we are still building with C compilers):
extern "C" {
  typedef void (*mytype) (void *, size_t);
}

And then:

      mytype gmp_free;
      mp_get_memory_functions (NULL, NULL, &gmp_free);

g++ can't see the difference (yet? see Bug 2316), but some other compilers can (sunpro), and we want other C++ compilers to be usable for stage1.

This code appears in 2 files:
./gcc/graphite-ppl.c
./gcc/graphite-interchange.c
Comment 1 Richard Biener 2011-08-24 08:16:55 UTC
Confirmed.
Comment 2 Marc Glisse 2012-08-13 06:17:30 UTC
Note that this could also be solved by using gmp_fprintf. (Or by using mpz_class::get_str, since we seem to be moving to C++ anyway)
Comment 3 Marc Glisse 2013-01-03 20:06:56 UTC
Author: glisse
Date: Thu Jan  3 20:06:49 2013
New Revision: 194868

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194868
Log:
2013-01-03  Marc Glisse  <marc.glisse@inria.fr>

	PR bootstrap/50167
gcc/
	* graphite-interchange.c (pdr_stride_in_loop): Use gmp_fprintf.
	* graphite-poly.c (debug_gmp_value): Likewise.

	PR bootstrap/50177
libcpp/
	* line-map.c (get_combined_adhoc_loc): Cast from extern "C" type.
	(new_linemap): Likewise.
	(linemap_enter_macro): Likewise.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/graphite-interchange.c
    trunk/gcc/graphite-poly.c
    trunk/libcpp/ChangeLog
    trunk/libcpp/line-map.c
Comment 4 Marc Glisse 2013-01-03 20:11:00 UTC
.