Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Windows fixes #20

Merged
merged 4 commits into from
Feb 2, 2022
Merged
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
4 changes: 2 additions & 2 deletions common/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static size_t file_read(void *data, void *buffer, size_t count)

static bool file_seek(void *data, off64_t offset, int origin)
{
#ifdef _MSC_VER
#ifdef _WIN32
return _fseeki64(data, offset, origin) == 0;
#else
#if _POSIX_C_SOURCE >= 200112L
Expand All @@ -74,7 +74,7 @@ static bool file_seek(void *data, off64_t offset, int origin)

static off64_t file_tell(void *data)
{
#ifdef _MSC_VER
#ifdef _WIN32
return _ftelli64(data);
#elif _POSIX_C_SOURCE >= 200112L
return ftello(data);
Expand Down
6 changes: 3 additions & 3 deletions lzmasdk/CpuArch.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ BoolInt CPU_Is_InOrder()
}

#if !defined(MY_CPU_AMD64) && defined(_WIN32)
#include <Windows.h>
#include <windows.h>
static BoolInt CPU_Sys_Is_SSE_Supported()
{
OSVERSIONINFO vi;
Expand Down Expand Up @@ -275,7 +275,7 @@ BoolInt CPU_IsSupported_SHA()
// #include <stdio.h>

#ifdef _WIN32
#include <Windows.h>
#include <windows.h>
#endif

BoolInt CPU_IsSupported_AVX2()
Expand Down Expand Up @@ -351,7 +351,7 @@ BoolInt CPU_IsSupported_PageGB()

#ifdef _WIN32

#include <Windows.h>
#include <windows.h>

BoolInt CPU_IsSupported_CRC32() { return IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE) ? 1 : 0; }
BoolInt CPU_IsSupported_CRYPTO() { return IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) ? 1 : 0; }
Expand Down
14 changes: 8 additions & 6 deletions zip/inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#include <stdint.h>
#include <string.h>

#ifndef _MSC_VER
#define __forceinline inline
#ifdef _MSC_VER
#define UNARR_FORCE_INLINE __forceinline
#else
#define UNARR_FORCE_INLINE inline __attribute__((always_inline))
#endif

#define MAX_BITS 16
Expand Down Expand Up @@ -95,7 +97,7 @@ static const struct {

static const int table_code_length_idxs[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };

static __forceinline bool br_ensure(inflate_state *state, int bits)
static UNARR_FORCE_INLINE bool br_ensure(inflate_state *state, int bits)
{
while (state->in.available < bits) {
if (*state->in.avail_in == 0)
Expand All @@ -107,15 +109,15 @@ static __forceinline bool br_ensure(inflate_state *state, int bits)
return true;
}

static __forceinline uint64_t br_bits(inflate_state *state, int bits)
static UNARR_FORCE_INLINE uint64_t br_bits(inflate_state *state, int bits)
{
uint64_t res = state->in.bits & (((uint64_t)1 << bits) - 1);
state->in.available -= bits;
state->in.bits >>= bits;
return res;
}

static __forceinline void output(inflate_state *state, uint8_t value)
static UNARR_FORCE_INLINE void output(inflate_state *state, uint8_t value)
{
*state->out.data_out++ = value;
(*state->out.avail_out)--;
Expand Down Expand Up @@ -172,7 +174,7 @@ static bool tree_add_value(struct tree *tree, int key, int bits, int value)
return true;
}

static __forceinline int tree_get_value(inflate_state *state, const struct tree *tree, bool not_fast)
static UNARR_FORCE_INLINE int tree_get_value(inflate_state *state, const struct tree *tree, bool not_fast)
{
if (state->state.tree_idx == 0) {
int key = state->in.bits & ((1 << TREE_FAST_BITS) - 1);
Expand Down