MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / blake2sp_update

Function blake2sp_update

Libraries/unrar/blake2sp.cpp:67–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67void blake2sp_update( blake2sp_state *S, const byte *in, size_t inlen )
68{
69 size_t left = S->buflen;
70 size_t fill = sizeof( S->buf ) - left;
71
72 if( left && inlen >= fill )
73 {
74 memcpy( S->buf + left, in, fill );
75
76 for( size_t i = 0; i < PARALLELISM_DEGREE; ++i )
77 blake2s_update( &S->S[i], S->buf + i * BLAKE2S_BLOCKBYTES, BLAKE2S_BLOCKBYTES );
78
79 in += fill;
80 inlen -= fill;
81 left = 0;
82 }
83
84 Blake2ThreadData btd_array[PARALLELISM_DEGREE];
85
86#ifdef RAR_SMP
87 uint ThreadNumber = inlen < 0x1000 ? 1 : S->MaxThreads;
88
89 if (ThreadNumber==6 || ThreadNumber==7) // 6 and 7 threads work slower than 4 here.
90 ThreadNumber=4;
91#else
92 uint ThreadNumber=1;
93#endif
94
95 for (size_t id__=0;id__<PARALLELISM_DEGREE;)
96 {
97 for (uint Thread=0;Thread<ThreadNumber && id__<PARALLELISM_DEGREE;Thread++)
98 {
99 Blake2ThreadData *btd=btd_array+Thread;
100
101 btd->inlen = inlen;
102 btd->in = in + id__ * BLAKE2S_BLOCKBYTES;
103 btd->S = &S->S[id__];
104
105#ifdef RAR_SMP
106 if (ThreadNumber>1)
107 S->ThPool->AddTask(Blake2Thread,(void*)btd);
108 else
109 btd->Update();
110#else
111 btd->Update();
112#endif
113 id__++;
114 }
115#ifdef RAR_SMP
116 if (S->ThPool!=NULL) // Can be NULL in -mt1 mode.
117 S->ThPool->WaitDone();
118#endif // RAR_SMP
119 }
120
121 in += inlen - inlen % ( PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES );
122 inlen %= PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES;
123
124 if( inlen > 0 )

Callers 1

UpdateMethod · 0.85

Calls 4

blake2s_updateFunction · 0.85
AddTaskMethod · 0.80
WaitDoneMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected