Skip to content

Commit

Permalink
Fixed formatting, 4 spaces for code intent, 2 spaces for preprocessor…
Browse files Browse the repository at this point in the history
… indent, initial function brace on the same line as definition, removed extraneous spaces and new lines.
  • Loading branch information
nmoinvaz authored and Dead2 committed Feb 7, 2020
1 parent 550f983 commit e0a711c
Show file tree
Hide file tree
Showing 44 changed files with 543 additions and 639 deletions.
37 changes: 18 additions & 19 deletions arch/arm/armfeature.c
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
#include "../../zutil.h"

#if defined(__linux__)
# include <sys/auxv.h>
# include <asm/hwcap.h>
# include <sys/auxv.h>
# include <asm/hwcap.h>
#elif defined(_WIN32)
# include <winapifamily.h>
# include <winapifamily.h>
#endif

static int arm_has_crc32() {
#if defined(__linux__) && defined(HWCAP2_CRC32)
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32) != 0 ? 1 : 0;
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32) != 0 ? 1 : 0;
#elif defined(ARM_NOCHECK_ACLE)
return 1;
return 1;
#else
return 0;
return 0;
#endif
}

/* AArch64 has neon. */
#if !defined(__aarch64__) && !defined(_M_ARM64)
static inline int arm_has_neon()
{
#if defined(__linux__) && defined(HWCAP_NEON)
static inline int arm_has_neon() {
#if defined(__linux__) && defined(HWCAP_NEON)
return (getauxval(AT_HWCAP) & HWCAP_NEON) != 0 ? 1 : 0;
#elif defined(_M_ARM) && defined(WINAPI_FAMILY_PARTITION)
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
#elif defined(_M_ARM) && defined(WINAPI_FAMILY_PARTITION)
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
return 1; /* Always supported */
#endif
#endif
# endif
#endif

#if defined(ARM_NOCHECK_NEON)
#if defined(ARM_NOCHECK_NEON)
return 1;
#else
#else
return 0;
#endif
#endif
}
#endif

Expand All @@ -42,9 +41,9 @@ ZLIB_INTERNAL int arm_cpu_has_crc32;

void ZLIB_INTERNAL arm_check_features(void) {
#if defined(__aarch64__) || defined(_M_ARM64)
arm_cpu_has_neon = 1; /* always available */
arm_cpu_has_neon = 1; /* always available */
#else
arm_cpu_has_neon = arm_has_neon();
arm_cpu_has_neon = arm_has_neon();
#endif
arm_cpu_has_crc32 = arm_has_crc32();
arm_cpu_has_crc32 = arm_has_crc32();
}
4 changes: 2 additions & 2 deletions arch/arm/insert_string_acle.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ Pos insert_string_acle(deflate_state *const s, const Pos str, unsigned int count
s->prev[p & s->w_mask] = head;
s->head[hm] = p;
if (p == lp)
ret = head;
ret = head;
} else if (p == lp) {
ret = p;
ret = p;
}
}
return ret;
Expand Down
18 changes: 6 additions & 12 deletions arch/s390/dfltcc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
`posix_memalign' is not an option. Thus, we overallocate and take the
aligned portion of the buffer.
*/
static inline int is_dfltcc_enabled(void)
{
static inline int is_dfltcc_enabled(void) {
uint64_t facilities[(DFLTCC_FACILITY / 64) + 1];
register uint8_t r0 __asm__("r0");

Expand All @@ -31,8 +30,7 @@ static inline int is_dfltcc_enabled(void)
return is_bit_set((const char *)facilities, DFLTCC_FACILITY);
}

void ZLIB_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size)
{
void ZLIB_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size) {
struct dfltcc_state *dfltcc_state = (struct dfltcc_state *)((char *)strm->state + ALIGN_UP(size, 8));
struct dfltcc_qaf_param *param = (struct dfltcc_qaf_param *)&dfltcc_state->param;

Expand All @@ -55,20 +53,17 @@ void ZLIB_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size)
dfltcc_state->param.ribm = DFLTCC_RIBM;
}

void ZLIB_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size)
{
void ZLIB_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size) {
return ZALLOC(strm, ALIGN_UP(items * size, 8) + sizeof(struct dfltcc_state), sizeof(unsigned char));
}

void ZLIB_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size)
{
void ZLIB_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size) {
memcpy(dst, src, ALIGN_UP(size, 8) + sizeof(struct dfltcc_state));
}

static const int PAGE_ALIGN = 0x1000;

void ZLIB_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size)
{
void ZLIB_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size) {
void *p;
void *w;

Expand All @@ -83,8 +78,7 @@ void ZLIB_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt
return w;
}

void ZLIB_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w)
{
void ZLIB_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w) {
if (w)
ZFREE(strm, *(void **)((unsigned char *)w - sizeof(void *)));
}
36 changes: 12 additions & 24 deletions arch/s390/dfltcc_deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@
#include "dfltcc_detail.h"

static inline int dfltcc_are_params_ok(int level, uInt window_bits, int strategy, uint16_t level_mask,
int reproducible)
{
int reproducible) {
return (level_mask & ((uint16_t)1 << level)) != 0 &&
(window_bits == HB_BITS) &&
(strategy == Z_FIXED || strategy == Z_DEFAULT_STRATEGY) &&
!reproducible;
}


int ZLIB_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm)
{
int ZLIB_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm) {
deflate_state *state = (deflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);

Expand All @@ -48,17 +46,15 @@ int ZLIB_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm)
return 1;
}

static inline void dfltcc_gdht(PREFIX3(streamp) strm)
{
static inline void dfltcc_gdht(PREFIX3(streamp) strm) {
deflate_state *state = (deflate_state *)strm->state;
struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
size_t avail_in = strm->avail_in;

dfltcc(DFLTCC_GDHT, param, NULL, NULL, &strm->next_in, &avail_in, NULL);
}

static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm)
{
static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm) {
deflate_state *state = (deflate_state *)strm->state;
struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
size_t avail_in = strm->avail_in;
Expand All @@ -75,8 +71,7 @@ static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm)
return cc;
}

static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0 *param)
{
static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0 *param) {
deflate_state *state = (deflate_state *)strm->state;

send_bits(state, bi_reverse(param->eobs >> (15 - param->eobl), param->eobl), param->eobl, state->bi_buf, state->bi_valid);
Expand All @@ -96,8 +91,7 @@ static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0
#endif
}

int ZLIB_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result)
{
int ZLIB_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result) {
deflate_state *state = (deflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
struct dfltcc_param_v0 *param = &dfltcc_state->param;
Expand Down Expand Up @@ -280,16 +274,14 @@ int ZLIB_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *
fly with deflateParams, we need to convert between hardware and software
window formats.
*/
static int dfltcc_was_deflate_used(PREFIX3(streamp) strm)
{
static int dfltcc_was_deflate_used(PREFIX3(streamp) strm) {
deflate_state *state = (deflate_state *)strm->state;
struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;

return strm->total_in > 0 || param->nt == 0 || param->hl > 0;
}

int ZLIB_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy)
{
int ZLIB_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy) {
deflate_state *state = (deflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
int could_deflate = dfltcc_can_deflate(strm);
Expand All @@ -308,8 +300,7 @@ int ZLIB_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int st
return Z_STREAM_ERROR;
}

int ZLIB_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reproducible)
{
int ZLIB_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reproducible) {
deflate_state *state = (deflate_state *)strm->state;

return reproducible != state->reproducible && !dfltcc_was_deflate_used(strm);
Expand All @@ -318,8 +309,7 @@ int ZLIB_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reprodu
/*
Preloading history.
*/
static void append_history(struct dfltcc_param_v0 *param, unsigned char *history, const unsigned char *buf, uInt count)
{
static void append_history(struct dfltcc_param_v0 *param, unsigned char *history, const unsigned char *buf, uInt count) {
size_t offset;
size_t n;

Expand Down Expand Up @@ -350,8 +340,7 @@ static void append_history(struct dfltcc_param_v0 *param, unsigned char *history
}

int ZLIB_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm,
const unsigned char *dictionary, uInt dict_length)
{
const unsigned char *dictionary, uInt dict_length) {
deflate_state *state = (deflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
struct dfltcc_param_v0 *param = &dfltcc_state->param;
Expand All @@ -361,8 +350,7 @@ int ZLIB_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm,
return Z_OK;
}

int ZLIB_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt *dict_length)
{
int ZLIB_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt *dict_length) {
deflate_state *state = (deflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
struct dfltcc_param_v0 *param = &dfltcc_state->param;
Expand Down
12 changes: 4 additions & 8 deletions arch/s390/dfltcc_detail.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ typedef enum {
#define DFLTCC_FACILITY 151

static inline dfltcc_cc dfltcc(int fn, void *param,
unsigned char **op1, size_t *len1, const unsigned char **op2, size_t *len2, void *hist)
{
unsigned char **op1, size_t *len1, const unsigned char **op2, size_t *len2, void *hist) {
unsigned char *t2 = op1 ? *op1 : NULL;
size_t t3 = len1 ? *len1 : 0;
const unsigned char *t4 = op2 ? *op2 : NULL;
Expand Down Expand Up @@ -108,13 +107,11 @@ struct dfltcc_qaf_param {

static_assert(sizeof(struct dfltcc_qaf_param) == 32, sizeof_struct_dfltcc_qaf_param_is_32);

static inline int is_bit_set(const char *bits, int n)
{
static inline int is_bit_set(const char *bits, int n) {
return bits[n / 8] & (1 << (7 - (n % 8)));
}

static inline void clear_bit(char *bits, int n)
{
static inline void clear_bit(char *bits, int n) {
bits[n / 8] &= ~(1 << (7 - (n % 8)));
}

Expand Down Expand Up @@ -175,8 +172,7 @@ struct dfltcc_param_v0 {

static_assert(sizeof(struct dfltcc_param_v0) == 1536, sizeof_struct_dfltcc_param_v0_is_1536);

static inline const char *oesc_msg(char *buf, int oesc)
{
static inline const char *oesc_msg(char *buf, int oesc) {
if (oesc == 0x00)
return NULL; /* Successful completion */
else {
Expand Down
15 changes: 5 additions & 10 deletions arch/s390/dfltcc_inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#include "dfltcc_inflate.h"
#include "dfltcc_detail.h"

int ZLIB_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm)
{
int ZLIB_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm) {
struct inflate_state *state = (struct inflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);

Expand All @@ -33,8 +32,7 @@ int ZLIB_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm)
return is_bit_set(dfltcc_state->af.fns, DFLTCC_XPND) && is_bit_set(dfltcc_state->af.fmts, DFLTCC_FMT0);
}

static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm)
{
static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm) {
struct inflate_state *state = (struct inflate_state *)strm->state;
struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
size_t avail_in = strm->avail_in;
Expand All @@ -49,8 +47,7 @@ static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm)
return cc;
}

dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret)
{
dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret) {
struct inflate_state *state = (struct inflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
struct dfltcc_param_v0 *param = &dfltcc_state->param;
Expand Down Expand Up @@ -115,16 +112,14 @@ dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int fl
DFLTCC_INFLATE_BREAK : DFLTCC_INFLATE_CONTINUE;
}

int ZLIB_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm)
{
int ZLIB_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm) {
struct inflate_state *state = (struct inflate_state *)strm->state;
struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;

return !param->nt;
}

int ZLIB_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm)
{
int ZLIB_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm) {
struct inflate_state *state = (struct inflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/crc_folding.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Compute the CRC32 using a parallelized folding approach with the PCLMULQDQ
* Compute the CRC32 using a parallelized folding approach with the PCLMULQDQ
* instruction.
*
* A white paper describing this algorithm can be found at:
Expand Down
30 changes: 15 additions & 15 deletions arch/x86/deflate_quick.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ static inline long compare258(const unsigned char *const src0, const unsigned ch
"cmp $256 + 16, %[ax]\n\t"
"jb 1b\n\t"

# if !defined(__x86_64__)
# if !defined(__x86_64__)
"movzwl -16(%[src0], %[ax]), %[dx]\n\t"
# else
# else
"movzwq -16(%[src0], %[ax]), %[dx]\n\t"
# endif
# endif
"xorw -16(%[src1], %[ax]), %%dx\n\t"
"jnz 3f\n\t"

Expand Down Expand Up @@ -134,19 +134,19 @@ static inline void quick_send_bits(deflate_state *const s,
/* Concatenate the new bits with the bits currently in the buffer */
unsigned out = s->bi_buf | (value1 << s->bi_valid);
if (width < 32) {
out |= (value2 << offset2);
/* Shift out the valid LSBs written out. */
s->bi_buf = out >> (bytes_out * 8);
} else /* width => 32 */ {
unsigned bits_that_fit = 32 - offset2;
unsigned mask = (1 << bits_that_fit) - 1;
/* Zero out the high bits of value2 such that the shift by offset2 will
not cause undefined behavior. */
out |= ((value2 & mask) << offset2);
out |= (value2 << offset2);
/* Shift out the valid LSBs written out. */
s->bi_buf = out >> (bytes_out * 8);
} else { /* width => 32 */
unsigned bits_that_fit = 32 - offset2;
unsigned mask = (1 << bits_that_fit) - 1;
/* Zero out the high bits of value2 such that the shift by offset2 will
not cause undefined behavior. */
out |= ((value2 & mask) << offset2);

/* Save in s->bi_buf the bits of value2 that do not fit: they will be
written in a next full byte. */
s->bi_buf = (width == 32) ? 0 : value2 >> bits_that_fit;
/* Save in s->bi_buf the bits of value2 that do not fit: they will be
written in a next full byte. */
s->bi_buf = (width == 32) ? 0 : value2 >> bits_that_fit;
}

s->bi_valid = width - (bytes_out * 8);
Expand Down
Loading

0 comments on commit e0a711c

Please sign in to comment.