Support RHEL8 on PowerPC architecture #1700

Did a global replace of __linux with __linux__
This commit is contained in:
Alex Lin 2024-04-26 13:07:29 -05:00
parent e4f6774b3c
commit b9b9a46e37
34 changed files with 67 additions and 67 deletions

View File

@ -12,7 +12,7 @@ PROGRAMMERS:
#ifndef GETTIMEOFDAYCLOCK_HH
#define GETTIMEOFDAYCLOCK_HH
#ifdef __linux
#ifdef __linux__
#include <time.h>
#endif
@ -24,7 +24,7 @@ namespace Trick {
these values are available in the time module. Delete this
when everybody is using python 3.
*/
#ifdef __linux
#ifdef __linux__
enum ClockID {
TRICK_CLOCK_REALTIME = CLOCK_REALTIME ,
TRICK_CLOCK_MONOTONIC = CLOCK_MONOTONIC ,
@ -55,7 +55,7 @@ namespace Trick {
int get_clock_ID() ;
protected:
#ifdef __linux
#ifdef __linux__
clockid_t clk_id ; // trick_io(**)
#endif
} ;

View File

@ -11,7 +11,7 @@
#include <iostream>
#include <string>
#include <vector>
#if __linux
#if __linux__
#include <sys/types.h>
#endif
#include <unistd.h>

View File

@ -10,7 +10,7 @@
#include <pthread.h>
#include <iostream>
#include <string>
#if __linux
#if __linux__
#include <sys/types.h>
#endif
#include <unistd.h>
@ -70,7 +70,7 @@ namespace Trick {
*/
int cpu_clr(unsigned int cpu ) ;
#if __linux
#if __linux__
#ifndef SWIG
/**
* Gets the cpu set for this thread
@ -184,7 +184,7 @@ namespace Trick {
bool cancellable; /**< trick_io(**) */
pthread_mutex_t shutdown_mutex; /**< trick_io(**) */
#if __linux
#if __linux__
#ifndef SWIG
/** Set of cpus to use with thread */
cpu_set_t * cpus ; /**< trick_io(**) */

View File

@ -8,7 +8,7 @@
#include <queue>
#include <pthread.h>
#if __linux
#if __linux__
#include <sys/types.h>
#endif
#include <unistd.h>

View File

@ -9,7 +9,7 @@
#include <string>
#ifdef HAVE_ZEROCONF
#if __linux
#if __linux__
#include <avahi-client/client.h>
#include <avahi-client/publish.h>
#include <avahi-common/simple-watch.h>
@ -38,7 +38,7 @@ namespace Trick {
std::string name ;
std::string type ;
#ifdef HAVE_ZEROCONF
#if __linux
#if __linux__
AvahiSimplePoll *simple_poll ;
AvahiClient *client ;
AvahiEntryGroup *group ;

View File

@ -48,7 +48,7 @@ const char* trickTypeCharString( TRICK_TYPE type, const char* name);
#define TRICK_USER_DEFINED_TYPE TRICK_OPAQUE_TYPE
/* Define int_64t and uint_64t depending on compiler options */
#if __linux
#if __linux__
# include <stdint.h>
# include <sys/types.h>
# if __WORDSIZE == 64

View File

@ -19,7 +19,7 @@ PROGRAMMERS:
#include "trick/trick_error_hndlr.h"
#if (__linux)
#if (__linux__)
# define TC_NOSIGNAL MSG_NOSIGNAL
#else
# define TC_NOSIGNAL 0

View File

@ -37,7 +37,7 @@ This set of macros operates on vectors. Parameters to the macros are as follows:
#include <stdio.h>
#include <math.h>
#include <limits.h>
#if (__vxworks | __APPLE__ | __linux | __CYGWIN__)
#if (__vxworks | __APPLE__ | __linux__ | __CYGWIN__)
#include <float.h>
#endif

View File

@ -7,7 +7,7 @@
#include "test_struct.h"
#if (__linux)
#if (__linux__)
# define TC_NOSIGNAL MSG_NOSIGNAL
#else
# define TC_NOSIGNAL 0

View File

@ -36,7 +36,7 @@ void HeaderSearchDirs::AddCompilerBuiltInSearchDirs () {
// Add clang specific include directory first. Only required on linux systems. :(
// This is so that ICG will find clang friendly headers first. gcc headers cause
// all kinds of problems. On macs all headers are clang friendly.
#if __linux
#if __linux__
std::stringstream icg_dir ;
icg_dir << LLVM_HOME << "/lib/clang/" ;
icg_dir << LIBCLANG_MAJOR << "." << LIBCLANG_MINOR ;

View File

@ -1166,7 +1166,7 @@ int main()
*/
fprintf(stderr, "\nMore tests.\n");
#if ( __linux | __APPLE__ )
#if ( __linux__ | __APPLE__ )
// Infinity
strcpy(equation1,
"10000000000000000000000000000000000^1000000000000000000000000000000000000");

View File

@ -187,7 +187,7 @@ int Trick::CheckPointRestart::do_checkpoint(std::string file_name, bool print_st
if ( cpu_num != -1 ) {
// if the user specified a cpu number for the checkpoint, fork a process to write the checkpoint
if ((pid = fork()) == 0) {
#if __linux
#if __linux__
if ( cpu_num >= 0 ) {
unsigned long mask;
mask = 1 << cpu_num ;

View File

@ -23,7 +23,7 @@ PROGRAMMERS:
-# Calls the base Clock constructor
*/
Trick::GetTimeOfDayClock::GetTimeOfDayClock() : Clock(1000000, "GetTimeOfDay - CLOCK_REALTIME")
#if ( __linux )
#if ( __linux__ )
, clk_id(CLOCK_REALTIME)
#endif
{ }
@ -49,7 +49,7 @@ int Trick::GetTimeOfDayClock::clock_init() {
-# Return the current real time as a count of microseconds
*/
long long Trick::GetTimeOfDayClock::wall_clock_time() {
#if ( __linux )
#if ( __linux__ )
struct timespec tp ;
clock_gettime( clk_id, &tp ) ;
return (long long)tp.tv_sec * 1000000LL + (long long)((tp.tv_nsec) / 1000) ;
@ -69,7 +69,7 @@ int Trick::GetTimeOfDayClock::clock_stop() {
}
void Trick::GetTimeOfDayClock::set_clock_ID( int id ) {
#if ( __linux )
#if ( __linux__ )
clk_id = (clockid_t)id ;
switch ( clk_id ) {
case CLOCK_REALTIME: name = "GetTimeOfDay - CLOCK_REALTIME" ; break ;
@ -83,7 +83,7 @@ void Trick::GetTimeOfDayClock::set_clock_ID( int id ) {
}
int Trick::GetTimeOfDayClock::get_clock_ID() {
#if ( __linux )
#if ( __linux__ )
return clk_id ;
#else
message_publish(MSG_ERROR, "get_clock_ID not implemented\n");

View File

@ -191,7 +191,7 @@ int Trick::DRAscii::copy_data_ascii_item( Trick::DataRecordBuffer * DI, int item
break;
case TRICK_UNSIGNED_CHARACTER:
#if ( __linux | __sgi )
#if ( __linux__ | __sgi )
case TRICK_BOOLEAN:
#endif
snprintf(buf, writer_buf_spare, "%u", *((unsigned char *) address));

View File

@ -11,7 +11,7 @@
#include <unistd.h>
#include <signal.h>
#if __linux
#if __linux__
#include <sys/syscall.h>
#endif

View File

@ -2,7 +2,7 @@
#include <iostream>
#include <math.h>
#include <sys/stat.h>
#if __linux
#if __linux__
#include <sys/prctl.h>
#endif

View File

@ -16,7 +16,7 @@
/*
* FPE specific headers
*/
#ifdef __linux
#ifdef __linux__
#include <fenv.h>
#endif
@ -37,7 +37,7 @@
void Trick::Executive::fpe_handler(siginfo_t * sip __attribute__((unused)) ) {
write( 2 , "\033[31mProcess terminated by signal FPE" , 36 ) ;
#if __linux
#if __linux__
/* Determine what floating point error occurred */
if (sip != (siginfo_t *) NULL) {
switch (sip->si_code) {
@ -73,7 +73,7 @@ void Trick::Executive::fpe_handler(siginfo_t * sip __attribute__((unused)) ) {
Attempt to attach with debugger or print stack trace. Not a requirement.
snprintf and system are not async signal safe, but we don't have anything to lose.
*/
#if __linux
#if __linux__
char command[1024];
if (attach_debugger == true) {
snprintf(command, sizeof(command), "%s -silent /proc/%d/exe %d", debugger_command.c_str(), getpid(), getpid());

View File

@ -3,7 +3,7 @@
#include <errno.h>
/* Headers for floating point exceptions */
#ifdef __linux
#ifdef __linux__
#include <fenv.h>
#endif
@ -60,7 +60,7 @@ int Trick::Executive::set_trap_sigfpe(bool on_off) {
if ( on_off ) {
/* Assign fpe_sig_handler() as the signal handler for SIGFPE. */
#ifdef __linux
#ifdef __linux__
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW);
#endif
#if (__APPLE__ | __CYGWIN__ | __INTERIX )
@ -70,7 +70,7 @@ int Trick::Executive::set_trap_sigfpe(bool on_off) {
sigact.sa_sigaction = (void (*)(int, siginfo_t *, void *)) fpe_sig_handler;
#endif
} else {
#ifdef __linux
#ifdef __linux__
fedisableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW);
#endif
sigact.sa_handler = SIG_DFL;

View File

@ -60,7 +60,7 @@ void Trick::Executive::signal_handler(int sig) {
* sprintf and system are not async signal safe, but we don't have anything to lose.
*/
if ( ! debugger_command.empty() ) {
#if __linux
#if __linux__
char command[1024];
if (attach_debugger == true) {
snprintf(command, sizeof(command), "%s -silent /proc/%d/exe %d", debugger_command.c_str(), getpid(), getpid());

View File

@ -47,7 +47,7 @@ void Trick::ThreadTriggerFlag::dump(std::ostream & oss) {
oss << " trigger type = flag" << std::endl ;
}
#if __linux
#if __linux__
#include <sys/eventfd.h>
#include <sys/types.h>
#include <unistd.h>
@ -128,7 +128,7 @@ void Trick::ThreadTriggerContainer::setThreadTrigger( ThreadTriggerType in_trigg
ttBase = &ttFlag ;
break ;
case TT_EVENTFD :
#if __linux
#if __linux__
ttBase = &ttEventFD ;
#else
message_publish(MSG_ERROR, "EventFD thread trigger type not available, using mutex\n") ;
@ -136,7 +136,7 @@ void Trick::ThreadTriggerContainer::setThreadTrigger( ThreadTriggerType in_trigg
#endif
break ;
case TT_FUTEX :
#if __linux
#if __linux__
ttBase = &ttFutex ;
#else
message_publish(MSG_ERROR, "Futex thread trigger type not available, using mutex\n") ;

View File

@ -16,7 +16,7 @@
#include <signal.h>
#include <sys/syscall.h>
#ifdef __linux
#ifdef __linux__
#include <cxxabi.h>
#endif
@ -218,7 +218,7 @@ void * Trick::Threads::thread_body() {
" THREAD STOP TIME: %f\n" ,
thread_id, ex.file.c_str(), ex.message.c_str(), exec_get_sim_time()) ;
exit(ex.ret_code) ;
#ifdef __linux
#ifdef __linux__
// for post gcc 4.1.2
} catch (abi::__forced_unwind&) {
//pthread_exit and pthread_cancel will cause an abi::__forced_unwind to be thrown. Rethrow it.

View File

@ -11,7 +11,7 @@
/*
* FPE specific headers
*/
#ifdef __linux
#ifdef __linux__
#include <fenv.h>
#endif

View File

@ -90,7 +90,7 @@ int ref_to_value(REF2 * R, V_DATA * V)
break;
case TRICK_UNSIGNED_CHARACTER:
#if ( __linux | __sgi )
#if ( __linux__ | __sgi )
case TRICK_BOOLEAN:
#endif
ucp = (unsigned char *) address;

View File

@ -130,7 +130,7 @@ TEST_F(MM_declare_var, UINT32_T) {
validate_alloc_info_local(memmgr, test_var, TRICK_UNSIGNED_INTEGER, NULL, NULL, 1, 0, NULL);
}
#if __linux
#if __linux__
# include <stdint.h>
# include <sys/types.h>
# if __WORDSIZE == 64

View File

@ -93,7 +93,7 @@ extern "C" int real_time_set_rt_clock_ratio(double in_clock_ratio) {
// not required for syncing. Therefore keep the routines as stand
// alone C functions.
#if __linux
#if __linux__
#include <sys/mman.h>
#include <errno.h>
#endif
@ -101,7 +101,7 @@ extern "C" int real_time_set_rt_clock_ratio(double in_clock_ratio) {
extern "C" int real_time_lock_memory(int yes_no) {
/* lock or unlock memory based on yes_no parameter */
int ret = 0 ;
#if __linux
#if __linux__
if ( yes_no ) {
if ((ret = mlockall(MCL_CURRENT | MCL_FUTURE)) != 0 ) {
perror("Error locking memory.");

View File

@ -2,7 +2,7 @@
#include <iostream>
#include <sstream>
#include <stdio.h>
#if __linux
#if __linux__
#include <sys/syscall.h>
#include <sys/types.h>
#include <sched.h>

View File

@ -3,7 +3,7 @@
#include <signal.h>
#include <cstring>
#if __linux
#if __linux__
#include <sys/syscall.h>
#include <sys/types.h>
#include <sched.h>
@ -23,7 +23,7 @@ Trick::ThreadBase::ThreadBase(std::string in_name) :
cancellable(true)
{
pthread_mutex_init(&shutdown_mutex, NULL);
#if __linux
#if __linux__
max_cpu = sysconf( _SC_NPROCESSORS_ONLN ) ;
#ifdef CPU_ALLOC
cpus = CPU_ALLOC(max_cpu) ;
@ -38,7 +38,7 @@ Trick::ThreadBase::ThreadBase(std::string in_name) :
}
Trick::ThreadBase::~ThreadBase() {
#if __linux
#if __linux__
#ifdef CPU_FREE
CPU_FREE(cpus) ;
#endif
@ -62,7 +62,7 @@ pid_t Trick::ThreadBase::get_pid() {
}
void Trick::ThreadBase::set_pid() {
#if __linux
#if __linux__
pid = syscall( __NR_gettid ) ;
#else
pid = getpid() ;
@ -71,7 +71,7 @@ void Trick::ThreadBase::set_pid() {
int Trick::ThreadBase::cpu_set(unsigned int cpu __attribute__((unused))) {
int ret = 0 ;
#if __linux
#if __linux__
if ( cpu < max_cpu ) {
#ifdef CPU_SET_S
CPU_SET_S(cpu, CPU_ALLOC_SIZE(max_cpu), cpus) ;
@ -91,7 +91,7 @@ int Trick::ThreadBase::cpu_set(unsigned int cpu __attribute__((unused))) {
int Trick::ThreadBase::cpu_clr(unsigned int cpu __attribute__((unused))) {
int ret = 0 ;
#if __linux
#if __linux__
if ( cpu < max_cpu ) {
#ifdef CPU_CLR_S
CPU_CLR_S(cpu, CPU_ALLOC_SIZE(max_cpu), cpus) ;
@ -109,7 +109,7 @@ int Trick::ThreadBase::cpu_clr(unsigned int cpu __attribute__((unused))) {
return ret ;
}
#if __linux
#if __linux__
cpu_set_t * Trick::ThreadBase::get_cpus() {
return cpus ;
}
@ -133,7 +133,7 @@ void Trick::ThreadBase::copy_cpus(void * in_cpus __attribute__((unused))) {
#endif
int Trick::ThreadBase::execute_cpu_affinity() {
#if __linux
#if __linux__
#ifdef CPU_ALLOC_SIZE
sched_setaffinity(pid, CPU_ALLOC_SIZE(max_cpu), cpus) ;
#else
@ -148,7 +148,7 @@ int Trick::ThreadBase::set_priority(unsigned int req_priority) {
return 0 ;
}
#if __linux
#if __linux__
#include <sched.h>
#include <errno.h>
@ -290,7 +290,7 @@ int Trick::ThreadBase::create_thread() {
pthread_create(&pthread_id, &attr, Trick::ThreadBase::thread_helper , (void *)this);
created = true;
#if __linux
#if __linux__
#ifdef __GNUC__
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2
if ( ! name.empty() ) {
@ -380,7 +380,7 @@ void Trick::ThreadBase::dump( std::ostream & oss ) {
oss << " pthread_id = " << pthread_id << "\n";
oss << " process_id = " << pid << "\n";
oss << " rt_priority = " << rt_priority << "\n";
#if __linux
#if __linux__
oss << " cpus = " ;
bool first_print = true ;
for ( unsigned int ii = 0 ; ii < max_cpu ; ii++ ) {

View File

@ -1,6 +1,6 @@
#include <iostream>
#ifdef __linux
#ifdef __linux__
#include <cxxabi.h>
#endif
@ -104,7 +104,7 @@ void * Trick::VariableServerSessionThread::thread_body() {
exec_signal_terminate();
#ifdef __linux
#ifdef __linux__
#ifdef __GNUC__
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2
// for post gcc 4.1.2 or whatever glibc version is used in RHEL6 and above.
@ -115,7 +115,7 @@ void * Trick::VariableServerSessionThread::thread_body() {
#endif
#endif
} catch (...) {
#ifdef __linux
#ifdef __linux__
#ifdef __GNUC__
#if (__GNUC__ == 4 && __GNUC_MINOR__ == 1) || __GNUC__ == 12
// for gcc 4.1.2 or whatever glib version in RHEL 5 that does not work with the abi::__forced_unwind

View File

@ -292,7 +292,7 @@ int var_set_client_tag( std::string text ) {
vst->set_client_tag(text);
#if __linux
#if __linux__
#ifdef __GNUC__
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2
std::string short_str = std::string("VS_") + text.substr(0,12) ;

View File

@ -2,7 +2,7 @@
#include <stdio.h>
#ifdef HAVE_ZEROCONF
#if __linux
#if __linux__
#include <avahi-client/client.h>
#include <avahi-client/publish.h>
#include <avahi-common/simple-watch.h>
@ -23,7 +23,7 @@ Trick::Zeroconf::Zeroconf() {
type = std::string("_trick-vs._tcp") ;
#ifdef HAVE_ZEROCONF
#if __linux
#if __linux__
simple_poll = NULL ;
client = NULL ;
group = NULL ;
@ -33,7 +33,7 @@ Trick::Zeroconf::Zeroconf() {
}
#ifdef HAVE_ZEROCONF
#if __linux
#if __linux__
extern "C" void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) ;
extern "C" {
@ -67,7 +67,7 @@ void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, void *
int Trick::Zeroconf::init() {
#ifdef HAVE_ZEROCONF
#if __linux
#if __linux__
int error;
int ret ;
char r[128] ;

View File

@ -3,7 +3,7 @@
* Get system clock reference time
*/
#if __linux
#if __linux__
#include <time.h>
#else
#include <sys/time.h>
@ -17,7 +17,7 @@ double tc_clock_init(void)
#if __WIN32__
ref_time = GetTickCount();
#elif __linux
#elif __linux__
struct timespec tp;
/* Get absolute time from system */

View File

@ -3,7 +3,7 @@
* Get elapsed time since last call to tc_clock_init()
*/
#ifdef __linux
#ifdef __linux__
#include <time.h>
#else
#include <sys/time.h>
@ -17,7 +17,7 @@ double tc_clock_time(double ref_time)
#if __WIN32__
y_secs = GetTickCount();
#elif __linux
#elif __linux__
struct timespec tp;
/* Get absolute time from system */

View File

@ -27,7 +27,7 @@ double drandom_gaussian( /* Return: Random number consistent with Gaussia
/* Call rand() 2*range times to get plus/minus range sigma output */
/* Normalize output of rand to the range of [-0.5,0.5] */
#ifdef __linux
#ifdef __linux__
out = (((double) rand()) / RAND_MAX) - 0.5;
#elif __APPLE__
out = (((double) rand()) / LONG_MAX) - 0.5;

View File

@ -22,7 +22,7 @@
#include "trick/wave_form.h"
#include "trick/trick_math.h"
#if ( __sun || __linux || __APPLE__ || __CYGWIN__ || __Lynx__ || __QNX__ || __ghs || __INTERIX )
#if ( __sun || __linux__ || __APPLE__ || __CYGWIN__ || __Lynx__ || __QNX__ || __ghs || __INTERIX )
#define gettimeofday(T) gettimeofday(T,NULL)
#endif