~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/zlib_dfltcc/dfltcc_inflate.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /lib/zlib_dfltcc/dfltcc_inflate.c (Architecture mips) and /lib/zlib_dfltcc/dfltcc_inflate.c (Architecture sparc)


  1 // SPDX-License-Identifier: Zlib                    1 // SPDX-License-Identifier: Zlib
  2                                                     2 
  3 #include "../zlib_inflate/inflate.h"                3 #include "../zlib_inflate/inflate.h"
  4 #include "dfltcc_util.h"                            4 #include "dfltcc_util.h"
  5 #include "dfltcc_inflate.h"                         5 #include "dfltcc_inflate.h"
  6 #include <asm/setup.h>                              6 #include <asm/setup.h>
  7 #include <linux/export.h>                           7 #include <linux/export.h>
  8 #include <linux/zutil.h>                            8 #include <linux/zutil.h>
  9                                                     9 
 10 /*                                                 10 /*
 11  * Expand.                                         11  * Expand.
 12  */                                                12  */
 13 int dfltcc_can_inflate(                            13 int dfltcc_can_inflate(
 14     z_streamp strm                                 14     z_streamp strm
 15 )                                                  15 )
 16 {                                                  16 {
 17     struct inflate_state *state = (struct infl     17     struct inflate_state *state = (struct inflate_state *)strm->state;
 18     struct dfltcc_state *dfltcc_state = GET_DF     18     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
 19                                                    19 
 20     /* Check for kernel dfltcc command line pa     20     /* Check for kernel dfltcc command line parameter */
 21     if (zlib_dfltcc_support == ZLIB_DFLTCC_DIS     21     if (zlib_dfltcc_support == ZLIB_DFLTCC_DISABLED ||
 22             zlib_dfltcc_support == ZLIB_DFLTCC     22             zlib_dfltcc_support == ZLIB_DFLTCC_DEFLATE_ONLY)
 23         return 0;                                  23         return 0;
 24                                                    24 
 25     /* Unsupported hardware */                     25     /* Unsupported hardware */
 26     return is_bit_set(dfltcc_state->af.fns, DF     26     return is_bit_set(dfltcc_state->af.fns, DFLTCC_XPND) &&
 27                is_bit_set(dfltcc_state->af.fmt     27                is_bit_set(dfltcc_state->af.fmts, DFLTCC_FMT0);
 28 }                                                  28 }
 29 EXPORT_SYMBOL(dfltcc_can_inflate);                 29 EXPORT_SYMBOL(dfltcc_can_inflate);
 30                                                    30 
 31 void dfltcc_reset_inflate_state(z_streamp strm     31 void dfltcc_reset_inflate_state(z_streamp strm) {
 32     struct inflate_state *state = (struct infl     32     struct inflate_state *state = (struct inflate_state *)strm->state;
 33     struct dfltcc_state *dfltcc_state = GET_DF     33     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
 34                                                    34 
 35     dfltcc_reset_state(dfltcc_state);              35     dfltcc_reset_state(dfltcc_state);
 36 }                                                  36 }
 37 EXPORT_SYMBOL(dfltcc_reset_inflate_state);         37 EXPORT_SYMBOL(dfltcc_reset_inflate_state);
 38                                                    38 
 39 static int dfltcc_was_inflate_used(                39 static int dfltcc_was_inflate_used(
 40     z_streamp strm                                 40     z_streamp strm
 41 )                                                  41 )
 42 {                                                  42 {
 43     struct inflate_state *state = (struct infl     43     struct inflate_state *state = (struct inflate_state *)strm->state;
 44     struct dfltcc_param_v0 *param = &GET_DFLTC     44     struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
 45                                                    45 
 46     return !param->nt;                             46     return !param->nt;
 47 }                                                  47 }
 48                                                    48 
 49 static int dfltcc_inflate_disable(                 49 static int dfltcc_inflate_disable(
 50     z_streamp strm                                 50     z_streamp strm
 51 )                                                  51 )
 52 {                                                  52 {
 53     struct inflate_state *state = (struct infl     53     struct inflate_state *state = (struct inflate_state *)strm->state;
 54     struct dfltcc_state *dfltcc_state = GET_DF     54     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
 55                                                    55 
 56     if (!dfltcc_can_inflate(strm))                 56     if (!dfltcc_can_inflate(strm))
 57         return 0;                                  57         return 0;
 58     if (dfltcc_was_inflate_used(strm))             58     if (dfltcc_was_inflate_used(strm))
 59         /* DFLTCC has already decompressed som     59         /* DFLTCC has already decompressed some data. Since there is not
 60          * enough information to resume decomp     60          * enough information to resume decompression in software, the call
 61          * must fail.                              61          * must fail.
 62          */                                        62          */
 63         return 1;                                  63         return 1;
 64     /* DFLTCC was not used yet - decompress in     64     /* DFLTCC was not used yet - decompress in software */
 65     memset(&dfltcc_state->af, 0, sizeof(dfltcc     65     memset(&dfltcc_state->af, 0, sizeof(dfltcc_state->af));
 66     return 0;                                      66     return 0;
 67 }                                                  67 }
 68                                                    68 
 69 static dfltcc_cc dfltcc_xpnd(                      69 static dfltcc_cc dfltcc_xpnd(
 70     z_streamp strm                                 70     z_streamp strm
 71 )                                                  71 )
 72 {                                                  72 {
 73     struct inflate_state *state = (struct infl     73     struct inflate_state *state = (struct inflate_state *)strm->state;
 74     struct dfltcc_param_v0 *param = &GET_DFLTC     74     struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
 75     size_t avail_in = strm->avail_in;              75     size_t avail_in = strm->avail_in;
 76     size_t avail_out = strm->avail_out;            76     size_t avail_out = strm->avail_out;
 77     dfltcc_cc cc;                                  77     dfltcc_cc cc;
 78                                                    78 
 79     cc = dfltcc(DFLTCC_XPND | HBT_CIRCULAR,        79     cc = dfltcc(DFLTCC_XPND | HBT_CIRCULAR,
 80                 param, &strm->next_out, &avail     80                 param, &strm->next_out, &avail_out,
 81                 &strm->next_in, &avail_in, sta     81                 &strm->next_in, &avail_in, state->window);
 82     strm->avail_in = avail_in;                     82     strm->avail_in = avail_in;
 83     strm->avail_out = avail_out;                   83     strm->avail_out = avail_out;
 84     return cc;                                     84     return cc;
 85 }                                                  85 }
 86                                                    86 
 87 dfltcc_inflate_action dfltcc_inflate(              87 dfltcc_inflate_action dfltcc_inflate(
 88     z_streamp strm,                                88     z_streamp strm,
 89     int flush,                                     89     int flush,
 90     int *ret                                       90     int *ret
 91 )                                                  91 )
 92 {                                                  92 {
 93     struct inflate_state *state = (struct infl     93     struct inflate_state *state = (struct inflate_state *)strm->state;
 94     struct dfltcc_state *dfltcc_state = GET_DF     94     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
 95     struct dfltcc_param_v0 *param = &dfltcc_st     95     struct dfltcc_param_v0 *param = &dfltcc_state->param;
 96     dfltcc_cc cc;                                  96     dfltcc_cc cc;
 97                                                    97 
 98     if (flush == Z_BLOCK || flush == Z_PACKET_     98     if (flush == Z_BLOCK || flush == Z_PACKET_FLUSH) {
 99         /* DFLTCC does not support stopping on     99         /* DFLTCC does not support stopping on block boundaries (Z_BLOCK flush option)
100          * as well as the use of Z_PACKET_FLUS    100          * as well as the use of Z_PACKET_FLUSH option (used exclusively by PPP driver)
101          */                                       101          */
102         if (dfltcc_inflate_disable(strm)) {       102         if (dfltcc_inflate_disable(strm)) {
103             *ret = Z_STREAM_ERROR;                103             *ret = Z_STREAM_ERROR;
104             return DFLTCC_INFLATE_BREAK;          104             return DFLTCC_INFLATE_BREAK;
105         } else                                    105         } else
106             return DFLTCC_INFLATE_SOFTWARE;       106             return DFLTCC_INFLATE_SOFTWARE;
107     }                                             107     }
108                                                   108 
109     if (state->last) {                            109     if (state->last) {
110         if (state->bits != 0) {                   110         if (state->bits != 0) {
111             strm->next_in++;                      111             strm->next_in++;
112             strm->avail_in--;                     112             strm->avail_in--;
113             state->bits = 0;                      113             state->bits = 0;
114         }                                         114         }
115         state->mode = CHECK;                      115         state->mode = CHECK;
116         return DFLTCC_INFLATE_CONTINUE;           116         return DFLTCC_INFLATE_CONTINUE;
117     }                                             117     }
118                                                   118 
119     if (strm->avail_in == 0 && !param->cf)        119     if (strm->avail_in == 0 && !param->cf)
120         return DFLTCC_INFLATE_BREAK;              120         return DFLTCC_INFLATE_BREAK;
121                                                   121 
122     if (!state->window || state->wsize == 0) {    122     if (!state->window || state->wsize == 0) {
123         state->mode = MEM;                        123         state->mode = MEM;
124         return DFLTCC_INFLATE_CONTINUE;           124         return DFLTCC_INFLATE_CONTINUE;
125     }                                             125     }
126                                                   126 
127     /* Translate stream to parameter block */     127     /* Translate stream to parameter block */
128     param->cvt = CVT_ADLER32;                     128     param->cvt = CVT_ADLER32;
129     param->sbb = state->bits;                     129     param->sbb = state->bits;
130     if (param->hl)                                130     if (param->hl)
131         param->nt = 0; /* Honor history for th    131         param->nt = 0; /* Honor history for the first block */
132     param->cv = state->check;                     132     param->cv = state->check;
133                                                   133 
134     /* Inflate */                                 134     /* Inflate */
135     do {                                          135     do {
136         cc = dfltcc_xpnd(strm);                   136         cc = dfltcc_xpnd(strm);
137     } while (cc == DFLTCC_CC_AGAIN);              137     } while (cc == DFLTCC_CC_AGAIN);
138                                                   138 
139     /* Translate parameter block to stream */     139     /* Translate parameter block to stream */
140     strm->msg = oesc_msg(dfltcc_state->msg, pa    140     strm->msg = oesc_msg(dfltcc_state->msg, param->oesc);
141     state->last = cc == DFLTCC_CC_OK;             141     state->last = cc == DFLTCC_CC_OK;
142     state->bits = param->sbb;                     142     state->bits = param->sbb;
143     state->check = param->cv;                     143     state->check = param->cv;
144     if (cc == DFLTCC_CC_OP2_CORRUPT && param->    144     if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) {
145         /* Report an error if stream is corrup    145         /* Report an error if stream is corrupted */
146         state->mode = BAD;                        146         state->mode = BAD;
147         return DFLTCC_INFLATE_CONTINUE;           147         return DFLTCC_INFLATE_CONTINUE;
148     }                                             148     }
149     state->mode = TYPEDO;                         149     state->mode = TYPEDO;
150     /* Break if operands are exhausted, otherw    150     /* Break if operands are exhausted, otherwise continue looping */
151     return (cc == DFLTCC_CC_OP1_TOO_SHORT || c    151     return (cc == DFLTCC_CC_OP1_TOO_SHORT || cc == DFLTCC_CC_OP2_TOO_SHORT) ?
152         DFLTCC_INFLATE_BREAK : DFLTCC_INFLATE_    152         DFLTCC_INFLATE_BREAK : DFLTCC_INFLATE_CONTINUE;
153 }                                                 153 }
154 EXPORT_SYMBOL(dfltcc_inflate);                    154 EXPORT_SYMBOL(dfltcc_inflate);
155                                                   155 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php