summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-08-21 08:00:53 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-08-21 08:00:53 (GMT)
commit6abb2548315b9db2925194e54f09f01126182f81 (patch) (side-by-side diff)
tree327743c0e929933ae38a241770d08da0433561b4
parent3adba48f117f748dfb08a0dd4cdd42f214bae93f (diff)
downloadgamma-6abb2548315b9db2925194e54f09f01126182f81.tar.gz
gamma-6abb2548315b9db2925194e54f09f01126182f81.tar.bz2
Switch to Guile 2.2
Drop support for older Guile versions.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--configure.ac2
-rw-r--r--src/gamma-expat.c10
-rw-r--r--src/gsql_conn.c8
-rw-r--r--src/guile-sql.h2
-rw-r--r--src/mysql.c15
-rw-r--r--src/pgsql.c19
-rw-r--r--src/syslog-port.c124
7 files changed, 43 insertions, 137 deletions
diff --git a/configure.ac b/configure.ac
index 15aeb87..0695551 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,7 +34,7 @@ AC_PROG_INSTALL
AC_PROG_LN_S
AM_PROG_LIBTOOL
-GINT_INIT(gint,[1.8])
+GINT_INIT(gint,[2.2.0])
AC_SUBST(INCLUDEPATH)
AC_MSG_CHECKING(for additional includes)
diff --git a/src/gamma-expat.c b/src/gamma-expat.c
index a81d30e..cd3efaa 100644
--- a/src/gamma-expat.c
+++ b/src/gamma-expat.c
@@ -32,7 +32,7 @@ gamma_xml_parser_create(XML_Parser parser)
{
struct gamma_xml_parser *gp;
- gp = scm_malloc(sizeof (*gp));
+ gp = scm_gc_malloc(sizeof (*gp), "xml_parser");
gp->parser = parser;
SCM_RETURN_NEWSMOB(gamma_xml_parser_tag, gp);
}
@@ -40,7 +40,7 @@ gamma_xml_parser_create(XML_Parser parser)
#define GAMMA_XML_PARSER_PTR(smob) \
((struct gamma_xml_parser *)SCM_CDR(smob))
-static scm_sizet
+static size_t
gamma_xml_parser_free(SCM smob)
{
struct gamma_xml_parser *gp = GAMMA_XML_PARSER_PTR(smob);
@@ -84,7 +84,7 @@ gamma_xml_parser_print(SCM smob, SCM port, scm_print_state *pstate)
}
static void
-gamma_xml_parser_init()
+gamma_xml_parser_init(void)
{
gamma_xml_parser_tag =
scm_make_smob_type("XML_Parser",
@@ -96,7 +96,7 @@ gamma_xml_parser_init()
static struct gamma_expat_user_data *
-make_user_data ()
+make_user_data(void)
{
int i;
@@ -153,7 +153,7 @@ SCM_DEFINE_PUBLIC(scm_xml_primitive_make_parser, "xml-primitive-make-parser",
} else
parser = XML_ParserCreate(encoding);
if (!parser)
- scm_memory_error(FUNC_NAME);
+ scm_report_out_of_memory();
XML_SetUserData(parser, make_user_data());
free(encoding);
return gamma_xml_parser_create(parser);
diff --git a/src/gsql_conn.c b/src/gsql_conn.c
index 4d53a03..64cec27 100644
--- a/src/gsql_conn.c
+++ b/src/gsql_conn.c
@@ -34,15 +34,15 @@ static SCM
sql_connect_mark (SCM connect_smob)
{
struct sql_connect *conn = (struct sql_connect *)SCM_CDR(connect_smob);
+ if (sql_iftab[conn->iface].mark)
return sql_iftab[conn->iface].mark(conn);
}
-static scm_sizet
+static size_t
sql_connect_free (SCM connect_smob)
{
- scm_sizet size = sizeof(struct sql_connect);
struct sql_connect *conn = (struct sql_connect *)SCM_CDR(connect_smob);
- size += sql_iftab[conn->iface].free(conn);
+ sql_iftab[conn->iface].free(conn);
if (conn->hostname)
free(conn->hostname);
if (conn->username)
@@ -50,7 +50,7 @@ sql_connect_free (SCM connect_smob)
if (conn->database)
free(conn->database);
scm_gc_free(conn, sizeof *conn, "SQL connection");
- return size;
+ return 0;
}
static int
diff --git a/src/guile-sql.h b/src/guile-sql.h
index 926aa74..f656fd4 100644
--- a/src/guile-sql.h
+++ b/src/guile-sql.h
@@ -39,7 +39,7 @@ struct sql_result {
struct sql_iface {
char *name;
SCM (*mark) (struct sql_connect *);
- scm_sizet (*free) (struct sql_connect *);
+ size_t (*free) (struct sql_connect *);
SCM (*connect) (SCM parmlist, const char *func_name);
void (*close) (struct sql_connect *);
SCM (*query) (struct sql_connect *, const char *query);
diff --git a/src/mysql.c b/src/mysql.c
index 1310212..dcc1847 100644
--- a/src/mysql.c
+++ b/src/mysql.c
@@ -21,20 +21,13 @@
#include <guile-sql.h>
#include <mysql/mysql.h>
-static SCM
-s_mysql_mark(struct sql_connect *conn)
-{
- return SCM_BOOL_F;
-}
-
-static scm_sizet
+static size_t
s_mysql_free(struct sql_connect *conn)
{
MYSQL *mysql = (MYSQL*) conn->data;
- if (!mysql)
- return 0;
+ if (mysql)
mysql_close(mysql);
- return sizeof(MYSQL);
+ return 0;
}
static SCM
@@ -225,7 +218,7 @@ s_mysql_close(struct sql_connect *conn)
struct sql_iface mysql_iface = {
"mysql",
- s_mysql_mark,
+ NULL, /* mark */
s_mysql_free,
s_mysql_connect,
s_mysql_close,
diff --git a/src/pgsql.c b/src/pgsql.c
index c5cf51e..1421c40 100644
--- a/src/pgsql.c
+++ b/src/pgsql.c
@@ -21,20 +21,13 @@
#include <guile-sql.h>
#include <libpq-fe.h>
-static SCM
-s_pgsql_mark(struct sql_connect *conn)
-{
- return SCM_BOOL_F;
-}
-
-static scm_sizet
+static size_t
s_pgsql_free(struct sql_connect *conn)
{
PGconn *pgconn = (PGconn*) conn->data;
- if (!pgconn)
- return 0;
+ if (pgconn)
PQfinish(pgconn);
- return sizeof(pgconn);
+ return 0;
}
static SCM
@@ -168,15 +161,15 @@ static void
s_pgsql_close(struct sql_connect *conn)
{
PGconn *pgconn = (PGconn*) conn->data;
- if (!pgconn)
- return;
+ if (pgconn) {
PQfinish(pgconn);
conn->data = NULL;
}
+}
struct sql_iface pgsql_iface = {
"pgsql",
- s_pgsql_mark,
+ NULL, /* mark */
s_pgsql_free,
s_pgsql_connect,
s_pgsql_close,
diff --git a/src/syslog-port.c b/src/syslog-port.c
index 4b27ef9..4388c10 100644
--- a/src/syslog-port.c
+++ b/src/syslog-port.c
@@ -28,7 +28,7 @@ typedef off_t scm_t_off;
#endif
#define GAMMA_SYSLOG_PORT_BUFSIZE 1024
-static scm_t_bits scm_tc16_syslog_port;
+static scm_t_port_type *scm_syslog_port_type;
struct _gamma_syslog_port {
int prio;
};
@@ -37,118 +37,40 @@ static SCM
_make_syslog_port(int prio)
{
struct _gamma_syslog_port *dp;
- SCM port;
- scm_port *pt;
- dp = scm_gc_malloc (sizeof (struct _gamma_syslog_port), "syslog-port");
+ dp = scm_gc_typed_calloc (struct _gamma_syslog_port);
dp->prio = prio;
-
- port = scm_new_port_table_entry(scm_tc16_syslog_port);
- pt = SCM_PTAB_ENTRY(port);
- pt->rw_random = 0;
- pt->write_buf = scm_gc_malloc(GAMMA_SYSLOG_PORT_BUFSIZE,
- "syslog port buffer");
- pt->write_pos = pt->write_buf;
- pt->write_buf_size = GAMMA_SYSLOG_PORT_BUFSIZE;
- pt->write_end = pt->write_buf + pt->write_buf_size;
- SCM_SET_CELL_TYPE(port,
- (scm_tc16_syslog_port |
- SCM_OPN | SCM_WRTNG | SCM_BUFLINE));
- SCM_SETSTREAM(port, dp);
- return port;
+ return scm_c_make_port(scm_syslog_port_type,
+ SCM_OPN | SCM_WRTNG | SCM_BUFLINE,
+ (scm_t_bits) dp);
}
#define SYSLOG_PORT(x) ((struct _gamma_syslog_port *) SCM_STREAM (x))
-static SCM
-_syslog_port_mark(SCM port)
-{
- return SCM_BOOL_F;
-}
-
static void
-_syslog_port_flush(SCM port)
-{
- struct _gamma_syslog_port *dp = SYSLOG_PORT(port);
- scm_port *pt = SCM_PTAB_ENTRY(port);
- size_t size = pt->write_pos - pt->write_buf;
- unsigned char *nl = memchr(pt->write_buf, '\n', size);
- int wrsize;
-
- if (!nl)
- return;
-
- wrsize = nl - pt->write_buf;
-
- *nl = 0;
- syslog (dp->prio, "%s", (char *) pt->write_buf);
- *nl = '\n';
-
- if (wrsize < size) {
- size_t write_start;
-
- nl++;
- write_start = pt->write_pos - nl;
- memmove(pt->write_buf, nl, write_start);
- pt->write_pos = pt->write_buf + write_start;
- } else
- pt->write_pos = pt->write_buf;
-}
-
-static int
_syslog_port_close(SCM port)
{
struct _gamma_syslog_port *dp = SYSLOG_PORT(port);
-
- if (dp) {
- _syslog_port_flush(port);
- SCM_SETSTREAM(port, NULL);
- scm_gc_free(dp, sizeof(struct _gamma_syslog_port),
- "syslog-port");
- }
- return 0;
+ /* nothing */
}
-static scm_sizet
+static size_t
_syslog_port_free(SCM port)
+/* FIXME: basically, a no-op */
{
_syslog_port_close(port);
return 0;
}
-static int
-_syslog_port_fill_input(SCM port)
+static size_t
+_syslog_port_write(SCM port, SCM src, size_t start, size_t count)
{
- return EOF;
-}
-
-static void
-_syslog_port_write(SCM port, const void *data, size_t size)
-{
- scm_port *pt = SCM_PTAB_ENTRY (port);
- size_t space = pt->write_end - pt->write_pos;
- if (space < size) {
- size_t start = pt->write_pos - pt->write_buf;
- size_t new_size = pt->write_buf_size;
-
- do {
- /*FIXME*/
- new_size *= 2;
- } while (new_size - start < size);
-
- pt->write_buf = scm_gc_realloc(pt->write_buf,
- pt->write_buf_size,
- new_size,
- "syslog port buffer");
- pt->write_buf_size = new_size;
- pt->write_end = pt->write_buf + pt->write_buf_size;
- pt->write_pos = pt->write_buf + start;
- }
- memcpy(pt->write_pos, data, size);
- pt->write_pos += size;
-
- if (memchr (data, '\n', size))
- _syslog_port_flush(port);
+ struct _gamma_syslog_port *dp = SYSLOG_PORT(port);
+ syslog(dp->prio, "%*.*s",
+ (int) count,
+ (int) count,
+ SCM_BYTEVECTOR_CONTENTS(src) + start);
+ return count;
}
static scm_t_off
@@ -180,15 +102,13 @@ SCM_DEFINE_PUBLIC(scm_open_syslog_port, "open-syslog-port", 1, 0, 0,
void
_gamma_init_syslog_port()
{
- scm_tc16_syslog_port = scm_make_port_type("syslog-port",
- _syslog_port_fill_input,
+ scm_syslog_port_type = scm_make_port_type("syslog-port",
+ NULL,
_syslog_port_write);
- scm_set_port_mark(scm_tc16_syslog_port, _syslog_port_mark);
- scm_set_port_free(scm_tc16_syslog_port, _syslog_port_free);
- scm_set_port_print(scm_tc16_syslog_port, _syslog_port_print);
- scm_set_port_flush(scm_tc16_syslog_port, _syslog_port_flush);
- scm_set_port_close(scm_tc16_syslog_port, _syslog_port_close);
- scm_set_port_seek(scm_tc16_syslog_port, _syslog_port_seek);
+ scm_set_port_free(scm_syslog_port_type, _syslog_port_free);
+ scm_set_port_print(scm_syslog_port_type, _syslog_port_print);
+ scm_set_port_close(scm_syslog_port_type, _syslog_port_close);
+ scm_set_port_seek(scm_syslog_port_type, _syslog_port_seek);
#include <syslog-port.x>
}

Return to:

Send suggestions and report system problems to the System administrator.