aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormi <mi@FreeBSD.org>2013-02-05 08:15:35 +0800
committermi <mi@FreeBSD.org>2013-02-05 08:15:35 +0800
commit4f5f7527f70fc055603dcf9d87559b9d7718060a (patch)
tree6f099af021085771ceb393322ea911d1fc55ce16
parent4965d37f1b8984eec2fd1c2935c9192961ffaa26 (diff)
downloadfreebsd-ports-gnome-4f5f7527f70fc055603dcf9d87559b9d7718060a.tar.gz
freebsd-ports-gnome-4f5f7527f70fc055603dcf9d87559b9d7718060a.tar.zst
freebsd-ports-gnome-4f5f7527f70fc055603dcf9d87559b9d7718060a.zip
Add port tcl-mmap -- Tcl interface to mmap(2).
-rw-r--r--devel/Makefile1
-rw-r--r--devel/tcl-mmap/Makefile27
-rw-r--r--devel/tcl-mmap/distinfo2
-rw-r--r--devel/tcl-mmap/files/Makefile.bsd36
-rw-r--r--devel/tcl-mmap/files/alltests.tcl6
-rw-r--r--devel/tcl-mmap/files/patch-tests79
-rw-r--r--devel/tcl-mmap/files/patch-warnings148
-rw-r--r--devel/tcl-mmap/pkg-descr11
8 files changed, 310 insertions, 0 deletions
diff --git a/devel/Makefile b/devel/Makefile
index 27b080538c8b..44aba5667aac 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -4222,6 +4222,7 @@
SUBDIR += talloc
SUBDIR += tbb
SUBDIR += tcl-memchan
+ SUBDIR += tcl-mmap
SUBDIR += tcl-signal
SUBDIR += tcl-trf
SUBDIR += tclcheck
diff --git a/devel/tcl-mmap/Makefile b/devel/tcl-mmap/Makefile
new file mode 100644
index 000000000000..65addc44a1a4
--- /dev/null
+++ b/devel/tcl-mmap/Makefile
@@ -0,0 +1,27 @@
+# Created by: Mikhail Teterin <mi@aldan.algebra.com>
+# $FreeBSD$
+
+PORTNAME= tcl-mmap
+PORTVERSION= 1.1
+CATEGORIES= devel tcl
+MASTER_SITES= SF
+
+MAINTAINER= tcltk@FreeBSD.org
+COMMENT= New TCL channel type using mmap-ed files
+
+MAKEFILE= ${FILESDIR}/Makefile.bsd
+
+USE_TCL= 84+
+
+MAKE_ENV+= TCL_VER=${TCL_VER} MKDIR="${MKDIR}" \
+ PORTVERSION="${PORTVERSION}" \
+ FILESDIR="${FILESDIR}" \
+ TCLSH="${TCLSH}" \
+ INSTALL_DATA="${INSTALL_DATA}"
+PLIST_DIRS= lib/tcl${TCL_VER}/mmap
+PLIST_FILES= ${PLIST_DIRS}/pkgIndex.tcl ${PLIST_DIRS}/libmmap${PORTVERSION}.so
+
+MANN= tcl-mmap.n
+MANCOMPRESSED= maybe
+
+.include <bsd.port.mk>
diff --git a/devel/tcl-mmap/distinfo b/devel/tcl-mmap/distinfo
new file mode 100644
index 000000000000..73d8159c957b
--- /dev/null
+++ b/devel/tcl-mmap/distinfo
@@ -0,0 +1,2 @@
+SHA256 (tcl-mmap-1.1.tar.gz) = e41dd103866437eb0e4ed42671be6587de0d2787998391cd5b9cc8fc67bf0bb0
+SIZE (tcl-mmap-1.1.tar.gz) = 276254
diff --git a/devel/tcl-mmap/files/Makefile.bsd b/devel/tcl-mmap/files/Makefile.bsd
new file mode 100644
index 000000000000..2115e4a99de6
--- /dev/null
+++ b/devel/tcl-mmap/files/Makefile.bsd
@@ -0,0 +1,36 @@
+LIBNAME= mmap${PORTVERSION}
+SHLIB_NAME= lib${LIBNAME}.so
+
+.PATH: ${.CURDIR}/unix ${.CURDIR}/doc
+
+SRCS= mmap.c
+MAN= tcl-mmap.n
+
+TCL_VER?= 8.3
+LOCALBASE?= /usr/local
+
+CFLAGS+= -I${LOCALBASE}/include/tcl${TCL_VER}
+
+LDADD= -L${LOCALBASE}/lib -ltcl${TCL_VER:S/.//}
+
+all: pkgIndex.tcl test
+
+pkgIndex.tcl:
+ echo 'package ifneeded mmap ${PORTVERSION} \
+ [list load [file join $$dir $(SHLIB_NAME)]]' > pkgIndex.tcl
+
+DIR = lib/tcl${TCL_VER}/mmap
+LIBDIR = ${PREFIX}/${DIR}
+MANDIR = ${PREFIX}/man/man
+WARNS = 3
+
+${LIBDIR}:
+ ${MKDIR} ${LIBDIR}
+
+beforeinstall: ${LIBDIR} pkgIndex.tcl
+ ${INSTALL_DATA} pkgIndex.tcl ${LIBDIR}/
+
+.include <bsd.lib.mk>
+
+test: ${SHLIB_NAME} pkgIndex.tcl
+ cd tests && ${TCLSH} ${FILESDIR}/alltests.tcl
diff --git a/devel/tcl-mmap/files/alltests.tcl b/devel/tcl-mmap/files/alltests.tcl
new file mode 100644
index 000000000000..8f1109c5bd2f
--- /dev/null
+++ b/devel/tcl-mmap/files/alltests.tcl
@@ -0,0 +1,6 @@
+lappend auto_path ..
+
+foreach t [glob *.tcl] {
+ puts "Running tests from $t"
+ source $t
+}
diff --git a/devel/tcl-mmap/files/patch-tests b/devel/tcl-mmap/files/patch-tests
new file mode 100644
index 000000000000..b67eafb8a94b
--- /dev/null
+++ b/devel/tcl-mmap/files/patch-tests
@@ -0,0 +1,79 @@
+--- tests/mmap_err.tcl 2008-04-12 19:45:49.000000000 -0400
++++ tests/mmap_err.tcl 2013-02-04 18:38:40.000000000 -0500
+@@ -1,29 +1,10 @@
+ #!/usr/bin/tclsh
+ package require mmap
+-set fd [open /tmp/messages r]
+-set mp [mmap -length 30 -offset 4095 $fd]
+-close $fd
+-
+-puts Gets:
+-for {set i 0} {$i < 10} {incr i} {
+- gets $mp line
+- puts $line
++set fd [open messages r]
++if {[catch {mmap -length 30 -offset 4095 $fd} mp]} {
++ close $fd
++ puts "Using offset 4095 resulted in error ($mp), as expected. Good"
++} else {
++ puts "Offset 4095 should've caused an error. Test failed"
++ exit 1
+ }
+-close $mp
+-
+-set fd [open /tmp/a r+]
+-set mp [mmap -shared -length 30 $fd]
+-close $fd
+-
+-flush $mp
+-
+-seek $mp 1
+-puts -nonewline $mp alex
+-seek $mp 0
+-
+-puts Read:
+-puts [read $mp]
+-
+-puts [eof $mp]
+-
+-close $mp
+--- tests/test_mem2.tcl 2008-04-21 08:34:42.000000000 -0400
++++ tests/test_mem2.tcl 2013-02-04 18:41:57.000000000 -0500
+@@ -2,10 +2,10 @@
+ package require mmap
+
+-catch { file copy tests/testfile tests/testfile1 }
+-set fd [open tests/testfile1 r+]
++catch { file copy testfile testfile1 }
++set fd [open testfile1 r+]
+ set mp [mmap -shared -length 30 $fd]
+ close $fd
+
+-while {1} {
++for {set i 0} {$i < 3} {incr i} {
+ flush $mp
+
+@@ -23,3 +23,3 @@
+ close $mp
+
+-file delete tests/testfile1
++file delete testfile1
+--- tests/test_mem.tcl 2008-04-21 08:35:36.000000000 -0400
++++ tests/test_mem.tcl 2013-02-04 18:43:29.000000000 -0500
+@@ -2,7 +2,7 @@
+ package require mmap
+
+-while {1} {
+-catch { file copy tests/testfile tests/testfile1 }
+-set fd [open tests/testfile1 r+]
++for {set i 0} {$i < 3} {incr i} {
++catch { file copy testfile testfile1 }
++set fd [open testfile1 r+]
+ set mp [mmap -shared -length 30 $fd]
+ close $fd
+@@ -21,4 +21,4 @@
+ close $mp
+
+-file delete tests/testfile1
++file delete testfile1
+ }
diff --git a/devel/tcl-mmap/files/patch-warnings b/devel/tcl-mmap/files/patch-warnings
new file mode 100644
index 000000000000..90aec0e55c12
--- /dev/null
+++ b/devel/tcl-mmap/files/patch-warnings
@@ -0,0 +1,148 @@
+Submitted upstream as:
+
+https://sourceforge.net/tracker/?func=detail&aid=3603360&group_id=224597&atid=1062254
+
+--- unix/mmap.c 2008-04-21 08:47:04.000000000 -0400
++++ unix/mmap.c 2013-02-04 18:18:52.000000000 -0500
+@@ -37,23 +37,16 @@
+ */
+
+-static int MmapCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]);
++Tcl_PackageInitProc Mmap_Init;
+
+-void NewChannelName(char *name, CONST char* prefix);
++static Tcl_ObjCmdProc MmapCmd;
+
+-static int Input(ClientData instanceData, char *buf, int bufSize, int *errorCodePtr);
++static void NewChannelName(char *name, const char* prefix);
+
+-static int Output(ClientData instanceData, const char *buf, int bufSize, int *errorCodePtr);
+-
+-static int Seek(ClientData instanceData, long offset, int seekMode, int *errorCodePtr);
+-
+-static int Close(ClientData instanceData, Tcl_Interp *interp);
+-
+-static void Watch(ClientData instanceData, int mask);
+-
+-//static int BlockMode(ClientData instanceData, int mode);
+-
+-static int GetHandle(ClientData instanceData, int direction, ClientData *handlePtr);
+-
+-//static void catch_signal(int sig_num);
++static Tcl_DriverInputProc Input;
++static Tcl_DriverOutputProc Output;
++static Tcl_DriverSeekProc Seek;
++static Tcl_DriverCloseProc Close;
++static Tcl_DriverWatchProc Watch;
++static Tcl_DriverGetHandleProc GetHandle;
+
+ /*
+@@ -62,19 +55,12 @@
+
+ static Tcl_ChannelType channelType = {
+- "mmap", /* Channel type name */
+- TCL_CHANNEL_VERSION_2,
+- (Tcl_DriverCloseProc *) Close,
+- (Tcl_DriverInputProc *) Input,
+- (Tcl_DriverOutputProc *) Output,
+- (Tcl_DriverSeekProc *) Seek,
+- (Tcl_DriverSetOptionProc *) NULL, /* no channel type specific options */
+- (Tcl_DriverGetOptionProc *) NULL, /* no channel type specific options */
+- (Tcl_DriverWatchProc *) Watch,
+- (Tcl_DriverGetHandleProc *) GetHandle,
+- (Tcl_DriverClose2Proc *) NULL, /* no support for closing the read and write sides independently */
+- (Tcl_DriverBlockModeProc *) NULL, /* mmap channels are always in non-blocking mode */
+- //(Tcl_DriverBlockModeProc *) BlockMode,
+- (Tcl_DriverFlushProc *) NULL, /* currently reserved for future use. It should be set to NULL */
+- (Tcl_DriverHandlerProc *) NULL /* this is not a stacked channel driver */
++ .typeName = "mmap", /* Channel type name */
++ .version = TCL_CHANNEL_VERSION_2,
++ .closeProc = Close,
++ .inputProc = Input,
++ .outputProc = Output,
++ .seekProc = Seek,
++ .watchProc = Watch,
++ .getHandleProc = GetHandle
+ };
+
+@@ -129,9 +115,9 @@
+ }
+
+- if (bufSize > data->length - data->seek) {
++ if (bufSize > (int)(data->length - data->seek)) {
+ bufSize = data->length - data->seek;
+ }
+
+- memcpy((char *)buf, (char *) (data->addr + data->seek), (size_t) bufSize);
++ memcpy(buf, data->addr + data->seek, (size_t)bufSize);
+ data->seek += bufSize;
+
+@@ -144,10 +130,10 @@
+ int ret;
+
+- if (bufSize > data->length - data->seek) {
++ if (bufSize > (int)(data->length - data->seek)) {
+ bufSize = data->length - data->seek;
+- memcpy((char *) (data->addr + data->seek), (char *) buf, (size_t) bufSize);
++ memcpy(data->addr + data->seek, buf, (size_t)bufSize);
+ data->seek = 0;
+ } else {
+- memcpy((char *) (data->addr + data->seek), (char *) buf, (size_t) bufSize);
++ memcpy(data->addr + data->seek, buf, (size_t)bufSize);
+ data->seek += bufSize;
+ }
+@@ -163,4 +149,5 @@
+ static int Seek(ClientData instanceData, long offset, int seekMode, int *errorCodePtr) {
+ ChannelInstance* data;
++ off_t seek;
+ data = (ChannelInstance*) instanceData;
+
+@@ -178,21 +165,20 @@
+ switch (seekMode) {
+ case SEEK_SET:
+- data->seek = offset;
++ seek = offset;
+ break;
+
+ case SEEK_CUR:
+- data->seek += offset;
++ seek += offset;
+ break;
+
+ case SEEK_END:
+- data->seek = data->length + offset;
++ seek = data->length + offset;
+ break;
+ }
+
+ /* We check if seek is within range, and fix */
+- if (data->seek < 0) data->seek = 0;
+- if (data->seek > data->length) data->seek = data->length;
+-
+- return data->seek;
++ if (seek < 0) seek = 0;
++ if (seek > (off_t)data->length) seek = data->length;
++ return data->seek = seek;
+ }
+
+@@ -255,5 +241,5 @@
+ */
+ static int MmapCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
+- static char* cmds[] = { "-shared", "-length", "-offset", NULL };
++ static const char* cmds[] = { "-shared", "-length", "-offset", NULL };
+ int index;
+ int ret;
+@@ -329,5 +315,5 @@
+ ClientData cd;
+ ret = Tcl_GetChannelHandle(chan, mode, (ClientData *) &cd);
+- fd = (int) cd; // This should be ok because the pointer size in bytes is at least as may bytes as 'int'
++ fd = (intptr_t) cd; // This should be ok because the pointer size in bytes is at least as may bytes as 'int'
+ if (ret != TCL_OK) {
+ Tcl_SetResult(interp, "Could not get file handle", TCL_STATIC);
+@@ -384,5 +370,5 @@
+ }
+
+-void NewChannelName(char *name, CONST char* prefix) {
++void NewChannelName(char *name, const char* prefix) {
+ TCL_DECLARE_MUTEX (mmapCounterMutex)
+ static unsigned long mmapCounter = 0;
diff --git a/devel/tcl-mmap/pkg-descr b/devel/tcl-mmap/pkg-descr
new file mode 100644
index 000000000000..b7f8aa39cc2f
--- /dev/null
+++ b/devel/tcl-mmap/pkg-descr
@@ -0,0 +1,11 @@
+This extension provides a Tcl interface to the mmap(2) POSIX system
+call.
+
+The functionality of 'mmap' is exported from this extension in the
+form of a new Tcl channel type, named "mmap". A memory mapping is
+established with the 'mmap' command. Following 'mmap' execution,
+access to the memory mapped file is done via the standard Tcl
+commands: puts/gets/seek/flush/close/fconfigure, only that this
+time these commands operate on memory, rather than on a file.
+
+WWW: http://tcl-mmap.sourceforge.net/