Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5a0d31d

Browse files
author
Michael Meskes
committed
Made new test also work without threading enabled.
1 parent b5efdba commit 5a0d31d

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/interfaces/ecpg/test/expected/thread-descriptor.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
99

1010
#line 1 "descriptor.pgc"
11+
#ifdef ENABLE_THREAD_SAFETY
1112
#ifdef WIN32
1213
#define WIN32_LEAN_AND_MEAN
1314
#include <windows.h>
1415
#include <process.h>
1516
#else
1617
#include <pthread.h>
1718
#endif
19+
#endif
1820
#include <stdio.h>
1921

2022
#define THREADS 16
@@ -89,36 +91,36 @@ struct sqlca_t *ECPGget_sqlca(void);
8991

9092
#endif
9193

92-
#line 13 "descriptor.pgc"
94+
#line 15 "descriptor.pgc"
9395

9496
/* exec sql whenever sqlerror sqlprint ; */
95-
#line 14 "descriptor.pgc"
97+
#line 16 "descriptor.pgc"
9698

9799
/* exec sql whenever not found sqlprint ; */
98-
#line 15 "descriptor.pgc"
100+
#line 17 "descriptor.pgc"
99101

100102

101103
#ifdef WIN32
102104
static unsigned STDCALL fn(void* arg)
103105
#else
104-
void* fn(void* arg)
106+
static void* fn(void* arg)
105107
#endif
106108
{
107109
int i;
108110

109111
for (i = 1; i <= REPEATS; ++i)
110112
{
111113
ECPGallocate_desc(__LINE__, "mydesc");
112-
#line 27 "descriptor.pgc"
114+
#line 29 "descriptor.pgc"
113115

114116
if (sqlca.sqlcode < 0) sqlprint();
115-
#line 27 "descriptor.pgc"
117+
#line 29 "descriptor.pgc"
116118

117119
ECPGdeallocate_desc(__LINE__, "mydesc");
118-
#line 28 "descriptor.pgc"
120+
#line 30 "descriptor.pgc"
119121

120122
if (sqlca.sqlcode < 0) sqlprint();
121-
#line 28 "descriptor.pgc"
123+
#line 30 "descriptor.pgc"
122124

123125
}
124126

@@ -127,6 +129,7 @@ if (sqlca.sqlcode < 0) sqlprint();
127129

128130
int main (int argc, char** argv)
129131
{
132+
#ifdef ENABLE_THREAD_SAFETY
130133
int i;
131134
#ifdef WIN32
132135
HANDLE threads[THREADS];
@@ -150,6 +153,9 @@ int main (int argc, char** argv)
150153
for (i = 0; i < THREADS; ++i)
151154
pthread_join(threads[i], NULL);
152155
#endif
156+
#else
157+
fn(NULL);
158+
#endif
153159

154160
return 0;
155161
}

src/interfaces/ecpg/test/thread/descriptor.pgc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
#ifdef ENABLE_THREAD_SAFETY
12
#ifdef WIN32
23
#define WIN32_LEAN_AND_MEAN
34
#include <windows.h>
45
#include <process.h>
56
#else
67
#include <pthread.h>
78
#endif
9+
#endif
810
#include <stdio.h>
911

1012
#define THREADS 16
@@ -17,7 +19,7 @@ EXEC SQL whenever not found sqlprint;
1719
#ifdef WIN32
1820
static unsigned STDCALL fn(void* arg)
1921
#else
20-
void* fn(void* arg)
22+
static void* fn(void* arg)
2123
#endif
2224
{
2325
int i;
@@ -33,6 +35,7 @@ void* fn(void* arg)
3335

3436
int main (int argc, char** argv)
3537
{
38+
#ifdef ENABLE_THREAD_SAFETY
3639
int i;
3740
#ifdef WIN32
3841
HANDLE threads[THREADS];
@@ -56,6 +59,9 @@ int main (int argc, char** argv)
5659
for (i = 0; i < THREADS; ++i)
5760
pthread_join(threads[i], NULL);
5861
#endif
62+
#else
63+
fn(NULL);
64+
#endif
5965

6066
return 0;
6167
}

0 commit comments

Comments
 (0)