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

+ (Numeric) error

Get errno value.

Returns:

  • (Numeric)


115
116
117
118
119
# File 'ext/ffi_c/LastError.c', line 115

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

+ (nil) error(error)

Set errno value.

Parameters:

  • error (Numeric)

Returns:

  • (nil)


128
129
130
131
132
133
134
135
136
137
138
139
# File 'ext/ffi_c/LastError.c', line 128

static VALUE
set_last_error(VALUE self, VALUE error)
{

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

    return Qnil;
}

Instance Method Details

- (Numeric) error (private)

Get errno value.

Returns:

  • (Numeric)


115
116
117
118
119
# File 'ext/ffi_c/LastError.c', line 115

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

- (nil) error(error) (private)

Set errno value.

Parameters:

  • error (Numeric)

Returns:

  • (nil)


128
129
130
131
132
133
134
135
136
137
138
139
# File 'ext/ffi_c/LastError.c', line 128

static VALUE
set_last_error(VALUE self, VALUE error)
{

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

    return Qnil;
}