Add st: non-preemptive thread library for Internet applications
The State Threads Library is a small application library which provides a foundation for writing fast and highly scalable Internet applications (such as web servers, proxy servers, mail transfer agents, and so on, really any network-data-driven application) on UNIX-like platforms. It combines the simplicity of the multithreaded programming paradigm, in which one thread supports each simultaneous connection, with the performance and scalability of an event-driven state machine architecture. In other words, this library offers a threading API for structuring an Internet application as a state machine.
This commit is contained in:
parent
efb93b17bd
commit
4a9659909c
7 changed files with 256 additions and 0 deletions
10
devel/st/DESCR
Normal file
10
devel/st/DESCR
Normal file
|
@ -0,0 +1,10 @@
|
|||
The State Threads Library is a small application library which
|
||||
provides a foundation for writing fast and highly scalable Internet
|
||||
applications (such as web servers, proxy servers, mail transfer
|
||||
agents, and so on, really any network-data-driven application) on
|
||||
UNIX-like platforms. It combines the simplicity of the multithreaded
|
||||
programming paradigm, in which one thread supports each simultaneous
|
||||
connection, with the performance and scalability of an event-driven
|
||||
state machine architecture. In other words, this library offers a
|
||||
threading API for structuring an Internet application as a state
|
||||
machine.
|
34
devel/st/Makefile
Normal file
34
devel/st/Makefile
Normal file
|
@ -0,0 +1,34 @@
|
|||
# $NetBSD: Makefile,v 1.1.1.1 2002/08/25 19:40:16 gson Exp $
|
||||
#
|
||||
|
||||
DISTNAME= st-1.3
|
||||
CATEGORIES= devel
|
||||
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=state-threads/}
|
||||
|
||||
MAINTAINER= gson@netbsd.org
|
||||
HOMEPAGE= http://state-threads.sourceforge.net/
|
||||
COMMENT= Non-preemptive thread library for Internet applications
|
||||
|
||||
ONLY_FOR_PLATFORM= NetBSD-*-i386 NetBSD-*-sparc
|
||||
|
||||
USE_LIBTOOL= yes
|
||||
USE_GMAKE= yes
|
||||
ALL_TARGET= netbsd-debug
|
||||
|
||||
HTMLDIR= ${PREFIX}/share/doc/html/st
|
||||
|
||||
do-install:
|
||||
${LIBTOOL} --mode=install ${INSTALL_DATA} \
|
||||
${WRKSRC}/libst.la ${PREFIX}/lib
|
||||
${LIBTOOL} --mode=install ${INSTALL_PROGRAM} \
|
||||
${WRKSRC}/examples/lookupdns ${PREFIX}/bin/st-lookupdns
|
||||
${LIBTOOL} --mode=install ${INSTALL_PROGRAM} \
|
||||
${WRKSRC}/examples/proxy ${PREFIX}/bin/st-proxy
|
||||
${LIBTOOL} --mode=install ${INSTALL_PROGRAM} \
|
||||
${WRKSRC}/examples/server ${PREFIX}/bin/st-server
|
||||
${INSTALL_DATA_DIR} ${PREFIX}/include/st
|
||||
${INSTALL_DATA} ${WRKSRC}/public.h ${PREFIX}/include/st.h
|
||||
${INSTALL_DATA_DIR} ${HTMLDIR}
|
||||
cd ${WRKSRC}/docs; ${INSTALL_DATA} *.html *.gif ${HTMLDIR}
|
||||
|
||||
.include "../../mk/bsd.pkg.mk"
|
15
devel/st/PLIST
Normal file
15
devel/st/PLIST
Normal file
|
@ -0,0 +1,15 @@
|
|||
@comment $NetBSD: PLIST,v 1.1.1.1 2002/08/25 19:40:16 gson Exp $
|
||||
bin/st-lookupdns
|
||||
bin/st-proxy
|
||||
bin/st-server
|
||||
include/st.h
|
||||
lib/libst.a
|
||||
lib/libst.la
|
||||
lib/libst.so
|
||||
lib/libst.so.1
|
||||
lib/libst.so.1.3
|
||||
share/doc/html/st/fig.gif
|
||||
share/doc/html/st/notes.html
|
||||
share/doc/html/st/reference.html
|
||||
share/doc/html/st/st.html
|
||||
@dirrm share/doc/html/st
|
7
devel/st/distinfo
Normal file
7
devel/st/distinfo
Normal file
|
@ -0,0 +1,7 @@
|
|||
$NetBSD: distinfo,v 1.1.1.1 2002/08/25 19:40:16 gson Exp $
|
||||
|
||||
SHA1 (st-1.3.tar.gz) = 5d97fc248a2a86602cbd3944ff78a9e916058672
|
||||
Size (st-1.3.tar.gz) = 75588 bytes
|
||||
SHA1 (patch-aa) = e01af9bcf55cbbbd0b4f2e93f5734a2c615431c3
|
||||
SHA1 (patch-ab) = 3c69a37f27c9d4fa4e85b23bb378ac2ae330c759
|
||||
SHA1 (patch-ac) = 7c832f17da0637d646685d49c0a43d12db066d65
|
85
devel/st/patches/patch-aa
Normal file
85
devel/st/patches/patch-aa
Normal file
|
@ -0,0 +1,85 @@
|
|||
$NetBSD: patch-aa,v 1.1.1.1 2002/08/25 19:40:16 gson Exp $
|
||||
|
||||
--- Makefile.orig Mon Jan 21 19:59:08 2002
|
||||
+++ Makefile
|
||||
@@ -86,6 +86,7 @@
|
||||
irix-64-debug irix-64-optimized \
|
||||
linux-debug linux-optimized \
|
||||
linux-ia64-debug linux-ia64-optimized \
|
||||
+ netbsd-debug netbsd-optimized \
|
||||
openbsd-debug openbsd-optimized \
|
||||
osf1-debug osf1-optimized \
|
||||
solaris-debug solaris-optimized
|
||||
@@ -148,6 +149,13 @@
|
||||
OTHER_FLAGS = -Wall
|
||||
endif
|
||||
|
||||
+ifeq ($(OS), NETBSD)
|
||||
+OTHER_FLAGS = -Wall
|
||||
+TARGETDIR = .
|
||||
+# The following is a lie; we do build dynamic libraries
|
||||
+STATIC_ONLY = yes
|
||||
+endif
|
||||
+
|
||||
ifeq ($(OS), OPENBSD)
|
||||
SFLAGS = -fPIC
|
||||
LDFLAGS = -shared -soname=$(SONAME) -lc
|
||||
@@ -203,14 +211,14 @@
|
||||
|
||||
CFLAGS += $(DEFINES) $(OTHER_FLAGS)
|
||||
|
||||
-OBJS = $(TARGETDIR)/sched.o \
|
||||
- $(TARGETDIR)/stk.o \
|
||||
- $(TARGETDIR)/sync.o \
|
||||
- $(TARGETDIR)/key.o \
|
||||
- $(TARGETDIR)/io.o
|
||||
+OBJS = $(TARGETDIR)/sched.lo \
|
||||
+ $(TARGETDIR)/stk.lo \
|
||||
+ $(TARGETDIR)/sync.lo \
|
||||
+ $(TARGETDIR)/key.lo \
|
||||
+ $(TARGETDIR)/io.lo
|
||||
OBJS += $(EXTRA_OBJS)
|
||||
HEADER = $(TARGETDIR)/st.h
|
||||
-SLIBRARY = $(TARGETDIR)/libst.a
|
||||
+SLIBRARY = $(TARGETDIR)/libst.la
|
||||
DLIBRARY = $(TARGETDIR)/libst.$(DSO_SUFFIX).$(VERSION)
|
||||
EXAMPLES = examples
|
||||
|
||||
@@ -248,8 +256,7 @@
|
||||
if [ ! -d $(TARGETDIR) ]; then mkdir $(TARGETDIR); fi
|
||||
|
||||
$(SLIBRARY): $(OBJS)
|
||||
- $(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
- $(RANLIB) $@
|
||||
+ ${LIBTOOL} --mode=link ${CC} -o $@ ${OBJS} -rpath ${PREFIX}/lib -version-info 1:3
|
||||
rm -f obj; $(LN) $(LNFLAGS) $(TARGETDIR) obj
|
||||
|
||||
$(DLIBRARY): $(OBJS:%.o=%-pic.o)
|
||||
@@ -261,11 +268,11 @@
|
||||
rm -f $@
|
||||
cp public.h $@
|
||||
|
||||
-$(TARGETDIR)/%asm.o: %asm.S
|
||||
- $(CC) $(CFLAGS) -c $< -o $@
|
||||
+$(TARGETDIR)/%asm.lo: %asm.S
|
||||
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
-$(TARGETDIR)/%.o: %.c common.h md.h
|
||||
- $(CC) $(CFLAGS) -c $< -o $@
|
||||
+$(TARGETDIR)/%.lo: %.c common.h md.h
|
||||
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
examples::
|
||||
@cd $@; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" OS="$(OS)" TARGETDIR="$(TARGETDIR)"
|
||||
@@ -330,6 +337,11 @@
|
||||
$(MAKE) OS="LINUX_IA64" BUILD="DBG"
|
||||
linux-ia64-optimized:
|
||||
$(MAKE) OS="LINUX_IA64" BUILD="OPT"
|
||||
+
|
||||
+netbsd-debug:
|
||||
+ $(MAKE) OS="NETBSD" BUILD="DBG"
|
||||
+netbsd-optimized:
|
||||
+ $(MAKE) OS="NETBSD" BUILD="OPT"
|
||||
|
||||
openbsd-debug:
|
||||
$(MAKE) OS="OPENBSD" BUILD="DBG"
|
60
devel/st/patches/patch-ab
Normal file
60
devel/st/patches/patch-ab
Normal file
|
@ -0,0 +1,60 @@
|
|||
$NetBSD: patch-ab,v 1.1.1.1 2002/08/25 19:40:16 gson Exp $
|
||||
|
||||
--- examples/Makefile.orig Sat Nov 3 13:18:42 2001
|
||||
+++ examples/Makefile
|
||||
@@ -38,6 +38,7 @@
|
||||
# IRIX_64
|
||||
# LINUX
|
||||
# LINUX_IA64
|
||||
+# NETBSD
|
||||
# OPENBSD
|
||||
# OSF1
|
||||
# SOLARIS
|
||||
@@ -58,9 +59,9 @@
|
||||
OTHER_FLAGS =
|
||||
|
||||
OBJDIR = $(DEPTH)/$(TARGETDIR)
|
||||
-INCDIR = $(DEPTH)/$(TARGETDIR)
|
||||
-LIBST = $(OBJDIR)/libst.a
|
||||
-HEADER = $(INCDIR)/st.h
|
||||
+INCDIR = $(DEPTH)
|
||||
+LIBST = $(DEPTH)/libst.la
|
||||
+HEADER = $(DEPTH)/st.h
|
||||
|
||||
LIBRESOLV =
|
||||
EXTRALIBS =
|
||||
@@ -68,7 +69,7 @@
|
||||
ifeq ($(OS),)
|
||||
EXAMPLES = unknown
|
||||
else
|
||||
-EXAMPLES = $(OBJDIR)/lookupdns $(OBJDIR)/proxy $(OBJDIR)/server
|
||||
+EXAMPLES = lookupdns proxy server
|
||||
endif
|
||||
|
||||
|
||||
@@ -92,17 +93,17 @@
|
||||
|
||||
all: $(EXAMPLES)
|
||||
|
||||
-$(OBJDIR)/lookupdns: lookupdns.c $(OBJDIR)/res.o $(LIBST) $(HEADER)
|
||||
- $(CC) $(CFLAGS) -I$(INCDIR) lookupdns.c $(OBJDIR)/res.o $(LIBST) $(LIBRESOLV) $(EXTRALIBS) -o $@
|
||||
+lookupdns: lookupdns.lo res.lo $(LIBST) $(HEADER)
|
||||
+ $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -I$(INCDIR) lookupdns.lo res.lo $(LIBST) $(LIBRESOLV) $(EXTRALIBS) -o $@
|
||||
|
||||
-$(OBJDIR)/proxy: proxy.c $(LIBST) $(HEADER)
|
||||
- $(CC) $(CFLAGS) -I$(INCDIR) proxy.c $(LIBST) $(EXTRALIBS) -o $@
|
||||
+proxy: proxy.lo $(LIBST) $(HEADER)
|
||||
+ $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -I$(INCDIR) proxy.lo $(LIBST) $(EXTRALIBS) -o $@
|
||||
|
||||
-$(OBJDIR)/server: server.c $(OBJDIR)/error.o $(LIBST) $(HEADER)
|
||||
- $(CC) $(CFLAGS) -I$(INCDIR) server.c $(OBJDIR)/error.o $(LIBST) $(EXTRALIBS) -o $@
|
||||
+server: server.lo error.lo $(LIBST) $(HEADER)
|
||||
+ $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -I$(INCDIR) server.lo error.lo $(LIBST) $(EXTRALIBS) -o $@
|
||||
|
||||
-$(OBJDIR)/%.o: %.c
|
||||
- $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
|
||||
+%.lo: %.c
|
||||
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
|
||||
|
||||
.DEFAULT:
|
||||
@cd $(DEPTH); $(MAKE) $@
|
45
devel/st/patches/patch-ac
Normal file
45
devel/st/patches/patch-ac
Normal file
|
@ -0,0 +1,45 @@
|
|||
$NetBSD: patch-ac,v 1.1.1.1 2002/08/25 19:40:16 gson Exp $
|
||||
|
||||
--- md.h.orig Tue Jan 15 22:20:40 2002
|
||||
+++ md.h
|
||||
@@ -245,6 +245,40 @@
|
||||
(void) gettimeofday(&tv, NULL); \
|
||||
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
||||
|
||||
+#elif defined (NETBSD)
|
||||
+
|
||||
+#define MD_STACK_GROWS_DOWN
|
||||
+#define MD_USE_BSD_ANON_MMAP
|
||||
+#define MD_ACCEPT_NB_INHERITED
|
||||
+#define MD_ALWAYS_UNSERIALIZED_ACCEPT
|
||||
+#define MD_HAVE_SOCKLEN_T
|
||||
+
|
||||
+#define MD_SETJMP(env) _setjmp(env)
|
||||
+#define MD_LONGJMP(env, val) _longjmp(env, val)
|
||||
+
|
||||
+#if __sparc__
|
||||
+#define MD_INIT_CONTEXT(_thread, _sp, _main) \
|
||||
+ ST_BEGIN_MACRO \
|
||||
+ (void) MD_SETJMP((_thread)->context); \
|
||||
+ (_thread)->context[0] = (long) (_sp); \
|
||||
+ (_thread)->context[1] = (long) (_main) - 8; \
|
||||
+ ST_END_MACRO
|
||||
+#elif __i386__
|
||||
+#define MD_INIT_CONTEXT(_thread, _sp, _main) \
|
||||
+ ST_BEGIN_MACRO \
|
||||
+ (void) MD_SETJMP((_thread)->context); \
|
||||
+ (_thread)->context[0] = (long) _main; \
|
||||
+ (_thread)->context[2] = (long) (_sp); \
|
||||
+ ST_END_MACRO
|
||||
+#else
|
||||
+#error Unsupported architecture
|
||||
+#endif
|
||||
+
|
||||
+#define MD_GET_UTIME() \
|
||||
+ struct timeval tv; \
|
||||
+ (void) gettimeofday(&tv, NULL); \
|
||||
+ return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
||||
+
|
||||
#elif defined (OPENBSD)
|
||||
|
||||
#define MD_STACK_GROWS_DOWN
|
Loading…
Reference in a new issue