summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
Diffstat (limited to 'libguile')
-rw-r--r--libguile/ChangeLog30
-rw-r--r--libguile/fports.c22
-rw-r--r--libguile/fports.h10
-rw-r--r--libguile/init.c6
-rw-r--r--libguile/ports.c14
-rw-r--r--libguile/ports.h9
-rw-r--r--libguile/posix.c2
-rw-r--r--libguile/strports.c15
-rw-r--r--libguile/tags.h8
-rw-r--r--libguile/vports.c14
10 files changed, 83 insertions, 47 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 0d03bc3c7..8ce25d60b 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,5 +1,35 @@
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
(set-source-property! <obj> 'copy <datum>) correctly.
diff --git a/libguile/fports.c b/libguile/fports.c
index 093a4ee45..302303f5e 100644
--- a/libguile/fports.c
+++ b/libguile/fports.c
@@ -69,6 +69,10 @@ scm_sizet fwrite ();
#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;
@@ -767,12 +771,11 @@ fport_free (SCM port)
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);
@@ -781,17 +784,22 @@ scm_make_fptob ()
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
}
/*
diff --git a/libguile/fports.h b/libguile/fports.h
index d543c63df..8fc992579 100644
--- a/libguile/fports.h
+++ b/libguile/fports.h
@@ -58,13 +58,15 @@ struct scm_fport {
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)
diff --git a/libguile/init.c b/libguile/init.c
index 674510680..2c079df7b 100644
--- a/libguile/init.c
+++ b/libguile/init.c
@@ -499,7 +499,8 @@ scm_init_guile_1 (SCM_STACKITEM *base)
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 ();
@@ -539,7 +540,6 @@ scm_init_guile_1 (SCM_STACKITEM *base)
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 */
@@ -570,7 +570,7 @@ scm_init_guile_1 (SCM_STACKITEM *base)
#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 ();
diff --git a/libguile/ports.c b/libguile/ports.c
index f955b0302..a840ff538 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -115,7 +115,7 @@ end_input_default (SCM port, int offset)
{
}
-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))
@@ -1382,23 +1382,11 @@ scm_port_print (SCM exp, SCM port, scm_print_state *pstate)
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 ();
}
diff --git a/libguile/ports.h b/libguile/ports.h
index 9676bde18..fe2c0dc92 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -217,10 +217,11 @@ extern int scm_port_table_room;
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,
diff --git a/libguile/posix.c b/libguile/posix.c
index cf8146b67..b766cb4c1 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -716,7 +716,7 @@ SCM_DEFINE (scm_ttyname, "ttyname", 1, 0, 0,
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));
diff --git a/libguile/strports.c b/libguile/strports.c
index d0b9f57a6..0e48e0f7d 100644
--- a/libguile/strports.c
+++ b/libguile/strports.c
@@ -79,6 +79,10 @@
when rw_active is SCM_PORT_NEITHER.
*/
+
+static scm_bits_t scm_tc16_strport;
+
+
static int
stfill_buffer (SCM port)
{
@@ -416,22 +420,25 @@ SCM_DEFINE (scm_eval_string, "eval-string", 1, 0, 0,
}
#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
diff --git a/libguile/tags.h b/libguile/tags.h
index 6d4b6ed70..02ddeec9e 100644
--- a/libguile/tags.h
+++ b/libguile/tags.h
@@ -372,16 +372,10 @@ typedef long scm_bits_t;
#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.
*/
diff --git a/libguile/vports.c b/libguile/vports.c
index 512d55862..cdb43598d 100644
--- a/libguile/vports.c
+++ b/libguile/vports.c
@@ -67,6 +67,9 @@
*/
+static scm_bits_t scm_tc16_sfport;
+
+
static void
sf_flush (SCM port)
{
@@ -197,20 +200,23 @@ SCM_DEFINE (scm_make_soft_port, "make-soft-port", 2, 0, 0,
#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