Created
January 31, 2020 17:21
-
-
Save RChehowski/9995c3f6f9288bb72745701d5fa45b64 to your computer and use it in GitHub Desktop.
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 <cstdint> | |
#include "library.h" | |
#include <pthread.h> | |
#include <cstring> | |
#include <string> | |
#include <iostream> | |
#include <cstdio> | |
#define MAKE_VERSION(x, y, z) "" #x "." #y "." #z "" | |
std::string GAME_VERSION = MAKE_VERSION(INT_MAX, INT_MAX, INT_MAX); | |
void emplace_suffix(const uint64_t index, char* name_template) | |
{ | |
static const uint64_t BASE_63 = 63; | |
static const uint64_t NUM_ONE_BITS_63 = 6; | |
static const char char_table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_!"; | |
char suffix[] = { '\0', '\0', '\0', '\0', '\0', '\0' }; | |
const size_t suffix_length = sizeof(suffix) / sizeof(*suffix); | |
uint64_t mutable_index = index; | |
for (uint64_t i = 0; i < suffix_length; ++i) | |
{ | |
const uint64_t part = (index >> (i * NUM_ONE_BITS_63)) & BASE_63; | |
suffix[(suffix_length - 1) - i] = char_table[part]; | |
mutable_index &= (UINT64_MAX & ~(BASE_63 << (i * NUM_ONE_BITS_63))); | |
} | |
const size_t name_template_length = strlen(name_template); | |
// if (name_template_length != ((suffix_ptr - name_template) + suffix_length)) | |
// { | |
// | |
// } | |
for (uint64_t i = 0; i < (uint64_t)(sizeof(suffix) / sizeof(*suffix)); ++i) | |
{ | |
printf("%c", suffix[i]); | |
} | |
printf("\n"); | |
} | |
#include <poll.h> | |
#include <unistd.h> | |
#include <sys/socket.h> | |
int main() | |
{ | |
int pipe_ends[] = {0, 0}; | |
const int pipe_ret = pipe(pipe_ends); | |
struct pollfd poll_fd = { | |
.fd = pipe_ends[1], | |
.events = 0, | |
.revents = 0 | |
}; | |
const int num_events = poll(&poll_fd, 1, -1); | |
return 0; | |
// for (int i = 1000000; i < 1001000; ++i) | |
// { | |
// char len[] = "temp_XXXXXX"; | |
// emplace_suffix(i, len); | |
// | |
// printf("Hello: %s", len); | |
// } | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment