cygwin patch
Jeff <[email protected]> Fri, 11 Oct 2002 15:48:44 -0700
| Newsgroups | gmane.comp.lib.state-threads.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------050608020008080907070502
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Attached is a patch to get state threads working under cygwin. It has
not yet been heavily tested but I did compile and briefly test my UDP
file server app on a Windows XP box and it seemed to work fine. Since I
have never really gotten the hang of portable Makefiles, I would
appreciate critical attention to my changes there. Other changes are
pretty minimal because the people of Cygwin have done such a fine job.
I am thinking about adding asynchronous file i/o along the lines of
http://state-threads.sourceforge.net/docs/notes.html#disk
"Create multiple "helper" processes in addition to the main process that
will handle blocking disk I/O operations (asymmetric architecture). This
approach was suggested for Web servers in a paper by Peter Druschel et
al. In this architecture the main process communicates with a helper
process via an IPC channel (pipe(2), socketpair(2)). The main process
instructs a helper to perform the potentially blocking operation.
Once the
operation completes, the helper returns a notification via IPC."
At the moment my targets are linux, cygwin and SGI. I am thinking to
use shared memory to pass data from the helper to the main process.
Does anyone on the list have experience with this approach? Are there
any non-obvious portability considerations? Would this be a welcome
addition to the library?
--------------050608020008080907070502
Content-Type: text/plain;
name="st-1.4b-cygwin.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="st-1.4b-cygwin.patch"
diff -Naurb st-1.4b/Makefile st-1.4b-cygwin/Makefile
--- st-1.4b/Makefile 2002-02-18 23:03:45.000000000 -0800
+++ st-1.4b-cygwin/Makefile 2002-10-11 15:07:16.000000000 -0700
@@ -50,6 +50,7 @@
#OS = OPENBSD
#OS = OSF1
#OS = SOLARIS
+OS = CYGWIN
# Please see the "Other possible defines" section below for
# possible compilation options.
@@ -93,7 +94,8 @@
netbsd-debug netbsd-optimized \
openbsd-debug openbsd-optimized \
osf1-debug osf1-optimized \
- solaris-debug solaris-optimized
+ solaris-debug solaris-optimized \
+ cygwin-debug cygwin-optimized
#
# Platform specifics
@@ -126,6 +128,18 @@
OTHER_FLAGS = -Wall
endif
+ifeq ($(OS), CYGWIN)
+TARGETDIR = $(OS)_$(BUILD)
+CC = gcc
+LD = gcc
+DSO_SUFFIX = dll
+SLIBRARY = $(TARGETDIR)/libst.dll.a
+DLIBRARY = $(TARGETDIR)/libst.dll
+DEF_FILE = $(TARGETDIR)/libst.def
+LDFLAGS = libst.def -shared --enable-auto-image-base -Wl,--output-def,$(DEF_FILE),--out-implib,$(SLIBRARY)
+OTHER_FLAGS = -Wall
+endif
+
ifeq (HPUX, $(findstring HPUX, $(OS)))
ifeq ($(OS), HPUX_64)
DEFINES = -DHPUX
@@ -231,16 +245,23 @@
HEADER = $(TARGETDIR)/st.h
SLIBRARY = $(TARGETDIR)/libst.a
DLIBRARY = $(TARGETDIR)/libst.$(DSO_SUFFIX).$(VERSION)
-EXAMPLES = examples
+ST_ALL = $(TARGETDIR) $(LIBRARIES) $(HEADER) $(DESC)
+
+LINKNAME = libst.$(DSO_SUFFIX)
+SONAME = libst.$(DSO_SUFFIX).$(MAJOR)
+FULLNAME = libst.$(DSO_SUFFIX).$(VERSION)
ifeq ($(OS), DARWIN)
LINKNAME = libst.$(DSO_SUFFIX)
SONAME = libst.$(MAJOR).$(DSO_SUFFIX)
FULLNAME = libst.$(VERSION).$(DSO_SUFFIX)
-else
-LINKNAME = libst.$(DSO_SUFFIX)
-SONAME = libst.$(DSO_SUFFIX).$(MAJOR)
-FULLNAME = libst.$(DSO_SUFFIX).$(VERSION)
+endif
+
+ifeq ($(OS), CYGWIN)
+SONAME = cygst.$(DSO_SUFFIX)
+SLIBRARY = $(TARGETDIR)/libst.dll.a
+DLIBRARY = $(TARGETDIR)/$(SONAME)
+LINKNAME =
endif
ifeq ($(STATIC_ONLY), yes)
@@ -277,8 +298,12 @@
$(DLIBRARY): $(OBJS:%.o=%-pic.o)
$(LD) $(LDFLAGS) $^ -o $@
- cd $(TARGETDIR); rm -f $(SONAME); $(LN) $(LNFLAGS) $(FULLNAME) $(SONAME)
- cd $(TARGETDIR); rm -f $(LINKNAME); $(LN) $(LNFLAGS) $(FULLNAME) $(LINKNAME)
+ if test "$(LINKNAME)"; then \
+ cd $(TARGETDIR); \
+ rm -f $(SONAME) $(LINKNAME); \
+ $(LN) $(LNFLAGS) $(FULLNAME) $(SONAME); \
+ $(LN) $(LNFLAGS) $(FULLNAME) $(LINKNAME); \
+ fi
$(HEADER): public.h
rm -f $@
@@ -327,6 +352,11 @@
darwin-optimized:
$(MAKE) OS="DARWIN" BUILD="OPT"
+cygwin-debug:
+ $(MAKE) OS="CYGWIN" BUILD="DBG"
+cygwin-optimized:
+ $(MAKE) OS="CYGWIN" BUILD="OPT"
+
freebsd-debug:
$(MAKE) OS="FREEBSD" BUILD="DBG"
freebsd-optimized:
diff -Naurb st-1.4b/libst.def st-1.4b-cygwin/libst.def
--- st-1.4b/libst.def 1969-12-31 16:00:00.000000000 -0800
+++ st-1.4b-cygwin/libst.def 2002-10-11 15:07:16.000000000 -0700
@@ -0,0 +1,51 @@
+EXPORTS
+ st_accept @62
+ st_cond_broadcast @63
+ st_cond_destroy @64
+ st_cond_new @65
+ st_cond_signal @66
+ st_cond_timedwait @67
+ st_cond_wait @68
+ st_connect @69
+ st_getfdlimit @70
+ st_init @71
+ st_key_create @72
+ st_key_getlimit @73
+ st_mutex_destroy @74
+ st_mutex_lock @75
+ st_mutex_new @76
+ st_mutex_trylock @77
+ st_mutex_unlock @78
+ st_netfd_close @79
+ st_netfd_fileno @80
+ st_netfd_free @81
+ st_netfd_getspecific @82
+ st_netfd_open @83
+ st_netfd_open_socket @84
+ st_netfd_poll @85
+ st_netfd_serialize_accept @86
+ st_netfd_setspecific @87
+ st_open @88
+ st_poll @89
+ st_randomize_stacks @90
+ st_read @91
+ st_read_fully @92
+ st_read_resid @93
+ st_recvfrom @94
+ st_sendto @95
+ st_sleep @96
+ st_thread_create @97
+ st_thread_exit @98
+ st_thread_getspecific @99
+ st_thread_interrupt @100
+ st_thread_join @101
+ st_thread_self @102
+ st_thread_setspecific @103
+ st_time @104
+ st_timecache_set @105
+ st_usleep @106
+ st_utime @107
+ st_utime_last_clock @108
+ st_write @109
+ st_write_resid @110
+ st_writev @111
diff -Naurb st-1.4b/md.h st-1.4b-cygwin/md.h
--- st-1.4b/md.h 2002-02-22 12:55:46.000000000 -0800
+++ st-1.4b-cygwin/md.h 2002-10-11 15:07:16.000000000 -0700
@@ -495,6 +495,32 @@
#define MD_GET_UTIME() \
return (gethrtime() / 1000)
+#elif defined (CYGWIN)
+
+#define MD_STACK_GROWS_DOWN
+#define MD_USE_BSD_ANON_MMAP
+#define MD_ACCEPT_NB_NOT_INHERITED
+#define MD_ALWAYS_UNSERIALIZED_ACCEPT
+
+#define MD_SETJMP(env) setjmp(env)
+#define MD_LONGJMP(env, val) longjmp(env, val)
+
+#define JB_SP_INDEX 7
+
+#define MD_GET_SP(_t) (_t)->context[JB_SP_INDEX]
+
+#define MD_INIT_CONTEXT(_thread, _sp, _main) \
+ ST_BEGIN_MACRO \
+ if (MD_SETJMP((_thread)->context)) \
+ _main(); \
+ MD_GET_SP(_thread) = (long) (_sp); \
+ ST_END_MACRO
+
+#define MD_GET_UTIME() \
+ struct timeval tv; \
+ (void) gettimeofday(&tv, NULL); \
+ return (tv.tv_sec * 1000000LL + tv.tv_usec)
+
#else
#error Unknown OS
#endif /* OS */
--------------050608020008080907070502--
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf