mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 09:49:18 -04:00
- Use TEA configure script instead of our custom Makefile
- Add regression-test target - Enhance pkg-descr
This commit is contained in:
parent
51e2d7fd29
commit
b6ae0c9184
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=316411
4 changed files with 35 additions and 187 deletions
|
@ -3,25 +3,31 @@
|
|||
|
||||
PORTNAME= tcl-mmap
|
||||
PORTVERSION= 1.1
|
||||
CATEGORIES= devel tcl
|
||||
CATEGORIES= devel
|
||||
MASTER_SITES= SF
|
||||
|
||||
MAINTAINER= tcltk@FreeBSD.org
|
||||
COMMENT= New TCL channel type using mmap-ed files
|
||||
|
||||
MAKEFILE= ${FILESDIR}/Makefile.bsd
|
||||
LICENSE= GPLv3
|
||||
|
||||
USE_TCL= 84+
|
||||
GNU_CONFIGURE= yes
|
||||
CONFIGURE_ARGS+=--with-tcl=${TCL_LIBDIR} \
|
||||
--prefix=${PREFIX} \
|
||||
--exec-prefix=${PREFIX}
|
||||
|
||||
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
|
||||
PLIST_DIRS= lib/mmap${PORTVERSION}
|
||||
PLIST_FILES= lib/mmap${PORTVERSION}/pkgIndex.tcl \
|
||||
lib/mmap${PORTVERSION}/libmmap${PORTVERSION}.so
|
||||
|
||||
MANN= tcl-mmap.n
|
||||
MANCOMPRESSED= maybe
|
||||
|
||||
regression-test: build
|
||||
cd ${WRKSRC}/tests; \
|
||||
for t in *.tcl; \
|
||||
do \
|
||||
echo "load ../libmmap${PORTVERSION}.so; source $$t" | ${TCLSH}; \
|
||||
done;
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
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
|
|
@ -1,148 +1,21 @@
|
|||
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;
|
||||
--- unix/mmap.c.orig 2013-04-24 09:59:16.000000000 +0200
|
||||
+++ unix/mmap.c 2013-04-24 10:00:30.000000000 +0200
|
||||
@@ -190,8 +190,7 @@
|
||||
}
|
||||
|
||||
/* 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;
|
||||
+ if (data->seek > (unsigned long)data->length) data->seek = data->length;
|
||||
|
||||
return data->seek;
|
||||
}
|
||||
@@ -271,7 +270,7 @@
|
||||
|
||||
@@ -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 @@
|
||||
}
|
||||
int i;
|
||||
for (i = 1; i < objc - 1; i++) {
|
||||
- if (Tcl_GetIndexFromObj(interp, objv[i], cmds, "option", 0, &index) != TCL_OK)
|
||||
+ if (Tcl_GetIndexFromObj(interp, objv[i], (const char **)cmds, "option", 0, &index) != TCL_OK)
|
||||
return TCL_ERROR;
|
||||
|
||||
-void NewChannelName(char *name, CONST char* prefix) {
|
||||
+void NewChannelName(char *name, const char* prefix) {
|
||||
TCL_DECLARE_MUTEX (mmapCounterMutex)
|
||||
static unsigned long mmapCounter = 0;
|
||||
switch (index) {
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
This extension provides a Tcl interface to the mmap(2) POSIX system
|
||||
call.
|
||||
|
||||
It provides a Tcl package that allows Tcl scripts to:
|
||||
1) Memory map files for improved access efficiency;
|
||||
2) Share memory between related processes;
|
||||
3) Easily implement cyclic persistent log files.
|
||||
|
||||
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,
|
||||
|
@ -8,4 +13,4 @@ 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/
|
||||
WWW: http://tcl-mmap.sourceforge.net/
|
||||
|
|
Loading…
Add table
Reference in a new issue