Skip to Content.
Sympa Menu

freetds - [freetds] portability suggestion for src/tds/unittests/convert.c

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Craig A. Berry" <craigberry AT mac.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] portability suggestion for src/tds/unittests/convert.c
  • Date: Thu, 01 Jan 2004 18:15:13 -0600

In finalizing the VMS port for the upcoming release, I ran into a couple
of small gotchas with src/tds/unittests/convert.c, with a suggested
patch attached below.

1.) The Single UNIX Specification says that the behavior of
gettimeofday() is undefined unless the second argument is NULL. I think
that's a language lawyer way of saying it's deprecated and we don't
really know what will happen if you were depending on it. My system
(OpenVMS Alpha 7.3-1) doesn't even define the timezone type in its headers.

2.) The other thing I had trouble with was the relative path "../"
prepended when including tds_willconvert.h. My build procedure doesn't
change directories to the unittests directory when building the tests,
so this causes the compiler to look in the wrong place for the include
file. The patch moves the include directory from the C code to the
Makefile.am (which is a policy that appears to be observed everywhere
else in the sources). I tried to test this on Mac OS X, but my autoconf
version is too old, so I defer to the configuration gurus on whether the
patch handles this correctly.


--- src/tds/unittests/convert.c;-0 Sat Dec 6 07:43:53 2003
+++ src/tds/unittests/convert.c Thu Jan 1 10:28:11 2004
@@ -49,7 +49,7 @@
}
ANSWER;
const static ANSWER answers[] = {
-# include "../tds_willconvert.h"
+# include "tds_willconvert.h"
};

/* some default inputs */
@@ -57,7 +57,6 @@

/* timing variables to compute performance */
struct timeval start, end;
- struct timezone tzp;
double starttime, endtime;

int i, j, iterations = 0, result;
@@ -280,7 +279,7 @@
* If an iteration count was passed on the command line (not
by "make check")
* run the conversion N times and print the conversions per
second.
*/
- result = gettimeofday(&start, &tzp);
+ result = gettimeofday(&start, NULL);
starttime = (double) start.tv_sec + (double) start.tv_usec *
0.000001;

for (j = 0; result >= 0 && j < iterations; j++) {
@@ -288,7 +287,7 @@

}

- result = gettimeofday(&end, &tzp);
+ result = gettimeofday(&end, NULL);
endtime = (double) end.tv_sec + (double) end.tv_usec *
0.000001;

printf("%8.0f iterations/second converting %13s => %s.\n",
--- src/tds/unittests/Makefile.am;-0 Sat Nov 15 10:12:04 2003
+++ src/tds/unittests/Makefile.am Thu Jan 1 10:28:11 2004
@@ -21,5 +21,5 @@
utf8_2_SOURCES = utf8_2.c common.c common.h

LIBS = ../libtds.la @NETWORK_LIBS@
-INCLUDES = -I$(top_srcdir)/include
+INCLUDES = -I$(top_srcdir)/include -I../
CLEANFILES = tdsdump.out



Archive powered by MHonArc 2.6.24.

Top of Page