[Commit] nickle ChangeLog, 1.110, 1.111 Makefile.am, 1.62,
1.63 builtin-namespaces.h, 1.4, 1.5 builtin-sockets.c, 1.15,
1.16 builtin.c, 1.20, 1.21 builtin.h, 1.9, 1.10 configure.in,
1.38, 1.39 execute.c, 1.93, 1.94 file.c, 1.64, 1.65 gram.y,
1.143, 1.144 io.c, 1.12, 1.13 lex.l, 1.80, 1.81 mem.h, 1.16,
1.17 nickle.h, 1.120, 1.121 sched.c, 1.58, 1.59 string.c, 1.19,
1.20 value.c, 1.49, 1.50 value.h, 1.108, 1.109
Keith Packard
commit at keithp.com
Fri Dec 10 22:02:28 PST 2004
- Previous message: [Commit] nickle ChangeLog,1.109,1.110 prng.5c,1.11,1.12
- Next message: [Commit] nickle ChangeLog, 1.111, 1.112 builtin.c, 1.21,
1.22 builtin.h, 1.10, 1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: keithp
Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv4060
Modified Files:
ChangeLog Makefile.am builtin-namespaces.h builtin-sockets.c
builtin.c builtin.h configure.in execute.c file.c gram.y io.c
lex.l mem.h nickle.h sched.c string.c value.c value.h
Log Message:
2004-12-10 Keith Packard <keithp at keithp.com>
* Makefile.am:
* builtin-namespaces.h:
* builtin-sockets.c: (import_Socket_namespace):
* builtin.c: (BuiltinType), (BuiltinInit):
* builtin.h:
* configure.in:
* gram.y:
* io.c: (IoTimeout):
* lex.l:
* mem.h:
* nickle.h:
* string.c: (NewStrString):
* value.c: (ValueInit):
* value.h:
Add support for dlopen and Foreign datatypes
* execute.c: (ThreadsRun):
* file.c: (FileCreate), (FilePutRep), (FileCheckBlocked),
(FileSetBlocked):
* sched.c: (BlockHandlerMark), (ThreadsRegisterBlockHandler),
(ThreadsUnregisterBlockHandler), (ThreadsBlock), (ThreadInit):
Add block handlers.
Change file block handling to use timers only on pipes,
not on disk files or terminals. That makes for a lot
fewer signals while idle at the prompt.
Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/nickle/ChangeLog,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- ChangeLog 11 Dec 2004 05:02:53 -0000 1.110
+++ ChangeLog 11 Dec 2004 06:02:23 -0000 1.111
@@ -1,5 +1,33 @@
2004-12-10 Keith Packard <keithp at keithp.com>
+ * Makefile.am:
+ * builtin-namespaces.h:
+ * builtin-sockets.c: (import_Socket_namespace):
+ * builtin.c: (BuiltinType), (BuiltinInit):
+ * builtin.h:
+ * configure.in:
+ * gram.y:
+ * io.c: (IoTimeout):
+ * lex.l:
+ * mem.h:
+ * nickle.h:
+ * string.c: (NewStrString):
+ * value.c: (ValueInit):
+ * value.h:
+ Add support for dlopen and Foreign datatypes
+
+ * execute.c: (ThreadsRun):
+ * file.c: (FileCreate), (FilePutRep), (FileCheckBlocked),
+ (FileSetBlocked):
+ * sched.c: (BlockHandlerMark), (ThreadsRegisterBlockHandler),
+ (ThreadsUnregisterBlockHandler), (ThreadsBlock), (ThreadInit):
+ Add block handlers.
+ Change file block handling to use timers only on pipes,
+ not on disk files or terminals. That makes for a lot
+ fewer signals while idle at the prompt.
+
+2004-12-10 Keith Packard <keithp at keithp.com>
+
* prng.5c:
ARC4 requires positive keys
Index: Makefile.am
===================================================================
RCS file: /local/src/CVS/nickle/Makefile.am,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- Makefile.am 2 Dec 2004 05:28:36 -0000 1.62
+++ Makefile.am 11 Dec 2004 06:02:23 -0000 1.63
@@ -20,13 +20,19 @@
EXTRA_DIST = README.name autogen.sh \
$(NICKLEFILES) $(DEBIAN) ChangeLog nickle.1.in nickle.spec.in
+nickleincludedir=$(includedir)/nickle
+
+nickleinclude_HEADERS = \
+ builtin.h config.h mem.h nickle.h ref.h value.h \
+ builtin-namespaces.h gram.h memp.h opcode.h stack.h
+
bin_PROGRAMS = nickle
nickle_SOURCES = \
alarm.c array.c atom.c box.c compile.c debug.c \
divide.c edit.c error.c execute.c expr.c file.c float.c \
- frame.c func.c gcd.c hash.c int.c integer.c io.c main.c \
- mem.c natural.c pretty.c profile.c rational.c ref.c \
+ foreign.c frame.c func.c gcd.c hash.c int.c integer.c io.c \
+ main.c mem.c natural.c pretty.c profile.c rational.c ref.c \
refer.c sched.c scope.c stack.c string.c struct.c \
symbol.c sync.c type.c union.c util.c value.c \
mem.h memp.h nickle.h opcode.h ref.h stack.h value.h \
@@ -34,7 +40,9 @@
builtin-file.c builtin-math.c builtin-namespaces.h \
builtin-semaphore.c builtin-sockets.c builtin-string.c \
builtin-thread.c builtin-toplevel.c builtin.c builtin.h \
- gram.y lex.l
+ builtin-foreign.c gram.y lex.l
+
+nickle_LDFLAGS=$(NICKLE_LDFLAGS)
pkgdata_DATA = $(NICKLEFILES) COPYING
@@ -44,7 +52,8 @@
AM_CPPFLAGS = \
-DBUILD=\""$(BUILD_DATE)"\" \
- -DBUILD_VERSION=\""$(VERSION)"\"
+ -DBUILD_VERSION=\""$(VERSION)"\" \
+ -DLOCAL_BUILD
AM_CFLAGS = \
-Wall -Wpointer-arith -Wstrict-prototypes \
@@ -63,7 +72,7 @@
$(USES_GRAM_H): gram.h
-builtin.o: force
+builtin.o: $(nickle_SOURCES)
debuild debuild-signed: debuild-dirs
(cd $(distdir)/debian && debuild)
Index: builtin-namespaces.h
===================================================================
RCS file: /local/src/CVS/nickle/builtin-namespaces.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- builtin-namespaces.h 14 Jun 2004 06:43:33 -0000 1.4
+++ builtin-namespaces.h 11 Dec 2004 06:02:23 -0000 1.5
@@ -22,3 +22,4 @@
#endif
extern void import_Environ_namespace(void);
extern void import_Socket_namespace(void);
+extern void import_Foreign_namespace(void);
Index: builtin-sockets.c
===================================================================
RCS file: /local/src/CVS/nickle/builtin-sockets.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- builtin-sockets.c 8 Jun 2004 09:30:53 -0000 1.15
+++ builtin-sockets.c 11 Dec 2004 06:02:23 -0000 1.16
@@ -99,6 +99,21 @@
{ 0 }
};
+ static const struct ibuiltin ivars[] = {
+ { SOCK_STREAM, "SOCK_STREAM", &SocketNamespace },
+ { SOCK_DGRAM, "SOCK_DGRAM", &SocketNamespace },
+ { SHUT_RD, "SHUT_RD", &SocketNamespace },
+ { SHUT_WR, "SHUT_WR", &SocketNamespace },
+ { SHUT_RDWR, "SHUT_RDWR", &SocketNamespace },
+ { 0 }
+ };
+
+ static const struct sbuiltin svars[] = {
+ { "0.0.0.0", "INADDR_ANY", &SocketNamespace },
+ { "127.0.0.1", "INADDR_LOOPBACK", &SocketNamespace },
+ { "255.255.255.255", "INADDR_BROADCAST", &SocketNamespace },
+ { 0 }
+ };
SymbolPtr sym;
Type *type;
@@ -120,24 +135,8 @@
BuiltinFuncs2 (&SocketNamespace, funcs_2);
BuiltinFuncs3 (&SocketNamespace, funcs_3);
- sym = BuiltinSymbol (&SocketNamespace, "SOCK_STREAM", typePrim[rep_int]);
- BoxValueSet (sym->global.value, 0, NewInt (SOCK_STREAM));
- sym = BuiltinSymbol (&SocketNamespace, "SOCK_DGRAM", typePrim[rep_int]);
- BoxValueSet (sym->global.value, 0, NewInt (SOCK_DGRAM));
-
- sym = BuiltinSymbol (&SocketNamespace, "SHUT_RD", typePrim[rep_int]);
- BoxValueSet (sym->global.value, 0, NewInt (SHUT_RD));
- sym = BuiltinSymbol (&SocketNamespace, "SHUT_WR", typePrim[rep_int]);
- BoxValueSet (sym->global.value, 0, NewInt (SHUT_WR));
- sym = BuiltinSymbol (&SocketNamespace, "SHUT_RDWR", typePrim[rep_int]);
- BoxValueSet (sym->global.value, 0, NewInt (SHUT_RDWR));
-
- sym = BuiltinSymbol (&SocketNamespace, "INADDR_ANY", typePrim[rep_string]);
- BoxValueSet (sym->global.value, 0, NewStrString ("0.0.0.0"));
- sym = BuiltinSymbol (&SocketNamespace, "INADDR_LOOPBACK", typePrim[rep_string]);
- BoxValueSet (sym->global.value, 0, NewStrString ("127.0.0.1"));
- sym = BuiltinSymbol (&SocketNamespace, "INADDR_BROADCAST", typePrim[rep_string]);
- BoxValueSet (sym->global.value, 0, NewStrString ("255.255.255.255"));
+ BuiltinIntegers (ivars);
+ BuiltinStrings (svars);
EXIT ();
}
Index: builtin.c
===================================================================
RCS file: /local/src/CVS/nickle/builtin.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- builtin.c 14 Jun 2004 06:43:33 -0000 1.20
+++ builtin.c 11 Dec 2004 06:02:23 -0000 1.21
@@ -14,27 +14,6 @@
#include "builtin.h"
-struct sbuiltin {
- char *value;
- char *name;
- NamespacePtr *namespace;
-};
-
-struct envbuiltin {
-#ifdef CENVIRON
- char *var;
-#endif
- char *def;
- char *name;
- NamespacePtr *namespace;
-};
-
-struct filebuiltin {
- char *name;
- Value *value;
- NamespacePtr *namespace;
-};
-
static const struct sbuiltin svars[] = {
{ "> ", "prompt" },
{ "+ ", "prompt2" },
@@ -190,6 +169,7 @@
case 'c': t = typePrim[rep_continuation]; break;
case 'b': t = typePrim[rep_bool]; break;
case 'v': t = typePrim[rep_void]; break;
+ case 'F': t = typePrim[rep_foreign]; break;
case 'a': t = typeSockaddr; break;
default:
t = 0;
@@ -306,7 +286,6 @@
BuiltinInit (void)
{
ENTER ();
- const struct sbuiltin *s;
const struct filebuiltin *f;
const struct ebuiltin *e;
SymbolPtr sym;
@@ -333,12 +312,10 @@
#endif
import_Environ_namespace();
import_Socket_namespace();
+ import_Foreign_namespace ();
/* Import builtin strings with predefined values */
- for (s = svars; s->name; s++) {
- sym = BuiltinSymbol (s->namespace, s->name, typePrim[rep_string]);
- BoxValueSet (sym->global.value, 0, NewStrString (s->value));
- }
+ BuiltinStrings (svars);
#ifdef CENVIRON
/* Get the user's home directory in case it's referenced in the
Index: builtin.h
===================================================================
RCS file: /local/src/CVS/nickle/builtin.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- builtin.h 8 Jun 2004 09:30:53 -0000 1.9
+++ builtin.h 11 Dec 2004 06:02:23 -0000 1.10
@@ -12,7 +12,11 @@
* header shared across builtin implementation source files
*/
+#if LOCAL_BUILD
#include "nickle.h"
+#else
+#include <nickle/nickle.h>
+#endif
SymbolPtr
BuiltinAddName (NamespacePtr *namespacep,
@@ -47,6 +51,47 @@
char *format,
char *doc);
+struct sbuiltin {
+ char *value;
+ char *name;
+ NamespacePtr *namespace;
+};
+
+#define BuiltinStrings(s) do { \
+ SymbolPtr sym; const struct sbuiltin *si; \
+ for (si = (s); si->name; si++) { \
+ sym = BuiltinSymbol (si->namespace, si->name, typePrim[rep_string]); \
+ BoxValueSet (sym->global.value, 0, NewStrString (si->value)); \
+ } } while (0)
+
+struct envbuiltin {
+#ifdef CENVIRON
+ char *var;
+#endif
+ char *def;
+ char *name;
+ NamespacePtr *namespace;
+};
+
+struct ibuiltin {
+ int value;
+ char *name;
+ NamespacePtr *namespace;
+};
+
+#define BuiltinIntegers(s) do { \
+ SymbolPtr sym; const struct ibuiltin *ii; \
+ for (ii = (s); ii->name; ii++) { \
+ sym = BuiltinSymbol (ii->namespace ,ii->name, typePrim[rep_integer]); \
+ BoxValueSet (sym->global.value, 0, Reduce (NewIntInteger (ii->value))); \
+ } } while (0)
+
+struct filebuiltin {
+ char *name;
+ Value *value;
+ NamespacePtr *namespace;
+};
+
void
BuiltinAddFunction (NamespacePtr *namespacep, char *name, char *ret_format,
char *format, BuiltinFunc f, Bool jumping, char *doc);
@@ -137,4 +182,8 @@
#define BuiltinFuncs2J(n, f) \
BuiltinFuncsGeneric(n, f, fbuiltin_2j, builtin2J, True)
+#if LOCAL_BUILD
#include "builtin-namespaces.h"
+#else
+#include <nickle/builtin-namespaces.h>
+#endif
Index: configure.in
===================================================================
RCS file: /local/src/CVS/nickle/configure.in,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- configure.in 30 Nov 2004 05:27:53 -0000 1.38
+++ configure.in 11 Dec 2004 06:02:23 -0000 1.39
@@ -32,11 +32,47 @@
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(resolv, hstrerror)
+AC_CHECK_LIB(dl, dlopen)
+
+dnl as-compiler-flag.m4 0.0.1
+dnl autostars m4 macro for detection of compiler flags
+dnl
+dnl ds at schleef.org
+
+AC_DEFUN(AS_COMPILER_FLAG,
+[
+ AC_MSG_CHECKING(to see if compiler understands $1)
+
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+
+ AC_COMPILE_IFELSE([ ], [flag_ok=yes], [flag_ok=no])
+ CFLAGS="$save_CFLAGS"
+
+ if test "X$flag_ok" = Xyes; then
+ $2
+ true
+ else
+ $3
+ true
+ fi
+ AC_MSG_RESULT([$flag_ok])
+])
+
+AS_COMPILER_FLAG([-Wl,-E], GCC_EXTERN="yes", GCC_EXTERN="no")
+if test $GCC_EXTERN = yes; then
+ NICKLE_LDFLAGS="-Wl,-E"
+ AC_DEFINE([HAVE_EXTERN_SYMS], 1, [C compilers can extern program symbols])
+else
+ NICKLE_LDFLAGS=""
+fi
+AC_SUBST(NICKLE_LDFLAGS)
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h strings.h time.h sys/time.h unistd.h sys/resource.h)
AC_CHECK_HEADERS(stropts.h)
+AC_CHECK_HEADERS(dlfcn.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
Index: execute.c
===================================================================
RCS file: /local/src/CVS/nickle/execute.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- execute.c 19 Nov 2004 06:53:05 -0000 1.93
+++ execute.c 11 Dec 2004 06:02:23 -0000 1.94
@@ -988,15 +988,7 @@
else if (thread && !Runnable (thread))
break;
else if (!running)
- {
- sigset_t set, oset;
-
- sigfillset (&set);
- sigprocmask (SIG_SETMASK, &set, &oset);
- if (!signaling)
- sigsuspend (&oset);
- sigprocmask (SIG_SETMASK, &oset, &set);
- }
+ ThreadsBlock ();
else
{
ENTER ();
Index: file.c
===================================================================
RCS file: /local/src/CVS/nickle/file.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- file.c 8 Jun 2004 09:30:54 -0000 1.64
+++ file.c 11 Dec 2004 06:02:23 -0000 1.65
@@ -32,7 +32,7 @@
ReferencePtr fileBlockedReference;
Value fileBlocked;
Bool anyFileWriteBlocked;
-Bool anyFileReadBlocked;
+Bool anyPipeReadBlocked;
extern Bool ownTty[3];
typedef struct _FileErrorMap {
@@ -643,6 +643,8 @@
file->file.flags |= flags;
if (isatty (fd))
file->file.flags |= FileLineBuf;
+ else if (lseek (fd, 0, 1) < 0)
+ file->file.flags |= FileIsPipe;
if (fd >= 3)
FileSetFd (fd);
RETURN (file);
@@ -1422,6 +1424,9 @@
case rep_bool:
FilePuts (f, "bool");
break;
+ case rep_foreign:
+ FilePuts (f, "foreign");
+ break;
case rep_void:
FilePuts (f, "void");
break;
@@ -1851,7 +1856,7 @@
Value blocked, *prev;
Bool ready;
Bool writeBlocked;
- Bool readBlocked;
+ Bool readPipeBlocked;
FD_ZERO (&readable);
FD_ZERO (&writable);
@@ -1890,12 +1895,12 @@
else
{
anyFileWriteBlocked = False;
- anyFileReadBlocked = False;
+ anyPipeReadBlocked = False;
}
if (n > 0)
{
writeBlocked = False;
- readBlocked = False;
+ readPipeBlocked = False;
for (prev = &fileBlocked; (blocked = *prev); )
{
fd = blocked->file.fd;
@@ -1915,8 +1920,9 @@
}
if (blocked->file.flags & FileOutputBlocked)
writeBlocked = True;
- if (blocked->file.flags & FileInputBlocked)
- readBlocked = True;
+ if (blocked->file.flags & FileInputBlocked &&
+ blocked->file.flags & FileIsPipe)
+ readPipeBlocked = True;
if (ready)
ThreadsWakeup (blocked, WakeAll);
if ((blocked->file.flags & (FileOutputBlocked|FileInputBlocked)) == 0)
@@ -1925,7 +1931,7 @@
prev = &blocked->file.next;
}
anyFileWriteBlocked = writeBlocked;
- anyFileReadBlocked = readBlocked;
+ anyPipeReadBlocked = readPipeBlocked;
}
EXIT ();
}
@@ -1938,9 +1944,11 @@
anyFileWriteBlocked = True;
IoNoticeWriteBlocked ();
}
- if (flag == FileInputBlocked && !anyFileReadBlocked)
+ if (flag == FileInputBlocked &&
+ (file->file.flags & FileIsPipe) &&
+ !anyPipeReadBlocked)
{
- anyFileReadBlocked = True;
+ anyPipeReadBlocked = True;
IoNoticeReadBlocked ();
}
if (file->file.flags & (FileOutputBlocked|FileInputBlocked))
Index: gram.y
===================================================================
RCS file: /local/src/CVS/nickle/gram.y,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- gram.y 17 Oct 2004 23:34:34 -0000 1.143
+++ gram.y 11 Dec 2004 06:02:23 -0000 1.144
@@ -139,7 +139,7 @@
%token SEMI MOD OC CC DOLLAR DOTDOTDOT ENDFILE
%token <class> GLOBAL AUTO STATIC CONST
-%token <type> POLY INTEGER NATURAL RATIONAL REAL STRING
+%token <type> POLY INTEGER NATURAL RATIONAL REAL STRING FOREIGN
%token <type> FILET MUTEX SEMAPHORE CONTINUATION THREAD VOID BOOL
%token FUNCTION FUNC EXCEPTION RAISE
%token TYPEDEF IMPORT NEW ANONINIT
@@ -1043,6 +1043,7 @@
| THREAD
| VOID
| BOOL
+ | FOREIGN
;
opt_stars : stars
|
Index: io.c
===================================================================
RCS file: /local/src/CVS/nickle/io.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- io.c 27 Feb 2004 03:50:16 -0000 1.12
+++ io.c 11 Dec 2004 06:02:23 -0000 1.13
@@ -106,7 +106,7 @@
if (anyTtyUnowned)
IoStart ();
FileCheckBlocked (False);
- if (anyFileWriteBlocked || anyFileReadBlocked || anyTtyUnowned)
+ if (anyFileWriteBlocked || anyPipeReadBlocked || anyTtyUnowned)
return True;
ioTimeoutQueued = False;
return False;
Index: lex.l
===================================================================
RCS file: /local/src/CVS/nickle/lex.l,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- lex.l 15 Nov 2004 19:58:39 -0000 1.80
+++ lex.l 11 Dec 2004 06:02:23 -0000 1.81
@@ -337,6 +337,7 @@
union { yylval.ints = UNION; return UNION; }
enum { yylval.ints = ENUM; return ENUM; }
void { yylval.type = typePrim[rep_void]; return VOID; }
+foreign { yylval.type = typePrim[rep_foreign]; return FOREIGN; }
true { yylval.value = TrueVal; return BOOLVAL; }
false { yylval.value = FalseVal; return BOOLVAL; }
Index: mem.h
===================================================================
RCS file: /local/src/CVS/nickle/mem.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mem.h 17 Oct 2004 23:34:34 -0000 1.16
+++ mem.h 11 Dec 2004 06:02:23 -0000 1.17
@@ -22,7 +22,11 @@
typedef const struct _DataType DataType;
#endif
+#if LOCAL_BUILD
#include "stack.h"
+#else
+#include <nickle/stack.h>
+#endif
struct _DataType {
void (*Mark) (void *);
Index: nickle.h
===================================================================
RCS file: /local/src/CVS/nickle/nickle.h,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- nickle.h 22 Jul 2004 19:42:06 -0000 1.120
+++ nickle.h 11 Dec 2004 06:02:23 -0000 1.121
@@ -6,9 +6,17 @@
* for licensing information.
*/
+#if LOCAL_BUILD
#include "config.h"
+#include "mem.h"
#include "value.h"
#include "opcode.h"
+#else
+#include <nickle/config.h>
+#include <nickle/mem.h>
+#include <nickle/value.h>
+#include <nickle/opcode.h>
+#endif
#include <assert.h>
typedef struct _func *FuncPtr;
@@ -598,6 +606,15 @@
void TraceFunction (Value file, FramePtr frame, CodePtr code, ExprPtr name);
void TraceFrame (Value file, FramePtr frame, ObjPtr obj, InstPtr pc, int depth);
void ThreadStackDump (Value thread);
+void ThreadsBlock (void);
+
+typedef void (*NickleBlockHandler) (void *closure);
+
+void
+ThreadsRegisterBlockHandler (NickleBlockHandler handler, void *closure);
+
+void
+ThreadsUnregisterBlockHandler (NickleBlockHandler handler, void *closure);
typedef struct _jump {
DataType *data;
Index: sched.c
===================================================================
RCS file: /local/src/CVS/nickle/sched.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- sched.c 9 Jul 2004 18:48:35 -0000 1.58
+++ sched.c 11 Dec 2004 06:02:23 -0000 1.59
@@ -517,7 +517,79 @@
RETURN (ret);
}
+typedef struct _blockHandler {
+ DataType *data;
+ struct _blockHandler *next;
+ NickleBlockHandler handler;
+ void *closure;
+} BlockHandler;
+
+static void
+BlockHandlerMark (void *object)
+{
+ BlockHandler *bh = object;
+
+ MemReference (bh->next);
+}
+
+DataType BlockHandlerType = { BlockHandlerMark, 0, "BlockHandlerType" };
+
+static BlockHandler *blockHandlers;
+
+void
+ThreadsRegisterBlockHandler (NickleBlockHandler handler, void *closure)
+{
+ ENTER ();
+ BlockHandler *bh = ALLOCATE (&BlockHandlerType, sizeof (BlockHandler));
+ bh->next = blockHandlers;
+ blockHandlers = bh;
+ bh->handler = handler;
+ bh->closure = closure;
+ EXIT ();
+}
+
+void
+ThreadsUnregisterBlockHandler (NickleBlockHandler handler, void *closure)
+{
+ ENTER ();
+ BlockHandler **prev, *bh;
+
+ for (prev = &blockHandlers; (bh = *prev); prev = &bh->next)
+ {
+ if (bh->handler == handler && bh->closure == closure)
+ {
+ bh->handler = 0;
+ *prev = bh->next;
+ }
+ }
+ EXIT ();
+}
+
+void
+ThreadsBlock (void)
+{
+ BlockHandler *bh, *next;
+
+ for (bh = blockHandlers; bh; bh = next)
+ {
+ next = bh->next;
+ if (bh->handler)
+ (*bh->handler) (bh->closure);
+ }
+ if (!running)
+ {
+ sigset_t set, oset;
+
+ sigfillset (&set);
+ sigprocmask (SIG_SETMASK, &set, &oset);
+ if (!signaling)
+ sigsuspend (&oset);
+ sigprocmask (SIG_SETMASK, &oset, &set);
+ }
+}
+
ReferencePtr RunningReference, StoppedReference;
+ReferencePtr BlockHandlerReference;
void
ThreadInit (void)
@@ -527,6 +599,8 @@
MemAddRoot (RunningReference);
StoppedReference = NewReference ((void **) &stopped);
MemAddRoot (StoppedReference);
+ BlockHandlerReference = NewReference ((void **) &blockHandlers);
+ MemAddRoot (BlockHandlerReference);
EXIT ();
}
Index: string.c
===================================================================
RCS file: /local/src/CVS/nickle/string.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- string.c 30 Nov 2004 19:51:16 -0000 1.19
+++ string.c 11 Dec 2004 06:02:23 -0000 1.20
@@ -239,7 +239,7 @@
}
Value
-NewStrString (char *str)
+NewStrString (const char *str)
{
ENTER ();
Value ret;
Index: value.c
===================================================================
RCS file: /local/src/CVS/nickle/value.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- value.c 30 Nov 2004 19:51:16 -0000 1.49
+++ value.c 11 Dec 2004 06:02:23 -0000 1.50
@@ -842,6 +842,8 @@
return 0;
if (!StructInit ())
return 0;
+ if (!ForeignInit ())
+ return 0;
ValuePrintStack = StackCreate ();
MemAddRoot (ValuePrintStack);
Void = NewVoid ();
Index: value.h
===================================================================
RCS file: /local/src/CVS/nickle/value.h,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- value.h 30 Nov 2004 19:51:16 -0000 1.108
+++ value.h 11 Dec 2004 06:02:23 -0000 1.109
@@ -22,8 +22,6 @@
#include <string.h>
#include <signal.h>
#include <assert.h>
-#include "mem.h"
-#include "opcode.h"
typedef enum { False = 0, True = 1 } Bool;
typedef char *Atom;
@@ -267,7 +265,9 @@
* with functions that operate on the value
*/
typedef enum _rep {
+ /* unknown type */
rep_undef = -1,
+ /* primitive types */
rep_int = 0,
rep_integer = 1,
rep_rational = 2,
@@ -278,15 +278,18 @@
rep_semaphore = 7,
rep_continuation = 8,
rep_bool = 9,
- rep_void = 10,
- rep_ref = 11,
- rep_func = 12,
+ rep_foreign = 10,
+ rep_void = 11,
+
+ /* composite types */
+ rep_ref = 12,
+ rep_func = 13,
/* mutable type */
- rep_array = 13,
- rep_struct = 14,
- rep_union = 15,
- rep_hash = 16
+ rep_array = 14,
+ rep_struct = 15,
+ rep_union = 16,
+ rep_hash = 17
} Rep;
/* because rep_undef is -1, using (unsigned) makes these a single compare */
@@ -299,6 +302,7 @@
extern ValueRep RefRep, StructRep, UnionRep, HashRep;
extern ValueRep FuncRep, ThreadRep;
extern ValueRep SemaphoreRep, ContinuationRep, UnitRep, BoolRep;
+extern ValueRep ForeignRep;
#define NewInt(i) ((Value) IntToPtr ((((i) << 1) | 1)))
#define IntSign(i) ((i) < 0 ? Negative : Positive)
@@ -353,6 +357,7 @@
#define ValueIsContinuation(v) (ValueRep(v) == &ContinuationRep)
#define ValueIsUnit(v) (ValueRep(v) == &UnitRep)
#define ValueIsBool(v) (ValueRep(v) == &BoolRep)
+#define ValueIsForeign(v) (ValueRep(v) == &ForeignRep)
/*
* Aggregate types
@@ -576,6 +581,13 @@
#define StringChars(s) ((char *) ((s) + 1))
+typedef struct _foreign {
+ BaseValue base;
+ const char *id;
+ void *data;
+ void (*free)(void *);
+} Foreign;
+
/*
* Resizable arrays are actually vectors of single entry
* boxes. Otherwise shrinking the array leaves old references
@@ -652,6 +664,7 @@
#define FileEnd 0x0400
#define FileString 0x0800
#define FilePipe 0x1000
+#define FileIsPipe 0x2000
typedef struct _boxTypes {
DataType *data;
@@ -853,6 +866,7 @@
Array array;
File file;
Ref ref;
+ Foreign foreign;
Struct structs;
Union unions;
Func func;
@@ -950,7 +964,9 @@
Value NewNaturalFloat (Sign sign, Natural *n, unsigned prec);
Value NewRationalFloat (Rational *r, unsigned prec);
Value NewValueFloat (Value av, unsigned prec);
+Value NewDoubleFloat (double d);
Value NewContinuation (ContinuationPtr continuation, InstPtr pc);
+Value NewForeign (const char *id, void *data, void (*free)(void *data));
unsigned FpartLength (Fpart *a);
@@ -960,7 +976,7 @@
extern DataCachePtr refCache;
Value NewString (long length);
-Value NewStrString (char *);
+Value NewStrString (const char *);
Value NewCharString (int c);
Value NewArray (Bool constant, Bool resizable, TypePtr type, int ndim, int *dims);
void ArrayResize (Value av, int dim, int size);
@@ -1068,7 +1084,7 @@
void FileSetBuffer (Value file, int buf);
extern Bool anyFileWriteBlocked;
-extern Bool anyFileReadBlocked;
+extern Bool anyPipeReadBlocked;
extern Value FileStdin, FileStdout, FileStderr;
@@ -1177,6 +1193,8 @@
int IntegerToInt (Integer *);
int IntPart (Value, char *error);
+double DoublePart (Value av, char *error);
+
#ifndef Numericp
Bool Numericp (Rep);
#endif
@@ -1205,6 +1223,7 @@
int StringInit (void);
int StructInit (void);
int RefInit (void);
+int ForeignInit (void);
int ValueInit (void);
# define oneNp(n) ((n)->length == 1 && NaturalDigits(n)[0] == 1)
- Previous message: [Commit] nickle ChangeLog,1.109,1.110 prng.5c,1.11,1.12
- Next message: [Commit] nickle ChangeLog, 1.111, 1.112 builtin.c, 1.21,
1.22 builtin.h, 1.10, 1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Commit
mailing list