Skip to content

Commit

Permalink
Replace WIN32 with _WIN32. The latest is defined by the compiler and …
Browse files Browse the repository at this point in the history
…doesn't need to be defined externally.
  • Loading branch information
plusvic committed Aug 20, 2014
1 parent e6db404 commit 3b5ddd0
Show file tree
Hide file tree
Showing 23 changed files with 66 additions and 68 deletions.
2 changes: 1 addition & 1 deletion libyara/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ int yr_compiler_get_rules(
yara_rules->code_start = rules_file_header->code_start;
yara_rules->tidx_mask = 0;

#if WIN32
#if _WIN32
yara_rules->mutex = CreateMutex(NULL, FALSE, NULL);
#else
pthread_mutex_init(&yara_rules->mutex, NULL);
Expand Down
2 changes: 1 addition & 1 deletion libyara/exefiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

#include <limits.h>

#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <yara/pe.h>
Expand Down
4 changes: 2 additions & 2 deletions libyara/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

#include <fcntl.h>

#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/stat.h>
Expand All @@ -28,7 +28,7 @@ limitations under the License.
#include <yara/error.h>


#ifdef WIN32
#ifdef _WIN32

//
// Win32 implementation
Expand Down
8 changes: 4 additions & 4 deletions libyara/hex_lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ limitations under the License.

#include "hex_grammar.h"

#ifdef WIN32
#ifdef _WIN32
#define snprintf _snprintf
#endif

Expand Down Expand Up @@ -2083,7 +2083,7 @@ void hex_yyfree (void * ptr , yyscan_t yyscanner)



#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
extern DWORD recovery_state_key;
#else
Expand All @@ -2098,7 +2098,7 @@ void yyfatal(
{
jmp_buf* recovery_state;

#ifdef WIN32
#ifdef _WIN32
recovery_state = TlsGetValue(recovery_state_key) ;
#else
recovery_state = pthread_getspecific(recovery_state_key);
Expand Down Expand Up @@ -2142,7 +2142,7 @@ int yr_parse_hex_string(
lex_env.last_error_code = ERROR_SUCCESS;
lex_env.inside_or = 0;

#ifdef WIN32
#ifdef _WIN32
TlsSetValue(recovery_state_key, (LPVOID) &recovery_state);
#else
pthread_setspecific(recovery_state_key, (void*) &recovery_state);
Expand Down
2 changes: 1 addition & 1 deletion libyara/include/yara/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ limitations under the License.
#include <yara/limits.h>
#include <yara/hash.h>

#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
typedef HANDLE mutex_t;
#else
Expand Down
2 changes: 1 addition & 1 deletion libyara/include/yara/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ limitations under the License.

#define PTR_TO_UINT64(x) ((uint64_t) (size_t) x)

#ifdef WIN32
#ifdef _WIN32
#define snprintf _snprintf
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
Expand Down
4 changes: 2 additions & 2 deletions libyara/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ limitations under the License.
} \
}

#ifdef WIN32
#ifdef _WIN32
#define snprintf _snprintf
#endif

Expand Down Expand Up @@ -1288,7 +1288,7 @@ YY_RULE_SETUP
// make included file path relative to current source file
s = strrchr(buffer, '/');

#ifdef WIN32
#ifdef _WIN32
b = strrchr(buffer, '\\'); // in Windows both path delimiters are accepted
#endif

Expand Down
12 changes: 6 additions & 6 deletions libyara/libyara.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ limitations under the License.
#include <yara/re.h>


#ifdef WIN32
#ifdef _WIN32
#define snprintf _snprintf
#endif


#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
DWORD tidx_key;
DWORD recovery_state_key;
Expand Down Expand Up @@ -66,7 +66,7 @@ void yr_initialize(void)

yr_heap_alloc();

#ifdef WIN32
#ifdef _WIN32
tidx_key = TlsAlloc();
recovery_state_key = TlsAlloc();
#else
Expand Down Expand Up @@ -102,7 +102,7 @@ void yr_finalize(void)
{
yr_re_finalize_thread();

#ifdef WIN32
#ifdef _WIN32
TlsFree(tidx_key);
TlsFree(recovery_state_key);
#else
Expand All @@ -128,7 +128,7 @@ void yr_finalize(void)

void yr_set_tidx(int tidx)
{
#ifdef WIN32
#ifdef _WIN32
TlsSetValue(tidx_key, (LPVOID) (tidx + 1));
#else
pthread_setspecific(tidx_key, (void*) (size_t) (tidx + 1));
Expand All @@ -148,7 +148,7 @@ void yr_set_tidx(int tidx)

int yr_get_tidx(void)
{
#ifdef WIN32
#ifdef _WIN32
return (int) TlsGetValue(tidx_key) - 1;
#else
return (int) (size_t) pthread_getspecific(tidx_key) - 1;
Expand Down
2 changes: 1 addition & 1 deletion libyara/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifdef WIN32
#ifdef _WIN32

#include <windows.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion libyara/modules/pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <yara/pe.h>
Expand Down
2 changes: 1 addition & 1 deletion libyara/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifdef WIN32
#ifdef _WIN32

#include <windows.h>

Expand Down
16 changes: 8 additions & 8 deletions libyara/re.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ order to avoid confusion with operating system threads.
#include <string.h>
#include <limits.h>

#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <pthread.h>
Expand Down Expand Up @@ -86,7 +86,7 @@ typedef struct _RE_THREAD_STORAGE
} RE_THREAD_STORAGE;


#ifdef WIN32
#ifdef _WIN32
DWORD thread_storage_key;
#else
pthread_key_t thread_storage_key;
Expand All @@ -101,7 +101,7 @@ pthread_key_t thread_storage_key;

int yr_re_initialize(void)
{
#ifdef WIN32
#ifdef _WIN32
thread_storage_key = TlsAlloc();
#else
pthread_key_create(&thread_storage_key, NULL);
Expand All @@ -119,7 +119,7 @@ int yr_re_initialize(void)

int yr_re_finalize(void)
{
#ifdef WIN32
#ifdef _WIN32
TlsFree(thread_storage_key);
#else
pthread_key_delete(thread_storage_key);
Expand All @@ -141,7 +141,7 @@ int yr_re_finalize_thread(void)
RE_FIBER* next_fiber;
RE_THREAD_STORAGE* storage;

#ifdef WIN32
#ifdef _WIN32
storage = TlsGetValue(thread_storage_key);
#else
storage = pthread_getspecific(thread_storage_key);
Expand All @@ -161,7 +161,7 @@ int yr_re_finalize_thread(void)
yr_free(storage);
}

#ifdef WIN32
#ifdef _WIN32
TlsSetValue(thread_storage_key, NULL);
#else
pthread_setspecific(thread_storage_key, NULL);
Expand Down Expand Up @@ -1104,7 +1104,7 @@ int yr_re_emit_code(
int _yr_re_alloc_storage(
RE_THREAD_STORAGE** storage)
{
#ifdef WIN32
#ifdef _WIN32
*storage = TlsGetValue(thread_storage_key);
#else
*storage = pthread_getspecific(thread_storage_key);
Expand All @@ -1120,7 +1120,7 @@ int _yr_re_alloc_storage(
(*storage)->fiber_pool.head = NULL;
(*storage)->fiber_pool.tail = NULL;

#ifdef WIN32
#ifdef _WIN32
TlsSetValue(thread_storage_key, *storage);
#else
pthread_setspecific(thread_storage_key, *storage);
Expand Down
8 changes: 4 additions & 4 deletions libyara/re_lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ limitations under the License.
#include <yara/re_lexer.h>


#ifdef WIN32
#ifdef _WIN32
#define snprintf _snprintf
#endif

Expand Down Expand Up @@ -2443,7 +2443,7 @@ uint8_t read_escaped_char(yyscan_t yyscanner)



#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
extern DWORD recovery_state_key;
#else
Expand All @@ -2457,7 +2457,7 @@ void yyfatal(
{
jmp_buf* recovery_state;

#ifdef WIN32
#ifdef _WIN32
recovery_state = TlsGetValue(recovery_state_key) ;
#else
recovery_state = pthread_getspecific(recovery_state_key);
Expand Down Expand Up @@ -2501,7 +2501,7 @@ int yr_parse_re_string(

lex_env.last_error_code = ERROR_SUCCESS;

#ifdef WIN32
#ifdef _WIN32
TlsSetValue(recovery_state_key, (LPVOID) &recovery_state);
#else
pthread_setspecific(recovery_state_key, (void*) &recovery_state);
Expand Down
8 changes: 4 additions & 4 deletions libyara/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ limitations under the License.
void _yr_rules_lock(
YR_RULES* rules)
{
#ifdef WIN32
#ifdef _WIN32
WaitForSingleObject(rules->mutex, INFINITE);
#else
pthread_mutex_lock(&rules->mutex);
Expand All @@ -52,7 +52,7 @@ void _yr_rules_lock(
void _yr_rules_unlock(
YR_RULES* rules)
{
#ifdef WIN32
#ifdef _WIN32
ReleaseMutex(rules->mutex);
#else
pthread_mutex_unlock(&rules->mutex);
Expand Down Expand Up @@ -624,7 +624,7 @@ int yr_rules_load(
new_rules->rules_list_head = header->rules_list_head;
new_rules->tidx_mask = 0;

#if WIN32
#if _WIN32
new_rules->mutex = CreateMutex(NULL, FALSE, NULL);

if (new_rules->mutex == NULL)
Expand Down Expand Up @@ -657,7 +657,7 @@ int yr_rules_destroy(
external++;
}

#if WIN32
#if _WIN32
CloseHandle(rules->mutex);
#else
pthread_mutex_destroy(&rules->mutex);
Expand Down
Loading

0 comments on commit 3b5ddd0

Please sign in to comment.