View | Details | Raw Unified | Return to bug 120853
Collapse All | Expand All

(-)Makefile (-20 / +13 lines)
Lines 6-23 Link Here
6
#
6
#
7
7
8
PORTNAME=	st
8
PORTNAME=	st
9
PORTVERSION=	1.4
9
PORTVERSION=	1.8
10
PORTREVISION=	1
11
CATEGORIES=	devel
10
CATEGORIES=	devel
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
11
MASTER_SITES=	SF/state-threads
13
MASTER_SITE_SUBDIR=	state-threads
14
12
15
MAINTAINER=	alfred@FreeBSD.org
13
MAINTAINER=	alfred@FreeBSD.org
16
COMMENT=	State Threads Library for Internet Applications
14
COMMENT=	State Threads Library for Internet Applications
17
15
18
INSTALLS_SHLIB=	yes
16
USE_LDCONFIG=	yes
19
ONLY_FOR_ARCHS=	i386 alpha amd64
17
ONLY_FOR_ARCHS=	i386 alpha amd64
20
18
19
DOCS=		fig.gif notes.html reference.html st.html \
20
		timeout_heap.txt
21
EXAMPLES=	Makefile README error.c lookupdns.c proxy.c \
22
		res.c server.c
23
21
.include <bsd.port.pre.mk>
24
.include <bsd.port.pre.mk>
22
25
23
post-patch:
26
post-patch:
Lines 26-47 Link Here
26
	@${CP} ${FILESDIR}/Makefile.examples ${WRKSRC}/examples/Makefile
29
	@${CP} ${FILESDIR}/Makefile.examples ${WRKSRC}/examples/Makefile
27
30
28
post-install:
31
post-install:
29
	@${MKDIR} ${PREFIX}/include
32
	@${CP} ${WRKSRC}/public.h ${PREFIX}/include/st.h
30
	@${INSTALL_DATA} ${WRKSRC}/public.h ${PREFIX}/include/st.h
31
	@${MKDIR} ${PREFIX}/share/examples/st
32
	@${INSTALL_DATA} ${WRKSRC}/examples/Makefile	${PREFIX}/share/examples/st
33
	@${INSTALL_DATA} ${WRKSRC}/examples/README	${PREFIX}/share/examples/st
34
	@${INSTALL_DATA} ${WRKSRC}/examples/error.c	${PREFIX}/share/examples/st
35
	@${INSTALL_DATA} ${WRKSRC}/examples/lookupdns.c	${PREFIX}/share/examples/st
36
	@${INSTALL_DATA} ${WRKSRC}/examples/proxy.c	${PREFIX}/share/examples/st
37
	@${INSTALL_DATA} ${WRKSRC}/examples/res.c	${PREFIX}/share/examples/st
38
	@${INSTALL_DATA} ${WRKSRC}/examples/server.c	${PREFIX}/share/examples/st
39
.if !defined(NOPORTDOCS)
33
.if !defined(NOPORTDOCS)
40
	@${MKDIR} ${PREFIX}/share/doc/st
34
	@${MKDIR} ${DOCSDIR}
41
	@${INSTALL_DATA} ${WRKSRC}/docs/fig.gif		${PREFIX}/share/doc/st
35
	@${INSTALL_DATA} ${DOCS:S,^,${WRKSRC}/docs/,} ${DOCSDIR}/
42
	@${INSTALL_DATA} ${WRKSRC}/docs/notes.html	${PREFIX}/share/doc/st
36
	@${MKDIR} ${EXAMPLESDIR}
43
	@${INSTALL_DATA} ${WRKSRC}/docs/reference.html	${PREFIX}/share/doc/st
37
	@${INSTALL_DATA} ${EXAMPLES:S,^,${WRKSRC}/examples/,} ${EXAMPLESDIR}/
44
	@${INSTALL_DATA} ${WRKSRC}/docs/st.html		${PREFIX}/share/doc/st
45
.endif
38
.endif
46
39
47
.include <bsd.port.post.mk>
40
.include <bsd.port.post.mk>
(-)distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
MD5 (st-1.4.tar.gz) = aac2e6a31a58b089be97c86e9c30f07b
1
MD5 (st-1.8.tar.gz) = 088515a622c1fa7724ab1c9aa7102238
2
SHA256 (st-1.4.tar.gz) = e3bef563069f3d459b921fe6f45d2384585ff1791f60b34e675a00274fce7fc0
2
SHA256 (st-1.8.tar.gz) = 1c2b27da32ed7618b3fda5b24d4c1e350ee0efd265b5ae0d3f8876f3d25061f5
3
SIZE (st-1.4.tar.gz) = 80245
3
SIZE (st-1.8.tar.gz) = 106604
(-)pkg-plist (-13 / +14 lines)
Lines 2-17 Link Here
2
lib/libst.a
2
lib/libst.a
3
lib/libst.so.1
3
lib/libst.so.1
4
lib/libst.so
4
lib/libst.so
5
%%PORTDOCS%%share/doc/st/fig.gif
5
%%PORTDOCS%%%%DOCSDIR%%/fig.gif
6
%%PORTDOCS%%share/doc/st/notes.html
6
%%PORTDOCS%%%%DOCSDIR%%/notes.html
7
%%PORTDOCS%%share/doc/st/reference.html
7
%%PORTDOCS%%%%DOCSDIR%%/reference.html
8
%%PORTDOCS%%share/doc/st/st.html
8
%%PORTDOCS%%%%DOCSDIR%%/st.html
9
%%PORTDOCS%%@dirrm share/doc/st
9
%%PORTDOCS%%%%DOCSDIR%%/timeout_heap.txt
10
share/examples/st/Makefile
10
%%PORTDOCS%%%%EXAMPLESDIR%%/Makefile
11
share/examples/st/README
11
%%PORTDOCS%%%%EXAMPLESDIR%%/README
12
share/examples/st/error.c
12
%%PORTDOCS%%%%EXAMPLESDIR%%/error.c
13
share/examples/st/lookupdns.c
13
%%PORTDOCS%%%%EXAMPLESDIR%%/lookupdns.c
14
share/examples/st/proxy.c
14
%%PORTDOCS%%%%EXAMPLESDIR%%/proxy.c
15
share/examples/st/res.c
15
%%PORTDOCS%%%%EXAMPLESDIR%%/res.c
16
share/examples/st/server.c
16
%%PORTDOCS%%%%EXAMPLESDIR%%/server.c
17
@dirrm share/examples/st
17
%%PORTDOCS%%@dirrm %%EXAMPLESDIR%%
18
%%PORTDOCS%%@dirrm %%DOCSDIR%%
(-)files/Makefile.main (-1 / +1 lines)
Lines 6-12 Link Here
6
SHLIB_MAJOR=	1
6
SHLIB_MAJOR=	1
7
SHLIB_MINOR=	1
7
SHLIB_MINOR=	1
8
LIB=		st
8
LIB=		st
9
NOPROFILE=	yes
9
NO_PROFILE=	yes
10
10
11
SRCS=		io.c key.c sched.c stk.c sync.c
11
SRCS=		io.c key.c sched.c stk.c sync.c
12
CFLAGS+=	-DFREEBSD
12
CFLAGS+=	-DFREEBSD
(-)files/patch-aa (-49 lines)
Removed Link Here
1
diff -ur common.h common.h
2
--- common.h	Fri Feb 22 12:55:46 2002
3
+++ common.h	Fri Jan 21 15:14:51 2005
4
@@ -190,6 +190,7 @@
5
   int on_ioq;                 /* Is it on ioq? */
6
 } _st_pollq_t;
7
 
8
+typedef void (*_st_switch_cb_t)(void);
9
 
10
 typedef struct _st_vp {
11
   _st_thread_t *idle_thread;  /* Idle thread for this vp */
12
@@ -204,6 +205,8 @@
13
 #endif
14
   st_utime_t sleep_max;
15
   int pagesize;
16
+  _st_switch_cb_t switch_out_cb; /* called when a thread is switched out */
17
+  _st_switch_cb_t switch_in_cb;  /* called when a thread is switched in */
18
 
19
 #ifndef USE_POLL
20
   int maxfd;
21
@@ -362,12 +365,22 @@
22
  * Switch away from the current thread context by saving its state and
23
  * calling the thread scheduler
24
  */
25
-#define _ST_SWITCH_CONTEXT(_thread)       \
26
-    ST_BEGIN_MACRO                        \
27
-    if (!MD_SETJMP((_thread)->context)) { \
28
-      _st_vp_schedule();                  \
29
-    }                                     \
30
-    ST_DEBUG_ITERATE_THREADS();           \
31
+#define _ST_SWITCH_CONTEXT(_thread)                     \
32
+    ST_BEGIN_MACRO                                      \
33
+    if (_st_this_vp.switch_out_cb != NULL &&            \
34
+	_thread != _st_this_vp.idle_thread &&		\
35
+	_thread->state != _ST_ST_ZOMBIE) {              \
36
+      _st_this_vp.switch_out_cb();                      \
37
+    }                                                   \
38
+    if (!MD_SETJMP((_thread)->context)) {               \
39
+      _st_vp_schedule();                                \
40
+    }                                                   \
41
+    ST_DEBUG_ITERATE_THREADS();                         \
42
+    if (_st_this_vp.switch_in_cb != NULL &&             \
43
+	_thread != _st_this_vp.idle_thread &&		\
44
+	_thread->state != _ST_ST_ZOMBIE) {              \
45
+      _st_this_vp.switch_in_cb();                       \
46
+    }                                                   \
47
     ST_END_MACRO
48
 
49
 /*
(-)files/patch-ab (-101 lines)
Removed Link Here
1
diff -ur docs/reference.html docs/reference.html
2
--- docs/reference.html	Fri Oct 25 19:54:20 2002
3
+++ docs/reference.html	Fri Jan 21 15:14:24 2005
4
@@ -13,6 +13,7 @@
5
 <DL><DD><A HREF=#mutex_t>st_mutex_t</A></DD></DL>
6
 <DL><DD><A HREF=#utime_t>st_utime_t</A></DD></DL>
7
 <DL><DD><A HREF=#netfd_t>st_netfd_t</A></DD></DL>
8
+<DL><DD><A HREF=#switch_cb_t>st_switch_cb_t</A></DD></DL>
9
 <P>
10
 <DD><A HREF=#errors><B>Error Handling</B></A></DD>
11
 <P>
12
@@ -20,6 +21,8 @@
13
 <P>
14
 <DL><DD><A HREF=#st_init>st_init()</A></DD></DL>
15
 <DL><DD><A HREF=#st_getfdlimit>st_getfdlimit()</A></DD></DL>
16
+<DL><DD><A HREF=#st_set_switch_in_cb>st_set_switch_in_cb()</A></DD></DL>
17
+<DL><DD><A HREF=#st_set_switch_out_cb>st_set_switch_out_cb()</A></DD></DL>
18
 <P>
19
 <DD><A HREF=#threads><B>Thread Control and Identification</B></A></DD>
20
 <P>
21
@@ -244,6 +247,29 @@
22
 <HR>
23
 <P>
24
 
25
+<A NAME="switch_cb_t">
26
+<H4>st_switch_cb_t</H4>
27
+</A>
28
+Context switch callback function type.
29
+<P>
30
+<H5>Syntax</H5>
31
+
32
+<PRE>
33
+#include &lt;st.h&gt;
34
+
35
+typedef void (*st_switch_cb_t)(void);
36
+</PRE>
37
+<P>
38
+<H5>Description</H5>
39
+
40
+This datatype is a convenience type for describing a pointer
41
+to a function that will be called when a thread is set to stop
42
+or set to run.
43
+
44
+<P>
45
+<HR>
46
+<P>
47
+
48
 <A NAME="errors">
49
 <H2>Error Handling</H2>
50
 </A>
51
@@ -267,6 +293,8 @@
52
 <DL>
53
 <DD><A HREF=#st_init>st_init()</A></DD>
54
 <DD><A HREF=#st_getfdlimit>st_getfdlimit()</A></DD>
55
+<DD><A HREF=#st_set_switch_in_cb>st_set_switch_in_cb()</A></DD>
56
+<DD><A HREF=#st_set_switch_out_cb>st_set_switch_out_cb()</A></DD>
57
 </DL>
58
 <P>
59
 <HR>
60
@@ -343,6 +371,41 @@
61
 <H5>Description</H5>
62
 This function returns the limit on the number of open file descriptors which
63
 is set by the <A HREF=#st_init>st_init()</A> function.
64
+<P>
65
+<HR>
66
+<P>
67
+
68
+<A NAME="st_set_switch_in_cb">
69
+<H4>st_set_switch_in_cb()</H4>
70
+</A>
71
+<A NAME="st_set_switch_out_cb">
72
+<H4>st_set_switch_out_cb()</H4>
73
+</A>
74
+Set the callback function for thread switches.
75
+<P>
76
+<H5>Syntax</H5>
77
+
78
+<PRE>
79
+#include &lt;st.h&gt;
80
+
81
+st_switch_cb_t st_set_switch_in_cb(st_switch_cb_t cb);
82
+st_switch_cb_t st_set_switch_out_cb(st_switch_cb_t cb);
83
+</PRE>
84
+<P>
85
+<H5>Parameters</H5>
86
+<TT>st_set_switch_in_cb()</TT> and <TT>st_set_switch_out_cb()</TT> have the
87
+following parameter:<P>
88
+<TT>cb</TT><P>
89
+A function to be called when a thread is resumed and stopped respectively.<P>
90
+<H5>Returns</H5>
91
+The previous callback function pointer.
92
+<P>
93
+<H5>Description</H5>
94
+These functions set the callback for when a thread is resumed and stopped
95
+respectively.  After being called any thread switch will call the callback.
96
+It is suggested that thread specific data is used to differentiate between
97
+different threads.<P>
98
+These functions can be called at any time.
99
 <P>
100
 <HR>
101
 <P>
(-)files/patch-ac (-16 lines)
Removed Link Here
1
diff -ur public.h public.h
2
--- public.h	Thu Mar 28 21:09:08 2002
3
+++ public.h	Fri Jan 21 15:14:24 2005
4
@@ -85,9 +85,12 @@
5
 typedef struct _st_cond *   st_cond_t;
6
 typedef struct _st_mutex *  st_mutex_t;
7
 typedef struct _st_netfd *  st_netfd_t;
8
+typedef void (*st_switch_cb_t)(void);
9
 
10
 extern int st_init(void);
11
 extern int st_getfdlimit(void);
12
+extern st_switch_cb_t st_set_switch_in_cb(st_switch_cb_t cb);
13
+extern st_switch_cb_t st_set_switch_out_cb(st_switch_cb_t cb);
14
 
15
 extern st_thread_t st_thread_self(void);
16
 extern void st_thread_exit(void *retval);
(-)files/patch-ad (-25 lines)
Removed Link Here
1
diff -ur sched.c sched.c
2
--- sched.c	Wed Jan 30 19:46:11 2002
3
+++ sched.c	Fri Jan 21 15:14:24 2005
4
@@ -232,6 +232,21 @@
5
   return 0;
6
 }
7
 
8
+st_switch_cb_t st_set_switch_in_cb(st_switch_cb_t cb)
9
+{
10
+  st_switch_cb_t ocb = _st_this_vp.switch_in_cb;
11
+
12
+  _st_this_vp.switch_in_cb = cb;
13
+  return (ocb);
14
+}
15
+
16
+st_switch_cb_t st_set_switch_out_cb(st_switch_cb_t cb)
17
+{
18
+  st_switch_cb_t ocb = _st_this_vp.switch_out_cb;
19
+
20
+  _st_this_vp.switch_out_cb = cb;
21
+  return (ocb);
22
+}
23
 
24
 /*
25
  * Start function for the idle thread
(-)files/patch-md.h (-11 lines)
Removed Link Here
1
--- md.h.orig	Thu Aug 11 11:15:00 2005
2
+++ md.h	Thu Aug 11 11:33:23 2005
3
@@ -154,6 +154,8 @@
4
 #define MD_JB_SP   2
5
 #elif defined(__alpha__)
6
 #define MD_JB_SP  34
7
+#elif defined(__amd64__)
8
+#define MD_JB_SP  2
9
 #else
10
 #error Unknown CPU architecture
11
 #endif

Return to bug 120853