summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@oblong.net>2009-03-17 16:05:37 +0100
committerAndy Wingo <wingo@oblong.net>2009-03-17 16:05:37 +0100
commit80a7d5dc8e39efcedb9882f20902a42e66371053 (patch)
tree6dab85110b15a15fa740640ed875fd2b77b967e6
parent798e66ab10aba03ab98a070dbaef427e4cc1573f (diff)
parent5bb2d903b9e54fdd5858a16ba11fa91a9dc0c692 (diff)
downloadguile-80a7d5dc8e39efcedb9882f20902a42e66371053.tar.gz
Merge commit '5bb2d903b9e54fdd5858a16ba11fa91a9dc0c692' into vm-check
-rw-r--r--libguile/goops.c7
-rw-r--r--libguile/objects.h8
-rw-r--r--libguile/ports.c4
-rw-r--r--libguile/ports.h5
4 files changed, 14 insertions, 10 deletions
diff --git a/libguile/goops.c b/libguile/goops.c
index 340a9d05e..a6923354f 100644
--- a/libguile/goops.c
+++ b/libguile/goops.c
@@ -2771,9 +2771,10 @@ create_port_classes (void)
{
long i;
- scm_port_class = (SCM *) scm_malloc (3 * 256 * sizeof (SCM));
- for (i = 0; i < 3 * 256; ++i)
- scm_port_class[i] = 0;
+ /* Allocate 3 times the maximum number of port types so that input ports,
+ output ports, and in/out ports can be stored at different offsets. See
+ `SCM_IN_PCLASS_INDEX' et al. */
+ scm_port_class = scm_calloc (3 * SCM_I_MAX_PORT_TYPE_COUNT * sizeof (SCM));
for (i = 0; i < scm_numptob; ++i)
scm_make_port_classes (i, SCM_PTOBNAME (i));
diff --git a/libguile/objects.h b/libguile/objects.h
index 68996d2a0..9b2a0ed5a 100644
--- a/libguile/objects.h
+++ b/libguile/objects.h
@@ -3,7 +3,7 @@
#ifndef SCM_OBJECTS_H
#define SCM_OBJECTS_H
-/* Copyright (C) 1996,1999,2000,2001, 2003, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1999,2000,2001, 2003, 2006, 2008, 2009 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -171,9 +171,9 @@ typedef struct scm_effective_slot_definition {
#define SCM_CMETHOD_ENV(cmethod) SCM_CAR (cmethod)
/* Port classes */
-#define SCM_IN_PCLASS_INDEX 0x000
-#define SCM_OUT_PCLASS_INDEX 0x100
-#define SCM_INOUT_PCLASS_INDEX 0x200
+#define SCM_IN_PCLASS_INDEX 0
+#define SCM_OUT_PCLASS_INDEX SCM_I_MAX_PORT_TYPE_COUNT
+#define SCM_INOUT_PCLASS_INDEX (2 * SCM_I_MAX_PORT_TYPE_COUNT)
/* Plugin proxy classes for basic types. */
SCM_API SCM scm_metaclass_standard;
diff --git a/libguile/ports.c b/libguile/ports.c
index 2b7677220..dc412a445 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -136,7 +136,7 @@ scm_make_port_type (char *name,
void (*write) (SCM port, const void *data, size_t size))
{
char *tmp;
- if (255 <= scm_numptob)
+ if (SCM_I_MAX_PORT_TYPE_COUNT - 1 <= scm_numptob)
goto ptoberr;
SCM_CRITICAL_SECTION_START;
SCM_SYSCALL (tmp = (char *) realloc ((char *) scm_ptobs,
diff --git a/libguile/ports.h b/libguile/ports.h
index 084a55500..cb9d9d2d5 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -3,7 +3,7 @@
#ifndef SCM_PORTS_H
#define SCM_PORTS_H
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -162,6 +162,9 @@ SCM_INTERNAL SCM scm_i_port_weak_hash;
#define SCM_DECCOL(port) {if (SCM_COL (port) > 0) SCM_COL (port) -= 1;}
#define SCM_TABCOL(port) {SCM_COL (port) += 8 - SCM_COL (port) % 8;}
+/* Maximum number of port types. */
+#define SCM_I_MAX_PORT_TYPE_COUNT 256
+
/* port-type description. */