HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-3.0.2/io.rbinc
// -*- c -*-
// DO NOT MODIFY THIS FILE DIRECTLY.
// auto-generated file
//   by ./tool/mk_builtin_loader.rb
//   with io.rb
#include "internal/compilers.h"     /* for MAYBE_UNUSED */
#include "internal/warnings.h"      /* for COMPILER_WARNING_PUSH */
#include "ruby/ruby.h"              /* for VALUE */
#include "builtin.h"                /* for RB_BUILTIN_FUNCTION */
struct rb_execution_context_struct; /* in vm_core.h */

static void
mjit_compile_invokebuiltin_for_io_read_nonblock(FILE *f, long index, unsigned stack_size, bool inlinable_p)
{
    fprintf(f, "    VALUE self = GET_SELF();\n");
    fprintf(f, "    typedef VALUE (*func)(rb_execution_context_t *, VALUE, VALUE, VALUE, VALUE);\n");
    if (index == -1) {
        fprintf(f, "    const VALUE *argv = &stack[%d];\n", stack_size - 3);
    }
    else {
        fprintf(f, "    const unsigned int lnum = GET_ISEQ()->body->local_table_size;\n");
        fprintf(f, "    const VALUE *argv = GET_EP() - lnum - VM_ENV_DATA_SIZE + 1 + %ld;\n", index);
    }
    fprintf(f, "    func f = (func)%"PRIdPTR"; /* == io_read_nonblock */\n", (intptr_t)io_read_nonblock);
    fprintf(f, "    val = f(ec, self, argv[0], argv[1], argv[2]);\n");
}

static void
mjit_compile_invokebuiltin_for_io_write_nonblock(FILE *f, long index, unsigned stack_size, bool inlinable_p)
{
    fprintf(f, "    VALUE self = GET_SELF();\n");
    fprintf(f, "    typedef VALUE (*func)(rb_execution_context_t *, VALUE, VALUE, VALUE);\n");
    if (index == -1) {
        fprintf(f, "    const VALUE *argv = &stack[%d];\n", stack_size - 2);
    }
    else {
        fprintf(f, "    const unsigned int lnum = GET_ISEQ()->body->local_table_size;\n");
        fprintf(f, "    const VALUE *argv = GET_EP() - lnum - VM_ENV_DATA_SIZE + 1 + %ld;\n", index);
    }
    fprintf(f, "    func f = (func)%"PRIdPTR"; /* == io_write_nonblock */\n", (intptr_t)io_write_nonblock);
    fprintf(f, "    val = f(ec, self, argv[0], argv[1]);\n");
}

void Init_builtin_io(void)
{
  // table definition
  static const struct rb_builtin_function io_table[] = {
    RB_BUILTIN_FUNCTION(0, io_read_nonblock, io_read_nonblock, 3, mjit_compile_invokebuiltin_for_io_read_nonblock),
    RB_BUILTIN_FUNCTION(1, io_write_nonblock, io_write_nonblock, 2, mjit_compile_invokebuiltin_for_io_write_nonblock),
    RB_BUILTIN_FUNCTION(-1, NULL, NULL, 0, 0),
  };

  // arity_check
COMPILER_WARNING_PUSH
#if GCC_VERSION_SINCE(5, 1, 0) || __clang__
COMPILER_WARNING_ERROR(-Wincompatible-pointer-types)
#endif
  if (0) rb_builtin_function_check_arity3(io_read_nonblock);
  if (0) rb_builtin_function_check_arity2(io_write_nonblock);
COMPILER_WARNING_POP

  // load
  rb_load_with_builtin_functions("io", io_table);
}