profile
viewpoint

Ask questionsEasier implementation for software running on "normal" architectures

I wish there was a simplified implementation of xxhash, in a single cpp file, without #ifdef, a ~6KB file instead of ~145KB

Something like this https://create.stephan-brumme.com/xxhash/ but for XXH3 (the 128 bit version), just to get (snippet)

    XXH3_state_t state128;
    (void)XXH3_128bits_reset(&state128);
	
	size_t readSize;
	while ((readSize = fread(buffer, 1, blockSize, inFile)) > 0) 
	{
		(void)XXH3_128bits_update(&state128, buffer, readSize);
	}

In fact, I find it particularly difficult to debug other programs in which XXH3 is "integrated", it is really difficult to understand the interaction of all the #ifdefs.

Often you have "normal" environments (x86 / x64 machines) in which to use xxhash (actually a great program, when ... it works!)

I'm having trouble with a software that compiles and works fine with gcc on Windows and FreeBSD but not Linux, due to XXH3_state_t

Thank you

Cyan4973/xxHash

Answer questions felixhandte

C11 says:

If an object's alignment is made stricter (larger) than max_align_t using _Alignas, it has extended alignment requirement. A struct or union type whose member has extended alignment is an over-aligned type. It is implementation-defined if over-aligned types are supported, and their support may be different in each kind of storage duration.

Which, if I'm reading correctly, is not particularly encouraging. It looks like implementations are free to ignore alignas(64)...

I'm not sure if there's a good solution available, but one small possible improvement would be: is it possible the XXH_ALIGN() macro does not interact well with C++? It only uses alignas() when it detects C11, but doesn't check for C++11. We should consider adding || (defined(__cplusplus) && (__cplusplus >= 201103L).

useful!

Related questions

No questions were found.
source:https://uonfu.com/
answerer
Felix Handte felixhandte @facebook New York. NY felixhandte.com Software Engineer on @facebook's Data Compression Team
Github User Rank List