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)


147
148
149
150
151
# File 'ext/ffi_c/LastError.c', line 147

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)


173
174
175
176
177
178
179
180
181
182
183
# File 'ext/ffi_c/LastError.c', line 173

static VALUE
set_last_error(VALUE self, VALUE error)
{
#ifdef _WIN32
    SetLastError(NUM2INT(error));
#else
    errno = NUM2INT(error);
#endif

    return Qnil;
}

.winapi_errorNumeric

Get GetLastError() value. Only Windows or Cygwin.

Returns:

  • (Numeric)


159
160
161
162
163
# File 'ext/ffi_c/LastError.c', line 159

static VALUE
get_last_winapi_error(VALUE self)
{
    return INT2NUM(thread_data_get()->td_winapi_errno);
}

.error(error) ⇒ nil

Set GetLastError() value. Only on Windows and Cygwin.

Parameters:

  • error (Numeric)

Returns:

  • (nil)


192
193
194
195
196
197
# File 'ext/ffi_c/LastError.c', line 192

static VALUE
set_last_winapi_error(VALUE self, VALUE error)
{
    SetLastError(NUM2INT(error));
    return Qnil;
}

Instance Method Details

#errorNumeric (private)

Get errno value.

Returns:

  • (Numeric)


147
148
149
150
151
# File 'ext/ffi_c/LastError.c', line 147

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)


173
174
175
176
177
178
179
180
181
182
183
# File 'ext/ffi_c/LastError.c', line 173

static VALUE
set_last_error(VALUE self, VALUE error)
{
#ifdef _WIN32
    SetLastError(NUM2INT(error));
#else
    errno = NUM2INT(error);
#endif

    return Qnil;
}

#winapi_errorNumeric (private)

Get GetLastError() value. Only Windows or Cygwin.

Returns:

  • (Numeric)


159
160
161
162
163
# File 'ext/ffi_c/LastError.c', line 159

static VALUE
get_last_winapi_error(VALUE self)
{
    return INT2NUM(thread_data_get()->td_winapi_errno);
}

#error(error) ⇒ nil (private)

Set GetLastError() value. Only on Windows and Cygwin.

Parameters:

  • error (Numeric)

Returns:

  • (nil)


192
193
194
195
196
197
# File 'ext/ffi_c/LastError.c', line 192

static VALUE
set_last_winapi_error(VALUE self, VALUE error)
{
    SetLastError(NUM2INT(error));
    return Qnil;
}