SRS 6.0-b0 源码 + danmaku 后端(排除 objs/3rdparty/测试媒体)

This commit is contained in:
RRRosmontis
2026-08-27 21:46:20 +08:00
commit 41b5da7c7e
578 changed files with 237858 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
/*
ulimit -S -v 204800
g++ -g -O0 bad_alloc0.cpp -o bad_alloc && ./bad_alloc
*/
#include <stdio.h>
int main(){
char* p1 = new char[193000 * 1024]; // huge allocation
char* p0 = new char[100 * 1024]; // small allocation
printf("OK\n");
}
+17
View File
@@ -0,0 +1,17 @@
/*
ulimit -S -v 204800
g++ -g -O0 bad_alloc1.cpp -o bad_alloc && ./bad_alloc
*/
#include <stdio.h>
#include <new>
void handler() {
printf("Memory allocate failed\n");
std::set_new_handler(NULL); // New will try to alloc again, then abort.
}
int main(){
std::set_new_handler(handler);
char* p1 = new char[193000 * 1024]; // huge allocation
char* p0 = new char[100 * 1024]; // small allocation
printf("OK\n");
}
+23
View File
@@ -0,0 +1,23 @@
/*
# https://www.jianshu.com/p/eaa2700ebedc
g++ frame0.cpp -g -O0 -o frame && ./frame
*/
#include <stdio.h>
#include <stdlib.h>
int callee(int a, long b) {
int c = a;
c += (int)b;
return c;
}
void caller() {
int v = callee(10, 20);
printf("v=%d\n", v);
}
int main(int argc, char** argv)
{
caller();
return 0;
}
+35
View File
@@ -0,0 +1,35 @@
/*
# https://www.jianshu.com/p/eaa2700ebedc
g++ frame1.cpp -g -O0 -o frame && ./frame
*/
#include <stdio.h>
#include <stdlib.h>
int callee(int a, long b, long c, int d, long e, int f, int g, int h) {
int v = a;
v += (int)b;
v += (int)c;
v += (int)e;
v += (int)g;
v += (int)h;
return v;
}
void caller() {
int a = 10;
int b = 20;
long c = 30;
int d = 40;
int e = 50;
int f = 60;
int g = 70;
int h = 80;
int v = callee(a, b, c, d, e, f, g, h);
printf("v=%d, c=%ld\n", v, c);
}
int main(int argc, char** argv)
{
caller();
return 0;
}
+31
View File
@@ -0,0 +1,31 @@
/*
g++ mmap0.cpp -g -O0 -o mmap && ./mmap
*/
#include <stdio.h>
#include <assert.h>
#include <sys/mman.h>
#include <string.h>
int main(int argc, char** argv)
{
int zero_fd = -1;
int size = 64 * 1024;
int mmap_flags = MAP_PRIVATE | MAP_ANON;
char* vaddr = (char*)mmap(NULL, size, PROT_READ | PROT_WRITE, mmap_flags, zero_fd, 0);
assert (vaddr != (void *)MAP_FAILED);
printf("vaddr=%p, size=%d\n", vaddr, size);
vaddr[0] = 0x0f;
printf("OK: access vaddr p[0]=%x\n", vaddr[0]);
int REDZONE = 4096;
mprotect(vaddr, REDZONE, PROT_NONE);
printf("protect vaddr=%p, [0, %d]\n", vaddr, REDZONE);
printf("try to access vaddr\n");
vaddr[0] = 0x0f;
printf("OK: access vaddr p[0]=%x\n", vaddr[0]);
return 0;
}
+30
View File
@@ -0,0 +1,30 @@
/*
g++ mmap1.cpp -g -O0 -o mmap && ./mmap
*/
#include <stdio.h>
#include <assert.h>
#include <sys/mman.h>
#include <string.h>
int main(int argc, char** argv)
{
int zero_fd = -1;
int size = 64 * 1024;
int mmap_flags = MAP_PRIVATE | MAP_ANON;
char* vaddr = (char*)mmap(NULL, size, PROT_READ | PROT_WRITE, mmap_flags, zero_fd, 0);
assert (vaddr != (void *)MAP_FAILED);
printf("vaddr=%p, size=%d\n", vaddr, size);
vaddr[0] = 0x0f;
printf("OK: access vaddr p[0]=%x\n", vaddr[0]);
munmap(vaddr, size);
printf("munmap vaddr=%p, size=%d\n", vaddr, size);
printf("try to access vaddr\n");
vaddr[0] = 0x0f;
printf("OK: access vaddr p[0]=%x\n", vaddr[0]);
return 0;
}
+14
View File
@@ -0,0 +1,14 @@
/*
g++ st0.cpp ../../objs/st/libst.a -g -O0 -o st && ./st
*/
#include <stdio.h>
#include "../../objs/st/st.h"
int main(int argc, char** argv) {
st_init();
for (;;) {
st_usleep(1000 * 1000);
}
return 0;
}