先看看题目:结对编程-四则运算(挑战出题)
以下思路来自轮子哥:
| #ifndef _SPINLOCK_H_20170410_ | |
| #define _SPINLOCK_H_20170410_ | |
| #include <atomic> | |
| class spinlock { | |
| public: | |
| spinlock() { m_lock.clear(); } | |
| spinlock(const spinlock&) = delete; | |
| ~spinlock() = default; |
| #include <stdint.h> | |
| uint32_t time31_hash_bin(const void* data, uint32_t length) | |
| { | |
| uint32_t hash = 0; | |
| const uint8_t* p = (const uint8_t*)data; | |
| const uint8_t* pend = p + length; | |
| for(; p < pend; ++p) | |
| hash = (hash<<5) - hash + *p; | |
| return hash; |
先看看题目:结对编程-四则运算(挑战出题)
以下思路来自轮子哥:
| #define _CRT_SECURE_NO_WARNINGS | |
| #include <stdio.h> | |
| #include <time.h> | |
| #include <assert.h> | |
| #ifdef _WIN32 | |
| #include <Windows.h> | |
| #else | |
| #include <unistd.h> | |
| #endif |
| # | |
| # STL GDB evaluators/views/utilities - 1.03 | |
| # | |
| # The new GDB commands: | |
| # are entirely non instrumental | |
| # do not depend on any "inline"(s) - e.g. size(), [], etc | |
| # are extremely tolerant to debugger settings | |
| # | |
| # This file should be "included" in .gdbinit as following: | |
| # source stl-views.gdb or just paste it into your .gdbinit file |
| #!/usr/bin/awk -f | |
| BEGIN { | |
| dec = ARGV[1] | |
| for (e = 3; e >= 0; e--) { | |
| octet = int(dec / (256 ^ e)) | |
| dec -= octet * 256 ^ e | |
| ip = octet delim ip | |
| delim = "." | |
| } | |
| printf("%s\n", ip) |
| /** | |
| # -*- coding:UTF-8 -*- | |
| */ | |
| #include "json_parser.hpp" | |
| #include <assert.h> | |
| static JO _g_jo_empty; | |
| JO::JO() |
| #include <uv.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #define WORKER_NUM 10 | |
| uv_thread_t worker_tid[WORKER_NUM]; | |
| uv_async_t async[WORKER_NUM]; | |
| uv_mutex_t mutex[WORKER_NUM]; |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #include <errno.h> | |
| #include <string.h> | |
| #include <fcntl.h> | |
| #include <signal.h> | |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> |