Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/zjit-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ env:
# Work around transient crates.io download failures (curl HTTP/2 framing / partial transfer)
CARGO_NET_RETRY: 10
CARGO_HTTP_MULTIPLEXING: false
RUST_BACKTRACE: 1
ZJIT_RB_BUG: 1

jobs:
make:
Expand Down Expand Up @@ -60,8 +62,6 @@ jobs:
RUN_OPTS: ${{ matrix.run_opts }}
SPECOPTS: ${{ matrix.specopts }} -B../src/spec/zjit.mspec
TESTOPTS: ${{ matrix.testopts }}
RUST_BACKTRACE: 1
ZJIT_RB_BUG: 1

runs-on: macos-26

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/zjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ env:
# Work around transient crates.io download failures (curl HTTP/2 framing / partial transfer)
CARGO_NET_RETRY: 10
CARGO_HTTP_MULTIPLEXING: false
RUST_BACKTRACE: 1
ZJIT_RB_BUG: 1

jobs:
lint:
Expand Down Expand Up @@ -125,8 +127,6 @@ jobs:
TESTOPTS: ${{ matrix.testopts }}
RUBY_DEBUG: ci
BUNDLE_JOBS: 8 # for yjit-bench
RUST_BACKTRACE: 1
ZJIT_RB_BUG: 1

runs-on: ${{ matrix.runs-on || 'ubuntu-22.04' }}

Expand Down
28 changes: 28 additions & 0 deletions ext/-test-/io_buffer/io_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,30 @@ io_buffer_for_writing_modify_string(VALUE self, VALUE string)
return rb_io_buffer_for_writing(string, io_buffer_modify_string, string);
}

static VALUE
io_buffer_lock(VALUE self, VALUE buffer)
{
return rb_io_buffer_lock(buffer);
}

static VALUE
io_buffer_unlock(VALUE self, VALUE buffer)
{
return rb_io_buffer_unlock(buffer);
}

static VALUE
io_buffer_new_locked(VALUE self, VALUE size)
{
return rb_io_buffer_new_locked(NULL, NUM2SIZET(size), RB_IO_BUFFER_INTERNAL);
}

static VALUE
io_buffer_free_locked(VALUE self, VALUE buffer)
{
return rb_io_buffer_free_locked(buffer);
}

void
Init_io_buffer(void)
{
Expand All @@ -102,4 +126,8 @@ Init_io_buffer(void)
rb_define_singleton_method(mIOBuffer, "for_writing_set_string", io_buffer_for_writing_set_string, 2);
rb_define_singleton_method(mIOBuffer, "for_writing_readonly?", io_buffer_for_writing_readonly_p, 1);
rb_define_singleton_method(mIOBuffer, "for_writing_modify_string", io_buffer_for_writing_modify_string, 1);
rb_define_singleton_method(mIOBuffer, "lock", io_buffer_lock, 1);
rb_define_singleton_method(mIOBuffer, "unlock", io_buffer_unlock, 1);
rb_define_singleton_method(mIOBuffer, "new_locked", io_buffer_new_locked, 1);
rb_define_singleton_method(mIOBuffer, "free_locked", io_buffer_free_locked, 1);
}
36 changes: 21 additions & 15 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2734,21 +2734,27 @@ rb_file_ctime(VALUE obj)
#if defined(HAVE_STAT_BIRTHTIME)
/*
* call-seq:
* File.birthtime(entry_path) -> new_time
* File.birthtime(path) -> time
*
* Returns a new Time object containing the create time
* of the entry at the given +path+:
* of the entry at the given +path+;
* see {File System Timestamps}[rdoc-ref:file/timestamps.md]:
*
* path = 't.tmp'
* File.birthtime(path) # Raises Errno::ENOENT: No such file or directory
* File.write(path, 'foo')
* File.birthtime(path) # => 2026-04-14 11:10:43.2891695 -0500
* File.write(path, 'bar')
* File.birthtime(path) # => 2026-04-14 11:10:43.2891695 -0500
* File.delete(path)
* File.birthtime(path) # Raises Errno::ENOENT: No such file or directory
* filepath = 't.tmp'
* File.birthtime(filepath) # Raises Errno::ENOENT: No such file or directory
* File.write(filepath, 'foo')
* File.birthtime(filepath) # => 2026-04-14 11:10:43.2891695 -0500
* File.write(filepath, 'bar')
* File.birthtime(filepath) # => 2026-04-14 11:10:43.2891695 -0500
* File.delete(filepath)
* File.birthtime(filepath) # Raises Errno::ENOENT: No such file or directory.
*
* dirpath = 'tmp'
* Dir.mkdir(dirpath)
* File.birthtime(dirpath) # => 2026-08-21 13:42:19.389324172 -0500
* Dir.rmdir(dirpath)
* File.birthtime(dirpath) # Raises Errno::ENOENT: No such file or directory.
*
* See {File System Timestamps}[rdoc-ref:file/timestamps.md].
*/

VALUE
Expand Down Expand Up @@ -5364,11 +5370,11 @@ ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encodin

/*
* call-seq:
* File.basename(path, suffix = '') -> new_string
* File.basename(path, suffix = '') -> string
*
* Returns a new string containing all or part of the last entry of the given +path+.
* Entries are delimited by the value of constant File::SEPARATOR
* and, if non-nil, the value of constant File::ALT_SEPARATOR.
* Returns a new string containing all or part of the last component of the given +path+.
* Components are delimited by the value of constant File::SEPARATOR
* and, if non-+nil+, the value of constant File::ALT_SEPARATOR.
*
* When +suffix+ is the empty string <tt>''</tt>,
* returns all of the last entry:
Expand Down
14 changes: 9 additions & 5 deletions include/ruby/io/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ enum rb_io_buffer_flags {
// A mapped buffer that is also shared.
RB_IO_BUFFER_SHARED = 8,

// The buffer is locked and cannot be resized.
// More specifically, it means we can't change the base address or size.
// A buffer is typically locked before a system call that uses the data.
RB_IO_BUFFER_LOCKED = 32,

// The buffer mapping is private and will not impact other processes or the underlying file.
RB_IO_BUFFER_PRIVATE = 64,

Expand All @@ -79,13 +74,22 @@ enum rb_io_buffer_endian {
};

VALUE rb_io_buffer_new(void *base, size_t size, enum rb_io_buffer_flags flags);
// Create a buffer with an initial lock count of one. This is typically used
// for temporary wrappers around borrowed memory and paired with
// rb_io_buffer_free_locked.
VALUE rb_io_buffer_new_locked(void *base, size_t size, enum rb_io_buffer_flags flags);
VALUE rb_io_buffer_map(VALUE io, size_t size, rb_off_t offset, enum rb_io_buffer_flags flags);

// Acquire and release a reference-counted lock on the backing allocation.
// Every successful lock call must be paired with exactly one unlock call.
VALUE rb_io_buffer_lock(VALUE self);
VALUE rb_io_buffer_unlock(VALUE self);
int rb_io_buffer_try_unlock(VALUE self);

VALUE rb_io_buffer_free(VALUE self);
// Release the buffer's only lock and immediately invalidate it. This is for
// temporary wrappers around borrowed memory. Calls rb_bug if the lock count is
// not exactly one.
VALUE rb_io_buffer_free_locked(VALUE self);

// Access the internal buffer and flags. Validates the pointers.
Expand Down
Loading