On Fri, May 15, 2009 at 1:30 PM, Jerry James <james(a)xemacs.org> wrote:
The lvalue version is easy, since console_data is a void *, so
anything can be assigned to it. I'd probably write the
non-error-checking version like this:
#define CONSOLE_TYPE_DATA_LVALUE(con) ((con)->console_data)
or, more likely, just dispense with the stupid macro and assign to
con->console_data directly. What do you other developers think?
So here's a concrete proposal. Please give me your reaction to this
patch. It looks like we have several other places in the codebase
that need a similar treatment for us to compile safely with alias
analysis turned on:
Note that we aren't losing anything with error-checking on, because
each affected function has other error-checking calls using the
original macro.
diff -r c064d7197712 src/console-impl.h
--- a/src/console-impl.h Sat Apr 18 03:24:48 2009 +0900
+++ b/src/console-impl.h Fri May 15 13:49:44 2009 -0600
@@ -469,11 +469,11 @@
return con;
}
# define CONSOLE_TYPE_DATA(con, type) \
- (*(struct type##_console **) \
- &(error_check_console_type (con, Q##type))->console_data)
+ ((struct type##_console *) \
+ (error_check_console_type (con, Q##type))->console_data)
#else
# define CONSOLE_TYPE_DATA(con, type) \
- (*(struct type##_console **) &((con)->console_data))
+ ((struct type##_console *) ((con)->console_data))
#endif
#define CHECK_CONSOLE_TYPE(x, type) do { \
diff -r c064d7197712 src/console-stream.c
--- a/src/console-stream.c Sat Apr 18 03:24:48 2009 +0900
+++ b/src/console-stream.c Fri May 15 13:49:44 2009 -0600
@@ -72,12 +72,12 @@
struct stream_console *stream_con;
#ifdef NEW_GC
- if (CONSOLE_STREAM_DATA (con) == NULL)
- CONSOLE_STREAM_DATA (con) = alloc_lrecord_type (struct stream_console,
- &lrecord_stream_console);
+ if (con->console_data == NULL)
+ con->console_data = alloc_lrecord_type (struct stream_console,
+ &lrecord_stream_console);
#else /* not NEW_GC */
- if (CONSOLE_STREAM_DATA (con) == NULL)
- CONSOLE_STREAM_DATA (con) = xnew_and_zero (struct stream_console);
+ if (con->console_data == NULL)
+ con->console_data = xnew_and_zero (struct stream_console);
#endif /* not NEW_GC */
stream_con = CONSOLE_STREAM_DATA (con);
@@ -140,7 +140,7 @@
#ifndef NEW_GC
xfree (stream_con, struct stream_console *);
#endif /* not NEW_GC */
- CONSOLE_STREAM_DATA (con) = NULL;
+ con->console_data = NULL;
}
}
diff -r c064d7197712 src/console-tty.c
--- a/src/console-tty.c Sat Apr 18 03:24:48 2009 +0900
+++ b/src/console-tty.c Fri May 15 13:49:44 2009 -0600
@@ -77,10 +77,10 @@
{
/* zero out all slots except the lisp ones ... */
#ifdef NEW_GC
- CONSOLE_TTY_DATA (con) = alloc_lrecord_type (struct tty_console,
- &lrecord_tty_console);
+ con->console_data = alloc_lrecord_type (struct tty_console,
+ &lrecord_tty_console);
#else /* not NEW_GC */
- CONSOLE_TTY_DATA (con) = xnew_and_zero (struct tty_console);
+ con->console_data = xnew_and_zero (struct tty_console);
#endif /* not NEW_GC */
CONSOLE_TTY_DATA (con)->terminal_type = Qnil;
CONSOLE_TTY_DATA (con)->instream = Qnil;
@@ -222,7 +222,7 @@
#ifndef NEW_GC
xfree (tty_con, struct tty_console *);
#endif /* not NEW_GC */
- CONSOLE_TTY_DATA (con) = NULL;
+ con->console_data = NULL;
}
}
--
Jerry James
http://www.jamezone.org/
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta