File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #define _GNU_SOURCE
2+ #include <unistd.h>
3+ #include <sys/syscall.h>
4+ #include <errno.h>
5+
6+ #ifdef __linux__
7+ #ifndef SYS_copy_file_range
8+ // Fallback implementation using read/write
9+ ssize_t copy_file_range (int fd_in , loff_t * off_in , int fd_out ,
10+ loff_t * off_out , size_t len , unsigned int flags )
11+ {
12+ char buf [8192 ];
13+ ssize_t bytes_read , bytes_written ;
14+ size_t total = 0 ;
15+
16+ while (total < len ) {
17+ size_t to_read = len - total ;
18+ if (to_read > sizeof (buf ))
19+ to_read = sizeof (buf );
20+
21+ bytes_read = read (fd_in , buf , to_read );
22+ if (bytes_read <= 0 )
23+ return total > 0 ? total : bytes_read ;
24+
25+ bytes_written = write (fd_out , buf , bytes_read );
26+ if (bytes_written != bytes_read )
27+ return -1 ;
28+
29+ total += bytes_written ;
30+ }
31+
32+ return total ;
33+ }
34+ #endif
35+ #endif
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ def configure(config: ZigCcConfig):
2929
3030 # Use wrapper for quickjs.c to ensure stddef.h is included
3131 config ["sources" ].append ("c-sources/quickjs_wrapper.c" )
32+
33+ # Add compatibility layer for older Linux systems
34+ if os .name == "posix" and os .uname ().sysname == "Linux" :
35+ config ["sources" ].append ("c-sources/compat.c" )
3236
3337 for src in qjs_sources :
3438 config ["sources" ].append (os .path .join (qjs_root , src ))
@@ -45,3 +49,4 @@ def configure(config: ZigCcConfig):
4549 config ["defines" ].append ("_GNU_SOURCE" )
4650 config ["defines" ].append ('CONFIG_VERSION="2025-09-13"' )
4751 config ["defines" ].append ("CONFIG_BIGNUM" )
52+
You can’t perform that action at this time.
0 commit comments