Fix compiler warnings on 64-bit Windows
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 21 Feb 2020 18:49:44 +0000 (19:49 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 21 Feb 2020 18:58:39 +0000 (19:58 +0100)
GCC reports various instances of

warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

and MSVC equivalently

warning C4312: 'type cast': conversion from 'int' to 'void *' of greater size
warning C4311: 'type cast': pointer truncation from 'void *' to 'long'

in ECPG test files.  This is because void* and long are cast back and
forth, but on 64-bit Windows, these have different sizes.  Fix by
using intptr_t instead.

The code actually worked fine because the integer values in use are
all small.  So this is just to get the test code to compile warning-free.

This change is simplified by having made stdint.h required (commit
957338418b69e9774ccc1bab59f765a62f0aa6f9).  Before this it would have
been more complicated because the ecpg test source files don't use the
full pg_config.h.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/5d398bbb-262a-5fed-d839-d0e5cff3c0d7%402ndquadrant.com

src/interfaces/ecpg/test/expected/thread-alloc.c
src/interfaces/ecpg/test/expected/thread-prep.c
src/interfaces/ecpg/test/expected/thread-thread.c
src/interfaces/ecpg/test/expected/thread-thread_implicit.c
src/interfaces/ecpg/test/thread/alloc.pgc
src/interfaces/ecpg/test/thread/prep.pgc
src/interfaces/ecpg/test/thread/thread.pgc
src/interfaces/ecpg/test/thread/thread_implicit.pgc

index 9678ebe6fd6fbb290b6311fa3a48779718cf105b..37ef44ed94bd0efde5a951917ec758ffcacd169a 100644 (file)
@@ -7,6 +7,7 @@
 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
 
 #line 1 "alloc.pgc"
+#include <stdint.h>
 #include <stdlib.h>
 #include "ecpg_config.h"
 
@@ -100,7 +101,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 #endif
 
-#line 25 "alloc.pgc"
+#line 26 "alloc.pgc"
 
 
 #line 1 "regression.h"
@@ -110,14 +111,14 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 
-#line 26 "alloc.pgc"
+#line 27 "alloc.pgc"
 
 
 /* exec sql whenever sqlerror  sqlprint ; */
-#line 28 "alloc.pgc"
+#line 29 "alloc.pgc"
 
 /* exec sql whenever not found  sqlprint ; */
-#line 29 "alloc.pgc"
+#line 30 "alloc.pgc"
 
 
 #ifdef WIN32
@@ -133,54 +134,54 @@ static void* fn(void* arg)
     
       
    
-#line 40 "alloc.pgc"
+#line 41 "alloc.pgc"
  int value ;
  
-#line 41 "alloc.pgc"
+#line 42 "alloc.pgc"
  char name [ 100 ] ;
  
-#line 42 "alloc.pgc"
+#line 43 "alloc.pgc"
  char ** r = NULL ;
 /* exec sql end declare section */
-#line 43 "alloc.pgc"
+#line 44 "alloc.pgc"
 
 
-   value = (long)arg;
+   value = (intptr_t) arg;
    sprintf(name, "Connection: %d", value);
 
    { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0); 
-#line 48 "alloc.pgc"
+#line 49 "alloc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 48 "alloc.pgc"
+#line 49 "alloc.pgc"
 
    { ECPGsetcommit(__LINE__, "on", NULL);
-#line 49 "alloc.pgc"
+#line 50 "alloc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 49 "alloc.pgc"
+#line 50 "alloc.pgc"
 
    for (i = 1; i <= REPEATS; ++i)
    {
        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select relname from pg_class where relname = 'pg_class'", ECPGt_EOIT, 
    ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 52 "alloc.pgc"
+#line 53 "alloc.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
-#line 52 "alloc.pgc"
+#line 53 "alloc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 52 "alloc.pgc"
+#line 53 "alloc.pgc"
 
        free(r);
        r = NULL;
    }
    { ECPGdisconnect(__LINE__, name);
-#line 56 "alloc.pgc"
+#line 57 "alloc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 56 "alloc.pgc"
+#line 57 "alloc.pgc"
 
 
    return 0;
@@ -188,7 +189,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 int main ()
 {
-   int i;
+   intptr_t i;
 #ifdef WIN32
    HANDLE threads[THREADS];
 #else
@@ -207,7 +208,7 @@ int main ()
        CloseHandle(threads[i]);
 #else
    for (i = 0; i < THREADS; ++i)
-       pthread_create(&threads[i], NULL, fn, (void *) (long) i);
+       pthread_create(&threads[i], NULL, fn, (void *) i);
    for (i = 0; i < THREADS; ++i)
        pthread_join(threads[i], NULL);
 #endif
index 98861d36f0200ebf3fe120b93f25b30f9072233c..7cdf2505d3f334dbcb06e01eb1abdf9cebbd5a65 100644 (file)
@@ -7,6 +7,7 @@
 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
 
 #line 1 "prep.pgc"
+#include <stdint.h>
 #include <stdlib.h>
 #include "ecpg_config.h"
 
@@ -100,7 +101,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 #endif
 
-#line 25 "prep.pgc"
+#line 26 "prep.pgc"
 
 
 #line 1 "regression.h"
@@ -110,14 +111,14 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 
-#line 26 "prep.pgc"
+#line 27 "prep.pgc"
 
 
 /* exec sql whenever sqlerror  sqlprint ; */
-#line 28 "prep.pgc"
+#line 29 "prep.pgc"
 
 /* exec sql whenever not found  sqlprint ; */
-#line 29 "prep.pgc"
+#line 30 "prep.pgc"
 
 
 #ifdef WIN32
@@ -133,64 +134,64 @@ static void* fn(void* arg)
     
       
    
-#line 40 "prep.pgc"
+#line 41 "prep.pgc"
  int value ;
  
-#line 41 "prep.pgc"
+#line 42 "prep.pgc"
  char name [ 100 ] ;
  
-#line 42 "prep.pgc"
+#line 43 "prep.pgc"
  char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ;
 /* exec sql end declare section */
-#line 43 "prep.pgc"
+#line 44 "prep.pgc"
 
 
-   value = (long)arg;
+   value = (intptr_t) arg;
    sprintf(name, "Connection: %d", value);
 
    { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0); 
-#line 48 "prep.pgc"
+#line 49 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 48 "prep.pgc"
+#line 49 "prep.pgc"
 
    { ECPGsetcommit(__LINE__, "on", NULL);
-#line 49 "prep.pgc"
+#line 50 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 49 "prep.pgc"
+#line 50 "prep.pgc"
 
    for (i = 1; i <= REPEATS; ++i)
    {
        { ECPGprepare(__LINE__, NULL, 0, "i", query);
-#line 52 "prep.pgc"
+#line 53 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 52 "prep.pgc"
+#line 53 "prep.pgc"
 
        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", 
    ECPGt_int,&(value),(long)1,(long)1,sizeof(int), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 53 "prep.pgc"
+#line 54 "prep.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
-#line 53 "prep.pgc"
+#line 54 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 53 "prep.pgc"
+#line 54 "prep.pgc"
 
    }
    { ECPGdeallocate(__LINE__, 0, NULL, "i");
-#line 55 "prep.pgc"
+#line 56 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 55 "prep.pgc"
+#line 56 "prep.pgc"
 
    { ECPGdisconnect(__LINE__, name);
-#line 56 "prep.pgc"
+#line 57 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 56 "prep.pgc"
+#line 57 "prep.pgc"
 
 
    return 0;
@@ -198,7 +199,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 int main ()
 {
-   int i;
+   intptr_t i;
 #ifdef WIN32
    HANDLE threads[THREADS];
 #else
@@ -206,35 +207,35 @@ int main ()
 #endif
 
    { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); 
-#line 70 "prep.pgc"
-
-if (sqlca.sqlcode < 0) sqlprint();}
-#line 70 "prep.pgc"
-
-   { ECPGsetcommit(__LINE__, "on", NULL);
 #line 71 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 71 "prep.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table if exists T", ECPGt_EOIT, ECPGt_EORT);
+   { ECPGsetcommit(__LINE__, "on", NULL);
 #line 72 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 72 "prep.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( i int )", ECPGt_EOIT, ECPGt_EORT);
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table if exists T", ECPGt_EOIT, ECPGt_EORT);
 #line 73 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 73 "prep.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( i int )", ECPGt_EOIT, ECPGt_EORT);
 #line 74 "prep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 74 "prep.pgc"
 
+   { ECPGdisconnect(__LINE__, "CURRENT");
+#line 75 "prep.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 75 "prep.pgc"
+
 
 #ifdef WIN32
    for (i = 0; i < THREADS; ++i)
@@ -248,7 +249,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
        CloseHandle(threads[i]);
 #else
    for (i = 0; i < THREADS; ++i)
-       pthread_create(&threads[i], NULL, fn, (void *) (long) i);
+       pthread_create(&threads[i], NULL, fn, (void *) i);
    for (i = 0; i < THREADS; ++i)
        pthread_join(threads[i], NULL);
 #endif
index 68f153e57c1a39f9dbf495f81847b1755816e571..a7e401570a40975a2a1f83c86f69d5d7b3f6502d 100644 (file)
@@ -11,6 +11,7 @@
  * Thread test program
  * by Philip Yarra & Lee Kindness.
  */
+#include <stdint.h>
 #include <stdlib.h>
 #include "ecpg_config.h"
 
@@ -37,7 +38,7 @@ main(void)
 
 
 
-#line 23 "thread.pgc"
+#line 24 "thread.pgc"
 
 
 void *test_thread(void *arg);
@@ -52,14 +53,14 @@ int main()
 #else
   HANDLE *threads;
 #endif
-  int n;
+  intptr_t n;
   /* exec sql begin declare section */
    
   
-#line 39 "thread.pgc"
+#line 40 "thread.pgc"
  int l_rows ;
 /* exec sql end declare section */
-#line 40 "thread.pgc"
+#line 41 "thread.pgc"
 
 
  /* Do not switch on debug output for regression tests. The threads get executed in
@@ -68,22 +69,22 @@ int main()
 
   /* setup test_thread table */
   { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 47 "thread.pgc"
+#line 48 "thread.pgc"
 
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test_thread", ECPGt_EOIT, ECPGt_EORT);}
-#line 48 "thread.pgc"
+#line 49 "thread.pgc"
  /* DROP might fail */
   { ECPGtrans(__LINE__, NULL, "commit");}
-#line 49 "thread.pgc"
+#line 50 "thread.pgc"
 
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test_thread ( tstamp timestamp not null default cast ( timeofday ( ) as timestamp ) , thread text not null , iteration integer not null , primary key ( thread , iteration ) )", ECPGt_EOIT, ECPGt_EORT);}
-#line 54 "thread.pgc"
+#line 55 "thread.pgc"
 
   { ECPGtrans(__LINE__, NULL, "commit");}
-#line 55 "thread.pgc"
+#line 56 "thread.pgc"
 
   { ECPGdisconnect(__LINE__, "CURRENT");}
-#line 56 "thread.pgc"
+#line 57 "thread.pgc"
 
 
   /* create, and start, threads */
@@ -96,7 +97,7 @@ int main()
   for( n = 0; n < nthreads; n++ )
     {
 #ifndef WIN32
-      pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1));
+      pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
 #else
       threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_thread, (void *) (n + 1), 0, NULL);
 #endif
@@ -115,18 +116,18 @@ int main()
 
   /* and check results */
   { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 86 "thread.pgc"
+#line 87 "thread.pgc"
 
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from test_thread", ECPGt_EOIT, 
    ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
-#line 87 "thread.pgc"
+#line 88 "thread.pgc"
 
   { ECPGtrans(__LINE__, NULL, "commit");}
-#line 88 "thread.pgc"
+#line 89 "thread.pgc"
 
   { ECPGdisconnect(__LINE__, "CURRENT");}
-#line 89 "thread.pgc"
+#line 90 "thread.pgc"
 
   if( l_rows == (nthreads * iterations) )
     printf("Success.\n");
@@ -138,19 +139,19 @@ int main()
 
 void *test_thread(void *arg)
 {
-  long threadnum = (long)arg;
+  long threadnum = (intptr_t) arg;
 
   /* exec sql begin declare section */
     
    
   
-#line 103 "thread.pgc"
+#line 104 "thread.pgc"
  int l_i ;
  
-#line 104 "thread.pgc"
+#line 105 "thread.pgc"
  char l_connection [ 128 ] ;
 /* exec sql end declare section */
-#line 105 "thread.pgc"
+#line 106 "thread.pgc"
 
 
   /* build up connection name, and connect to database */
@@ -160,13 +161,13 @@ void *test_thread(void *arg)
   _snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
 #endif
   /* exec sql whenever sqlerror  sqlprint ; */
-#line 113 "thread.pgc"
+#line 114 "thread.pgc"
 
   { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0); 
-#line 114 "thread.pgc"
+#line 115 "thread.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 114 "thread.pgc"
+#line 115 "thread.pgc"
 
   if( sqlca.sqlcode != 0 )
     {
@@ -174,10 +175,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
       return NULL;
     }
   { ECPGtrans(__LINE__, l_connection, "begin");
-#line 120 "thread.pgc"
+#line 121 "thread.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 120 "thread.pgc"
+#line 121 "thread.pgc"
 
 
   /* insert into test_thread table */
@@ -188,10 +189,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
    ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 125 "thread.pgc"
+#line 126 "thread.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 125 "thread.pgc"
+#line 126 "thread.pgc"
 
       if( sqlca.sqlcode != 0 )
    printf("%s: ERROR: insert failed!\n", l_connection);
@@ -199,16 +200,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
   /* all done */
   { ECPGtrans(__LINE__, l_connection, "commit");
-#line 131 "thread.pgc"
+#line 132 "thread.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 131 "thread.pgc"
+#line 132 "thread.pgc"
 
   { ECPGdisconnect(__LINE__, l_connection);
-#line 132 "thread.pgc"
+#line 133 "thread.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 132 "thread.pgc"
+#line 133 "thread.pgc"
 
   return NULL;
 }
index d0352765486da3252ab1fda23f05ea79fa055b5c..6c7adb062c8075ae6c6678cc188a607c199ee63f 100644 (file)
@@ -11,7 +11,7 @@
  * Thread test program
  * by Lee Kindness.
  */
-
+#include <stdint.h>
 #include <stdlib.h>
 #include "ecpg_config.h"
 
@@ -53,7 +53,7 @@ int main()
 #else
   HANDLE *threads;
 #endif
-  int n;
+  intptr_t n;
   /* exec sql begin declare section */
    
   
@@ -97,7 +97,7 @@ int main()
   for( n = 0; n < nthreads; n++ )
     {
 #ifndef WIN32
-      pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1));
+      pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
 #else
       threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_thread, (void *) (n+1), 0, NULL);
 #endif
@@ -139,7 +139,7 @@ int main()
 
 void *test_thread(void *arg)
 {
-  long threadnum = (long)arg;
+  long threadnum = (intptr_t) arg;
 
   /* exec sql begin declare section */
     
index c44bc91d78f7933489cb06578ffa583fcd821859..c0021a737ed312fbca9dc0f9f12d8c161c04dc63 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #include <stdlib.h>
 #include "ecpg_config.h"
 
@@ -42,7 +43,7 @@ static void* fn(void* arg)
    char **r = NULL;
    EXEC SQL END DECLARE SECTION;
 
-   value = (long)arg;
+   value = (intptr_t) arg;
    sprintf(name, "Connection: %d", value);
 
    EXEC SQL CONNECT TO REGRESSDB1 AS :name;
@@ -60,7 +61,7 @@ static void* fn(void* arg)
 
 int main ()
 {
-   int i;
+   intptr_t i;
 #ifdef WIN32
    HANDLE threads[THREADS];
 #else
@@ -79,7 +80,7 @@ int main ()
        CloseHandle(threads[i]);
 #else
    for (i = 0; i < THREADS; ++i)
-       pthread_create(&threads[i], NULL, fn, (void *) (long) i);
+       pthread_create(&threads[i], NULL, fn, (void *) i);
    for (i = 0; i < THREADS; ++i)
        pthread_join(threads[i], NULL);
 #endif
index bdf27e7d5aa3439cc2a4b393af61759e32ba36b7..d7ecfd485559848520c264ec17f1f035c4fd1d2b 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #include <stdlib.h>
 #include "ecpg_config.h"
 
@@ -42,7 +43,7 @@ static void* fn(void* arg)
    char query[256] = "INSERT INTO T VALUES ( ? )";
    EXEC SQL END DECLARE SECTION;
 
-   value = (long)arg;
+   value = (intptr_t) arg;
    sprintf(name, "Connection: %d", value);
 
    EXEC SQL CONNECT TO REGRESSDB1 AS :name;
@@ -60,7 +61,7 @@ static void* fn(void* arg)
 
 int main ()
 {
-   int i;
+   intptr_t i;
 #ifdef WIN32
    HANDLE threads[THREADS];
 #else
@@ -85,7 +86,7 @@ int main ()
        CloseHandle(threads[i]);
 #else
    for (i = 0; i < THREADS; ++i)
-       pthread_create(&threads[i], NULL, fn, (void *) (long) i);
+       pthread_create(&threads[i], NULL, fn, (void *) i);
    for (i = 0; i < THREADS; ++i)
        pthread_join(threads[i], NULL);
 #endif
index 0e3217ce63c600e3726951d427eeaa301d34e5e9..e149b91d976b096cf540c417ca4ac3527f3e51b9 100644 (file)
@@ -2,6 +2,7 @@
  * Thread test program
  * by Philip Yarra & Lee Kindness.
  */
+#include <stdint.h>
 #include <stdlib.h>
 #include "ecpg_config.h"
 
@@ -34,7 +35,7 @@ int main()
 #else
   HANDLE *threads;
 #endif
-  int n;
+  intptr_t n;
   EXEC SQL BEGIN DECLARE SECTION;
   int l_rows;
   EXEC SQL END DECLARE SECTION;
@@ -65,7 +66,7 @@ int main()
   for( n = 0; n < nthreads; n++ )
     {
 #ifndef WIN32
-      pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1));
+      pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
 #else
       threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_thread, (void *) (n + 1), 0, NULL);
 #endif
@@ -97,7 +98,7 @@ int main()
 
 void *test_thread(void *arg)
 {
-  long threadnum = (long)arg;
+  long threadnum = (intptr_t) arg;
 
   EXEC SQL BEGIN DECLARE SECTION;
   int  l_i;
index bbc4d7783c1770641ea70953fe0f07b408b6fb94..3209da22bc54d78202be1823ab44f51e76452c7d 100644 (file)
@@ -2,7 +2,7 @@
  * Thread test program
  * by Lee Kindness.
  */
-
+#include <stdint.h>
 #include <stdlib.h>
 #include "ecpg_config.h"
 
@@ -35,7 +35,7 @@ int main()
 #else
   HANDLE *threads;
 #endif
-  int n;
+  intptr_t n;
   EXEC SQL BEGIN DECLARE SECTION;
   int l_rows;
   EXEC SQL END DECLARE SECTION;
@@ -66,7 +66,7 @@ int main()
   for( n = 0; n < nthreads; n++ )
     {
 #ifndef WIN32
-      pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1));
+      pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
 #else
       threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_thread, (void *) (n+1), 0, NULL);
 #endif
@@ -98,7 +98,7 @@ int main()
 
 void *test_thread(void *arg)
 {
-  long threadnum = (long)arg;
+  long threadnum = (intptr_t) arg;
 
   EXEC SQL BEGIN DECLARE SECTION;
   int  l_i;