aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.c
diff options
context:
space:
mode:
authorPaul Eggert2011-04-29 00:54:43 -0700
committerPaul Eggert2011-04-29 00:54:43 -0700
commit8ac068ac0c00afa85bc4df54032b7a855c639312 (patch)
tree551b5146f8f0c9e5c2f7129eaac0fb9f97d8a866 /src/doc.c
parentc7b270ab8559d9c9ca86ed5887b86b537796042d (diff)
downloademacs-8ac068ac0c00afa85bc4df54032b7a855c639312.tar.gz
emacs-8ac068ac0c00afa85bc4df54032b7a855c639312.zip
Prefer intptr_t/uintptr_t for integers the same widths as pointers.
This removes an assumption that EMACS_INT and long are the same width as pointers. The assumption is true for Emacs porting targets now, but we want to make other targets possible. * lisp.h: Include <inttypes.h>, for INTPTR_MAX, UINTPTR_MAX. (EMACS_INTPTR, EMACS_UINTPTR): New macros. In the rest of the code, change types of integers that hold casted pointers to EMACS_INTPTR and EMACS_UINTPTR, systematically replacing EMACS_INT, long, EMACS_UINT, and unsigned long. (XTYPE): Don't cast arg to EMACS_UINT; normally is not needed. (XSET): Cast type of XTYPE arg to EMACS_INTPTR; it is needed here. No need to cast type when ORing. (XPNTR): Return a value of type EMACS_INTPTR or EMACS_UINTPTR. * alloc.c (lisp_align_malloc): Remove a no-longer-needed cast. * doc.c (store_function_docstring): Use EMACS_INTPTR, so as not to assume EMACS_INT is the same width as char *. * gtkutil.c (xg_gtk_scroll_destroy, xg_tool_bar_button_cb): (xg_tool_bar_callback, xg_tool_bar_help_callback, xg_make_tool_item): Remove no-longer-needed casts. (xg_create_scroll_bar, xg_tool_bar_button_cb, xg_tool_bar_callback): (xg_tool_bar_help_callback, xg_make_tool_item): Use EMACS_INTPTR to hold an integer that will be cast to void *; this can avoid a GCC warning if EMACS_INT is not the same width as void *. * menu.c (find_and_call_menu_selection): Remove no-longer-needed cast. * xdisp.c (display_echo_area_1, resize_mini_window_1): (current_message_1, set_message_1): Use a local to convert to proper width without a cast. * xmenu.c (dialog_selection_callback): Likewise.
Diffstat (limited to 'src/doc.c')
-rw-r--r--src/doc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/doc.c b/src/doc.c
index 3832eb3708d..740bb26ff08 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -349,10 +349,10 @@ string is passed through `substitute-command-keys'. */)
349 return Qnil; 349 return Qnil;
350 /* FIXME: This is not portable, as it assumes that string 350 /* FIXME: This is not portable, as it assumes that string
351 pointers have the top bit clear. */ 351 pointers have the top bit clear. */
352 else if ((EMACS_INT) XSUBR (fun)->doc >= 0) 352 else if ((EMACS_INTPTR) XSUBR (fun)->doc >= 0)
353 doc = build_string (XSUBR (fun)->doc); 353 doc = build_string (XSUBR (fun)->doc);
354 else 354 else
355 doc = make_number ((EMACS_INT) XSUBR (fun)->doc); 355 doc = make_number ((EMACS_INTPTR) XSUBR (fun)->doc);
356 } 356 }
357 else if (COMPILEDP (fun)) 357 else if (COMPILEDP (fun))
358 { 358 {
@@ -506,8 +506,11 @@ store_function_docstring (Lisp_Object fun, EMACS_INT offset)
506 /* The type determines where the docstring is stored. */ 506 /* The type determines where the docstring is stored. */
507 507
508 /* Lisp_Subrs have a slot for it. */ 508 /* Lisp_Subrs have a slot for it. */
509 if (SUBRP (fun)) 509 if (SUBRP (fun))
510 XSUBR (fun)->doc = (char *) - offset; 510 {
511 EMACS_INTPTR negative_offset = - offset;
512 XSUBR (fun)->doc = (char *) negative_offset;
513 }
511 514
512 /* If it's a lisp form, stick it in the form. */ 515 /* If it's a lisp form, stick it in the form. */
513 else if (CONSP (fun)) 516 else if (CONSP (fun))