Made new test also work without threading enabled.

This commit is contained in:
Michael Meskes 2007-10-02 14:01:57 +00:00
parent b5efdbac5c
commit 5a0d31d3dc
2 changed files with 21 additions and 9 deletions

View File

@ -8,6 +8,7 @@
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "descriptor.pgc"
#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -15,6 +16,7 @@
#else
#include <pthread.h>
#endif
#endif
#include <stdio.h>
#define THREADS 16
@ -89,19 +91,19 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif
#line 13 "descriptor.pgc"
#line 15 "descriptor.pgc"
/* exec sql whenever sqlerror sqlprint ; */
#line 14 "descriptor.pgc"
#line 16 "descriptor.pgc"
/* exec sql whenever not found sqlprint ; */
#line 15 "descriptor.pgc"
#line 17 "descriptor.pgc"
#ifdef WIN32
static unsigned STDCALL fn(void* arg)
#else
void* fn(void* arg)
static void* fn(void* arg)
#endif
{
int i;
@ -109,16 +111,16 @@ void* fn(void* arg)
for (i = 1; i <= REPEATS; ++i)
{
ECPGallocate_desc(__LINE__, "mydesc");
#line 27 "descriptor.pgc"
#line 29 "descriptor.pgc"
if (sqlca.sqlcode < 0) sqlprint();
#line 27 "descriptor.pgc"
#line 29 "descriptor.pgc"
ECPGdeallocate_desc(__LINE__, "mydesc");
#line 28 "descriptor.pgc"
#line 30 "descriptor.pgc"
if (sqlca.sqlcode < 0) sqlprint();
#line 28 "descriptor.pgc"
#line 30 "descriptor.pgc"
}
@ -127,6 +129,7 @@ if (sqlca.sqlcode < 0) sqlprint();
int main (int argc, char** argv)
{
#ifdef ENABLE_THREAD_SAFETY
int i;
#ifdef WIN32
HANDLE threads[THREADS];
@ -150,6 +153,9 @@ int main (int argc, char** argv)
for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL);
#endif
#else
fn(NULL);
#endif
return 0;
}

View File

@ -1,3 +1,4 @@
#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -5,6 +6,7 @@
#else
#include <pthread.h>
#endif
#endif
#include <stdio.h>
#define THREADS 16
@ -17,7 +19,7 @@ EXEC SQL whenever not found sqlprint;
#ifdef WIN32
static unsigned STDCALL fn(void* arg)
#else
void* fn(void* arg)
static void* fn(void* arg)
#endif
{
int i;
@ -33,6 +35,7 @@ void* fn(void* arg)
int main (int argc, char** argv)
{
#ifdef ENABLE_THREAD_SAFETY
int i;
#ifdef WIN32
HANDLE threads[THREADS];
@ -56,6 +59,9 @@ int main (int argc, char** argv)
for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL);
#endif
#else
fn(NULL);
#endif
return 0;
}