Module: FFI::LastError

Defined in:
ext/ffi_c/LastError.c,
ext/ffi_c/LastError.c

Overview

This module defines a couple of method to set and get errno for current thread.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.errorNumeric

Get errno value.

Returns:

  • (Numeric)


123
124
125
126
127
# File 'ext/ffi_c/LastError.c', line 123

static VALUE
get_last_error(VALUE self)
{
    return INT2NUM(thread_data_get()->td_errno);
}

.error(error) ⇒ nil

Set errno value.

Parameters:

  • error (Numeric)

Returns:

  • (nil)


136
137
138
139
140
141
142
143
144
145
146
147
# File 'ext/ffi_c/LastError.c', line 136

static VALUE
set_last_error(VALUE self, VALUE error)
{

#ifdef _WIN32
    SetLastError(NUM2INT(error));
#else
    errno = NUM2INT(error);
#endif

    return Qnil;
}

Instance Method Details

#errorNumeric (private)

Get errno value.

Returns:

  • (Numeric)


123
124
125
126
127
# File 'ext/ffi_c/LastError.c', line 123

static VALUE
get_last_error(VALUE self)
{
    return INT2NUM(thread_data_get()->td_errno);
}

#error(error) ⇒ nil (private)

Set errno value.

Parameters:

  • error (Numeric)

Returns:

  • (nil)


136
137
138
139
140
141
142
143
144
145
146
147
# File 'ext/ffi_c/LastError.c', line 136

static VALUE
set_last_error(VALUE self, VALUE error)
{

#ifdef _WIN32
    SetLastError(NUM2INT(error));
#else
    errno = NUM2INT(error);
#endif

    return Qnil;
}