mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[ion] Fix crc32_padded inclusion
This commit is contained in:
@@ -17,6 +17,7 @@ initializer_list = $(shell echo $(1) | sed "s/\(.\)/'\1',/g")0
|
||||
ion/src/shared/platform_info.o: SFLAGS += -DPATCH_LEVEL="$(call initializer_list,$(PATCH_LEVEL))" -DEPSILON_VERSION="$(call initializer_list,$(EPSILON_VERSION))"
|
||||
|
||||
objs += $(addprefix ion/src/shared/, \
|
||||
crc32_padded.o\
|
||||
events.o \
|
||||
platform_info.o \
|
||||
storage.o \
|
||||
|
||||
@@ -9,6 +9,7 @@ objs += $(addprefix ion/src/shared/, \
|
||||
console_line.o \
|
||||
console_stdio.o \
|
||||
crc32.o \
|
||||
crc32_padded.o \
|
||||
events.o \
|
||||
power.o \
|
||||
random.o \
|
||||
|
||||
@@ -6,6 +6,7 @@ ion/src/shared/platform_info.o: SFLAGS += -DHEADER_SECTION="__attribute__((secti
|
||||
|
||||
objs += $(addprefix ion/src/shared/, \
|
||||
console_line.o \
|
||||
crc32_padded.o\
|
||||
events_modifier.o \
|
||||
)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ objs += $(addprefix ion/src/emscripten/, \
|
||||
|
||||
objs += $(addprefix ion/src/shared/, \
|
||||
crc32.o \
|
||||
crc32_padded.o \
|
||||
events.o \
|
||||
events_modifier.o \
|
||||
power.o \
|
||||
|
||||
@@ -23,26 +23,3 @@ uint32_t Ion::crc32(const uint32_t * data, size_t length) {
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
uint32_t Ion::crc32PaddedString(const char * s, int length) {
|
||||
/* s is a char array. Its length in Bytes is not necessarily a multiple of 4.
|
||||
* However, crc32 method awaits input in a form of uint32_t table. To limit
|
||||
* the use of additional memory, we compute 2 crc32:
|
||||
* - one corresponding to s with a byte length truncated to be a multiple of 4
|
||||
* - the other corresponds to the remaining chars in s padded with 0 to be 4
|
||||
* bytes long
|
||||
* The CRC32 of s is the crc32 of both. */
|
||||
|
||||
// CRC32 of the truncated string
|
||||
uint32_t c[2] = {0, 0};
|
||||
size_t crc32TruncatedInputSize = length*sizeof(char)/sizeof(uint32_t);
|
||||
c[0] = Ion::crc32((const uint32_t *)s, crc32TruncatedInputSize);
|
||||
|
||||
// CRC32 of the tail of the string
|
||||
uint32_t tailName = 0;
|
||||
size_t tailLength = length - crc32TruncatedInputSize*sizeof(uint32_t)/sizeof(char);
|
||||
strlcpy((char *)&tailName, s+crc32TruncatedInputSize*sizeof(uint32_t)/sizeof(char), tailLength+1); //+1 because strlcpy assures null termination
|
||||
c[1] = Ion::crc32(&tailName, 1);
|
||||
|
||||
return Ion::crc32((const uint32_t *)c, 2);
|
||||
}
|
||||
|
||||
24
ion/src/shared/crc32_padded.cpp
Normal file
24
ion/src/shared/crc32_padded.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <ion.h>
|
||||
|
||||
uint32_t Ion::crc32PaddedString(const char * s, int length) {
|
||||
/* s is a char array. Its length in Bytes is not necessarily a multiple of 4.
|
||||
* However, crc32 method awaits input in a form of uint32_t table. To limit
|
||||
* the use of additional memory, we compute 2 crc32:
|
||||
* - one corresponding to s with a byte length truncated to be a multiple of 4
|
||||
* - the other corresponds to the remaining chars in s padded with 0 to be 4
|
||||
* bytes long
|
||||
* The CRC32 of s is the crc32 of both. */
|
||||
|
||||
// CRC32 of the truncated string
|
||||
uint32_t c[2] = {0, 0};
|
||||
size_t crc32TruncatedInputSize = length*sizeof(char)/sizeof(uint32_t);
|
||||
c[0] = Ion::crc32((const uint32_t *)s, crc32TruncatedInputSize);
|
||||
|
||||
// CRC32 of the tail of the string
|
||||
uint32_t tailName = 0;
|
||||
size_t tailLength = length - crc32TruncatedInputSize*sizeof(uint32_t)/sizeof(char);
|
||||
strlcpy((char *)&tailName, s+crc32TruncatedInputSize*sizeof(uint32_t)/sizeof(char), tailLength+1); //+1 because strlcpy assures null termination
|
||||
c[1] = Ion::crc32(&tailName, 1);
|
||||
|
||||
return Ion::crc32((const uint32_t *)c, 2);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ objs += $(addprefix ion/src/simulator/keyboard/, fltkkbd.o)
|
||||
|
||||
objs += $(addprefix ion/src/shared/, \
|
||||
crc32.o \
|
||||
crc32_padded.o \
|
||||
console_line.o \
|
||||
console_stdio.o \
|
||||
events_modifier.o \
|
||||
|
||||
Reference in New Issue
Block a user