# HG changeset patch # User Jerry James # Date 1415291646 25200 # Node ID 5d5aeb79edb47904410c6600f2ed1ea71c28c481 # Parent 6928877dbc26781161b655a841c000d5622079ed Fix build with g++. This patch fixes various issues that cause build failures with g++ 4.8.3. See in xemacs-patches. diff -r 6928877dbc26 -r 5d5aeb79edb4 src/ChangeLog --- a/src/ChangeLog Sat Oct 25 15:59:31 2014 +0200 +++ b/src/ChangeLog Thu Nov 06 09:34:06 2014 -0700 @@ -1,3 +1,18 @@ +2014-11-05 Jerry James + + * ExternalClient-Xlib.c (ExternalClientEventHandler): Cast integer + to long before casting to XPointer, which may be larger than int. + * database.c: Use BEGIN_C_DECLS/END_C_DECLS around dbm definitions. + * lisp.h (ALLOCA): Use NULL instead of (void) 0 to placate g++. + (MALLOC_OR_ALLOCA): Ditto. + (XSTRING_LENGTH): Use an explicit temporary with NEW_GC so g++ 4.8 + won't create an uninitialized anonymous temporary. + (XSTRING_DATA): Ditto. + * sysdll.c: Check whether HAVE_LTDL is defined, not its value. + * tls.c (tls_open): Add typecast to xmalloc call in the nss, + gnutls, and openssl versions to satisfy g++. In the gnutls version, + use gnutls_certificate_type_t appropriately. + 2014-10-25 Michael Sperber * fontcolor-x.c (x_font_instance_truename): diff -r 6928877dbc26 -r 5d5aeb79edb4 src/ExternalClient-Xlib.c --- a/src/ExternalClient-Xlib.c Sat Oct 25 15:59:31 2014 +0200 +++ b/src/ExternalClient-Xlib.c Thu Nov 06 09:34:06 2014 -0700 @@ -134,9 +134,10 @@ else return; XFindContext(display, win, focus_context, ¤t_focus); - if (focus_status != (int) current_focus) + if ((XPointer) (long) focus_status != current_focus) { - XSaveContext(display, win, focus_context, (XPointer) focus_status); + XSaveContext(display, win, focus_context, + (XPointer) (long) focus_status); extw_send_notify_3(display, win, focus_status ? extw_notify_focus_in : extw_notify_focus_out, 0, 0, 0); diff -r 6928877dbc26 -r 5d5aeb79edb4 src/database.c --- a/src/database.c Sat Oct 25 15:59:31 2014 +0200 +++ b/src/database.c Thu Nov 06 09:34:06 2014 -0700 @@ -83,6 +83,7 @@ #endif /* HAVE_BERKELEY_DB */ #ifdef HAVE_DBM +BEGIN_C_DECLS # ifdef TRUST_NDBM_H_PROTOTYPES # include NDBM_H_FILE # else /* not TRUST_NDBM_H_PROTOTYPES */ @@ -91,10 +92,6 @@ using C++, since they are of the form `datum dbm_firstkey()', without any args given. */ -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - /* Parameters to dbm_store for simple insertion or replacement. */ #define DBM_INSERT 0 #define DBM_REPLACE 1 @@ -119,11 +116,9 @@ DBM *dbm_open(const char *, int, mode_t); int dbm_store(DBM *, datum, datum, int); -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif +# endif /* (not) TRUST_NDBM_H_PROTOTYPES */ +END_C_DECLS -# endif /* (not) TRUST_NDBM_H_PROTOTYPES */ Lisp_Object Qdbm; #endif /* HAVE_DBM */ diff -r 6928877dbc26 -r 5d5aeb79edb4 src/lisp.h --- a/src/lisp.h Sat Oct 25 15:59:31 2014 +0200 +++ b/src/lisp.h Thu Nov 06 09:34:06 2014 -0700 @@ -1368,7 +1368,7 @@ __temp_alloca_size__ = (size), \ __temp_alloca_size__ > MAX_ALLOCA_VS_C_ALLOCA ? \ xemacs_c_alloca (__temp_alloca_size__) : \ - (need_to_check_c_alloca ? xemacs_c_alloca (0) : (void) 0, \ + (need_to_check_c_alloca ? xemacs_c_alloca (0) : NULL, \ alloca (__temp_alloca_size__))) /* Version of ALLOCA() that is guaranteed to work inside of function calls @@ -1402,7 +1402,7 @@ __temp_alloca_size__ = (size), \ __temp_alloca_size__ > MAX_ALLOCA_VS_MALLOC ? \ xmalloc_and_record_unwind (__temp_alloca_size__) : \ - (need_to_check_c_alloca ? xemacs_c_alloca (0) : (void) 0, \ + (need_to_check_c_alloca ? xemacs_c_alloca (0) : NULL, \ alloca (__temp_alloca_size__))) /* -------------- convenience functions for memory allocation ------------- */ @@ -2643,13 +2643,27 @@ #ifdef NEW_GC #define STRING_DATA_OBJECT(s) ((s)->data_object) #define XSTRING_DATA_OBJECT(s) (STRING_DATA_OBJECT (XSTRING (s))) -#define XSTRING_LENGTH(s) (XSTRING_DATA_SIZE (XSTRING (s))) +DECLARE_INLINE_HEADER ( +Bytecount +XSTRING_LENGTH (Lisp_Object s) +) +{ + Lisp_String *str = XSTRING (s); + return XSTRING_DATA_SIZE (str); +} #else /* not NEW_GC */ #define XSTRING_LENGTH(s) (XSTRING (s)->size_) #endif /* not NEW_GC */ #define XSTRING_PLIST(s) (XSTRING (s)->plist) #ifdef NEW_GC -#define XSTRING_DATA(s) (XSTRING_DATA_DATA (XSTRING (s))) +DECLARE_INLINE_HEADER ( +Ibyte * +XSTRING_DATA (Lisp_Object s) +) +{ + Lisp_String *str = XSTRING (s); + return XSTRING_DATA_DATA (str); +} #else /* not NEW_GC */ #define XSTRING_DATA(s) (XSTRING (s)->data_ + 0) #endif /* not NEW_GC */ diff -r 6928877dbc26 -r 5d5aeb79edb4 src/sysdll.c --- a/src/sysdll.c Sat Oct 25 15:59:31 2014 +0200 +++ b/src/sysdll.c Thu Nov 06 09:34:06 2014 -0700 @@ -454,7 +454,7 @@ NSLinkEditError (&c, &errorNumber, &fileNameWithError, &errorString); return build_extstring (errorString, Qerror_message_encoding); } -#elif HAVE_LTDL +#elif defined(HAVE_LTDL) /* Libtool's libltdl */ #include diff -r 6928877dbc26 -r 5d5aeb79edb4 src/tls.c --- a/src/tls.c Sat Oct 25 15:59:31 2014 +0200 +++ b/src/tls.c Thu Nov 06 09:34:06 2014 -0700 @@ -122,7 +122,7 @@ } /* Create the socket */ - nspr = xmalloc (sizeof (*nspr)); + nspr = (tls_state_t *) xmalloc (sizeof (*nspr)); nspr->tls_refcount = 2; nspr->tls_file_desc = SSL_ImportFD (nss_model, PR_OpenTCPSocket (addr->sa_family)); @@ -507,7 +507,7 @@ setsockopt (s, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); /* Create the state object */ - gnutls = xmalloc (sizeof (*gnutls)); + gnutls = (tls_state_t *) xmalloc (sizeof (*gnutls)); gnutls->tls_refcount = 2; /* Initialize the session object */ @@ -615,7 +615,9 @@ gnutls_datum_t msg; #ifdef HAVE_GNUTLS_CERTIFICATE_VERIFICATION_STATUS_PRINT - int type = gnutls_certificate_type_get (gnutls->tls_session); + gnutls_certificate_type_t type; + + type = gnutls_certificate_type_get (gnutls->tls_session); err = gnutls_certificate_verification_status_print (status, type, &msg, 0); #else @@ -966,7 +968,7 @@ setsockopt (s, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); /* Create the state object */ - openssl = xmalloc (sizeof (*openssl)); + openssl = (tls_state_t *) xmalloc (sizeof (*openssl)); openssl->tls_refcount = 2; /* Create the connection object */