summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2021-07-17 08:47:14 +0200
committerGitHub <noreply@github.com>2021-07-17 08:47:14 +0200
commit335e4a12ade8196a5e0bc8b7efa9d9f038f5883a (patch)
treed7768b9cb834c92eb2984c8178fe7853c239d195
parentccbd4637729195fc838ed322bf8629d7c53c9f3c (diff)
parent2fa3cc5530ce41128f7821a674beffc19a5b165d (diff)
downloadATCD-335e4a12ade8196a5e0bc8b7efa9d9f038f5883a.tar.gz
Merge pull request #1616 from jwillemsen/jwi-2980test
Make use of std::printf with all compilers
-rw-r--r--ACE/tests/Bug_2980_Regression_Test.cpp54
1 files changed, 21 insertions, 33 deletions
diff --git a/ACE/tests/Bug_2980_Regression_Test.cpp b/ACE/tests/Bug_2980_Regression_Test.cpp
index 1b4383d61ce..002cf03b53c 100644
--- a/ACE/tests/Bug_2980_Regression_Test.cpp
+++ b/ACE/tests/Bug_2980_Regression_Test.cpp
@@ -4,7 +4,7 @@
#include <iostream>
#include <assert.h>
-#include <stdio.h>
+#include <cstdio>
#include <string.h>
#include <stdlib.h>
#include <string.h>
@@ -14,7 +14,6 @@
// platform-specific ones.
//
// This test has not been made to work on Windows and vxWorks, yet ...
-
#if defined (ACE_HAS_THREADS)
# define CAN_USE_THREADS
#else
@@ -43,16 +42,8 @@ namespace {
# undef CAN_RUN_TEST
#endif
-#if defined (__BORLANDC__)
-# define PRINTF std::printf
-#else
-# define PRINTF printf
-#endif
-
-
using voidfunction = int (*)();
-
#if defined (CAN_RUN_TEST)
static void * dllHandle;
static voidfunction capi_init = 0;
@@ -60,13 +51,11 @@ static voidfunction capi_fini = 0;
static voidfunction capi_dosomething = 0;
#endif /* defined (CAN_RUN_TEST) */
-
extern "C"
void* loadDll(void*)
{
#if defined (CAN_RUN_TEST)
-
- PRINTF ("loadDll - entered\n");
+ std::printf ("loadDll - entered\n");
const char *subdir_env = getenv ("ACE_EXE_SUB_DIR");
if (subdir_env)
{
@@ -85,7 +74,7 @@ void* loadDll(void*)
if (dllHandle == 0)
{
- PRINTF ("unable to load library: %s\n", dlerror());
+ std::printf ("unable to load library: %s\n", dlerror());
assert(dllHandle != 0);
}
@@ -93,7 +82,7 @@ void* loadDll(void*)
memcpy (&capi_init, &temp, sizeof (temp));
if (capi_init == 0)
{
- PRINTF ("unable to resolve symbol capi_init: %s\n", dlerror());
+ std::printf ("unable to resolve symbol capi_init: %s\n", dlerror());
assert(capi_init != 0);
}
@@ -101,7 +90,7 @@ void* loadDll(void*)
memcpy (&capi_fini, &temp, sizeof (temp));
if (capi_fini == 0)
{
- PRINTF ("unable to resolve symbol capi_fini: %s\n", dlerror());
+ std::printf ("unable to resolve symbol capi_fini: %s\n", dlerror());
assert(capi_fini != 0);
}
@@ -109,11 +98,11 @@ void* loadDll(void*)
memcpy (&capi_dosomething, &temp, sizeof (temp));
if (capi_dosomething == 0)
{
- PRINTF ("unable to resolve symbol capi_dosomething: %s\n", dlerror());
+ std::printf ("unable to resolve symbol capi_dosomething: %s\n", dlerror());
assert(capi_dosomething != 0);
}
capi_init();
- PRINTF ("loadDll - leaving\n");
+ std::printf ("loadDll - leaving\n");
#endif /* defined (CAN_RUN_TEST) */
return 0;
}
@@ -122,10 +111,10 @@ extern "C"
void* unloadDll(void*)
{
#if defined (CAN_RUN_TEST)
- PRINTF ("unloadDll - entered\n");
+ std::printf ("unloadDll - entered\n");
capi_fini();
dlclose(dllHandle);
- PRINTF ("unloadDll - leaving\n");
+ std::printf ("unloadDll - leaving\n");
#endif /* defined (CAN_RUN_TEST) */
return 0;
}
@@ -148,12 +137,12 @@ int main (int, char *[])
{
#if !defined (CAN_RUN_TEST)
# ifndef ACE_FACE_SAFETY_EXTENDED
- PRINTF ("Terminating because this test has not been designed "
+ std::printf ("Terminating because this test has not been designed "
"to run on WIN32 or VXWORKS.\n");
# endif
#else
- PRINTF ("main called\n");
- PRINTF ("main - calling loadDll\n");
+ std::printf ("main called\n");
+ std::printf ("main - calling loadDll\n");
# if defined (CAN_USE_THREADS)
int result = 0;
@@ -161,44 +150,43 @@ int main (int, char *[])
result = pthread_create(&tid1, 0, &loadDll, 0);
if (result != 0)
{
- PRINTF ("pthread_create() failed: %d\n", result);
+ std::printf ("pthread_create() failed: %d\n", result);
return result;
}
pthread_join(tid1, 0);
- PRINTF ("loadDll thread finished and re-joined\n");
+ std::printf ("loadDll thread finished and re-joined\n");
# else
loadDll(0);
- PRINTF ("loadDll finished\n");
+ std::printf ("loadDll finished\n");
# endif /* defined (CAN_USE_THREADS) */
- PRINTF ("main - calling unloadDll\n");
+ std::printf ("main - calling unloadDll\n");
# if defined (CAN_USE_THREADS)
pthread_t tid2;
result = pthread_create(&tid2, 0, &unloadDll, 0);
if (result != 0)
{
- PRINTF ("pthread_create() failed: %d\n", result);
+ std::printf ("pthread_create() failed: %d\n", result);
return 1;
}
pthread_join(tid2, 0);
- PRINTF ("unloadDll thread finished and re-joined\n");
+ std::printf ("unloadDll thread finished and re-joined\n");
# else
unloadDll(0);
- PRINTF ("unloadDll finished\n");
+ std::printf ("unloadDll finished\n");
# endif /* defined (CAN_USE_THREADS) */
- PRINTF ("main finished\n");
+ std::printf ("main finished\n");
#endif /* defined (CAN_RUN_TEST) */
return 0;
-
}
- //FUZZ: enable check_for_lack_ACE_OS
+//FUZZ: enable check_for_lack_ACE_OS