如何找到两次提交之间的提交次数git?
另外,有什么方法可以对GitHub上的任何项目做同样的事情(使用UI,而不是API)?
我读了关于汉明重量的维基百科文章,并注意到一些有趣的东西:
因此它等同于
Hamming distance来自相同长度的全零字符串.对于最典型的情况,一串位,这是字符串中1的数字.在这个二进制的情况下,它也被称为人口数popcount或横向总和.[强调我的]
所以有些事发生在我身上.我可以XOR通过它们计算两个弦之间的汉明距离,然后取得结果弦的汉明重量(POPCOUNT)吗?
有点像这样的东西(使用gcc内在函数):
#include <stdint.h>
int hammingDistance (uint64_t x, uint64_t y) {
uint64_t res = x ^ y;
return __builtin_popcountll (res);
}
Run Code Online (Sandbox Code Playgroud)
现在,至于为什么我想要这样做,好吧,在某些平台上,是的,这只会转换为gcc发出对计算函数的调用popcount.例如,在没有的x64上popcnt,gcc吐出(Godbolt的GCC Online):
hammingDistance:
sub rsp, 8
xor rdi, rsi
call __popcountdi2
add rsp, 8
ret
Run Code Online (Sandbox Code Playgroud)
OTOH,如果你有一个支持POPCOUNT的平台,比如x64模型包括nehalem和之后(有POPCNT),你得到(Godbolt的GCC Online):
hammingDistance:
xor rdi, rsi
popcnt rax, rdi
ret …Run Code Online (Sandbox Code Playgroud) 我已经重载了fork()系统调用并fork()使用RTLD_NEXT 创建了我自己的版本.就是这样dlsym(RTLD_NEXT, fork).这将打到我的版本的fork.在此之后,我想复制实际fork()系统调用的任务,即创建子进程并返回pid,以及一些更多的附加功能.
我无法弄清楚如何做到这一点.我检查了fork()(fork.c)的内核源代码并且无法弄清楚.
这样做:
dlsym(RTLD_NEXT,fork);
int fork(void) {
int pid=_fork(); // Trying to call actual fork does not work
return pid;
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?这是fork的内核源代码的链接:http://lxr.linux.no/linux+v2.6.32/kernel/fork.c#L10
编辑(从评论中提取):
我正在研究泄漏检测工具,当子进程删除父进程分配的内存时,此工具会检测到double free.为了克服这一点,我将覆盖fork(),并且只要有a fork(),父进程的内存分配表将被复制到子进程.
我正在尝试一些内在函数,因为我需要一个O (1)类似于memcmp()固定输入大小的复杂性函数。我最终写了这个:
#include <stdint.h>
#include <emmintrin.h>
int64_t f (int64_t a[4], int64_t b[4]) {
__m128i *x = (void *) a, *y = (void *) b, r[2], t;
int64_t *ret = (void *) &t;
r[0] = _mm_xor_si128(x[0], y[0]);
r[1] = _mm_xor_si128(x[1], y[1]);
t = _mm_or_si128(r[0], r[1]);
return (ret[0] | ret[1]);
}
Run Code Online (Sandbox Code Playgroud)
编译后会变成这样:
f:
movdqa xmm0, XMMWORD PTR [rdi]
movdqa xmm1, XMMWORD PTR [rdi+16]
pxor xmm0, XMMWORD PTR [rsi]
pxor xmm1, XMMWORD PTR [rsi+16]
por xmm0, xmm1
movq rdx, …Run Code Online (Sandbox Code Playgroud) 我打电话给GCC是这样的:
$ gcc -I/usr/include/SDL2 -D_REENTRANT -Ibuild -I. -S -fverbose-asm -O2 -m64 -mpc64 -mfpmath=both -fipa-pta -ftree-loop-linear -floop-interchange -floop-strip-mine -floop-block -ftree-loop-distribution -ftree-loop-distribute-patterns -funswitch-loops -ftree-vectorize -march=core-avx-i -c algo/collision.c -o build/collision.s
Run Code Online (Sandbox Code Playgroud)
重要的选择是:
-S : output assembly
-ftree-vectorize : vectorize loops
-march=core-avx-i : enable "MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
: AVX, AES, PCLMUL, FSGSBASE, RDRND and F16C
: instruction set support."
Run Code Online (Sandbox Code Playgroud)
这是汇编之前的来源:
#include "collision.h"
int8_t currentField[FIELD_W][FIELD_H];
// Clear and rebuild the field based on the objects with a gravity well
void buildField (const …Run Code Online (Sandbox Code Playgroud)