You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/11/03 04:47:42 UTC

[PATCH] Brian Havard's OS/2 stuff

On Wed, 29 Oct 1997, Brian Havard wrote:

> On Mon, 27 Oct 1997 17:24:09 -0800 (PST), Dean Gaudet wrote:
> 
> [...]
> 
> >So all of the above works for me.
> 
> Great, I've now done all of these and here's the result. As far as I know it
> should be OK to commit all of these without breaking any other platforms. I
> tested building the same tree on Linux with no apparent errors.
> 
> I've done a full diff against the current source and broken it up into a few
> separate logical areas.
> 
> 1) Configure: changes to Configure and related script and Makefile.tmpl
> files.
> 
> 2) Abstraction: The new files for the os/emx directory, created as per Paul's
> instructions.
> 
> 3) Code fixes: changes to .c & .h files required to make it compile & run
> successfully. Most are inside an #ifdef __EMX__. NOTE: this includes the
> patch that adds #include <sys/types.h> to conf.h as the available patch
> hasn't been committed yet.
> 
> 4) The proxy patch that I posted a while back but still sits on the available
> list.

This patch works for me, +1. 

I've redone it as a single patch so that other folks can see it... (have I
mentioned before that I really dislike the output format generated by "cvs
diff" ?  It can't be properly parsed by patch when it recurses and has
multiple files with the same basename). 

Brian can you test that with a fresh copy of the latest code, plus this
patch, it works for you under OS/2?  Just to make sure I didn't miss any
portions. 

Dean

diff -Nu -r -x CVS ../../apachen5/src/.cvsignore ./.cvsignore
--- ../../apachen5/src/.cvsignore	Sun Oct 26 13:53:44 1997
+++ ./.cvsignore	Sun Nov  2 19:38:34 1997
@@ -1,3 +1,4 @@
+Makefile
 *.dsw
 *.mdp
 *.ncb
diff -Nu -r -x CVS ../../apachen5/src/Configure ./Configure
--- ../../apachen5/src/Configure	Sun Nov  2 19:35:18 1997
+++ ./Configure	Sun Nov  2 19:29:31 1997
@@ -139,7 +139,10 @@
 DBM_LIB="-ldbm"
 DB_LIB="-ldb"
 SHELL="/bin/sh"
-if ./helpers/PrintPath -s ranlib; then
+TARGET="httpd"
+PRINTPATH=PrintPath
+
+if ./helpers/$PRINTPATH -s ranlib; then
     RANLIB="ranlib"
 else
     RANLIB="true"
@@ -213,8 +216,11 @@
 	DEF_WANTHSREGEX=yes
 	OS='EMX OS/2'
 	CFLAGS="$CFLAGS -Zbsd-signals -Zbin-files -DTCPIPV4 -g"
-	LIBS="$LIBS -lsocket -llibufc -lbsd"
+	LIBS="$LIBS -lsocket -lufc -lbsd"
 	DBM_LIB="-lgdbm"
+	TARGET=httpd.exe
+	SHELL=sh
+	PRINTPATH=PrintPathOS2
 	;;
     *-hi-hiux)
 	OS='HI-UX'
@@ -573,7 +579,7 @@
 	for compilers in "gcc" "cc" "acc" "c89"
 	do
 	    lookedfor="$lookedfor $compilers"
-	    if ./helpers/PrintPath -s $compilers; then
+	    if ./helpers/$PRINTPATH -s $compilers; then
 		COMPILER="$compilers"
 		break
 	    fi
@@ -968,6 +974,7 @@
 echo "SHELL=$SHELL">> Makefile.config
 echo "OSDIR=$OSDIR">> Makefile.config
 echo "SUBDIRS=$SUBDIRS">> Makefile.config
+echo "TARGET=$TARGET" >> Makefile.config
 echo >> Makefile.config
 echo "#### End of Configure created section ####">> Makefile.config
 
@@ -1000,7 +1007,7 @@
 #
 # directories to create makefiles in
 #
-MAKEDIRS="support main $OSDIR"
+MAKEDIRS="support main regex $OSDIR"
 for dir in $MAKEDIRS ; do
 	echo Creating Makefile in $dir
 	cat Makefile.config $dir/Makefile.tmpl > $dir/Makefile
@@ -1015,10 +1022,7 @@
 default: all
 
 all clean :: 
-	for i in \$(MODULES); do \\
-	 (cd \$\$i; \\
-	  \$(MAKE) CC='\$(CC)' AUX_CFLAGS='\$(CFLAGS)' RANLIB='\$(RANLIB)' \$@) || exit 1;\\
-	done
+	for i in \$(MODULES); do (cd \$\$i; \$(MAKE) CC='\$(CC)' AUX_CFLAGS='\$(CFLAGS)' RANLIB='\$(RANLIB)' \$@) || exit 1; done
 
 EOF
 
diff -Nu -r -x CVS ../../apachen5/src/Makefile.tmpl ./Makefile.tmpl
--- ../../apachen5/src/Makefile.tmpl	Sun Oct 26 13:53:46 1997
+++ ./Makefile.tmpl	Sun Nov  2 19:31:56 1997
@@ -17,7 +17,7 @@
 .c.o:
 	$(CC) -c $(INCLUDES) $(CFLAGS) $(SPACER) $<
 
-all: @@Configuration@@ httpd
+all: @@Configuration@@ $(TARGET)
 
 @@Configuration@@: Configuration.tmpl
 	@echo "@@Configuration@@ older than Configuration.tmpl, or doesn't exist."
@@ -26,11 +26,11 @@
 	@echo "If not, you will at least have to touch @@Configuration@@."
 	@false
 
-httpd:  subdirs modules.o
+$(TARGET):  subdirs modules.o
 	rm -f buildmark.c
 	echo 'const char SERVER_BUILT[] = "'`date`'";' > buildmark.c
 	$(CC) -c $(CFLAGS) buildmark.c
-	$(CC) $(CFLAGS) $(LDFLAGS)  -o httpd buildmark.o $(OBJS) $(REGLIB) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS)  -o $(TARGET) buildmark.o $(OBJS) $(REGLIB) $(LIBS)
 
 subdirs:
 	for i in $(SUBDIRS); do \
@@ -43,7 +43,7 @@
 	cd support; $(MAKE) CC='$(CC)' AUX_CFLAGS='$(CFLAGS)' RANLIB='$(RANLIB)'
 
 clean:
-	rm -f httpd *.o
+	rm -f $(TARGET) *.o
 	for i in $(SUBDIRS); do \
 		( cd $$i; $(MAKE) $@ ) || exit 1; \
 	done
diff -Nu -r -x CVS ../../apachen5/src/helpers/CutRule ./helpers/CutRule
--- ../../apachen5/src/helpers/CutRule	Sun Nov  2 19:35:19 1997
+++ ./helpers/CutRule	Sun Nov  2 19:29:31 1997
@@ -1,4 +1,5 @@
 #!/bin/sh
+#!/bin/sh
 # Helper script for Configure - cut a rule from Configuration.
 # note that there is a tab and a space in the character groups.
 # Map to lowercase to make tests easier
diff -Nu -r -x CVS ../../apachen5/src/helpers/PrintPathOS2 ./helpers/PrintPathOS2
--- ../../apachen5/src/helpers/PrintPathOS2	Wed Dec 31 16:00:00 1969
+++ ./helpers/PrintPathOS2	Sun Nov  2 19:29:31 1997
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Look for $1 somewhere in $PATH
+#  will print out the full pathname unless
+#  called with the '-s' option
+#
+
+if [ "x$1" = "x-s" ]; then
+    shift
+else
+    echo="yes"
+fi
+
+for path in `echo $PATH |
+ sed 's/^;/.;/
+      s/;;/;.;/g
+      s/;$/;./
+      s/;/ /g' `
+do
+    if [ $test_exec_flag $path/$1.exe ] && [ ! -d $path/$1.exe ]; then
+        if [ "$echo" = "yes" ]; then
+	    echo $path/$1.exe
+	fi
+	exit 0
+    fi
+done
+exit 1
+
diff -Nu -r -x CVS ../../apachen5/src/main/conf.h ./main/conf.h
--- ../../apachen5/src/main/conf.h	Sun Oct 26 13:53:48 1997
+++ ./main/conf.h	Sun Nov  2 19:26:32 1997
@@ -59,6 +59,7 @@
 
 /* Have to include sys/stat.h before ../os/win32/os.h so we can override
 stat() properly */
+#include <sys/types.h>
 #include <sys/stat.h>
 
 #ifdef WIN32
@@ -800,10 +801,7 @@
 #endif
 
 #ifndef S_ISLNK
-#ifndef __EMX__
-/* Don't define this for OS/2 */
 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
-#endif
 #endif
 
 #ifndef INADDR_NONE
diff -Nu -r -x CVS ../../apachen5/src/main/http_core.c ./main/http_core.c
--- ../../apachen5/src/main/http_core.c	Sun Oct 26 13:53:50 1997
+++ ./main/http_core.c	Sun Nov  2 19:26:32 1997
@@ -1121,7 +1121,7 @@
 		"requires SUEXEC wrapper.\n");
 	}
     }
-#if !defined (BIG_SECURITY_HOLE)
+#if !defined (BIG_SECURITY_HOLE) && !defined (__EMX__)
     if (cmd->server->server_uid == 0) {
 	fprintf (stderr,
 "Error:\tApache has not been designed to serve pages while running\n"
diff -Nu -r -x CVS ../../apachen5/src/main/http_main.c ./main/http_main.c
--- ../../apachen5/src/main/http_main.c	Sun Nov  2 19:35:24 1997
+++ ./main/http_main.c	Sun Nov  2 19:26:32 1997
@@ -1211,7 +1211,7 @@
     char errstr[MAX_STRING_LEN];
     int rc;
 
-    m = (caddr_t) create_shared_heap("\\SHAREMEM\\SCOREBOARD", HARD_SERVER_LIMIT * sizeof(short_score));
+    m = (caddr_t) create_shared_heap("\\SHAREMEM\\SCOREBOARD", SCOREBOARD_SIZE);
     if (m == 0) {
 	fprintf(stderr, "httpd: Could not create OS/2 Shared memory pool.\n");
 	exit(1);
@@ -2071,7 +2071,7 @@
 
 void detach(void)
 {
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__EMX__)
     int x;
 
     chdir("/");
@@ -2130,7 +2130,7 @@
      * but we haven't opened that yet.  So leave it alone for now and it'll
      * be reopened moments later.
      */
-#endif /* ndef WIN32 */
+#endif /* ndef WIN32 or __EMX__ */
 }
 
 /* Reset group privileges, after rereading the config files
diff -Nu -r -x CVS ../../apachen5/src/modules/proxy/proxy_cache.c ./modules/proxy/proxy_cache.c
--- ../../apachen5/src/modules/proxy/proxy_cache.c	Sun Oct 26 13:53:57 1997
+++ ./modules/proxy/proxy_cache.c	Sun Nov  2 19:34:04 1997
@@ -276,6 +276,27 @@
 	/* FIXME: Shouldn't any unexpected files be deleted? */
 	/*      if (strlen(ent->d_name) != HASH_LEN) continue; */
 
+/* under OS/2 use dirent's d_attr to identify a diretory */
+#ifdef __EMX__
+/* is it a directory? */
+	if (ent->d_attr & A_DIR) {
+	    char newcachedir[HUGE_STRING_LEN];
+	    ap_snprintf(newcachedir, sizeof(newcachedir),
+			"%s%s/", cachesubdir, ent->d_name);
+	    if (!sub_garbage_coll(r, files, cachebasedir, newcachedir)) {
+		ap_snprintf(newcachedir, sizeof(newcachedir),
+			    "%s%s", cachedir, ent->d_name);
+#if TESTING
+		fprintf(stderr, "Would remove directory %s\n", newcachedir);
+#else
+		rmdir(newcachedir);
+#endif
+		--nfiles;
+	    }
+	    continue;
+	}
+#endif
+
 /* read the file */
 	fd = open(filename, O_RDONLY | O_BINARY);
 	if (fd == -1) {
@@ -289,6 +310,9 @@
 	    close(fd);
 	    continue;
 	}
+
+/* In OS/2 this has already been done above */
+#ifndef __EMX__
 	if (S_ISDIR(buf.st_mode)) {
 	    char newcachedir[HUGE_STRING_LEN];
 	    close(fd);
@@ -306,6 +330,7 @@
 	    }
 	    continue;
 	}
+#endif
 
 	i = read(fd, line, 26);
 	if (i == -1) {
diff -Nu -r -x CVS ../../apachen5/src/os/emx/.cvsignore ./os/emx/.cvsignore
--- ../../apachen5/src/os/emx/.cvsignore	Wed Dec 31 16:00:00 1969
+++ ./os/emx/.cvsignore	Sun Nov  2 19:38:54 1997
@@ -0,0 +1 @@
+Makefile
diff -Nu -r -x CVS ../../apachen5/src/os/emx/Makefile.tmpl ./os/emx/Makefile.tmpl
--- ../../apachen5/src/os/emx/Makefile.tmpl	Wed Dec 31 16:00:00 1969
+++ ./os/emx/Makefile.tmpl	Sun Nov  2 19:22:27 1997
@@ -0,0 +1,35 @@
+CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
+LIBS=$(EXTRA_LIBS) $(LIBS1)
+INCLUDES=$(INCLUDES_DEPTH2) $(EXTRA_INCLUDES)
+LFLAGS=$(LFLAGS1) $(EXTRA_LFLAGS)
+INCDIR=../../main
+
+OBJS=	os.o os-inline.o
+COPY=	os.h os-inline.c
+
+LIB=	libos.a
+
+all:	$(LIB) copy
+
+copy:
+	for i in $(COPY); do  \
+		rm -f $(INCDIR)/$$i ;\
+		cp `pwd`/$$i $(INCDIR)/$$i ;\
+	done
+
+$(LIB): $(OBJS)
+	rm -f $@
+	ar cr $@ $(OBJS)
+	$(RANLIB) $@
+
+.c.o:
+	$(CC) -c $(INCLUDES) $(CFLAGS) $(SPACER) $<
+
+clean:
+	for i in $(COPY); do  rm -f $(INCDIR)/$$i ; done
+	rm -f $(OBJS) $(LIB)
+
+$(OBJS): Makefile
+
+# DO NOT REMOVE
+os.o:	os.c os-inline.c
diff -Nu -r -x CVS ../../apachen5/src/os/emx/os-inline.c ./os/emx/os-inline.c
--- ../../apachen5/src/os/emx/os-inline.c	Wed Dec 31 16:00:00 1969
+++ ./os/emx/os-inline.c	Sun Nov  2 19:20:41 1997
@@ -0,0 +1,33 @@
+/*
+ * This file contains functions which can be inlined if the compiler
+ * has an "inline" modifier. Because of this, this file is both a
+ * header file and a compilable module.
+ *
+ * Only inlineable functions should be defined in here. They must all
+ * include the INLINE modifier. 
+ *
+ * If the compiler supports inline, this file will be #included as a
+ * header file from os.h to create all the inline function
+ * definitions. INLINE will be defined to whatever is required on
+ * function definitions to make them inline declarations.
+ *
+ * If the compiler does not support inline, this file will be compiled
+ * as a normal C file into libos.a (along with os.c). In this case
+ * INLINE will _not_ be set so we can use this to test if we are
+ * compiling this source file.  
+ */
+
+#ifndef INLINE
+#define INLINE
+
+/* Anything required only when compiling */
+
+#endif
+
+INLINE int os_is_path_absolute(char *file)
+{
+  /* For now, just do the same check that http_request.c and mod_alias.c
+   * do. 
+   */
+  return file && (file[0] == '/' || file[1] == ':');
+}
diff -Nu -r -x CVS ../../apachen5/src/os/emx/os.c ./os/emx/os.c
--- ../../apachen5/src/os/emx/os.c	Wed Dec 31 16:00:00 1969
+++ ./os/emx/os.c	Sun Nov  2 19:20:41 1997
@@ -0,0 +1,6 @@
+/*
+ * This file will include OS specific functions which are not inlineable.
+ * Any inlineable functions should be defined in os-inline.c instead.
+ */
+
+#include "os.h"
diff -Nu -r -x CVS ../../apachen5/src/os/emx/os.h ./os/emx/os.h
--- ../../apachen5/src/os/emx/os.h	Wed Dec 31 16:00:00 1969
+++ ./os/emx/os.h	Sun Nov  2 19:20:41 1997
@@ -0,0 +1,23 @@
+/*
+ * This file in included in all Apache source code. It contains definitions
+ * of facilities available on _this_ operating system (HAVE_* macros),
+ * and prototypes of OS specific functions defined in os.c or os-inline.c
+ */
+
+#if defined(__GNUC__) && !defined(INLINE)
+/* Compiler supports inline, so include the inlineable functions as
+ * part of the header
+ */
+#define INLINE extern __inline__
+#include "os-inline.c"
+#endif
+
+#ifndef INLINE
+/* Compiler does not support inline, so prototype the inlineable functions
+ * as normal
+ */
+extern int os_is_path_absolute(char *f);
+#endif
+
+/* OS/2 doesn't have symlinks so S_ISLNK is always false */
+#define S_ISLNK(m) 0
diff -Nu -r -x CVS ../../apachen5/src/regex/.cvsignore ./regex/.cvsignore
--- ../../apachen5/src/regex/.cvsignore	Sun Oct 26 13:54:08 1997
+++ ./regex/.cvsignore	Sun Nov  2 19:38:40 1997
@@ -3,3 +3,4 @@
 Release
 regex.mdp
 regex.ncb
+Makefile
diff -Nu -r -x CVS ../../apachen5/src/regex/Makefile.tmpl ./regex/Makefile.tmpl
--- ../../apachen5/src/regex/Makefile.tmpl	Wed Dec 31 16:00:00 1969
+++ ./regex/Makefile.tmpl	Sun Nov  2 19:32:23 1997
@@ -0,0 +1,133 @@
+# You probably want to take -DREDEBUG out of CFLAGS, and put something like
+# -O in, *after* testing (-DREDEBUG strengthens testing by enabling a lot of
+# internal assertion checking and some debugging facilities).
+# Put -Dconst= in for a pre-ANSI compiler.
+# Do not take -DPOSIX_MISTAKE out.
+# REGCFLAGS isn't important to you (it's for my use in some special contexts).
+CFLAGS=-I. -DPOSIX_MISTAKE $(AUX_CFLAGS)
+
+# If you have a pre-ANSI compiler, put -o into MKHFLAGS.  If you want
+# the Berkeley __P macro, put -b in.
+MKHFLAGS=
+
+# Flags for linking but not compiling, if any.
+LDFLAGS=
+
+# Extra libraries for linking, if any.
+LIBS=
+
+# Internal stuff, should not need changing.
+OBJPRODN=regcomp.o regexec.o regerror.o regfree.o
+OBJS=$(OBJPRODN) split.o debug.o main.o
+H=cclass.h cname.h regex2.h utils.h
+REGSRC=regcomp.c regerror.c regexec.c regfree.c
+ALLSRC=$(REGSRC) engine.c debug.c main.c split.c
+
+# Stuff that matters only if you're trying to lint the package.
+LINTFLAGS=-I. -Dstatic= -Dconst= -DREDEBUG
+LINTC=regcomp.c regexec.c regerror.c regfree.c debug.c main.c
+JUNKLINT=possible pointer alignment|null effect
+
+# arrangements to build forward-reference header files
+.SUFFIXES:	.ih .h
+.c.ih:
+	sh ./mkh $(MKHFLAGS) -p $< >$@
+
+all lib: libregex.a
+
+libregex.a: $(OBJPRODN)
+	rm -f libregex.a
+	ar cr libregex.a $(OBJPRODN)
+	$(RANLIB) libregex.a
+
+default:	r
+
+purge:
+	rm -f *.o
+
+# stuff to build regex.h
+REGEXH=regex.h
+REGEXHSRC=regex2.h $(REGSRC)
+$(REGEXH):	$(REGEXHSRC) mkh
+	sh ./mkh $(MKHFLAGS) -i _REGEX_H_ $(REGEXHSRC) >regex.h
+	#cmp -s regex.tmp regex.h 2>/dev/null || cp regex.tmp regex.h
+	#rm -f regex.tmp
+
+# dependencies
+$(OBJPRODN) debug.o:	utils.h regex.h regex2.h
+regcomp.o:	cclass.h cname.h regcomp.ih
+regexec.o:	engine.c engine.ih
+regerror.o:	regerror.ih
+debug.o:	debug.ih
+main.o:	main.ih
+
+# tester
+re:	$(OBJS)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
+
+# regression test
+r:	re tests
+	./re <tests
+	./re -el <tests
+	./re -er <tests
+
+# 57 variants, and other stuff, for development use -- not useful to you
+ra:	./re tests
+	-./re <tests
+	-./re -el <tests
+	-./re -er <tests
+
+rx:	./re tests
+	./re -x <tests
+	./re -x -el <tests
+	./re -x -er <tests
+
+t:	./re tests
+	-time ./re <tests
+	-time ./re -cs <tests
+	-time ./re -el <tests
+	-time ./re -cs -el <tests
+
+l:	$(LINTC)
+	lint $(LINTFLAGS) -h $(LINTC) 2>&1 | egrep -v '$(JUNKLINT)' | tee lint
+
+fullprint:
+	ti README WHATSNEW notes todo | list
+	ti *.h | list
+	list *.c
+	list regex.3 regex.7
+
+print:
+	ti README WHATSNEW notes todo | list
+	ti *.h | list
+	list reg*.c engine.c
+
+
+mf.tmp:	Makefile
+	sed '/^REGEXH=/s/=.*/=regex.h/' Makefile | sed '/#DEL$$/d' >$@
+
+DTRH=cclass.h cname.h regex2.h utils.h
+PRE=COPYRIGHT README WHATSNEW
+POST=mkh regex.3 regex.7 tests $(DTRH) $(ALLSRC) fake/*.[ch]
+FILES=$(PRE) Makefile $(POST)
+DTR=$(PRE) Makefile=mf.tmp $(POST)
+dtr:	$(FILES) mf.tmp
+	makedtr $(DTR) >$@
+	rm mf.tmp
+
+cio:	$(FILES)
+	cio $(FILES)
+
+rdf:	$(FILES)
+	rcsdiff -c $(FILES) 2>&1 | p
+
+# various forms of cleanup
+tidy:
+	rm -f junk* core core.* *.core dtr *.tmp lint
+
+clean:	tidy
+	rm -f *.o *.s re libregex.a
+
+# don't do this one unless you know what you're doing
+spotless:	clean
+	rm -f mkh regex.h
diff -Nu -r -x CVS ../../apachen5/src/regex/mkh ./regex/mkh
--- ../../apachen5/src/regex/mkh	Sun Oct 26 13:54:08 1997
+++ ./regex/mkh	Sun Nov  2 19:29:31 1997
@@ -1,6 +1,5 @@
 #! /bin/sh
 # mkh - pull headers out of C source
-PATH=/bin:/usr/bin ; export PATH
 
 # egrep pattern to pick out marked lines
 egrep='^ =([ 	]|$)'