Commit 3f9c1697 authored by Peter Eisentraut's avatar Peter Eisentraut

Fix compiler warnings on 64-bit Windows

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
95733841).  Before this it would have
been more complicated because the ecpg test source files don't use the
full pg_config.h.
Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/5d398bbb-262a-5fed-d839-d0e5cff3c0d7%402ndquadrant.com
parent b7fabe80
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "alloc.pgc" #line 1 "alloc.pgc"
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "ecpg_config.h" #include "ecpg_config.h"
...@@ -100,7 +101,7 @@ struct sqlca_t *ECPGget_sqlca(void); ...@@ -100,7 +101,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif #endif
#line 25 "alloc.pgc" #line 26 "alloc.pgc"
#line 1 "regression.h" #line 1 "regression.h"
...@@ -110,14 +111,14 @@ struct sqlca_t *ECPGget_sqlca(void); ...@@ -110,14 +111,14 @@ struct sqlca_t *ECPGget_sqlca(void);
#line 26 "alloc.pgc" #line 27 "alloc.pgc"
/* exec sql whenever sqlerror sqlprint ; */ /* exec sql whenever sqlerror sqlprint ; */
#line 28 "alloc.pgc" #line 29 "alloc.pgc"
/* exec sql whenever not found sqlprint ; */ /* exec sql whenever not found sqlprint ; */
#line 29 "alloc.pgc" #line 30 "alloc.pgc"
#ifdef WIN32 #ifdef WIN32
...@@ -133,54 +134,54 @@ static void* fn(void* arg) ...@@ -133,54 +134,54 @@ static void* fn(void* arg)
#line 40 "alloc.pgc" #line 41 "alloc.pgc"
int value ; int value ;
#line 41 "alloc.pgc" #line 42 "alloc.pgc"
char name [ 100 ] ; char name [ 100 ] ;
#line 42 "alloc.pgc" #line 43 "alloc.pgc"
char ** r = NULL ; char ** r = NULL ;
/* exec sql end declare section */ /* 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); sprintf(name, "Connection: %d", value);
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0); { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
#line 48 "alloc.pgc" #line 49 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 48 "alloc.pgc" #line 49 "alloc.pgc"
{ ECPGsetcommit(__LINE__, "on", NULL); { ECPGsetcommit(__LINE__, "on", NULL);
#line 49 "alloc.pgc" #line 50 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 49 "alloc.pgc" #line 50 "alloc.pgc"
for (i = 1; i <= REPEATS; ++i) 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, { 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_char,&(r),(long)0,(long)0,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 52 "alloc.pgc" #line 53 "alloc.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 52 "alloc.pgc" #line 53 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 52 "alloc.pgc" #line 53 "alloc.pgc"
free(r); free(r);
r = NULL; r = NULL;
} }
{ ECPGdisconnect(__LINE__, name); { ECPGdisconnect(__LINE__, name);
#line 56 "alloc.pgc" #line 57 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 56 "alloc.pgc" #line 57 "alloc.pgc"
return 0; return 0;
...@@ -188,7 +189,7 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -188,7 +189,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
int main () int main ()
{ {
int i; intptr_t i;
#ifdef WIN32 #ifdef WIN32
HANDLE threads[THREADS]; HANDLE threads[THREADS];
#else #else
...@@ -207,7 +208,7 @@ int main () ...@@ -207,7 +208,7 @@ int main ()
CloseHandle(threads[i]); CloseHandle(threads[i]);
#else #else
for (i = 0; i < THREADS; ++i) 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) for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL); pthread_join(threads[i], NULL);
#endif #endif
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "prep.pgc" #line 1 "prep.pgc"
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "ecpg_config.h" #include "ecpg_config.h"
...@@ -100,7 +101,7 @@ struct sqlca_t *ECPGget_sqlca(void); ...@@ -100,7 +101,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif #endif
#line 25 "prep.pgc" #line 26 "prep.pgc"
#line 1 "regression.h" #line 1 "regression.h"
...@@ -110,14 +111,14 @@ struct sqlca_t *ECPGget_sqlca(void); ...@@ -110,14 +111,14 @@ struct sqlca_t *ECPGget_sqlca(void);
#line 26 "prep.pgc" #line 27 "prep.pgc"
/* exec sql whenever sqlerror sqlprint ; */ /* exec sql whenever sqlerror sqlprint ; */
#line 28 "prep.pgc" #line 29 "prep.pgc"
/* exec sql whenever not found sqlprint ; */ /* exec sql whenever not found sqlprint ; */
#line 29 "prep.pgc" #line 30 "prep.pgc"
#ifdef WIN32 #ifdef WIN32
...@@ -133,64 +134,64 @@ static void* fn(void* arg) ...@@ -133,64 +134,64 @@ static void* fn(void* arg)
#line 40 "prep.pgc" #line 41 "prep.pgc"
int value ; int value ;
#line 41 "prep.pgc" #line 42 "prep.pgc"
char name [ 100 ] ; char name [ 100 ] ;
#line 42 "prep.pgc" #line 43 "prep.pgc"
char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ; char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ;
/* exec sql end declare section */ /* 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); sprintf(name, "Connection: %d", value);
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0); { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
#line 48 "prep.pgc" #line 49 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 48 "prep.pgc" #line 49 "prep.pgc"
{ ECPGsetcommit(__LINE__, "on", NULL); { ECPGsetcommit(__LINE__, "on", NULL);
#line 49 "prep.pgc" #line 50 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 49 "prep.pgc" #line 50 "prep.pgc"
for (i = 1; i <= REPEATS; ++i) for (i = 1; i <= REPEATS; ++i)
{ {
{ ECPGprepare(__LINE__, NULL, 0, "i", query); { ECPGprepare(__LINE__, NULL, 0, "i", query);
#line 52 "prep.pgc" #line 53 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 52 "prep.pgc" #line 53 "prep.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i",
ECPGt_int,&(value),(long)1,(long)1,sizeof(int), ECPGt_int,&(value),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); 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(); if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 53 "prep.pgc" #line 54 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 53 "prep.pgc" #line 54 "prep.pgc"
} }
{ ECPGdeallocate(__LINE__, 0, NULL, "i"); { ECPGdeallocate(__LINE__, 0, NULL, "i");
#line 55 "prep.pgc" #line 56 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 55 "prep.pgc" #line 56 "prep.pgc"
{ ECPGdisconnect(__LINE__, name); { ECPGdisconnect(__LINE__, name);
#line 56 "prep.pgc" #line 57 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 56 "prep.pgc" #line 57 "prep.pgc"
return 0; return 0;
...@@ -198,7 +199,7 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -198,7 +199,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
int main () int main ()
{ {
int i; intptr_t i;
#ifdef WIN32 #ifdef WIN32
HANDLE threads[THREADS]; HANDLE threads[THREADS];
#else #else
...@@ -206,35 +207,35 @@ int main () ...@@ -206,35 +207,35 @@ int main ()
#endif #endif
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); { 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" #line 71 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 71 "prep.pgc" #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" #line 72 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 72 "prep.pgc" #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" #line 73 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 73 "prep.pgc" #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" #line 74 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 74 "prep.pgc" #line 74 "prep.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
#line 75 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 75 "prep.pgc"
#ifdef WIN32 #ifdef WIN32
for (i = 0; i < THREADS; ++i) for (i = 0; i < THREADS; ++i)
...@@ -248,7 +249,7 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -248,7 +249,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
CloseHandle(threads[i]); CloseHandle(threads[i]);
#else #else
for (i = 0; i < THREADS; ++i) 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) for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL); pthread_join(threads[i], NULL);
#endif #endif
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
* Thread test program * Thread test program
* by Philip Yarra & Lee Kindness. * by Philip Yarra & Lee Kindness.
*/ */
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "ecpg_config.h" #include "ecpg_config.h"
...@@ -37,7 +38,7 @@ main(void) ...@@ -37,7 +38,7 @@ main(void)
#line 23 "thread.pgc" #line 24 "thread.pgc"
void *test_thread(void *arg); void *test_thread(void *arg);
...@@ -52,14 +53,14 @@ int main() ...@@ -52,14 +53,14 @@ int main()
#else #else
HANDLE *threads; HANDLE *threads;
#endif #endif
int n; intptr_t n;
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 39 "thread.pgc" #line 40 "thread.pgc"
int l_rows ; int l_rows ;
/* exec sql end declare section */ /* 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 /* Do not switch on debug output for regression tests. The threads get executed in
...@@ -68,22 +69,22 @@ int main() ...@@ -68,22 +69,22 @@ int main()
/* setup test_thread table */ /* setup test_thread table */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } { 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);} { 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 */ /* DROP might fail */
{ ECPGtrans(__LINE__, NULL, "commit");} { 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);} { 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");} { ECPGtrans(__LINE__, NULL, "commit");}
#line 55 "thread.pgc" #line 56 "thread.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");} { ECPGdisconnect(__LINE__, "CURRENT");}
#line 56 "thread.pgc" #line 57 "thread.pgc"
/* create, and start, threads */ /* create, and start, threads */
...@@ -96,7 +97,7 @@ int main() ...@@ -96,7 +97,7 @@ int main()
for( n = 0; n < nthreads; n++ ) for( n = 0; n < nthreads; n++ )
{ {
#ifndef WIN32 #ifndef WIN32
pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1)); pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
#else #else
threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_thread, (void *) (n + 1), 0, NULL); threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_thread, (void *) (n + 1), 0, NULL);
#endif #endif
...@@ -115,18 +116,18 @@ int main() ...@@ -115,18 +116,18 @@ int main()
/* and check results */ /* and check results */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } { 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, { 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_int,&(l_rows),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 87 "thread.pgc" #line 88 "thread.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");} { ECPGtrans(__LINE__, NULL, "commit");}
#line 88 "thread.pgc" #line 89 "thread.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");} { ECPGdisconnect(__LINE__, "CURRENT");}
#line 89 "thread.pgc" #line 90 "thread.pgc"
if( l_rows == (nthreads * iterations) ) if( l_rows == (nthreads * iterations) )
printf("Success.\n"); printf("Success.\n");
...@@ -138,19 +139,19 @@ int main() ...@@ -138,19 +139,19 @@ int main()
void *test_thread(void *arg) void *test_thread(void *arg)
{ {
long threadnum = (long)arg; long threadnum = (intptr_t) arg;
/* exec sql begin declare section */ /* exec sql begin declare section */
#line 103 "thread.pgc" #line 104 "thread.pgc"
int l_i ; int l_i ;
#line 104 "thread.pgc" #line 105 "thread.pgc"
char l_connection [ 128 ] ; char l_connection [ 128 ] ;
/* exec sql end declare section */ /* exec sql end declare section */
#line 105 "thread.pgc" #line 106 "thread.pgc"
/* build up connection name, and connect to database */ /* build up connection name, and connect to database */
...@@ -160,13 +161,13 @@ void *test_thread(void *arg) ...@@ -160,13 +161,13 @@ void *test_thread(void *arg)
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum); _snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
#endif #endif
/* exec sql whenever sqlerror sqlprint ; */ /* exec sql whenever sqlerror sqlprint ; */
#line 113 "thread.pgc" #line 114 "thread.pgc"
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0); { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
#line 114 "thread.pgc" #line 115 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 114 "thread.pgc" #line 115 "thread.pgc"
if( sqlca.sqlcode != 0 ) if( sqlca.sqlcode != 0 )
{ {
...@@ -174,10 +175,10 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -174,10 +175,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
return NULL; return NULL;
} }
{ ECPGtrans(__LINE__, l_connection, "begin"); { ECPGtrans(__LINE__, l_connection, "begin");
#line 120 "thread.pgc" #line 121 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 120 "thread.pgc" #line 121 "thread.pgc"
/* insert into test_thread table */ /* insert into test_thread table */
...@@ -188,10 +189,10 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -188,10 +189,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int), ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 125 "thread.pgc" #line 126 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 125 "thread.pgc" #line 126 "thread.pgc"
if( sqlca.sqlcode != 0 ) if( sqlca.sqlcode != 0 )
printf("%s: ERROR: insert failed!\n", l_connection); printf("%s: ERROR: insert failed!\n", l_connection);
...@@ -199,16 +200,16 @@ if (sqlca.sqlcode < 0) sqlprint();} ...@@ -199,16 +200,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
/* all done */ /* all done */
{ ECPGtrans(__LINE__, l_connection, "commit"); { ECPGtrans(__LINE__, l_connection, "commit");
#line 131 "thread.pgc" #line 132 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 131 "thread.pgc" #line 132 "thread.pgc"
{ ECPGdisconnect(__LINE__, l_connection); { ECPGdisconnect(__LINE__, l_connection);
#line 132 "thread.pgc" #line 133 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();} if (sqlca.sqlcode < 0) sqlprint();}
#line 132 "thread.pgc" #line 133 "thread.pgc"
return NULL; return NULL;
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Thread test program * Thread test program
* by Lee Kindness. * by Lee Kindness.
*/ */
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "ecpg_config.h" #include "ecpg_config.h"
...@@ -53,7 +53,7 @@ int main() ...@@ -53,7 +53,7 @@ int main()
#else #else
HANDLE *threads; HANDLE *threads;
#endif #endif
int n; intptr_t n;
/* exec sql begin declare section */ /* exec sql begin declare section */
...@@ -97,7 +97,7 @@ int main() ...@@ -97,7 +97,7 @@ int main()
for( n = 0; n < nthreads; n++ ) for( n = 0; n < nthreads; n++ )
{ {
#ifndef WIN32 #ifndef WIN32
pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1)); pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
#else #else
threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_thread, (void *) (n+1), 0, NULL); threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_thread, (void *) (n+1), 0, NULL);
#endif #endif
...@@ -139,7 +139,7 @@ int main() ...@@ -139,7 +139,7 @@ int main()
void *test_thread(void *arg) void *test_thread(void *arg)
{ {
long threadnum = (long)arg; long threadnum = (intptr_t) arg;
/* exec sql begin declare section */ /* exec sql begin declare section */
......
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "ecpg_config.h" #include "ecpg_config.h"
...@@ -42,7 +43,7 @@ static void* fn(void* arg) ...@@ -42,7 +43,7 @@ static void* fn(void* arg)
char **r = NULL; char **r = NULL;
EXEC SQL END DECLARE SECTION; EXEC SQL END DECLARE SECTION;
value = (long)arg; value = (intptr_t) arg;
sprintf(name, "Connection: %d", value); sprintf(name, "Connection: %d", value);
EXEC SQL CONNECT TO REGRESSDB1 AS :name; EXEC SQL CONNECT TO REGRESSDB1 AS :name;
...@@ -60,7 +61,7 @@ static void* fn(void* arg) ...@@ -60,7 +61,7 @@ static void* fn(void* arg)
int main () int main ()
{ {
int i; intptr_t i;
#ifdef WIN32 #ifdef WIN32
HANDLE threads[THREADS]; HANDLE threads[THREADS];
#else #else
...@@ -79,7 +80,7 @@ int main () ...@@ -79,7 +80,7 @@ int main ()
CloseHandle(threads[i]); CloseHandle(threads[i]);
#else #else
for (i = 0; i < THREADS; ++i) 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) for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL); pthread_join(threads[i], NULL);
#endif #endif
......
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "ecpg_config.h" #include "ecpg_config.h"
...@@ -42,7 +43,7 @@ static void* fn(void* arg) ...@@ -42,7 +43,7 @@ static void* fn(void* arg)
char query[256] = "INSERT INTO T VALUES ( ? )"; char query[256] = "INSERT INTO T VALUES ( ? )";
EXEC SQL END DECLARE SECTION; EXEC SQL END DECLARE SECTION;
value = (long)arg; value = (intptr_t) arg;
sprintf(name, "Connection: %d", value); sprintf(name, "Connection: %d", value);
EXEC SQL CONNECT TO REGRESSDB1 AS :name; EXEC SQL CONNECT TO REGRESSDB1 AS :name;
...@@ -60,7 +61,7 @@ static void* fn(void* arg) ...@@ -60,7 +61,7 @@ static void* fn(void* arg)
int main () int main ()
{ {
int i; intptr_t i;
#ifdef WIN32 #ifdef WIN32
HANDLE threads[THREADS]; HANDLE threads[THREADS];
#else #else
...@@ -85,7 +86,7 @@ int main () ...@@ -85,7 +86,7 @@ int main ()
CloseHandle(threads[i]); CloseHandle(threads[i]);
#else #else
for (i = 0; i < THREADS; ++i) 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) for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL); pthread_join(threads[i], NULL);
#endif #endif
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Thread test program * Thread test program
* by Philip Yarra & Lee Kindness. * by Philip Yarra & Lee Kindness.
*/ */
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "ecpg_config.h" #include "ecpg_config.h"
...@@ -34,7 +35,7 @@ int main() ...@@ -34,7 +35,7 @@ int main()
#else #else
HANDLE *threads; HANDLE *threads;
#endif #endif
int n; intptr_t n;
EXEC SQL BEGIN DECLARE SECTION; EXEC SQL BEGIN DECLARE SECTION;
int l_rows; int l_rows;
EXEC SQL END DECLARE SECTION; EXEC SQL END DECLARE SECTION;
...@@ -65,7 +66,7 @@ int main() ...@@ -65,7 +66,7 @@ int main()
for( n = 0; n < nthreads; n++ ) for( n = 0; n < nthreads; n++ )
{ {
#ifndef WIN32 #ifndef WIN32
pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1)); pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
#else #else
threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_thread, (void *) (n + 1), 0, NULL); threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_thread, (void *) (n + 1), 0, NULL);
#endif #endif
...@@ -97,7 +98,7 @@ int main() ...@@ -97,7 +98,7 @@ int main()
void *test_thread(void *arg) void *test_thread(void *arg)
{ {
long threadnum = (long)arg; long threadnum = (intptr_t) arg;
EXEC SQL BEGIN DECLARE SECTION; EXEC SQL BEGIN DECLARE SECTION;
int l_i; int l_i;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Thread test program * Thread test program
* by Lee Kindness. * by Lee Kindness.
*/ */
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "ecpg_config.h" #include "ecpg_config.h"
...@@ -35,7 +35,7 @@ int main() ...@@ -35,7 +35,7 @@ int main()
#else #else
HANDLE *threads; HANDLE *threads;
#endif #endif
int n; intptr_t n;
EXEC SQL BEGIN DECLARE SECTION; EXEC SQL BEGIN DECLARE SECTION;
int l_rows; int l_rows;
EXEC SQL END DECLARE SECTION; EXEC SQL END DECLARE SECTION;
...@@ -66,7 +66,7 @@ int main() ...@@ -66,7 +66,7 @@ int main()
for( n = 0; n < nthreads; n++ ) for( n = 0; n < nthreads; n++ )
{ {
#ifndef WIN32 #ifndef WIN32
pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1)); pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
#else #else
threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_thread, (void *) (n+1), 0, NULL); threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_thread, (void *) (n+1), 0, NULL);
#endif #endif
...@@ -98,7 +98,7 @@ int main() ...@@ -98,7 +98,7 @@ int main()
void *test_thread(void *arg) void *test_thread(void *arg)
{ {
long threadnum = (long)arg; long threadnum = (intptr_t) arg;
EXEC SQL BEGIN DECLARE SECTION; EXEC SQL BEGIN DECLARE SECTION;
int l_i; int l_i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment