emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 6994731: Port to Oracle Developer Studio 12.6


From: Paul Eggert
Subject: [Emacs-diffs] master 6994731: Port to Oracle Developer Studio 12.6
Date: Thu, 25 Apr 2019 16:23:12 -0400 (EDT)

branch: master
commit 69947311d84a2572e8382e401ab97fdab25cb433
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Port to Oracle Developer Studio 12.6
    
    This compiler is a bit pickier about checking conformance to
    the C standard, ranging from syntax trivia (no extra ";" at
    the top level) to portability trivia (warnings re conversion
    between function and data pointers) to more-important stuff
    like lack of support for some __attribute__ usages.
    * src/dynlib.c (dynlib_addr): First argument is a function
    pointer, not a data pointer.  All callers changed.
    * src/emacs-module.c (module_function_address):
    Return module_funcptr, not void *.  All uses changed.
    * src/lisp.h (module_funcptr) [HAVE_MODULES]: New type.
    * src/lread.c (union ieee754_double): Don’t assume the usual
    semantics for converting signed to unsigned int when initializing
    a bitfield, as the Oracle compiler complains and the C standard
    is unclear.
    * src/pdumper.c (ALLOW_IMPLICIT_CONVERSION): Make it clearer
    that -Wsign-conversion is disabled everywhere in this file.
    (dump_trace, dump_tailq_prepend, dump_tailq_append):
    Don’t assume __attribute__.
    (dump_object_self_representing_p): Don’t disable conversion
    warnings; it’s not needed here.
    (DEFINE_FROMLISP_FUNC): Avoid possible signal in integer
    conversion from unsigned to signed.
    (DEFINE_FROMLISP_FUNC, finish_dump_pvec): Avoid warning about
    unreachable statements on platforms not supporting the
    __attribute__.
    (intmax_t_from_lisp, intmax_t_to_lisp, dump_off_from_lisp)
    (dump_off_to_lisp, dump_emacs_reloc_immediate_lv)
    (dump_emacs_reloc_immediate_ptrdiff_t)
    (dump_emacs_reloc_immediate_intmax_t)
    (dump_emacs_reloc_immediate_int, dump_emacs_reloc_immediate_bool):
    Omit stray semicolon that violates C standard.
    (dump_metadata_for_pdumper): Add cast to pacify compiler complaining
    about conversion from function pointer to data pointer.
    (Fdump_emacs_portable): Do not use CALLN to call a function
    with zero arguments, as C99 prohibits empty initializers.
    * src/xdisp.c (syms_of_xdisp): Do not nest calls to pure_list,
    to work around a bug in Oracle Developer Studio 12.6.
---
 src/dynlib.c       |  5 ++--
 src/dynlib.h       |  2 +-
 src/emacs-module.c |  4 ++--
 src/lisp.h         | 15 +++++++++---
 src/lread.c        |  2 +-
 src/pdumper.c      | 67 +++++++++++++++++++++++++++---------------------------
 src/print.c        |  2 +-
 src/xdisp.c        | 12 ++++++----
 8 files changed, 61 insertions(+), 48 deletions(-)

diff --git a/src/dynlib.c b/src/dynlib.c
index 8780445..9c1bf4a 100644
--- a/src/dynlib.c
+++ b/src/dynlib.c
@@ -123,7 +123,7 @@ dynlib_sym (dynlib_handle_ptr h, const char *sym)
 }
 
 void
-dynlib_addr (void *addr, const char **fname, const char **symname)
+dynlib_addr (void (*addr) (void), const char **fname, const char **symname)
 {
   static char dll_filename[MAX_UTF8_PATH];
   static GetModuleHandleExA_Proc s_pfn_Get_Module_HandleExA = NULL;
@@ -279,11 +279,12 @@ dynlib_sym (dynlib_handle_ptr h, const char *sym)
 }
 
 void
-dynlib_addr (void *ptr, const char **path, const char **sym)
+dynlib_addr (void (*funcptr) (void), const char **path, const char **sym)
 {
   *path = NULL;
   *sym = NULL;
 #ifdef HAVE_DLADDR
+  void *ptr = (void *) funcptr;
   Dl_info info;
   if (dladdr (ptr, &info) && info.dli_fname && info.dli_sname)
     {
diff --git a/src/dynlib.h b/src/dynlib.h
index 168ddbc..2688712 100644
--- a/src/dynlib.h
+++ b/src/dynlib.h
@@ -35,6 +35,6 @@ dynlib_function_ptr dynlib_func (dynlib_handle_ptr h, const 
char *sym);
 /* Sets *FILE to the file name from which PTR was loaded, and *SYM to
    its symbol name.  If the file or symbol name could not be
    determined, set the corresponding argument to NULL.  */
-void dynlib_addr (void *ptr, const char **file, const char **sym);
+void dynlib_addr (void (*ptr) (void), const char **file, const char **sym);
 
 #endif /* DYNLIB_H */
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 0b7b3d6..80a04ba 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -934,10 +934,10 @@ module_function_documentation (const struct 
Lisp_Module_Function *function)
   return function->documentation;
 }
 
-void *
+module_funcptr
 module_function_address (const struct Lisp_Module_Function *function)
 {
-  return function->subr;
+  return (module_funcptr) function->subr;
 }
 
 
diff --git a/src/lisp.h b/src/lisp.h
index 8dc4429..f613ce2 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3069,7 +3069,9 @@ enum maxargs
 /* Call a function F that accepts many args, passing it the remaining args,
    E.g., 'return CALLN (Fformat, fmt, text);' is less error-prone than
    '{ Lisp_Object a[2]; a[0] = fmt; a[1] = text; return Fformat (2, a); }'.
-   CALLN is overkill for simple usages like 'Finsert (1, &text);'.  */
+   CALLN requires at least one function argument (as C99 prohibits
+   empty initializers), and is overkill for simple usages like
+   'Finsert (1, &text);'.  */
 #define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
 
 extern void defvar_lisp (struct Lisp_Objfwd const *, char const *);
@@ -4168,14 +4170,21 @@ XMODULE_FUNCTION (Lisp_Object o)
 }
 
 #ifdef HAVE_MODULES
+/* A function pointer type good enough for lisp.h.  Actual module
+   function pointers are of a different type that relies on details
+   internal to emacs-module.c.  */
+typedef void (*module_funcptr) (void);
+
 /* Defined in alloc.c.  */
 extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p);
 
 /* Defined in emacs-module.c.  */
 extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *);
 extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *);
-extern Lisp_Object module_function_documentation (const struct 
Lisp_Module_Function *);
-extern void *module_function_address (const struct Lisp_Module_Function *);
+extern Lisp_Object module_function_documentation
+  (struct Lisp_Module_Function const *);
+extern module_funcptr module_function_address
+  (struct Lisp_Module_Function const *);
 extern void mark_modules (void);
 extern void init_module_assertions (bool);
 extern void syms_of_module (void);
diff --git a/src/lread.c b/src/lread.c
index 6cd1029..1c97805 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3782,7 +3782,7 @@ string_to_number (char const *string, int base, ptrdiff_t 
*plen)
              state |= E_EXP;
              cp += 3;
              union ieee754_double u
-               = { .ieee_nan = { .exponent = -1, .quiet_nan = 1,
+               = { .ieee_nan = { .exponent = 0x7ff, .quiet_nan = 1,
                                  .mantissa0 = n >> 31 >> 1, .mantissa1 = n }};
              value = u.d;
            }
diff --git a/src/pdumper.c b/src/pdumper.c
index 39931c6..28045d1 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -70,18 +70,18 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #ifdef HAVE_PDUMPER
 
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
+#if GNUC_PREREQ (4, 7, 0)
 # pragma GCC diagnostic error "-Wconversion"
+# pragma GCC diagnostic ignored "-Wsign-conversion"
 # pragma GCC diagnostic error "-Wshadow"
 # define ALLOW_IMPLICIT_CONVERSION                       \
   _Pragma ("GCC diagnostic push")                        \
   _Pragma ("GCC diagnostic ignored \"-Wconversion\"")
-  _Pragma ("GCC diagnostic ignored \"-Wsign-conversion\"")
 # define DISALLOW_IMPLICIT_CONVERSION \
   _Pragma ("GCC diagnostic pop")
 #else
-# define ALLOW_IMPLICIT_CONVERSION ((void)0)
-# define DISALLOW_IMPLICIT_CONVERSION ((void)0)
+# define ALLOW_IMPLICIT_CONVERSION ((void) 0)
+# define DISALLOW_IMPLICIT_CONVERSION ((void) 0)
 #endif
 
 #define VM_POSIX 1
@@ -124,7 +124,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
    general-purpose computer made after 1990.  */
 verify (sizeof (ptrdiff_t) == sizeof (void *));
 verify (sizeof (intptr_t) == sizeof (ptrdiff_t));
-verify (sizeof (void (*)(void)) == sizeof (void *));
+verify (sizeof (void (*) (void)) == sizeof (void *));
 verify (sizeof (ptrdiff_t) <= sizeof (Lisp_Object));
 verify (sizeof (ptrdiff_t) <= sizeof (EMACS_INT));
 verify (CHAR_BIT == 8);
@@ -151,8 +151,7 @@ typedef int_least32_t dump_off;
 #define DUMP_OFF_MIN INT_LEAST32_MIN
 #define DUMP_OFF_MAX INT_LEAST32_MAX
 
-__attribute__((format (printf,1,2)))
-static void
+static void ATTRIBUTE_FORMAT ((printf, 1, 2))
 dump_trace (const char *fmt, ...)
 {
   if (0)
@@ -734,11 +733,7 @@ dump_builtin_symbol_p (Lisp_Object object)
 static bool
 dump_object_self_representing_p (Lisp_Object object)
 {
-  bool result;
-  ALLOW_IMPLICIT_CONVERSION;
-  result =  FIXNUMP (object) || dump_builtin_symbol_p (object);
-  DISALLOW_IMPLICIT_CONVERSION;
-  return result;
+  return FIXNUMP (object) || dump_builtin_symbol_p (object);
 }
 
 #define DEFINE_FROMLISP_FUNC(fn, type)          \
@@ -749,10 +744,13 @@ dump_object_self_representing_p (Lisp_Object object)
     if (FIXNUMP (value))                        \
       return XFIXNUM (value);                   \
     eassert (BIGNUMP (value));                  \
-    return TYPE_SIGNED (type)                   \
-      ? bignum_to_intmax (value)                \
-      : bignum_to_uintmax (value);              \
+    type result;                               \
+    if (TYPE_SIGNED (type))                    \
+      result = bignum_to_intmax (value);       \
+    else                                       \
+      result = bignum_to_uintmax (value);      \
     DISALLOW_IMPLICIT_CONVERSION;               \
+    return result;                             \
   }
 
 #define DEFINE_TOLISP_FUNC(fn, type) \
@@ -762,10 +760,10 @@ dump_object_self_representing_p (Lisp_Object object)
     return INT_TO_INTEGER (value);   \
   }
 
-DEFINE_FROMLISP_FUNC (intmax_t_from_lisp, intmax_t);
-DEFINE_TOLISP_FUNC (intmax_t_to_lisp, intmax_t);
-DEFINE_FROMLISP_FUNC (dump_off_from_lisp, dump_off);
-DEFINE_TOLISP_FUNC (dump_off_to_lisp, dump_off);
+DEFINE_FROMLISP_FUNC (intmax_t_from_lisp, intmax_t)
+DEFINE_TOLISP_FUNC (intmax_t_to_lisp, intmax_t)
+DEFINE_FROMLISP_FUNC (dump_off_from_lisp, dump_off)
+DEFINE_TOLISP_FUNC (dump_off_to_lisp, dump_off)
 
 static void
 dump_write (struct dump_context *ctx, const void *buf, dump_off nbyte)
@@ -797,8 +795,7 @@ dump_tailq_length (const struct dump_tailq *tailq)
   return tailq->length;
 }
 
-__attribute__((unused))
-static void
+static void ATTRIBUTE_UNUSED
 dump_tailq_prepend (struct dump_tailq *tailq, Lisp_Object value)
 {
   Lisp_Object link = Fcons (value, tailq->head);
@@ -808,8 +805,7 @@ dump_tailq_prepend (struct dump_tailq *tailq, Lisp_Object 
value)
   tailq->length += 1;
 }
 
-__attribute__((unused))
-static void
+static void ATTRIBUTE_UNUSED
 dump_tailq_append (struct dump_tailq *tailq, Lisp_Object value)
 {
   Lisp_Object link = Fcons (value, Qnil);
@@ -1593,11 +1589,11 @@ dump_emacs_reloc_immediate (struct dump_context *ctx,
       ctx, emacs_ptr, &value, sizeof (value));                          \
   }
 
-DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_lv, Lisp_Object);
-DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_ptrdiff_t, ptrdiff_t);
-DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_intmax_t, intmax_t);
-DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_int, int);
-DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_bool, bool);
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_lv, Lisp_Object)
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_ptrdiff_t, ptrdiff_t)
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_intmax_t, intmax_t)
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_int, int)
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_bool, bool)
 
 /* Add an emacs relocation that makes a raw pointer in Emacs point
    into the dump.  */
@@ -2011,8 +2007,10 @@ finish_dump_pvec (struct dump_context *ctx,
                   union vectorlike_header *out_hdr)
 {
   ALLOW_IMPLICIT_CONVERSION;
-  return dump_object_finish (ctx, out_hdr, vectorlike_nbytes (out_hdr));
+  dump_off result = dump_object_finish (ctx, out_hdr,
+                                       vectorlike_nbytes (out_hdr));
   DISALLOW_IMPLICIT_CONVERSION;
+  return result;
 }
 
 static void
@@ -3237,7 +3235,8 @@ static void
 dump_metadata_for_pdumper (struct dump_context *ctx)
 {
   for (int i = 0; i < nr_dump_hooks; ++i)
-    dump_emacs_reloc_to_emacs_ptr_raw (ctx, &dump_hooks[i], dump_hooks[i]);
+    dump_emacs_reloc_to_emacs_ptr_raw (ctx, &dump_hooks[i],
+                                      (void const *) dump_hooks[i]);
   dump_emacs_reloc_immediate_int (ctx, &nr_dump_hooks, nr_dump_hooks);
 
   for (int i = 0; i < nr_remembered_data; ++i)
@@ -3801,8 +3800,8 @@ dump_merge_emacs_relocs (Lisp_Object lreloc_a, 
Lisp_Object lreloc_b)
                 dump_off_to_lisp (reloc_a.length));
 }
 
-typedef void (*drain_reloc_handler)(struct dump_context *, Lisp_Object);
-typedef Lisp_Object (*drain_reloc_merger)(Lisp_Object a, Lisp_Object b);
+typedef void (*drain_reloc_handler) (struct dump_context *, Lisp_Object);
+typedef Lisp_Object (*drain_reloc_merger) (Lisp_Object a, Lisp_Object b);
 
 static void
 drain_reloc_list (struct dump_context *ctx,
@@ -4040,7 +4039,7 @@ types.  */)
   ctx->deferred_symbols = Qnil;
 
   ctx->fixups = Qnil;
-  ctx->staticpro_table = CALLN (Fmake_hash_table);
+  ctx->staticpro_table = Fmake_hash_table (0, NULL);
   ctx->symbol_aux = Qnil;
   ctx->copied_queue = Qnil;
   ctx->cold_queue = Qnil;
@@ -4587,7 +4586,7 @@ struct dump_memory_map
 {
   struct dump_memory_map_spec spec;
   void *mapping;  /* Actual mapped memory.  */
-  void (*release)(struct dump_memory_map *);
+  void (*release) (struct dump_memory_map *);
   void *private;
 };
 
diff --git a/src/print.c b/src/print.c
index 8b163e3..68ed678 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1787,7 +1787,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag,
     case PVEC_MODULE_FUNCTION:
       {
        print_c_string ("#<module function ", printcharfun);
-        void *ptr = module_function_address (XMODULE_FUNCTION (obj));
+        module_funcptr ptr = module_function_address (XMODULE_FUNCTION (obj));
         const char *file = NULL;
        const char *symbol = NULL;
        dynlib_addr (ptr, &file, &symbol);
diff --git a/src/xdisp.c b/src/xdisp.c
index 825b74d..c77a980 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -32910,14 +32910,18 @@ which no explicit name has been set (see 
`modify-frame-parameters').  */);
 This variable has the same structure as `mode-line-format' (which see),
 and is used only on frames for which no explicit name has been set
 \(see `modify-frame-parameters').  */);
+  /* Do not nest calls to pure_list.  This works around a bug in
+     Oracle Developer Studio 12.6.  */
+  Lisp_Object icon_title_name_format
+    = pure_list (empty_unibyte_string,
+                intern_c_string ("invocation-name"),
+                build_pure_c_string ("@"),
+                intern_c_string ("system-name"));
   Vicon_title_format
     = Vframe_title_format
     = pure_list (intern_c_string ("multiple-frames"),
                 build_pure_c_string ("%b"),
-                pure_list (empty_unibyte_string,
-                           intern_c_string ("invocation-name"),
-                           build_pure_c_string ("@"),
-                           intern_c_string ("system-name")));
+                icon_title_name_format);
 
   DEFVAR_LISP ("message-log-max", Vmessage_log_max,
     doc: /* Maximum number of lines to keep in the message log buffer.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]