[m-rev.] For review: expand MR_INT_CTOR_ADDR etc.

Ralph Becket rafe at cs.mu.OZ.AU
Tue Dec 14 18:01:26 AEDT 2004


Estimated hours taken: 0.2
Branches: main

runtime/mercury_type_info.h:
	Expanded the definitions of MR_INT_CTOR_ADDR, MR_FLOAT_CTOR_ADDR,
	MR_CHAR_CTOR_ADDR, MR_STRING_CTOR_ADDR, MR_IO_CTOR_ADDR,
	MR_BOOL_CTOR_ADDR, MR_LIST_CTOR_ADDR, MR_TYPE_INFO_CTOR_ADDR to
	avoid problems when linking with C files that export names such
	as `bool'.

Index: mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.114
diff -u -r1.114 mercury_type_info.h
--- mercury_type_info.h	28 Jun 2004 04:50:07 -0000	1.114
+++ mercury_type_info.h	14 Dec 2004 06:56:08 -0000
@@ -1366,23 +1366,67 @@
 #define MR_CTOR1_ADDR(m, n)                                             \
     (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(m, n, 1)
 
-#define MR_INT_CTOR_ADDR                                                \
-    (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, int, 0)
-#define MR_FLOAT_CTOR_ADDR                                              \
-    (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, float, 0)
-#define MR_CHAR_CTOR_ADDR                                               \
-    (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, character, 0)
-#define MR_STRING_CTOR_ADDR                                             \
-    (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, string, 0)
-#define MR_IO_CTOR_ADDR                                                 \
-    (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(io, state, 0)
-#define MR_BOOL_CTOR_ADDR                                               \
-    (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(bool, bool, 0)
-#define MR_LIST_CTOR_ADDR                                               \
-    (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(list, list, 1)
-#define MR_TYPE_INFO_CTOR_ADDR                                          \
-    (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(private_builtin, type_info, 1)
+/*
+** `bool' is often defined in other C code and can cause conflicts
+** when linking, hence we expand these definitions out fully here.
+*/
 
+#ifdef MR_HIGHLEVEL_CODE
+
+  #define MR_INT_CTOR_ADDR                                                \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_int_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, int, 0) */
+  #define MR_FLOAT_CTOR_ADDR                                              \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_float_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, float, 0) */
+  #define MR_CHAR_CTOR_ADDR                                               \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_character_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, character, 0) */
+  #define MR_STRING_CTOR_ADDR                                             \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_string_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, string, 0) */
+  #define MR_IO_CTOR_ADDR                                                 \
+      (MR_Word *) &mercury__io__io__type_ctor_info_state_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(io, state, 0) */
+  #define MR_BOOL_CTOR_ADDR                                               \
+      (MR_Word *) &mercury__bool__bool__type_ctor_info_bool_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(bool, bool, 0) */
+  #define MR_LIST_CTOR_ADDR                                               \
+      (MR_Word *) &mercury__list__list__type_ctor_info_list_1
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(list, list, 1) */
+  #define MR_TYPE_INFO_CTOR_ADDR                                          \
+      (MR_Word *) &mercury__private_builtin__private_builtin__type_ctor_info_type_info_1
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(private_builtin, type_info, 1) */
+
+#else /* ! MR_HIGHLEVEL_CODE */
+
+  #define MR_INT_CTOR_ADDR                                                \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_int_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, int, 0) */
+  #define MR_FLOAT_CTOR_ADDR                                              \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_float_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, float, 0) */
+  #define MR_CHAR_CTOR_ADDR                                               \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_character_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, character, 0) */
+  #define MR_STRING_CTOR_ADDR                                             \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_string_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, string, 0) */
+  #define MR_IO_CTOR_ADDR                                                 \
+      (MR_Word *) &mercury_data_io__type_ctor_info_state_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(io, state, 0) */
+  #define MR_BOOL_CTOR_ADDR                                               \
+      (MR_Word *) &mercury_data_bool__type_ctor_info_bool_0
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(bool, bool, 0) */
+  #define MR_LIST_CTOR_ADDR                                               \
+      (MR_Word *) &mercury_data_list__type_ctor_info_list_1
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(list, list, 1) */
+  #define MR_TYPE_INFO_CTOR_ADDR                                          \
+      (MR_Word *) &mercury_data_private_builtin__type_ctor_info_type_info_1
+      /* (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(private_builtin, type_info, 1) */
+
+#endif
+  
 /*---------------------------------------------------------------------------*/
 
 /*
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list