... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
CC=gcc |
2 |
-CFLAGS=-g -Wall |
|
2 |
+CFLAGS=-g -Wall -pthread |
|
3 | 3 |
LDFLAGS= |
4 | 4 |
|
5 | 5 |
all: imgmover imgmover.exe |
... | ... |
@@ -8,9 +8,10 @@ imgmover: imgmover.c roboto_regular.c |
8 | 8 |
$(CC) $(CFLAGS) -Iexternal/raylib/include/ imgmover.c external/raylib/libraylib.a -lm $(LDFLAGS) -o imgmover |
9 | 9 |
|
10 | 10 |
imgmover.exe: imgmover.c roboto_regular.c |
11 |
- sh -c "if [ ! -e test-icon_256x256.png ] ; then convert -size 256x256 xc:white test-icon_256x256.png ; fi" |
|
11 |
+ sh -c "if [ ! -e test-icon_256x256.png ] ; then convert -size 256x256 xc:white test-icon_256x256.png ; fi" |
|
12 | 12 |
toolchain-zig/compile.sh imgmover.c -c -o imgmover-windows.o |
13 |
- toolchain-zig/link.sh -icon test-icon_256x256.png imgmover.exe imgmover-windows.o toolchain-zig/windows-msys2-mingw/lib/libraylib.a |
|
13 |
+ toolchain-zig/compile.sh win32_pipe.c -c -o win32_pipe-windows.o |
|
14 |
+ toolchain-zig/link.sh -icon test-icon_256x256.png imgmover.exe imgmover-windows.o win32_pipe-windows.o toolchain-zig/windows-msys2-mingw/lib/libraylib.a toolchain-zig/windows-msys2-mingw/lib/libpthread.a toolchain-zig/windows-msys2-mingw/lib/libwinpthread.a |
|
14 | 15 |
|
15 | 16 |
roboto_regular.c: ttf2h.sh fonts/Roboto-Regular.ttf |
16 | 17 |
./ttf2h.sh fonts/Roboto-Regular.ttf |
... | ... |
@@ -18,5 +19,5 @@ roboto_regular.c: ttf2h.sh fonts/Roboto-Regular.ttf |
18 | 19 |
roboto_regular.h: roboto_regular.c |
19 | 20 |
|
20 | 21 |
clean: |
21 |
- rm -f imgmover-windows.o imgmover imgmover.exe |
|
22 |
+ rm -f imgmover-windows.o win32_pipe-windows.o imgmover imgmover.exe |
|
22 | 23 |
|
... | ... |
@@ -32,6 +32,7 @@ |
32 | 32 |
* Dirdata colors. Select dirdata. |
33 | 33 |
* 20250329 Background loading of thumbnails. |
34 | 34 |
* 20250330 Refine background loading. |
35 |
+ * 20250413 Background loading for windows target. |
|
35 | 36 |
* |
36 | 37 |
* Author: Dario Rodriguez dario@darionomono.com |
37 | 38 |
* (c) Dario Rodriguez 2025 |
... | ... |
@@ -326,6 +327,8 @@ int bg_freeunmarked(bg_t *bg); |
326 | 327 |
|
327 | 328 |
void *bg_thread(void *); |
328 | 329 |
|
330 |
+static int mypipe(int fds[2]); |
|
331 |
+ |
|
329 | 332 |
int |
330 | 333 |
main(int argc, char *argv[]) |
331 | 334 |
{ |
... | ... |
@@ -1852,7 +1855,7 @@ bg_init(int sizebgload) |
1852 | 1855 |
bg=NULL; |
1853 | 1856 |
if((bg=calloc(1,sizeof(bg_t)))==NULL |
1854 | 1857 |
|| (bg->pipe[0]=bg->pipe[1]=-1)!=-1 |
1855 |
- || pipe(bg->pipe)!=0 |
|
1858 |
+ || mypipe(bg->pipe)!=0 |
|
1856 | 1859 |
|| (bg->bgload=calloc(sizebgload,sizeof(bgload_t)))==NULL |
1857 | 1860 |
|| (bg->sizebgload=sizebgload)!=sizebgload |
1858 | 1861 |
|| pthread_attr_init(&(bg->tattr))!=0 |
... | ... |
@@ -2018,3 +2021,18 @@ bg_thread(void *parambg) |
2018 | 2021 |
pthread_exit(NULL); |
2019 | 2022 |
} |
2020 | 2023 |
|
2024 |
+#if !defined(__linux__) && !defined(ANDROID) |
|
2025 |
+#include "win32_pipe.h" |
|
2026 |
+static int |
|
2027 |
+mypipe(int fds[2]) |
|
2028 |
+{ |
|
2029 |
+ return(win32_pipe(fds)); |
|
2030 |
+} |
|
2031 |
+#else |
|
2032 |
+static int |
|
2033 |
+mypipe(char fds[2]) |
|
2034 |
+{ |
|
2035 |
+ return(pipe(fds)); |
|
2036 |
+} |
|
2037 |
+#endif |
|
2038 |
+ |
2021 | 2039 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,57 @@ |
1 |
+#include <winsock2.h> |
|
2 |
+ |
|
3 |
+#ifndef FILLIPV4ADDR |
|
4 |
+#define FILLIPV4ADDR(a,family,addr,port) \ |
|
5 |
+ memset(&(a),0,sizeof(struct sockaddr_in)),\ |
|
6 |
+ s.sin_family=family,\ |
|
7 |
+ s.sin_addr.s_addr=addr,\ |
|
8 |
+ s.sin_port=htons(port) |
|
9 |
+#endif |
|
10 |
+ |
|
11 |
+#ifndef SHUT_WR |
|
12 |
+#define SHUT_WR SD_SEND |
|
13 |
+#endif |
|
14 |
+ |
|
15 |
+#ifndef SHUT_RD |
|
16 |
+#define SHUT_RD SD_RECEIVE |
|
17 |
+#endif |
|
18 |
+ |
|
19 |
+#define close(s) closesocket(s) |
|
20 |
+ |
|
21 |
+int |
|
22 |
+win32_pipe(int fds[2]) |
|
23 |
+{ |
|
24 |
+ int serverfd,workfd,clientfd; |
|
25 |
+ struct sockaddr_in c,s; |
|
26 |
+ int sizes,sizec; |
|
27 |
+ FILLIPV4ADDR(s,AF_INET,htonl(INADDR_ANY),0); |
|
28 |
+ serverfd=workfd=clientfd=-1; |
|
29 |
+ if((serverfd=socket(AF_INET,SOCK_STREAM,0))==-1 |
|
30 |
+ || bind(serverfd,(struct sockaddr *)&s,sizeof(s))!=0 |
|
31 |
+ || listen(serverfd,1)==-1 |
|
32 |
+ || (sizes=sizeof(s))!=sizeof(s) |
|
33 |
+ || getsockname(serverfd,(struct sockaddr *)&s,&sizes)==-1 |
|
34 |
+ || memcpy(&c,&s,sizeof(c))==NULL |
|
35 |
+ || (clientfd=socket(AF_INET,SOCK_STREAM,0))==-1 |
|
36 |
+ || connect(clientfd,(struct sockaddr *)&c,sizeof(c))==-1 |
|
37 |
+ || (sizes=sizeof(s))!=sizeof(s) |
|
38 |
+ || (workfd=accept(serverfd,(struct sockaddr *)&s,&sizes))==-1 |
|
39 |
+ || (sizec=sizeof(c))!=sizeof(c) |
|
40 |
+ || getsockname(workfd,(struct sockaddr *)&c,&sizec)==-1 |
|
41 |
+ || memcmp(&c,&s,sizeof(c))!=0 |
|
42 |
+ ) { |
|
43 |
+ if(serverfd!=-1) |
|
44 |
+ close(serverfd),serverfd=-1; |
|
45 |
+ if(clientfd!=-1) |
|
46 |
+ close(clientfd),clientfd=-1; |
|
47 |
+ if(workfd!=-1) |
|
48 |
+ close(workfd),workfd=-1; |
|
49 |
+ } |
|
50 |
+ close(serverfd),serverfd=-1; |
|
51 |
+ shutdown(workfd,SHUT_WR); |
|
52 |
+ shutdown(clientfd,SHUT_RD); |
|
53 |
+ fds[0]=workfd,workfd=-1; |
|
54 |
+ fds[1]=clientfd,clientfd=-1; |
|
55 |
+ return(0); |
|
56 |
+} |
|
57 |
+ |