This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# By default, enforce LF line-endings on all text files | |
* text=auto eol=lf | |
*.c text eol=lf | |
*.h text eol=lf | |
*.cpp text eol=lf | |
*.hpp text eol=lf | |
# Visual Studio | |
*.sln eol=crlf | |
*.vcxproj eol=crlf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#use https://github.com/newren/git-filter-repo | |
git-filter-repo --file-info-callback ' | |
contents = value.get_contents_by_identifier(blob_id) | |
ext = filename.lower().split(b".")[-1] | |
if ext not in [b"c", b"cpp", b"h", b"hpp"] or \ | |
value.is_binary(contents): | |
# Make no changes to the file; return as-is | |
return (filename, mode, blob_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <intrin.h> | |
// based on XXH_mult64to128 from xxHash https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h#L4464 | |
uint64_t umul128(uint64_t x, uint64_t y, uint64_t* hi) | |
{ | |
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__wasm__) \ | |
&& defined(__SIZEOF_INT128__) \ | |
|| (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 128) | |
// gcc/clang __uint128_t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pcg-based rand32() and rand64() | |
#include <stdint.h> | |
struct pcg32_random_t | |
{ | |
uint64_t state; | |
}; | |
static const uint64_t inc = 997; | |
static struct pcg32_random_t rndState = {99991}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check TCP connect to port/host | |
var sock = require('net').connect({ port: 443, host: '127.0.0.1' }).on('connect', () => { console.log('connect OK'); sock.end(); }).on('error', (e) => { console.log('connect error (code:'+e.code+')'); }) | |
// listen for TCP connect on port/host | |
var server = require('net').createServer((sock) => { console.log('client connected'); sock.end(); }).listen({ port: 443, host: '127.0.0.1' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run node server.js | |
then build and run curl-test.cpp | |
Everything will be ok: | |
``` | |
CURLINFO_ACTIVESOCKET, ret:0 sockWs:276 | |
curl_easy_send ret:0 sentSize:194 | |
curl_easy_recv ret:0 recvSize:167 | |
CURLINFO_ACTIVESOCKET, ret:0 sockWs:296 | |
curl_easy_send ret:0 sentSize:194 | |
curl_easy_recv ret:0 recvSize:167 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#undef NDEBUG | |
#include "compositecodec.h" | |
#include "simdfastpfor.h" | |
#include "variablebyte.h" | |
#include <stdlib.h> | |
#include <vector> | |
// typedef for simdfastpfor128 codec from FastPFor | |
typedef FastPForLib::CompositeCodec<FastPForLib::SIMDFastPFor<4>, FastPForLib::VariableByte> IntCodec; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _WIN32 | |
#include <windows.h> | |
#if !defined(PLATFORM_XBOX) && !defined(PLATFORM_UWP) | |
#include <wincrypt.h> | |
#else | |
#include <bcrypt.h> | |
#pragma comment(lib, "bcrypt.lib") | |
#endif | |
int computeHash(const void* data, unsigned dataSize, unsigned char hashBuf[64], const void *hmacSecret, unsigned hmacSecretSize, bool isMD5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note, bsf/bsr are used by default. | |
// Enable /arch:AVX2 compilation for better optimizations | |
#if defined(_MSC_VER) && !defined(__clang__) | |
#include <intrin.h> | |
#include <limits.h> | |
#if (defined(__cplusplus) && (__cplusplus >= 202002L)) || \ | |
(defined(_MSVC_LANG) && (_MSVC_LANG >= 202002L)) | |
#include <type_traits> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _WS2DEF_ | |
#include "inaddr.h" | |
#include "MSTcpIP.h" | |
void startServer(); | |
void startClient_6_to_4(short xxport); | |
void startClient_4_to_4(short xxport); | |
void startClient_6_to_6(short xxport); | |
short xxport = 8112; |
NewerOlder