From f4640442277edb2f424dcf853a8a88629bbad621 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 16 Mar 2024 20:26:49 +0800 Subject: [PATCH 1/4] ST: Add examples for thread and hello. --- trunk/research/st/hello-st.cpp | 16 ++++++++++++++ trunk/research/st/hello-world.cpp | 19 ++++++++++++++++ trunk/research/st/hello.cpp | 11 ++++++++++ trunk/research/st/win-thread.cpp | 36 +++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 trunk/research/st/hello-st.cpp create mode 100644 trunk/research/st/hello-world.cpp create mode 100644 trunk/research/st/hello.cpp create mode 100644 trunk/research/st/win-thread.cpp diff --git a/trunk/research/st/hello-st.cpp b/trunk/research/st/hello-st.cpp new file mode 100644 index 0000000000..f0fba9a2be --- /dev/null +++ b/trunk/research/st/hello-st.cpp @@ -0,0 +1,16 @@ +/* +g++ hello-st.cpp ../../objs/st/libst.a -g -O0 -o hello-st && ./hello-st +*/ +#include +#include "../../objs/st/st.h" + +void foo() { + st_init(); + st_sleep(1); + printf("Hello World, ST!\n"); +} + +int main() { + foo(); + return 0; +} diff --git a/trunk/research/st/hello-world.cpp b/trunk/research/st/hello-world.cpp new file mode 100644 index 0000000000..c49dba3278 --- /dev/null +++ b/trunk/research/st/hello-world.cpp @@ -0,0 +1,19 @@ +/* +g++ hello-world.cpp ../../objs/st/libst.a -g -O0 -o hello-world && ./hello-world +*/ +#include +#include "../../objs/st/st.h" + +void foo() { + st_init(); + + for (int i = 0; ; i++) { + st_sleep(1); + printf("#%d: main: working\n", i); + } +} + +int main() { + foo(); + return 0; +} diff --git a/trunk/research/st/hello.cpp b/trunk/research/st/hello.cpp new file mode 100644 index 0000000000..dd21ba7f03 --- /dev/null +++ b/trunk/research/st/hello.cpp @@ -0,0 +1,11 @@ +/* + g++ hello.cpp -g -O0 -o hello && ./hello + */ + +void foo() { +} + +int main(int argc, char** argv) { + foo(); + return 0; +} diff --git a/trunk/research/st/win-thread.cpp b/trunk/research/st/win-thread.cpp new file mode 100644 index 0000000000..6ae5d1412e --- /dev/null +++ b/trunk/research/st/win-thread.cpp @@ -0,0 +1,36 @@ +/* +Directly compile c++ source and execute: + g++ win-thread.cpp ../../objs/st/libst.a -g -O0 -o win-thread && ./win-thread +*/ +#include +#include +#include "../../objs/st/st.h" + +void* foo(void* arg) { + while (true) { + printf("Hello, child thread\n"); + st_sleep(1); + } + return NULL; +} + +void* pfn(void* arg) { + st_init(); + st_thread_create(foo, NULL, 0, 0); + st_thread_exit(NULL); + return NULL; +} + +int main(int argc, char** argv) { + st_init(); + + pthread_t trd; + pthread_create(&trd, NULL, pfn, NULL); + + while (true) { + printf("Hello, main thread\n"); + st_sleep(1); + } + return 0; +} + From d1d6055e762ea966bb3c18c7a23dece6ae1fbb8b Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 16 Mar 2024 20:35:00 +0800 Subject: [PATCH 2/4] ST: Add exceptions examples. --- trunk/research/st/exceptions.cpp | 29 +++++++++++++++++++ .../st/{win-thread.cpp => threads.cpp} | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 trunk/research/st/exceptions.cpp rename trunk/research/st/{win-thread.cpp => threads.cpp} (87%) diff --git a/trunk/research/st/exceptions.cpp b/trunk/research/st/exceptions.cpp new file mode 100644 index 0000000000..8dadcfc5d0 --- /dev/null +++ b/trunk/research/st/exceptions.cpp @@ -0,0 +1,29 @@ +/* +# !!! ST does not support C++ exceptions on cygwin !!! +g++ exceptions.cpp ../../objs/st/libst.a -g -O0 -o exceptions && ./exceptions +*/ +#include +#include +#include "../../objs/st/st.h" + +int handle_exception() { + try { + throw 3; + } catch (...) { + return 5; + } +} + +void* foo(void* arg) { + int r0 = handle_exception(); + printf("r0=%d\n", r0); + return NULL; +} + +int main(int argc, char** argv) { + st_init(); + st_thread_create(foo, NULL, 0, 0); + st_thread_exit(NULL); + return 0; +} + diff --git a/trunk/research/st/win-thread.cpp b/trunk/research/st/threads.cpp similarity index 87% rename from trunk/research/st/win-thread.cpp rename to trunk/research/st/threads.cpp index 6ae5d1412e..1ce58be552 100644 --- a/trunk/research/st/win-thread.cpp +++ b/trunk/research/st/threads.cpp @@ -1,6 +1,6 @@ /* Directly compile c++ source and execute: - g++ win-thread.cpp ../../objs/st/libst.a -g -O0 -o win-thread && ./win-thread + g++ threads.cpp ../../objs/st/libst.a -g -O0 -o threads && ./threads */ #include #include From 07ed788b2e396bea27735b3c3d7d103493710c8d Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 16 Mar 2024 20:37:30 +0800 Subject: [PATCH 3/4] ST: Rename threads to pthreads. --- trunk/research/st/{threads.cpp => pthreads.cpp} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename trunk/research/st/{threads.cpp => pthreads.cpp} (88%) diff --git a/trunk/research/st/threads.cpp b/trunk/research/st/pthreads.cpp similarity index 88% rename from trunk/research/st/threads.cpp rename to trunk/research/st/pthreads.cpp index 1ce58be552..e87c6034e1 100644 --- a/trunk/research/st/threads.cpp +++ b/trunk/research/st/pthreads.cpp @@ -1,6 +1,6 @@ /* Directly compile c++ source and execute: - g++ threads.cpp ../../objs/st/libst.a -g -O0 -o threads && ./threads + g++ pthreads.cpp ../../objs/st/libst.a -g -O0 -o pthreads && ./pthreads */ #include #include From 21eaf1bc6a33b4dcfe52fb3d9c323bad64956f64 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 24 Mar 2024 09:28:14 +0800 Subject: [PATCH 4/4] Update release to v6.0.118 --- trunk/doc/CHANGELOG.md | 1 + trunk/src/core/srs_core_version6.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 7607a48bf6..76852b6d46 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2024-03-24, Merge [#3989](https://github.com/ossrs/srs/pull/3989): ST: Research adds examples that demos pthread and helloworld. v6.0.118 (#3989) * v6.0, 2024-03-19, Merge [#3958](https://github.com/ossrs/srs/pull/3958): Add a TCP proxy for debugging. v6.0.117 (#3958) * v6.0, 2024-03-20, Merge [#3964](https://github.com/ossrs/srs/pull/3964): WebRTC: Add support for A/V only WHEP/WHEP player. v6.0.116 (#3964) * v6.0, 2024-03-19, Merge [#3990](https://github.com/ossrs/srs/pull/3990): System: Disable feature that obtains versions and check features status. v6.0.115 (#3990) diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index d79d5849d4..36551a9e00 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 117 +#define VERSION_REVISION 118 #endif