content
stringlengths
263
5.24M
pred_label
stringclasses
1 value
pred_score_pos
float64
0.6
1
#include <stdlib.h> #include <string.h> #include <stdio.h> #define ERR(str, chr) if(opterr){fprintf(stderr, "%s%s%c\n", argv[0], str, chr);} int opterr = 1; int optind = 1; int optopt; char *optarg; int getopt (int argc, char **argv, char *opts) { static int sp = 1; register c; register char *cp; ...
__label__POS
0.913503
#include <stdlib.h> #include <sys/types.h> #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <libnet.h> #define NAMELEN 28 static int nettrans(char*, char*, int na, char*, int); /* * announce a network service. */ int announce(char *addr, char *dir) { int c...
__label__POS
0.865
#include <stdlib.h> #include <sys/types.h> #include <string.h> #include <fcntl.h> #include <stdio.h> #include <unistd.h> #include <libnet.h> #define NAMELEN 28 static int call(char *clone, char *dest, int *cfdp, char *dir, char *local) { int fd, cfd; int n; char name[3*NAMELEN+5]; char data[3*NAMELEN+10]; char *...
__label__POS
0.75287
#include <math.h> #include <errno.h> /* * bug: should detect overflow, set errno = ERANGE, and return +/- HUGE_VAL */ double strtod(const char *cp, char **endptr) { double num, dem; extern double pow10(int); int neg, eneg, dig, predig, exp, c; const char *p; p = cp; num = 0; neg = 0; dig = 0; predig = 0; ...
__label__POS
0.954151
#include <stdlib.h> #include <errno.h> #include <limits.h> #define UVLONG_MAX (1LL<<63) unsigned long long strtoull(char *nptr, char **endptr, int base) { char *p; unsigned long long n, nn, m; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;; p++) { ...
__label__POS
0.881322
#include <stdlib.h> #include <limits.h> #include <errno.h> long strtol(const char *nptr, char **endptr, int base) { const char *p; long n, nn; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;;p++){ switch(*p){ case ' ': case '\t': case '\n': c...
__label__POS
0.773679
#include <time.h> /* * BUG: Doesn't do leap years in full glory, * or calendar changes. In 2038 the sign bit * will be needed in time_t, but we say it * can't be represented. */ static int dysize(int y) { y += 1900; /* arg is a tm_year, number of years since 1900 */ if((y%4) == 0 && ((y%100) !=0 || (y%400) == 0...
__label__POS
0.69805
#include <stdlib.h> #include <errno.h> #include <limits.h> unsigned long strtoul(const char *nptr, char **endptr, int base) { const char *p; unsigned long n, nn; int c, ovfl, neg, v, ndig; p = (char*)nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;;p++){ switch(*p){ case ' ': c...
__label__POS
0.60437
#include <stdlib.h> #include <limits.h> #include <errno.h> #define VLONG_MAX ~(1LL<<63) #define VLONG_MIN (1LL<<63) long long strtoll(char *nptr, char **endptr, int base) { char *p; long long n, nn, m; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;; ...
__label__POS
0.706673
#include "lib.h" #include <unistd.h> #include <string.h> #include <stdio.h> #include <errno.h> #include <stdlib.h> #include "sys9.h" #include "dir.h" int rename(const char *from, const char *to) { int n; char *f, *t; Dir *d, nd; if(access(to, 0) >= 0){ if(_REMOVE(to) < 0){ _syserrno(); return -1; } } ...
__label__POS
0.952091
#include "lib.h" #include <stdio.h> #include <string.h> #include <stdlib.h> #include "sys9.h" #include "dir.h" static char qsep[] = " \t\r\n"; static char* qtoken(char *s) { int quoting; char *t; quoting = 0; t = s; /* s is output string, t is input string */ while(*t!='\0' && (quoting || strchr(qsep, *t)==nil)...
__label__POS
0.668754
#include "lib.h" #include <string.h> #include "sys9.h" #include "dir.h" uint _convD2M(Dir *d, uchar *buf, uint nbuf) { uchar *p, *ebuf; char *sv[4]; int i, ns, nsv[4], ss; if(nbuf < BIT16SZ) return 0; p = buf; ebuf = buf + nbuf; sv[0] = d->name; sv[1] = d->uid; sv[2] = d->gid; sv[3] = d->muid; ns = 0;...
__label__POS
0.757997
#include "lib.h" #include <string.h> #include <stdlib.h> #include "sys9.h" #include "dir.h" static int statcheck(uchar *buf, uint nbuf) { uchar *ebuf; int i; ebuf = buf + nbuf; buf += STATFIXLEN - 4 * BIT16SZ; for(i = 0; i < 4; i++){ if(buf + BIT16SZ > ebuf) return -1; buf += BIT16SZ + GBIT16(buf); } ...
__label__POS
0.875778
#define _BSDTIME_EXTENSION #include "lib.h" #include <sys/stat.h> #include <stdlib.h> #include "sys9.h" #include <string.h> extern int errno; Fdinfo _fdinfo[OPEN_MAX]; /* called from _envsetup, either with the value of the environment variable _fdinfo (from s to se-1), or with s==0 if there was no _fdinfo */ s...
__label__POS
0.715826
#include <stdlib.h> #include <string.h> #include <stdio.h> #include <sys/types.h> #include <termios.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include "sys9.h" #include "lib.h" #include "dir.h" #define CESC '\\' #define CINTR 0177 /* DEL */ #define CQUIT 034 /* FS, cntl | */ #define CERASE 010 /* BS...
__label__POS
0.889657
#include <math.h> #include <errno.h> /* floating point Bessel's function of the first and second kinds and of integer order. int n; double x; jn(n,x); returns the value of Jn(x) for all integer values of n and all real values of x. There are no error returns. Calls j0, j1. For n=0, j0(x) is called, fo...
__label__POS
0.932357
#include <math.h> #include <errno.h> #include <limits.h> double pow(double x, double y) /* return x ^ y (exponentiation) */ { double xy, y1, ye; long i; int ex, ey, flip; if(y == 0.0) return 1.0; /* prevent infinite loop */ if(isNaN(x) || isNaN(y)) return NaN(); if(isInf(x, 0)) return x; if(isInf(y, 0)...
__label__POS
0.693192
Plan 9 from Bell Labs 127 holes free 213327872 bytes free l1: int split i&d, 4 ways 256 sets 32 bytes/line; can WB; can write-allocate; l1 I policy VIPT l2: ext unified, 8 ways 512 sets 32 bytes/line; can WT; can WB; can write-allocate fp: arm arch VFPv3+ with null subarch 1000 mips (single-issue), 1980 mips (dual-...
__label__POS
0.808638
#include <u.h> #include <libc.h> #include <fcall.h> static uchar* gstring(uchar *p, uchar *ep, char **s) { uint n; if(p+BIT16SZ > ep) return nil; n = GBIT16(p); p += BIT16SZ - 1; if(p+n+1 > ep) return nil; /* move it down, on top of count, to make room for '\0' */ memmove(p, p + 1, n); p[n] = '\0'; *s = ...
__label__POS
0.817847
#include <u.h> #include <libc.h> #include <fcall.h> int statcheck(uchar *buf, uint nbuf) { uchar *ebuf; int i; ebuf = buf + nbuf; if(nbuf < STATFIXLEN || nbuf != BIT16SZ + GBIT16(buf)) return -1; buf += STATFIXLEN - 4 * BIT16SZ; for(i = 0; i < 4; i++){ if(buf + BIT16SZ > ebuf) return -1; buf += BIT1...
__label__POS
0.833562
#include <u.h> #include <libc.h> #include <fcall.h> static uchar* pstring(uchar *p, char *s) { uint n; if(s == nil){ PBIT16(p, 0); p += BIT16SZ; return p; } n = strlen(s); /* * We are moving the string before the length, * so you can S2M a struct into an existing message */ memmove(p + BIT16SZ, s, ...
__label__POS
0.892522
#include <u.h> #include <libc.h> #include <fcall.h> uint sizeD2M(Dir *d) { char *sv[4]; int i, ns; sv[0] = d->name; sv[1] = d->uid; sv[2] = d->gid; sv[3] = d->muid; ns = 0; for(i = 0; i < 4; i++) if(sv[i]) ns += strlen(sv[i]); return STATFIXLEN + ns; } uint convD2M(Dir *d, uchar *buf, uint nbuf) { u...
__label__POS
0.718956
#include <u.h> #include <libc.h> #include <fcall.h> static long dirpackage(uchar *buf, long ts, Dir **d) { char *s; long ss, i, n, nn, m; *d = nil; if(ts <= 0) return 0; /* * first find number of all stats, check they look like stats, & size all associated strings */ ss = 0; n = 0; for(i = 0; i < ts; i...
__label__POS
0.966566
#include <u.h> #include <libc.h> #include <ctype.h> static int nettrans(char*, char*, int na, char*, int); enum { Maxpath= 256, }; /* * announce a network service. */ int announce(char *addr, char *dir) { int ctl, n, m; char buf[Maxpath]; char buf2[Maxpath]; char netdir[Maxpath]; char naddr[Maxpath]; char ...
__label__POS
0.934807
#include <u.h> #include <libc.h> #include <mp.h> #include <libsec.h> enum { TLSFinishedLen = 12, HFinished = 20, }; static int finished(int hand, int isclient) { int i, n; uchar buf[500], buf2[500]; buf[0] = HFinished; buf[1] = TLSFinishedLen>>16; buf[2] = TLSFinishedLen>>8; buf[3] = TLSFinishedLen; n = TLS...
__label__POS
0.726125
#include <u.h> #include <libc.h> #define TZSIZE 150 static void readtimezone(void); static int rd_name(char**, char*); static int rd_long(char**, long*); static struct { char stname[4]; char dlname[4]; long stdiff; long dldiff; long dlpairs[TZSIZE]; } timezone; #define SEC2MIN 60L #define SEC2HOUR (60L*SEC2MIN) ...
__label__POS
0.609605
#include <u.h> #include <libc.h> /* * Reads a floating-point number by interpreting successive characters * returned by (*f)(vp). The last call it makes to f terminates the * scan, so is not a character in the number. It may therefore be * necessary to back up the input stream up one byte after calling charstod....
__label__POS
0.811715
#include <u.h> #include <libc.h> #define Bit(i) (7-(i)) /* N 0's preceded by i 1's, T(Bit(2)) is 1100 0000 */ #define T(i) (((1 << (Bit(i)+1))-1) ^ 0xFF) /* 0000 0000 0000 0111 1111 1111 */ #define RuneX(i) ((1 << (Bit(i) + ((i)-1)*Bitx))-1) enum { Bitx = Bit(1), Tx = T(1), /* 1000 0000 */ Rune1 = (1<<(Bit(0)+0...
__label__POS
0.903177
#include <u.h> #include <libc.h> #define UVLONG_MAX (1LL<<63) uvlong strtoull(char *nptr, char **endptr, int base) { char *p; uvlong n, nn, m; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;; p++) { switch(*p) { case ' ': case '\t': case '\n':...
__label__POS
0.938414
#include <u.h> #include <libc.h> #define LONG_MAX 2147483647L #define LONG_MIN -2147483648L long strtol(char *nptr, char **endptr, int base) { char *p; long n, nn, m; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;; p++) { switch(*p) { case ' ': ...
__label__POS
0.763142
#include <u.h> #include <libc.h> static char qsep[] = " \t\r\n"; static char* qtoken(char *s, char *sep) { int quoting; char *t; quoting = 0; t = s; /* s is output string, t is input string */ while(*t!='\0' && (quoting || utfrune(sep, *t)==nil)){ if(*t != '\''){ *s++ = *t++; continue; } /* *t is a ...
__label__POS
0.873119
#include <u.h> #include <libc.h> #define ULONG_MAX 4294967295UL ulong strtoul(char *nptr, char **endptr, int base) { char *p; ulong n, nn, m; int c, ovfl, neg, v, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;;p++){ switch(*p){ case ' ': case '\t': case '\n': c...
__label__POS
0.858324
#include <u.h> #include <libc.h> #define VLONG_MAX ~(1LL<<63) #define VLONG_MIN (1LL<<63) vlong strtoll(char *nptr, char **endptr, int base) { char *p; vlong n, nn, m; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;; p++) { switch(*p) { case ' ': ...
__label__POS
0.723396
#include <u.h> #include <libc.h> #include "fmtdef.h" static int runeFmtStrFlush(Fmt *f) { Rune *s; int n; if(f->start == nil) return 0; n = (int)(uintptr)f->farg; n *= 2; s = f->start; f->start = realloc(s, sizeof(Rune)*n); if(f->start == nil){ f->farg = nil; f->to = nil; f->stop = nil; free(s); r...
__label__POS
0.978189
#include <u.h> #include <libc.h> #include "fmtdef.h" static int fmtStrFlush(Fmt *f) { char *s; int n; if(f->start == nil) return 0; n = (int)(uintptr)f->farg; n *= 2; s = f->start; f->start = realloc(s, n); if(f->start == nil){ f->farg = nil; f->to = nil; f->stop = nil; free(s); return 0; } f->f...
__label__POS
0.972669
原文地址:https://mp.weixin.qq.com/s/9rKG1HcryZTzzgmHeOXQKw # sed:小工具,大用处 ![图片](https://mmbiz.qpic.cn/mmbiz_gif/ibj9nANUc6z74QqKQCcRGEhFTHhfr5A1sViar95KE8EmSobNxbBjW0h8GEsK9mo1Y2IsmpkqGEqBQUCe4mNDc2Dg/640?wx_fmt=gif&tp=wxpic&wxfrom=5&wx_lazy=1) 在学习工作中发现,在Linux中除了ll、ls、less等查看命令,sed与awk是使用最为频繁的文本编辑命令,这两个工具可以使用最简单的方法...
__label__POS
0.665739
# POSIX编程的代码示例 以下是10个Linux POSIX编程的代码示例,涵盖了线程、进程间通信和文件操作等多个方面。每个示例都附带简要说明。 ### 1. 创建线程 ``` #include <pthread.h> #include <stdio.h> void* threadFunction(void* arg) { printf("Hello from thread!\n"); return NULL; } int main() { pthread_t thread; pthread_create(&thread, NULL, threadFunction, NULL);...
__label__POS
0.995282
原文地址:https://www.tecmint.com/linux-commands-for-sysadmins/ # 50 Must-Know Linux Commands: From Newbie to SysAdmin Pro For someone new to **Linux**, using it can still feel challenging, even with [user-friendly distributions](https://www.tecmint.com/top-most-popular-linux-distributions/) like **Ubuntu** and **Mint...
__label__POS
0.907847
# Shell脚本:常用100个shell命令使用讲解题 在大多数的Linux和Unix系统、及其他类Unix系统中,Shell是用户与操作系统内核交互的主要方式。作为一种强大的命令行解释器,它也支持编程功能,用户可以写脚本来处理各种任务。 无论你是新手还是专业人士,掌握Shell命令都是必不可少的技能。在这篇文章中,我将逐个解读和展示Shell脚本中最常用的100个命令,并为每个命令提供实际的例子。 ------ # 目录 - 文件操作命令 - 搜索命令 - 目录操作命令 - 权限操作命令 - 网络操作命令 - 进程和系统控制命令 - 文本操作命令 - 压缩与解压命令 - 磁盘使用管理命令 - 包管理命令 - 进程管...
__label__POS
0.981419
# 一篇文章让你彻底掌握 Shell ## 目录 - 什么是 shell - 什么是 shell 脚本 - Shell 环境 - - 指定脚本解释器 - 模式 - - 交互模式 - 非交互模式 - 基本语法 - - 解释器 - 注释 - echo - printf - 变量 - - 变量命名原则 - 声明变量 - 只读变量 - 删除变量 - 变量类型 - 字符串 - - 单引号和双引号 - 拼接字符串 - 获取字符串长度 - 截取子字符串 - 查找子字符串 - 数组 - - 创建数组 - 访问数组元素 - 访问数组长度 - 向数组中添加元...
__label__POS
0.660127
#include <u.h> #include <libc.h> #include <mp.h> #include <libsec.h> #define STRLEN(s) (sizeof(s)-1) uchar* decodePEM(char *s, char *type, int *len, char **new_s) { uchar *d; char *t, *e, *tt; int n; *len = 0; /* * find the correct section of the file, stripping garbage at the beginning and end. * the data...
__label__POS
0.649902
#include "os.h" #include <mp.h> #include <libsec.h> typedef struct State{ QLock lock; int seeded; uvlong seed; DES3state des3; } State; static State x917state; static void X917(uchar *rand, int nrand) { int i, m, n8; uvlong I, x; /* 1. Compute intermediate value I = Ek(time). */ I = nsec(); triple_block_...
__label__POS
0.601398
#include <u.h> #include <libc.h> #include <auth.h> #include <mp.h> #include <libsec.h> static char* readfile(char *name) { int fd; char *s; Dir *d; fd = open(name, OREAD); if(fd < 0) return nil; if((d = dirfstat(fd)) == nil) { close(fd); return nil; } s = malloc(d->length + 1); if(s == nil || readn(fd,...
__label__POS
0.969501
#include "os.h" #include <mp.h> #include <libsec.h> #include "dat.h" mpint* mpfactorial(ulong n) { int i; ulong k; unsigned cnt; int max, mmax; mpdigit p, pp[2]; mpint *r, *s, *stk[31]; cnt = 0; max = mmax = -1; p = 1; r = mpnew(0); for(k=2; k<=n; k++){ pp[0] = 0; pp[1] = 0; mpvecdigmuladd(&p, 1, (mp...
__label__POS
0.898111
#include "os.h" #include <mp.h> // extended euclid // // For a and b it solves, d = gcd(a,b) and finds x and y s.t. // ax + by = d // // Handbook of Applied Cryptography, Menezes et al, 1997, pg 67 void mpeuclid(mpint *a, mpint *b, mpint *d, mpint *x, mpint *y) { mpint *tmp, *x0, *x1, *x2, *y0, *y1, *y2, *q, *r; i...
__label__POS
0.724018
#include "os.h" #include <mp.h> #include "dat.h" static mpdigit _mptwodata[1] = { 2 }; static mpint _mptwo = { 1, 1, 1, _mptwodata, MPstatic }; mpint *mptwo = &_mptwo; static mpdigit _mponedata[1] = { 1 }; static mpint _mpone = { 1, 1, 1, _mponedata, MPstatic }; mpint *mpone = &_mpone; static mpdigit _mpze...
__label__POS
0.952006
#include "os.h" #include <mp.h> #include <libsec.h> #include "dat.h" static int to64(mpint *b, char *buf, int len) { uchar *p; int n, rv; p = nil; n = mptobe(b, nil, 0, &p); if(n < 0) return -1; rv = enc64(buf, len, p, n); free(p); return rv; } static int to32(mpint *b, char *buf, int len) { uchar *p; in...
__label__POS
0.907585
#include "os.h" #include <mp.h> #include "dat.h" #define LO(x) ((x) & ((1<<(Dbits/2))-1)) #define HI(x) ((x) >> (Dbits/2)) static void mpdigmul(mpdigit a, mpdigit b, mpdigit *p) { mpdigit x, ah, al, bh, bl, p1, p2, p3, p4; int carry; // half digits ah = HI(a); al = LO(a); bh = HI(b); bl = LO(b); // partial ...
__label__POS
0.791357
#include "os.h" #include <mp.h> #include <libsec.h> // chinese remainder theorem // // handbook of applied cryptography, menezes et al, 1997, pp 610 - 613 struct CRTpre { int n; // number of moduli mpint **m; // pointer to moduli mpint **c; // precomputed coefficients mpint **p; // precomputed products mpint...
__label__POS
0.72987
#include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "../port/error.h" static char Ebadlogctl[] = "unknown log ctl message"; void logopen(Log *alog) { lock(alog); if(waserror()){ unlock(alog); nexterror(); } if(alog->opens == 0){ if(alog->nlog == 0) alog->nl...
__label__POS
0.953665
#!/usr/bin/env python3 # 2017, Georg Sauthoff <mail@gms.tf>, GPLv3 import sys def skip_comments(lines): state = 0 for line in lines: n = len(line) l = '' p = 0 while p < n: if state == 0: a = line.find('//', p) b = line.find('/*', p) if a > -1 and (a < b or b == -1):...
__label__POS
0.947681
#include <u.h> #include <libc.h> #include <draw.h> #include <event.h> #include "mahjongg.h" Click NC = { -1, 0, 0, }; Click Cl(int d, int x, int y) { return (Click){d, x, y}; } int eqcl(Click c1, Click c2) { return c1.d == c2.d && c1.x == c2.x && c1.y == c2.y; } int freeup(Click c) { if(c.d == Depth -1 || (leve...
__label__POS
0.917221
#include <u.h> #include <libc.h> #include <draw.h> #include <event.h> #include "mahjongg.h" /* * mark tiles that partially obscure the given tile. * relies on Depth*Dxy <= Tilex/2 */ void markabove(int d, int x, int y) { int dx, dy; for(d++; d < Depth; d++) for(dx = -1; dx <= 2; dx++) for(dy = -1; dy <= 2...
__label__POS
0.869354
#include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON value json j = { {"number", 1}, {"string", "foo"}, {"array", {1, 2}} }; // read-only access // output element with JSON pointer "/number" std::cout << j["/number"_json_poin...
__label__POS
0.9723
#include "u.h" #include "../port/lib.h" /* * The code makes two assumptions: strlen(ld) is 1 or 2; latintab[i].ld can be a * prefix of latintab[j].ld only when j<i. */ struct cvlist { char *ld; /* must be seen before using this conversion */ char *si; /* options for last input characters */ Rune *so; /* the co...
__label__POS
0.989577
# Object Order The [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". As such, an implementation does not need to preserve any specific order of object keys. The default type `nlohmann::json` uses a `std::map` to store JSON objects,...
__label__POS
0.995701
#include <cstdlib> #include <iostream> #include <sstream> using namespace std; void build_code(int max_args) { stringstream ss; ss << "#define NLOHMANN_JSON_EXPAND( x ) x" << endl; ss << "#define NLOHMANN_JSON_GET_MACRO("; for (int i = 0 ; i < max_args ; i++) ss << "_" << i + 1 << ", "; ss...
__label__POS
0.824358
#include <u.h> #include <libc.h> #include <../boot/boot.h> /* int plumb(char *dir, char *dest, int *efd, char *here) { char buf[128]; char name[128]; int n; sprint(name, "%s/clone", dir); efd[0] = open(name, ORDWR); if(efd[0] < 0) return -1; n = read(efd[0], buf, sizeof(buf)-1); if(n < 0){ close(efd[0]); ...
__label__POS
0.996651
#include <u.h> #include <libc.h> #include <../boot/boot.h> uchar statbuf[Statsz]; int cache(int fd) { int argc, i, p[2]; char *argv[5], bd[32], buf[256], partition[64], *pp; if(stat("/boot/cfs", statbuf, sizeof statbuf) < 0) return fd; *partition = 0; bind("#S", "/dev", MAFTER); readfile("#e/cfs", buf, siz...
__label__POS
0.937671
#include <u.h> #include <libc.h> #include <auth.h> #include <fcall.h> #include "../boot/boot.h" static long lusertime(char*); char *timeserver = "#s/boot"; void settime(int islocal, int afd, char *rp) { int n, f; Dir dir[2]; char timebuf[64]; static int timeset; if(timeset) return; print("time..."); if(isl...
__label__POS
0.665019
# 🤸‍♀️🤾‍♀️🤸‍♂️硬核总结linux环境开发工具,包含linux,虚拟机,编译器,编辑器,测试工具,加密工具 ## 🚩源码(提取码1024) - [linux-5.15(最新版本).tar](https://pan.baidu.com/s/1cRp-cH7Cmn9AWmxtIKetxw) - [linux-5.13.5(稳定版).tar](https://pan.baidu.com/s/1HNYQ6UktSU5UxRVWZEELHg) - [linux-5.10.53(长期版).tar](https://pan.baidu.com/s/1yLIRgxPrbmYGw1JLXWNjkg) - [linux-5.4....
__label__POS
0.925439
#include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "../port/error.h" #include "../port/netif.h" #include "etherif.h" #include "ethermii.h" int mii(Mii* mii, int mask) { MiiPhy *miiphy; int bit, oui, phyno, rmask; u32int id; /* * Probe through mii...
__label__POS
0.644016
Plan 9 from Bell Labs 127 holes free 213327872 bytes free l1: int split i&d, 4 ways 256 sets 32 bytes/line; can WB; can write-allocate; l1 I policy VIPT l2: ext unified, 8 ways 512 sets 32 bytes/line; can WT; can WB; can write-allocate fp: arm arch VFPv3+ with null subarch 1000 mips (single-issue), 1980 mips (dual-...
__label__POS
0.808638
#include <u.h> #include <libc.h> #include <fcall.h> static uchar* gstring(uchar *p, uchar *ep, char **s) { uint n; if(p+BIT16SZ > ep) return nil; n = GBIT16(p); p += BIT16SZ - 1; if(p+n+1 > ep) return nil; /* move it down, on top of count, to make room for '\0' */ memmove(p, p + 1, n); p[n] = '\0'; *s = ...
__label__POS
0.817847
#include <u.h> #include <libc.h> #include <fcall.h> int statcheck(uchar *buf, uint nbuf) { uchar *ebuf; int i; ebuf = buf + nbuf; if(nbuf < STATFIXLEN || nbuf != BIT16SZ + GBIT16(buf)) return -1; buf += STATFIXLEN - 4 * BIT16SZ; for(i = 0; i < 4; i++){ if(buf + BIT16SZ > ebuf) return -1; buf += BIT1...
__label__POS
0.833562
#include <u.h> #include <libc.h> #include <fcall.h> static uchar* pstring(uchar *p, char *s) { uint n; if(s == nil){ PBIT16(p, 0); p += BIT16SZ; return p; } n = strlen(s); /* * We are moving the string before the length, * so you can S2M a struct into an existing message */ memmove(p + BIT16SZ, s, ...
__label__POS
0.892522
#include <u.h> #include <libc.h> #include <fcall.h> uint sizeD2M(Dir *d) { char *sv[4]; int i, ns; sv[0] = d->name; sv[1] = d->uid; sv[2] = d->gid; sv[3] = d->muid; ns = 0; for(i = 0; i < 4; i++) if(sv[i]) ns += strlen(sv[i]); return STATFIXLEN + ns; } uint convD2M(Dir *d, uchar *buf, uint nbuf) { u...
__label__POS
0.718956
#include <u.h> #include <libc.h> #include <fcall.h> static long dirpackage(uchar *buf, long ts, Dir **d) { char *s; long ss, i, n, nn, m; *d = nil; if(ts <= 0) return 0; /* * first find number of all stats, check they look like stats, & size all associated strings */ ss = 0; n = 0; for(i = 0; i < ts; i...
__label__POS
0.966566
#include <u.h> #include <libc.h> #include <ctype.h> static int nettrans(char*, char*, int na, char*, int); enum { Maxpath= 256, }; /* * announce a network service. */ int announce(char *addr, char *dir) { int ctl, n, m; char buf[Maxpath]; char buf2[Maxpath]; char netdir[Maxpath]; char naddr[Maxpath]; char ...
__label__POS
0.934807
#include <u.h> #include <libc.h> #include <mp.h> #include <libsec.h> enum { TLSFinishedLen = 12, HFinished = 20, }; static int finished(int hand, int isclient) { int i, n; uchar buf[500], buf2[500]; buf[0] = HFinished; buf[1] = TLSFinishedLen>>16; buf[2] = TLSFinishedLen>>8; buf[3] = TLSFinishedLen; n = TLS...
__label__POS
0.724336
#include <u.h> #include <libc.h> /* * Reads a floating-point number by interpreting successive characters * returned by (*f)(vp). The last call it makes to f terminates the * scan, so is not a character in the number. It may therefore be * necessary to back up the input stream up one byte after calling charstod....
__label__POS
0.811715
#include <u.h> #include <libc.h> #define Bit(i) (7-(i)) /* N 0's preceded by i 1's, T(Bit(2)) is 1100 0000 */ #define T(i) (((1 << (Bit(i)+1))-1) ^ 0xFF) /* 0000 0000 0000 0111 1111 1111 */ #define RuneX(i) ((1 << (Bit(i) + ((i)-1)*Bitx))-1) enum { Bitx = Bit(1), Tx = T(1), /* 1000 0000 */ Rune1 = (1<<(Bit(0)+0...
__label__POS
0.903177
#include <u.h> #include <libc.h> double pow(double x, double y) /* return x ^ y (exponentiation) */ { double xy, y1, ye; long i; int ex, ey, flip; if(y == 0.0) return 1.0; /* prevent infinite loop */ if(isNaN(x) || isNaN(y)) return NaN(); if(isInf(x, 0)) return x; if(isInf(y, 0)) return x == 0 || x =...
__label__POS
0.714836
# 142、假设现有n个有序数组,如何合并成一个有序数组? 假设有n个有序数组A1、A2、...、An,每个数组的长度分别为L1、L2、...、Ln,合并成一个有序数组的步骤如下: 从每个数组中取出第一个元素,将它们放入一个最小堆中; 取出堆顶元素(即当前n个数组中最小的元素),将它放入结果数组中; 如果该元素来自某个数组的末尾,则不再将它的下一个元素加入堆中; 如果堆为空,则说明所有元素都已经被取出,合并结束。 时间复杂度为O(knlogn),其中k为数组中元素的平均数量。 示例代码如下: ``` vector<int> mergeKSortedArrays(vector<vector<int>>& arrays) ...
__label__POS
0.999913
# 161、 QMap类/QHash类/QVectoro类作用和区别? 在Qt中,QMap类、QHash类和QVector类都是用来管理数据的容器类,它们的作用和区别如下: 1. QMap类 QMap类是一种有序的映射容器,它可以将一个键值对映射到另一个键值对,且键值对是按照键的顺序进行排序的。QMap类通常用于对一组数据进行映射操作,常见的操作包括查找、插入、删除等。例如: ``` QMap<QString, int> map; map.insert("Tom", 18); map.insert("Jack", 20); map.insert("Lucy", 17); int age = map.value("Tom"); ...
__label__POS
0.931252
#include <u.h> #include <libc.h> #define UVLONG_MAX (1LL<<63) uvlong strtoull(char *nptr, char **endptr, int base) { char *p; uvlong n, nn, m; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;; p++) { switch(*p) { case ' ': case '\t': case '\n':...
__label__POS
0.938414
# 操作系统级虚拟化实现 ## 1.2 操作系统级虚拟化实现 ### 1.2.1 chroot 容器的概念始于 1979 年的 UNIX chroot,它是一个 UNIX 操作系统上的系统调用,用于将一个进程及其子进程的根目录改变到文件系统中的一个新位置,让这些进程只能访问到该目录。这个功能的想法是为每个进程提供独立的磁盘空间。其后在 1982年,它被加入到了 BSD 系统中。 ### 1.2.2 LXC LXC 的意思是 LinuX Containers,它是第一个最完善的 Linux 容器管理器的实现方案,是通过 cgroups 和 Linux 名字空间namespace实现的。LXC 存在于 liblxc 库中,提供了各种...
__label__POS
0.786749
# 141、如何反转链表?判断链表是否是回文链表?如何判断链表相交? 1. 反转链表的步骤如下: - 新建一个空链表,作为反转后的链表; - 遍历原链表,将每个节点插入到新链表的头部,即使新节点成为新链表的头节点; - 返回新链表。 示例代码如下: ``` Node* reverseList(Node* head) { Node* newHead = NULL; Node* cur = head; while (cur != NULL) { Node* next = cur->next; cur->next = newHead; newHead = cur...
__label__POS
0.988508
# 192、 分库分表(垂直分表、垂直分库、水平分表、水平分库) ? 分库分表是一种常见的数据库水平和垂直扩展方案,用于解决单一数据库性能瓶颈问题。分库分表的实现方式有垂直分表、垂直分库、水平分表和水平分库四种方式。 1. 垂直分表:将一张表按照列拆分成多个表,每个表只存储部分列的数据,不同的表可以存储在不同的数据库中。垂直分表的优点是可以将不同的关注点拆分到不同的表中,减少表的冗余和重复,提高查询效率。缺点是如果需要查询多个表的数据则需要进行关联查询,增加了查询的复杂度。 2. 垂直分库:将不同的业务数据存储在不同的数据库中,每个数据库只处理特定的业务逻辑。垂直分库的优点是可以提高数据库读写的并发性,减少单库数据量,降低单点故...
__label__POS
0.999683
#include <u.h> #include <libc.h> #define LONG_MAX 2147483647L #define LONG_MIN -2147483648L long strtol(char *nptr, char **endptr, int base) { char *p; long n, nn, m; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;; p++) { switch(*p) { case ' ': ...
__label__POS
0.763142
#include <u.h> #include <libc.h> static char qsep[] = " \t\r\n"; static char* qtoken(char *s, char *sep) { int quoting; char *t; quoting = 0; t = s; /* s is output string, t is input string */ while(*t!='\0' && (quoting || utfrune(sep, *t)==nil)){ if(*t != '\''){ *s++ = *t++; continue; } /* *t is a ...
__label__POS
0.873119
# 103、Qt的智能指针,QSharePoint和shared_ptr有什么区别,weak_ptr呢? Qt智能指针是一种特殊的指针,它可以指向另一个指针。它可以用来创建复杂的数据结构,如链表或树结构。 QSharePoint是一种智能指针,它可以自动管理指向的对象的内存分配和释放,从而实现自动内存管理。 shared_ptr也是一种智能指针,它可以跟踪指向的对象的引用计数,从而保证在没有任何引用的情况下,可以自动释放指向的对象。 weak_ptr是一种特殊的shared_ptr,它可以指向shared_ptr指向的对象,但不会增加指向对象的引用计数。它可以用来避免循环引用导致的内存泄漏问题。 在Qt中,指针指针(Poi...
__label__POS
0.994078
# 172、QtChart (图表、曲线图、饼状图、柱形、拆线图等) ? QtChart是Qt自带的图表库,用于绘制各种类型的图表,例如曲线图、饼状图、柱形图、折线图等。使用QtChart可以方便地将数据可视化,并支持用户交互和定制化设置。下面介绍QtChart中常用的几种图表类型及其使用方法。 1. 曲线图 曲线图用于展示一段时间内某个变量的变化趋势,例如温度、湿度、压力等。使用QtChart绘制曲线图的步骤如下: - 创建QChart对象,并设置标题和坐标轴。 - 创建QLineSeries对象,设置曲线的名称和数据。 - 将QLineSeries对象添加到QChart对象中。 - 创建一个QChartView对象,并将Q...
__label__POS
0.729134
# 140、向链表的末尾添加一个元素?从链表尾部到头部打印结点信息?如何合并两个有序链表? 向链表的末尾添加一个元素的步骤如下: 新建一个节点,为其赋值; 遍历链表,找到最后一个节点; 将最后一个节点的next指针指向新节点; 新节点的next指针赋值为NULL,表示链表的末尾。 从链表尾部到头部打印节点信息的步骤如下: 遍历链表,将每个节点的值存放在栈中; 遍历栈,将栈中的值弹出并输出,即为链表的逆序输出。 合并两个有序链表的步骤如下: 新建一个空链表,作为合并后的链表; 遍历两个有序链表,比较当前两个链表的节点值,将较小的节点插入到新链表中; 如果其中一个链表已经遍历完,将另一个链表剩余的节点插...
__label__POS
0.748177
# 167、Graphics View图形视图框架结构? Graphics View是Qt中用于显示和处理大量图形元素的框架,其主要包括以下几个重要的类和组件: 1. QGraphicsItem和QGraphicsScene:QGraphicsItem类是Graphics View框架中所有图形项的基类,它定义了所有图形项的共同属性和行为。QGraphicsScene类是Graphics View框架中的场景类,它管理着所有的图形项,并且提供了对它们进行操作的接口。 2. QGraphicsView:QGraphicsView类是Graphics View框架中的视图类,它用于在屏幕上显示QGraphicsScene中的内容,并...
__label__POS
0.997335
#include <u.h> #include <libc.h> #define ULONG_MAX 4294967295UL ulong strtoul(char *nptr, char **endptr, int base) { char *p; ulong n, nn, m; int c, ovfl, neg, v, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;;p++){ switch(*p){ case ' ': case '\t': case '\n': c...
__label__POS
0.858324
#include <u.h> #include <libc.h> #define VLONG_MAX ~(1LL<<63) #define VLONG_MIN (1LL<<63) vlong strtoll(char *nptr, char **endptr, int base) { char *p; vlong n, nn, m; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ for(;; p++) { switch(*p) { case ' ': ...
__label__POS
0.723396
#include <u.h> #include <libc.h> #include "fmtdef.h" static int runeFmtStrFlush(Fmt *f) { Rune *s; int n; if(f->start == nil) return 0; n = (int)(uintptr)f->farg; n *= 2; s = f->start; f->start = realloc(s, sizeof(Rune)*n); if(f->start == nil){ f->farg = nil; f->to = nil; f->stop = nil; free(s); r...
__label__POS
0.978189
# 162、QList 类/QLinkedList类作用? 在Qt中,QList类和QLinkedList类都是用来管理数据的容器类,它们的作用和区别如下: 1. QList类 QList类是一种动态数组容器,它可以存储任意类型的数据,并且支持动态增加和删除操作。QList类的内部实现是一个可变大小的数组,可以动态调整数组的大小以适应数据的存储需求。QList类通常用于存储一组数据,并且需要对数据进行动态操作,如排序、查找等。例如: ``` QList<int> list; list.append(1); list.append(2); list.append(3); int num = list.at(1); // 获取第2...
__label__POS
0.979964
#include <u.h> #include <libc.h> #include "fmtdef.h" static int fmtStrFlush(Fmt *f) { char *s; int n; if(f->start == nil) return 0; n = (int)(uintptr)f->farg; n *= 2; s = f->start; f->start = realloc(s, n); if(f->start == nil){ f->farg = nil; f->to = nil; f->stop = nil; free(s); return 0; } f->f...
__label__POS
0.972669
# Neutron实现网络虚拟化 ## 1. 云计算时代数据中心物理网络的问题 数据中心虚拟化成为了趋势,最典型的场景莫过于:对数据中心的服务器进行虚拟化,来提高资源利用率,同时降低单位能耗。 但是,随着数据中心虚拟化程度的不断提高、虚拟化服务器规模的不断扩大,带来了巨大的管理压力。===>这正是云计算诞生的原因。 在大规模虚拟化的基础上,实现了自动化管理和集中化管理,就是云计算的基本模型。 云计算的超大规模加上其特有的服务模式带来了诸多亟需解决的问题,这些问题中,首当其冲的就是网络问题 我们需要从两个角度去看: * 数据中心现有的物理网络,无法承载云计算机的超大规模 (详见1.1小节) * 数据中心现有的物理网络,无法满足云...
__label__POS
0.902237
# 块虚拟化过程 存储系统采用了块虚拟化技术,实现了存储池中资源的动态分配和扩展,提升了存储池中数据的读写响应速度,缩短了硬盘故障后的重构时间。 块虚拟化过程如图1所示。 图1 块虚拟化过程 ![image](https://user-images.githubusercontent.com/87458342/134517700-bbb8aec7-2280-4e8e-bf52-d4395a0719a2.png) 1. 存储系统所有硬盘划分为多个硬盘域。虚拟机业务中SAS硬盘用于安装虚拟机操作系统,NL-SAS和SATA硬盘用于存储业务数据。一个硬盘域里可以创建多个存储池。 2. 存储系统将各存储层的存储介质划分为固定大小的...
__label__POS
0.998976
# 169、Qt中事件过滤处理方法? Qt中的事件过滤器可以用于对某个对象的事件进行拦截和处理。事件过滤器是一个QObject对象,它可以安装到任何QObject派生类中,并且可以监听该对象的所有事件。当事件发生时,事件过滤器可以拦截并处理该事件,也可以将该事件转发给原始的事件接收者对象进行处理。 事件过滤器的处理方法如下: 1. 创建一个QObject派生类,实现其eventFilter()函数,该函数会在事件发生时被调用。 ``` class MyEventFilter : public QObject { Q_OBJECT public: explicit MyEventFilter(QObject *p...
__label__POS
0.957578
# 9、对QObject的理解 QObject 类是Qt 所有类的基类。 QObject是Qt对象模型的核心。这个模型的中心要素就是一种强大的叫做信号与槽无缝对象沟通机制。你可以用 connect() 函数来把一个信号连接到槽,也可以用disconnect() 函数来破坏这个连接。为了避免永无止境的通知循环,你可以用blockSignal() 函数来暂时阻塞信号。保护函数 connectNotify() 和 disconnectNotify() 可以用来跟踪连接。 对象树都是通过QObject 组织起来的,当以一个对象作为父类创建一个新的对象时,这个新对象会被自动加入到父类的 children() 队列中。这个父类有子类的所有...
__label__POS
0.668036
# 191、读写分离? 读写分离是一种数据库优化方案,通过将读操作和写操作分离到不同的服务器上,从而达到提高数据库性能和可用性的目的。读写分离的基本原理是:将写入操作集中在主服务器上,而将读操作分散到多个从服务器上,从而降低主服务器的读负载,提高数据库的并发处理能力。 读写分离的主要实现方式是:在应用程序中使用多个数据库连接,其中一个连接用于写操作,而其他连接则用于读操作。读写分离的优点包括: 1. 提高性能:通过将读操作分散到多个从服务器上,可以降低主服务器的读负载,提高数据库的并发处理能力。 2. 提高可用性:在主服务器出现故障时,可以通过从服务器提供读服务来保证系统的可用性。 3. 提高扩展性:通过增加从服务器的数量,可以...
__label__POS
0.999815
# 190、MySQL的主从复制? MySQL的主从复制是一种数据复制技术,可以将一个MySQL主服务器上的数据以异步方式复制到一个或多个MySQL从服务器上,从服务器上的数据与主服务器上的数据保持一致。主从复制可以帮助我们实现数据备份、读写分离、负载均衡等功能。 主从复制的基本原理如下: 1. 主服务器将写操作记录到二进制日志(binary log)中,包括对表的增删改操作。 2. 从服务器连接到主服务器,请求复制二进制日志中的数据。 3. 主服务器将二进制日志中的数据发送给从服务器,从服务器接收并应用这些数据。 4. 从服务器定期轮询主服务器,查找更新的二进制日志数据,并将这些数据应用到从服务器上。 在MySQL的主从复制中...
__label__POS
0.999665
# 详解存储子系统的虚拟化 随着存储虚拟化技术的越发成熟,存储虚拟化在企业中的应用越来越广。下面我们来介绍一下与存储虚拟化关系最近的计算机的存储子系统的虚拟化,看看存储子系统是怎么抽象虚拟的。 存储子系统的元素包括:磁盘、磁盘控制器、存储网络、磁盘阵列、卷管理层、目录虚拟层。具体看下面详细介绍。 1. 的虚拟化 磁盘控制器的工作就是根据驱动程序发来的磁盘读写信息,向磁盘发送scsi指令和数据。这个不减的虚拟化是大家最常用的虚拟化方式,raid就是典型代表,控制器将磁盘组成raid阵列模式,在此基础上,虚拟出多了lun ,通告给主机驱动。 2. 存储网络的虚拟化 目前存储系统,网络化已经非常彻底,从磁盘到磁盘控制器,从磁盘阵控制...
__label__POS
0.998951
# 166、Qt绘制原理双缓冲机制? Qt绘制原理中的双缓冲机制是指在绘制过程中使用两个缓冲区,一个用于绘制,一个用于显示,从而避免了绘制过程中的闪烁等问题。具体来说,双缓冲机制的实现过程如下: 1. 创建两个缓冲区,一个用于绘制,一个用于显示; 2. 在绘制过程中,将所有的绘制操作都先绘制到绘制缓冲区中; 3. 绘制完成后,将绘制缓冲区中的内容复制到显示缓冲区中; 4. 显示缓冲区中的内容会被显示在屏幕上。 这样,由于绘制操作是在绘制缓冲区中进行的,因此不会直接影响到显示缓冲区中的内容,从而避免了闪烁等问题。 在Qt中,双缓冲机制是由QPainter类和QWidget类共同实现的。QPainter类用于在绘制缓冲区中进行绘制操...
__label__POS
0.999723
# 184、事务的ACID与实现原理? 事务是指一组逻辑操作,要么全部执行成功,要么全部执行失败,是保证数据完整性和一致性的重要机制。ACID是事务的四个基本特性,分别是原子性、一致性、隔离性和持久性。 1. 原子性:事务是一个原子操作,要么全部执行成功,要么全部执行失败,不存在部分执行的情况。 2. 一致性:事务执行前后,数据的完整性和一致性都得到保证,不会破坏数据的完整性和一致性。 3. 隔离性:事务之间是相互隔离的,一个事务的执行不会影响其他事务的执行。 4. 持久性:事务执行成功后,对数据的修改将被永久保存在数据库中,即使系统崩溃也不会丢失数据。 实现原理: 实现事务的ACID特性需要数据库管理系统提供一些机制和技术来支...
__label__POS
0.999571
# 176、Qt相机和视频处理技术? Qt相机和视频处理技术是Qt提供的一组API和库,用于在Qt应用程序中访问摄像头和处理视频。以下是一些常用的Qt相机和视频处理技术: 1. QtMultimedia模块:提供了访问音频、视频、相机等多媒体设备的API。可以用来在Qt应用程序中访问相机,捕捉视频和音频流,以及播放音频和视频文件。 2. QtCamera模块:是QtMultimedia模块的一部分,提供了访问相机的API。可以用来获取相机的设备信息、预览相机的图像、捕捉相机的图像和视频等。 3. QtAV库:是一个基于Qt的多媒体框架,提供了高性能的视频和音频处理能力。可以用来播放各种格式的视频和音频文件,以及进行视频编解码和处...
__label__POS
0.999946