From d08062222196df73d19a1f7a68af6032128a3f59 Mon Sep 17 00:00:00 2001 From: TheTechsTech Date: Thu, 1 Jun 2023 14:51:33 -0400 Subject: [PATCH 01/38] update CMakeLists.txt --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 593d6c5..125fe35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,4 +23,3 @@ foreach (TARGET ${TARGET_LIST}) target_include_directories(${TARGET} PRIVATE src) target_link_libraries(${TARGET} task) endforeach() -libtask From a08195ea05156752cdb78266974ea74ab7056764 Mon Sep 17 00:00:00 2001 From: TheTechsTech Date: Fri, 2 Jun 2023 16:49:17 -0400 Subject: [PATCH 02/38] update task.c, ucontext.c and ucontext.h --- src/task.c | 9 +++++++++ src/ucontext.c | 2 ++ src/ucontext.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/task.c b/src/task.c index 81c83ed..ea2a3d2 100644 --- a/src/task.c +++ b/src/task.c @@ -367,6 +367,15 @@ taskmainstart(void *v) int main(int argc, char **argv) { +#if !defined(_WIN32) || !defined(_WIN64) + struct sigaction sa, osa; + + memset(&sa, 0, sizeof sa); + sa.sa_handler = taskinfo; + sa.sa_flags = SA_RESTART; + sigaction(SIGQUIT, &sa, &osa); +#endif + #ifdef SIGINFO sigaction(SIGINFO, &sa, &osa); #endif diff --git a/src/ucontext.c b/src/ucontext.c index f9dd621..5f649c5 100644 --- a/src/ucontext.c +++ b/src/ucontext.c @@ -24,6 +24,7 @@ #include #include +#if defined(_WIN32) || defined(_WIN64) int getcontext(ucontext_t *ucp) { int ret; @@ -99,3 +100,4 @@ int swapcontext(ucontext_t *oucp, const ucontext_t *ucp) } return ret; } +#endif diff --git a/src/ucontext.h b/src/ucontext.h index 49093cf..f40cb46 100644 --- a/src/ucontext.h +++ b/src/ucontext.h @@ -23,6 +23,7 @@ #ifndef UCONTEXT_H #define UCONTEXT_H +#if defined(_WIN32) || defined(_WIN64) #include #ifdef __cplusplus @@ -62,4 +63,5 @@ int swapcontext(ucontext_t *, const ucontext_t *); } #endif +#endif #endif /* UCONTEXT_H */ From afff64ad4b772798f374da95711b1e4c01c3c67a Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Sat, 3 Jun 2023 09:14:19 -0400 Subject: [PATCH 03/38] bug fixes for Windows cmake build --- examples/tcpproxy.c | 4 ++-- src/compat/netdb.h | 2 +- src/compat/netinet/in.h | 2 +- src/compat/netinet/tcp.h | 2 +- src/compat/poll.h | 6 ------ src/net.c | 27 +++++++++++++++++---------- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/examples/tcpproxy.c b/examples/tcpproxy.c index d52ce46..10683ae 100644 --- a/examples/tcpproxy.c +++ b/examples/tcpproxy.c @@ -3,13 +3,13 @@ #include #if defined(_WIN32) || defined(_WIN64) #include "../src/compat/unistd.h" +#include "../src/compat/sys/socket.h" #else #include +#include #endif #include "../src/task.h" #include -#include - enum { STACK = 32768 diff --git a/src/compat/netdb.h b/src/compat/netdb.h index d36b91d..6c1fca6 100644 --- a/src/compat/netdb.h +++ b/src/compat/netdb.h @@ -6,5 +6,5 @@ #ifndef _WIN32 #include_next #else -#include +#include "win32netcompat.h" #endif diff --git a/src/compat/netinet/in.h b/src/compat/netinet/in.h index d1afb27..7d10b23 100644 --- a/src/compat/netinet/in.h +++ b/src/compat/netinet/in.h @@ -6,7 +6,7 @@ #ifndef _WIN32 #include_next #else -#include +#include "../win32netcompat.h" #endif #ifndef LIBCRYPTOCOMPAT_NETINET_IN_H diff --git a/src/compat/netinet/tcp.h b/src/compat/netinet/tcp.h index c98cf74..2f346a3 100644 --- a/src/compat/netinet/tcp.h +++ b/src/compat/netinet/tcp.h @@ -6,5 +6,5 @@ #ifndef _WIN32 #include_next #else -#include +#include "../win32netcompat.h" #endif diff --git a/src/compat/poll.h b/src/compat/poll.h index d81a4f7..7c4a552 100644 --- a/src/compat/poll.h +++ b/src/compat/poll.h @@ -22,12 +22,6 @@ /* Type used for the number of file descriptors. */ typedef unsigned long int nfds_t; -/* Data structure describing a polling request. */ -struct pollfd { - int fd; /* file descriptor */ - short events; /* requested events */ - short revents; /* returned events */ -}; /* Event types that can be polled */ #define POLLIN 0x001 /* There is data to read. */ diff --git a/src/net.c b/src/net.c index bd05778..7417930 100644 --- a/src/net.c +++ b/src/net.c @@ -1,10 +1,18 @@ #include "taskimpl.h" #include -#include +#if defined(_WIN32) || defined(_WIN64) +#include "compat/netdb.h" +#include "compat/sys/socket.h" +#include "compat/netinet/in.h" +#include "compat/netinet/tcp.h" +#include "compat/poll.h" +#else #include +#include #include #include #include +#endif int netannounce(int istcp, char *server, int port) @@ -30,7 +38,7 @@ netannounce(int istcp, char *server, int port) taskstate("socket failed"); return -1; } - + /* set reuse flag for tcp */ if(istcp && getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&n, &sn) >= 0){ n = 1; @@ -58,7 +66,7 @@ netaccept(int fd, char *server, int *port) struct sockaddr_in sa; uchar *ip; socklen_t len; - + fdwait(fd, 'r'); taskstate("netaccept"); @@ -133,7 +141,7 @@ netlookup(char *name, uint32_t *ip) if(parseip(name, ip) >= 0) return 0; - + /* BUG - Name resolution blocks. Need a non-blocking DNS. */ taskstate("netlookup"); if((he = gethostbyname(name)) != 0){ @@ -141,7 +149,7 @@ netlookup(char *name, uint32_t *ip) taskstate("netlookup succeeded"); return 0; } - + taskstate("netlookup failed"); return -1; } @@ -153,7 +161,7 @@ netdial(int istcp, char *server, int port) uint32_t ip; struct sockaddr_in sa; socklen_t sn; - + if(netlookup(server, &ip) < 0) return -1; @@ -170,7 +178,7 @@ netdial(int istcp, char *server, int port) n = 1; setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &n, sizeof n); } - + /* start connecting */ memset(&sa, 0, sizeof sa); memmove(&sa.sin_addr, &ip, 4); @@ -182,14 +190,14 @@ netdial(int istcp, char *server, int port) return -1; } - /* wait for finish */ + /* wait for finish */ fdwait(fd, 'w'); sn = sizeof sa; if(getpeername(fd, (struct sockaddr*)&sa, &sn) >= 0){ taskstate("connect succeeded"); return fd; } - + /* report error */ sn = sizeof n; getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&n, &sn); @@ -200,4 +208,3 @@ netdial(int istcp, char *server, int port) errno = n; return -1; } - From ca35bb757dc6908c59a12e79fcaa040c906ec146 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Mon, 5 Jun 2023 22:26:23 -0400 Subject: [PATCH 04/38] update CMakeLists.txt, cl_32.bat, cl_64.bat and task.c --- CMakeLists.txt | 16 ++++++++++++---- src/cl_32.bat | 2 +- src/cl_64.bat | 2 +- src/task.c | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 125fe35..c06d0c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,18 @@ cmake_minimum_required(VERSION 3.10) project(LIBTASK C) -set(C_STANDARD 99) +set(C_STANDARD 89) -# -g for debugging -set(CMAKE_C_FLAGS "-g") +if(WIN32) + set(CMAKE_GENERATOR_PLATFORM Win32) +endif() + +if(UNIX) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g ") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fomit-frame-pointer ") +endif() + +message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}") set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIR}/bin) @@ -17,7 +25,7 @@ file(GLOB lib_files ) add_library(task STATIC ${lib_files}) -set(TARGET_LIST primes tcpproxy helloworld chan_1 chan_2 chan_3) +set(TARGET_LIST testdelay primes helloworld chan_1 chan_2 chan_3) foreach (TARGET ${TARGET_LIST}) add_executable(${TARGET} examples/${TARGET}.c) target_include_directories(${TARGET} PRIVATE src) diff --git a/src/cl_32.bat b/src/cl_32.bat index 2878f06..faa572a 100644 --- a/src/cl_32.bat +++ b/src/cl_32.bat @@ -2,5 +2,5 @@ if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" ( %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars32.bat" ) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" ( - %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsamd64_x86.bat" + %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat" ) diff --git a/src/cl_64.bat b/src/cl_64.bat index cd4db3d..7e7b60a 100644 --- a/src/cl_64.bat +++ b/src/cl_64.bat @@ -2,5 +2,5 @@ if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" ( %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" ) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" ( - %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsx86_amd64.bat" + %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" ) diff --git a/src/task.c b/src/task.c index ea2a3d2..fe385ff 100644 --- a/src/task.c +++ b/src/task.c @@ -367,7 +367,7 @@ taskmainstart(void *v) int main(int argc, char **argv) { -#if !defined(_WIN32) || !defined(_WIN64) +#if !defined(_WIN32) struct sigaction sa, osa; memset(&sa, 0, sizeof sa); From 8e654a176338119919a3be76d89347e04e402e82 Mon Sep 17 00:00:00 2001 From: TheTechsTech Date: Tue, 6 Jun 2023 12:27:56 -0400 Subject: [PATCH 05/38] update README.md - some styling fixes --- README.md | 92 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 3bb6f66..e689e27 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -Libtask is a simple coroutine library. It runs on Linux (ARM, MIPS, and x86), +# Libtask + +**Libtask** is a simple coroutine library. It runs on Linux (ARM, MIPS, and x86), FreeBSD (x86), OS X (PowerPC x86, and x86-64), and SunOS Solaris (Sparc), and is easy to port to other systems. @@ -12,32 +14,32 @@ the CPU. Most of the functions provided in task.h do have the possibility of going to sleep. Programs using the task functions should #include . ---- Basic task manipulation +## Basic task manipulation -int taskcreate(void (*f)(void*arg), void *arg, unsigned int stacksize); +`int taskcreate(void (*f)(void*arg), void *arg, unsigned int stacksize);` Create a new task running f(arg) on a stack of size stacksize. -void tasksystem(void); +`void tasksystem(void);` Mark the current task as a "system" task. These are ignored for the purposes of deciding the program is done running (see taskexit next). -void taskexit(int status); +`void taskexit(int status);` Exit the current task. If this is the last non-system task, exit the entire program using the given exit status. -void taskexitall(int status); +`void taskexitall(int status);` Exit the entire program, using the given exit status. -void taskmain(int argc, char *argv[]); +`void taskmain(int argc, char *argv[]);` Write this function instead of main. Libtask provides its own main. -int taskyield(void); +`int taskyield(void);` Explicitly give up the CPU. The current task will be scheduled again once all the other currently-ready tasks have a chance @@ -45,33 +47,33 @@ int taskyield(void); current task was waiting. (Zero means there are no other tasks trying to run.) -int taskdelay(unsigned int ms) +`int taskdelay(unsigned int ms);` Explicitly give up the CPU for at least ms milliseconds. Other tasks continue to run during this time. -void** taskdata(void); +`void** taskdata(void);` Return a pointer to a single per-task void* pointer. You can use this as a per-task storage place. -void needstack(int n); +`void needstack(int n);` Tell the task library that you need at least n bytes left on the stack. If you don't have it, the task library will call abort. (It's hard to figure out how big stacks should be. I usually make them really big (say 32768) and then don't worry about it.) -void taskname(char*, ...); +`void taskname(char*, ...);` Takes an argument list like printf. Sets the current task's name. -char* taskgetname(void); +`char* taskgetname(void);` Returns the current task's name. Is the actual buffer; do not free. -void taskstate(char*, ...); -char* taskgetstate(void); +`void taskstate(char*, ...);` +`char* taskgetstate(void);` Like taskname and taskgetname but for the task state. @@ -79,31 +81,31 @@ char* taskgetstate(void); it will print a list of all its tasks and their names and states. This is useful for debugging why your program isn't doing anything! -unsigned int taskid(void); +`unsigned int taskid(void);` Return the unique task id for the current task. ---- Non-blocking I/O +## Non-blocking I/O There is a small amount of runtime support for non-blocking I/O on file descriptors. -int fdnoblock(int fd); +`int fdnoblock(int fd);` Sets I/O on the given fd to be non-blocking. Should be called before any of the other fd routines. -int fdread(int, void*, int); +`int fdread(int, void*, int);` Like regular read(), but puts task to sleep while waiting for data instead of blocking the whole program. -int fdwrite(int, void*, int); +`int fdwrite(int, void*, int);` Like regular write(), but puts task to sleep while waiting to write data instead of blocking the whole program. -void fdwait(int fd, int rw); +`void fdwait(int fd, int rw);` Low-level call sitting underneath fdread and fdwrite. Puts task to sleep while waiting for I/O to be possible on fd. @@ -111,12 +113,12 @@ void fdwait(int fd, int rw); anything else means just exceptional conditions (hang up, etc.) The 'r' and 'w' also wake up for exceptional conditions. ---- Network I/O +## Network I/O These are convenient packaging of the ugly Unix socket routines. They can all put the current task to sleep during the call. -int netannounce(int proto, char *address, int port) +`int netannounce(int proto, char *address, int port);` Start a network listener running on address and port of protocol. Proto is either TCP or UDP. Port is a port number. Address is a @@ -126,7 +128,7 @@ int netannounce(int proto, char *address, int port) Examples: netannounce(TCP, "localhost", 80) or netannounce(TCP, "127.0.0.1", 80) or netannounce(TCP, 0, 80). -int netaccept(int fd, char *server, int*port) +`int netaccept(int fd, char *server, int*port);` Get the next connection that comes in to the listener fd. Returns a fd to use to talk to the guy who just connected. @@ -134,13 +136,16 @@ int netaccept(int fd, char *server, int*port) 16 bytes that is filled in with the remote IP address. If port is not null, it is filled in with the report port. Example: + +```c char server[16]; int port; if(netaccept(fd, server, &port) >= 0) printf("connect from %s:%d", server, port); +``` -int netdial(int proto, char *name, int port) +`int netdial(int proto, char *name, int port);` Create a new (outgoing) connection to a particular host. Name can be an ip address or a domain name. If it's a domain name, @@ -149,28 +154,29 @@ int netdial(int proto, char *name, int port) Example: netdial(TCP, "www.google.com", 80) or netdial(TCP, "18.26.4.9", 80) ---- Time +## Time -unsigned int taskdelay(unsigned int ms) +`unsigned int taskdelay(unsigned int ms);` Put the current task to sleep for approximately ms milliseconds. Return the actual amount of time slept, in milliseconds. ---- Example programs +## Example programs -In this directory, tcpproxy.c is a simple TCP proxy that illustrates +In this directory, `tcpproxy.c` is a simple TCP proxy that illustrates most of the above. You can run - tcpproxy 1234 www.google.com 80 +- tcpproxy 1234 80 and then you should be able to visit and see Google. Other examples are: - primes.c - simple prime sieve - httpload.c - simple HTTP load generator - testdelay.c - test taskdelay() ---- Building +- primes.c - simple prime sieve +- httpload.c - simple HTTP load generator +- testdelay.c - test taskdelay() + +## Building To build, run make. You can run make install to copy task.h and libtask.a to the appropriate places in /usr/local. Then you @@ -179,19 +185,21 @@ that use it. On SunOS Solaris machines, run makesun instead of just make. ---- Contact Info +### Contact Info Please email me with questions or problems. Russ Cox ---- Stuff you probably won't use at first --- ---- but might want to know about eventually --- +***Stuff you probably won't use at first*** +***but might want to know about eventually*** +```c void tasksleep(Rendez*); int taskwakeup(Rendez*); int taskwakeupall(Rendez*); +``` A Rendez is a condition variable. You can declare a new one by just allocating memory for it (or putting it in another structure) @@ -202,9 +210,11 @@ int taskwakeupall(Rendez*); Taskwakeupall(r) wakes up all the tasks sleeping on r. They both return the actual number of tasks awakened. +```c void qlock(QLock*); int canqlock(QLock*); void qunlock(QLock*); +``` You probably won't need locks because of the cooperative scheduling, but if you do, here are some. You can make a new @@ -214,6 +224,7 @@ void qunlock(QLock*); Calling canqlock tries to lock the lock, but will not give up the CPU. It returns 1 if the lock was acquired, 0 if it cannot be at this time. +```C void rlock(RWLock*); int canrlock(RWLock*); void runlock(RWLock*); @@ -221,12 +232,13 @@ void runlock(RWLock*); void wlock(RWLock*); int canwlock(RWLock*); void wunlock(RWLock*); +``` RWLocks are reader-writer locks. Any number of readers can lock them at once, but only one writer at a time. If a writer is holding it, there can't be any readers. -Channel *chancreate(int, int); +`Channel *chancreate(int, int);` etc. Channels are buffered communication pipes you can @@ -234,7 +246,7 @@ etc. doing most of the inter-task communication using channels. For details on channels see the description of channels in - http://swtch.com/usr/local/plan9/man/man3/thread.html and - http://swtch.com/~rsc/thread/ + and + and also the example program primes.c, which implements a concurrent prime sieve. From 17717295a6b5764b96edee9362fefe4bf3943978 Mon Sep 17 00:00:00 2001 From: TheTechsTech Date: Tue, 6 Jun 2023 12:49:25 -0400 Subject: [PATCH 06/38] updates - add Windows cmake build instructions --- README.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e689e27..602072f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Libtask **Libtask** is a simple coroutine library. It runs on Linux (ARM, MIPS, and x86), -FreeBSD (x86), OS X (PowerPC x86, and x86-64), and SunOS Solaris (Sparc), +FreeBSD (x86), OS X (PowerPC x86, and x86-64), SunOS Solaris (Sparc), **Windows** and is easy to port to other systems. Libtask gives the programmer the illusion of threads, but @@ -178,10 +178,21 @@ Other examples are: ## Building -To build, run make. You can run make install to copy task.h and -libtask.a to the appropriate places in /usr/local. Then you -should be able to just link with -ltask in your programs -that use it. +To build, run **cmake**. You can copy task.h and +libtask.a to the appropriate places in /usr/local. Then you +should be able to just link with -ltask in your programs that use it. + +```shell +mkdir build +cd build +# Windows +cmake .. -D CMAKE_GENERATOR_PLATFORM=Win32 +# Linux/Unix +cmake .. +cmake --build . +``` + +`libtask.a` or `libtask.lib` is in **lib** directory. On SunOS Solaris machines, run makesun instead of just make. From fb9ce618584a08792511198d9cf909be3d90c5f7 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Tue, 6 Jun 2023 21:08:21 -0400 Subject: [PATCH 07/38] ci: create ci.yml --- .github/workflows/ci.yml | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5e391fb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,97 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + name: ${{ matrix.target }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - target: amd64 + flags: -O3 -fomit-frame-pointer + - target: x86 + flags: -m32 -O3 -fomit-frame-pointer + steps: + - uses: actions/checkout@v3 + - name: Prepare + run: | + sudo dpkg --add-architecture i386 + sudo apt-get update -q -y + sudo apt-get install -y gcc-multilib g++-multilib valgrind libc6-dbg libc6-dbg:i386 + - name: cmake build & test examples + run: | + mkdir build + cd build + cmake .. + cmake --build . + cd bin + ./chan_1 + ./chan_2 + ./chan_3 + ./primes + ./testdelay 2 + + build-qemu: + name: ${{ matrix.target }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - target: arm + arch: armv7 + - target: aarch64 + arch: aarch64 + - target: ppc64v2 + arch: ppc64le + steps: + - uses: actions/checkout@v3 + - uses: uraimo/run-on-arch-action@v2 + with: + arch: ${{ matrix.arch }} + distro: ubuntu_latest + install: | + apt-get update -q -y + apt-get install -q -y --no-install-recommends build-essential valgrind + env: | + target: ${{ matrix.target }} + run: | + mkdir build + cd build + cmake .. + cmake --build . + cd bin + ./chan_1 + ./chan_2 + ./chan_3 + ./primes + ./testdelay 2 + + + build-windows: + name: Windows (${{ matrix.arch }}) + runs-on: windows-2019 + strategy: + fail-fast: false + matrix: + arch: [amd64, x86] + steps: + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} + - uses: actions/checkout@v3 + - name: cmake build & test examples + run: | + mkdir build + cd build + cmake .. -D CMAKE_GENERATOR_PLATFORM=Win32 + cmake --build . + cd bin/Debug + .\chan_1.exe + .\chan_2.exe + .\chan_3.exe + .\primes.exe + .\testdelay.exe 2 From 0202137fe310454192fef0396964241caf148dae Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Tue, 6 Jun 2023 21:28:19 -0400 Subject: [PATCH 08/38] ci: update ci.yml --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e391fb..80e88ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: build: name: ${{ matrix.target }} - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: @@ -58,7 +58,8 @@ jobs: apt-get install -q -y --no-install-recommends build-essential valgrind env: | target: ${{ matrix.target }} - run: | + - name: cmake build & test examples + run: | mkdir build cd build cmake .. From 12bc10493ec5bc2c0ce49bc0705cba79211501be Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Tue, 6 Jun 2023 21:36:47 -0400 Subject: [PATCH 09/38] ci: update ci.yml --- .github/workflows/ci.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80e88ce..3a1842e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,15 +21,13 @@ jobs: sudo dpkg --add-architecture i386 sudo apt-get update -q -y sudo apt-get install -y gcc-multilib g++-multilib valgrind libc6-dbg libc6-dbg:i386 - - name: cmake build & test examples + - name: cmake build & test example run: | mkdir build cd build cmake .. cmake --build . cd bin - ./chan_1 - ./chan_2 ./chan_3 ./primes ./testdelay 2 @@ -58,20 +56,16 @@ jobs: apt-get install -q -y --no-install-recommends build-essential valgrind env: | target: ${{ matrix.target }} - - name: cmake build & test examples - run: | + run: | mkdir build cd build cmake .. cmake --build . cd bin - ./chan_1 - ./chan_2 ./chan_3 ./primes ./testdelay 2 - build-windows: name: Windows (${{ matrix.arch }}) runs-on: windows-2019 From dd2b14ae4dadfa5d336c3604cb9485ba25457397 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Tue, 6 Jun 2023 22:00:12 -0400 Subject: [PATCH 10/38] ci: update ci and add --- .github/workflows/ci.yml | 34 ------------------------------- .github/workflows/ci_qemu.yml | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/ci_qemu.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a1842e..8d94595 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,40 +32,6 @@ jobs: ./primes ./testdelay 2 - build-qemu: - name: ${{ matrix.target }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - target: arm - arch: armv7 - - target: aarch64 - arch: aarch64 - - target: ppc64v2 - arch: ppc64le - steps: - - uses: actions/checkout@v3 - - uses: uraimo/run-on-arch-action@v2 - with: - arch: ${{ matrix.arch }} - distro: ubuntu_latest - install: | - apt-get update -q -y - apt-get install -q -y --no-install-recommends build-essential valgrind - env: | - target: ${{ matrix.target }} - run: | - mkdir build - cd build - cmake .. - cmake --build . - cd bin - ./chan_3 - ./primes - ./testdelay 2 - build-windows: name: Windows (${{ matrix.arch }}) runs-on: windows-2019 diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml new file mode 100644 index 0000000..86cddcb --- /dev/null +++ b/.github/workflows/ci_qemu.yml @@ -0,0 +1,38 @@ +name: CI-Qemu + +on: [push, pull_request] + +jobs: + build-qemu: + name: ${{ matrix.target }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - target: arm + arch: armv7 + - target: aarch64 + arch: aarch64 + - target: ppc64v2 + arch: ppc64le + steps: + - uses: actions/checkout@v3 + - uses: uraimo/run-on-arch-action@v2 + with: + arch: ${{ matrix.arch }} + distro: ubuntu_latest + install: | + apt-get update -q -y + apt-get install -q -y --no-install-recommends build-essential valgrind + env: | + target: ${{ matrix.target }} + run: | + mkdir build + cd build + cmake .. + cmake --build . + cd bin + ./chan_3 + ./primes + ./testdelay 2 From e424aa75068541dc232a4df2f02c235b47cb1be2 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Tue, 6 Jun 2023 23:18:15 -0400 Subject: [PATCH 11/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 86cddcb..c8ad88a 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: build-qemu: name: ${{ matrix.target }} - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: @@ -21,7 +21,7 @@ jobs: - uses: uraimo/run-on-arch-action@v2 with: arch: ${{ matrix.arch }} - distro: ubuntu_latest + distro: ubuntu20.04 install: | apt-get update -q -y apt-get install -q -y --no-install-recommends build-essential valgrind From a613beeda61e010c228c51dea84f5b00f5f5ed53 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Tue, 6 Jun 2023 23:44:01 -0400 Subject: [PATCH 12/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index c8ad88a..9e0be7e 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: build-qemu: name: ${{ matrix.target }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -21,12 +21,14 @@ jobs: - uses: uraimo/run-on-arch-action@v2 with: arch: ${{ matrix.arch }} - distro: ubuntu20.04 + distro: ubuntu_latest install: | apt-get update -q -y apt-get install -q -y --no-install-recommends build-essential valgrind env: | - target: ${{ matrix.target }} + # Valgrind on arm will fail if the stack size is larger than 8MB. + # Set QEMUs stack size to 8MB since Github runners use 16MB default. + QEMU_STACK_SIZE: 8388608 run: | mkdir build cd build From a1bf758954c104eacc25352dff8a4ee1e264030a Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Tue, 6 Jun 2023 23:49:41 -0400 Subject: [PATCH 13/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 9e0be7e..7dc036c 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -24,7 +24,7 @@ jobs: distro: ubuntu_latest install: | apt-get update -q -y - apt-get install -q -y --no-install-recommends build-essential valgrind + apt-get install -q -y --no-install-recommends cmake build-essential valgrind env: | # Valgrind on arm will fail if the stack size is larger than 8MB. # Set QEMUs stack size to 8MB since Github runners use 16MB default. From fb2f845fa62accffbe51d91ef982fae7aa8df7e0 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 07:05:14 -0400 Subject: [PATCH 14/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 7dc036c..50b771c 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -16,6 +16,10 @@ jobs: arch: aarch64 - target: ppc64v2 arch: ppc64le + - target: riscv64 + arch: riscv64 + - target: s390x + arch: s390x steps: - uses: actions/checkout@v3 - uses: uraimo/run-on-arch-action@v2 From b4ab678ab9b8af70ab5459354c7b267cf750a21e Mon Sep 17 00:00:00 2001 From: TheTechsTech Date: Wed, 7 Jun 2023 15:25:21 -0400 Subject: [PATCH 15/38] corrections, bug fix arm build, move mips-ucontext --- .github/workflows/ci_qemu.yml | 2 +- src/context.c | 19 +++++++++++++----- mips-ucontext.h => src/mips-ucontext.h | 0 src/taskimpl.h | 27 ++++++++++++-------------- 4 files changed, 27 insertions(+), 21 deletions(-) rename mips-ucontext.h => src/mips-ucontext.h (100%) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 50b771c..7209ba4 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -28,7 +28,7 @@ jobs: distro: ubuntu_latest install: | apt-get update -q -y - apt-get install -q -y --no-install-recommends cmake build-essential valgrind + apt-get install -q -y --no-install-recommends cmake build-essential env: | # Valgrind on arm will fail if the stack size is larger than 8MB. # Set QEMUs stack size to 8MB since Github runners use 16MB default. diff --git a/src/context.c b/src/context.c index 4699f88..ed886c9 100644 --- a/src/context.c +++ b/src/context.c @@ -43,7 +43,7 @@ makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) va_list arg; tos = (ulong*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/sizeof(ulong); - sp = tos - 16; + sp = tos - 16; ucp->mc.pc = (long)func; ucp->mc.sp = (long)sp; va_start(arg, argc); @@ -98,14 +98,24 @@ makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) { int i, *sp; va_list arg; - + sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4; va_start(arg, argc); +/* for(i=0; i<4 && iuc_mcontext.gregs[i] = va_arg(arg, uint); - va_end(arg); +*/ + if (argc-- > 0) uc->uc_mcontext.arm_r0 = va_arg(arg, uint); + if (argc-- > 0) uc->uc_mcontext.arm_r1 = va_arg(arg, uint); + if (argc-- > 0) uc->uc_mcontext.arm_r2 = va_arg(arg, uint); + if (argc-- > 0) uc->uc_mcontext.arm_r3 = va_arg(arg, uint); + va_end(arg); +/* uc->uc_mcontext.gregs[13] = (uint)sp; uc->uc_mcontext.gregs[14] = (uint)fn; +*/ + uc->uc_mcontext.arm_sp = (uint)sp; + uc->uc_mcontext.arm_lr = (uint)fn; } #endif @@ -115,7 +125,7 @@ makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) { int i, *sp; va_list arg; - + va_start(arg, argc); sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4; for(i=0; i<4 && i #include + #if defined(_WIN32) || defined(_WIN64) #include "compat/unistd.h" +#include "compat/sys/time.h" +#include "compat/wait.h" #else #include +#include +#include #endif + #include #include #include -#if defined(_WIN32) || defined(_WIN64) -#include "compat/sys/time.h" -#else -#include -#endif #include -#if defined(_WIN32) || defined(_WIN64) -#include "compat/wait.h" -#else -#include -#endif - #include #if USE_UCONTEXT - #if defined(_WIN32) || defined(_WIN64) -#include "ucontext.h" + #include "ucontext.h" #else -#include + #include #endif - #endif #if defined(_WIN32) || defined(_WIN64) @@ -150,8 +143,12 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #if defined(__arm__) int getmcontext(mcontext_t*); void setmcontext(const mcontext_t*); +/* #define setcontext(u) setmcontext(&(u)->uc_mcontext) #define getcontext(u) getmcontext(&(u)->uc_mcontext) +*/ +#define setcontext(u) setmcontext((void *)&((u)->uc_mcontext.arm_r0)) +#define getcontext(u) getmcontext((void *)&((u)->uc_mcontext.arm_r0)) #endif #if defined(__mips__) From ba23f495670302650af0e6212d3c14b3e5061ff9 Mon Sep 17 00:00:00 2001 From: TheTechsTech Date: Wed, 7 Jun 2023 17:02:52 -0400 Subject: [PATCH 16/38] Update taskimpl.h --- src/taskimpl.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/taskimpl.h b/src/taskimpl.h index 0c9be2d..3f081fe 100644 --- a/src/taskimpl.h +++ b/src/taskimpl.h @@ -141,9 +141,12 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #endif #if defined(__arm__) + +extern int getmcontext(mcontext_t *); +extern void setmcontext(const mcontext_t *); +/* int getmcontext(mcontext_t*); void setmcontext(const mcontext_t*); -/* #define setcontext(u) setmcontext(&(u)->uc_mcontext) #define getcontext(u) getmcontext(&(u)->uc_mcontext) */ From f564ef2760676c0dae1adeee1473fab407e4878c Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 19:02:34 -0400 Subject: [PATCH 17/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 73 +++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 7209ba4..4c25e52 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -4,41 +4,58 @@ on: [push, pull_request] jobs: build-qemu: - name: ${{ matrix.target }} + name: ${{ matrix.config.target }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - include: - - target: arm - arch: armv7 - - target: aarch64 - arch: aarch64 - - target: ppc64v2 - arch: ppc64le - - target: riscv64 - arch: riscv64 - - target: s390x - arch: s390x + config: + - {target: arm, toolchain: gcc-arm-linux-gnueabi, cc: arm-linux-gnueabi-gcc, qemu: qemu-arm-static } + - {target: armhf, toolchain: gcc-arm-linux-gnueabihf, cc: arm-linux-gnueabihf-gcc, qemu: qemu-arm-static } + - {target: aarch64, toolchain: gcc-aarch64-linux-gnu, cc: aarch64-linux-gnu-gcc, qemu: qemu-aarch64-static } + - {target: riscv64, toolchain: gcc-riscv64-linux-gnu, cc: riscv64-linux-gnu-gcc, qemu: qemu-riscv64-static } + - {target: ppc, toolchain: gcc-powerpc-linux-gnu, cc: powerpc-linux-gnu-gcc, qemu: qemu-ppc-static } + - {target: ppc64, toolchain: gcc-powerpc64-linux-gnu, cc: powerpc64-linux-gnu-gcc, qemu: qemu-ppc64-static } + - {target: ppc64le, toolchain: gcc-powerpc64le-linux-gnu, cc: powerpc64le-linux-gnu-gcc, qemu: qemu-ppc64le-static } + - {target: s390x, toolchain: gcc-s390x-linux-gnu, cc: s390x-linux-gnu-gcc, qemu: qemu-s390x-static } + - {target: mips, toolchain: gcc-mips-linux-gnu, cc: mips-linux-gnu-gcc, qemu: qemu-mips-static } + - {target: mips64, toolchain: gcc-mips64-linux-gnuabi64, cc: mips64-linux-gnuabi64-gcc, qemu: qemu-mips64-static } + - {target: mipsel, toolchain: gcc-mipsel-linux-gnu, cc: mipsel-linux-gnu-gcc, qemu: qemu-mipsel-static } + - {target: mips64el,toolchain: gcc-mips64el-linux-gnuabi64, cc: mips64el-linux-gnuabi64-gcc,qemu: qemu-mips64el-static } + - {target: arm (u64 slots), toolchain: gcc-arm-linux-gnueabi, cc: arm-linux-gnueabi-gcc, qemu: qemu-arm-static} + - {target: aarch64 (u64 slots), toolchain: gcc-aarch64-linux-gnu, cc: aarch64-linux-gnu-gcc, qemu: qemu-aarch64-static} + - {target: ppc (u64 slots), toolchain: gcc-powerpc-linux-gnu, cc: powerpc-linux-gnu-gcc, qemu: qemu-ppc-static} + - {target: ppc64 (u64 slots), toolchain: gcc-powerpc64-linux-gnu, cc: powerpc64-linux-gnu-gcc, qemu: qemu-ppc64-static} + steps: - uses: actions/checkout@v3 - - uses: uraimo/run-on-arch-action@v2 - with: - arch: ${{ matrix.arch }} - distro: ubuntu_latest - install: | - apt-get update -q -y - apt-get install -q -y --no-install-recommends cmake build-essential - env: | - # Valgrind on arm will fail if the stack size is larger than 8MB. - # Set QEMUs stack size to 8MB since Github runners use 16MB default. - QEMU_STACK_SIZE: 8388608 - run: | - mkdir build - cd build - cmake .. + - name: Install QEMU + # this ensure install latest qemu on ubuntu, apt get version is old + env: + QEMU_SRC: "http://archive.ubuntu.com/ubuntu/pool/universe/q/qemu" + QEMU_VER: "qemu-user-static_7\\.0+dfsg-.*_amd64.deb$" + QEMU_STACK_SIZE: 8388608 + run: | + DEB=`curl -s $QEMU_SRC/ | grep -o -E 'href="([^"#]+)"' | cut -d'"' -f2 | grep $QEMU_VER | tail -1` + wget $QEMU_SRC/$DEB + sudo dpkg -i $DEB + - name: Install ${{ matrix.config.toolchain }} + run: | + sudo apt update + sudo apt install ${{ matrix.config.toolchain }} -y + - name: Configure with ${{ matrix.config.cc }} + run: | + mkdir build + cd build + cmake .. -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=${{ matrix.config.cc }} + - name: Build + run: | cmake --build . - cd bin + - name: Test + run: | + ${{ matrix.config.qemu }} ./chan_3 + ${{ matrix.config.qemu }} ./primes + ${{ matrix.config.qemu }} ./testdelay 2 ./chan_3 ./primes ./testdelay 2 From f10b2506668688c01ff7bf4c9d4ab5f15a640830 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 19:17:16 -0400 Subject: [PATCH 18/38] update ci_qemu.yml and CMakeLists.txt --- .github/workflows/ci_qemu.yml | 5 ++--- CMakeLists.txt | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 4c25e52..4d60b19 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -34,7 +34,6 @@ jobs: env: QEMU_SRC: "http://archive.ubuntu.com/ubuntu/pool/universe/q/qemu" QEMU_VER: "qemu-user-static_7\\.0+dfsg-.*_amd64.deb$" - QEMU_STACK_SIZE: 8388608 run: | DEB=`curl -s $QEMU_SRC/ | grep -o -E 'href="([^"#]+)"' | cut -d'"' -f2 | grep $QEMU_VER | tail -1` wget $QEMU_SRC/$DEB @@ -47,10 +46,10 @@ jobs: run: | mkdir build cd build - cmake .. -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=${{ matrix.config.cc }} + cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.cc }} - name: Build run: | - cmake --build . + cmake --build . --config Debug - name: Test run: | ${{ matrix.config.qemu }} ./chan_3 diff --git a/CMakeLists.txt b/CMakeLists.txt index c06d0c5..a8b86ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,11 +2,12 @@ cmake_minimum_required(VERSION 3.10) project(LIBTASK C) +include(CMakeDependentOption) +include(CheckCCompilerFlag) + set(C_STANDARD 89) -if(WIN32) - set(CMAKE_GENERATOR_PLATFORM Win32) -endif() +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if(UNIX) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g ") From b067916d319c7b6ca30f69baa4735a3215a69615 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 19:22:18 -0400 Subject: [PATCH 19/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 4d60b19..9b05da3 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -28,7 +28,7 @@ jobs: - {target: ppc64 (u64 slots), toolchain: gcc-powerpc64-linux-gnu, cc: powerpc64-linux-gnu-gcc, qemu: qemu-ppc64-static} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Install QEMU # this ensure install latest qemu on ubuntu, apt get version is old env: @@ -42,19 +42,15 @@ jobs: run: | sudo apt update sudo apt install ${{ matrix.config.toolchain }} -y - - name: Configure with ${{ matrix.config.cc }} + - name: Configure build and Test with ${{ matrix.config.cc }} run: | mkdir build cd build cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.cc }} - - name: Build - run: | - cmake --build . --config Debug - - name: Test - run: | - ${{ matrix.config.qemu }} ./chan_3 - ${{ matrix.config.qemu }} ./primes - ${{ matrix.config.qemu }} ./testdelay 2 - ./chan_3 - ./primes - ./testdelay 2 + cmake --build . --config Debug + ${{ matrix.config.qemu }} ./chan_3 + ${{ matrix.config.qemu }} ./primes + ${{ matrix.config.qemu }} ./testdelay 2 + ./chan_3 + ./primes + ./testdelay 2 From a07489a31d261481240662c3e6b86172016127e3 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 19:28:22 -0400 Subject: [PATCH 20/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 9b05da3..f6b788c 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -47,10 +47,7 @@ jobs: mkdir build cd build cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.cc }} - cmake --build . --config Debug - ${{ matrix.config.qemu }} ./chan_3 - ${{ matrix.config.qemu }} ./primes - ${{ matrix.config.qemu }} ./testdelay 2 + cmake --build . ./chan_3 ./primes ./testdelay 2 From 5d8a4c56ab93588b74c009efb2bc4840f4390c63 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 19:42:18 -0400 Subject: [PATCH 21/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index f6b788c..47d96ce 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -48,6 +48,7 @@ jobs: cd build cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.cc }} cmake --build . + cd bin ./chan_3 ./primes ./testdelay 2 From 612afe0665410d3cd2008d13a3dad4a78e439558 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 19:45:27 -0400 Subject: [PATCH 22/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 47d96ce..343e51a 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -49,6 +49,6 @@ jobs: cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.cc }} cmake --build . cd bin - ./chan_3 - ./primes - ./testdelay 2 + ${{ matrix.config.qemu }} ./chan_3 + ${{ matrix.config.qemu }} ./primes + ${{ matrix.config.qemu }} ./testdelay 2 From 3cca83c92c766a2a9c83b9b9fc93e6e4656eaea7 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 19:49:23 -0400 Subject: [PATCH 23/38] update CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8b86ff..e877642 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project(LIBTASK C) include(CMakeDependentOption) include(CheckCCompilerFlag) +include(GNUInstallDirs) set(C_STANDARD 89) From bd350f7265a43861528fd1718d23c4a6b4cf072b Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 19:57:24 -0400 Subject: [PATCH 24/38] update CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e877642..a61d3e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ include(GNUInstallDirs) set(C_STANDARD 89) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +option(QEMU "build for qemu" ON) if(UNIX) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g ") From 8d3f98e8acbdbad37c47887f769f55f66f32c9fe Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 20:07:38 -0400 Subject: [PATCH 25/38] revert ci_qemu.yml and CMakeLists.txt --- .github/workflows/ci_qemu.yml | 76 +++++++++++++++-------------------- CMakeLists.txt | 7 ---- 2 files changed, 33 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 343e51a..7209ba4 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -4,51 +4,41 @@ on: [push, pull_request] jobs: build-qemu: - name: ${{ matrix.config.target }} + name: ${{ matrix.target }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - config: - - {target: arm, toolchain: gcc-arm-linux-gnueabi, cc: arm-linux-gnueabi-gcc, qemu: qemu-arm-static } - - {target: armhf, toolchain: gcc-arm-linux-gnueabihf, cc: arm-linux-gnueabihf-gcc, qemu: qemu-arm-static } - - {target: aarch64, toolchain: gcc-aarch64-linux-gnu, cc: aarch64-linux-gnu-gcc, qemu: qemu-aarch64-static } - - {target: riscv64, toolchain: gcc-riscv64-linux-gnu, cc: riscv64-linux-gnu-gcc, qemu: qemu-riscv64-static } - - {target: ppc, toolchain: gcc-powerpc-linux-gnu, cc: powerpc-linux-gnu-gcc, qemu: qemu-ppc-static } - - {target: ppc64, toolchain: gcc-powerpc64-linux-gnu, cc: powerpc64-linux-gnu-gcc, qemu: qemu-ppc64-static } - - {target: ppc64le, toolchain: gcc-powerpc64le-linux-gnu, cc: powerpc64le-linux-gnu-gcc, qemu: qemu-ppc64le-static } - - {target: s390x, toolchain: gcc-s390x-linux-gnu, cc: s390x-linux-gnu-gcc, qemu: qemu-s390x-static } - - {target: mips, toolchain: gcc-mips-linux-gnu, cc: mips-linux-gnu-gcc, qemu: qemu-mips-static } - - {target: mips64, toolchain: gcc-mips64-linux-gnuabi64, cc: mips64-linux-gnuabi64-gcc, qemu: qemu-mips64-static } - - {target: mipsel, toolchain: gcc-mipsel-linux-gnu, cc: mipsel-linux-gnu-gcc, qemu: qemu-mipsel-static } - - {target: mips64el,toolchain: gcc-mips64el-linux-gnuabi64, cc: mips64el-linux-gnuabi64-gcc,qemu: qemu-mips64el-static } - - {target: arm (u64 slots), toolchain: gcc-arm-linux-gnueabi, cc: arm-linux-gnueabi-gcc, qemu: qemu-arm-static} - - {target: aarch64 (u64 slots), toolchain: gcc-aarch64-linux-gnu, cc: aarch64-linux-gnu-gcc, qemu: qemu-aarch64-static} - - {target: ppc (u64 slots), toolchain: gcc-powerpc-linux-gnu, cc: powerpc-linux-gnu-gcc, qemu: qemu-ppc-static} - - {target: ppc64 (u64 slots), toolchain: gcc-powerpc64-linux-gnu, cc: powerpc64-linux-gnu-gcc, qemu: qemu-ppc64-static} - + include: + - target: arm + arch: armv7 + - target: aarch64 + arch: aarch64 + - target: ppc64v2 + arch: ppc64le + - target: riscv64 + arch: riscv64 + - target: s390x + arch: s390x steps: - - uses: actions/checkout@v2 - - name: Install QEMU - # this ensure install latest qemu on ubuntu, apt get version is old - env: - QEMU_SRC: "http://archive.ubuntu.com/ubuntu/pool/universe/q/qemu" - QEMU_VER: "qemu-user-static_7\\.0+dfsg-.*_amd64.deb$" - run: | - DEB=`curl -s $QEMU_SRC/ | grep -o -E 'href="([^"#]+)"' | cut -d'"' -f2 | grep $QEMU_VER | tail -1` - wget $QEMU_SRC/$DEB - sudo dpkg -i $DEB - - name: Install ${{ matrix.config.toolchain }} - run: | - sudo apt update - sudo apt install ${{ matrix.config.toolchain }} -y - - name: Configure build and Test with ${{ matrix.config.cc }} - run: | - mkdir build - cd build - cmake .. -DCMAKE_C_COMPILER=${{ matrix.config.cc }} - cmake --build . - cd bin - ${{ matrix.config.qemu }} ./chan_3 - ${{ matrix.config.qemu }} ./primes - ${{ matrix.config.qemu }} ./testdelay 2 + - uses: actions/checkout@v3 + - uses: uraimo/run-on-arch-action@v2 + with: + arch: ${{ matrix.arch }} + distro: ubuntu_latest + install: | + apt-get update -q -y + apt-get install -q -y --no-install-recommends cmake build-essential + env: | + # Valgrind on arm will fail if the stack size is larger than 8MB. + # Set QEMUs stack size to 8MB since Github runners use 16MB default. + QEMU_STACK_SIZE: 8388608 + run: | + mkdir build + cd build + cmake .. + cmake --build . + cd bin + ./chan_3 + ./primes + ./testdelay 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index a61d3e3..a54e85e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,15 +2,8 @@ cmake_minimum_required(VERSION 3.10) project(LIBTASK C) -include(CMakeDependentOption) -include(CheckCCompilerFlag) -include(GNUInstallDirs) - set(C_STANDARD 89) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -option(QEMU "build for qemu" ON) - if(UNIX) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g ") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fomit-frame-pointer ") From 96a7ef04639bedbe2750fd99e0c324cb28774999 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 21:13:35 -0400 Subject: [PATCH 26/38] update context.c and taskimpl.h --- src/arm-ucontext.h | 32 ++++++++++++++++++++++++++++++++ src/context.c | 11 +---------- src/taskimpl.h | 12 +----------- 3 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 src/arm-ucontext.h diff --git a/src/arm-ucontext.h b/src/arm-ucontext.h new file mode 100644 index 0000000..a3f51e7 --- /dev/null +++ b/src/arm-ucontext.h @@ -0,0 +1,32 @@ +#define setcontext(u) setmcontext(&(u)->uc_mcontext) +#define getcontext(u) getmcontext(&(u)->uc_mcontext) +typedef struct mcontext mcontext_t; +typedef struct ucontext ucontext_t; + +extern int swapcontext(ucontext_t*, const ucontext_t*); +extern void makecontext(ucontext_t*, void(*)(), int, ...); +extern int getmcontext(mcontext_t*); +extern void setmcontext(const mcontext_t*); + +struct mcontext { + int gregs[16]; +}; + +struct ucontext { + /* + * Keep the order of the first two fields. Also, + * keep them the first two fields in the structure. + * This way we can have a union with struct + * sigcontext and ucontext_t. This allows us to + * support them both at the same time. + * note: the union is not defined, though. + */ + sigset_t uc_sigmask; + mcontext_t uc_mcontext; + + struct __ucontext *uc_link; + stack_t uc_stack; + int __spare__[8]; +}; + + diff --git a/src/context.c b/src/context.c index ed886c9..5f38758 100644 --- a/src/context.c +++ b/src/context.c @@ -101,21 +101,12 @@ makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4; va_start(arg, argc); -/* for(i=0; i<4 && iuc_mcontext.gregs[i] = va_arg(arg, uint); -*/ - if (argc-- > 0) uc->uc_mcontext.arm_r0 = va_arg(arg, uint); - if (argc-- > 0) uc->uc_mcontext.arm_r1 = va_arg(arg, uint); - if (argc-- > 0) uc->uc_mcontext.arm_r2 = va_arg(arg, uint); - if (argc-- > 0) uc->uc_mcontext.arm_r3 = va_arg(arg, uint); va_end(arg); -/* + uc->uc_mcontext.gregs[13] = (uint)sp; uc->uc_mcontext.gregs[14] = (uint)fn; -*/ - uc->uc_mcontext.arm_sp = (uint)sp; - uc->uc_mcontext.arm_lr = (uint)fn; } #endif diff --git a/src/taskimpl.h b/src/taskimpl.h index 3f081fe..b0ce0da 100644 --- a/src/taskimpl.h +++ b/src/taskimpl.h @@ -141,17 +141,7 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #endif #if defined(__arm__) - -extern int getmcontext(mcontext_t *); -extern void setmcontext(const mcontext_t *); -/* -int getmcontext(mcontext_t*); -void setmcontext(const mcontext_t*); -#define setcontext(u) setmcontext(&(u)->uc_mcontext) -#define getcontext(u) getmcontext(&(u)->uc_mcontext) -*/ -#define setcontext(u) setmcontext((void *)&((u)->uc_mcontext.arm_r0)) -#define getcontext(u) getmcontext((void *)&((u)->uc_mcontext.arm_r0)) +#include "arm-ucontext.h" #endif #if defined(__mips__) From 6c97769f8cbbecca0cd7cd0919eb12852fe5d29d Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 21:43:05 -0400 Subject: [PATCH 27/38] update arm-ucontext.h --- src/arm-ucontext.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/arm-ucontext.h b/src/arm-ucontext.h index a3f51e7..fd250eb 100644 --- a/src/arm-ucontext.h +++ b/src/arm-ucontext.h @@ -1,18 +1,11 @@ #define setcontext(u) setmcontext(&(u)->uc_mcontext) #define getcontext(u) getmcontext(&(u)->uc_mcontext) -typedef struct mcontext mcontext_t; -typedef struct ucontext ucontext_t; -extern int swapcontext(ucontext_t*, const ucontext_t*); -extern void makecontext(ucontext_t*, void(*)(), int, ...); -extern int getmcontext(mcontext_t*); -extern void setmcontext(const mcontext_t*); - -struct mcontext { +typedef struct mcontext { int gregs[16]; -}; +} mcontext_t; -struct ucontext { +typedef struct ucontext { /* * Keep the order of the first two fields. Also, * keep them the first two fields in the structure. @@ -27,6 +20,7 @@ struct ucontext { struct __ucontext *uc_link; stack_t uc_stack; int __spare__[8]; -}; - +} ucontext_t; +extern int getmcontext(mcontext_t*); +extern void setmcontext(const mcontext_t*); From 8d4165d4bd8e22a3b197855c60c91195d35b2449 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 22:18:29 -0400 Subject: [PATCH 28/38] update arm-ucontext.h, context.c and taskimpl.h --- src/arm-ucontext.h | 18 +++++++++++------- src/context.c | 3 +++ src/taskimpl.h | 9 +++++++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/arm-ucontext.h b/src/arm-ucontext.h index fd250eb..791886e 100644 --- a/src/arm-ucontext.h +++ b/src/arm-ucontext.h @@ -1,11 +1,18 @@ #define setcontext(u) setmcontext(&(u)->uc_mcontext) #define getcontext(u) getmcontext(&(u)->uc_mcontext) +typedef struct mcontext mcontext_t; +typedef struct ucontext ucontext_t; -typedef struct mcontext { +extern int swapcontext(ucontext_t*, const ucontext_t*); +extern void makecontext(ucontext_t*, void(*)(), int, ...); +extern int getmcontext(mcontext_t*); +extern void setmcontext(const mcontext_t*); + +struct mcontext { int gregs[16]; -} mcontext_t; +}; -typedef struct ucontext { +struct ucontext { /* * Keep the order of the first two fields. Also, * keep them the first two fields in the structure. @@ -20,7 +27,4 @@ typedef struct ucontext { struct __ucontext *uc_link; stack_t uc_stack; int __spare__[8]; -} ucontext_t; - -extern int getmcontext(mcontext_t*); -extern void setmcontext(const mcontext_t*); +}; diff --git a/src/context.c b/src/context.c index 5f38758..a19f4cb 100644 --- a/src/context.c +++ b/src/context.c @@ -9,6 +9,9 @@ #elif defined(__x86_64__) #define NEEDAMD64MAKECONTEXT #define NEEDSWAPCONTEXT +#elif defined(__arm__) +#define NEEDARMMAKECONTEXT +#define NEEDSWAPCONTEXT #else #define NEEDPOWERMAKECONTEXT #define NEEDSWAPCONTEXT diff --git a/src/taskimpl.h b/src/taskimpl.h index b0ce0da..8fd8cd1 100644 --- a/src/taskimpl.h +++ b/src/taskimpl.h @@ -114,6 +114,8 @@ extern void makecontext(ucontext_t*, void(*)(), int, ...); # include "386-ucontext.h" # elif defined(__x86_64__) # include "amd64-ucontext.h" +# elif defined(__arm__) +# include "arm-ucontext.h" # else # include "power-ucontext.h" # endif @@ -140,8 +142,11 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); # include "sparc-ucontext.h" #endif -#if defined(__arm__) -#include "arm-ucontext.h" +#if defined(__arm__) && defined(__linux__) +int getmcontext(mcontext_t *); +void setmcontext(const mcontext_t *); +#define setcontext(u) setmcontext(&(u)->uc_mcontext) +#define getcontext(u) getmcontext(&(u)->uc_mcontext) #endif #if defined(__mips__) From a773ddacd8050f49c2db46bc6178817cce2a40b1 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 22:28:54 -0400 Subject: [PATCH 29/38] update taskimpl.h --- src/taskimpl.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/taskimpl.h b/src/taskimpl.h index 8fd8cd1..612de32 100644 --- a/src/taskimpl.h +++ b/src/taskimpl.h @@ -143,8 +143,15 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #endif #if defined(__arm__) && defined(__linux__) -int getmcontext(mcontext_t *); -void setmcontext(const mcontext_t *); +typedef struct mcontext mcontext_t; +struct mcontext +{ + int gregs[16]; +}; + +extern int getmcontext(mcontext_t *); +extern void setmcontext(const mcontext_t *); + #define setcontext(u) setmcontext(&(u)->uc_mcontext) #define getcontext(u) getmcontext(&(u)->uc_mcontext) #endif From 26c80d342adca34acc844d8cf2567886fe1918b2 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 22:38:37 -0400 Subject: [PATCH 30/38] update context.c and taskimpl.h --- src/context.c | 10 ++++++---- src/taskimpl.h | 9 ++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/context.c b/src/context.c index a19f4cb..8f21c4e 100644 --- a/src/context.c +++ b/src/context.c @@ -104,12 +104,14 @@ makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4; va_start(arg, argc); - for(i=0; i<4 && iuc_mcontext.gregs[i] = va_arg(arg, uint); + if (argc-- > 0) uc->uc_mcontext.arm_r0 = va_arg(arg, uint); + if (argc-- > 0) uc->uc_mcontext.arm_r1 = va_arg(arg, uint); + if (argc-- > 0) uc->uc_mcontext.arm_r2 = va_arg(arg, uint); + if (argc-- > 0) uc->uc_mcontext.arm_r3 = va_arg(arg, uint); va_end(arg); - uc->uc_mcontext.gregs[13] = (uint)sp; - uc->uc_mcontext.gregs[14] = (uint)fn; + uc->uc_mcontext.arm_sp = (uint)sp; + uc->uc_mcontext.arm_lr = (uint)fn; } #endif diff --git a/src/taskimpl.h b/src/taskimpl.h index 612de32..c4e6476 100644 --- a/src/taskimpl.h +++ b/src/taskimpl.h @@ -143,17 +143,12 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #endif #if defined(__arm__) && defined(__linux__) -typedef struct mcontext mcontext_t; -struct mcontext -{ - int gregs[16]; -}; extern int getmcontext(mcontext_t *); extern void setmcontext(const mcontext_t *); -#define setcontext(u) setmcontext(&(u)->uc_mcontext) -#define getcontext(u) getmcontext(&(u)->uc_mcontext) +#define setcontext(u) setmcontext((void *)&((u)->uc_mcontext.arm_r0)) +#define getcontext(u) getmcontext((void *)&((u)->uc_mcontext.arm_r0)) #endif #if defined(__mips__) From b876ac532857d3ed2b3155b340381778a8d2c5e3 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Wed, 7 Jun 2023 23:16:22 -0400 Subject: [PATCH 31/38] update --- src/taskimpl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/taskimpl.h b/src/taskimpl.h index c4e6476..7e8cb4f 100644 --- a/src/taskimpl.h +++ b/src/taskimpl.h @@ -143,7 +143,7 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #endif #if defined(__arm__) && defined(__linux__) - +#include extern int getmcontext(mcontext_t *); extern void setmcontext(const mcontext_t *); From cb71e4e9e05e1c190f6ff8f5afc9ca7f0f30be71 Mon Sep 17 00:00:00 2001 From: TheTechsTech Date: Thu, 8 Jun 2023 12:00:03 -0400 Subject: [PATCH 32/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 7209ba4..aff4ebd 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -25,10 +25,10 @@ jobs: - uses: uraimo/run-on-arch-action@v2 with: arch: ${{ matrix.arch }} - distro: ubuntu_latest + distro: ubuntu20.04 install: | apt-get update -q -y - apt-get install -q -y --no-install-recommends cmake build-essential + apt-get install -q -y --no-install-recommends cmake build-essential gcc-4.7 env: | # Valgrind on arm will fail if the stack size is larger than 8MB. # Set QEMUs stack size to 8MB since Github runners use 16MB default. From a6e1e366ae45fb91297bd640d3151739fda5fc27 Mon Sep 17 00:00:00 2001 From: TheTechsTech Date: Thu, 8 Jun 2023 12:02:31 -0400 Subject: [PATCH 33/38] Update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index aff4ebd..7fd87dc 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -28,7 +28,7 @@ jobs: distro: ubuntu20.04 install: | apt-get update -q -y - apt-get install -q -y --no-install-recommends cmake build-essential gcc-4.7 + apt-get install -q -y cmake build-essential env: | # Valgrind on arm will fail if the stack size is larger than 8MB. # Set QEMUs stack size to 8MB since Github runners use 16MB default. From 280a06ce28757dc1e7efea1c5d30b032cac6525a Mon Sep 17 00:00:00 2001 From: TheTechsTech Date: Thu, 8 Jun 2023 12:16:21 -0400 Subject: [PATCH 34/38] ci: update ci.yml and ci_qemu.yml --- .github/workflows/ci.yml | 2 +- .github/workflows/ci_qemu.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d94595..c96160a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: CI +name: windows & linux on: [push, pull_request] diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 7fd87dc..320554a 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -1,4 +1,4 @@ -name: CI-Qemu +name: arch64 & others by qemu on: [push, pull_request] @@ -25,10 +25,10 @@ jobs: - uses: uraimo/run-on-arch-action@v2 with: arch: ${{ matrix.arch }} - distro: ubuntu20.04 + distro: ubuntu_latest install: | apt-get update -q -y - apt-get install -q -y cmake build-essential + apt-get install -q -y --no-install-recommends cmake build-essential env: | # Valgrind on arm will fail if the stack size is larger than 8MB. # Set QEMUs stack size to 8MB since Github runners use 16MB default. From 7d8527049641c2f4011c7fb2663b34d459243eff Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Fri, 9 Jun 2023 00:11:29 -0400 Subject: [PATCH 35/38] skip building for armv7 not linking examples [ 50%] Building C object CMakeFiles/testdelay.dir/examples/testdelay.c.o [ 54%] Linking C executable bin/testdelay /usr/bin/ld: lib/libtask.a(task.c.o): in function `taskcreate': task.c:(.text+0x1ea): undefined reference to `getmcontext' /usr/bin/ld: lib/libtask.a(context.c.o): in function `swapcontext': context.c:(.text+0x82): undefined reference to `getmcontext' /usr/bin/ld: context.c:(.text+0x90): undefined reference to `setmcontext' collect2: error: ld returned 1 exit status --- .github/workflows/ci_qemu.yml | 2 -- src/taskimpl.h | 1 - 2 files changed, 3 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 7209ba4..226654d 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -10,8 +10,6 @@ jobs: fail-fast: false matrix: include: - - target: arm - arch: armv7 - target: aarch64 arch: aarch64 - target: ppc64v2 diff --git a/src/taskimpl.h b/src/taskimpl.h index 7e8cb4f..53b5fca 100644 --- a/src/taskimpl.h +++ b/src/taskimpl.h @@ -143,7 +143,6 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #endif #if defined(__arm__) && defined(__linux__) -#include extern int getmcontext(mcontext_t *); extern void setmcontext(const mcontext_t *); From 84c57b7a6eb545d794b12b362dee9ef0a24bd344 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Fri, 9 Jun 2023 19:46:59 -0400 Subject: [PATCH 36/38] ci: update ci_qemu.yml --- .github/workflows/ci_qemu.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index 37b299f..ae38c5b 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -10,23 +10,33 @@ jobs: fail-fast: false matrix: include: + - target: arm + arch: armv6 + distro: buster + - target: arm + arch: armv7 + distro: archarm_latest - target: aarch64 arch: aarch64 + distro: ubuntu_latest - target: ppc64v2 arch: ppc64le + distro: ubuntu_latest - target: riscv64 arch: riscv64 + distro: ubuntu_latest - target: s390x arch: s390x + distro: ubuntu_latest steps: - uses: actions/checkout@v3 - uses: uraimo/run-on-arch-action@v2 with: arch: ${{ matrix.arch }} - distro: ubuntu_latest + distro: ${{ matrix.distro }} install: | apt-get update -q -y - apt-get install -q -y --no-install-recommends cmake build-essential + apt-get install -q -y cmake build-essential env: | # Valgrind on arm will fail if the stack size is larger than 8MB. # Set QEMUs stack size to 8MB since Github runners use 16MB default. From 74a1b416d6e917404706b2d08c8dce307949a46c Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Fri, 9 Jun 2023 20:05:35 -0400 Subject: [PATCH 37/38] revert/restore skip building for armv7 not linking examples [ 50%] Building C object CMakeFiles/testdelay.dir/examples/testdelay.c.o [ 54%] Linking C executable bin/testdelay /usr/bin/ld: lib/libtask.a(task.c.o): in function `taskcreate': task.c:(.text+0x1ea): undefined reference to `getmcontext' /usr/bin/ld: lib/libtask.a(context.c.o): in function `swapcontext': context.c:(.text+0x82): undefined reference to `getmcontext' /usr/bin/ld: context.c:(.text+0x90): undefined reference to `setmcontext' collect2: error: ld returned 1 exit status --- .github/workflows/ci_qemu.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci_qemu.yml b/.github/workflows/ci_qemu.yml index ae38c5b..37b299f 100644 --- a/.github/workflows/ci_qemu.yml +++ b/.github/workflows/ci_qemu.yml @@ -10,33 +10,23 @@ jobs: fail-fast: false matrix: include: - - target: arm - arch: armv6 - distro: buster - - target: arm - arch: armv7 - distro: archarm_latest - target: aarch64 arch: aarch64 - distro: ubuntu_latest - target: ppc64v2 arch: ppc64le - distro: ubuntu_latest - target: riscv64 arch: riscv64 - distro: ubuntu_latest - target: s390x arch: s390x - distro: ubuntu_latest steps: - uses: actions/checkout@v3 - uses: uraimo/run-on-arch-action@v2 with: arch: ${{ matrix.arch }} - distro: ${{ matrix.distro }} + distro: ubuntu_latest install: | apt-get update -q -y - apt-get install -q -y cmake build-essential + apt-get install -q -y --no-install-recommends cmake build-essential env: | # Valgrind on arm will fail if the stack size is larger than 8MB. # Set QEMUs stack size to 8MB since Github runners use 16MB default. From a1fe2df2708f4e0fd6f68c82be37a271e324c304 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Sun, 11 Jun 2023 11:40:42 -0400 Subject: [PATCH 38/38] skip delay polling Windows, not working correctly --- src/fd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fd.c b/src/fd.c index 5d60139..a5bcb67 100644 --- a/src/fd.c +++ b/src/fd.c @@ -75,11 +75,9 @@ void fdtask(void *v) } #if defined(_WIN32) || defined(_WIN64) - if (WSAPoll(pollfd, npollfd, ms) < 0) + /* if (WSAPoll(pollfd, npollfd, ms) < 0) */ #else if (poll(pollfd, npollfd, ms) < 0) -#endif - { if (errno == EINTR) continue; @@ -98,6 +96,7 @@ void fdtask(void *v) polltask[i] = polltask[npollfd]; } } +#endif now = nsec(); while ((t = sleeping.head) && now >= t->alarmtime) {