[m-rev.] diff: fix decldebug grades with MSVC

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Oct 21 00:41:25 AEDT 2011


Branches: main, 11.07

Fix the decldebug grades with MSVC.
(XXX Most of the system can now be built in none.gc.decldebug with MSVC
except for the deep profiler; the Windows header files define the macro
interface and this stuffs up compilation of the C code generated
for deep_profiler/interface.m - I am looking into possible fixes
for this.)

compiler/layout_out.
 	Avoid declarations for layout structures that contain incomplete
 	types.  MSVC treats them as erroneous definitions rather than
 	declarations.  Use the existing mechanism we have in the LLDS
 	backend for doing this, the MR_STATIC_LINKAGE macro.

 	Replace my earlier fix or alloc_sites arrays with the
 	above as well.

library/thread.semaphore.m:
browser/declarative_debugger.m:
browser/util.m:
 	Use don't care variables for the I/O state in more
 	foreign procs in order to avoid warnings from MSVC.

Julien.

Index: browser/declarative_debugger.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/declarative_debugger.m,v
retrieving revision 1.78
diff -u -r1.78 declarative_debugger.m
--- browser/declarative_debugger.m	5 May 2011 07:11:49 -0000	1.78
+++ browser/declarative_debugger.m	20 Oct 2011 13:12:56 -0000
@@ -969,11 +969,10 @@
  :- pred debug_origin(int::out, io::di, io::uo) is det.

  :- pragma foreign_proc("C",
-    debug_origin(Flag::out, IO0::di, IO::uo),
+    debug_origin(Flag::out, _IO0::di, _IO::uo),
      [will_not_call_mercury, promise_pure, tabled_for_io],
  "
      Flag = MR_DD_debug_origin;
-    IO = IO0;
  ").
  debug_origin(_, !IO) :-
      private_builtin.sorry("declarative_debugger.debug_origin").
Index: browser/util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/util.m,v
retrieving revision 1.40
diff -u -r1.40 util.m
--- browser/util.m	16 Jun 2010 01:29:05 -0000	1.40
+++ browser/util.m	20 Oct 2011 13:13:33 -0000
@@ -90,7 +90,7 @@

  :- pragma foreign_proc("C",
      call_trace_getline(MdbIn::in, MdbOut::in, Prompt::in, Line::out,
-        Success::out, IO0::di, IO::uo),
+        Success::out, _IO0::di, _IO::uo),
      % We need to use will_not_call_mercury here,
      % because MR_make_aligned_string_copy() references MR_hp,
      % which only works for will_not_call_mercury foreign_procs.
@@ -117,8 +117,6 @@
          MR_free(line);
          Success = 1;
      }
-
-    IO = IO0;
  ").

  call_trace_getline(MdbIn, MdbOut, Prompt, Line, Success, !IO) :-
Index: compiler/layout_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/layout_out.m,v
retrieving revision 1.125
diff -u -r1.125 layout_out.m
--- compiler/layout_out.m	20 Oct 2011 06:37:30 -0000	1.125
+++ compiler/layout_out.m	20 Oct 2011 12:33:52 -0000
@@ -375,10 +375,9 @@
      ;
          AllocSites = [_ | _],
          AllocSiteArrayName = alloc_site_array,
-        list.length(AllocSites, NumAllocSites),
          output_layout_array_name_storage_type_name(MangledModuleName,
              AllocSiteArrayName, not_being_defined, !IO),
-        io.format("[%d];\n", [i(NumAllocSites)], !IO)
+        io.write_string("[];\n", !IO)
      ).

  output_layout_array_defns(Info, PseudoTypeInfos, HLDSVarNums,
@@ -1983,112 +1982,122 @@
          io.write_string(ModuleNameStr, !IO)
      ).

-output_layout_array_name_storage_type_name(ModuleName, Name, _BeingDefined,
+output_layout_array_name_storage_type_name(ModuleName, Name, BeingDefined,
          !IO) :-
      (
+        BeingDefined = being_defined,
+        io.write_string("static ", !IO)
+    ; 
+        % Avoid problems with MS Visual C. 
+        % See the comments in llds_out_file.output_static_linkage_define/2
+        % for a further explanation.
+        BeingDefined = not_being_defined,
+        io.write_string("MR_STATIC_LINKAGE ", !IO)
+    ),
+    (
          Name = label_layout_array(label_has_no_var_info),
-        io.write_string("static const MR_LabelLayoutNoVarInfo ", !IO),
+        io.write_string("const MR_LabelLayoutNoVarInfo ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = label_layout_array(label_has_short_var_info),
-        io.write_string("static const MR_LabelLayoutShort ", !IO),
+        io.write_string("const MR_LabelLayoutShort ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = label_layout_array(label_has_long_var_info),
-        io.write_string("static const MR_LabelLayout ", !IO),
+        io.write_string("const MR_LabelLayout ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = pseudo_type_info_array,
-        io.write_string("static const MR_PseudoTypeInfo ", !IO),
+        io.write_string("const MR_PseudoTypeInfo ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = long_locns_array,
-        io.write_string("static const MR_LongLval ", !IO),
+        io.write_string("const MR_LongLval ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = short_locns_array,
-        io.write_string("static const MR_ShortLval ", !IO),
+        io.write_string("const MR_ShortLval ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = hlds_var_nums_array,
-        io.write_string("static const MR_HLDSVarNum ", !IO),
+        io.write_string("const MR_HLDSVarNum ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = user_event_var_nums_array,
-        io.write_string("static const MR_HLDSVarNum ", !IO),
+        io.write_string("const MR_HLDSVarNum ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = user_event_layout_array,
-        io.write_string("static const struct MR_UserEvent_Struct ", !IO),
+        io.write_string("const struct MR_UserEvent_Struct ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_static_call_sites_array,
-        io.write_string("static const MR_CallSiteStatic ", !IO),
+        io.write_string("const MR_CallSiteStatic ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_static_cp_static_array,
-        io.write_string("static const MR_CoveragePointStatic ", !IO),
+        io.write_string("const MR_CoveragePointStatic ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_static_cp_dynamic_array,
-        io.write_string("static MR_Unsigned ", !IO),
+        io.write_string("MR_Unsigned ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_static_array,
-        io.write_string("static MR_ProcStatic ", !IO),
+        io.write_string("MR_ProcStatic ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_head_var_nums_array,
-        io.write_string("static const MR_uint_least16_t ", !IO),
+        io.write_string("const MR_uint_least16_t ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_var_names_array,
-        io.write_string("static const MR_uint_least32_t ", !IO),
+        io.write_string("const MR_uint_least32_t ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_body_bytecodes_array,
-        io.write_string("static const MR_uint_least8_t ", !IO),
+        io.write_string("const MR_uint_least8_t ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_table_io_decl_array,
-        io.write_string("static const MR_TableIoDecl ", !IO),
+        io.write_string("const MR_TableIoDecl ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_event_layouts_array,
-        io.write_string("static const MR_LabelLayout *", !IO),
+        io.write_string("const MR_LabelLayout *", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = proc_exec_trace_array,
-        io.write_string("static MR_STATIC_CODE_CONST MR_ExecTrace ", !IO),
+        io.write_string("MR_STATIC_CODE_CONST MR_ExecTrace ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = threadscope_string_table_array,
-        io.write_string("static MR_Threadscope_String ", !IO),
+        io.write_string("MR_Threadscope_String ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ;
          Name = alloc_site_array,
          % The type field may be updated at runtime so this array is not const.
-        io.write_string("static MR_AllocSiteInfo ", !IO),
+        io.write_string("MR_AllocSiteInfo ", !IO),
          output_layout_array_name(do_not_use_layout_macro, ModuleName,
              Name, !IO)
      ).
Index: library/thread.semaphore.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/thread.semaphore.m,v
retrieving revision 1.24
diff -u -r1.24 thread.semaphore.m
--- library/thread.semaphore.m	11 Oct 2011 04:31:04 -0000	1.24
+++ library/thread.semaphore.m	20 Oct 2011 13:15:15 -0000
@@ -290,7 +290,7 @@
      %
  :- pragma no_inline(semaphore.wait/3).
  :- pragma foreign_proc("C",
-    wait(Semaphore::in, IO0::di, IO::uo),
+    wait(Semaphore::in, _IO0::di, _IO::uo),
      [promise_pure, will_not_call_mercury, thread_safe, tabled_for_io],
  "
      ML_Semaphore    *sem;
@@ -350,7 +350,6 @@

      MR_UNLOCK(&(sem->lock), ""semaphore__wait"");
  #endif
-    IO = IO0;
  ").

  :- pragma foreign_proc("C#",
@@ -386,7 +385,7 @@
  :- pred try_wait_2(semaphore::in, int::out, io::di, io::uo) is det.

  :- pragma foreign_proc("C",
-    try_wait_2(Semaphore::in, Res::out, IO0::di, IO::uo),
+    try_wait_2(Semaphore::in, Res::out, _IO0::di, _IO::uo),
      [promise_pure, will_not_call_mercury, thread_safe, tabled_for_io],
  "
      ML_Semaphore    *sem;
@@ -402,7 +401,6 @@
          MR_UNLOCK(&(sem->lock), ""semaphore.try_wait"");
          Res = 1;
      }
-    IO = IO0;
  ").

  :- pragma foreign_proc("C#",

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list