Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/source-pcap-file-directory-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ TmEcode PcapDirectoryPopulateBuffer(PcapFileDirectoryVars *pv,
PendingFile *file_to_add = NULL;

while ((dir = readdir(pv->directory)) != NULL) {
#ifndef OS_WIN32
#if defined(DT_REG)
if (dir->d_type != DT_REG) {
continue;
}
Expand Down
4 changes: 3 additions & 1 deletion src/suricata.c
Original file line number Diff line number Diff line change
Expand Up @@ -3089,6 +3089,8 @@ int InitGlobal(void)

void SuricataPreInit(const char *progname)
{
UtilCpuEnableSparcMisalignEmulation();

SCInstanceInit(&suricata, progname);

if (InitGlobal() != 0) {
Expand Down Expand Up @@ -3223,7 +3225,7 @@ void SuricataPostInit(void)
#endif

if (limit_nproc) {
#if defined(HAVE_SYS_RESOURCE_H)
#if defined(HAVE_SYS_RESOURCE_H) && defined(RLIMIT_NPROC)
#ifdef linux
if (geteuid() == 0) {
SCLogWarning("setrlimit has no effect when running as root.");
Expand Down
6 changes: 2 additions & 4 deletions src/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ enum {
unsigned long _scgetthread_tid = (unsigned long)tpid; \
_scgetthread_tid; \
})
#elif defined(sun)
#elif defined(__sun)
#include <thread.h>
#define SCGetThreadIdLong(...) ({ \
thread_t tmpthid = thr_self(); \
Expand Down Expand Up @@ -302,9 +302,7 @@ extern thread_local char t_thread_name[THREAD_NAME_LEN + 1];
SCLogDebug("Error setting thread name \"%s\": %s", tname, strerror(errno)); \
})
#else
#define SCSetThreadName(n) ({ \
strlcpy(t_thread_name, n, sizeof(t_thread_name)); \
}
#define SCSetThreadName(n) ({ strlcpy(t_thread_name, n, sizeof(t_thread_name)); })
#endif


Expand Down
6 changes: 3 additions & 3 deletions src/tm-threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ void TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, const void *data)
}
}

#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
static int SetCPUAffinitySet(cpu_set_t *cs)
{
#if defined OS_FREEBSD
Expand Down Expand Up @@ -735,7 +735,7 @@ static int SetCPUAffinitySet(cpu_set_t *cs)
*/
static int SetCPUAffinity(uint16_t cpuid)
{
#if defined __OpenBSD__ || defined sun
#if defined __OpenBSD__ || defined __sun
return 0;
#else
int cpu = (int)cpuid;
Expand Down Expand Up @@ -871,7 +871,7 @@ TmEcode TmThreadSetupOptions(ThreadVars *tv)
SetCPUAffinity(tv->cpu_affinity);
}

#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
if (tv->thread_setup_flags & THREAD_SET_PRIORITY)
TmThreadSetPrio(tv);
if (tv->thread_setup_flags & THREAD_SET_AFFTYPE) {
Expand Down
12 changes: 6 additions & 6 deletions src/util-affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ThreadsAffinityType thread_affinity[MAX_CPU_SET] = {

int thread_affinity_init_done = 0;

#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
#ifdef HAVE_HWLOC
static hwloc_topology_t topology = NULL;
#endif /* HAVE_HWLOC */
Expand Down Expand Up @@ -206,7 +206,7 @@ ThreadsAffinityType *GetOrAllocAffinityTypeForIfaceOfName(
return parent_affinity;
}

#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
static void AffinitySetupInit(void)
{
int i, j;
Expand Down Expand Up @@ -587,7 +587,7 @@ static bool AffinityConfigIsLegacy(void)
*/
void AffinitySetupLoadFromConfig(void)
{
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
if (thread_affinity_init_done == 0) {
AffinitySetupInit();
AffinityConfigIsLegacy();
Expand Down Expand Up @@ -643,7 +643,7 @@ void AffinitySetupLoadFromConfig(void)
#endif /* OS_WIN32 and __OpenBSD__ */
}

#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
#ifdef HAVE_HWLOC
static int HwLocDeviceNumaGet(hwloc_topology_t topo, hwloc_obj_t obj)
{
Expand Down Expand Up @@ -1006,7 +1006,7 @@ static bool AutopinEnabled(void)
uint16_t AffinityGetNextCPU(ThreadVars *tv, ThreadsAffinityType *taf)
{
uint16_t ncpu = 0;
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
int iface_numa = -1;
if (AutopinEnabled()) {
#ifdef HAVE_HWLOC
Expand Down Expand Up @@ -1043,7 +1043,7 @@ uint16_t AffinityGetNextCPU(ThreadVars *tv, ThreadsAffinityType *taf)
uint16_t UtilAffinityGetAffinedCPUNum(ThreadsAffinityType *taf)
{
uint16_t ncpu = 0;
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
SCMutexLock(&taf->taf_mutex);
for (int i = UtilCpuGetNumProcessorsOnline(); i >= 0; i--)
if (CPU_ISSET(i, &taf->cpu_set)) {
Expand Down
2 changes: 1 addition & 1 deletion src/util-affinity.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ typedef struct ThreadsAffinityType_ {
struct ThreadsAffinityType_ *parent; // e.g. worker-cpu-set for interfaces
SCMutex taf_mutex;

#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
cpu_set_t cpu_set;
cpu_set_t lowprio_cpu;
cpu_set_t medprio_cpu;
Expand Down
7 changes: 6 additions & 1 deletion src/util-byte.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@
#define SCByteSwap16(x) OSSwapInt16(x)
#define SCByteSwap32(x) OSSwapInt32(x)
#define SCByteSwap64(x) OSSwapInt64(x)
#elif defined(__WIN32) || defined(_WIN32) || defined(sun)
#elif defined(__sun)
#include <sys/byteorder.h>
#define SCByteSwap16(x) BSWAP_16(x)
#define SCByteSwap32(x) BSWAP_32(x)
#define SCByteSwap64(x) BSWAP_64(x)
#elif defined(__WIN32) || defined(_WIN32)
/* Quick & dirty solution, nothing seems to exist for this in Win32 API */
#define SCByteSwap16(x) \
((((x) & 0xff00) >> 8) \
Expand Down
13 changes: 13 additions & 0 deletions src/util-cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,16 @@ uint64_t UtilCpuGetTicks(void)
#endif
return val;
}

/**
* \brief Handle memory access miss align on SPARC processors
*/
void UtilCpuEnableSparcMisalignEmulation(void)
{
/* 'ta 6' tells the kernel to synthesize any unaligned accesses this process
* makes, instead of just signalling an error and terminating the process.
*/
#ifdef __sparc
__asm("ta 6");
#endif /* __sparc */
}
2 changes: 2 additions & 0 deletions src/util-cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ void UtilCpuPrintSummary(void);

uint64_t UtilCpuGetTicks(void);

void UtilCpuEnableSparcMisalignEmulation(void);

#endif /* SURICATA_UTIL_CPU_H */
4 changes: 2 additions & 2 deletions src/util-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bool SCPathExists(const char *path)
*/
bool SCIsRegularDirectory(const struct dirent *const dir_entry)
{
#ifndef OS_WIN32
#if !defined(OS_WIN32) && !defined(__sun)
if ((dir_entry->d_type == DT_DIR) &&
(strcmp(dir_entry->d_name, ".") != 0) &&
(strcmp(dir_entry->d_name, "..") != 0)) {
Expand All @@ -214,7 +214,7 @@ bool SCIsRegularDirectory(const struct dirent *const dir_entry)
*/
bool SCIsRegularFile(const struct dirent *const dir_entry)
{
#ifndef OS_WIN32
#if defined(DT_REG)
return dir_entry->d_type == DT_REG;
#endif
return false;
Expand Down
4 changes: 4 additions & 0 deletions src/util-syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
#include "util-syslog.h"

/* holds the string-enum mapping for the syslog facility in SCLogOPIfaceCtx */
// clang-format off
SCEnumCharMap sc_syslog_facility_map[] = {
{ "auth", LOG_AUTH },
{ "authpriv", LOG_AUTHPRIV },
{ "cron", LOG_CRON },
{ "daemon", LOG_DAEMON },
#if defined(LOG_FTP)
{ "ftp", LOG_FTP },
#endif
{ "kern", LOG_KERN },
{ "lpr", LOG_LPR },
{ "mail", LOG_MAIL },
Expand All @@ -52,6 +55,7 @@ SCEnumCharMap sc_syslog_facility_map[] = {
{ "local7", LOG_LOCAL7 },
{ NULL, -1 }
};
// clang-format on

/** \brief returns the syslog facility enum map */
SCEnumCharMap *SCSyslogGetFacilityMap(void)
Expand Down
4 changes: 2 additions & 2 deletions src/util-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ time_t SCMkTimeUtc (struct tm *tp)
result += tp->tm_min;
result *= 60;
result += tp->tm_sec;
#ifndef OS_WIN32
#if !defined(OS_WIN32) && !defined(__sun)
if (tp->tm_gmtoff)
result -= tp->tm_gmtoff;
#endif
Expand Down Expand Up @@ -497,7 +497,7 @@ int SCStringPatternToTime (char *string, const char **patterns, int num_patterns
tp->tm_hour = tp->tm_min = tp->tm_sec = 0;
tp->tm_year = tp->tm_mon = tp->tm_mday = tp->tm_wday = INT_MIN;
tp->tm_isdst = -1;
#ifndef OS_WIN32
#if !defined(OS_WIN32) && !defined(__sun)
tp->tm_gmtoff = 0;
tp->tm_zone = NULL;
#endif
Expand Down
Loading