[PATCH] VMS build update

"Craig A. Berry" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Make the VMS-specific configuration and build procedures handle threads, plus admit to having some other things that we do have but weren't configuring for, such as clock_gettime(), socketpair(), getaddrinfo(), and stdio locking.

The attached patch was created with git format-patch and should be applicable with git am.  Or GNU patch -p1 for traditionalists.

TODO:

1.) Fire up a recent port of unixODBC and see whether the ODBC portion of the build needs any attention.

2.) Figure out why src/dblib/t0017.c is failing.  Removing the fgetc/ungetc pair added at the commit below makes it succeed, so there might be a CRTL bug on VMS with either or both of fgetc and ungetc.

$ git blame src/dblib/bcp.c | grep -C3 fgetc
6e3afa4d (Frediano Ziglio        2013-06-05 12:47:50 +0100 1124) 	 * then we've stumbled across the finish line.  Tell the caller we failed to read
6e3afa4d (Frediano Ziglio        2013-06-05 12:47:50 +0100 1125) 	 * anything but encountered no error.
6e3afa4d (Frediano Ziglio        2013-06-05 12:47:50 +0100 1126) 	 */
6e3afa4d (Frediano Ziglio        2013-06-05 12:47:50 +0100 1127) 	i = fgetc(hostfile);
6e3afa4d (Frediano Ziglio        2013-06-05 12:47:50 +0100 1128) 	if (i == EOF)
6e3afa4d (Frediano Ziglio        2013-06-05 12:47:50 +0100 1129) 		return _bcp_check_eof(dbproc, hostfile, 0);
6e3afa4d (Frediano Ziglio        2013-06-05 12:47:50 +0100 1130) 	ungetc(i, hostfile);


________________________________________
Craig A. Berry
mailto:[email protected]

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
0001-VMS-build-update.patch (application/octet-stream, 9.3 KB)
From 6126df17b71021f971ab370078de77babfcb7443 Mon Sep 17 00:00:00 2001
From: "Craig A. Berry" <[email protected]>
Date: Sat, 12 Oct 2013 17:46:46 -0500
Subject: [PATCH] VMS build update.

Make the VMS-specific configuration and build procedure handle
threads, plus admit to having some other things that we do have
but weren't configuring for, such as clock_gettime(), socketpair(),
getaddrinfo(), and stdio locking.
---
 vms/config_h.vms         |   35 +++++++++++++++++++++++++++++++++++
 vms/configure.com        |   30 ++++++++++++++++++++++++++++++
 vms/descrip_mms.template |   25 +++++++++++++++++++++----
 3 files changed, 86 insertions(+), 4 deletions(-)

diff --git a/vms/config_h.vms b/vms/config_h.vms
index 1622c71..b666783 100644
--- a/vms/config_h.vms
+++ b/vms/config_h.vms
@@ -41,6 +41,11 @@
 #define HAVE_BASENAME 0
 #endif
 
+/* Define if you have the clock_gettime function. */
+#if __CRTL_VER >= 70302000
+#define HAVE_CLOCK_GETTIME 1
+#endif
+
 /* Define to 1 if you have the <errno.h> header file. */
 #define HAVE_ERRNO_H 1
 
@@ -95,6 +100,9 @@
 /* Define to 1 if you have the `gethostent_r' function. */
 #undef HAVE_GETHOSTENT_R
 
+/* Define if you have getaddrinfo function */
+#define HAVE_GETADDRINFO 1
+
 /* Define to 1 if you have the `gethostname' function. */
 #define HAVE_GETHOSTNAME 1
 
@@ -156,12 +164,23 @@
 
 #endif
 
+/* Define if you have POSIX threads libraries and header files. */
+#define HAVE_PTHREAD 1
+
+/* Define to 1 if you have the `pthread_cond_timedwait' function. */
+#define HAVE_PTHREAD_COND_TIMEDWAIT 1
+
 /* Define to 1 if you have the GNU Readline library. */
 #define HAVE_READLINE 1
 
 /* Define to 1 if you have the `sethostent_r' function. */
 #undef HAVE_SETHOSTENT_R
 
+/* Define to 1 if you have the `socketpair' function. */
+#if __CRTL_VER >= 80200000
+#define HAVE_SOCKETPAIR 1
+#endif
+
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
@@ -266,6 +285,19 @@
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
 
+/* define to constant to use for clock_gettime */
+#if __CRTL_VER >= 70302000
+#define TDS_GETTIMEMILLI_CONST CLOCK_REALTIME
+#endif
+
+/* Define if you have pthread with mutex support */
+#define TDS_HAVE_PTHREAD_MUTEX 1
+
+/* Define if stdio support locking */
+#if __CRTL_VER >= 80200000
+#define TDS_HAVE_STDIO_LOCKED 1
+#endif
+
 /* define to prefix format string used for 64bit integers */
 #define TDS_I64_PREFIX "ll"
 
@@ -289,6 +321,9 @@
 /* This really just needs to be the current working directory for the tests */
 #define FREETDS_SRCDIR "."
 
+/* But some tests insist on redefining that in terms of this */
+#define FREETDS_TOPDIR "../../.."
+
 #include <limits.h>
 #define MAXPATHLEN PATH_MAX
 
diff --git a/vms/configure.com b/vms/configure.com
index 1c5bd2c..c58c154 100644
--- a/vms/configure.com
+++ b/vms/configure.com
@@ -119,6 +119,13 @@ $ else
 $   snprintfobj = "[.src.replacements]snprintf$(OBJ),"
 $ endif
 $!
+$ if P1 .eqs. "--disable-thread-safe"
+$ then
+$   enable_thread_safe = " "
+$ else
+$   enable_thread_safe = "ENABLE_THREAD_SAFE = 1"
+$ endif
+$!
 $ open/write vmsconfigtmp vmsconfigtmp.com
 $ write vmsconfigtmp "$ define/user_mode/nolog SYS$OUTPUT _NLA0:"
 $ write vmsconfigtmp "$ edit/tpu/nodisplay/noinitialization -"
@@ -136,6 +143,8 @@ $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));"
 $ write vmsconfigtmp "eve_global_replace(""@LIBICONVOBJ@"",""''libiconvobj'"");"
 $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));"
 $ write vmsconfigtmp "eve_global_replace(""@SNPRINTFOBJ@"",""''snprintfobj'"");"
+$ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));"
+$ write vmsconfigtmp "eve_global_replace(""@ENABLE_THREAD_SAFE@"",""''enable_thread_safe'"");"
 $ write vmsconfigtmp "out_file := GET_INFO (COMMAND_LINE, ""output_file"");"
 $ write vmsconfigtmp "WRITE_FILE (main_buffer, out_file);"
 $ write vmsconfigtmp "quit;"
@@ -144,6 +153,27 @@ $ close vmsconfigtmp
 $ @vmsconfigtmp.com
 $ delete/noconfirm/nolog vmsconfigtmp.com;
 $!
+$! C99 requires t, z, and j modifiers to decimal format specifiers
+$! but the HP compiler doesn't handle them, so replace the one
+$! use of %td with %ld.
+$!
+$ open/write vmsbsqldbtmp vmsbsqldbtmp.com
+$ write vmsbsqldbtmp "$ define/user_mode/nolog SYS$OUTPUT _NLA0:"
+$ write vmsbsqldbtmp "$ edit/tpu/nodisplay/noinitialization -"
+$ write vmsbsqldbtmp "/section=sys$library:eve$section.tpu$section -"
+$ write vmsbsqldbtmp "/command=sys$input/output=[.src.apps]bsqldb.c [.src.apps]bsqldb.c"
+$ write vmsbsqldbtmp "input_file := GET_INFO (COMMAND_LINE, ""file_name"");"
+$ write vmsbsqldbtmp "main_buffer:= CREATE_BUFFER (""main"", input_file);"
+$ write vmsbsqldbtmp "POSITION (BEGINNING_OF (main_buffer));"
+$ write vmsbsqldbtmp "eve_global_replace("" %td "","" %ld "");"
+$ write vmsbsqldbtmp "out_file := GET_INFO (COMMAND_LINE, ""output_file"");"
+$ write vmsbsqldbtmp "WRITE_FILE (main_buffer, out_file);"
+$ write vmsbsqldbtmp "quit;"
+$ write vmsbsqldbtmp "$ exit"
+$ close vmsbsqldbtmp
+$ @vmsbsqldbtmp.com
+$ delete/noconfirm/nolog vmsbsqldbtmp.com;
+$!
 $ Say ""
 $ Say "Configuration complete; run MMK or MMS to build."
 $ EXIT
diff --git a/vms/descrip_mms.template b/vms/descrip_mms.template
index e768697..4bc808c 100644
--- a/vms/descrip_mms.template
+++ b/vms/descrip_mms.template
@@ -80,6 +80,14 @@ CODBCFLAGS = /NAMES=SHORTENED
 CPREFIX = ALL
 CINCLUDE = "./","./include"$(ODBC_INC)
 
+@ENABLE_THREAD_SAFE@
+.IFDEF ENABLE_THREAD_SAFE
+CDEFINE = $(CDEFINE),"_THREAD_SAFE"=1
+PTHREAD_LINK_FLAGS = /THREADS=UPCALLS
+.ELSE
+PTHREAD_LINK_FLAGS = 
+.ENDIF
+
 .IFDEF __DEBUG__
 CDBGFLAGS = /DEBUG/NOOPTIMIZE/LIST=$(MMS$TARGET_NAME)/SHOW=(EXPANSION,INCLUDE)
 LDBGFLAGS = /DEBUG/MAP
@@ -89,7 +97,7 @@ LDBGFLAGS = /NOTRACE
 .ENDIF
 
 CFLAGS = /DEFINE=($(CDEFINE))/PREFIX=($(CPREFIX))/FLOAT=IEEE/IEEE=DENORM/OBJECT=$(MMS$TARGET_NAME)$(OBJ) $(CODBCFLAGS) $(CDBGFLAGS)
-LINKFLAGS = $(LDBGFLAGS)
+LINKFLAGS = $(LDBGFLAGS)$(PTHREAD_LINK_FLAGS)
 
 .c$(OBJ) :
 	$(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE)) $(MMS$SOURCE)
@@ -113,7 +121,7 @@ TDSOBJS = [.src.tds]bulk$(OBJ), [.src.tds]challenge$(OBJ), [.src.tds]config$(OBJ
 	[.src.tds]query$(OBJ), [.src.tds]read$(OBJ), [.src.tds]tdsstring$(OBJ), \
 	[.src.tds]threadsafe$(OBJ), [.src.tds]token$(OBJ), [.src.tds]util$(OBJ), \
 	[.src.tds]vstrbuild$(OBJ), [.src.tds]write$(OBJ), [.src.tds]md5$(OBJ), \
-	[.src.tds]net$(OBJ), [.src.tds]log$(OBJ), [.src.tds]stream$(OBJ), \
+	[.src.tds]net$(OBJ), [.src.tds]log$(OBJ), [.src.tds]packet$(OBJ), [.src.tds]stream$(OBJ), \
 	[.src.replacements]strlcpy$(OBJ), [.src.replacements]getpassarg$(OBJ), \
 	$(ASPRINTFOBJ) $(VASPRINTFOBJ) $(SNPRINTFOBJ) $(STRTOK_ROBJ) $(LIBICONVOBJ) \
 	[.vms]getpass$(OBJ)
@@ -121,7 +129,7 @@ TDSOBJS = [.src.tds]bulk$(OBJ), [.src.tds]challenge$(OBJ), [.src.tds]config$(OBJ
 CTLIBOBJS = [.src.ctlib]blk$(OBJ), [.src.ctlib]cs$(OBJ), [.src.ctlib]ct$(OBJ), \
 	[.src.ctlib]ctutil$(OBJ)
 
-DBLIBOBJS = [.src.dblib]bcp$(OBJ), [.src.dblib]dblib$(OBJ), $(DBOPENOBJ) \
+DBLIBOBJS = [.src.dblib]bcp$(OBJ), [.src.dblib]dblib$(OBJ), [.src.dblib]dbpivot$(OBJ), $(DBOPENOBJ) \
 	[.src.dblib]dbutil$(OBJ), [.src.dblib]rpc$(OBJ), [.src.dblib]xact$(OBJ)
 
 TDSSRVOBJS = [.src.server]query$(OBJ), [.src.server]server$(OBJ), [.src.server]login$(OBJ)
@@ -386,6 +394,7 @@ libtdscheck :
 	@ run/nodebug []utf8_1$(E)
 	@ run/nodebug []utf8_2$(E)
 	@ run/nodebug []utf8_3$(E)
+	@ run/nodebug []toodynamic$(E)
 	@ set default [---]
 
 
@@ -538,7 +547,8 @@ libtdstests : [.src.tds.unittests]dynamic1$(E) [.src.tds.unittests]iconv_fread$(
 	[.src.tds.unittests]t0003$(E) [.src.tds.unittests]t0004$(E) [.src.tds.unittests]t0005$(E) \
 	[.src.tds.unittests]t0006$(E) [.src.tds.unittests]t0007$(E) [.src.tds.unittests]t0008$(E) \
 	[.src.tds.unittests]convert$(E) [.src.tds.unittests]dataread$(E) \
-	[.src.tds.unittests]utf8_1$(E) [.src.tds.unittests]utf8_2$(E) [.src.tds.unittests]utf8_3$(E)
+	[.src.tds.unittests]utf8_1$(E) [.src.tds.unittests]utf8_2$(E) [.src.tds.unittests]utf8_3$(E) \
+	[.src.tds.unittests]toodynamic$(E)
 	@ continue
 
 ctlibtests : [.src.ctlib.unittests]t0001$(E) [.src.ctlib.unittests]t0002$(E) [.src.ctlib.unittests]t0003$(E) \
@@ -701,6 +711,12 @@ odbctests : [.src.odbc.unittests]t0001$(E) [.src.odbc.unittests]t0002$(E) [.src.
 [.src.tds.unittests]utf8_3$(OBJ) : [.src.tds.unittests]utf8_3.c
 	$(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE)
 
+[.src.tds.unittests]toodynamic$(E) : [.src.tds.unittests]toodynamic$(OBJ) [.src.tds.unittests]common$(OBJ)
+	link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library
+
+[.src.tds.unittests]toodynamic$(OBJ) : [.src.tds.unittests]toodynamic.c
+	$(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE)
+
 # ctlib test detailed dependencies
 
 [.src.ctlib.unittests]t0001$(E) : [.src.ctlib.unittests]t0001$(OBJ) [.src.ctlib.unittests]common$(OBJ)
@@ -1457,6 +1473,7 @@ distclean :
 	@ if f$search("[...unittests]*$(E)") .nes. "" then delete/noconfirm [...unittests]*$(E);*
 	@ if f$search("[.src.odbc._libs]*$(E)") .nes. "" then delete/noconfirm [.src.odbc._libs]*$(E);*
 	@ if f$search("[...unittests]*.ini") .nes. "" then delete/noconfirm [...unittests]*.ini;*
+	@ if f$search("[...unittests]*.out") .nes. "" then delete/noconfirm [...unittests]*.out;*
 	@ if f$search("*$(OLB)") .nes. "" then purge/noconfirm *$(OLB)
 	@ if f$search("*$(E)") .nes. "" then purge/noconfirm *$(E)
 
-- 
1.7.7.GIT
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.