1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

* pairs.h, eval.c, gc.c, init.c, ioext.c, ports.c, ports.h,

srcprop.h, tags.h, throw.c, unif.c: Added new selectors
SCM_SETAND_CAR, SCM_SETAND_CDR, SCM_SETOR_CAR and SCM_SETOR_CDR.
Motivation: Safer use.  Some other macros are defined in terms of
these operations.  If these are defined using the SCM_SETCXR
(<e1>, SCM_CXR (<e1>) <op> <e2>) pattern a complex <e1> will lead
to inefficiency and an <e1> with side-effects could potentially
break.  Also, these particular operations are heavily utilized in
the garbage collector.  In unoptimized code there will be a
measurable speedup.

* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
This commit is contained in:
Mikael Djurfeldt 1996-10-20 03:28:34 +00:00
parent 3f46d95978
commit 898a256f91
8 changed files with 34 additions and 32 deletions

View file

@ -145,13 +145,13 @@ scm_start_stack (base, in, out, err)
{
SCM_NEWCELL (scm_def_inp);
pt = scm_add_to_port_table (scm_def_inp);
SCM_CAR (scm_def_inp) = (scm_tc16_fport | SCM_OPN | SCM_RDNG);
SCM_SETCAR (scm_def_inp, (scm_tc16_fport | SCM_OPN | SCM_RDNG));
SCM_SETPTAB_ENTRY (scm_def_inp, pt);
SCM_SETSTREAM (scm_def_inp, (SCM)in);
if (isatty (fileno (in)))
{
scm_setbuf0 (scm_def_inp); /* turn off stdin buffering */
SCM_CAR (scm_def_inp) |= SCM_BUF0;
SCM_SETOR_CAR (scm_def_inp, SCM_BUF0);
}
scm_set_port_revealed_x (scm_def_inp, SCM_MAKINUM (1));
}
@ -164,7 +164,7 @@ scm_start_stack (base, in, out, err)
{
SCM_NEWCELL (scm_def_outp);
pt = scm_add_to_port_table (scm_def_outp);
SCM_CAR (scm_def_outp) = (scm_tc16_fport | SCM_OPN | SCM_WRTNG);
SCM_SETCAR (scm_def_outp, (scm_tc16_fport | SCM_OPN | SCM_WRTNG));
SCM_SETPTAB_ENTRY (scm_def_outp, pt);
SCM_SETSTREAM (scm_def_outp, (SCM)out);
scm_set_port_revealed_x (scm_def_outp, SCM_MAKINUM (1));
@ -178,7 +178,7 @@ scm_start_stack (base, in, out, err)
{
SCM_NEWCELL (scm_def_errp);
pt = scm_add_to_port_table (scm_def_errp);
SCM_CAR (scm_def_errp) = (scm_tc16_fport | SCM_OPN | SCM_WRTNG);
SCM_SETCAR (scm_def_errp, (scm_tc16_fport | SCM_OPN | SCM_WRTNG));
SCM_SETPTAB_ENTRY (scm_def_errp, pt);
SCM_SETSTREAM (scm_def_errp, (SCM)err);
scm_set_port_revealed_x (scm_def_errp, SCM_MAKINUM (1));
@ -199,7 +199,7 @@ scm_start_stack (base, in, out, err)
*/
SCM_NEWCELL (scm_rootcont);
SCM_SETJMPBUF (scm_rootcont, scm_must_malloc ((long) sizeof (scm_contregs), "continuation"));
SCM_CAR (scm_rootcont) = scm_tc7_contin;
SCM_SETCAR (scm_rootcont, scm_tc7_contin);
SCM_SEQ (scm_rootcont) = 0;
/* The root continuation if further initialized by scm_restart_stack. */

View file

@ -116,14 +116,15 @@ scm_sys_freopen (filename, modes, port)
SCM p;
p = port;
port = SCM_MAKINUM (errno);
SCM_CAR (p) &= ~SCM_OPN;
SCM_SETAND_CAR (p, ~SCM_OPN);
scm_remove_from_port_table (p);
}
else
{
SCM_CAR (port) = scm_tc16_fport | scm_mode_bits (SCM_CHARS (modes));
SCM_SETCAR (port, scm_tc16_fport | scm_mode_bits (SCM_CHARS (modes)));
SCM_SETSTREAM (port, (SCM)f);
if (SCM_BUF0 & (SCM_CAR (port) = scm_tc16_fport | scm_mode_bits (SCM_CHARS (modes))))
SCM_SETCAR (port, scm_tc16_fport | scm_mode_bits (SCM_CHARS (modes)));
if (SCM_BUF0 & SCM_CAR (port))
scm_setbuf0 (port);
}
SCM_ALLOW_INTS;
@ -163,7 +164,8 @@ scm_sys_duplicate_port (oldpt, modes)
struct scm_port_table * pt;
pt = scm_add_to_port_table (newpt);
SCM_SETPTAB_ENTRY (newpt, pt);
if (SCM_BUF0 & (SCM_CAR (newpt) = scm_tc16_fport | scm_mode_bits (SCM_CHARS (modes))))
SCM_SETCAR (newpt, scm_tc16_fport | scm_mode_bits (SCM_CHARS (modes)));
if (SCM_BUF0 & SCM_CAR (newpt))
scm_setbuf0 (newpt);
SCM_SETSTREAM (newpt, (SCM)f);
SCM_PTAB_ENTRY (newpt)->file_name = SCM_PTAB_ENTRY (oldpt)->file_name;
@ -249,8 +251,8 @@ scm_sys_fdopen (fdes, modes)
scm_syserror (s_sys_fdopen);
pt = scm_add_to_port_table (port);
SCM_SETPTAB_ENTRY (port, pt);
if (SCM_BUF0 & (SCM_CAR (port) = scm_tc16_fport
| scm_mode_bits (SCM_CHARS (modes))))
SCM_SETCAR (port, scm_tc16_fport | scm_mode_bits (SCM_CHARS (modes)));
if (SCM_BUF0 & SCM_CAR (port))
scm_setbuf0 (port);
SCM_SETSTREAM (port, (SCM)f);
SCM_ALLOW_INTS;

View file

@ -444,7 +444,7 @@ scm_close_port (port)
if (scm_ptobs[i].fclose)
SCM_SYSCALL ((scm_ptobs[i].fclose) (SCM_STREAM (port)));
scm_remove_from_port_table (port);
SCM_CAR (port) &= ~SCM_OPN;
SCM_SETAND_CAR (port, ~SCM_OPN);
SCM_ALLOW_INTS;
return SCM_UNSPECIFIED;
}
@ -877,7 +877,7 @@ scm_void_port (mode_str)
SCM_DEFER_INTS;
mode_bits = scm_mode_bits (mode_str);
pt = scm_add_to_port_table (answer);
SCM_CAR (answer) = scm_tc16_void_port | mode_bits;
SCM_SETCAR (answer, scm_tc16_void_port | mode_bits);
SCM_SETPTAB_ENTRY (answer, pt);
SCM_SETSTREAM (answer, SCM_BOOL_F);
SCM_ALLOW_INTS;

View file

@ -122,9 +122,9 @@ extern int scm_port_table_size; /* Number of ports in scm_port_table. */
#define SCM_SETREVEALED(x,s) (SCM_PTAB_ENTRY(x)->revealed = s)
#define SCM_PORT_REPRESENTATION(x) SCM_PTAB_ENTRY(x)->representation
#define SCM_SET_PORT_REPRESENTATION(x,s) (SCM_PTAB_ENTRY(x)->representation = s)
#define SCM_CRDYP(port) (SCM_CAR(port) & SCM_CRDY)
#define SCM_CLRDY(port) {SCM_CAR(port) &= SCM_CUC;}
#define SCM_SETRDY(port) {SCM_CAR(port) |= SCM_CRDY;}
#define SCM_CRDYP(port) (SCM_CAR (port) & SCM_CRDY)
#define SCM_CLRDY(port) {SCM_SETAND_CAR (port, SCM_CUC);}
#define SCM_SETRDY(port) {SCM_SETOR_CAR (port, SCM_CRDY);}
#define SCM_CUNGET(c,port) {SCM_PTAB_ENTRY(port)->unchr = c; SCM_SETRDY(port);}
#define SCM_CGETUN(port) (SCM_PTAB_ENTRY(port)->unchr)

View file

@ -100,8 +100,8 @@ typedef struct scm_srcprops_chunk
#define SRCPROPFNAME(p) ((scm_srcprops *) SCM_CDR (p))->fname
#define SRCPROPCOPY(p) ((scm_srcprops *) SCM_CDR (p))->copy
#define SRCPROPPLIST(p) ((scm_srcprops *) SCM_CDR (p))->plist
#define SETSRCPROPBRK(p) (SCM_CAR (p) = SCM_CAR (p) | (1L << 16))
#define CLEARSRCPROPBRK(p) (SCM_CAR (p) = SCM_CAR (p) & ~(1L << 16))
#define SETSRCPROPBRK(p) (SCM_SETOR_CAR (p, (1L << 16)))
#define CLEARSRCPROPBRK(p) SCM_SETAND_CAR (p, ~(1L << 16))
#define SRCPROPMAKPOS(l,c) (((l) << 12) + (c))
#define SETSRCPROPPOS(p,l,c) (SRCPROPPOS (p) = SRCPROPMAKPOS (l, c))
#define SETSRCPROPLINE(p,l) SETSRCPROPPOS (p, l, SRCPROPCOL (p))

View file

@ -323,10 +323,10 @@ typedef long SCM;
*/
#define SCM_GCMARKP(x) (1 & (int)SCM_CDR(x))
#define SCM_GC8MARKP(x) (0x80 & (int)SCM_CAR(x))
#define SCM_SETGCMARK(x) (SCM_CDR(x) |= 1)
#define SCM_CLRGCMARK(x) (SCM_CDR(x) &= ~1L)
#define SCM_SETGC8MARK(x) (SCM_CAR(x) |= 0x80)
#define SCM_CLRGC8MARK(x) (SCM_CAR(x) &= ~0x80L)
#define SCM_SETGCMARK(x) SCM_SETOR_CDR (x,1)
#define SCM_CLRGCMARK(x) SCM_SETAND_CDR (x, ~1L)
#define SCM_SETGC8MARK(x) SCM_SETOR_CAR (x, 0x80)
#define SCM_CLRGC8MARK(x) SCM_SETAND_CAR (x, ~0x80L)

View file

@ -62,8 +62,8 @@ static int scm_tc16_jmpbuffer;
#define SCM_JMPBUFP(O) (SCM_TYP16(O) == scm_tc16_jmpbuffer)
#define JBACTIVE(O) (SCM_CAR (O) & (1L << 16L))
#define ACTIVATEJB(O) (SCM_CAR (O) |= (1L << 16L))
#define DEACTIVATEJB(O) (SCM_CAR (O) &= ~(1L << 16L))
#define ACTIVATEJB(O) (SCM_SETOR_CAR (O, (1L << 16L)))
#define DEACTIVATEJB(O) (SCM_SETAND_CAR (O, ~(1L << 16L)))
#ifndef DEBUG_EXTENSIONS
#define JBJMPBUF(O) ((jmp_buf*)SCM_CDR (O) )
@ -71,7 +71,7 @@ static int scm_tc16_jmpbuffer;
#else
#define SCM_JBDFRAME(O) ((scm_debug_frame*)SCM_CAR (SCM_CDR (O)) )
#define JBJMPBUF(O) ((jmp_buf*)SCM_CDR (SCM_CDR (O)) )
#define SCM_SETJBDFRAME(O,X) SCM_CAR(SCM_CDR (O)) = (SCM)(X)
#define SCM_SETJBDFRAME(O,X) SCM_SETCAR (SCM_CDR (O), (SCM)(X))
#define SETJBJMPBUF(O,X) SCM_SETCDR(SCM_CDR (O), X)
static scm_sizet freejb SCM_P ((SCM jbsmob));
@ -122,7 +122,7 @@ make_jmpbuf ()
char *mem = scm_must_malloc (sizeof (scm_cell), "jb");
SCM_SETCDR (answer, (SCM) mem);
#endif
SCM_CAR(answer) = scm_tc16_jmpbuffer;
SCM_SETCAR (answer, scm_tc16_jmpbuffer);
SETJBJMPBUF(answer, (jmp_buf *)0);
DEACTIVATEJB(answer);
}

View file

@ -182,7 +182,7 @@ scm_makflo (x)
return scm_flo0;
SCM_NEWCELL (z);
SCM_DEFER_INTS;
SCM_CAR (z) = scm_tc_flo;
SCM_SETCAR (z, scm_tc_flo);
SCM_FLO (z) = x;
SCM_ALLOW_INTS;
return z;
@ -501,7 +501,7 @@ scm_make_ra (ndim)
SCM_DEFER_INTS;
SCM_SETCDR (ra, scm_must_malloc ((long) (sizeof (scm_array) + ndim * sizeof (scm_array_dim)),
"array"));
SCM_CAR (ra) = ((long) ndim << 17) + scm_tc16_array;
SCM_SETCAR (ra, ((long) ndim << 17) + scm_tc16_array);
SCM_ARRAY_V (ra) = scm_nullvect;
SCM_ALLOW_INTS;
return ra;
@ -583,7 +583,7 @@ scm_dimensions_to_uniform_array (dims, prot, fill)
SCM_ASSERT (SCM_NULLP (dims) || (SCM_NIMP (dims) && SCM_CONSP (dims)),
dims, SCM_ARG1, s_dimensions_to_uniform_array);
ra = scm_shap2ra (dims, s_dimensions_to_uniform_array);
SCM_CAR (ra) |= SCM_ARRAY_CONTIGUOUS;
SCM_SETOR_CAR (ra, SCM_ARRAY_CONTIGUOUS);
s = SCM_ARRAY_DIMS (ra);
k = SCM_ARRAY_NDIM (ra);
while (k--)
@ -653,14 +653,14 @@ scm_ra_set_contp (ra)
{
if (inc != SCM_ARRAY_DIMS (ra)[k].inc)
{
SCM_CAR (ra) &= ~SCM_ARRAY_CONTIGUOUS;
SCM_SETAND_CAR (ra, ~SCM_ARRAY_CONTIGUOUS);
return;
}
inc *= (SCM_ARRAY_DIMS (ra)[k].ubnd
- SCM_ARRAY_DIMS (ra)[k].lbnd + 1);
}
}
SCM_CAR (ra) |= SCM_ARRAY_CONTIGUOUS;
SCM_SETOR_CAR (ra, SCM_ARRAY_CONTIGUOUS);
}
@ -736,7 +736,7 @@ scm_make_shared_array (oldra, mapfunc, dims)
{
if (s[k].ubnd > s[k].lbnd)
{
SCM_CAR (indptr) = SCM_MAKINUM (SCM_INUM (SCM_CAR (indptr)) + 1);
SCM_SETCAR (indptr, SCM_MAKINUM (SCM_INUM (SCM_CAR (indptr)) + 1));
imap = scm_apply (mapfunc, scm_reverse (inds), SCM_EOL);
if (SCM_ARRAYP (oldra))