Without this, negative numbers may change signedness
* libguile/bytevectors (is_signed_int8, is_unsigned_int8)
(is_signed_int16, is_unsigned_int16)[__MINGW32__ __x86_64__]:
use long long type.
* test-suite/tests/filesys.test (chmodat): some chmodat tests don't test if it
exists. Mark unwritable file writable before deleting.
("port representing a regular file"): reorder to avoid unclosed
port on exception.
For MinGW, there is a native signal function in UCRT. It handles
a limited set of signals.
* libguile/scmsigs.c (scm_sigaction_for_thread)[__MINGW32__]: removed
(scm_sigaction_for_thread)[!__MINGW32__]: use for MinGW as well.
For signals outside UCRT's native signal set, always return SIG_IGN.
* libguile/gc.c (scm_object_address): use uintptr_t instead of ulong
* libguile/gen-scmconfig.c (main): handle different sizes of scm_off_t
* libguile/integers.c (scm_integer_length_z): the mask size is bitcnt_max,
not UINTPTR_MAX
* libguile/ports.c (scm_set_port_line_x): test that line is an intptr_t,
not a long
* libguile/srfi-60.c (scm_srfi60_rotate_bit_fields): use correct size of
integer for bit-shifting
(scm_srfi60_reverse_bit_field): use correct integer size for bit-shifting
* libguile/symbols.h (scm_i_symbol_hash): cast to uintptr_t, not unsigned long
FIXME Apply this patch only when compiling for mingw.
Temporary hack until we have a proper fix to determine
compile-time-file-name-convention
* module/ice-9/boot-9.scm (compile-time-file-name-convention): Hardcode
to 'mingw instead of 'posix.
After installing a signal handler, these are handled
* C-c
* kill -SIGINT <guile.exe-pid> (the wine process) works
these result in a direct terminate (or kill even?)
- kill <guile.exe-pid>
- wine cmd /c guile -c '(kill <guile-exe.pid> SIGINT)'
- wine cmd /c guile -c '(kill <guile-exe.pid> SIGTERM)'
* libguile/scmsigs.c (mingw_take_signal)[__MINGW32__]: New function.
install_mingw_take_signal)[__MINGW32__]: New function.
(scm_init_scmsigs)[__MINGW32__]: Use it.
On MinGW, port-read will block on sockets if no data is available.
Avoid blocking by using select first.
* module/ice-9/suspendable-ports.scm (read-bytes): For socket ports,
guard port-read with select.
* module/ice-9/boot-9.scm (compile-time-file-name-convention): New
procedure, defined only when loading.
(compile-time-case): Use it to correctly determine system file name
convention while compiling.
On x86-64-MinGW the size of long is 4. As long is used for
SCM_FIXNUM_BIT, that would mean incompatible .go files, and waste of
cell space. So we would like to use long long, but the GMP interface
uses long.
To get around this, the x86-64-MinGW port now requires the use of
mini-GMP. Mini-GMP has been changed to use intptr_t and uintptr_t.
Likewise, "integers.{h,c}" and "numbers.{h,c}" now use intptr_t instead
of scm_t_inum or long, and uintptr_t instead of unsigned long.
* configure.ac: When x86_64-w64-mingw32, require mini-GMP.
* libguile/mini-gmp.h: Use intptr_t instead of long, uintptr_t instead
of unsigned long throughout.
* libguile/mini-gmp.c: Likewise.
* libguile/scm.h (SCM_INTPTR_T_BIT): New define.
* libguile/numbers.h (SCM_FIXNUM_BIT): Use it.
* libguile/numbers.c (L1, UL1): New macros. Use them thoughout instead
of 1L, 1UL.
(verify): Use SCM_INTPTR_T_BIT.
(verify): Use SCM_INTPTR_T_MAX and SCM_INTPTR_T_MIN.
(scm_from_inum): Remove macro.
Use intptr_t and uintptr_t instead of scm_t_inum or long, and unsigned
long.
* libguile/numbers.h (scm_from_intptr, scm_from_uintptr, scm_to_intptr,
scm_to_uintptr): New defines.
* libguile/integers.h: Use intptr_t and uintptr_t instead of scm_t_inum
and unsigned long.
* libguile/integers.c (L1) : New macro. Use it thoughout instead of 1L.
Use intptr_t and uintptr_t instead of long and unsigned long.
(long_magnitude): Rename to...
(intptr_t_magnitude): ...this. Use intptr_t, uintptr_t.
(negative_long): Rename to...
(negative_t_intptr): ...this. Use uintptr_t, INTPTR_MIN.
(inum_magnitude): Use intptr_t.
(ulong_to_bignum): Rename to...
(uintptr_t_to_bignum): ...this. Use uintptr_t.
(long_to_bignum): Rename to...
(intptr_t_to_bignum): ...this. Use intptr_t.
(long_to_scm): Rename to...
(intptr_t_to_scm): ...this. Use intptr_to_bignum.
(ulong_to_scm): Rename to...
(uintptr_t_to_scm): ...this. Use uintptr_to_bignum.
(long_sign): Rename to..
(intptr_t_sign): ...this. Use SCM_SIZEOF_INTPTR_T.
(bignum_cmp_long): Rename to...
(bignum_cmp_intptr_t): ...this. Use uintptr_t.
* libguile/array-map.c (array_compare): Use uintptr_t instead of
unsigned long and intptr_t instead of long.
* libguile/arrays.c (make-shared-array): Use ssize_t instead of long.
* libguile/bytevectors.c (is_signed_int32, is_unsigned_int32)
[MINGW32 && __x86_64__]: Use ULL.
(twos_complement): Use uintptr_t instead of unsigned long.
* libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2): Likewise.
(narrow_string_hash, wide_string_hash, scm_i_string_hash,
scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash, scm_i_struct_hash, scm_raw_ihashq,
scm_raw_ihash): Use and return uintptr_t instead of unsigned long.
(scm_hashv, scm_hash): Use SCM_UINTPTR_T_MAX.
* libguile/hash.h (scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash): update prototypes.
* libguile/scmsigs.c (sigaction): Use intptr_t instead of long.
* libguile/strings.c (scm_i_make_symbol, (scm_i_c_make_symbol): Use
uintptr_t instead of unsigned long.
* libguile/strings.h (scm_i_make_symbol, (scm_i_c_make_symbol): Update
declacations.
* libguile/srfi-60.c: Use scm_to_uintptr, scm_from_intptr and variants
throughout.
* libguile/symbols.c (symbol-hash): Use scm_from_uintptr.
Co-authored-by: Mike Gran <spk121@yahoo.com>
Co-authored-by: Andy Wingo <wingo@pobox.com>
* libguile/posix-w32.c (canonicalize_device_name,
slashify_file_name): New static functions.
(canonicalize_file_name_mingw): Use them in new function.
* libguile/posix-w32.h (canonicalize_file_name_mingw): Declare it.
(canonicalize_file_name): New define.
* libguile/filesys.c[__MINGW32__]: Include posix-w32.h to use it.
* libguile/fports.c[__MINGW32__]: Likewise.
* configure.ac: Detect if ‘openat’ is defined.
* libguile/filesys.c
(flags_to_mode): Extract from ...
(scm_mode): ... here.
(scm_open_fdes_at, scm_openat): Define the Scheme bindings.
* libguile/filesys.h (scm_open_fdes_at, scm_openat): Make them part
of the API.
* doc/ref/posix.texi (File System): Document them.
* test-suite/tests/filesys.test ("openat"): Test ‘openat’.
* libguile/syscalls.h (openat_or_openat64): Decide between ‘openat’
and ‘openat64’.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect if ‘fstatat’ is defined.
* libguile/filesys.c (scm_statat): Define a Scheme binding to ‘fstatat’.
* libguile/filesys.h (scm_statat): Make it part of the C API.
* doc/ref/posix.texi (File System): Document it.
* libguile/syscalls.h (fstatat_or_fstatat64): Choose between ‘fstatat’
and ‘fstatat64’.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect whether ‘fchownat’ is available.
* libguile/filesys.c (scm_chownat): Define a Scheme binding to
‘fchownat’ when available.
* libguile/filesys.h (scm_chownat): Make it part of the API.
* doc/ref/posix.texi (File System): Document it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
‘unlinkat’ is used for both unlinking regular files
and removing empty directories.
* configure.ac: Detect if ‘unlinkat’ exists.
* doc/ref/posix.texi (File System): Document why there is no
‘rmdirat’ procedure, and document the ‘delete-file-at’ procedure.
* libguile/filesys.c
(scm_rmdir): Adjust the docstring here as well.
(scm_delete_file_at): Define a Scheme binding to ‘unlinkat’.
* libguile/filesys.h (scm_delete_file_at): Make ‘scm_delete_file_at’
part of the C API.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect existence of fchmodat.
* libguile/filesys.c (scm_chmodat): New procedure.
* libguile/filesys.h (scm_chmodat): Make it part of the API.
* test-suite/tests/filesys.test ("chmodat"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect if ‘renameat’ is defined.
* libguile/filesys.c (scm_renameat): Define a Scheme binding
to the ‘renameat’ system call.
* doc/ref/posix.texi (File System): Document it.
* libguile/filesys.h (scm_renameat): Make it part of the C API.
* test-suite/tests/filesys.test ("rename-file-at"): New tests.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect whether ‘symlinkat’ exists.
* libguile/filesys.c (scm_symlinkat): Define a Scheme binding
when it exists.
* libguile/filesys.h: Make the binding part of the public C API.
* doc/ref/posix.texi (File System): Document the binding.
* test-suite/tests/filesys.test ("symlinkat"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect whether ‘readlinkat’ is defined.
* libguile/filesys.c (scm_readlink): Support file ports
when ‘readlinkat’ exists.
(scm_init_filesys): Provide ‘chdir-ports’ when it exists.
* doc/ref/posix.texi (File System): Document it.
* test-suite/tests/filesys.test ("readlink"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Check for ‘fchdir’.
* libguile/filesys.c
(scm_chdir): Support file ports.
(scm_init_filesys): Report support of file ports.
* doc/ref/posix.texi (Processes): Update accordingly.
* doc/ref/guile.texi: Add copyright line for new documentation in this
patch and later patches.
* test-suite/tests/filesys.test ("chdir"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
The definition and the declaration for scm_integer_from_mpz
do not match
* libguile/integers.c (scm_integer_from_mpz): takes const mpz_t arg
No callers need to be changed.
Since Guile requires a C99 compiler, we can rely on signal handlers
returning void, not int.
* configure.ac: remove AC_TYPE_SIGNAL
* libguile/scmsigs.c (SIGRETTYPE): remove SIGRETTYPE
(take_signal): returns void
(scm_sigaction_for_thread): presumes handlers return void