+2001-01-25 Dirk Herrmann <D.Herrmann@tu-bs.de>
+
+ * tags.h (scm_tc16_fport, scm_tc16_strport, scm_tc16_sfport):
+ These are now defined in fports.c, strports.c and vports.c.
+
+ * fports.[ch] (scm_tc16_fport), strports.c (scm_tc16_strport),
+ vports.c (scm_tc16_sfport): Made variables (were macros defined in
+ tags.h).
+
+ fports.c (scm_make_fptob), strports.c (scm_make_stptob), vports.c
+ (scm_make_sfptob): Made static. These return a type code now.
+
+ fports.c (scm_init_fports), strports.c (scm_init_strports),
+ vports.c (scm_init_vports): Create the corresponding port types.
+
+ * fports.h (SCM_FPORTP, SCM_OPFPORTP, SCM_OPINFPORTP,
+ SCM_OPOUTFPORTP): Redefined in terms of scm_tc16_fport.
+
+ * init.c (scm_init_guile_1): Make sure strports are initialized
+ before gdbint.
+
+ * ports.[ch] (scm_make_port_type): Changed the return type to
+ scm_bits_t.
+
+ * ports.c (scm_ports_prehistory): Don't create any port types
+ here.
+
+ * posix.c (scm_ttyname): Use SCM_FPORTP instead of comparing
+ against scm_tc16_fport directly.
+
2001-01-25 Dirk Herrmann <D.Herrmann@tu-bs.de>
* srcprop.c (scm_set_source_property_x): Fix to handle
#include "libguile/iselect.h"
+
+scm_bits_t scm_tc16_fport;
+
+
/* default buffer size, used if the O/S won't supply a value. */
static const int default_buffer_size = 1024;
return 0;
}
-void scm_make_fptob (void); /* Called from ports.c */
-
-void
+static scm_bits_t
scm_make_fptob ()
{
- long tc = scm_make_port_type ("file", fport_fill_input, fport_write);
+ scm_bits_t tc = scm_make_port_type ("file", fport_fill_input, fport_write);
+
scm_set_port_free (tc, fport_free);
scm_set_port_print (tc, fport_print);
scm_set_port_flush (tc, fport_flush);
scm_set_port_seek (tc, fport_seek);
scm_set_port_truncate (tc, fport_truncate);
scm_set_port_input_waiting (tc, fport_input_waiting);
+
+ return tc;
}
void
scm_init_fports ()
{
-#ifndef SCM_MAGIC_SNARFER
-#include "libguile/fports.x"
-#endif
+ scm_tc16_fport = scm_make_fptob ();
+
scm_sysintern ("_IOFBF", SCM_MAKINUM (_IOFBF));
scm_sysintern ("_IOLBF", SCM_MAKINUM (_IOLBF));
scm_sysintern ("_IONBF", SCM_MAKINUM (_IONBF));
+
+#ifndef SCM_MAGIC_SNARFER
+#include "libguile/fports.x"
+#endif
}
/*
int fdes; /* file descriptor. */
};
+extern scm_bits_t scm_tc16_fport;
+
#define SCM_FSTREAM(x) ((struct scm_fport *) SCM_STREAM (x))
#define SCM_FPORT_FDES(x) (SCM_FSTREAM (x)->fdes)
-#define SCM_FPORTP(x) (!SCM_IMP (x) && (SCM_TYP16S (x) == scm_tc7_port))
-#define SCM_OPFPORTP(x) (!SCM_IMP (x) && (((0xfeff | SCM_OPN) & SCM_CELL_WORD_0 (x)) == (scm_tc7_port | SCM_OPN)))
-#define SCM_OPINFPORTP(x) (!SCM_IMP (x) && (((0xfeff | SCM_OPN | SCM_RDNG) & SCM_CELL_WORD_0 (x)) == (scm_tc7_port | SCM_OPN | SCM_RDNG)))
-#define SCM_OPOUTFPORTP(x) (!SCM_IMP(x) && (((0xfeff | SCM_OPN | SCM_WRTNG) & SCM_CELL_WORD_0 (x)) == (scm_tc7_port | SCM_OPN | SCM_WRTNG)))
+#define SCM_FPORTP(x) (!SCM_IMP (x) && (SCM_TYP16 (x) == scm_tc16_fport))
+#define SCM_OPFPORTP(x) (SCM_FPORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_OPN))
+#define SCM_OPINFPORTP(x) (SCM_OPFPORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_RDNG))
+#define SCM_OPOUTFPORTP(x) (SCM_OPFPORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_WRTNG))
/* test whether fdes supports random access. */
#define SCM_FDES_RANDOM_P(fdes) ((lseek (fdes, 0, SEEK_CUR) == -1) ? 0 : 1)
scm_init_fluids ();
scm_init_backtrace (); /* Requires fluids */
scm_init_fports ();
- scm_init_gdbint ();
+ scm_init_strports ();
+ scm_init_gdbint (); /* Requires strports */
scm_init_hash ();
scm_init_hashtab ();
scm_init_objprop ();
scm_init_stackchk ();
scm_init_struct ();
scm_init_stacks (); /* Requires struct */
- scm_init_strports ();
scm_init_symbols ();
scm_init_tag ();
scm_init_values (); /* Requires struct */
#endif
scm_init_simpos ();
scm_init_load_path ();
- scm_init_standard_ports ();
+ scm_init_standard_ports (); /* Requires fports */
scm_init_dynamic_linking ();
scm_init_lang ();
scm_init_script ();
{
}
-long
+scm_bits_t
scm_make_port_type (char *name,
int (*fill_input) (SCM port),
void (*write) (SCM port, const void *data, size_t size))
return 1;
}
-extern void scm_make_fptob ();
-extern void scm_make_stptob ();
-extern void scm_make_sfptob ();
-
void
scm_ports_prehistory ()
{
scm_numptob = 0;
scm_ptobs = (scm_ptob_descriptor *) malloc (sizeof (scm_ptob_descriptor));
-
- /* WARNING: These scm_newptob calls must be done in this order.
- * They must agree with the port declarations in tags.h.
- */
- /* scm_tc16_fport = */ scm_make_fptob ();
- /* scm_tc16_pipe was here */ scm_make_fptob (); /* dummy. */
- /* scm_tc16_strport = */ scm_make_stptob ();
- /* scm_tc16_sfport = */ scm_make_sfptob ();
}
\f
\f
extern SCM scm_markstream (SCM ptr);
-extern long scm_make_port_type (char *name,
- int (*fill_input) (SCM port),
- void (*write) (SCM port, const void *data,
- size_t size));
+extern scm_bits_t scm_make_port_type (char *name,
+ int (*fill_input) (SCM port),
+ void (*write) (SCM port,
+ const void *data,
+ size_t size));
extern void scm_set_port_mark (long tc, SCM (*mark) (SCM));
extern void scm_set_port_free (long tc, scm_sizet (*free) (SCM));
extern void scm_set_port_print (long tc,
port = SCM_COERCE_OUTPORT (port);
SCM_VALIDATE_OPPORT (1,port);
- if (scm_tc16_fport != SCM_TYP16 (port))
+ if (!SCM_FPORTP (port))
return SCM_BOOL_F;
fd = SCM_FPORT_FDES (port);
SCM_SYSCALL (ans = ttyname (fd));
when rw_active is SCM_PORT_NEITHER.
*/
+
+static scm_bits_t scm_tc16_strport;
+
+
static int
stfill_buffer (SCM port)
{
}
#undef FUNC_NAME
-void scm_make_stptob (void); /* Called from ports.c */
-
-void
+static scm_bits_t
scm_make_stptob ()
{
- long tc = scm_make_port_type ("string", stfill_buffer, st_write);
+ scm_bits_t tc = scm_make_port_type ("string", stfill_buffer, st_write);
+
scm_set_port_mark (tc, scm_markstream);
scm_set_port_end_input (tc, st_end_input);
scm_set_port_flush (tc, st_flush);
scm_set_port_seek (tc, st_seek);
scm_set_port_truncate (tc, st_truncate);
+
+ return tc;
}
void
scm_init_strports ()
{
+ scm_tc16_strport = scm_make_stptob ();
+
#ifndef SCM_MAGIC_SNARFER
#include "libguile/strports.x"
#endif
#define scm_tc7_lsubr 119
-/* There are 256 port subtypes. Here are the first few.
- * These must agree with the init function in ports.c
+/* There are 256 port subtypes.
*/
#define scm_tc7_port 125
-#define scm_tc16_fport (scm_tc7_port + 0 * 256L)
-/* scm_tc16_pipe was here. */
-#define scm_tc16_strport (scm_tc7_port + 2 * 256L)
-#define scm_tc16_sfport (scm_tc7_port + 3 * 256L)
-
/* There are 256 smob subtypes. Here are the first four.
*/
*/
+static scm_bits_t scm_tc16_sfport;
+
+
static void
sf_flush (SCM port)
{
#undef FUNC_NAME
-void scm_make_sfptob (void); /* Called from ports.c */
-
-void
+static scm_bits_t
scm_make_sfptob ()
{
- long tc = scm_make_port_type ("soft", sf_fill_input, sf_write);
+ scm_bits_t tc = scm_make_port_type ("soft", sf_fill_input, sf_write);
+
scm_set_port_mark (tc, scm_markstream);
scm_set_port_flush (tc, sf_flush);
scm_set_port_close (tc, sf_close);
+
+ return tc;
}
void
scm_init_vports ()
{
+ scm_tc16_sfport = scm_make_sfptob ();
+
#ifndef SCM_MAGIC_SNARFER
#include "libguile/vports.x"
#endif