diff --git a/core/src/main/java/org/jruby/ext/ffi/AbstractMemory.java b/core/src/main/java/org/jruby/ext/ffi/AbstractMemory.java index ae058772696..c5ff79776c2 100644 --- a/core/src/main/java/org/jruby/ext/ffi/AbstractMemory.java +++ b/core/src/main/java/org/jruby/ext/ffi/AbstractMemory.java @@ -124,6 +124,14 @@ protected AbstractMemory(Ruby runtime, RubyClass klass, MemoryIO io, long size, this.typeSize = typeSize; } + static AbstractMemory cast(ThreadContext context, IRubyObject ptr) { + if (!(ptr instanceof AbstractMemory)) { + throw context.runtime.newTypeError(ptr, context.runtime.getFFI().memoryClass); + } + + return (AbstractMemory) ptr; + } + @Override protected MemoryIO allocateMemoryIO() { throw getRuntime().newRuntimeError("allocateMemoryIO should not be called"); @@ -594,7 +602,7 @@ public IRubyObject get_int32(ThreadContext context, IRubyObject offset) { * @param value The value to write. * @return The value written. */ - @JRubyMethod(name = { "write_uint" }, required = 1) + @JRubyMethod(name = { "write_uint32", "write_uint" }, required = 1) public IRubyObject write_uint(ThreadContext context, IRubyObject value) { getMemoryIO().putInt(0, (int) Util.uint32Value(value)); @@ -628,12 +636,32 @@ public IRubyObject put_uint32(ThreadContext context, IRubyObject offset, IRubyOb return this; } + /** + * Reads a 8 bit unsigned integer value from the memory address. + * + * @return The value read from the address. + */ + @JRubyMethod(name = { "read_uint8" }) + public IRubyObject read_uint8(ThreadContext context) { + return Util.newUnsigned8(context.runtime, getMemoryIO().getByte(0)); + } + + /** + * Reads a 16 bit unsigned integer value from the memory address. + * + * @return The value read from the address. + */ + @JRubyMethod(name = { "read_uint16" }) + public IRubyObject read_uint16(ThreadContext context) { + return Util.newUnsigned16(context.runtime, getMemoryIO().getShort(0)); + } + /** * Reads a 32 bit unsigned integer value from the memory address. * * @return The value read from the address. */ - @JRubyMethod(name = { "read_uint" }) + @JRubyMethod(name = { "read_uint", "read_uint32" }) public IRubyObject read_uint(ThreadContext context) { return Util.newUnsigned32(context.runtime, getMemoryIO().getInt(0)); } @@ -665,7 +693,7 @@ public IRubyObject get_uint32(ThreadContext context, IRubyObject offset) { * @param value The value to write. * @return The value written. */ - @JRubyMethod(name = { "write_long_long" }, required = 1) + @JRubyMethod(name = { "write_int64", "write_long_long" }, required = 1) public IRubyObject write_long_long(ThreadContext context, IRubyObject value) { getMemoryIO().putLong(0, Util.int64Value(value)); @@ -704,7 +732,7 @@ public IRubyObject put_int64(ThreadContext context, IRubyObject offset, IRubyObj * * @return The value read from the address. */ - @JRubyMethod(name = { "read_long_long" }) + @JRubyMethod(name = { "read_int64", "read_long_long" }) public IRubyObject read_long_long(ThreadContext context) { return Util.newSigned64(context.runtime, getMemoryIO().getLong(0)); } @@ -736,7 +764,7 @@ public IRubyObject get_int64(ThreadContext context, IRubyObject offset) { * @param value The value to write. * @return The value written. */ - @JRubyMethod(name = { "write_ulong_long" }, required = 1) + @JRubyMethod(name = { "write_uint64", "write_ulong_long" }, required = 1) public IRubyObject write_ulong_long(ThreadContext context, IRubyObject value) { getMemoryIO().putLong(0, Util.uint64Value(value)); @@ -775,7 +803,7 @@ public IRubyObject put_uint64(ThreadContext context, IRubyObject offset, IRubyOb * * @return The value read from the address. */ - @JRubyMethod(name = { "read_ulong_long" }) + @JRubyMethod(name = { "read_uint64", "read_ulong_long" }) public IRubyObject read_ulong_long(ThreadContext context) { return Util.newUnsigned64(context.runtime, getMemoryIO().getLong(0)); } @@ -1880,13 +1908,14 @@ public IRubyObject get_bytes(ThreadContext context, IRubyObject offArg, IRubyObj } private IRubyObject putBytes(ThreadContext context, long off, ByteList bl, int idx, int len) { - if (idx < 0 || idx > bl.length()) { - throw context.runtime.newRangeError("invalid string index"); + if (idx < 0) { + throw context.runtime.newRangeError("index can not be less than zero"); } - if (len < 0 || len > (bl.length() - idx)) { - throw context.runtime.newRangeError("invalid length"); + if ((idx + len) > bl.length()) { + throw context.runtime.newRangeError("index+length is greater than size of string"); } + getMemoryIO().put(off, bl.getUnsafeBytes(), bl.begin() + idx, len); return this; @@ -2051,6 +2080,35 @@ public final IRubyObject slice(ThreadContext context, IRubyObject offset, IRubyO return slice(context.getRuntime(), RubyNumeric.num2int(offset), RubyNumeric.num2int(size)); } + @JRubyMethod(name = "get") + public final IRubyObject put(ThreadContext context, IRubyObject typeName, IRubyObject offset) { + Ruby runtime = context.runtime; + + Type type = runtime.getFFI().getTypeResolver().findType(runtime, typeName); + MemoryOp op = MemoryOp.getMemoryOp(type); + + if(op != null) { + return op.get(context, getMemoryIO(), RubyNumeric.num2long(offset)); + } + + throw runtime.newArgumentError("undefined type " + typeName); + } + + @JRubyMethod(name = "put") + public final IRubyObject get(ThreadContext context, IRubyObject typeName, IRubyObject offset, IRubyObject value) { + Ruby runtime = context.runtime; + + Type type = runtime.getFFI().getTypeResolver().findType(runtime, typeName); + MemoryOp op = MemoryOp.getMemoryOp(type); + if(op != null) { + op.put(context, getMemoryIO(), RubyNumeric.num2long(offset), value); + + return context.nil; + } + + throw runtime.newArgumentError("undefined type " + typeName); + } + abstract public AbstractMemory order(Ruby runtime, ByteOrder order); abstract protected AbstractMemory slice(Ruby runtime, long offset); abstract protected AbstractMemory slice(Ruby runtime, long offset, long size); diff --git a/core/src/main/java/org/jruby/ext/ffi/AutoPointer.java b/core/src/main/java/org/jruby/ext/ffi/AutoPointer.java index f2534e33eda..ae98878c329 100644 --- a/core/src/main/java/org/jruby/ext/ffi/AutoPointer.java +++ b/core/src/main/java/org/jruby/ext/ffi/AutoPointer.java @@ -1,47 +1,20 @@ package org.jruby.ext.ffi; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; -import java.lang.ref.WeakReference; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; import org.jruby.Ruby; -import org.jruby.RubyBoolean; import org.jruby.RubyClass; import org.jruby.RubyModule; import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.callsite.CachingCallSite; -import org.jruby.runtime.callsite.FunctionalCachingCallSite; -import org.jruby.util.PhantomReferenceReaper; import org.jruby.util.cli.Options; -import static org.jruby.runtime.Visibility.*; - -@JRubyClass(name = "FFI::" + AutoPointer.AUTOPTR_CLASS_NAME, parent = "FFI::Pointer") +@JRubyClass(name = "FFI::AutoPointer", parent = "FFI::Pointer") public class AutoPointer extends Pointer { - static final String AUTOPTR_CLASS_NAME = "AutoPointer"; - - /** Keep strong references to the Reaper until cleanup */ - private static final ConcurrentMap referenceSet = new ConcurrentHashMap(); - private static final ThreadLocal> currentReaper = new ThreadLocal>(); - - private Pointer pointer; - private Object referent; - private transient volatile Reaper reaper; - + public static RubyClass createAutoPointerClass(Ruby runtime, RubyModule module) { - RubyClass autoptrClass = module.defineClassUnder(AUTOPTR_CLASS_NAME, + RubyClass autoptrClass = module.defineClassUnder("AutoPointer", module.getClass("Pointer"), - Options.REIFY_FFI.load() ? new ReifyingAllocator(AutoPointer.class) : AutoPointerAllocator.INSTANCE); - autoptrClass.defineAnnotatedMethods(AutoPointer.class); - autoptrClass.defineAnnotatedConstants(AutoPointer.class); + Options.REIFY_FFI.load() ? new ReifyingAllocator(AutoPointer.class) : AutoPointer::new); autoptrClass.setReifiedClass(AutoPointer.class); autoptrClass.kindOf = new RubyModule.KindOf() { @Override @@ -53,230 +26,7 @@ public boolean isKindOf(IRubyObject obj, RubyModule type) { return autoptrClass; } - private static final class AutoPointerAllocator implements ObjectAllocator { - static final ObjectAllocator INSTANCE = new AutoPointerAllocator(); - - public IRubyObject allocate(Ruby runtime, RubyClass klazz) { - return new AutoPointer(runtime, klazz); - } - - } - public AutoPointer(Ruby runtime, RubyClass klazz) { super(runtime, klazz, runtime.getFFI().getNullMemoryIO()); } - - private static final void checkPointer(Ruby runtime, IRubyObject ptr) { - if (!(ptr instanceof Pointer)) { - throw runtime.newTypeError(ptr, runtime.getFFI().pointerClass); - } - if (ptr instanceof MemoryPointer || ptr instanceof AutoPointer) { - throw runtime.newTypeError("Cannot use AutoPointer with MemoryPointer or AutoPointer instances"); - } - } - - @JRubyMethod(name="from_native", meta = true) - public static IRubyObject from_native(ThreadContext context, IRubyObject recv, IRubyObject value, IRubyObject ctx) { - return ((RubyClass) recv).newInstance(context, value, Block.NULL_BLOCK); - } - - @Override - @JRubyMethod(name = "initialize", visibility = PRIVATE) - public final IRubyObject initialize(ThreadContext context, IRubyObject pointerArg) { - - Ruby runtime = context.runtime; - - checkPointer(runtime, pointerArg); - - Object ffiHandle = getMetaClass().getFFIHandle(); - if (!(ffiHandle instanceof ClassData)) { - getMetaClass().setFFIHandle(ffiHandle = new ClassData()); - } - ClassData classData = (ClassData) ffiHandle; - - // If no release method is defined, then memory leaks will result. - DynamicMethod releaseMethod = classData.releaseCallSite.retrieveCache((IRubyObject) getMetaClass()).method; - if (releaseMethod.isUndefined()) { - throw runtime.newRuntimeError("release method undefined"); - - } else if ((releaseMethod.getArity().isFixed() && releaseMethod.getArity().required() != 1) || releaseMethod.getArity().required() > 1) { - throw runtime.newRuntimeError("wrong number of arguments to release method (" - + 1 + " for " + releaseMethod.getArity().required() + ")"); - } - - - setMemoryIO(((Pointer) pointerArg).getMemoryIO()); - this.pointer = (Pointer) pointerArg; - this.size = pointer.size; - this.typeSize = pointer.typeSize; - setReaper(new Reaper(pointer, getMetaClass(), classData.releaseCallSite)); - - return this; - } - - @Override - @JRubyMethod(name = "initialize", visibility = PRIVATE) - public final IRubyObject initialize(ThreadContext context, IRubyObject pointerArg, IRubyObject releaser) { - - checkPointer(context.runtime, pointerArg); - - setMemoryIO(((Pointer) pointerArg).getMemoryIO()); - this.pointer = (Pointer) pointerArg; - this.size = pointer.size; - this.typeSize = pointer.typeSize; - - Object ffiHandle = releaser.getMetaClass().getFFIHandleAccessorField().getVariableAccessorForRead().get(releaser); - if (!(ffiHandle instanceof ReleaserData)) { - getMetaClass().setFFIHandle(ffiHandle = new ReleaserData()); - } - - ReleaserData releaserData = (ReleaserData) ffiHandle; - DynamicMethod releaseMethod = releaserData.releaseCallSite.retrieveCache(releaser).method; - // If no release method is defined, then memory leaks will result. - if (releaseMethod.isUndefined()) { - throw context.runtime.newRuntimeError("call method undefined"); - - } else if ((releaseMethod.getArity().isFixed() && releaseMethod.getArity().required() != 1) || releaseMethod.getArity().required() > 1) { - throw context.runtime.newRuntimeError("wrong number of arguments to call method (" - + 1 + " for " + releaseMethod.getArity().required() + ")"); - } - - setReaper(new Reaper(pointer, releaser, releaserData.releaseCallSite)); - - return this; - } - - @JRubyMethod(name = "free") - public final IRubyObject free(ThreadContext context) { - Reaper r = reaper; - - if (r == null || r.released) { - throw context.runtime.newRuntimeError("pointer already freed"); - } - - r.release(context); - reaper = null; - referent = null; - - return context.nil; - } - - @JRubyMethod(name = "autorelease=") - public final IRubyObject autorelease(ThreadContext context, IRubyObject autorelease) { - Reaper r = reaper; - - if (r == null || r.released) { - throw context.runtime.newRuntimeError("pointer already freed"); - } - - r.autorelease(autorelease.isTrue()); - - return context.nil; - } - - @JRubyMethod(name = "autorelease?") - public final IRubyObject autorelease_p(ThreadContext context) { - return RubyBoolean.newBoolean(context, reaper != null ? !reaper.unmanaged : false); - } - - private void setReaper(Reaper reaper) { - Reference reaperGroupReference = currentReaper.get(); - ReaperGroup reaperGroup = reaperGroupReference != null ? reaperGroupReference.get() : null; - Object referent = reaperGroup != null ? reaperGroup.referent() : null; - if (referent == null || !reaperGroup.canAccept()) { - reaperGroup = new ReaperGroup(referent = new Object()); - currentReaper.set(new SoftReference(reaperGroup)); - referenceSet.put(reaperGroup, Boolean.TRUE); - } - this.referent = referent; - this.reaper = reaper; - reaperGroup.add(reaper); - } - - private static final class ReaperGroup extends PhantomReferenceReaper implements Runnable { - private static int MAX_REAPERS_PER_GROUP = 100; - private final WeakReference weakref; - private int reaperCount; - private volatile Reaper head; - - ReaperGroup(Object referent) { - super(referent); - this.weakref = new WeakReference(referent); - } - - Object referent() { - return weakref.get(); - } - - boolean canAccept() { - return reaperCount < MAX_REAPERS_PER_GROUP; - } - - void add(Reaper r) { - ++reaperCount; - r.next = head; - head = r; - } - - public void run() { - referenceSet.remove(this); - Ruby runtime = null; - ThreadContext ctx = null; - Reaper r = head; - - while (r != null) { - if (!r.released && !r.unmanaged) { - if (r.getRuntime() != runtime) { - runtime = r.getRuntime(); - ctx = runtime.getCurrentContext(); - } - r.dispose(ctx); - } - r = r.next; - } - } - } - - private static final class Reaper { - final Pointer pointer; - final IRubyObject proc; - final CachingCallSite callSite; - volatile Reaper next; - volatile boolean released; - volatile boolean unmanaged; - - - private Reaper(Pointer ptr, IRubyObject proc, CachingCallSite callSite) { - this.pointer = ptr; - this.proc = proc; - this.callSite = callSite; - } - - final Ruby getRuntime() { - return proc.getRuntime(); - } - - void dispose(ThreadContext context) { - callSite.call(context, proc, proc, pointer); - } - - public final void release(ThreadContext context) { - if (!released) { - released = true; - dispose(context); - } - } - - public final void autorelease(boolean autorelease) { - this.unmanaged = !autorelease; - } - } - - private static final class ClassData { - private final CachingCallSite releaseCallSite = new FunctionalCachingCallSite("release"); - } - - private static final class ReleaserData { - private final CachingCallSite releaseCallSite = new FunctionalCachingCallSite("call"); - } } diff --git a/core/src/main/java/org/jruby/ext/ffi/DataConverter.java b/core/src/main/java/org/jruby/ext/ffi/DataConverter.java index 809dc085a29..b7183acd103 100644 --- a/core/src/main/java/org/jruby/ext/ffi/DataConverter.java +++ b/core/src/main/java/org/jruby/ext/ffi/DataConverter.java @@ -14,63 +14,7 @@ public class DataConverter { public static RubyModule createDataConverterModule(Ruby runtime, RubyModule module) { RubyModule result = module.defineModuleUnder("DataConverter"); - result.defineAnnotatedMethods(DataConverter.class); - result.defineAnnotatedConstants(DataConverter.class); return result; } - - private static RubyModule module(IRubyObject obj) { - if (!(obj instanceof RubyModule)) { - throw obj.getRuntime().newTypeError("not a module"); - } - - return (RubyModule) obj; - } - - @JRubyMethod(name = "native_type", module=true, optional = 1) - public static IRubyObject native_type(ThreadContext context, IRubyObject self, IRubyObject[] args) { - RubyModule m = module(self); - - if (args.length == 0) { - if (!m.hasInternalVariable("native_type")) { - throw context.runtime.newNotImplementedError("native_type method not overridden and no native_type set"); - } - - return (Type) m.getInternalVariable("native_type"); - - } else if (args.length == 1) { - Type type = Util.findType(context, args[0]); - - m.setInternalVariable("native_type", type); - - return type; - - } else { - throw context.runtime.newArgumentError("incorrect arguments"); - } - } - - - @JRubyMethod(name = "to_native", module=true) - public static IRubyObject to_native(ThreadContext context, IRubyObject self, IRubyObject value, IRubyObject ctx) { - return value; - } - - @JRubyMethod(name = "from_native", module=true) - public static IRubyObject from_native(ThreadContext context, IRubyObject self, IRubyObject value, IRubyObject ctx) { - return value; - } - - @JRubyMethod(name = "reference_required?", module=true) - public static IRubyObject reference_required_p(ThreadContext context, IRubyObject self) { - Object ref = module(self).getInternalVariable("reference_required"); - return RubyBoolean.newBoolean(context, !(ref instanceof IRubyObject) || ((IRubyObject) ref).isTrue()); - } - - @JRubyMethod(name = "reference_required", module=true, optional = 1) - public static IRubyObject reference_required(ThreadContext context, IRubyObject self, IRubyObject[] args) { - module(self).setInternalVariable("reference_required", RubyBoolean.newBoolean(context, args.length < 1 || args[0].isTrue())); - return self; - } } diff --git a/core/src/main/java/org/jruby/ext/ffi/Enum.java b/core/src/main/java/org/jruby/ext/ffi/Enum.java deleted file mode 100644 index eca05cfe4dd..00000000000 --- a/core/src/main/java/org/jruby/ext/ffi/Enum.java +++ /dev/null @@ -1,234 +0,0 @@ -/***** BEGIN LICENSE BLOCK ***** - * Version: EPL 2.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Eclipse Public - * License Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/epl-v20.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2010, 2011 Wayne Meissner - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the EPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the EPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ - -package org.jruby.ext.ffi; - -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.Ruby; -import org.jruby.RubyArray; -import org.jruby.RubyClass; -import org.jruby.RubyFixnum; -import org.jruby.RubyHash; -import org.jruby.RubyInteger; -import org.jruby.RubyModule; -import org.jruby.RubyObject; -import org.jruby.RubySymbol; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; - -/** - * Represents a C enum - */ -@JRubyClass(name="FFI::Enum", parent="Object") -public final class Enum extends RubyObject { - private IRubyObject nativeType; - private final RubyHash kv_map; - private volatile IRubyObject tag; - - private volatile Map symbolToValue = new IdentityHashMap(); - private volatile ConcurrentHashMap valueToSymbol = new ConcurrentHashMap(); - - public static RubyClass createEnumClass(Ruby runtime, RubyModule ffiModule) { - RubyClass enumClass = ffiModule.defineClassUnder("Enum", runtime.getObject(), - Allocator.INSTANCE); - enumClass.defineAnnotatedMethods(Enum.class); - enumClass.defineAnnotatedConstants(Enum.class); - enumClass.includeModule(ffiModule.getConstant("DataConverter")); - - return enumClass; - } - - private static final class Allocator implements ObjectAllocator { - private static final ObjectAllocator INSTANCE = new Allocator(); - - public final IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new Enum(runtime, klass); - } - } - - private Enum(Ruby runtime, RubyClass klass) { - super(runtime, klass); - kv_map = RubyHash.newHash(runtime); - tag = runtime.getNil(); - } - - @JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE) - public final IRubyObject initialize(ThreadContext context, IRubyObject arg) { - return initialize(context, null, null, arg); - } - - @JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE) - public final IRubyObject initialize(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { - if (arg0 instanceof org.jruby.ext.ffi.Type) - return initialize(context, arg0, arg1, null); - - if (arg1.isNil()) - return initialize(context, null, arg0, null); - - // Handles bad args and tag, values case. - return initialize(context, null, arg0, arg1); - } - - @JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE) - public final IRubyObject initialize(ThreadContext context, IRubyObject type, IRubyObject values, IRubyObject tag) { - int offset = 0; - if (type instanceof org.jruby.ext.ffi.Type) { - nativeType = type; - } else { - if (!(type == null || type.isNil())) - throw context.runtime.newTypeError(type, context.runtime.getModule("FFI").getClass("Type")); - - nativeType = context.runtime.getModule("FFI").getClass("Type").getConstant("INT"); - } - - if (!(tag == null || tag.isNil() || tag instanceof RubySymbol)) - throw context.runtime.newTypeError(tag, context.runtime.getSymbol()); - - this.tag = tag; - - if (!(values instanceof RubyArray)) { - throw context.runtime.newTypeError(values, context.runtime.getArray()); - } - - RubyArray ary = (RubyArray) values; - - Map s2v = new IdentityHashMap(); - IRubyObject prevConstant = null; - long nextValue = 0; - - for (int i = 0; i < ary.size(); i++) { - IRubyObject v = ary.entry(i); - - if (v instanceof RubySymbol) { - s2v.put((RubySymbol) v, RubyFixnum.newFixnum(context.runtime, nextValue)); - prevConstant = v; - nextValue++; - - } else if (v instanceof RubyInteger) { - if (prevConstant == null) { - throw context.runtime.newArgumentError("invalid enum sequence - no symbol for value " - + v); - } - s2v.put((RubySymbol) prevConstant, (RubyFixnum) v); - nextValue = ((RubyInteger) v).getLongValue() + 1; - - } else { - throw context.runtime.newTypeError(v, context.runtime.getSymbol()); - } - } - - symbolToValue = new IdentityHashMap(s2v); - valueToSymbol = new ConcurrentHashMap(symbolToValue.size()); - for (Map.Entry e : symbolToValue.entrySet()) { - kv_map.fastASet(e.getKey(), e.getValue()); - valueToSymbol.put(e.getValue().getLongValue(), e.getKey()); - } - - return this; - } - - @JRubyMethod(name = { "[]", "find" }) - public final IRubyObject find(ThreadContext context, IRubyObject query) { - if (query instanceof RubySymbol) { - IRubyObject value = kv_map.fastARef(query); - return value != null ? value : context.nil; - - } else if (query instanceof RubyInteger) { - RubySymbol symbol = valueToSymbol.get((Long)((RubyInteger) query).getLongValue()); - return symbol != null ? symbol : context.nil; - - } else { - return context.nil; - } - } - - @JRubyMethod(name = { "symbol_map", "to_h", "to_hash" }) - public final IRubyObject symbol_map(ThreadContext context) { - return kv_map.dup(context); - } - - @JRubyMethod(name = { "symbols" }) - public final IRubyObject symbols(ThreadContext context) { - return kv_map.keys(context); - } - - @JRubyMethod(name = { "tag" }) - public final IRubyObject tag(ThreadContext context) { - return tag; - } - - @JRubyMethod(name = "native_type") - public final IRubyObject native_type(ThreadContext context) { - return nativeType; - } - - @JRubyMethod(name = "to_native") - public final IRubyObject to_native(ThreadContext context, IRubyObject name, IRubyObject ctx) { - RubyInteger value; - - if (name instanceof RubyFixnum) { - return name; - - } else if (name instanceof RubySymbol && (value = symbolToValue.get(name)) != null) { - return value; - - } else if (name instanceof RubyInteger) { - return name; - - } else if (name.respondsTo("to_int")) { - - return name.convertToInteger(); - - } else { - throw name.getRuntime().newArgumentError("invalid enum value, " + name.inspect()); - } - } - - @JRubyMethod(name = "from_native") - public final IRubyObject from_native(ThreadContext context, IRubyObject value, IRubyObject ctx) { - - RubySymbol sym; - - if (value instanceof RubyInteger && (sym = valueToSymbol.get((Long)((RubyInteger) value).getLongValue())) != null) { - return sym; - } - - return value; - } - - @JRubyMethod(name = "reference_required?") - public IRubyObject reference_required_p(ThreadContext context) { - return context.fals; - } -} diff --git a/core/src/main/java/org/jruby/ext/ffi/Enums.java b/core/src/main/java/org/jruby/ext/ffi/Enums.java index c8161823032..a5af6b861de 100644 --- a/core/src/main/java/org/jruby/ext/ffi/Enums.java +++ b/core/src/main/java/org/jruby/ext/ffi/Enums.java @@ -29,103 +29,49 @@ package org.jruby.ext.ffi; import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.ext.ffi.Enum; import org.jruby.Ruby; import org.jruby.RubyArray; -import org.jruby.RubyBoolean; import org.jruby.RubyClass; import org.jruby.RubyHash; import org.jruby.RubyModule; import org.jruby.RubyObject; -import org.jruby.RubySymbol; -import org.jruby.runtime.Block; import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.ObjectAllocator; import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; - -import java.util.Iterator; /** * Represents a C enum */ @JRubyClass(name="FFI::Enums", parent="Object") public final class Enums extends RubyObject { - private final RubyArray allEnums; - private final RubyHash symbolMap; - private final RubyHash taggedEnums; - public static RubyClass createEnumsClass(Ruby runtime, RubyModule ffiModule) { - RubyClass enumsClass = ffiModule.defineClassUnder("Enums", runtime.getObject(), - Allocator.INSTANCE); - enumsClass.defineAnnotatedMethods(Enums.class); - enumsClass.defineAnnotatedConstants(Enums.class); + RubyClass enumsClass = + ffiModule.defineClassUnder("Enums", runtime.getObject(), Enums::new); enumsClass.includeModule(ffiModule.getConstant("DataConverter")); return enumsClass; } - private static final class Allocator implements ObjectAllocator { - private static final ObjectAllocator INSTANCE = new Allocator(); - - public final IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new Enums(runtime, klass); - } - } - private Enums(Ruby runtime, RubyClass klass) { super(runtime, klass); - allEnums = RubyArray.newArray(runtime); - taggedEnums = RubyHash.newHash(runtime); - symbolMap = RubyHash.newHash(runtime); } - @JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE) - public final IRubyObject initialize(ThreadContext context) { - return (IRubyObject) this; + protected RubyArray getAllEnums() { + return (RubyArray) getInstanceVariable("@all_enums"); } - @JRubyMethod(name = "<<") - public IRubyObject append(final ThreadContext context, IRubyObject item){ - if(!(item instanceof Enum)){ - throw context.runtime.newTypeError(item, context.runtime.getFFI().ffiModule.getClass("Enum")); - } - allEnums.append(item); - if (!(item == null || item == context.nil)){ - IRubyObject tag = ((Enum)item).tag(context); - if (tag != null && !tag.isNil()) - taggedEnums.fastASet(tag, item); - } - symbolMap.merge_bang(context, ((Enum)item).symbol_map(context), Block.NULL_BLOCK); - return item; + protected RubyHash getSymbolMap() { + return (RubyHash) getInstanceVariable("@symbol_map"); } - public boolean isEmpty(){ - return ( allEnums.isEmpty() && symbolMap.isEmpty() && taggedEnums.isEmpty()); - } - - @JRubyMethod(name = "empty?") - public RubyBoolean empty_p(){ - return isEmpty() ? getRuntime().getTrue() : getRuntime().getFalse(); + protected RubyHash getTaggedEnums() { + return (RubyHash) getInstanceVariable("@tagged_enums"); } - @JRubyMethod(name = "find") - public IRubyObject find(final ThreadContext context, IRubyObject query){ - if (taggedEnums.has_key_p(context, query).isTrue()){ - return taggedEnums.fastARef(query); - } - for (int i = 0; i < allEnums.getLength(); i++){ - IRubyObject item = (IRubyObject)allEnums.entry(i); - if (((RubyArray)item.callMethod(context, "symbols")).include_p(context, query).isTrue()){ - return item; - } - } - return context.nil; + public boolean isEmpty(){ + return ( getAllEnums().isEmpty() && getSymbolMap().isEmpty() && getTaggedEnums().isEmpty()); } - @JRubyMethod(name = "__map_symbol") public IRubyObject mapSymbol(final ThreadContext context, IRubyObject symbol){ - return symbolMap.op_aref(context, symbol); + return callMethod(context, "__map_symbol", symbol); } } diff --git a/core/src/main/java/org/jruby/ext/ffi/Factory.java b/core/src/main/java/org/jruby/ext/ffi/Factory.java index f51ff7a0ff5..cc27b20dc19 100644 --- a/core/src/main/java/org/jruby/ext/ffi/Factory.java +++ b/core/src/main/java/org/jruby/ext/ffi/Factory.java @@ -130,9 +130,6 @@ public void init(Ruby runtime, RubyModule ffi) { if (ffi.getClass(CallbackInfo.CLASS_NAME) == null) { CallbackInfo.createCallbackInfoClass(runtime, ffi); } - if (ffi.getClass("Enum") == null) { - Enum.createEnumClass(runtime, ffi); - } if (ffi.getClass("Enums") == null) { Enums.createEnumsClass(runtime, ffi); } @@ -147,8 +144,6 @@ public void init(Ruby runtime, RubyModule ffi) { Platform.createPlatformModule(runtime, ffi); IOModule.createIOModule(runtime, ffi); - - StructByReference.createStructByReferenceClass(runtime, ffi); } } diff --git a/core/src/main/java/org/jruby/ext/ffi/NativeType.java b/core/src/main/java/org/jruby/ext/ffi/NativeType.java index 1df9aee17dc..154d01ee273 100644 --- a/core/src/main/java/org/jruby/ext/ffi/NativeType.java +++ b/core/src/main/java/org/jruby/ext/ffi/NativeType.java @@ -50,6 +50,7 @@ public enum NativeType { ULONG, FLOAT, DOUBLE, + LONGDOUBLE, POINTER, BUFFER_IN, BUFFER_OUT, diff --git a/core/src/main/java/org/jruby/ext/ffi/Platform.java b/core/src/main/java/org/jruby/ext/ffi/Platform.java index c8aa3152abe..085ea63d2e3 100644 --- a/core/src/main/java/org/jruby/ext/ffi/Platform.java +++ b/core/src/main/java/org/jruby/ext/ffi/Platform.java @@ -318,25 +318,12 @@ public static void createPlatformModule(Ruby runtime, RubyModule ffi) { OS_TYPE os = platform.getOS(); module.defineConstant("ADDRESS_SIZE", runtime.newFixnum(platform.addressSize)); module.defineConstant("LONG_SIZE", runtime.newFixnum(platform.longSize)); - module.defineConstant("OS", runtime.newString(OS.toString())); - module.defineConstant("ARCH", runtime.newString(platform.getCPU().toString())); - module.defineConstant("NAME", runtime.newString(platform.getName())); - module.defineConstant("IS_WINDOWS", runtime.newBoolean(os == OS.WINDOWS)); - module.defineConstant("IS_BSD", runtime.newBoolean(platform.isBSD())); - module.defineConstant("IS_FREEBSD", runtime.newBoolean(os == OS.FREEBSD)); - module.defineConstant("IS_DRAGONFLYBSD", runtime.newBoolean(os == OS.DRAGONFLYBSD)); - module.defineConstant("IS_OPENBSD", runtime.newBoolean(os == OS.OPENBSD)); - module.defineConstant("IS_SOLARIS", runtime.newBoolean(os == OS.SOLARIS)); - module.defineConstant("IS_LINUX", runtime.newBoolean(os == OS.LINUX)); - module.defineConstant("IS_MAC", runtime.newBoolean(os == OS.DARWIN)); - module.defineConstant("LIBC", runtime.newString(LIBC)); - module.defineConstant("LIBPREFIX", runtime.newString(LIBPREFIX)); - module.defineConstant("LIBSUFFIX", runtime.newString(LIBSUFFIX)); module.defineConstant("BYTE_ORDER", runtime.newFixnum(BYTE_ORDER)); module.defineConstant("BIG_ENDIAN", runtime.newFixnum(BIG_ENDIAN)); module.defineConstant("LITTLE_ENDIAN", runtime.newFixnum(LITTLE_ENDIAN)); module.defineAnnotatedMethods(Platform.class); } + @JRubyMethod(name = "windows?", module=true) public static IRubyObject windows_p(ThreadContext context, IRubyObject recv) { return RubyBoolean.newBoolean(context, OS == OS.WINDOWS); @@ -361,6 +348,7 @@ public static IRubyObject linux_p(ThreadContext context, IRubyObject recv) { public static IRubyObject solaris_p(ThreadContext context, IRubyObject recv) { return RubyBoolean.newBoolean(context, OS == OS.SOLARIS); } + /** * An extension over System.getProperty method. * Handles security restrictions, and returns the default diff --git a/core/src/main/java/org/jruby/ext/ffi/Struct.java b/core/src/main/java/org/jruby/ext/ffi/Struct.java index 2292d205d12..b51e385e1ad 100644 --- a/core/src/main/java/org/jruby/ext/ffi/Struct.java +++ b/core/src/main/java/org/jruby/ext/ffi/Struct.java @@ -21,7 +21,7 @@ public class Struct extends MemoryObject implements StructLayout.Storage { private AbstractMemory memory; private volatile Object[] referenceCache; private volatile IRubyObject[] valueCache; - + private static final class Allocator implements ObjectAllocator { public final IRubyObject allocate(Ruby runtime, RubyClass klass) { return new Struct(runtime, klass); diff --git a/core/src/main/java/org/jruby/ext/ffi/StructByReference.java b/core/src/main/java/org/jruby/ext/ffi/StructByReference.java deleted file mode 100644 index bd183c6643a..00000000000 --- a/core/src/main/java/org/jruby/ext/ffi/StructByReference.java +++ /dev/null @@ -1,121 +0,0 @@ - -package org.jruby.ext.ffi; - -import org.jruby.Ruby; -import org.jruby.RubyClass; -import org.jruby.RubyModule; -import org.jruby.RubyObject; -import org.jruby.RubyString; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - - - -@JRubyClass(name="FFI::StructByReference", parent="Object") -public final class StructByReference extends RubyObject { - private StructLayout structLayout; - private final RubyClass structClass; - - public static RubyClass createStructByReferenceClass(Ruby runtime, RubyModule ffiModule) { - RubyClass sbrClass = ffiModule.defineClassUnder("StructByReference", runtime.getObject(), - ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - sbrClass.defineAnnotatedMethods(StructByReference.class); - sbrClass.defineAnnotatedConstants(StructByReference.class); - sbrClass.includeModule(ffiModule.getConstant("DataConverter")); - - return sbrClass; - } - - - - @JRubyMethod(name = "new", meta = true) - public static final IRubyObject newStructByReference(ThreadContext context, IRubyObject klass, IRubyObject structClass) { - if (!(structClass instanceof RubyClass)) { - throw context.runtime.newTypeError("wrong argument type " - + structClass.getMetaClass().getName() + " (expected Class)"); - } - - if (!((RubyClass) structClass).isKindOfModule(context.runtime.getFFI().structClass)) { - throw context.runtime.newTypeError("wrong argument type " - + structClass.getMetaClass().getName() + " (expected subclass of FFI::Struct)"); - } - - return new StructByReference(context.runtime, (RubyClass) klass, - (RubyClass) structClass, null); - } - - private StructByReference(Ruby runtime, RubyClass klass, RubyClass structClass, StructLayout layout) { - super(runtime, klass); - this.structClass = structClass; - this.structLayout = layout; - } - - @JRubyMethod(name = "to_s") - public final IRubyObject to_s(ThreadContext context) { - return RubyString.newString(context.runtime, String.format("#", structClass.getName())); - } - - @JRubyMethod(name = "layout") - public final IRubyObject layout(ThreadContext context) { - // getStructLayout gets the @layout from the structClass - // which should be OK during concurrent access of this method - if (structLayout == null) { - structLayout = Struct.getStructLayout(context.runtime, structClass); - } - return structLayout; - } - - @JRubyMethod(name = "struct_class") - public final IRubyObject struct_class(ThreadContext context) { - return structClass; - } - - @JRubyMethod(name = "native_type") - public IRubyObject native_type(ThreadContext context) { - return context.runtime.getFFI().typeClass.getConstant("POINTER"); - } - - - @JRubyMethod(name = "to_native") - public IRubyObject to_native(ThreadContext context, IRubyObject value, IRubyObject ctx) { - if (value instanceof Struct && structClass.isInstance(value)) { - return ((Struct) value).getMemory(); - - } else if (value.isNil()) { - return Pointer.getNull(context.runtime); - - } else { - throw context.runtime.newTypeError(value, structClass); - } - } - - @JRubyMethod(name = "from_native") - public IRubyObject from_native(ThreadContext context, IRubyObject value, IRubyObject ctx) { - if (value instanceof AbstractMemory) { - return getStructClass().newInstance(context, value, Block.NULL_BLOCK); - - } else if (value.isNil()) { - return getStructClass().newInstance(context, Pointer.getNull(context.runtime), Block.NULL_BLOCK); - - } else { - throw context.runtime.newTypeError(value, context.runtime.getFFI().pointerClass); - } - } - - @JRubyMethod(name = "reference_required?") - public IRubyObject reference_required_p(ThreadContext context) { - return context.fals; - } - - public final StructLayout getStructLayout() { - return structLayout; - } - - public final RubyClass getStructClass() { - return structClass; - } -} diff --git a/core/src/main/java/org/jruby/ext/ffi/StructLayout.java b/core/src/main/java/org/jruby/ext/ffi/StructLayout.java index 3e6c5782a5b..ad1f21d9a8e 100644 --- a/core/src/main/java/org/jruby/ext/ffi/StructLayout.java +++ b/core/src/main/java/org/jruby/ext/ffi/StructLayout.java @@ -40,7 +40,6 @@ import org.jruby.Ruby; import org.jruby.RubyArray; import org.jruby.RubyClass; -import org.jruby.RubyFixnum; import org.jruby.RubyHash; import org.jruby.RubyInteger; import org.jruby.RubyModule; @@ -54,7 +53,6 @@ import org.jruby.runtime.Block; import org.jruby.runtime.ObjectAllocator; import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; import org.jruby.runtime.builtin.IRubyObject; import org.jruby.runtime.callsite.CachingCallSite; import org.jruby.runtime.callsite.FunctionalCachingCallSite; @@ -145,11 +143,6 @@ public static RubyClass createStructLayoutClass(Ruby runtime, RubyModule module) ArrayFieldAllocator.INSTANCE, layoutClass); arrayFieldClass.defineAnnotatedMethods(ArrayField.class); - RubyClass mappedFieldClass = runtime.defineClassUnder("Mapped", fieldClass, - MappedFieldAllocator.INSTANCE, layoutClass); - mappedFieldClass.defineAnnotatedMethods(MappedField.class); - - return layoutClass; } @@ -312,20 +305,47 @@ public IRubyObject fields(ThreadContext context) { return RubyArray.newArray(context.runtime, fields); } - final IRubyObject getValue(ThreadContext context, IRubyObject name, Storage cache, IRubyObject ptr) { - if (!(ptr instanceof AbstractMemory)) { - throw context.runtime.newTypeError(ptr, context.runtime.getFFI().memoryClass); + @JRubyMethod(name = "__union!") + public IRubyObject union_bang(ThreadContext context) { + Ruby runtime = context.runtime; + + NativeType[] alignmentTypes = { + NativeType.CHAR, NativeType.SHORT, NativeType.INT, NativeType.LONG, + NativeType.FLOAT, NativeType.DOUBLE, NativeType.LONGDOUBLE + }; + + NativeType t = null; + int count, i; + + for (NativeType alignmentType : alignmentTypes) { + if (Type.getNativeAlignment(alignmentType) == alignment) { + t = alignmentType; + break; + } + } + + if (t == null) { + throw runtime.newRuntimeError("cannot create libffi union representation for alignment " + alignment); } - return getMember(context.runtime, name).get(context, cache, (AbstractMemory) ptr); + // FIXME: wot +// count = layout.size / Type.getNativeSize(t); +// layout.ffiTypes = xcalloc(count + 1, sizeof(ffi_type *)); +// layout.base.ffiType->elements = layout->ffiTypes; +// +// for (i = 0; i < count; ++i) { +// layout->ffiTypes[i] = t; +// } + + return this; } - final void putValue(ThreadContext context, IRubyObject name, Storage cache, IRubyObject ptr, IRubyObject value) { - if (!(ptr instanceof AbstractMemory)) { - throw context.runtime.newTypeError(ptr, context.runtime.getFFI().memoryClass); - } + final IRubyObject getValue(ThreadContext context, IRubyObject name, Storage cache, IRubyObject ptr) { + return getMember(context.runtime, name).get(context, cache, AbstractMemory.cast(context, ptr)); + } - getMember(context.runtime, name).put(context, cache, (AbstractMemory) ptr, value); + final void putValue(ThreadContext context, IRubyObject name, Storage cache, IRubyObject ptr, IRubyObject value) { + getMember(context.runtime, name).put(context, cache, AbstractMemory.cast(context, ptr), value); } @Override @@ -486,7 +506,7 @@ public int hashCode() { /** * Writes a ruby value to the native struct member as the appropriate native value. * - * @param runtime The ruby runtime + * @param context the current context * @param cache The value cache * @param ptr The struct memory area. * @param value The ruby value to write to the native struct member. @@ -519,7 +539,7 @@ interface FieldIO { /** * Writes a ruby value to the native struct member as the appropriate native value. * - * @param runtime The ruby runtime + * @param context the current context * @param cache The value cache * @param ptr The struct memory area. * @param value The ruby value to write to the native struct member. @@ -594,6 +614,9 @@ public static class Field extends RubyObject { /** The offset within the memory area of this member */ private int offset; + /** The memory operation for this field type */ + private MemoryOp memoryOp; + Field(Ruby runtime, RubyClass klass) { this(runtime, klass, DefaultFieldIO.INSTANCE); @@ -611,12 +634,15 @@ public static class Field extends RubyObject { this.type = type; this.offset = offset; this.io = io; + this.memoryOp = MemoryOp.getMemoryOp(type); } void init(IRubyObject name, IRubyObject type, IRubyObject offset) { this.name = name; - this.type = checkType(type); + Type realType = checkType(type); + this.type = realType; this.offset = RubyNumeric.num2int(offset); + this.memoryOp = MemoryOp.getMemoryOp(realType); } void init(IRubyObject name, IRubyObject type, IRubyObject offset, FieldIO io) { @@ -731,6 +757,29 @@ public final IRubyObject type(ThreadContext context) { public final IRubyObject name(ThreadContext context) { return name; } + + @JRubyMethod + public final IRubyObject get(ThreadContext context, IRubyObject pointer) { + MemoryOp memoryOp = this.memoryOp; + if (memoryOp == null) { + throw context.runtime.newArgumentError("get not supported for " + type.nativeType.name()); + } + + return memoryOp.get(context, AbstractMemory.cast(context, pointer), offset); + } + + @JRubyMethod + public final IRubyObject put(ThreadContext context, IRubyObject pointer, IRubyObject value) { + MemoryOp memoryOp = this.memoryOp; + + if (memoryOp == null) { + throw context.runtime.newArgumentError("put not supported for " + type.nativeType.name()); + } + + memoryOp.put(context, AbstractMemory.cast(context, pointer), offset, value); + + return this; + } } private static final class NumberFieldAllocator implements ObjectAllocator { @@ -894,39 +943,6 @@ public final IRubyObject initialize(ThreadContext context, IRubyObject[] args) { } } - private static final class MappedFieldAllocator implements ObjectAllocator { - public final IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new MappedField(runtime, klass); - } - private static final ObjectAllocator INSTANCE = new MappedFieldAllocator(); - } - - @JRubyClass(name="FFI::StructLayout::Mapped", parent="FFI::StructLayout::Field") - public static final class MappedField extends Field { - - public MappedField(Ruby runtime, RubyClass klass) { - super(runtime, klass, DefaultFieldIO.INSTANCE); - } - - @JRubyMethod(required = 4, visibility = PRIVATE) - public IRubyObject initialize(ThreadContext context, IRubyObject[] args) { - if (!(args[2] instanceof MappedType)) { - throw context.runtime.newTypeError(args[2], - context.runtime.getModule("FFI").getClass("Type").getClass("Mapped")); - } - - if (!(args[3] instanceof Field)) { - throw context.runtime.newTypeError(args[3], - context.runtime.getModule("FFI").getClass("StructLayout").getClass("Field")); - } - - init(args[0], args[2], args[1], new MappedFieldIO((MappedType) args[2], ((Field) args[3]).getFieldIO())); - - return this; - } - } - - public static interface Storage { IRubyObject getCachedValue(Member member); void putCachedValue(Member member, IRubyObject value); diff --git a/core/src/main/java/org/jruby/ext/ffi/Type.java b/core/src/main/java/org/jruby/ext/ffi/Type.java index e2fbb235a1b..2980490aef6 100644 --- a/core/src/main/java/org/jruby/ext/ffi/Type.java +++ b/core/src/main/java/org/jruby/ext/ffi/Type.java @@ -312,10 +312,10 @@ private static final boolean isPrimitive(NativeType type) { } } - private static final int getNativeAlignment(NativeType type) { + static final int getNativeAlignment(NativeType type) { return isPrimitive(type) ? Factory.getInstance().alignmentOf(type) : 1; } - private static final int getNativeSize(NativeType type) { + static final int getNativeSize(NativeType type) { return isPrimitive(type) ? Factory.getInstance().sizeOf(type) : 0; } diff --git a/core/src/main/java/org/jruby/ext/ffi/TypeResolver.java b/core/src/main/java/org/jruby/ext/ffi/TypeResolver.java index 33fc9c252d1..215fbc50465 100644 --- a/core/src/main/java/org/jruby/ext/ffi/TypeResolver.java +++ b/core/src/main/java/org/jruby/ext/ffi/TypeResolver.java @@ -18,7 +18,7 @@ public final class TypeResolver { } public final Type findType(Ruby runtime, IRubyObject name) { - return findType(runtime, name, null); + return findType(runtime, name, runtime.getNil()); } public final Type findType(Ruby runtime, IRubyObject name, IRubyObject typeMap) { @@ -44,14 +44,14 @@ public final Type findType(Ruby runtime, IRubyObject name, IRubyObject typeMap) return type; } - return lookupAndCacheType(runtime, (RubySymbol)name, (RubyHash)typeMap); + return lookupAndCacheType(runtime, (RubySymbol) name, typeMap); } else { return lookupType(runtime, name, typeMap); } } - private synchronized Type lookupAndCacheType(Ruby runtime, RubySymbol name, RubyHash typeMap) { + private synchronized Type lookupAndCacheType(Ruby runtime, RubySymbol name, IRubyObject typeMap) { Type type = lookupType(runtime, name, typeMap); Map map = new IdentityHashMap(symbolTypeCache); @@ -68,11 +68,12 @@ private Type lookupType(Ruby runtime, IRubyObject name, IRubyObject typeMap) { return (Type) type; } - IRubyObject args[] = new IRubyObject[]{name, typeMap}; - if ((type = ffi.ffiModule.callMethod(runtime.getCurrentContext(), "find_type", args)) instanceof Type) { - return (Type) type; - } + // Unsure why this was there but there's no equivalent in the C code +// IRubyObject args[] = new IRubyObject[]{name, typeMap}; +// if ((type = ffi.ffiModule.callMethod(runtime.getCurrentContext(), "find_type", args)) instanceof Type) { +// return (Type) type; +// } - throw runtime.newTypeError("cannot resolve type " + name); + throw runtime.newArgumentError("cannot resolve type " + name); } } diff --git a/core/src/main/java/org/jruby/ext/ffi/jffi/FFIUtil.java b/core/src/main/java/org/jruby/ext/ffi/jffi/FFIUtil.java index 9e63078108c..dc54969c8a4 100644 --- a/core/src/main/java/org/jruby/ext/ffi/jffi/FFIUtil.java +++ b/core/src/main/java/org/jruby/ext/ffi/jffi/FFIUtil.java @@ -44,6 +44,7 @@ private static final Map buildTypeMap() { m.put(NativeType.FLOAT, com.kenai.jffi.Type.FLOAT); m.put(NativeType.DOUBLE, com.kenai.jffi.Type.DOUBLE); + m.put(NativeType.LONGDOUBLE, com.kenai.jffi.Type.LONGDOUBLE); m.put(NativeType.POINTER, com.kenai.jffi.Type.POINTER); m.put(NativeType.BUFFER_IN, com.kenai.jffi.Type.POINTER); m.put(NativeType.BUFFER_OUT, com.kenai.jffi.Type.POINTER); diff --git a/core/src/main/java/org/jruby/ext/ffi/jffi/Factory.java b/core/src/main/java/org/jruby/ext/ffi/jffi/Factory.java index cfe5e1a1d1b..b52f8fd757b 100644 --- a/core/src/main/java/org/jruby/ext/ffi/jffi/Factory.java +++ b/core/src/main/java/org/jruby/ext/ffi/jffi/Factory.java @@ -9,6 +9,8 @@ import org.jruby.ext.ffi.*; import org.jruby.runtime.ThreadContext; import org.jruby.runtime.builtin.IRubyObject; +import org.jruby.platform.Platform; +import org.jruby.util.WindowsFFI; public class Factory extends org.jruby.ext.ffi.Factory { @@ -40,6 +42,9 @@ public void init(Ruby runtime, RubyModule ffi) { } if (ffi.getClass("LastError") == null) { ffi.defineModuleUnder("LastError").defineAnnotatedMethods(LastError.class); + if (Platform.IS_WINDOWS) { + ffi.defineModuleUnder("LastError").defineAnnotatedMethods(WinapiLastError.class); + } } } @@ -122,4 +127,18 @@ public static final IRubyObject error_set(ThreadContext context, IRubyObject re return value; } } + + public static final class WinapiLastError { + @JRubyMethod(name = { "winapi_error" }, module = true) + public static final IRubyObject winapi_error(ThreadContext context, IRubyObject recv) { + return context.runtime.newFixnum(WindowsFFI.getKernel32().GetLastError()); + } + + @JRubyMethod(name = { "winapi_error=" }, module = true) + public static final IRubyObject winapi_error_set(ThreadContext context, IRubyObject recv, IRubyObject value) { + WindowsFFI.getKernel32().SetLastError((int)value.convertToInteger().getLongValue()); + + return value; + } + } } diff --git a/core/src/main/java/org/jruby/ext/ffi/jffi/Function.java b/core/src/main/java/org/jruby/ext/ffi/jffi/Function.java index fa484af844f..02cfa4402ef 100644 --- a/core/src/main/java/org/jruby/ext/ffi/jffi/Function.java +++ b/core/src/main/java/org/jruby/ext/ffi/jffi/Function.java @@ -75,8 +75,6 @@ public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, I Object proc = null; int optionsIndex = 2; - Type returnType = org.jruby.ext.ffi.Util.findType(context, args[0]); - if (!(args[1] instanceof RubyArray)) { throw context.runtime.newTypeError("Invalid parameter array " + args[1].getMetaClass().getName() + " (expected Array)"); @@ -100,7 +98,9 @@ public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, I } else { throw context.runtime.newTypeError("Invalid function address " + args[0].getMetaClass().getName() + " (expected FFI::Pointer)"); - } + } + + Type returnType = org.jruby.ext.ffi.Util.findType(context, args[0]); // Get the convention from the options hash String convention = "default"; diff --git a/core/src/main/java/org/jruby/ext/ffi/jffi/JITRuntime.java b/core/src/main/java/org/jruby/ext/ffi/jffi/JITRuntime.java index 433368cd76e..fcc5d9a47b3 100644 --- a/core/src/main/java/org/jruby/ext/ffi/jffi/JITRuntime.java +++ b/core/src/main/java/org/jruby/ext/ffi/jffi/JITRuntime.java @@ -483,7 +483,7 @@ private static MemoryIO convertToPointerMemoryIO(IRubyObject parameter) { } } else { - throw parameter.getRuntime().newTypeError("cannot convert parameter to native pointer"); + throw parameter.getRuntime().newArgumentError("cannot convert parameter to native pointer"); } } @@ -533,7 +533,7 @@ public static PointerParameterStrategy pointerParameterStrategy(IRubyObject para return new DelegatingPointerParameterStrategy(ptr, pointerParameterStrategy(ptr)); } else { - throw parameter.getRuntime().newTypeError("cannot convert parameter to native pointer"); + throw parameter.getRuntime().newArgumentError("cannot convert parameter to native pointer"); } } diff --git a/core/src/main/java/org/jruby/ext/ffi/jffi/VariadicInvoker.java b/core/src/main/java/org/jruby/ext/ffi/jffi/VariadicInvoker.java index d426cafe0a9..8b52d2b9c6c 100644 --- a/core/src/main/java/org/jruby/ext/ffi/jffi/VariadicInvoker.java +++ b/core/src/main/java/org/jruby/ext/ffi/jffi/VariadicInvoker.java @@ -64,56 +64,58 @@ public final Arity getArity() { return Arity.OPTIONAL; } - @JRubyMethod(name = { "new" }, meta = true, required = 3, optional = 1) + @JRubyMethod(name = { "new" }, meta = true, required = 4) public static VariadicInvoker newInstance(ThreadContext context, IRubyObject klass, IRubyObject[] args) { + IRubyObject rbFunction = args[0]; + IRubyObject rbParameterTypes = args[1]; + IRubyObject rbReturnType = args[2]; + RubyHash options = (RubyHash) args[3]; + // Get the convention from the options hash String convention = "default"; IRubyObject enums = null; boolean saveError = true; IRubyObject typeMap = null; - if (args.length == 4) { - RubyHash options = (RubyHash) args[3]; - IRubyObject rbConvention = options.fastARef(context.runtime.newSymbol("convention")); - if (rbConvention != null && !rbConvention.isNil()) { - convention = rbConvention.asJavaString(); - } + IRubyObject rbConvention = options.fastARef(context.runtime.newSymbol("convention")); + if (rbConvention != null && !rbConvention.isNil()) { + convention = rbConvention.asJavaString(); + } - IRubyObject rbSaveErrno = options.fastARef(context.runtime.newSymbol("save_errno")); - if (rbSaveErrno != null && !rbSaveErrno.isNil()) { - saveError = rbSaveErrno.isTrue(); - } + IRubyObject rbSaveErrno = options.fastARef(context.runtime.newSymbol("save_errno")); + if (rbSaveErrno != null && !rbSaveErrno.isNil()) { + saveError = rbSaveErrno.isTrue(); + } - enums = options.fastARef(context.runtime.newSymbol("enums")); - if (enums != null && !enums.isNil() && !(enums instanceof RubyHash || enums instanceof Enums)) { - throw context.runtime.newTypeError("wrong type for options[:enum] " - + enums.getMetaClass().getName() + " (expected Hash or Enums)"); + enums = options.fastARef(context.runtime.newSymbol("enums")); + if (enums != null && !enums.isNil() && !(enums instanceof RubyHash || enums instanceof Enums)) { + throw context.runtime.newTypeError("wrong type for options[:enum] " + + enums.getMetaClass().getName() + " (expected Hash or Enums)"); - } - typeMap = options.fastARef(context.runtime.newSymbol("type_map")); - if (typeMap != null && !typeMap.isNil() && !(typeMap instanceof RubyHash)) { - throw context.runtime.newTypeError("wrong type for options[:type_map] " - + typeMap.getMetaClass().getName() + " (expected Hash)"); + } + typeMap = options.fastARef(context.runtime.newSymbol("type_map")); + if (typeMap != null && !typeMap.isNil() && !(typeMap instanceof RubyHash)) { + throw context.runtime.newTypeError("wrong type for options[:type_map] " + + typeMap.getMetaClass().getName() + " (expected Hash)"); - } } - final Type returnType = org.jruby.ext.ffi.Util.findType(context, args[0], typeMap); + final Type returnType = org.jruby.ext.ffi.Util.findType(context, rbReturnType, typeMap); - if (!(args[1] instanceof RubyArray)) { + if (!(rbParameterTypes instanceof RubyArray)) { throw context.runtime.newTypeError("Invalid parameter array " - + args[1].getMetaClass().getName() + " (expected Array)"); + + rbParameterTypes.getMetaClass().getName() + " (expected Array)"); } - if (!(args[2] instanceof Pointer)) { - throw context.runtime.newTypeError(args[2], context.runtime.getFFI().pointerClass); + if (!(rbFunction instanceof Pointer)) { + throw context.runtime.newTypeError(rbFunction, context.runtime.getFFI().pointerClass); } - final Pointer address = (Pointer) args[2]; + final Pointer address = (Pointer) rbFunction; CallingConvention callConvention = "stdcall".equals(convention) ? CallingConvention.STDCALL : CallingConvention.DEFAULT; - RubyArray paramTypes = (RubyArray) args[1]; + RubyArray paramTypes = (RubyArray) rbParameterTypes; RubyArray fixed = RubyArray.newArray(context.runtime); for (int i = 0; i < paramTypes.getLength(); ++i) { Type type = (Type)paramTypes.entry(i); diff --git a/core/src/main/java/org/jruby/ext/rbconfig/RbConfigLibrary.java b/core/src/main/java/org/jruby/ext/rbconfig/RbConfigLibrary.java index 5662b4ef0b4..d0c575b7590 100644 --- a/core/src/main/java/org/jruby/ext/rbconfig/RbConfigLibrary.java +++ b/core/src/main/java/org/jruby/ext/rbconfig/RbConfigLibrary.java @@ -251,6 +251,7 @@ public void load(Ruby runtime, boolean wrap) { setConfig(context, CONFIG, "bindir", binDir); setConfig(context, CONFIG, "RUBY_INSTALL_NAME", jrubyScript()); + setConfig(context, CONFIG, "RUBY_BASE_NAME", jrubyScript()); setConfig(context, CONFIG, "RUBYW_INSTALL_NAME", Platform.IS_WINDOWS ? "jrubyw.exe" : jrubyScript()); setConfig(context, CONFIG, "ruby_install_name", jrubyScript()); setConfig(context, CONFIG, "rubyw_install_name", Platform.IS_WINDOWS ? "jrubyw.exe" : jrubyScript()); @@ -332,6 +333,11 @@ public void load(Ruby runtime, boolean wrap) { setConfig(context, CONFIG, "sysconfdir", sysConfDir); setConfig(context, CONFIG, "localstatedir", newFile(normalizedHome, "var").getPath()); setConfig(context, CONFIG, "DLEXT", "jar"); + if (Platform.IS_WINDOWS) { + setConfig(context, CONFIG, "RUBY_SO_NAME", ((arch.equals("x86_64")) ? "x64-" : "") + "msvcrt-" + jrubyScript()); + } else { + setConfig(context, CONFIG, "RUBY_SO_NAME", "ruby"); + } final String rubygemsDir = getRubygemsDir(runtime); if (rubygemsDir != null) { diff --git a/core/src/main/java/org/jruby/util/StringSupport.java b/core/src/main/java/org/jruby/util/StringSupport.java index 6ee1c5d759f..f37dc4d0aea 100644 --- a/core/src/main/java/org/jruby/util/StringSupport.java +++ b/core/src/main/java/org/jruby/util/StringSupport.java @@ -762,7 +762,7 @@ public static int octLength(byte[]bytes, int p, int len, Encoding enc) { /** * Check whether input object's string value contains a null byte, and if so - * throw SecurityError. + * throw ArgumentError. * @param runtime * @param value */ @@ -773,7 +773,7 @@ public static final void checkStringSafety(Ruby runtime, IRubyObject value) { final int end = bl.length(); for (int i = bl.begin(); i < end; ++i) { if (array[i] == (byte) 0) { - throw runtime.newSecurityError("string contains null byte"); + throw runtime.newArgumentError("string contains null byte"); } } } diff --git a/core/src/main/java/org/jruby/util/WindowsFFI.java b/core/src/main/java/org/jruby/util/WindowsFFI.java index 856917c28e1..5332297bbc0 100644 --- a/core/src/main/java/org/jruby/util/WindowsFFI.java +++ b/core/src/main/java/org/jruby/util/WindowsFFI.java @@ -28,16 +28,11 @@ package org.jruby.util; -import jnr.ffi.*; -import jnr.ffi.LibraryOption; -import jnr.ffi.Runtime; import jnr.ffi.annotations.Out; import jnr.ffi.byref.IntByReference; import jnr.ffi.types.intptr_t; -import jnr.ffi.types.uintptr_t; - -import java.util.HashMap; -import java.util.Map; +import jnr.ffi.CallingConvention; +import jnr.ffi.LibraryLoader; /** * A binding of a few key win32 functions we need to behave properly. @@ -53,6 +48,7 @@ public static interface Kernel32 { jnr.ffi.Pointer OpenProcess(int dwDesiredAccess, int bInheritHandle, int dwProcessId); int CloseHandle(jnr.ffi.Pointer handle); int GetLastError(); + int SetLastError(int ErrorCode); int GetExitCodeProcess(jnr.ffi.Pointer hProcess, @Out IntByReference pointerToExitCodeDword); int TerminateProcess(jnr.ffi.Pointer hProcess, int uExitCode); } diff --git a/lib/ruby/stdlib/ffi.rb b/lib/ruby/stdlib/ffi.rb index aa42f408e80..7d97ca49883 100644 --- a/lib/ruby/stdlib/ffi.rb +++ b/lib/ruby/stdlib/ffi.rb @@ -1 +1,24 @@ -require 'ffi/ffi' \ No newline at end of file +if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx' + Object.send(:remove_const, :FFI) if defined?(::FFI) + begin + require RUBY_VERSION.split('.')[0, 2].join('.') + '/ffi_c' + rescue Exception + require 'ffi_c' + end + + require 'ffi/ffi' + +elsif RUBY_ENGINE == 'jruby' + JRuby::Util.load_ext("org.jruby.ext.ffi.FFIService") + require 'ffi/ffi' + +elsif defined?(RUBY_ENGINE) + # Remove the ffi gem dir from the load path, then reload the internal ffi implementation + $LOAD_PATH.delete(File.dirname(__FILE__)) + $LOAD_PATH.delete(File.join(File.dirname(__FILE__), 'ffi')) + unless $LOADED_FEATURES.nil? + $LOADED_FEATURES.delete(__FILE__) + $LOADED_FEATURES.delete('ffi.rb') + end + require 'ffi.rb' +end diff --git a/lib/ruby/stdlib/ffi/autopointer.rb b/lib/ruby/stdlib/ffi/autopointer.rb index aa6b003ee07..889a3e395cb 100644 --- a/lib/ruby/stdlib/ffi/autopointer.rb +++ b/lib/ruby/stdlib/ffi/autopointer.rb @@ -1,37 +1,203 @@ # # Copyright (C) 2008-2010 Wayne Meissner +# Copyright (C) 2008 Mike Dalessio # -# Version: EPL 2.0/GPL 2.0/LGPL 2.1 +# This file is part of ruby-ffi. # -# The contents of this file are subject to the Common Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.eclipse.org/legal/cpl-v10.html +# All rights reserved. # -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: # -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the EPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the EPL, the GPL or the LGPL. +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. module FFI class AutoPointer < Pointer extend DataConverter + # @overload initialize(pointer, method) + # @param pointer [Pointer] + # @param method [Method] + # @return [self] + # The passed Method will be invoked at GC time. + # @overload initialize(pointer, proc) + # @param pointer [Pointer] + # @return [self] + # The passed Proc will be invoked at GC time (SEE WARNING BELOW!) + # @note WARNING: passing a proc _may_ cause your pointer to never be + # GC'd, unless you're careful to avoid trapping a reference to the + # pointer in the proc. See the test specs for examples. + # @overload initialize(pointer) { |p| ... } + # @param pointer [Pointer] + # @yieldparam [Pointer] p +pointer+ passed to the block + # @return [self] + # The passed block will be invoked at GC time. + # @note + # WARNING: passing a block will cause your pointer to never be GC'd. + # This is bad. + # @overload initialize(pointer) + # @param pointer [Pointer] + # @return [self] + # The pointer's release() class method will be invoked at GC time. + # + # @note The safest, and therefore preferred, calling + # idiom is to pass a Method as the second parameter. Example usage: + # + # class PointerHelper + # def self.release(pointer) + # ... + # end + # end + # + # p = AutoPointer.new(other_pointer, PointerHelper.method(:release)) + # + # The above code will cause PointerHelper#release to be invoked at GC time. + # + # @note + # The last calling idiom (only one parameter) is generally only + # going to be useful if you subclass {AutoPointer}, and override + # #release, which by default does nothing. + def initialize(ptr, proc=nil, &block) + super(ptr.type_size, ptr) + raise TypeError, "Invalid pointer" if ptr.nil? || !ptr.kind_of?(Pointer) \ + || ptr.kind_of?(MemoryPointer) || ptr.kind_of?(AutoPointer) + + @releaser = if proc + if not proc.respond_to?(:call) + raise RuntimeError.new("proc must be callable") + end + CallableReleaser.new(ptr, proc) + + else + if not self.class.respond_to?(:release) + raise RuntimeError.new("no release method defined") + end + DefaultReleaser.new(ptr, self.class) + end + + ObjectSpace.define_finalizer(self, @releaser) + self + end + + # @return [nil] + # Free the pointer. + def free + @releaser.free + end + + # @param [Boolean] autorelease + # @return [Boolean] +autorelease+ + # Set +autorelease+ property. See {Pointer Autorelease section at Pointer}. + def autorelease=(autorelease) + @releaser.autorelease=(autorelease) + end + + # @return [Boolean] +autorelease+ + # Get +autorelease+ property. See {Pointer Autorelease section at Pointer}. + def autorelease? + @releaser.autorelease + end + + # @abstract Base class for {AutoPointer}'s releasers. + # + # All subclasses of Releaser should define a +#release(ptr)+ method. + # A releaser is an object in charge of release an {AutoPointer}. + class Releaser + attr_accessor :autorelease + + # @param [Pointer] ptr + # @param [#call] proc + # @return [nil] + # A new instance of Releaser. + def initialize(ptr, proc) + @ptr = ptr + @proc = proc + @autorelease = true + end + + # @return [nil] + # Free pointer. + def free + if @ptr + release(@ptr) + @autorelease = false + @ptr = nil + @proc = nil + end + end + + # @param args + # Release pointer if +autorelease+ is set. + def call(*args) + release(@ptr) if @autorelease && @ptr + end + end + + # DefaultReleaser is a {Releaser} used when an {AutoPointer} is defined + # without Proc or Method. In this case, the pointer to release must be of + # a class derived from AutoPointer with a {release} class method. + class DefaultReleaser < Releaser + # @param [Pointer] ptr + # @return [nil] + # Release +ptr+ using the {release} class method of its class. + def release(ptr) + @proc.release(ptr) + end + end + + # CallableReleaser is a {Releaser} used when an {AutoPointer} is defined with a + # Proc or a Method. + class CallableReleaser < Releaser + # Release +ptr+ by using Proc or Method defined at +ptr+ + # {AutoPointer#initialize initialization}. + # + # @param [Pointer] ptr + # @return [nil] + def release(ptr) + @proc.call(ptr) + end + end + + # Return native type of AutoPointer. + # + # Override {DataConverter#native_type}. + # @return [Type::POINTER] + # @raise {RuntimeError} if class does not implement a +#release+ method def self.native_type - raise RuntimeError.new("no release method defined for #{self.inspect}") unless self.respond_to?(:release) + if not self.respond_to?(:release) + raise RuntimeError.new("no release method defined for #{self.inspect}") + end Type::POINTER end + + # Create a new AutoPointer. + # + # Override {DataConverter#from_native}. + # @overload self.from_native(ptr, ctx) + # @param [Pointer] ptr + # @param ctx not used. Please set +nil+. + # @return [AutoPointer] + def self.from_native(val, ctx) + self.new(val) + end end + end diff --git a/lib/ruby/stdlib/ffi/buffer.rb b/lib/ruby/stdlib/ffi/buffer.rb index 6e7633bfe01..449e45b0de9 100644 --- a/lib/ruby/stdlib/ffi/buffer.rb +++ b/lib/ruby/stdlib/ffi/buffer.rb @@ -1 +1,4 @@ -# This file intentionally left blank +# +# All the code from this file is now implemented in C. This file remains +# to satisfy any leftover require 'ffi/buffer' in user code +# diff --git a/lib/ruby/stdlib/ffi/callback.rb b/lib/ruby/stdlib/ffi/callback.rb new file mode 100644 index 00000000000..32d52f7214a --- /dev/null +++ b/lib/ruby/stdlib/ffi/callback.rb @@ -0,0 +1,4 @@ +# +# All the code from this file is now implemented in C. This file remains +# to satisfy any leftover require 'ffi/callback' in user code +# diff --git a/lib/ruby/stdlib/ffi/data_converter.rb b/lib/ruby/stdlib/ffi/data_converter.rb new file mode 100644 index 00000000000..1527588b758 --- /dev/null +++ b/lib/ruby/stdlib/ffi/data_converter.rb @@ -0,0 +1,67 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.# + +module FFI + # This module is used to extend somes classes and give then a common API. + # + # Most of methods defined here must be overriden. + module DataConverter + # Get native type. + # + # @overload native_type(type) + # @param [String, Symbol, Type] type + # @return [Type] + # Get native type from +type+. + # + # @overload native_type + # @raise {NotImplementedError} This method must be overriden. + def native_type(type = nil) + if type + @native_type = FFI.find_type(type) + else + native_type = @native_type + unless native_type + raise NotImplementedError, 'native_type method not overridden and no native_type set' + end + native_type + end + end + + # Convert to a native type. + def to_native(value, ctx) + value + end + + # Convert from a native type. + def from_native(value, ctx) + value + end + end +end diff --git a/lib/ruby/stdlib/ffi/enum.rb b/lib/ruby/stdlib/ffi/enum.rb index 75ecdd38ca0..8fcb4985953 100644 --- a/lib/ruby/stdlib/ffi/enum.rb +++ b/lib/ruby/stdlib/ffi/enum.rb @@ -1 +1,296 @@ -# The enum functionality has been migrated to Enum.java \ No newline at end of file +# +# Copyright (C) 2009, 2010 Wayne Meissner +# Copyright (C) 2009 Luc Heinrich +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +module FFI + + # An instance of this class permits to manage {Enum}s. In fact, Enums is a collection of {Enum}s. + class Enums + + # @return [nil] + def initialize + @all_enums = Array.new + @tagged_enums = Hash.new + @symbol_map = Hash.new + end + + # @param [Enum] enum + # Add an {Enum} to the collection. + def <<(enum) + @all_enums << enum + @tagged_enums[enum.tag] = enum unless enum.tag.nil? + @symbol_map.merge!(enum.symbol_map) + end + + # @param query enum tag or part of an enum name + # @return [Enum] + # Find a {Enum} in collection. + def find(query) + if @tagged_enums.has_key?(query) + @tagged_enums[query] + else + @all_enums.detect { |enum| enum.symbols.include?(query) } + end + end + + # @param symbol a symbol to find in merge symbol maps of all enums. + # @return a symbol + def __map_symbol(symbol) + @symbol_map[symbol] + end + + end + + # Represents a C enum. + # + # For a C enum: + # enum fruits { + # apple, + # banana, + # orange, + # pineapple + # }; + # are defined this vocabulary: + # * a _symbol_ is a word from the enumeration (ie. _apple_, by example); + # * a _value_ is the value of a symbol in the enumeration (by example, apple has value _0_ and banana _1_). + class Enum + include DataConverter + + attr_reader :tag + attr_reader :native_type + + # @overload initialize(info, tag=nil) + # @param [nil, Enumerable] info + # @param [nil, Symbol] tag enum tag + # @overload initialize(native_type, info, tag=nil) + # @param [FFI::Type] native_type Native type for new Enum + # @param [nil, Enumerable] info symbols and values for new Enum + # @param [nil, Symbol] tag name of new Enum + def initialize(*args) + @native_type = args.first.kind_of?(FFI::Type) ? args.shift : Type::INT + info, @tag = *args + @kv_map = Hash.new + unless info.nil? + last_cst = nil + value = 0 + info.each do |i| + case i + when Symbol + raise ArgumentError, "duplicate enum key" if @kv_map.has_key?(i) + @kv_map[i] = value + last_cst = i + value += 1 + when Integer + @kv_map[last_cst] = i + value = i+1 + end + end + end + @vk_map = @kv_map.invert + end + + # @return [Array] enum symbol names + def symbols + @kv_map.keys + end + + # Get a symbol or a value from the enum. + # @overload [](query) + # Get enum value from symbol. + # @param [Symbol] query + # @return [Integer] + # @overload [](query) + # Get enum symbol from value. + # @param [Integer] query + # @return [Symbol] + def [](query) + case query + when Symbol + @kv_map[query] + when Integer + @vk_map[query] + end + end + alias find [] + + # Get the symbol map. + # @return [Hash] + def symbol_map + @kv_map + end + + alias to_h symbol_map + alias to_hash symbol_map + + # @param [Symbol, Integer, #to_int] val + # @param ctx unused + # @return [Integer] value of a enum symbol + def to_native(val, ctx) + @kv_map[val] || if val.is_a?(Integer) + val + elsif val.respond_to?(:to_int) + val.to_int + else + raise ArgumentError, "invalid enum value, #{val.inspect}" + end + end + + # @param val + # @return symbol name if it exists for +val+. + def from_native(val, ctx) + @vk_map[val] || val + end + end + + # Represents a C enum whose values are power of 2 + # + # @example + # enum { + # red = (1<<0), + # green = (1<<1), + # blue = (1<<2) + # } + # + # Contrary to classical enums, bitmask values are usually combined + # when used. + class Bitmask < Enum + + # @overload initialize(info, tag=nil) + # @param [nil, Enumerable] info symbols and bit rank for new Bitmask + # @param [nil, Symbol] tag name of new Bitmask + # @overload initialize(native_type, info, tag=nil) + # @param [FFI::Type] native_type Native type for new Bitmask + # @param [nil, Enumerable] info symbols and bit rank for new Bitmask + # @param [nil, Symbol] tag name of new Bitmask + def initialize(*args) + @native_type = args.first.kind_of?(FFI::Type) ? args.shift : Type::INT + info, @tag = *args + @kv_map = Hash.new + unless info.nil? + last_cst = nil + value = 0 + info.each do |i| + case i + when Symbol + raise ArgumentError, "duplicate bitmask key" if @kv_map.has_key?(i) + @kv_map[i] = 1 << value + last_cst = i + value += 1 + when Integer + raise ArgumentError, "bitmask index should be positive" if i<0 + @kv_map[last_cst] = 1 << i + value = i+1 + end + end + end + @vk_map = @kv_map.invert + end + + # Get a symbol list or a value from the bitmask + # @overload [](*query) + # Get bitmask value from symbol list + # @param [Symbol] query + # @return [Integer] + # @overload [](query) + # Get bitmaks value from symbol array + # @param [Array] query + # @return [Integer] + # @overload [](*query) + # Get a list of bitmask symbols corresponding to + # the or reduction of a list of integer + # @param [Integer] query + # @return [Array] + # @overload [](query) + # Get a list of bitmask symbols corresponding to + # the or reduction of a list of integer + # @param [Array] query + # @return [Array] + def [](*query) + flat_query = query.flatten + raise ArgumentError, "query should be homogeneous, #{query.inspect}" unless flat_query.all? { |o| o.is_a?(Symbol) } || flat_query.all? { |o| o.is_a?(Integer) || o.respond_to?(:to_int) } + case flat_query[0] + when Symbol + flat_query.inject(0) do |val, o| + v = @kv_map[o] + if v then val |= v else val end + end + when Integer, ->(o) { o.respond_to?(:to_int) } + val = flat_query.inject(0) { |mask, o| mask |= o.to_int } + @kv_map.select { |_, v| v & val != 0 }.keys + end + end + + # Get the native value of a bitmask + # @overload to_native(query, ctx) + # @param [Symbol, Integer, #to_int] query + # @param ctx unused + # @return [Integer] value of a bitmask + # @overload to_native(query, ctx) + # @param [Array] query + # @param ctx unused + # @return [Integer] value of a bitmask + def to_native(query, ctx) + return 0 if query.nil? + flat_query = [query].flatten + flat_query.inject(0) do |val, o| + case o + when Symbol + v = @kv_map[o] + raise ArgumentError, "invalid bitmask value, #{o.inspect}" unless v + val |= v + when Integer + val |= o + when ->(obj) { obj.respond_to?(:to_int) } + val |= o.to_int + else + raise ArgumentError, "invalid bitmask value, #{o.inspect}" + end + end + end + + # @param [Integer] val + # @param ctx unused + # @return [Array] list of symbol names corresponding to val, plus an optional remainder if some bits don't match any constant + def from_native(val, ctx) + list = @kv_map.select { |_, v| v & val != 0 }.keys + # If there are unmatch flags, + # return them in an integer, + # else information can be lost. + # Similar to Enum behavior. + remainder = val ^ list.inject(0) do |tmp, o| + v = @kv_map[o] + if v then tmp |= v else tmp end + end + list.push remainder unless remainder == 0 + return list + end + end +end diff --git a/lib/ruby/stdlib/ffi/errno.rb b/lib/ruby/stdlib/ffi/errno.rb index 4c5b61b845e..de82d891fbe 100644 --- a/lib/ruby/stdlib/ffi/errno.rb +++ b/lib/ruby/stdlib/ffi/errno.rb @@ -1,35 +1,43 @@ # -# Copyright (C) 2008 Wayne Meissner +# Copyright (C) 2008-2010 Wayne Meissner # -# Version: EPL 2.0/GPL 2.0/LGPL 2.1 +# This file is part of ruby-ffi. # -# The contents of this file are subject to the Common Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.eclipse.org/legal/cpl-v10.html +# All rights reserved. # -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: # -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the EPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the EPL, the GPL or the LGPL. +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.# + module FFI + # @return (see FFI::LastError.error) + # @see FFI::LastError.error def self.errno FFI::LastError.error end + # @param error (see FFI::LastError.error=) + # @return (see FFI::LastError.error=) + # @see FFI::LastError.error= def self.errno=(error) FFI::LastError.error = error end -end \ No newline at end of file +end diff --git a/lib/ruby/stdlib/ffi/ffi.rb b/lib/ruby/stdlib/ffi/ffi.rb index 31a6940b710..5201dae81e1 100644 --- a/lib/ruby/stdlib/ffi/ffi.rb +++ b/lib/ruby/stdlib/ffi/ffi.rb @@ -1,34 +1,11 @@ # -# Version: EPL 2.0/GPL 2.0/LGPL 2.1 +# Copyright (C) 2008-2010 JRuby project # -# The contents of this file are subject to the Common Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.eclipse.org/legal/cpl-v10.html +# This file is part of ruby-ffi. # -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# Copyright (C) 2008 JRuby project -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the EPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the EPL, the GPL or the LGPL. -# -# Copyright (c) 2007, 2008 Evan Phoenix # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this @@ -36,109 +13,34 @@ # * Redistributions in binary form must reproduce the above copyright notice # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# * Neither the name of the Evan Phoenix nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -require 'rbconfig' - -module FFI - # Specialised error classes - delcare before loading all the other classes - class NativeError < LoadError; end - - class SignatureError < NativeError; end - - class NotFoundError < NativeError - def initialize(function, *libraries) - super("Function '#{function}' not found in [#{libraries[0].nil? ? 'current process' : libraries.join(", ")}]") - end - end -end - require 'ffi/platform' +require 'ffi/data_converter' require 'ffi/types' require 'ffi/library' +require 'ffi/errno' require 'ffi/pointer' require 'ffi/memorypointer' -require 'ffi/autopointer' require 'ffi/struct' require 'ffi/union' +require 'ffi/managedstruct' +require 'ffi/callback' require 'ffi/io' +require 'ffi/autopointer' require 'ffi/variadic' -require 'ffi/errno' -require 'ffi/managedstruct' - -module FFI - - def self.map_library_name(lib) - lib = lib.to_s - # Mangle the library name to reflect the native library naming conventions - lib = Platform::LIBC if lib == 'c' - if lib && File.basename(lib) == lib - lib = Platform::LIBPREFIX + lib unless lib =~ /^#{Platform::LIBPREFIX}/ - r = Platform::IS_LINUX ? "\\.so($|\\.[1234567890]+)" : "\\.#{Platform::LIBSUFFIX}$" - lib += ".#{Platform::LIBSUFFIX}" unless lib =~ /#{r}/ - end - lib - end - - def self.create_invoker(lib, name, args, ret_type, options = { :convention => :default }) - # Current artificial limitation based on JRuby::FFI limit - raise SignatureError, 'FFI functions may take max 32 arguments!' if args.size > 32 - - # Open the library if needed - library = if lib.kind_of?(DynamicLibrary) - lib - elsif lib.kind_of?(String) - # Allow FFI.create_invoker to be called with a library name - DynamicLibrary.open(FFI.map_library_name(lib), DynamicLibrary::RTLD_LAZY) - elsif lib.nil? - FFI::Library::DEFAULT - else - raise LoadError, "Invalid library '#{lib}'" - end - function = library.find_function(name) - raise NotFoundError.new(name, library.name) unless function - - args = args.map {|e| find_type(e) } - invoker = if args.length > 0 && args[args.length - 1] == FFI::NativeType::VARARGS - FFI::VariadicInvoker.new(library, function, args, find_type(ret_type), options) - else - FFI::Function.new(find_type(ret_type), args, function, options) - end - raise NotFoundError.new(name, library.name) unless invoker - - return invoker - end - - # Load all the platform dependent types/consts/struct members - class Config - CONFIG = Hash.new - begin - File.open(File.join(Platform::CONF_DIR, 'platform.conf'), "r") do |f| - typedef = "rbx.platform.typedef." - f.each_line { |line| - if line.index(typedef) == 0 - new_type, orig_type = line.chomp.slice(typedef.length..-1).split(/\s*=\s*/) - FFI.add_typedef(orig_type.to_sym, new_type.to_sym) - else - key, value = line.chomp.split(/\s*=\s*/) - CONFIG[String.new << key] = String.new << value unless key.nil? or value.nil? - end - } - end - rescue Errno::ENOENT - end - end -end +require 'ffi/enum' +require 'ffi/version' diff --git a/lib/ruby/stdlib/ffi/io.rb b/lib/ruby/stdlib/ffi/io.rb index f9d160ea7be..7fa1cf7fd55 100644 --- a/lib/ruby/stdlib/ffi/io.rb +++ b/lib/ruby/stdlib/ffi/io.rb @@ -1,43 +1,61 @@ # -# Copyright (C) 2008 Wayne Meissner +# Copyright (C) 2008, 2009 Wayne Meissner # -# Version: EPL 2.0/GPL 2.0/LGPL 2.1 +# This file is part of ruby-ffi. # -# The contents of this file are subject to the Common Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.eclipse.org/legal/cpl-v10.html +# All rights reserved. # -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: # -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the EPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the EPL, the GPL or the LGPL. +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.# module FFI + + # This module implements a couple of class methods to play with IO. module IO - def self.for_fd(fd, mode = 'r') - FFI::FileDescriptorIO.new(fd) + # @param [Integer] fd file decriptor + # @param [String] mode mode string + # @return [::IO] + # Synonym for IO::for_fd. + def self.for_fd(fd, mode = "r") + ::IO.for_fd(fd, mode) end + # @param [#read] io io to read from + # @param [AbstractMemory] buf destination for data read from +io+ + # @param [nil, Numeric] len maximul number of bytes to read from +io+. If +nil+, + # read until end of file. + # @return [Numeric] length really read, in bytes # - # A version of IO#read that reads into a native buffer + # A version of IO#read that reads data from an IO and put then into a native buffer. # - # This will be optimized at some future time to eliminate the double copy + # This will be optimized at some future time to eliminate the double copy. # - # def self.native_read(io, buf, len) + def self.native_read(io, buf, len) + tmp = io.read(len) + return -1 unless tmp + buf.put_bytes(0, tmp) + tmp.length + end end end diff --git a/lib/ruby/stdlib/ffi/library.rb b/lib/ruby/stdlib/ffi/library.rb index d8cd09cb97b..8d1effa684a 100644 --- a/lib/ruby/stdlib/ffi/library.rb +++ b/lib/ruby/stdlib/ffi/library.rb @@ -1,33 +1,9 @@ # # Copyright (C) 2008-2010 Wayne Meissner -# Copyright (C) 2008 Luc Heinrich # -# Version: EPL 2.0/GPL 2.0/LGPL 2.1 +# This file is part of ruby-ffi. # -# The contents of this file are subject to the Common Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.eclipse.org/legal/cpl-v10.html -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the EPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the EPL, the GPL or the LGPL. -# -# -# This file contains code that was originally under the following license: +# All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -37,7 +13,7 @@ # * Redistributions in binary form must reproduce the above copyright notice # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# * Neither the name of the Evan Phoenix nor the names of its contributors +# * Neither the name of the Ruby FFI project nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # @@ -50,11 +26,41 @@ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.# + module FFI CURRENT_PROCESS = USE_THIS_PROCESS_AS_LIBRARY = Object.new + # @param [#to_s] lib library name + # @return [String] library name formatted for current platform + # Transform a generic library name to a platform library name + # @example + # # Linux + # FFI.map_library_name 'c' # -> "libc.so.6" + # FFI.map_library_name 'jpeg' # -> "libjpeg.so" + # # Windows + # FFI.map_library_name 'c' # -> "msvcrt.dll" + # FFI.map_library_name 'jpeg' # -> "jpeg.dll" + def self.map_library_name(lib) + # Mangle the library name to reflect the native library naming conventions + lib = Library::LIBC if lib == 'c' + + if lib && File.basename(lib) == lib + lib = Platform::LIBPREFIX + lib unless lib =~ /^#{Platform::LIBPREFIX}/ + r = Platform::IS_WINDOWS || Platform::IS_MAC ? "\\.#{Platform::LIBSUFFIX}$" : "\\.so($|\\.[1234567890]+)" + lib += ".#{Platform::LIBSUFFIX}" unless lib =~ /#{r}/ + end + + lib + end + + # Exception raised when a function is not found in libraries + class NotFoundError < LoadError + def initialize(function, *libraries) + super("Function '#{function}' not found in [#{libraries[0].nil? ? 'current process' : libraries.join(", ")}]") + end + end + # This module is the base to use native functions. # # A basic usage may be: @@ -73,6 +79,15 @@ module Library CURRENT_PROCESS = FFI::CURRENT_PROCESS LIBC = FFI::Platform::LIBC + # @param mod extended object + # @return [nil] + # @raise {RuntimeError} if +mod+ is not a Module + # Test if extended object is a Module. If not, raise RuntimeError. + def self.extended(mod) + raise RuntimeError.new("must only be extended by module") unless mod.kind_of?(Module) + end + + # @param [Array] names names of libraries to load # @return [Array] # @raise {LoadError} if a library cannot be opened @@ -82,17 +97,21 @@ def ffi_lib(*names) lib_flags = defined?(@ffi_lib_flags) ? @ffi_lib_flags : FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL ffi_libs = names.map do |name| + if name == FFI::CURRENT_PROCESS FFI::DynamicLibrary.open(nil, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL) + else - libnames = (name.is_a?(::Array) ? name : [ name ]).map { |n| [ n, FFI.map_library_name(n) ].uniq }.flatten.compact + libnames = (name.is_a?(::Array) ? name : [ name ]).map(&:to_s).map { |n| [ n, FFI.map_library_name(n) ].uniq }.flatten.compact lib = nil errors = {} libnames.each do |libname| begin + orig = libname lib = FFI::DynamicLibrary.open(libname, lib_flags) break if lib + rescue Exception => ex ldscript = false if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format)/ @@ -105,13 +124,25 @@ def ffi_lib(*names) if ldscript retry else - errors[libname] = ex + # TODO better library lookup logic + unless libname.start_with?("/") || FFI::Platform.windows? + path = ['/usr/lib/','/usr/local/lib/','/opt/local/lib/'].find do |pth| + File.exist?(pth + libname) + end + if path + libname = path + libname + retry + end + end + + libr = (orig == libname ? orig : "#{orig} #{libname}") + errors[libr] = ex end end end if lib.nil? - raise LoadError.new(errors.values.join('. ')) + raise LoadError.new(errors.values.join(".\n")) end # return the found lib @@ -228,9 +259,10 @@ def attach_function(name, func, args, returns = nil, options = nil) raise LoadError unless function invokers << if arg_types.length > 0 && arg_types[arg_types.length - 1] == FFI::NativeType::VARARGS - FFI::VariadicInvoker.new(find_type(ret_type), arg_types, function, options) + VariadicInvoker.new(function, arg_types, find_type(ret_type), options) + else - FFI::Function.new(find_type(ret_type), arg_types, function, options) + Function.new(find_type(ret_type), arg_types, function, options) end rescue LoadError @@ -241,7 +273,7 @@ def attach_function(name, func, args, returns = nil, options = nil) raise FFI::NotFoundError.new(cname.to_s, ffi_libraries.map { |lib| lib.name }) unless invoker invoker.attach(self, mname.to_s) - invoker # Return a version that can be called via #call + invoker end # @param [#to_s] name function name @@ -259,12 +291,12 @@ def function_names(name, arg_types) if ffi_convention == :stdcall # Get the size of each parameter size = arg_types.inject(0) do |mem, arg| - mem + arg.size + size = arg.size + # The size must be a multiple of 4 + size += (4 - size) % 4 + mem + size end - # Next, the size must be a multiple of 4 - size += (4 - size) % 4 - result << "_#{name.to_s}@#{size}" # win32 result << "#{name.to_s}@#{size}" # win64 end @@ -272,24 +304,26 @@ def function_names(name, arg_types) end # @overload attach_variable(mname, cname, type) - # @example - # module Bar - # extend FFI::Library - # ffi_lib 'my_lib' - # attach_variable :c_myvar, :myvar, :long - # end - # # now callable via Bar.c_myvar + # @param [#to_s] mname name of ruby method to attach as + # @param [#to_s] cname name of C variable to attach + # @param [DataConverter, Struct, Symbol, Type] type C variable's type + # @example + # module Bar + # extend FFI::Library + # ffi_lib 'my_lib' + # attach_variable :c_myvar, :myvar, :long + # end + # # now callable via Bar.c_myvar # @overload attach_variable(cname, type) - # @example - # module Bar - # extend FFI::Library - # ffi_lib 'my_lib' - # attach_variable :myvar, :long - # end - # # now callable via Bar.myvar - # @param [#to_s] mname name of ruby method to attach as - # @param [#to_s] cname name of C variable to attach - # @param [DataConverter, Struct, Symbol, Type] type C varaible's type + # @param [#to_s] mname name of ruby method to attach as + # @param [DataConverter, Struct, Symbol, Type] type C variable's type + # @example + # module Bar + # extend FFI::Library + # ffi_lib 'my_lib' + # attach_variable :myvar, :long + # end + # # now callable via Bar.myvar # @return [DynamicLibrary::Symbol] # @raise {FFI::NotFoundError} if +cname+ cannot be found in libraries # @@ -308,7 +342,7 @@ def attach_variable(mname, a1, a2 = nil) raise FFI::NotFoundError.new(cname, ffi_libraries) if address.nil? || address.null? if type.is_a?(Class) && type < FFI::Struct # If it is a global struct, just attach directly to the pointer - s = type.new(address) + s = s = type.new(address) # Assigning twice to suppress unused variable warning self.module_eval <<-code, __FILE__, __LINE__ @@ffi_gvar_#{mname} = s def self.#{mname} @@ -340,10 +374,12 @@ def self.#{mname}=(value) # @overload callback(name, params, ret) + # @param name callback name to add to type map + # @param [Array] params array of parameters' types + # @param [DataConverter, Struct, Symbol, Type] ret callback return type # @overload callback(params, ret) - # @param name callback name to add to type map - # @param [Array] params array of parameters' types - # @param [DataConverter, Struct, Symbol, Type] ret callback return type + # @param [Array] params array of parameters' types + # @param [DataConverter, Struct, Symbol, Type] ret callback return type # @return [FFI::CallbackInfo] def callback(*args) raise ArgumentError, "wrong number of arguments" if args.length < 2 || args.length > 3 @@ -368,10 +404,6 @@ def callback(*args) cb end - # @param [DataConverter, Symbol, Type] old - # @param add - # @param [] info - # @return [FFI::Enum, FFI::Type] # Register or get an already registered type definition. # # To register a new type definition, +old+ should be a {FFI::Type}. +add+ @@ -384,6 +416,11 @@ def callback(*args) # * in others cases, +info+ is used to create a named enum. # # If +old+ is a key for type map, #typedef get +old+ type definition. + # + # @param [DataConverter, Symbol, Type] old + # @param [Symbol] add + # @param [Symbol] info + # @return [FFI::Enum, FFI::Type] def typedef(old, add, info=nil) @ffi_typedefs = Hash.new unless defined?(@ffi_typedefs) @@ -408,6 +445,28 @@ def typedef(old, add, info=nil) end end + private + # Generic enum builder + # @param [Class] klass can be one of FFI::Enum or FFI::Bitmask + # @param args (see #enum or #bitmask) + def generic_enum(klass, *args) + native_type = args.first.kind_of?(FFI::Type) ? args.shift : nil + name, values = if args[0].kind_of?(Symbol) && args[1].kind_of?(Array) + [ args[0], args[1] ] + elsif args[0].kind_of?(Array) + [ nil, args[0] ] + else + [ nil, args ] + end + @ffi_enums = FFI::Enums.new unless defined?(@ffi_enums) + @ffi_enums << (e = native_type ? klass.new(native_type, values, name) : klass.new(values, name)) + + # If called with a name, add a typedef alias + typedef(e, name) if name + e + end + + public # @overload enum(name, values) # Create a named enum. # @example @@ -446,27 +505,57 @@ def typedef(old, add, info=nil) # @return [FFI::Enum] # Create a new {FFI::Enum}. def enum(*args) - native_type = args.first.kind_of?(FFI::Type) ? args.shift : nil - name, values = if args[0].kind_of?(Symbol) && args[1].kind_of?(Array) - [ args[0], args[1] ] - elsif args[0].kind_of?(Array) - [ nil, args[0] ] - else - [ nil, args ] - end - @ffi_enums = FFI::Enums.new unless defined?(@ffi_enums) - @ffi_enums << (e = native_type ? FFI::Enum.new(native_type, values, name) : FFI::Enum.new(values, name)) + generic_enum(FFI::Enum, *args) + end - # If called as enum :foo, [ :zero, :one, :two ], add a typedef alias - typedef(e, name) if name - e + # @overload bitmask(name, values) + # Create a named bitmask + # @example + # bitmask :foo, [:red, :green, :blue] # bits 0,1,2 are used + # bitmask :foo, [:red, :green, 5, :blue] # bits 0,5,6 are used + # @param [Symbol] name for new bitmask + # @param [Array] values for new bitmask + # @overload bitmask(*args) + # Create an unamed bitmask + # @example + # bm = bitmask :red, :green, :blue # bits 0,1,2 are used + # bm = bitmask :red, :green, 5, blue # bits 0,5,6 are used + # @param [Symbol, Integer] args values for new bitmask + # @overload bitmask(values) + # Create an unamed bitmask + # @example + # bm = bitmask [:red, :green, :blue] # bits 0,1,2 are used + # bm = bitmask [:red, :green, 5, blue] # bits 0,5,6 are used + # @param [Array] values for new bitmask + # @overload bitmask(native_type, name, values) + # Create a named enum and specify the native type. + # @example + # bitmask FFI::Type::UINT64, :foo, [:red, :green, :blue] + # @param [FFI::Type] native_type native type for new bitmask + # @param [Symbol] name for new bitmask + # @param [Array] values for new bitmask + # @overload bitmask(native_type, *args) + # @example + # bitmask FFI::Type::UINT64, :red, :green, :blue + # @param [FFI::Type] native_type native type for new bitmask + # @param [Symbol, Integer] args values for new bitmask + # @overload bitmask(native_type, values) + # Create a named enum and specify the native type. + # @example + # bitmask FFI::Type::UINT64, [:red, :green, :blue] + # @param [FFI::Type] native_type native type for new bitmask + # @param [Array] values for new bitmask + # @return [FFI::Bitmask] + # Create a new FFI::Bitmask + def bitmask(*args) + generic_enum(FFI::Bitmask, *args) end # @param name # @return [FFI::Enum] # Find an enum by name. def enum_type(name) - @ffi_enums && @ffi_enums.find(name) + @ffi_enums.find(name) if defined?(@ffi_enums) end # @param symbol @@ -480,7 +569,7 @@ def enum_value(symbol) # @return [Type] # Find a type definition. def find_type(t) - if t.kind_of?(FFI::Type) + if t.kind_of?(Type) t elsif defined?(@ffi_typedefs) && @ffi_typedefs.has_key?(t) diff --git a/lib/ruby/stdlib/ffi/managedstruct.rb b/lib/ruby/stdlib/ffi/managedstruct.rb index 7643c8731be..0536280a9d5 100644 --- a/lib/ruby/stdlib/ffi/managedstruct.rb +++ b/lib/ruby/stdlib/ffi/managedstruct.rb @@ -1,5 +1,8 @@ +# Copyright (C) 2008 Mike Dalessio # -# Copyright (C) 2008 Mike Dalessio +# This file is part of ruby-ffi. +# +# All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -9,7 +12,7 @@ # * Redistributions in binary form must reproduce the above copyright notice # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# * Neither the name of the Evan Phoenix nor the names of its contributors +# * Neither the name of the Ruby FFI project nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # @@ -23,58 +26,58 @@ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# + module FFI # - # FFI::ManagedStruct allows custom garbage-collection of your FFI::Structs. + # FFI::ManagedStruct allows custom garbage-collection of your FFI::Structs. # - # The typical use case would be when interacting with a library - # that has a nontrivial memory management design, such as a linked - # list or a binary tree. + # The typical use case would be when interacting with a library + # that has a nontrivial memory management design, such as a linked + # list or a binary tree. # - # When the Struct instance is garbage collected, FFI::ManagedStruct will - # invoke the class's release() method during object finalization. + # When the {Struct} instance is garbage collected, FFI::ManagedStruct will + # invoke the class's release() method during object finalization. # - # Example usage: - # module MyLibrary - # ffi_lib "libmylibrary" - # attach_function :new_dlist, [], :pointer - # attach_function :destroy_dlist, [:pointer], :void + # @example Example usage: + # module MyLibrary + # ffi_lib "libmylibrary" + # attach_function :new_dlist, [], :pointer + # attach_function :destroy_dlist, [:pointer], :void + # end + # + # class DoublyLinkedList < FFI::ManagedStruct + # @@@ + # struct do |s| + # s.name 'struct dlist' + # s.include 'dlist.h' + # s.field :head, :pointer + # s.field :tail, :pointer # end + # @@@ # - # class DoublyLinkedList < FFI::ManagedStruct - # @@@ - # struct do |s| - # s.name 'struct dlist' - # s.include 'dlist.h' - # s.field :head, :pointer - # s.field :tail, :pointer - # end - # @@@ - # - # def self.release ptr - # MyLibrary.destroy_dlist(ptr) - # end + # def self.release ptr + # MyLibrary.destroy_dlist(ptr) # end + # end # - # begin - # ptr = DoublyLinkedList.new(MyLibrary.new_dlist) - # # do something with the list - # end - # # struct is out of scope, and will be GC'd using DoublyLinkedList#release + # begin + # ptr = DoublyLinkedList.new(MyLibrary.new_dlist) + # # do something with the list + # end + # # struct is out of scope, and will be GC'd using DoublyLinkedList#release # # class ManagedStruct < FFI::Struct - # call-seq: - # ManagedStruct.new(pointer) - # ManagedStruct.new - # - # When passed a pointer, create a new ManagedStruct which will invoke the class method release() on + # @overload initialize(pointer) + # @param [Pointer] pointer + # Create a new ManagedStruct which will invoke the class method #release on + # @overload initialize + # A new instance of FFI::ManagedStruct. def initialize(pointer=nil) - raise NoMethodError, "release() not implemented for class #{self.class}" unless self.class.respond_to? :release + raise NoMethodError, "release() not implemented for class #{self}" unless self.class.respond_to? :release raise ArgumentError, "Must supply a pointer to memory for the Struct" unless pointer - super FFI::AutoPointer.new(pointer, self.class.method(:release)) + super AutoPointer.new(pointer, self.class.method(:release)) end end diff --git a/lib/ruby/stdlib/ffi/memorypointer.rb b/lib/ruby/stdlib/ffi/memorypointer.rb index 32c97a54ad4..9f07bc69595 100644 --- a/lib/ruby/stdlib/ffi/memorypointer.rb +++ b/lib/ruby/stdlib/ffi/memorypointer.rb @@ -1 +1 @@ -# Now implemented in java +# This class is now implemented in C diff --git a/lib/ruby/stdlib/ffi/platform.rb b/lib/ruby/stdlib/ffi/platform.rb index fa04f65d264..3e0fc6059f5 100644 --- a/lib/ruby/stdlib/ffi/platform.rb +++ b/lib/ruby/stdlib/ffi/platform.rb @@ -1,12 +1,175 @@ -# Load built-in ffi-internal library -JRuby::Util.load_ext("org.jruby.ext.ffi.FFIService") +# +# Copyright (C) 2008, 2009 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.# +require 'rbconfig' module FFI + class PlatformError < LoadError; end + + # This module defines different constants and class methods to play with + # various platforms. module Platform - # - # Most of the constants are now defined in org.jruby.ext.ffi.Platform.java - # - FFI_DIR = File.dirname(__FILE__) - CONF_DIR = File.join(FFI_DIR, "platform", NAME) + OS = case RbConfig::CONFIG['host_os'].downcase + when /linux/ + "linux" + when /darwin/ + "darwin" + when /freebsd/ + "freebsd" + when /netbsd/ + "netbsd" + when /openbsd/ + "openbsd" + when /dragonfly/ + "dragonflybsd" + when /sunos|solaris/ + "solaris" + when /mingw|mswin/ + "windows" + else + RbConfig::CONFIG['host_os'].downcase + end + + OSVERSION = RbConfig::CONFIG['host_os'].gsub(/[^\d]/, '').to_i + + CPU = RbConfig::CONFIG['host_cpu'] + + ARCH = case CPU.downcase + when /amd64|x86_64/ + "x86_64" + when /i?86|x86|i86pc/ + "i386" + when /ppc64|powerpc64/ + "powerpc64" + when /ppc|powerpc/ + "powerpc" + when /sparcv9|sparc64/ + "sparcv9" + else + case RbConfig::CONFIG['host_cpu'] + when /^arm/ + "arm" + else + RbConfig::CONFIG['host_cpu'] + end + end + + private + # @param [String) os + # @return [Boolean] + # Test if current OS is +os+. + def self.is_os(os) + OS == os + end + + IS_GNU = defined?(GNU_LIBC) + IS_LINUX = is_os("linux") + IS_MAC = is_os("darwin") + IS_FREEBSD = is_os("freebsd") + IS_NETBSD = is_os("netbsd") + IS_OPENBSD = is_os("openbsd") + IS_DRAGONFLYBSD = is_os("dragonfly") + IS_SOLARIS = is_os("solaris") + IS_WINDOWS = is_os("windows") + IS_BSD = IS_MAC || IS_FREEBSD || IS_NETBSD || IS_OPENBSD || IS_DRAGONFLYBSD + + # Add the version for known ABI breaks + name_version = "12" if IS_FREEBSD && OSVERSION >= 12 # 64-bit inodes + + NAME = "#{ARCH}-#{OS}#{name_version}" + CONF_DIR = File.join(File.dirname(__FILE__), 'platform', NAME) + + public + + LIBPREFIX = case OS + when /windows|msys/ + '' + when /cygwin/ + 'cyg' + else + 'lib' + end + + LIBSUFFIX = case OS + when /darwin/ + 'dylib' + when /linux|bsd|solaris/ + 'so' + when /windows|cygwin|msys/ + 'dll' + else + # Punt and just assume a sane unix (i.e. anything but AIX) + 'so' + end + + LIBC = if IS_WINDOWS + RbConfig::CONFIG['RUBY_SO_NAME'].split('-')[-2] + '.dll' + elsif IS_GNU + GNU_LIBC + elsif OS == 'cygwin' + "cygwin1.dll" + elsif OS == 'msys' + # Not sure how msys 1.0 behaves, tested on MSYS2. + "msys-2.0.dll" + else + "#{LIBPREFIX}c.#{LIBSUFFIX}" + end + + # Test if current OS is a *BSD (include MAC) + # @return [Boolean] + def self.bsd? + IS_BSD + end + + # Test if current OS is Windows + # @return [Boolean] + def self.windows? + IS_WINDOWS + end + + # Test if current OS is Mac OS + # @return [Boolean] + def self.mac? + IS_MAC + end + + # Test if current OS is Solaris (Sun OS) + # @return [Boolean] + def self.solaris? + IS_SOLARIS + end + + # Test if current OS is a unix OS + # @return [Boolean] + def self.unix? + !IS_WINDOWS + end end end + diff --git a/lib/ruby/stdlib/ffi/platform/aarch64-freebsd/types.conf b/lib/ruby/stdlib/ffi/platform/aarch64-freebsd/types.conf index 0874ee55970..8255343fb26 100644 --- a/lib/ruby/stdlib/ffi/platform/aarch64-freebsd/types.conf +++ b/lib/ruby/stdlib/ffi/platform/aarch64-freebsd/types.conf @@ -1,128 +1,128 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__int_least8_t = char -rbx.platform.typedef.__uint_least8_t = uchar -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint -rbx.platform.typedef.__int_least64_t = long_long -rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__int_fast8_t = int -rbx.platform.typedef.__uint_fast8_t = uint -rbx.platform.typedef.__int_fast16_t = int -rbx.platform.typedef.__uint_fast16_t = uint -rbx.platform.typedef.__int_fast32_t = int -rbx.platform.typedef.__uint_fast32_t = uint -rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__uintptr_t = ulong -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__register_t = long_long -rbx.platform.typedef.__vaddr_t = ulong -rbx.platform.typedef.__paddr_t = ulong -rbx.platform.typedef.__vsize_t = ulong -rbx.platform.typedef.__psize_t = ulong rbx.platform.typedef.__clock_t = int rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__ptrdiff_t = long -rbx.platform.typedef.__size_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__time_t = int -rbx.platform.typedef.__timer_t = int -rbx.platform.typedef.__wchar_t = int -rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__rune_t = int -rbx.platform.typedef.__wctrans_t = pointer -rbx.platform.typedef.__wctype_t = pointer rbx.platform.typedef.__cpuid_t = ulong rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int rbx.platform.typedef.__fixpt_t = uint rbx.platform.typedef.__gid_t = uint rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__in_addr_t = uint rbx.platform.typedef.__in_port_t = ushort rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long rbx.platform.typedef.__key_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long_long rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = int rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__timer_t = int rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = int -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.cpuid_t = ulong -rbx.platform.typedef.register_t = long_long -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.vaddr_t = ulong -rbx.platform.typedef.paddr_t = ulong -rbx.platform.typedef.vsize_t = ulong -rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong rbx.platform.typedef.daddr32_t = int rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = int rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.gid_t = uint rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long rbx.platform.typedef.key_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long_long rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.clock_t = int -rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int rbx.platform.typedef.time_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/lib/ruby/stdlib/ffi/platform/aarch64-freebsd12/types.conf b/lib/ruby/stdlib/ffi/platform/aarch64-freebsd12/types.conf index 47fc293c3dd..c2969322650 100644 --- a/lib/ruby/stdlib/ffi/platform/aarch64-freebsd12/types.conf +++ b/lib/ruby/stdlib/ffi/platform/aarch64-freebsd12/types.conf @@ -1,128 +1,128 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__int_least8_t = char -rbx.platform.typedef.__uint_least8_t = uchar -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint -rbx.platform.typedef.__int_least64_t = long_long -rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__int_fast8_t = int -rbx.platform.typedef.__uint_fast8_t = uint -rbx.platform.typedef.__int_fast16_t = int -rbx.platform.typedef.__uint_fast16_t = uint -rbx.platform.typedef.__int_fast32_t = int -rbx.platform.typedef.__uint_fast32_t = uint -rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__uintptr_t = ulong -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__register_t = long_long -rbx.platform.typedef.__vaddr_t = ulong -rbx.platform.typedef.__paddr_t = ulong -rbx.platform.typedef.__vsize_t = ulong -rbx.platform.typedef.__psize_t = ulong rbx.platform.typedef.__clock_t = int rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__ptrdiff_t = long -rbx.platform.typedef.__size_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__time_t = int -rbx.platform.typedef.__timer_t = int -rbx.platform.typedef.__wchar_t = int -rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__rune_t = int -rbx.platform.typedef.__wctrans_t = pointer -rbx.platform.typedef.__wctype_t = pointer rbx.platform.typedef.__cpuid_t = ulong rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = int rbx.platform.typedef.__fixpt_t = uint rbx.platform.typedef.__gid_t = uint rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__in_addr_t = uint rbx.platform.typedef.__in_port_t = ushort rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long rbx.platform.typedef.__key_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = ulong_long +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long_long rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = int rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__timer_t = int rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = int -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.cpuid_t = ulong -rbx.platform.typedef.register_t = long_long -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.vaddr_t = ulong -rbx.platform.typedef.paddr_t = ulong -rbx.platform.typedef.vsize_t = ulong -rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong rbx.platform.typedef.daddr32_t = int rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.gid_t = uint rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long rbx.platform.typedef.key_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = ulong_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long_long rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.clock_t = int -rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int rbx.platform.typedef.time_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/lib/ruby/stdlib/ffi/platform/aarch64-linux/types.conf b/lib/ruby/stdlib/ffi/platform/aarch64-linux/types.conf index 072c4193338..4cd24385bbd 100644 --- a/lib/ruby/stdlib/ffi/platform/aarch64-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/aarch64-linux/types.conf @@ -1,104 +1,104 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = int -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__syscall_slong_t = long rbx.platform.typedef.__syscall_ulong_t = ulong -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = int -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/arm-freebsd/types.conf b/lib/ruby/stdlib/ffi/platform/arm-freebsd/types.conf index 3e7b20dd552..cfbb90f3238 100644 --- a/lib/ruby/stdlib/ffi/platform/arm-freebsd/types.conf +++ b/lib/ruby/stdlib/ffi/platform/arm-freebsd/types.conf @@ -1,152 +1,152 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long + +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = uint rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int rbx.platform.typedef.__cpumask_t = uint +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int rbx.platform.typedef.__critical_t = int -rbx.platform.typedef.__intfptr_t = int -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = uint +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long_long +rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char rbx.platform.typedef.__int_fast16_t = int rbx.platform.typedef.__int_fast32_t = int rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__int_fast8_t = int rbx.platform.typedef.__int_least16_t = short rbx.platform.typedef.__int_least32_t = int rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = int +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ushort +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__pid_t = int rbx.platform.typedef.__ptrdiff_t = int rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = long_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int rbx.platform.typedef.__size_t = uint +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__time_t = int -rbx.platform.typedef.__uintfptr_t = uint -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__uintptr_t = uint -rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar rbx.platform.typedef.__uint_fast16_t = uint rbx.platform.typedef.__uint_fast32_t = uint rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uint_fast8_t = uint rbx.platform.typedef.__uint_least16_t = ushort rbx.platform.typedef.__uint_least32_t = uint rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = uint +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = uint +rbx.platform.typedef.__useconds_t = uint rbx.platform.typedef.__vm_offset_t = uint rbx.platform.typedef.__vm_ooffset_t = long_long rbx.platform.typedef.__vm_paddr_t = uint rbx.platform.typedef.__vm_pindex_t = ulong_long rbx.platform.typedef.__vm_size_t = uint -rbx.platform.typedef.__blksize_t = uint -rbx.platform.typedef.__blkcnt_t = long_long -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__fflags_t = uint -rbx.platform.typedef.__fsblkcnt_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong_long -rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__id_t = long_long -rbx.platform.typedef.__ino_t = uint -rbx.platform.typedef.__key_t = long -rbx.platform.typedef.__lwpid_t = int -rbx.platform.typedef.__mode_t = ushort -rbx.platform.typedef.__accmode_t = int -rbx.platform.typedef.__nl_item = int -rbx.platform.typedef.__nlink_t = ushort -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__rlim_t = long_long -rbx.platform.typedef.__sa_family_t = uchar -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__uid_t = uint -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__cpuwhich_t = int -rbx.platform.typedef.__cpulevel_t = int -rbx.platform.typedef.__cpusetid_t = int -rbx.platform.typedef.__ct_rune_t = int -rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__wchar_t = int rbx.platform.typedef.__wint_t = int rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__dev_t = uint -rbx.platform.typedef.__fixpt_t = uint -rbx.platform.typedef.pthread_key_t = int -rbx.platform.typedef.*) = pointer -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = int -rbx.platform.typedef.uintptr_t = uint -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.c_caddr_t = pointer -rbx.platform.typedef.blksize_t = uint -rbx.platform.typedef.cpuwhich_t = int -rbx.platform.typedef.cpulevel_t = int -rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.accmode_t = int rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = uint +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int rbx.platform.typedef.cpumask_t = uint +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int rbx.platform.typedef.critical_t = int rbx.platform.typedef.daddr_t = long_long rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.fd_mask = ulong rbx.platform.typedef.fflags_t = uint rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.fsblkcnt_t = ulong_long rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long_long rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.id_t = long_long rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = int rbx.platform.typedef.key_t = long rbx.platform.typedef.lwpid_t = int rbx.platform.typedef.mode_t = ushort -rbx.platform.typedef.accmode_t = int rbx.platform.typedef.nlink_t = ushort rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long rbx.platform.typedef.register_t = int rbx.platform.typedef.rlim_t = long_long +rbx.platform.typedef.sa_family_t = uchar rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long rbx.platform.typedef.u_register_t = uint +rbx.platform.typedef.u_short = ushort rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = uint rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort rbx.platform.typedef.vm_offset_t = uint rbx.platform.typedef.vm_ooffset_t = long_long rbx.platform.typedef.vm_paddr_t = uint rbx.platform.typedef.vm_pindex_t = ulong_long rbx.platform.typedef.vm_size_t = uint -rbx.platform.typedef.__fd_mask = ulong -rbx.platform.typedef.fd_mask = ulong -rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint - diff --git a/lib/ruby/stdlib/ffi/platform/arm-freebsd12/types.conf b/lib/ruby/stdlib/ffi/platform/arm-freebsd12/types.conf index 9607e643c25..523370d99a8 100644 --- a/lib/ruby/stdlib/ffi/platform/arm-freebsd12/types.conf +++ b/lib/ruby/stdlib/ffi/platform/arm-freebsd12/types.conf @@ -1,152 +1,152 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long + +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = uint rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int rbx.platform.typedef.__cpumask_t = uint +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int rbx.platform.typedef.__critical_t = int -rbx.platform.typedef.__intfptr_t = int -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long_long +rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char rbx.platform.typedef.__int_fast16_t = int rbx.platform.typedef.__int_fast32_t = int rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__int_fast8_t = int rbx.platform.typedef.__int_least16_t = short rbx.platform.typedef.__int_least32_t = int rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = int +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ulong_long +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__pid_t = int rbx.platform.typedef.__ptrdiff_t = int rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = long_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int rbx.platform.typedef.__size_t = uint +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__time_t = int -rbx.platform.typedef.__uintfptr_t = uint -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__uintptr_t = uint -rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar rbx.platform.typedef.__uint_fast16_t = uint rbx.platform.typedef.__uint_fast32_t = uint rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uint_fast8_t = uint rbx.platform.typedef.__uint_least16_t = ushort rbx.platform.typedef.__uint_least32_t = uint rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = uint +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = uint +rbx.platform.typedef.__useconds_t = uint rbx.platform.typedef.__vm_offset_t = uint rbx.platform.typedef.__vm_ooffset_t = long_long rbx.platform.typedef.__vm_paddr_t = uint rbx.platform.typedef.__vm_pindex_t = ulong_long rbx.platform.typedef.__vm_size_t = uint -rbx.platform.typedef.__blksize_t = uint -rbx.platform.typedef.__blkcnt_t = long_long -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__fflags_t = uint -rbx.platform.typedef.__fsblkcnt_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong_long -rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__id_t = long_long -rbx.platform.typedef.__ino_t = ulong_long -rbx.platform.typedef.__key_t = long -rbx.platform.typedef.__lwpid_t = int -rbx.platform.typedef.__mode_t = ushort -rbx.platform.typedef.__accmode_t = int -rbx.platform.typedef.__nl_item = int -rbx.platform.typedef.__nlink_t = ulong_long -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__rlim_t = long_long -rbx.platform.typedef.__sa_family_t = uchar -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__uid_t = uint -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__cpuwhich_t = int -rbx.platform.typedef.__cpulevel_t = int -rbx.platform.typedef.__cpusetid_t = int -rbx.platform.typedef.__ct_rune_t = int -rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__wchar_t = int rbx.platform.typedef.__wint_t = int rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__fixpt_t = uint -rbx.platform.typedef.pthread_key_t = int -rbx.platform.typedef.*) = pointer -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = int -rbx.platform.typedef.uintptr_t = uint -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.c_caddr_t = pointer -rbx.platform.typedef.blksize_t = uint -rbx.platform.typedef.cpuwhich_t = int -rbx.platform.typedef.cpulevel_t = int -rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.accmode_t = int rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = uint +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int rbx.platform.typedef.cpumask_t = uint +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int rbx.platform.typedef.critical_t = int rbx.platform.typedef.daddr_t = long_long rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = ulong rbx.platform.typedef.fflags_t = uint rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.fsblkcnt_t = ulong_long rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long_long rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.id_t = long_long rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = int rbx.platform.typedef.key_t = long rbx.platform.typedef.lwpid_t = int rbx.platform.typedef.mode_t = ushort -rbx.platform.typedef.accmode_t = int rbx.platform.typedef.nlink_t = ulong_long rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long rbx.platform.typedef.register_t = int rbx.platform.typedef.rlim_t = long_long +rbx.platform.typedef.sa_family_t = uchar rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long rbx.platform.typedef.u_register_t = uint +rbx.platform.typedef.u_short = ushort rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = uint rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort rbx.platform.typedef.vm_offset_t = uint rbx.platform.typedef.vm_ooffset_t = long_long rbx.platform.typedef.vm_paddr_t = uint rbx.platform.typedef.vm_pindex_t = ulong_long rbx.platform.typedef.vm_size_t = uint -rbx.platform.typedef.__fd_mask = ulong -rbx.platform.typedef.fd_mask = ulong -rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint - diff --git a/lib/ruby/stdlib/ffi/platform/arm-linux/types.conf b/lib/ruby/stdlib/ffi/platform/arm-linux/types.conf index e9a923b5f1e..7a64cc61a4c 100644 --- a/lib/ruby/stdlib/ffi/platform/arm-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/arm-linux/types.conf @@ -1,104 +1,104 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__in_addr_t = uint rbx.platform.typedef.__in_port_t = ushort -rbx.platform.typedef.__ino_t = ulong rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/errno.rb.ffi b/lib/ruby/stdlib/ffi/platform/errno.rb.ffi deleted file mode 100644 index a97e45cd1d7..00000000000 --- a/lib/ruby/stdlib/ffi/platform/errno.rb.ffi +++ /dev/null @@ -1,71 +0,0 @@ -module Platform; end -module Platform::Errno - @@@ - constants do |c| - c.include 'errno.h' - %w[ - EPERM - ENOENT - ESRCH - EINTR - EIO - ENXIO - E2BIG - ENOEXEC - EBADF - ECHILD - EDEADLK - ENOMEM - EACCES - EFAULT - EBUSY - EEXIST - EXDEV - ENODEV - ENOTDIR - EISDIR - EINVAL - ENFILE - EMFILE - ENOTTY - ETXTBSY - EFBIG - ENOSPC - ESPIPE - EROFS - EMLINK - EPIPE - EAGAIN - EWOULDBLOCK - EINPROGRESS - EALREADY - ENOTSOCK - EDESTADDRREQ - EMSGSIZE - EPROTOTYPE - ENOPROTOOPT - EPROTONOSUPPORT - EOPNOTSUPP - EAFNOSUPPORT - EADDRINUSE - EADDRNOTAVAIL - ENETDOWN - ENETUNREACH - ENETRESET - ECONNABORTED - ECONNRESET - ENOBUFS - EISCONN - ENOTCONN - ETIMEDOUT - ECONNREFUSED - ELOOP - ENAMETOOLONG - EHOSTDOWN - EHOSTUNREACH - ENOTEMPTY - ].each { |errno| c.const errno } - end - @@@ -end - diff --git a/lib/ruby/stdlib/ffi/platform/etc.rb.ffi b/lib/ruby/stdlib/ffi/platform/etc.rb.ffi deleted file mode 100644 index ddfde7fed54..00000000000 --- a/lib/ruby/stdlib/ffi/platform/etc.rb.ffi +++ /dev/null @@ -1,31 +0,0 @@ -module Platform; end -module Platform::Etc - class Passwd < FFI::Struct - @@@ - struct do |s| - s.include "sys/types.h" - s.include "pwd.h" - - s.name "struct passwd" - s.field :pw_name, :string - s.field :pw_passwd, :string - s.field :pw_uid, :uint - s.field :pw_gid, :uint - s.field :pw_dir, :string - s.field :pw_shell, :string - end - @@@ - end - class Group < FFI::Struct - @@@ - struct do |s| - s.include "sys/types.h" - s.include "grp.h" - - s.name "struct group" - s.field :gr_name, :string - s.field :gr_gid, :uint - end - @@@ - end -end \ No newline at end of file diff --git a/lib/ruby/stdlib/ffi/platform/fcntl-flock.rb.ffi b/lib/ruby/stdlib/ffi/platform/fcntl-flock.rb.ffi deleted file mode 100644 index f96207d05d1..00000000000 --- a/lib/ruby/stdlib/ffi/platform/fcntl-flock.rb.ffi +++ /dev/null @@ -1,17 +0,0 @@ -module Fcntl - class Flock < FFI::Struct - @@@ - struct do |s| - s.name 'struct flock' - s.include 'fcntl.h' - s.field :l_type, :short - s.field :l_whence, :short - s.field :l_start, :off_t - s.field :l_len, :off_t - s.field :l_sysid, :int - s.field :l_pid, :int - s.field :l_pad, :int - end - @@@ - end -end \ No newline at end of file diff --git a/lib/ruby/stdlib/ffi/platform/fcntl.rb.ffi b/lib/ruby/stdlib/ffi/platform/fcntl.rb.ffi deleted file mode 100644 index 2e67a7c7392..00000000000 --- a/lib/ruby/stdlib/ffi/platform/fcntl.rb.ffi +++ /dev/null @@ -1,32 +0,0 @@ -module Fcntl - @@@ - constants do |c| - c.include 'fcntl.h' - - c.const 'F_DUPFD' - c.const 'F_GETFD' - c.const 'F_GETLK' - c.const 'F_SETFD' - c.const 'F_GETFL' - c.const 'F_SETFL' - c.const 'F_SETLK' - c.const 'F_SETLKW' - c.const 'FD_CLOEXEC' - c.const 'F_RDLCK' - c.const 'F_UNLCK' - c.const 'F_WRLCK' - c.const 'O_CREAT' - c.const 'O_EXCL' - c.const 'O_NOCTTY' - c.const 'O_TRUNC' - c.const 'O_APPEND' - c.const 'O_NONBLOCK' - c.const 'O_NDELAY' - c.const 'O_RDONLY' - c.const 'O_RDWR' - c.const 'O_WRONLY' - c.const 'O_ACCMODE' - end - @@@ -end - diff --git a/lib/ruby/stdlib/ffi/platform/i386-cygwin/types.conf b/lib/ruby/stdlib/ffi/platform/i386-cygwin/types.conf old mode 100755 new mode 100644 index cd3cc381c05..93f6b86122d --- a/lib/ruby/stdlib/ffi/platform/i386-cygwin/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-cygwin/types.conf @@ -1,3 +1,3 @@ -rbx.platform.typedef.size_t = uint rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.size_t = uint rbx.platform.typedef.ssize_t = int diff --git a/lib/ruby/stdlib/ffi/platform/i386-darwin/types.conf b/lib/ruby/stdlib/ffi/platform/i386-darwin/types.conf index 6b9313e5e18..ae100f415bf 100644 --- a/lib/ruby/stdlib/ffi/platform/i386-darwin/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-darwin/types.conf @@ -1,43 +1,7 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__darwin_intptr_t = long -rbx.platform.typedef.__darwin_natural_t = uint -rbx.platform.typedef.__darwin_ct_rune_t = int -rbx.platform.typedef.__darwin_ptrdiff_t = int -rbx.platform.typedef.__darwin_size_t = ulong -rbx.platform.typedef.__darwin_wchar_t = int -rbx.platform.typedef.__darwin_rune_t = int -rbx.platform.typedef.__darwin_wint_t = int -rbx.platform.typedef.__darwin_clock_t = ulong -rbx.platform.typedef.__darwin_socklen_t = uint -rbx.platform.typedef.__darwin_ssize_t = long -rbx.platform.typedef.__darwin_time_t = long -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = int -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.user_addr_t = ulong_long -rbx.platform.typedef.user_size_t = ulong_long -rbx.platform.typedef.user_ssize_t = long_long -rbx.platform.typedef.user_long_t = long_long -rbx.platform.typedef.user_ulong_t = ulong_long -rbx.platform.typedef.user_time_t = long_long -rbx.platform.typedef.syscall_arg_t = ulong_long rbx.platform.typedef.__darwin_blkcnt_t = long_long rbx.platform.typedef.__darwin_blksize_t = int +rbx.platform.typedef.__darwin_clock_t = ulong +rbx.platform.typedef.__darwin_ct_rune_t = int rbx.platform.typedef.__darwin_dev_t = int rbx.platform.typedef.__darwin_fsblkcnt_t = uint rbx.platform.typedef.__darwin_fsfilcnt_t = uint @@ -45,56 +9,92 @@ rbx.platform.typedef.__darwin_gid_t = uint rbx.platform.typedef.__darwin_id_t = uint rbx.platform.typedef.__darwin_ino64_t = ulong_long rbx.platform.typedef.__darwin_ino_t = ulong_long +rbx.platform.typedef.__darwin_intptr_t = long rbx.platform.typedef.__darwin_mach_port_name_t = uint rbx.platform.typedef.__darwin_mach_port_t = uint rbx.platform.typedef.__darwin_mode_t = ushort +rbx.platform.typedef.__darwin_natural_t = uint rbx.platform.typedef.__darwin_off_t = long_long rbx.platform.typedef.__darwin_pid_t = int rbx.platform.typedef.__darwin_pthread_key_t = ulong +rbx.platform.typedef.__darwin_ptrdiff_t = int +rbx.platform.typedef.__darwin_rune_t = int rbx.platform.typedef.__darwin_sigset_t = uint +rbx.platform.typedef.__darwin_size_t = ulong +rbx.platform.typedef.__darwin_socklen_t = uint +rbx.platform.typedef.__darwin_ssize_t = long rbx.platform.typedef.__darwin_suseconds_t = int +rbx.platform.typedef.__darwin_time_t = long rbx.platform.typedef.__darwin_uid_t = uint rbx.platform.typedef.__darwin_useconds_t = uint rbx.platform.typedef.__darwin_uuid_t[16] = uchar -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.__darwin_wchar_t = int +rbx.platform.typedef.__darwin_wint_t = int +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fd_mask = int rbx.platform.typedef.fixpt_t = uint -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.fsblkcnt_t = uint +rbx.platform.typedef.fsfilcnt_t = uint rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.ino_t = ulong_long rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long rbx.platform.typedef.key_t = int rbx.platform.typedef.mode_t = ushort rbx.platform.typedef.nlink_t = ushort -rbx.platform.typedef.id_t = uint -rbx.platform.typedef.pid_t = int rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.syscall_arg_t = ulong_long rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uintptr_t = ulong rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.fd_mask = int -rbx.platform.typedef.pthread_key_t = ulong -rbx.platform.typedef.fsblkcnt_t = uint -rbx.platform.typedef.fsfilcnt_t = uint -rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.user_addr_t = ulong_long +rbx.platform.typedef.user_long_t = long_long +rbx.platform.typedef.user_size_t = ulong_long +rbx.platform.typedef.user_ssize_t = long_long +rbx.platform.typedef.user_time_t = long_long +rbx.platform.typedef.user_ulong_t = ulong_long +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/i386-freebsd/types.conf b/lib/ruby/stdlib/ffi/platform/i386-freebsd/types.conf index 2b07db4cc85..6c882d48c88 100644 --- a/lib/ruby/stdlib/ffi/platform/i386-freebsd/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-freebsd/types.conf @@ -1,152 +1,152 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long + +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = uint rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int rbx.platform.typedef.__cpumask_t = uint +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int rbx.platform.typedef.__critical_t = int -rbx.platform.typedef.__intfptr_t = int -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = uint +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long_long +rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char rbx.platform.typedef.__int_fast16_t = int rbx.platform.typedef.__int_fast32_t = int rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__int_fast8_t = int rbx.platform.typedef.__int_least16_t = short rbx.platform.typedef.__int_least32_t = int rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = int +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ushort +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__pid_t = int rbx.platform.typedef.__ptrdiff_t = int rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = long_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int rbx.platform.typedef.__size_t = uint +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__uintfptr_t = uint -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__uintptr_t = uint -rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar rbx.platform.typedef.__uint_fast16_t = uint rbx.platform.typedef.__uint_fast32_t = uint rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uint_fast8_t = uint rbx.platform.typedef.__uint_least16_t = ushort rbx.platform.typedef.__uint_least32_t = uint rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = uint +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = uint +rbx.platform.typedef.__useconds_t = uint rbx.platform.typedef.__vm_offset_t = uint rbx.platform.typedef.__vm_ooffset_t = long_long rbx.platform.typedef.__vm_paddr_t = uint rbx.platform.typedef.__vm_pindex_t = ulong_long rbx.platform.typedef.__vm_size_t = uint -rbx.platform.typedef.__blksize_t = uint -rbx.platform.typedef.__blkcnt_t = long_long -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__fflags_t = uint -rbx.platform.typedef.__fsblkcnt_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong_long -rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__id_t = long_long -rbx.platform.typedef.__ino_t = uint -rbx.platform.typedef.__key_t = long -rbx.platform.typedef.__lwpid_t = int -rbx.platform.typedef.__mode_t = ushort -rbx.platform.typedef.__accmode_t = int -rbx.platform.typedef.__nl_item = int -rbx.platform.typedef.__nlink_t = ushort -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__rlim_t = long_long -rbx.platform.typedef.__sa_family_t = uchar -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__uid_t = uint -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__cpuwhich_t = int -rbx.platform.typedef.__cpulevel_t = int -rbx.platform.typedef.__cpusetid_t = int -rbx.platform.typedef.__ct_rune_t = int -rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__wchar_t = int rbx.platform.typedef.__wint_t = int rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__dev_t = uint -rbx.platform.typedef.__fixpt_t = uint -rbx.platform.typedef.pthread_key_t = int -rbx.platform.typedef.*) = pointer -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = int -rbx.platform.typedef.uintptr_t = uint -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.c_caddr_t = pointer -rbx.platform.typedef.blksize_t = uint -rbx.platform.typedef.cpuwhich_t = int -rbx.platform.typedef.cpulevel_t = int -rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.accmode_t = int rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = uint +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int rbx.platform.typedef.cpumask_t = uint +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int rbx.platform.typedef.critical_t = int rbx.platform.typedef.daddr_t = long_long rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.fd_mask = ulong rbx.platform.typedef.fflags_t = uint rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.fsblkcnt_t = ulong_long rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long_long rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.id_t = long_long rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = int rbx.platform.typedef.key_t = long rbx.platform.typedef.lwpid_t = int rbx.platform.typedef.mode_t = ushort -rbx.platform.typedef.accmode_t = int rbx.platform.typedef.nlink_t = ushort rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long rbx.platform.typedef.register_t = int rbx.platform.typedef.rlim_t = long_long +rbx.platform.typedef.sa_family_t = uchar rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long rbx.platform.typedef.u_register_t = uint +rbx.platform.typedef.u_short = ushort rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = uint rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort rbx.platform.typedef.vm_offset_t = uint rbx.platform.typedef.vm_ooffset_t = long_long rbx.platform.typedef.vm_paddr_t = uint rbx.platform.typedef.vm_pindex_t = ulong_long rbx.platform.typedef.vm_size_t = uint -rbx.platform.typedef.__fd_mask = ulong -rbx.platform.typedef.fd_mask = ulong -rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint - diff --git a/lib/ruby/stdlib/ffi/platform/i386-freebsd12/types.conf b/lib/ruby/stdlib/ffi/platform/i386-freebsd12/types.conf index 9607e643c25..523370d99a8 100644 --- a/lib/ruby/stdlib/ffi/platform/i386-freebsd12/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-freebsd12/types.conf @@ -1,152 +1,152 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long + +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long_long +rbx.platform.typedef.__blksize_t = uint rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int rbx.platform.typedef.__cpumask_t = uint +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int rbx.platform.typedef.__critical_t = int -rbx.platform.typedef.__intfptr_t = int -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = ulong_long +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong_long +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long_long +rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char rbx.platform.typedef.__int_fast16_t = int rbx.platform.typedef.__int_fast32_t = int rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__int_fast8_t = int rbx.platform.typedef.__int_least16_t = short rbx.platform.typedef.__int_least32_t = int rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = int +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ulong_long +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__pid_t = int rbx.platform.typedef.__ptrdiff_t = int rbx.platform.typedef.__register_t = int +rbx.platform.typedef.__rlim_t = long_long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int rbx.platform.typedef.__size_t = uint +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = int +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__time_t = int -rbx.platform.typedef.__uintfptr_t = uint -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__uintptr_t = uint -rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar rbx.platform.typedef.__uint_fast16_t = uint rbx.platform.typedef.__uint_fast32_t = uint rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uint_fast8_t = uint rbx.platform.typedef.__uint_least16_t = ushort rbx.platform.typedef.__uint_least32_t = uint rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__u_register_t = uint +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = uint +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = uint +rbx.platform.typedef.__useconds_t = uint rbx.platform.typedef.__vm_offset_t = uint rbx.platform.typedef.__vm_ooffset_t = long_long rbx.platform.typedef.__vm_paddr_t = uint rbx.platform.typedef.__vm_pindex_t = ulong_long rbx.platform.typedef.__vm_size_t = uint -rbx.platform.typedef.__blksize_t = uint -rbx.platform.typedef.__blkcnt_t = long_long -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__fflags_t = uint -rbx.platform.typedef.__fsblkcnt_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong_long -rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__id_t = long_long -rbx.platform.typedef.__ino_t = ulong_long -rbx.platform.typedef.__key_t = long -rbx.platform.typedef.__lwpid_t = int -rbx.platform.typedef.__mode_t = ushort -rbx.platform.typedef.__accmode_t = int -rbx.platform.typedef.__nl_item = int -rbx.platform.typedef.__nlink_t = ulong_long -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__rlim_t = long_long -rbx.platform.typedef.__sa_family_t = uchar -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__uid_t = uint -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__cpuwhich_t = int -rbx.platform.typedef.__cpulevel_t = int -rbx.platform.typedef.__cpusetid_t = int -rbx.platform.typedef.__ct_rune_t = int -rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__wchar_t = int rbx.platform.typedef.__wint_t = int rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__fixpt_t = uint -rbx.platform.typedef.pthread_key_t = int -rbx.platform.typedef.*) = pointer -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = int -rbx.platform.typedef.uintptr_t = uint -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.c_caddr_t = pointer -rbx.platform.typedef.blksize_t = uint -rbx.platform.typedef.cpuwhich_t = int -rbx.platform.typedef.cpulevel_t = int -rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.accmode_t = int rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = uint +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int rbx.platform.typedef.cpumask_t = uint +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int rbx.platform.typedef.critical_t = int rbx.platform.typedef.daddr_t = long_long rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = ulong rbx.platform.typedef.fflags_t = uint rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.fsblkcnt_t = ulong_long rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long_long rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.id_t = long_long rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = int rbx.platform.typedef.key_t = long rbx.platform.typedef.lwpid_t = int rbx.platform.typedef.mode_t = ushort -rbx.platform.typedef.accmode_t = int rbx.platform.typedef.nlink_t = ulong_long rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long rbx.platform.typedef.register_t = int rbx.platform.typedef.rlim_t = long_long +rbx.platform.typedef.sa_family_t = uchar rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long rbx.platform.typedef.u_register_t = uint +rbx.platform.typedef.u_short = ushort rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = uint rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort rbx.platform.typedef.vm_offset_t = uint rbx.platform.typedef.vm_ooffset_t = long_long rbx.platform.typedef.vm_paddr_t = uint rbx.platform.typedef.vm_pindex_t = ulong_long rbx.platform.typedef.vm_size_t = uint -rbx.platform.typedef.__fd_mask = ulong -rbx.platform.typedef.fd_mask = ulong -rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint - diff --git a/lib/ruby/stdlib/ffi/platform/i386-gnu/types.conf b/lib/ruby/stdlib/ffi/platform/i386-gnu/types.conf index f9169c29a77..fa2fa8cef64 100644 --- a/lib/ruby/stdlib/ffi/platform/i386-gnu/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-gnu/types.conf @@ -1,107 +1,107 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = uint -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsid_t = ulong_long rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__fsid_t = ulong_long -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__pthread_key = int +rbx.platform.typedef.__pthread_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__sigset_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = int -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.fsid_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.fsid_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.pthread_t = int +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.sigset_t = ulong +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.__sigset_t = ulong -rbx.platform.typedef.sigset_t = ulong -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.__pthread_t = int -rbx.platform.typedef.pthread_t = int -rbx.platform.typedef.__pthread_key = int -rbx.platform.typedef.pthread_key_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/i386-linux/types.conf b/lib/ruby/stdlib/ffi/platform/i386-linux/types.conf index c46a1342eb3..feb6bc47081 100644 --- a/lib/ruby/stdlib/ffi/platform/i386-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-linux/types.conf @@ -1,103 +1,103 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/i386-netbsd/types.conf b/lib/ruby/stdlib/ffi/platform/i386-netbsd/types.conf index 33bd12b9046..a5aba894389 100644 --- a/lib/ruby/stdlib/ffi/platform/i386-netbsd/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-netbsd/types.conf @@ -1,126 +1,126 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__int_least8_t = char -rbx.platform.typedef.__uint_least8_t = uchar -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint -rbx.platform.typedef.__int_least64_t = long_long -rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__int_fast8_t = int -rbx.platform.typedef.__uint_fast8_t = uint -rbx.platform.typedef.__int_fast16_t = int -rbx.platform.typedef.__uint_fast16_t = uint -rbx.platform.typedef.__int_fast32_t = int -rbx.platform.typedef.__uint_fast32_t = uint -rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__uintptr_t = ulong -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__register_t = int -rbx.platform.typedef.__vaddr_t = ulong -rbx.platform.typedef.__paddr_t = ulong -rbx.platform.typedef.__vsize_t = ulong -rbx.platform.typedef.__psize_t = ulong rbx.platform.typedef.__clock_t = int rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__ptrdiff_t = long -rbx.platform.typedef.__size_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__time_t = int -rbx.platform.typedef.__timer_t = int -rbx.platform.typedef.__wchar_t = int -rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__rune_t = int -rbx.platform.typedef.__wctrans_t = pointer -rbx.platform.typedef.__wctype_t = pointer rbx.platform.typedef.__cpuid_t = ulong rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int rbx.platform.typedef.__fixpt_t = uint rbx.platform.typedef.__gid_t = uint rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__in_addr_t = uint rbx.platform.typedef.__in_port_t = ushort rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long rbx.platform.typedef.__key_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = int rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = int rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__timer_t = int rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = int -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.cpuid_t = ulong -rbx.platform.typedef.register_t = int -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.vaddr_t = ulong -rbx.platform.typedef.paddr_t = ulong -rbx.platform.typedef.vsize_t = ulong -rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong rbx.platform.typedef.daddr32_t = int rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = int rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.gid_t = uint rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char rbx.platform.typedef.key_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.clock_t = int -rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int rbx.platform.typedef.time_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/lib/ruby/stdlib/ffi/platform/i386-openbsd/types.conf b/lib/ruby/stdlib/ffi/platform/i386-openbsd/types.conf index c4df68adbee..15a0d61380f 100644 --- a/lib/ruby/stdlib/ffi/platform/i386-openbsd/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-openbsd/types.conf @@ -1,128 +1,128 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__int_least8_t = char -rbx.platform.typedef.__uint_least8_t = uchar -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint -rbx.platform.typedef.__int_least64_t = long_long -rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__int_fast8_t = int -rbx.platform.typedef.__uint_fast8_t = uint -rbx.platform.typedef.__int_fast16_t = int -rbx.platform.typedef.__uint_fast16_t = uint -rbx.platform.typedef.__int_fast32_t = int -rbx.platform.typedef.__uint_fast32_t = uint -rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__uintptr_t = ulong -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__register_t = int -rbx.platform.typedef.__vaddr_t = ulong -rbx.platform.typedef.__paddr_t = ulong -rbx.platform.typedef.__vsize_t = ulong -rbx.platform.typedef.__psize_t = ulong rbx.platform.typedef.__clock_t = int rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__ptrdiff_t = long -rbx.platform.typedef.__size_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__time_t = int -rbx.platform.typedef.__timer_t = int -rbx.platform.typedef.__wchar_t = int -rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__rune_t = int -rbx.platform.typedef.__wctrans_t = pointer -rbx.platform.typedef.__wctype_t = pointer rbx.platform.typedef.__cpuid_t = ulong rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int rbx.platform.typedef.__fixpt_t = uint rbx.platform.typedef.__gid_t = uint rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__in_addr_t = uint rbx.platform.typedef.__in_port_t = ushort rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long rbx.platform.typedef.__key_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = int rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = int rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__timer_t = int rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = int -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.cpuid_t = ulong -rbx.platform.typedef.register_t = int -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.vaddr_t = ulong -rbx.platform.typedef.paddr_t = ulong -rbx.platform.typedef.vsize_t = ulong -rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong rbx.platform.typedef.daddr32_t = int rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = int rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.gid_t = uint rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long rbx.platform.typedef.key_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.clock_t = int -rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int rbx.platform.typedef.time_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/lib/ruby/stdlib/ffi/platform/i386-solaris/types.conf b/lib/ruby/stdlib/ffi/platform/i386-solaris/types.conf index a5851000ea8..22a2414e97e 100644 --- a/lib/ruby/stdlib/ffi/platform/i386-solaris/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-solaris/types.conf @@ -1,122 +1,122 @@ -rbx.platform.typedef.lock_t = uchar -rbx.platform.typedef.int8_t = char +rbx.platform.typedef.*caddr_t = char +rbx.platform.typedef.blkcnt64_t = long_long +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.cpu_flag_t = ushort +rbx.platform.typedef.ctid_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.datalink_id_t = uint +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.disp_lock_t = uchar +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fds_mask = long +rbx.platform.typedef.fsblkcnt64_t = ulong_long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt64_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.hrtime_t = long_long +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.index_t = short +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long rbx.platform.typedef.int16_t = short rbx.platform.typedef.int32_t = int rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intmax_t = long_long -rbx.platform.typedef.uintmax_t = ulong_long -rbx.platform.typedef.intptr_t = int -rbx.platform.typedef.uintptr_t = uint -rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int8_t = char rbx.platform.typedef.int_fast16_t = int rbx.platform.typedef.int_fast32_t = int rbx.platform.typedef.int_fast64_t = long_long -rbx.platform.typedef.uint_fast8_t = uchar -rbx.platform.typedef.uint_fast16_t = uint -rbx.platform.typedef.uint_fast32_t = uint -rbx.platform.typedef.uint_fast64_t = ulong_long -rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.int_fast8_t = char rbx.platform.typedef.int_least16_t = short rbx.platform.typedef.int_least32_t = int rbx.platform.typedef.int_least64_t = long_long -rbx.platform.typedef.uint_least8_t = uchar -rbx.platform.typedef.uint_least16_t = ushort -rbx.platform.typedef.uint_least32_t = uint -rbx.platform.typedef.uint_least64_t = ulong_long -rbx.platform.typedef.longlong_t = long_long -rbx.platform.typedef.u_longlong_t = ulong_long -rbx.platform.typedef.t_scalar_t = long -rbx.platform.typedef.t_uscalar_t = ulong -rbx.platform.typedef.uchar_t = uchar -rbx.platform.typedef.ushort_t = ushort -rbx.platform.typedef.uint_t = uint -rbx.platform.typedef.ulong_t = ulong -rbx.platform.typedef.*caddr_t = char -rbx.platform.typedef.daddr_t = long -rbx.platform.typedef.cnt_t = short -rbx.platform.typedef.ptrdiff_t = int -rbx.platform.typedef.pfn_t = ulong -rbx.platform.typedef.pgcnt_t = ulong -rbx.platform.typedef.spgcnt_t = long -rbx.platform.typedef.use_t = uchar -rbx.platform.typedef.sysid_t = short -rbx.platform.typedef.index_t = short -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.off64_t = long_long -rbx.platform.typedef.ino_t = ulong_long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.ino64_t = ulong_long -rbx.platform.typedef.blkcnt64_t = long_long -rbx.platform.typedef.fsblkcnt64_t = ulong_long -rbx.platform.typedef.fsfilcnt64_t = ulong_long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.pad64_t = long_long -rbx.platform.typedef.upad64_t = ulong_long -rbx.platform.typedef.offset_t = long_long -rbx.platform.typedef.u_offset_t = ulong_long -rbx.platform.typedef.len_t = ulong_long -rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.ipaddr_t = uint rbx.platform.typedef.k_fltset_t = uint -rbx.platform.typedef.id_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.len_t = ulong_long rbx.platform.typedef.lgrp_id_t = long -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.lock_t = uchar +rbx.platform.typedef.longlong_t = long_long rbx.platform.typedef.major_t = ulong rbx.platform.typedef.minor_t = ulong -rbx.platform.typedef.pri_t = short -rbx.platform.typedef.cpu_flag_t = ushort -rbx.platform.typedef.o_mode_t = ushort +rbx.platform.typedef.mode_t = ulong +rbx.platform.typedef.model_t = uint +rbx.platform.typedef.nfds_t = ulong +rbx.platform.typedef.nlink_t = ulong rbx.platform.typedef.o_dev_t = short -rbx.platform.typedef.o_uid_t = ushort rbx.platform.typedef.o_gid_t = ushort +rbx.platform.typedef.o_ino_t = ushort +rbx.platform.typedef.o_mode_t = ushort rbx.platform.typedef.o_nlink_t = short rbx.platform.typedef.o_pid_t = short -rbx.platform.typedef.o_ino_t = ushort -rbx.platform.typedef.key_t = int -rbx.platform.typedef.mode_t = ulong -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.gid_t = uint -rbx.platform.typedef.datalink_id_t = uint -rbx.platform.typedef.taskid_t = long -rbx.platform.typedef.projid_t = long +rbx.platform.typedef.o_uid_t = ushort +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.pad64_t = long_long +rbx.platform.typedef.pfn_t = ulong +rbx.platform.typedef.pgcnt_t = ulong +rbx.platform.typedef.pid_t = long rbx.platform.typedef.poolid_t = long -rbx.platform.typedef.zoneid_t = long -rbx.platform.typedef.ctid_t = long -rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.pri_t = short +rbx.platform.typedef.projid_t = long rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.dev_t = ulong -rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.pid_t = long +rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.spgcnt_t = long rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.sysid_t = short +rbx.platform.typedef.t_scalar_t = long +rbx.platform.typedef.t_uscalar_t = ulong +rbx.platform.typedef.taskid_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clock_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.hrtime_t = long_long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.fds_mask = long -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.nfds_t = ulong -rbx.platform.typedef.disp_lock_t = uchar -rbx.platform.typedef.model_t = uint -rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.ipaddr_t = uint -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_offset_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar_t = uchar +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.upad64_t = ulong_long +rbx.platform.typedef.use_t = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.zoneid_t = long diff --git a/lib/ruby/stdlib/ffi/platform/i386-windows/types.conf b/lib/ruby/stdlib/ffi/platform/i386-windows/types.conf index 38168bee4dd..35acdb739a7 100644 --- a/lib/ruby/stdlib/ffi/platform/i386-windows/types.conf +++ b/lib/ruby/stdlib/ffi/platform/i386-windows/types.conf @@ -1,105 +1,105 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.*addr_t = char +rbx.platform.typedef.__ULong = ulong +rbx.platform.typedef.__blkcnt32_t = long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__dev16_t = short +rbx.platform.typedef.__dev32_t = ulong +rbx.platform.typedef.__gid16_t = ushort +rbx.platform.typedef.__gid32_t = ulong +rbx.platform.typedef.__ino32_t = ulong +rbx.platform.typedef.__ino64_t = ulong_long rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__uid16_t = ushort +rbx.platform.typedef.__uid32_t = ulong +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef._off_t = long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef._fpos64_t = long_long +rbx.platform.typedef._fpos_t = long rbx.platform.typedef._off64_t = long_long +rbx.platform.typedef._off_t = long rbx.platform.typedef._ssize_t = int -rbx.platform.typedef.wint_t = uint -rbx.platform.typedef.ptrdiff_t = int -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.__off_t = long -rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.caddr_t = string rbx.platform.typedef.clock_t = ulong -rbx.platform.typedef.time_t = long +rbx.platform.typedef.clockid_t = ulong rbx.platform.typedef.daddr_t = long -rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.pid_t = int -rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.dev_t = ulong rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.clockid_t = ulong -rbx.platform.typedef.timer_t = ulong -rbx.platform.typedef.useconds_t = ulong -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.int8_t = char +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = ulong +rbx.platform.typedef.id_t = ulong +rbx.platform.typedef.ino_t = ulong_long rbx.platform.typedef.int16_t = short rbx.platform.typedef.int32_t = long rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = ulong -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.int_least8_t = char -rbx.platform.typedef.int_least16_t = short -rbx.platform.typedef.int_least32_t = long -rbx.platform.typedef.int_least64_t = long_long -rbx.platform.typedef.uint_least8_t = uchar -rbx.platform.typedef.uint_least16_t = ushort -rbx.platform.typedef.uint_least32_t = ulong -rbx.platform.typedef.uint_least64_t = ulong_long -rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int8_t = char rbx.platform.typedef.int_fast16_t = long rbx.platform.typedef.int_fast32_t = long rbx.platform.typedef.int_fast64_t = long_long -rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = long +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long_long +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.sig_atomic_t = int +rbx.platform.typedef.sigset_t = ulong +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = int +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = ulong +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = ulong +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = ulong +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar rbx.platform.typedef.uint_fast16_t = ulong rbx.platform.typedef.uint_fast32_t = ulong rbx.platform.typedef.uint_fast64_t = ulong_long -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = ulong +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar rbx.platform.typedef.uintmax_t = ulong_long -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.__dev16_t = short -rbx.platform.typedef.__dev32_t = ulong -rbx.platform.typedef.dev_t = ulong -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.__blkcnt32_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.__uid16_t = ushort -rbx.platform.typedef.__uid32_t = ulong -rbx.platform.typedef.uid_t = ulong -rbx.platform.typedef.__gid16_t = ushort -rbx.platform.typedef.__gid32_t = ulong -rbx.platform.typedef.gid_t = ulong -rbx.platform.typedef.__ino32_t = ulong -rbx.platform.typedef.__ino64_t = ulong_long -rbx.platform.typedef.ino_t = ulong_long -rbx.platform.typedef.id_t = ulong -rbx.platform.typedef.key_t = long_long +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.useconds_t = ulong +rbx.platform.typedef.ushort = ushort rbx.platform.typedef.vm_offset_t = ulong rbx.platform.typedef.vm_size_t = ulong -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = int -rbx.platform.typedef.*addr_t = char -rbx.platform.typedef.socklen_t = int -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.__ULong = ulong -rbx.platform.typedef._fpos_t = long -rbx.platform.typedef._fpos64_t = long_long -rbx.platform.typedef.sigset_t = ulong -rbx.platform.typedef.sig_atomic_t = int -rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.wint_t = uint diff --git a/lib/ruby/stdlib/ffi/platform/ia64-linux/types.conf b/lib/ruby/stdlib/ffi/platform/ia64-linux/types.conf index 70e44e8c6c9..e0eeecc9461 100644 --- a/lib/ruby/stdlib/ffi/platform/ia64-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/ia64-linux/types.conf @@ -1,104 +1,104 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__in_addr_t = uint rbx.platform.typedef.__in_port_t = ushort -rbx.platform.typedef.__ino_t = ulong rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = ulong -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/mips-linux/types.conf b/lib/ruby/stdlib/ffi/platform/mips-linux/types.conf index ad4ced04a50..24e82024023 100644 --- a/lib/ruby/stdlib/ffi/platform/mips-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/mips-linux/types.conf @@ -1,102 +1,102 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/mips64-linux/types.conf b/lib/ruby/stdlib/ffi/platform/mips64-linux/types.conf index 3feb704f728..b61f4f70dd1 100644 --- a/lib/ruby/stdlib/ffi/platform/mips64-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/mips64-linux/types.conf @@ -1,104 +1,104 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = ulong -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__syscall_slong_t = long rbx.platform.typedef.__syscall_ulong_t = ulong -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/mips64el-linux/types.conf b/lib/ruby/stdlib/ffi/platform/mips64el-linux/types.conf index 3feb704f728..b61f4f70dd1 100644 --- a/lib/ruby/stdlib/ffi/platform/mips64el-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/mips64el-linux/types.conf @@ -1,104 +1,104 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = ulong -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__syscall_slong_t = long rbx.platform.typedef.__syscall_ulong_t = ulong -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/mipsel-linux/types.conf b/lib/ruby/stdlib/ffi/platform/mipsel-linux/types.conf index ad4ced04a50..24e82024023 100644 --- a/lib/ruby/stdlib/ffi/platform/mipsel-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/mipsel-linux/types.conf @@ -1,102 +1,102 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/mipsisa32r6-linux/types.conf b/lib/ruby/stdlib/ffi/platform/mipsisa32r6-linux/types.conf index ad4ced04a50..24e82024023 100644 --- a/lib/ruby/stdlib/ffi/platform/mipsisa32r6-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/mipsisa32r6-linux/types.conf @@ -1,102 +1,102 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/mipsisa32r6el-linux/types.conf b/lib/ruby/stdlib/ffi/platform/mipsisa32r6el-linux/types.conf index ad4ced04a50..24e82024023 100644 --- a/lib/ruby/stdlib/ffi/platform/mipsisa32r6el-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/mipsisa32r6el-linux/types.conf @@ -1,102 +1,102 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/mipsisa64r6-linux/types.conf b/lib/ruby/stdlib/ffi/platform/mipsisa64r6-linux/types.conf index 3feb704f728..b61f4f70dd1 100644 --- a/lib/ruby/stdlib/ffi/platform/mipsisa64r6-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/mipsisa64r6-linux/types.conf @@ -1,104 +1,104 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = ulong -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__syscall_slong_t = long rbx.platform.typedef.__syscall_ulong_t = ulong -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/mipsisa64r6el-linux/types.conf b/lib/ruby/stdlib/ffi/platform/mipsisa64r6el-linux/types.conf index 3feb704f728..b61f4f70dd1 100644 --- a/lib/ruby/stdlib/ffi/platform/mipsisa64r6el-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/mipsisa64r6el-linux/types.conf @@ -1,104 +1,104 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = ulong -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__syscall_slong_t = long rbx.platform.typedef.__syscall_ulong_t = ulong -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/powerpc-aix/types.conf b/lib/ruby/stdlib/ffi/platform/powerpc-aix/types.conf index 30ee66b252a..cbd20e78cf8 100644 --- a/lib/ruby/stdlib/ffi/platform/powerpc-aix/types.conf +++ b/lib/ruby/stdlib/ffi/platform/powerpc-aix/types.conf @@ -1,180 +1,180 @@ -rbx.platform.typedef.int8_t = char +rbx.platform.typedef.UTF32Char = uint +rbx.platform.typedef.UniChar = ushort +rbx.platform.typedef.__cptr32 = string +rbx.platform.typedef.__cptr64 = ulong_long +rbx.platform.typedef.__long32_t = long +rbx.platform.typedef.__long64_t = int +rbx.platform.typedef.__ptr32 = pointer +rbx.platform.typedef.__ptr64 = ulong_long +rbx.platform.typedef.__ulong32_t = ulong +rbx.platform.typedef.__ulong64_t = uint +rbx.platform.typedef.aptx_t = ushort +rbx.platform.typedef.blkcnt32_t = int +rbx.platform.typedef.blkcnt64_t = ulong_long +rbx.platform.typedef.blkcnt_t = int +rbx.platform.typedef.blksize32_t = int +rbx.platform.typedef.blksize64_t = ulong_long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.boolean_t = int +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.chan_t = int +rbx.platform.typedef.class_id_t = uint +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = long_long +rbx.platform.typedef.cnt64_t = long_long +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.crid_t = int +rbx.platform.typedef.daddr32_t = int +rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev32_t = uint +rbx.platform.typedef.dev64_t = ulong_long +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.esid_t = uint +rbx.platform.typedef.ext_t = int +rbx.platform.typedef.fpos64_t = long_long +rbx.platform.typedef.fpos_t = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino32_t = uint +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16 = short rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32 = int rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int32long64_t = int +rbx.platform.typedef.int64 = long_long rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intmax_t = long_long -rbx.platform.typedef.uintmax_t = ulong_long -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.int_least8_t = char -rbx.platform.typedef.int_least16_t = short -rbx.platform.typedef.int_least32_t = int -rbx.platform.typedef.int_least64_t = long_long -rbx.platform.typedef.uint_least8_t = uchar -rbx.platform.typedef.uint_least16_t = ushort -rbx.platform.typedef.uint_least32_t = uint -rbx.platform.typedef.uint_least64_t = ulong_long -rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int8 = char +rbx.platform.typedef.int8_t = char rbx.platform.typedef.int_fast16_t = short rbx.platform.typedef.int_fast32_t = int -rbx.platform.typedef.uint_fast8_t = uchar -rbx.platform.typedef.uint_fast16_t = ushort -rbx.platform.typedef.uint_fast32_t = uint rbx.platform.typedef.int_fast64_t = long_long -rbx.platform.typedef.uint_fast64_t = ulong_long -rbx.platform.typedef.wchar_t = ushort +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char rbx.platform.typedef.intfast_t = int -rbx.platform.typedef.uintfast_t = uint -rbx.platform.typedef.__long32_t = long -rbx.platform.typedef.__ulong32_t = ulong -rbx.platform.typedef.__long64_t = int -rbx.platform.typedef.__ulong64_t = uint -rbx.platform.typedef.int32long64_t = int -rbx.platform.typedef.uint32long64_t = uint +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.krpn_t = int +rbx.platform.typedef.kvmhandle_t = ulong +rbx.platform.typedef.kvmid_t = long +rbx.platform.typedef.kvpn_t = int +rbx.platform.typedef.level_t = int +rbx.platform.typedef.liobn_t = uint rbx.platform.typedef.long32int64_t = long -rbx.platform.typedef.ulong32int64_t = ulong -rbx.platform.typedef.int8 = char -rbx.platform.typedef.int16 = short -rbx.platform.typedef.int32 = int -rbx.platform.typedef.int64 = long_long -rbx.platform.typedef.u_int8 = uchar -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16 = ushort -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32 = uint -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64 = ulong_long -rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.longlong_t = long_long +rbx.platform.typedef.mid_t = pointer +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.mtyp_t = long +rbx.platform.typedef.nlink_t = short +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.paddr_t = long +rbx.platform.typedef.pdtx_t = int +rbx.platform.typedef.pid32_t = int +rbx.platform.typedef.pid64_t = ulong_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pshift_t = ushort +rbx.platform.typedef.psize_t = long_long +rbx.platform.typedef.psx_t = short +rbx.platform.typedef.ptex_t = ulong +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_t = uint rbx.platform.typedef.ptrdiff_t = long -rbx.platform.typedef.wctype_t = uint -rbx.platform.typedef.fpos_t = long -rbx.platform.typedef.fpos64_t = long_long -rbx.platform.typedef.time_t = int -rbx.platform.typedef.clock_t = int +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.rpn64_t = long_long +rbx.platform.typedef.rpn_t = int +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.signal_t = int +rbx.platform.typedef.size64_t = ulong_long rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.uchar_t = uchar -rbx.platform.typedef.ushort_t = ushort -rbx.platform.typedef.uint_t = uint -rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.slab_t[12] = char +rbx.platform.typedef.snidx_t = int +rbx.platform.typedef.socklen_t = ulong +rbx.platform.typedef.soff_t = int +rbx.platform.typedef.sshift_t = ushort +rbx.platform.typedef.ssize64_t = long_long rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.level_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.daddr32_t = int -rbx.platform.typedef.daddr64_t = long_long -rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.ino_t = uint -rbx.platform.typedef.ino32_t = uint -rbx.platform.typedef.ino64_t = ulong_long -rbx.platform.typedef.cnt_t = short -rbx.platform.typedef.dev_t = uint -rbx.platform.typedef.dev32_t = uint -rbx.platform.typedef.dev64_t = ulong_long -rbx.platform.typedef.chan_t = int -rbx.platform.typedef.time32_t = int -rbx.platform.typedef.pid32_t = int +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.swhatx_t = ulong rbx.platform.typedef.tid32_t = int -rbx.platform.typedef.pid64_t = ulong_long rbx.platform.typedef.tid64_t = ulong_long +rbx.platform.typedef.tid_t = int +rbx.platform.typedef.time32_t = int rbx.platform.typedef.time64_t = long_long -rbx.platform.typedef.__ptr32 = pointer -rbx.platform.typedef.__cptr32 = string -rbx.platform.typedef.soff_t = int -rbx.platform.typedef.off_t = long -rbx.platform.typedef.off64_t = long_long -rbx.platform.typedef.paddr_t = long -rbx.platform.typedef.key_t = int -rbx.platform.typedef.timer_t = int +rbx.platform.typedef.time_t = int rbx.platform.typedef.timer32_t = int rbx.platform.typedef.timer64_t = long_long -rbx.platform.typedef.nlink_t = short -rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16 = ushort +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32 = uint +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64 = ulong_long +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8 = uchar +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar = uchar +rbx.platform.typedef.uchar_t = uchar rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.gid_t = uint -rbx.platform.typedef.mid_t = pointer -rbx.platform.typedef.pid_t = int -rbx.platform.typedef.tid_t = int -rbx.platform.typedef.slab_t[12] = char -rbx.platform.typedef.mtyp_t = long -rbx.platform.typedef.boolean_t = int -rbx.platform.typedef.crid_t = int -rbx.platform.typedef.blkcnt_t = int -rbx.platform.typedef.blksize_t = int -rbx.platform.typedef.blkcnt32_t = int -rbx.platform.typedef.blksize32_t = int -rbx.platform.typedef.blkcnt64_t = ulong_long -rbx.platform.typedef.blksize64_t = ulong_long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.wint_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint32long64_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = ushort +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintfast_t = uint +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong32int64_t = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unidx_t = int +rbx.platform.typedef.unit_addr_t = ulong_long +rbx.platform.typedef.ureg_t = ulong rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.clockid_t = long_long -rbx.platform.typedef.signal_t = int -rbx.platform.typedef.pthread_t = uint -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.vmid_t = long +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.va_list = string +rbx.platform.typedef.vmfkey_t = uint +rbx.platform.typedef.vmhandle32_t = uint rbx.platform.typedef.vmhandle_t = ulong +rbx.platform.typedef.vmhwkey_t = int rbx.platform.typedef.vmid32_t = int -rbx.platform.typedef.vmhandle32_t = uint -rbx.platform.typedef.kvmid_t = long -rbx.platform.typedef.kvmhandle_t = ulong rbx.platform.typedef.vmid64_t = long_long -rbx.platform.typedef.rpn64_t = long_long -rbx.platform.typedef.cnt64_t = long_long -rbx.platform.typedef.psize_t = long_long +rbx.platform.typedef.vmid_t = long rbx.platform.typedef.vmidx_t = int -rbx.platform.typedef.vmfkey_t = uint -rbx.platform.typedef.vmprkey_t = uint rbx.platform.typedef.vmkey_t = int -rbx.platform.typedef.vmhwkey_t = int -rbx.platform.typedef.vpn_t = int -rbx.platform.typedef.rpn_t = int -rbx.platform.typedef.ptex_t = ulong -rbx.platform.typedef.swhatx_t = ulong -rbx.platform.typedef.esid_t = uint -rbx.platform.typedef.aptx_t = ushort -rbx.platform.typedef.pdtx_t = int -rbx.platform.typedef.psx_t = short -rbx.platform.typedef.pshift_t = ushort -rbx.platform.typedef.sshift_t = ushort -rbx.platform.typedef.unidx_t = int -rbx.platform.typedef.snidx_t = int +rbx.platform.typedef.vmlpghandle_t = ulong +rbx.platform.typedef.vmm_lock_t = int rbx.platform.typedef.vmnodeidx_t = int -rbx.platform.typedef.kvpn_t = int -rbx.platform.typedef.krpn_t = int +rbx.platform.typedef.vmprkey_t = uint rbx.platform.typedef.vmsize_t = int -rbx.platform.typedef.vmm_lock_t = int -rbx.platform.typedef.ureg_t = ulong -rbx.platform.typedef.vmlpghandle_t = ulong -rbx.platform.typedef.ext_t = int -rbx.platform.typedef.va_list = string -rbx.platform.typedef.__ptr64 = ulong_long -rbx.platform.typedef.__cptr64 = ulong_long -rbx.platform.typedef.UniChar = ushort -rbx.platform.typedef.UTF32Char = uint -rbx.platform.typedef.uchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.offset_t = long_long -rbx.platform.typedef.ssize64_t = long_long -rbx.platform.typedef.longlong_t = long_long -rbx.platform.typedef.u_longlong_t = ulong_long -rbx.platform.typedef.class_id_t = uint -rbx.platform.typedef.liobn_t = uint -rbx.platform.typedef.unit_addr_t = ulong_long -rbx.platform.typedef.size64_t = ulong_long -rbx.platform.typedef.socklen_t = ulong -rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.vpn_t = int +rbx.platform.typedef.wchar_t = ushort +rbx.platform.typedef.wctype_t = uint +rbx.platform.typedef.wint_t = int diff --git a/lib/ruby/stdlib/ffi/platform/powerpc-darwin/types.conf b/lib/ruby/stdlib/ffi/platform/powerpc-darwin/types.conf index 6b9313e5e18..ae100f415bf 100644 --- a/lib/ruby/stdlib/ffi/platform/powerpc-darwin/types.conf +++ b/lib/ruby/stdlib/ffi/platform/powerpc-darwin/types.conf @@ -1,43 +1,7 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__darwin_intptr_t = long -rbx.platform.typedef.__darwin_natural_t = uint -rbx.platform.typedef.__darwin_ct_rune_t = int -rbx.platform.typedef.__darwin_ptrdiff_t = int -rbx.platform.typedef.__darwin_size_t = ulong -rbx.platform.typedef.__darwin_wchar_t = int -rbx.platform.typedef.__darwin_rune_t = int -rbx.platform.typedef.__darwin_wint_t = int -rbx.platform.typedef.__darwin_clock_t = ulong -rbx.platform.typedef.__darwin_socklen_t = uint -rbx.platform.typedef.__darwin_ssize_t = long -rbx.platform.typedef.__darwin_time_t = long -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = int -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.user_addr_t = ulong_long -rbx.platform.typedef.user_size_t = ulong_long -rbx.platform.typedef.user_ssize_t = long_long -rbx.platform.typedef.user_long_t = long_long -rbx.platform.typedef.user_ulong_t = ulong_long -rbx.platform.typedef.user_time_t = long_long -rbx.platform.typedef.syscall_arg_t = ulong_long rbx.platform.typedef.__darwin_blkcnt_t = long_long rbx.platform.typedef.__darwin_blksize_t = int +rbx.platform.typedef.__darwin_clock_t = ulong +rbx.platform.typedef.__darwin_ct_rune_t = int rbx.platform.typedef.__darwin_dev_t = int rbx.platform.typedef.__darwin_fsblkcnt_t = uint rbx.platform.typedef.__darwin_fsfilcnt_t = uint @@ -45,56 +9,92 @@ rbx.platform.typedef.__darwin_gid_t = uint rbx.platform.typedef.__darwin_id_t = uint rbx.platform.typedef.__darwin_ino64_t = ulong_long rbx.platform.typedef.__darwin_ino_t = ulong_long +rbx.platform.typedef.__darwin_intptr_t = long rbx.platform.typedef.__darwin_mach_port_name_t = uint rbx.platform.typedef.__darwin_mach_port_t = uint rbx.platform.typedef.__darwin_mode_t = ushort +rbx.platform.typedef.__darwin_natural_t = uint rbx.platform.typedef.__darwin_off_t = long_long rbx.platform.typedef.__darwin_pid_t = int rbx.platform.typedef.__darwin_pthread_key_t = ulong +rbx.platform.typedef.__darwin_ptrdiff_t = int +rbx.platform.typedef.__darwin_rune_t = int rbx.platform.typedef.__darwin_sigset_t = uint +rbx.platform.typedef.__darwin_size_t = ulong +rbx.platform.typedef.__darwin_socklen_t = uint +rbx.platform.typedef.__darwin_ssize_t = long rbx.platform.typedef.__darwin_suseconds_t = int +rbx.platform.typedef.__darwin_time_t = long rbx.platform.typedef.__darwin_uid_t = uint rbx.platform.typedef.__darwin_useconds_t = uint rbx.platform.typedef.__darwin_uuid_t[16] = uchar -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.__darwin_wchar_t = int +rbx.platform.typedef.__darwin_wint_t = int +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = int +rbx.platform.typedef.fd_mask = int rbx.platform.typedef.fixpt_t = uint -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.fsblkcnt_t = uint +rbx.platform.typedef.fsfilcnt_t = uint rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.ino_t = ulong_long rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long rbx.platform.typedef.key_t = int rbx.platform.typedef.mode_t = ushort rbx.platform.typedef.nlink_t = ushort -rbx.platform.typedef.id_t = uint -rbx.platform.typedef.pid_t = int rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.syscall_arg_t = ulong_long rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uintptr_t = ulong rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.fd_mask = int -rbx.platform.typedef.pthread_key_t = ulong -rbx.platform.typedef.fsblkcnt_t = uint -rbx.platform.typedef.fsfilcnt_t = uint -rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.user_addr_t = ulong_long +rbx.platform.typedef.user_long_t = long_long +rbx.platform.typedef.user_size_t = ulong_long +rbx.platform.typedef.user_ssize_t = long_long +rbx.platform.typedef.user_time_t = long_long +rbx.platform.typedef.user_ulong_t = ulong_long +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/powerpc-linux/types.conf b/lib/ruby/stdlib/ffi/platform/powerpc-linux/types.conf index 76014cd2542..29519196469 100644 --- a/lib/ruby/stdlib/ffi/platform/powerpc-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/powerpc-linux/types.conf @@ -1,100 +1,100 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/powerpc64-linux/types.conf b/lib/ruby/stdlib/ffi/platform/powerpc64-linux/types.conf index 3feb704f728..b61f4f70dd1 100644 --- a/lib/ruby/stdlib/ffi/platform/powerpc64-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/powerpc64-linux/types.conf @@ -1,104 +1,104 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = ulong -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__fsword_t = long +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__syscall_slong_t = long rbx.platform.typedef.__syscall_ulong_t = ulong -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/s390-linux/types.conf b/lib/ruby/stdlib/ffi/platform/s390-linux/types.conf index 1cc79ee804a..291b0326b76 100644 --- a/lib/ruby/stdlib/ffi/platform/s390-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/s390-linux/types.conf @@ -1,102 +1,102 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/s390x-linux/types.conf b/lib/ruby/stdlib/ffi/platform/s390x-linux/types.conf index f4c8cec617b..32a7feba647 100644 --- a/lib/ruby/stdlib/ffi/platform/s390x-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/s390x-linux/types.conf @@ -1,102 +1,102 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = ulong -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/socket.rb.ffi b/lib/ruby/stdlib/ffi/platform/socket.rb.ffi deleted file mode 100644 index dacfc406191..00000000000 --- a/lib/ruby/stdlib/ffi/platform/socket.rb.ffi +++ /dev/null @@ -1,197 +0,0 @@ -module Platform; end -module Platform::Socket - @@@ - constants do |cg| - cg.include "sys/types.h" - cg.include "sys/socket.h" - cg.include "netinet/in.h" - cg.include "netinet/icmp6.h" - cg.include "netdb.h" - - %w[ - SO_DEBUG - SO_ACCEPTCONN - SO_REUSEADDR - SO_KEEPALIVE - SO_DONTROUTE - SO_BROADCAST - SO_USELOOPBACK - SO_LINGER - SO_OOBINLINE - SO_REUSEPORT - SO_TIMESTAMP - SO_ACCEPTFILTER - SO_DONTTRUNC - SO_WANTMORE - SO_WANTOOBFLAG - SO_SNDBUF - SO_RCVBUF - SO_SNDLOWAT - SO_RCVLOWAT - SO_SNDTIMEO - SO_RCVTIMEO - SO_ERROR - SO_TYPE - SO_NREAD - SO_NKE - SO_NOSIGPIPE - SO_NOADDRERR - SO_NWRITE - SO_REUSESHAREUID - SO_LABEL - SO_PEERLABEL - SO_ATTACH_FILTER - SO_BINDTODEVICE - SO_DETACH_FILTER - SO_NO_CHECK - SO_PASSCRED - SO_PEERCRED - SO_PEERNAME - SO_PRIORITY - SO_SECURITY_AUTHENTICATION - SO_SECURITY_ENCRYPTION_NETWORK - SO_SECURITY_ENCRYPTION_TRANSPORT - ].each {|c| cg.const(c, "%#x", "(unsigned int)") { |v| v.hex} } - %w[ - SOCK_STREAM - SOCK_DGRAM - SOCK_RAW - SOCK_RDM - SOCK_SEQPACKET - SOCK_MAXADDRLEN - ].each {|c| cg.const c } - %w[ - AF_UNSPEC - AF_LOCAL - AF_UNIX - AF_INET - AF_IMPLINK - AF_PUP - AF_CHAOS - AF_NS - AF_ISO - AF_OSI - AF_ECMA - AF_DATAKIT - AF_CCITT - AF_SNA - AF_DECnet - AF_DLI - AF_LAT - AF_HYLINK - AF_APPLETALK - AF_ROUTE - AF_LINK - pseudo_AF_XTP - AF_COIP - AF_CNT - pseudo_AF_RTIP - AF_IPX - AF_SIP - pseudo_AF_PIP - AF_NDRV - AF_ISDN - AF_E164 - pseudo_AF_KEY - AF_INET6 - AF_NATM - AF_SYSTEM - AF_NETBIOS - AF_PPP - AF_ATM - pseudo_AF_HDRCMPLT - AF_NETGRAPH - AF_AX25 - AF_MAX - ].each {|c| cg.const c } - %w[ - PF_UNSPEC - PF_LOCAL - PF_UNIX - PF_INET - PF_IMPLINK - PF_PUP - PF_CHAOS - PF_NS - PF_ISO - PF_OSI - PF_ECMA - PF_DATAKIT - PF_CCITT - PF_SNA - PF_DECnet - PF_DLI - PF_LAT - PF_HYLINK - PF_APPLETALK - PF_ROUTE - PF_LINK - PF_XTP - PF_COIP - PF_CNT - PF_SIP - PF_IPX - PF_RTIP - PF_PIP - PF_NDRV - PF_ISDN - PF_KEY - PF_INET6 - PF_NATM - PF_SYSTEM - PF_NETBIOS - PF_PPP - PF_ATM - PF_NETGRAPH - PF_MAX - ].each {|c| cg.const c} - %w[ - NI_MAXHOST - NI_MAXSERV - NI_NOFQDN - NI_NUMERICHOST - NI_NAMEREQD - NI_NUMERICSERV - NI_DGRAM - NI_WITHSCOPEID - NI_QTYPE_NOOP - NI_QTYPE_SUPTYPES - NI_QTYPE_FQDN - NI_QTYPE_DNSNAME - NI_QTYPE_NODEADDR - NI_QTYPE_IPV4ADDR - NI_SUPTYPE_FLAG_COMPRESS - NI_FQDN_FLAG_VALIDTTL - NI_SUPTYPE_FLAG_COMPRESS - NI_FQDN_FLAG_VALIDTTL - NI_NODEADDR_FLAG_LINKLOCAL - NI_NODEADDR_FLAG_SITELOCAL - NI_NODEADDR_FLAG_GLOBAL - NI_NODEADDR_FLAG_ALL - NI_NODEADDR_FLAG_TRUNCATE - NI_NODEADDR_FLAG_ANYCAST - NI_NODEADDR_FLAG_LINKLOCAL - NI_NODEADDR_FLAG_SITELOCAL - NI_NODEADDR_FLAG_GLOBAL - NI_NODEADDR_FLAG_ALL - NI_NODEADDR_FLAG_TRUNCATE - NI_NODEADDR_FLAG_ANYCAST - NI_NODEADDR_FLAG_TRUNCATE - NI_NODEADDR_FLAG_ALL - NI_NODEADDR_FLAG_COMPAT - NI_NODEADDR_FLAG_LINKLOCAL - NI_NODEADDR_FLAG_SITELOCAL - NI_NODEADDR_FLAG_GLOBAL - NI_NODEADDR_FLAG_ANYCAST - NI_NODEADDR_FLAG_TRUNCATE - NI_NODEADDR_FLAG_ALL - NI_NODEADDR_FLAG_COMPAT - NI_NODEADDR_FLAG_LINKLOCAL - NI_NODEADDR_FLAG_SITELOCAL - NI_NODEADDR_FLAG_GLOBAL - NI_NODEADDR_FLAG_ANYCAST - ].each {|c| cg.const c} - end - @@@ -end - diff --git a/lib/ruby/stdlib/ffi/platform/sparc-linux/types.conf b/lib/ruby/stdlib/ffi/platform/sparc-linux/types.conf index 1882298eaf3..aea09d32cdf 100644 --- a/lib/ruby/stdlib/ffi/platform/sparc-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/sparc-linux/types.conf @@ -1,102 +1,102 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__quad_t = long_long -rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long_long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong_long +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong_long +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong_long +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = int +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long_long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long_long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long_long rbx.platform.typedef.__rlim64_t = ulong_long -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = int rbx.platform.typedef.__suseconds_t = int -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong_long -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong_long -rbx.platform.typedef.__ssize_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.*__qaddr_t = long_long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = int -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong_long +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long_long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long_long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = uint +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = int rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/sparc-solaris/types.conf b/lib/ruby/stdlib/ffi/platform/sparc-solaris/types.conf index c03c1446ed3..a1548e56ea5 100644 --- a/lib/ruby/stdlib/ffi/platform/sparc-solaris/types.conf +++ b/lib/ruby/stdlib/ffi/platform/sparc-solaris/types.conf @@ -1,128 +1,128 @@ -rbx.platform.typedef.lock_t = uchar -rbx.platform.typedef.int8_t = char +rbx.platform.typedef.() = pointer +rbx.platform.typedef.*caddr_t = char +rbx.platform.typedef.Psocklen_t = pointer +rbx.platform.typedef.avl_index_t = uint +rbx.platform.typedef.blkcnt64_t = long_long +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.cpu_flag_t = ushort +rbx.platform.typedef.ctid_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.disp_lock_t = uchar +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fds_mask = long +rbx.platform.typedef.fsblkcnt64_t = ulong_long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt64_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = long +rbx.platform.typedef.hrtime_t = long_long +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.index_t = short +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int) = pointer +rbx.platform.typedef.int) = pointer rbx.platform.typedef.int16_t = short rbx.platform.typedef.int32_t = int rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intmax_t = long_long -rbx.platform.typedef.uintmax_t = ulong_long -rbx.platform.typedef.intptr_t = int -rbx.platform.typedef.uintptr_t = uint -rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int8_t = char rbx.platform.typedef.int_fast16_t = int rbx.platform.typedef.int_fast32_t = int rbx.platform.typedef.int_fast64_t = long_long -rbx.platform.typedef.uint_fast8_t = uchar -rbx.platform.typedef.uint_fast16_t = uint -rbx.platform.typedef.uint_fast32_t = uint -rbx.platform.typedef.uint_fast64_t = ulong_long -rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.int_fast8_t = char rbx.platform.typedef.int_least16_t = short rbx.platform.typedef.int_least32_t = int rbx.platform.typedef.int_least64_t = long_long -rbx.platform.typedef.uint_least8_t = uchar -rbx.platform.typedef.uint_least16_t = ushort -rbx.platform.typedef.uint_least32_t = uint -rbx.platform.typedef.uint_least64_t = ulong_long -rbx.platform.typedef.longlong_t = long_long -rbx.platform.typedef.u_longlong_t = ulong_long -rbx.platform.typedef.t_scalar_t = long -rbx.platform.typedef.t_uscalar_t = ulong -rbx.platform.typedef.uchar_t = uchar -rbx.platform.typedef.ushort_t = ushort -rbx.platform.typedef.uint_t = uint -rbx.platform.typedef.ulong_t = ulong -rbx.platform.typedef.*caddr_t = char -rbx.platform.typedef.daddr_t = long -rbx.platform.typedef.cnt_t = short -rbx.platform.typedef.ptrdiff_t = int -rbx.platform.typedef.pfn_t = ulong -rbx.platform.typedef.pgcnt_t = ulong -rbx.platform.typedef.spgcnt_t = long -rbx.platform.typedef.use_t = uchar -rbx.platform.typedef.sysid_t = short -rbx.platform.typedef.index_t = short -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.off64_t = long_long -rbx.platform.typedef.ino_t = ulong_long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.ino64_t = ulong_long -rbx.platform.typedef.blkcnt64_t = long_long -rbx.platform.typedef.fsblkcnt64_t = ulong_long -rbx.platform.typedef.fsfilcnt64_t = ulong_long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.pad64_t = long_long -rbx.platform.typedef.upad64_t = ulong_long -rbx.platform.typedef.offset_t = long_long -rbx.platform.typedef.u_offset_t = ulong_long -rbx.platform.typedef.len_t = ulong_long -rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.ipaddr_t = uint rbx.platform.typedef.k_fltset_t = uint -rbx.platform.typedef.id_t = long -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.kid_t = int +rbx.platform.typedef.len_t = ulong_long +rbx.platform.typedef.lock_t = uchar +rbx.platform.typedef.longlong_t = long_long rbx.platform.typedef.major_t = ulong rbx.platform.typedef.minor_t = ulong -rbx.platform.typedef.pri_t = short -rbx.platform.typedef.cpu_flag_t = ushort -rbx.platform.typedef.o_mode_t = ushort +rbx.platform.typedef.mode_t = ulong +rbx.platform.typedef.model_t = uint +rbx.platform.typedef.nfds_t = ulong +rbx.platform.typedef.nlink_t = ulong rbx.platform.typedef.o_dev_t = short -rbx.platform.typedef.o_uid_t = ushort rbx.platform.typedef.o_gid_t = ushort +rbx.platform.typedef.o_ino_t = ushort +rbx.platform.typedef.o_mode_t = ushort rbx.platform.typedef.o_nlink_t = short rbx.platform.typedef.o_pid_t = short -rbx.platform.typedef.o_ino_t = ushort -rbx.platform.typedef.key_t = int -rbx.platform.typedef.mode_t = ulong -rbx.platform.typedef.uid_t = long -rbx.platform.typedef.gid_t = long -rbx.platform.typedef.taskid_t = long -rbx.platform.typedef.projid_t = long +rbx.platform.typedef.o_uid_t = ushort +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.pad64_t = long_long +rbx.platform.typedef.pfn_t = ulong +rbx.platform.typedef.pgcnt_t = ulong +rbx.platform.typedef.pid_t = long rbx.platform.typedef.poolid_t = long -rbx.platform.typedef.zoneid_t = long -rbx.platform.typedef.ctid_t = long -rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.pri_t = short +rbx.platform.typedef.projid_t = long rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.dev_t = ulong -rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.pid_t = long +rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort rbx.platform.typedef.size_t = uint +rbx.platform.typedef.size_t) = pointer +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.spgcnt_t = long rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.sysid_t = short +rbx.platform.typedef.t_scalar_t = long +rbx.platform.typedef.t_uscalar_t = ulong +rbx.platform.typedef.taskid_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clock_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ts_t = long_long rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.hrtime_t = long_long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.fds_mask = long -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.Psocklen_t = pointer -rbx.platform.typedef.disp_lock_t = uchar -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.rlim64_t = ulong_long -rbx.platform.typedef.kid_t = int -rbx.platform.typedef.int) = pointer -rbx.platform.typedef.size_t) = pointer -rbx.platform.typedef.int) = pointer -rbx.platform.typedef.avl_index_t = uint -rbx.platform.typedef.() = pointer -rbx.platform.typedef.nfds_t = ulong -rbx.platform.typedef.model_t = uint -rbx.platform.typedef.ts_t = long_long -rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.ipaddr_t = uint +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_offset_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar_t = uchar +rbx.platform.typedef.uid_t = long +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.upad64_t = ulong_long +rbx.platform.typedef.use_t = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.zoneid_t = long diff --git a/lib/ruby/stdlib/ffi/platform/sparc64-linux/types.conf b/lib/ruby/stdlib/ffi/platform/sparc64-linux/types.conf index d86ba2f1828..7626bfce849 100644 --- a/lib/ruby/stdlib/ffi/platform/sparc64-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/sparc64-linux/types.conf @@ -1,102 +1,102 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.*__qaddr_t = long +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long rbx.platform.typedef.__suseconds_t = int -rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer -rbx.platform.typedef.__blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int -rbx.platform.typedef.clock_t = long +rbx.platform.typedef.suseconds_t = int rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/sparcv9-solaris/types.conf b/lib/ruby/stdlib/ffi/platform/sparcv9-solaris/types.conf index c03c1446ed3..a1548e56ea5 100644 --- a/lib/ruby/stdlib/ffi/platform/sparcv9-solaris/types.conf +++ b/lib/ruby/stdlib/ffi/platform/sparcv9-solaris/types.conf @@ -1,128 +1,128 @@ -rbx.platform.typedef.lock_t = uchar -rbx.platform.typedef.int8_t = char +rbx.platform.typedef.() = pointer +rbx.platform.typedef.*caddr_t = char +rbx.platform.typedef.Psocklen_t = pointer +rbx.platform.typedef.avl_index_t = uint +rbx.platform.typedef.blkcnt64_t = long_long +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.cpu_flag_t = ushort +rbx.platform.typedef.ctid_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.disp_lock_t = uchar +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fds_mask = long +rbx.platform.typedef.fsblkcnt64_t = ulong_long +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt64_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long +rbx.platform.typedef.gid_t = long +rbx.platform.typedef.hrtime_t = long_long +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.index_t = short +rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int) = pointer +rbx.platform.typedef.int) = pointer rbx.platform.typedef.int16_t = short rbx.platform.typedef.int32_t = int rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intmax_t = long_long -rbx.platform.typedef.uintmax_t = ulong_long -rbx.platform.typedef.intptr_t = int -rbx.platform.typedef.uintptr_t = uint -rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int8_t = char rbx.platform.typedef.int_fast16_t = int rbx.platform.typedef.int_fast32_t = int rbx.platform.typedef.int_fast64_t = long_long -rbx.platform.typedef.uint_fast8_t = uchar -rbx.platform.typedef.uint_fast16_t = uint -rbx.platform.typedef.uint_fast32_t = uint -rbx.platform.typedef.uint_fast64_t = ulong_long -rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.int_fast8_t = char rbx.platform.typedef.int_least16_t = short rbx.platform.typedef.int_least32_t = int rbx.platform.typedef.int_least64_t = long_long -rbx.platform.typedef.uint_least8_t = uchar -rbx.platform.typedef.uint_least16_t = ushort -rbx.platform.typedef.uint_least32_t = uint -rbx.platform.typedef.uint_least64_t = ulong_long -rbx.platform.typedef.longlong_t = long_long -rbx.platform.typedef.u_longlong_t = ulong_long -rbx.platform.typedef.t_scalar_t = long -rbx.platform.typedef.t_uscalar_t = ulong -rbx.platform.typedef.uchar_t = uchar -rbx.platform.typedef.ushort_t = ushort -rbx.platform.typedef.uint_t = uint -rbx.platform.typedef.ulong_t = ulong -rbx.platform.typedef.*caddr_t = char -rbx.platform.typedef.daddr_t = long -rbx.platform.typedef.cnt_t = short -rbx.platform.typedef.ptrdiff_t = int -rbx.platform.typedef.pfn_t = ulong -rbx.platform.typedef.pgcnt_t = ulong -rbx.platform.typedef.spgcnt_t = long -rbx.platform.typedef.use_t = uchar -rbx.platform.typedef.sysid_t = short -rbx.platform.typedef.index_t = short -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.off64_t = long_long -rbx.platform.typedef.ino_t = ulong_long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.ino64_t = ulong_long -rbx.platform.typedef.blkcnt64_t = long_long -rbx.platform.typedef.fsblkcnt64_t = ulong_long -rbx.platform.typedef.fsfilcnt64_t = ulong_long -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.pad64_t = long_long -rbx.platform.typedef.upad64_t = ulong_long -rbx.platform.typedef.offset_t = long_long -rbx.platform.typedef.u_offset_t = ulong_long -rbx.platform.typedef.len_t = ulong_long -rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = int +rbx.platform.typedef.ipaddr_t = uint rbx.platform.typedef.k_fltset_t = uint -rbx.platform.typedef.id_t = long -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.key_t = int +rbx.platform.typedef.kid_t = int +rbx.platform.typedef.len_t = ulong_long +rbx.platform.typedef.lock_t = uchar +rbx.platform.typedef.longlong_t = long_long rbx.platform.typedef.major_t = ulong rbx.platform.typedef.minor_t = ulong -rbx.platform.typedef.pri_t = short -rbx.platform.typedef.cpu_flag_t = ushort -rbx.platform.typedef.o_mode_t = ushort +rbx.platform.typedef.mode_t = ulong +rbx.platform.typedef.model_t = uint +rbx.platform.typedef.nfds_t = ulong +rbx.platform.typedef.nlink_t = ulong rbx.platform.typedef.o_dev_t = short -rbx.platform.typedef.o_uid_t = ushort rbx.platform.typedef.o_gid_t = ushort +rbx.platform.typedef.o_ino_t = ushort +rbx.platform.typedef.o_mode_t = ushort rbx.platform.typedef.o_nlink_t = short rbx.platform.typedef.o_pid_t = short -rbx.platform.typedef.o_ino_t = ushort -rbx.platform.typedef.key_t = int -rbx.platform.typedef.mode_t = ulong -rbx.platform.typedef.uid_t = long -rbx.platform.typedef.gid_t = long -rbx.platform.typedef.taskid_t = long -rbx.platform.typedef.projid_t = long +rbx.platform.typedef.o_uid_t = ushort +rbx.platform.typedef.off64_t = long_long +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.pad64_t = long_long +rbx.platform.typedef.pfn_t = ulong +rbx.platform.typedef.pgcnt_t = ulong +rbx.platform.typedef.pid_t = long rbx.platform.typedef.poolid_t = long -rbx.platform.typedef.zoneid_t = long -rbx.platform.typedef.ctid_t = long -rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.pri_t = short +rbx.platform.typedef.projid_t = long rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.dev_t = ulong -rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.pid_t = long +rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.ptrdiff_t = int +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = ushort rbx.platform.typedef.size_t = uint +rbx.platform.typedef.size_t) = pointer +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.spgcnt_t = long rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.sysid_t = short +rbx.platform.typedef.t_scalar_t = long +rbx.platform.typedef.t_uscalar_t = ulong +rbx.platform.typedef.taskid_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clock_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ts_t = long_long rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.hrtime_t = long_long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.fds_mask = long -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.Psocklen_t = pointer -rbx.platform.typedef.disp_lock_t = uchar -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.rlim64_t = ulong_long -rbx.platform.typedef.kid_t = int -rbx.platform.typedef.int) = pointer -rbx.platform.typedef.size_t) = pointer -rbx.platform.typedef.int) = pointer -rbx.platform.typedef.avl_index_t = uint -rbx.platform.typedef.() = pointer -rbx.platform.typedef.nfds_t = ulong -rbx.platform.typedef.model_t = uint -rbx.platform.typedef.ts_t = long_long -rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.ipaddr_t = uint +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_offset_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar_t = uchar +rbx.platform.typedef.uid_t = long +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintmax_t = ulong_long +rbx.platform.typedef.uintptr_t = uint +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.upad64_t = ulong_long +rbx.platform.typedef.use_t = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.zoneid_t = long diff --git a/lib/ruby/stdlib/ffi/platform/stat.rb.ffi b/lib/ruby/stdlib/ffi/platform/stat.rb.ffi deleted file mode 100644 index 84938bf7be6..00000000000 --- a/lib/ruby/stdlib/ffi/platform/stat.rb.ffi +++ /dev/null @@ -1,53 +0,0 @@ -module Platform - module Stat - class Stat < FFI::Struct - @@@ - struct do |s| - s.include "sys/types.h" - s.include "sys/stat.h" - - s.name "struct stat" - s.field :st_dev, :dev_t - s.field :st_ino, :ino_t - s.field :st_nlink, :nlink_t - s.field :st_mode, :mode_t - s.field :st_uid, :uid_t - s.field :st_gid, :gid_t - s.field :st_size, :off_t - s.field :st_blocks, :blkcnt_t - s.field :st_atime, :time_t - s.field :st_mtime, :time_t - s.field :st_ctime, :time_t - end - @@@ - end - module Constants - @@@ - constants do |cg| - cg.include "sys/types.h" - cg.include "sys/stat.h" - %w[ - S_ISUID - S_ISGID - S_IRUSR - S_IWUSR - S_IXUSR - S_IRWXU - S_IREAD - S_IWRITE - S_IEXEC - S_IRGRP - S_IWGRP - S_IXGRP - S_IRWXG - S_IROTH - S_IWOTH - S_IXOTH - S_IRWXO - ].each {|c| cg.const(c, "%#x", "(unsigned int)") } - end - @@@ - end - include Constants - end -end \ No newline at end of file diff --git a/lib/ruby/stdlib/ffi/platform/sysconf.rb.ffi b/lib/ruby/stdlib/ffi/platform/sysconf.rb.ffi deleted file mode 100644 index 24310a58093..00000000000 --- a/lib/ruby/stdlib/ffi/platform/sysconf.rb.ffi +++ /dev/null @@ -1,139 +0,0 @@ -module Platform;end -module Platform::Sysconf - @@@ - constants do |cg| - cg.include "sys/types.h" - cg.include "unistd.h" - %w[ - _SC_ARG_MAX - _SC_CHILD_MAX - _SC_CLK_TCK - _SC_NGROUPS_MAX - _SC_OPEN_MAX - _SC_JOB_CONTROL - _SC_SAVED_IDS - _SC_VERSION - _SC_BC_BASE_MAX - _SC_BC_DIM_MAX - _SC_BC_SCALE_MAX - _SC_BC_STRING_MAX - _SC_COLL_WEIGHTS_MAX - _SC_EXPR_NEST_MAX - _SC_LINE_MAX - _SC_RE_DUP_MAX - _SC_2_VERSION - _SC_2_C_BIND - _SC_2_C_DEV - _SC_2_CHAR_TERM - _SC_2_FORT_DEV - _SC_2_FORT_RUN - _SC_2_LOCALEDEF - _SC_2_SW_DEV - _SC_2_UPE - _SC_STREAM_MAX - _SC_TZNAME_MAX - _SC_ASYNCHRONOUS_IO - _SC_PAGESIZE - _SC_MEMLOCK - _SC_MEMLOCK_RANGE - _SC_MEMORY_PROTECTION - _SC_MESSAGE_PASSING - _SC_PRIORITIZED_IO - _SC_PRIORITY_SCHEDULING - _SC_REALTIME_SIGNALS - _SC_SEMAPHORES - _SC_FSYNC - _SC_SHARED_MEMORY_OBJECTS - _SC_SYNCHRONIZED_IO - _SC_TIMERS - _SC_AIO_LISTIO_MAX - _SC_AIO_MAX - _SC_AIO_PRIO_DELTA_MAX - _SC_DELAYTIMER_MAX - _SC_MQ_OPEN_MAX - _SC_MAPPED_FILES - _SC_RTSIG_MAX - _SC_SEM_NSEMS_MAX - _SC_SEM_VALUE_MAX - _SC_SIGQUEUE_MAX - _SC_TIMER_MAX - _SC_NPROCESSORS_CONF - _SC_NPROCESSORS_ONLN - _SC_2_PBS - _SC_2_PBS_ACCOUNTING - _SC_2_PBS_CHECKPOINT - _SC_2_PBS_LOCATE - _SC_2_PBS_MESSAGE - _SC_2_PBS_TRACK - _SC_ADVISORY_INFO - _SC_BARRIERS - _SC_CLOCK_SELECTION - _SC_CPUTIME - _SC_FILE_LOCKING - _SC_GETGR_R_SIZE_MAX - _SC_GETPW_R_SIZE_MAX - _SC_HOST_NAME_MAX - _SC_LOGIN_NAME_MAX - _SC_MONOTONIC_CLOCK - _SC_MQ_PRIO_MAX - _SC_READER_WRITER_LOCKS - _SC_REGEXP - _SC_SHELL - _SC_SPAWN - _SC_SPIN_LOCKS - _SC_SPORADIC_SERVER - _SC_THREAD_ATTR_STACKADDR - _SC_THREAD_ATTR_STACKSIZE - _SC_THREAD_CPUTIME - _SC_THREAD_DESTRUCTOR_ITERATIONS - _SC_THREAD_KEYS_MAX - _SC_THREAD_PRIO_INHERIT - _SC_THREAD_PRIO_PROTECT - _SC_THREAD_PRIORITY_SCHEDULING - _SC_THREAD_PROCESS_SHARED - _SC_THREAD_SAFE_FUNCTIONS - _SC_THREAD_SPORADIC_SERVER - _SC_THREAD_STACK_MIN - _SC_THREAD_THREADS_MAX - _SC_TIMEOUTS - _SC_THREADS - _SC_TRACE - _SC_TRACE_EVENT_FILTER - _SC_TRACE_INHERIT - _SC_TRACE_LOG - _SC_TTY_NAME_MAX - _SC_TYPED_MEMORY_OBJECTS - _SC_V6_ILP32_OFF32 - _SC_V6_ILP32_OFFBIG - _SC_V6_LP64_OFF64 - _SC_V6_LPBIG_OFFBIG - _SC_IPV6 - _SC_RAW_SOCKETS - _SC_SYMLOOP_MAX - _SC_ATEXIT_MAX - _SC_IOV_MAX - _SC_PAGE_SIZE - _SC_XOPEN_CRYPT - _SC_XOPEN_ENH_I18N - _SC_XOPEN_LEGACY - _SC_XOPEN_REALTIME - _SC_XOPEN_REALTIME_THREADS - _SC_XOPEN_SHM - _SC_XOPEN_STREAMS - _SC_XOPEN_UNIX - _SC_XOPEN_VERSION - _SC_XOPEN_XCU_VERSION - _SC_XBS5_ILP32_OFF32 - _SC_XBS5_ILP32_OFFBIG - _SC_XBS5_LP64_OFF64 - _SC_XBS5_LPBIG_OFFBIG - _SC_SS_REPL_MAX - _SC_TRACE_EVENT_NAME_MAX - _SC_TRACE_NAME_MAX - _SC_TRACE_SYS_MAX - _SC_TRACE_USER_EVENT_MAX - _SC_PASS_MAX - ].each {|c| cg.const(c, nil, '', c.sub(/^_/, '')) } - end - @@@ -end diff --git a/lib/ruby/stdlib/ffi/platform/syslog.rb.ffi b/lib/ruby/stdlib/ffi/platform/syslog.rb.ffi deleted file mode 100644 index 615a474cee4..00000000000 --- a/lib/ruby/stdlib/ffi/platform/syslog.rb.ffi +++ /dev/null @@ -1,47 +0,0 @@ -module Syslog - module Constants - @@@ - constants do |c| - c.include 'syslog.h' - - c.const 'LOG_EMERG' - c.const 'LOG_ALERT' - c.const 'LOG_ERR' - c.const 'LOG_CRIT' - c.const 'LOG_WARNING' - c.const 'LOG_NOTICE' - c.const 'LOG_INFO' - c.const 'LOG_DEBUG' - c.const 'LOG_PID' - c.const 'LOG_CONS' - c.const 'LOG_ODELAY' - c.const 'LOG_NDELAY' - c.const 'LOG_NOWAIT' - c.const 'LOG_PERROR' - c.const 'LOG_AUTH' - c.const 'LOG_AUTHPRIV' - c.const 'LOG_CONSOLE' - c.const 'LOG_CRON' - c.const 'LOG_DAEMON' - c.const 'LOG_FTP' - c.const 'LOG_KERN' - c.const 'LOG_LPR' - c.const 'LOG_MAIL' - c.const 'LOG_NEWS' - c.const 'LOG_NTP' - c.const 'LOG_SECURITY' - c.const 'LOG_SYSLOG' - c.const 'LOG_USER' - c.const 'LOG_UUCP' - c.const 'LOG_LOCAL0' - c.const 'LOG_LOCAL1' - c.const 'LOG_LOCAL2' - c.const 'LOG_LOCAL3' - c.const 'LOG_LOCAL4' - c.const 'LOG_LOCAL5' - c.const 'LOG_LOCAL6' - c.const 'LOG_LOCAL7' - end - @@@ - end -end \ No newline at end of file diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-cygwin/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-cygwin/types.conf old mode 100755 new mode 100644 index 5dadc7f037d..5bef6d707e5 --- a/lib/ruby/stdlib/ffi/platform/x86_64-cygwin/types.conf +++ b/lib/ruby/stdlib/ffi/platform/x86_64-cygwin/types.conf @@ -1,3 +1,3 @@ -rbx.platform.typedef.size_t = uint64 rbx.platform.typedef.ptrdiff_t = int64 +rbx.platform.typedef.size_t = uint64 rbx.platform.typedef.ssize_t = int64 diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-darwin/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-darwin/types.conf index 51637eed0b7..2fd360eccc2 100644 --- a/lib/ruby/stdlib/ffi/platform/x86_64-darwin/types.conf +++ b/lib/ruby/stdlib/ffi/platform/x86_64-darwin/types.conf @@ -1,44 +1,7 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__darwin_intptr_t = long -rbx.platform.typedef.__darwin_natural_t = uint -rbx.platform.typedef.__darwin_ct_rune_t = int -rbx.platform.typedef.__darwin_ptrdiff_t = long -rbx.platform.typedef.__darwin_size_t = ulong -rbx.platform.typedef.__darwin_wchar_t = int -rbx.platform.typedef.__darwin_rune_t = int -rbx.platform.typedef.__darwin_wint_t = int -rbx.platform.typedef.__darwin_clock_t = ulong -rbx.platform.typedef.__darwin_socklen_t = uint -rbx.platform.typedef.__darwin_ssize_t = long -rbx.platform.typedef.__darwin_time_t = long -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long_long -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.user_addr_t = ulong_long -rbx.platform.typedef.user_size_t = ulong_long -rbx.platform.typedef.user_ssize_t = long_long -rbx.platform.typedef.user_long_t = long_long -rbx.platform.typedef.user_ulong_t = ulong_long -rbx.platform.typedef.user_time_t = long_long -rbx.platform.typedef.user_off_t = long_long -rbx.platform.typedef.syscall_arg_t = ulong_long rbx.platform.typedef.__darwin_blkcnt_t = long_long rbx.platform.typedef.__darwin_blksize_t = int +rbx.platform.typedef.__darwin_clock_t = ulong +rbx.platform.typedef.__darwin_ct_rune_t = int rbx.platform.typedef.__darwin_dev_t = int rbx.platform.typedef.__darwin_fsblkcnt_t = uint rbx.platform.typedef.__darwin_fsfilcnt_t = uint @@ -46,81 +9,118 @@ rbx.platform.typedef.__darwin_gid_t = uint rbx.platform.typedef.__darwin_id_t = uint rbx.platform.typedef.__darwin_ino64_t = ulong_long rbx.platform.typedef.__darwin_ino_t = ulong_long +rbx.platform.typedef.__darwin_intptr_t = long rbx.platform.typedef.__darwin_mach_port_name_t = uint rbx.platform.typedef.__darwin_mach_port_t = uint rbx.platform.typedef.__darwin_mode_t = ushort +rbx.platform.typedef.__darwin_natural_t = uint rbx.platform.typedef.__darwin_off_t = long_long rbx.platform.typedef.__darwin_pid_t = int +rbx.platform.typedef.__darwin_pthread_key_t = ulong +rbx.platform.typedef.__darwin_ptrdiff_t = long +rbx.platform.typedef.__darwin_rune_t = int rbx.platform.typedef.__darwin_sigset_t = uint +rbx.platform.typedef.__darwin_size_t = ulong +rbx.platform.typedef.__darwin_socklen_t = uint +rbx.platform.typedef.__darwin_ssize_t = long rbx.platform.typedef.__darwin_suseconds_t = int +rbx.platform.typedef.__darwin_time_t = long rbx.platform.typedef.__darwin_uid_t = uint rbx.platform.typedef.__darwin_useconds_t = uint -rbx.platform.typedef.__darwin_uuid_t[16] = uchar rbx.platform.typedef.__darwin_uuid_string_t[37] = char -rbx.platform.typedef.__darwin_pthread_key_t = ulong -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.__darwin_uuid_t[16] = uchar +rbx.platform.typedef.__darwin_wchar_t = int +rbx.platform.typedef.__darwin_wint_t = int +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = int rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = int +rbx.platform.typedef.errno_t = int +rbx.platform.typedef.fd_mask = int rbx.platform.typedef.fixpt_t = uint -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.fsblkcnt_t = uint +rbx.platform.typedef.fsfilcnt_t = uint rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.ino_t = ulong_long rbx.platform.typedef.ino64_t = ulong_long +rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = short +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long_long +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long rbx.platform.typedef.key_t = int rbx.platform.typedef.mode_t = ushort rbx.platform.typedef.nlink_t = ushort -rbx.platform.typedef.id_t = uint -rbx.platform.typedef.pid_t = int rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long_long +rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.rsize_t = ulong +rbx.platform.typedef.sa_family_t = uchar rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.clock_t = ulong rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.time_t = long -rbx.platform.typedef.useconds_t = uint rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.rsize_t = ulong -rbx.platform.typedef.errno_t = int -rbx.platform.typedef.fd_mask = int -rbx.platform.typedef.pthread_key_t = ulong -rbx.platform.typedef.fsblkcnt_t = uint -rbx.platform.typedef.fsfilcnt_t = uint -rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.swblk_t = int +rbx.platform.typedef.syscall_arg_t = ulong_long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint rbx.platform.typedef.uint16_t = ushort rbx.platform.typedef.uint32_t = uint rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.int_least8_t = char -rbx.platform.typedef.int_least16_t = short -rbx.platform.typedef.int_least32_t = int -rbx.platform.typedef.int_least64_t = long_long -rbx.platform.typedef.uint_least8_t = uchar -rbx.platform.typedef.uint_least16_t = ushort -rbx.platform.typedef.uint_least32_t = uint -rbx.platform.typedef.uint_least64_t = ulong_long -rbx.platform.typedef.int_fast8_t = char -rbx.platform.typedef.int_fast16_t = short -rbx.platform.typedef.int_fast32_t = int -rbx.platform.typedef.int_fast64_t = long_long -rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint8_t = uchar rbx.platform.typedef.uint_fast16_t = ushort rbx.platform.typedef.uint_fast32_t = uint rbx.platform.typedef.uint_fast64_t = ulong_long -rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar rbx.platform.typedef.uintmax_t = ulong -rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.user_addr_t = ulong_long +rbx.platform.typedef.user_long_t = long_long +rbx.platform.typedef.user_off_t = long_long +rbx.platform.typedef.user_size_t = ulong_long +rbx.platform.typedef.user_ssize_t = long_long +rbx.platform.typedef.user_time_t = long_long +rbx.platform.typedef.user_ulong_t = ulong_long +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-dragonflybsd/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-dragonflybsd/types.conf new file mode 100644 index 00000000000..451f13dfaf9 --- /dev/null +++ b/lib/ruby/stdlib/ffi/platform/x86_64-dragonflybsd/types.conf @@ -0,0 +1,148 @@ +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.__char16_t = ushort +rbx.platform.typedef.__char32_t = uint +rbx.platform.typedef.__clock_t = ulong +rbx.platform.typedef.__clockid_t = ulong +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long +rbx.platform.typedef.__rlim_t = long +rbx.platform.typedef.__rune_t = int +rbx.platform.typedef.__segsz_t = long +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__size_t = ulong +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = int +rbx.platform.typedef.__u_register_t = ulong +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__uintptr_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.c_caddr_t = pointer +rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = ulong +rbx.platform.typedef.clockid_t = ulong +rbx.platform.typedef.cpulock_t = uint +rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = long +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.int_fast16_t = int +rbx.platform.typedef.int_fast32_t = int +rbx.platform.typedef.int_fast64_t = long +rbx.platform.typedef.int_fast8_t = int +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.lwpid_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.mqd_t = int +rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pd_entry_t = ulong +rbx.platform.typedef.pdp_entry_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pml4_entry_t = ulong +rbx.platform.typedef.pt_entry_t = ulong +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = long +rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.segsz_t = long +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.timer_t = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_daddr_t = uint +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_register_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uint +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.v_caddr_t = pointer +rbx.platform.typedef.vm_offset_t = ulong +rbx.platform.typedef.vm_ooffset_t = long +rbx.platform.typedef.vm_paddr_t = ulong +rbx.platform.typedef.vm_pindex_t = ulong +rbx.platform.typedef.vm_poff_t = ulong +rbx.platform.typedef.vm_size_t = ulong +rbx.platform.typedef.vm_spindex_t = ulong diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-freebsd/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-freebsd/types.conf index 6d9ffe5a3d8..8dbe370349f 100644 --- a/lib/ruby/stdlib/ffi/platform/x86_64-freebsd/types.conf +++ b/lib/ruby/stdlib/ffi/platform/x86_64-freebsd/types.conf @@ -1,128 +1,128 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__int_least8_t = char -rbx.platform.typedef.__uint_least8_t = uchar -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint -rbx.platform.typedef.__int_least64_t = long_long -rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__int_fast8_t = int -rbx.platform.typedef.__uint_fast8_t = uint -rbx.platform.typedef.__int_fast16_t = int -rbx.platform.typedef.__uint_fast16_t = uint -rbx.platform.typedef.__int_fast32_t = int -rbx.platform.typedef.__uint_fast32_t = uint -rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__uintptr_t = ulong -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__register_t = long_long -rbx.platform.typedef.__vaddr_t = ulong -rbx.platform.typedef.__paddr_t = ulong -rbx.platform.typedef.__vsize_t = ulong -rbx.platform.typedef.__psize_t = ulong rbx.platform.typedef.__clock_t = int rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__ptrdiff_t = long -rbx.platform.typedef.__size_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__timer_t = int -rbx.platform.typedef.__wchar_t = int -rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__rune_t = int -rbx.platform.typedef.__wctrans_t = pointer -rbx.platform.typedef.__wctype_t = pointer rbx.platform.typedef.__cpuid_t = ulong rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int rbx.platform.typedef.__fixpt_t = uint rbx.platform.typedef.__gid_t = uint rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__in_addr_t = uint rbx.platform.typedef.__in_port_t = ushort rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long rbx.platform.typedef.__key_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long_long rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__timer_t = int rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.cpuid_t = ulong -rbx.platform.typedef.register_t = long_long -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.vaddr_t = ulong -rbx.platform.typedef.paddr_t = ulong -rbx.platform.typedef.vsize_t = ulong -rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong rbx.platform.typedef.daddr32_t = int rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = int rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.gid_t = uint rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long rbx.platform.typedef.key_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long_long rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.clock_t = int -rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.swblk_t = int rbx.platform.typedef.time_t = long rbx.platform.typedef.timer_t = int -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-freebsd12/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-freebsd12/types.conf index 47fc293c3dd..31b1073da90 100644 --- a/lib/ruby/stdlib/ffi/platform/x86_64-freebsd12/types.conf +++ b/lib/ruby/stdlib/ffi/platform/x86_64-freebsd12/types.conf @@ -1,128 +1,158 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.*) = pointer +rbx.platform.typedef.___wchar_t = int +rbx.platform.typedef.__accmode_t = int +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = int +rbx.platform.typedef.__char16_t = ushort +rbx.platform.typedef.__char32_t = uint +rbx.platform.typedef.__clock_t = int +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__cpulevel_t = int +rbx.platform.typedef.__cpusetid_t = int +rbx.platform.typedef.__cpuwhich_t = int +rbx.platform.typedef.__critical_t = long +rbx.platform.typedef.__ct_rune_t = int +rbx.platform.typedef.__dev_t = ulong +rbx.platform.typedef.__fd_mask = ulong +rbx.platform.typedef.__fflags_t = uint +rbx.platform.typedef.__fixpt_t = uint +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__gid_t = uint +rbx.platform.typedef.__id_t = long +rbx.platform.typedef.__ino_t = ulong rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__int_least8_t = char -rbx.platform.typedef.__uint_least8_t = uchar -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint -rbx.platform.typedef.__int_least64_t = long_long -rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__int_fast8_t = int -rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char rbx.platform.typedef.__int_fast16_t = int -rbx.platform.typedef.__uint_fast16_t = uint rbx.platform.typedef.__int_fast32_t = int -rbx.platform.typedef.__uint_fast32_t = uint -rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__int_fast64_t = long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intfptr_t = long +rbx.platform.typedef.__intmax_t = long rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__uintptr_t = ulong -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__register_t = long_long -rbx.platform.typedef.__vaddr_t = ulong -rbx.platform.typedef.__paddr_t = ulong -rbx.platform.typedef.__vsize_t = ulong -rbx.platform.typedef.__psize_t = ulong -rbx.platform.typedef.__clock_t = int -rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__ptrdiff_t = long -rbx.platform.typedef.__size_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__time_t = int -rbx.platform.typedef.__timer_t = int -rbx.platform.typedef.__wchar_t = int -rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__rune_t = int -rbx.platform.typedef.__wctrans_t = pointer -rbx.platform.typedef.__wctype_t = pointer -rbx.platform.typedef.__cpuid_t = ulong -rbx.platform.typedef.__dev_t = ulong_long -rbx.platform.typedef.__fixpt_t = uint -rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__in_addr_t = uint -rbx.platform.typedef.__in_port_t = ushort -rbx.platform.typedef.__ino_t = ulong_long rbx.platform.typedef.__key_t = long -rbx.platform.typedef.__mode_t = uint -rbx.platform.typedef.__nlink_t = ulong_long +rbx.platform.typedef.__lwpid_t = int +rbx.platform.typedef.__mode_t = ushort +rbx.platform.typedef.__nl_item = int +rbx.platform.typedef.__nlink_t = ulong +rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long +rbx.platform.typedef.__rlim_t = long +rbx.platform.typedef.__rman_res_t = ulong +rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__sa_family_t = uchar -rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__segsz_t = long +rbx.platform.typedef.__size_t = ulong rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = long +rbx.platform.typedef.__time_t = long +rbx.platform.typedef.__u_register_t = ulong rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintfptr_t = ulong +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__uintptr_t = ulong rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = int -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.cpuid_t = ulong -rbx.platform.typedef.register_t = long_long -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.vaddr_t = ulong -rbx.platform.typedef.paddr_t = ulong -rbx.platform.typedef.vsize_t = ulong -rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.__vm_offset_t = ulong +rbx.platform.typedef.__vm_paddr_t = ulong +rbx.platform.typedef.__vm_size_t = ulong +rbx.platform.typedef.__wint_t = int +rbx.platform.typedef.accmode_t = int +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.c_caddr_t = pointer rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.daddr32_t = int -rbx.platform.typedef.daddr64_t = long_long -rbx.platform.typedef.dev_t = ulong_long +rbx.platform.typedef.cap_ioctl_t = ulong +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpulevel_t = int +rbx.platform.typedef.cpusetid_t = int +rbx.platform.typedef.cpuwhich_t = int +rbx.platform.typedef.critical_t = long +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = ulong +rbx.platform.typedef.fflags_t = uint rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint -rbx.platform.typedef.id_t = uint -rbx.platform.typedef.ino_t = ulong_long -rbx.platform.typedef.key_t = long -rbx.platform.typedef.mode_t = uint -rbx.platform.typedef.nlink_t = ulong_long -rbx.platform.typedef.pid_t = int -rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.id_t = long rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.key_t = long +rbx.platform.typedef.ksize_t = ulong +rbx.platform.typedef.kvaddr_t = ulong +rbx.platform.typedef.lwpid_t = int +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ulong +rbx.platform.typedef.off64_t = long +rbx.platform.typedef.off_t = long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_key_t = int +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = long +rbx.platform.typedef.rman_res_t = ulong rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.clock_t = int -rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.sbintime_t = long +rbx.platform.typedef.segsz_t = long rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.time_t = int -rbx.platform.typedef.timer_t = int -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_register_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vm_offset_t = ulong +rbx.platform.typedef.vm_ooffset_t = long +rbx.platform.typedef.vm_paddr_t = ulong +rbx.platform.typedef.vm_pindex_t = ulong +rbx.platform.typedef.vm_size_t = ulong diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-linux/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-linux/types.conf index f319c0bbebc..3849264f401 100644 --- a/lib/ruby/stdlib/ffi/platform/x86_64-linux/types.conf +++ b/lib/ruby/stdlib/ffi/platform/x86_64-linux/types.conf @@ -1,102 +1,111 @@ -rbx.platform.typedef.__u_char = uchar -rbx.platform.typedef.__u_short = ushort -rbx.platform.typedef.__u_int = uint -rbx.platform.typedef.__u_long = ulong -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long -rbx.platform.typedef.__uint64_t = ulong -rbx.platform.typedef.__quad_t = long -rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.*__caddr_t = char +rbx.platform.typedef.__blkcnt64_t = long +rbx.platform.typedef.__blkcnt_t = long +rbx.platform.typedef.__blksize_t = long +rbx.platform.typedef.__clock_t = long +rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__daddr_t = int rbx.platform.typedef.__dev_t = ulong -rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__fd_mask = long +rbx.platform.typedef.__fsblkcnt64_t = ulong +rbx.platform.typedef.__fsblkcnt_t = ulong +rbx.platform.typedef.__fsfilcnt64_t = ulong +rbx.platform.typedef.__fsfilcnt_t = ulong +rbx.platform.typedef.__fsword_t = long rbx.platform.typedef.__gid_t = uint -rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__ino64_t = ulong +rbx.platform.typedef.__ino_t = ulong +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__intmax_t = long +rbx.platform.typedef.__intptr_t = long +rbx.platform.typedef.__key_t = int +rbx.platform.typedef.__loff_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = ulong -rbx.platform.typedef.__off_t = long rbx.platform.typedef.__off64_t = long +rbx.platform.typedef.__off_t = long rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__clock_t = long -rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.__quad_t = long rbx.platform.typedef.__rlim64_t = ulong -rbx.platform.typedef.__id_t = uint -rbx.platform.typedef.__time_t = long -rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.__rlim_t = ulong +rbx.platform.typedef.__rlimit_resource_t = int +rbx.platform.typedef.__rusage_who_t = int +rbx.platform.typedef.__sig_atomic_t = int +rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long rbx.platform.typedef.__suseconds_t = long -rbx.platform.typedef.__daddr_t = int -rbx.platform.typedef.__swblk_t = long -rbx.platform.typedef.__key_t = int -rbx.platform.typedef.__clockid_t = int +rbx.platform.typedef.__syscall_slong_t = long +rbx.platform.typedef.__syscall_ulong_t = ulong +rbx.platform.typedef.__time_t = long rbx.platform.typedef.__timer_t = pointer +rbx.platform.typedef.__u_char = uchar +rbx.platform.typedef.__u_int = uint +rbx.platform.typedef.__u_long = ulong +rbx.platform.typedef.__u_quad_t = ulong +rbx.platform.typedef.__u_short = ushort +rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong +rbx.platform.typedef.__useconds_t = uint +rbx.platform.typedef.blkcnt_t = long rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.__blkcnt_t = long -rbx.platform.typedef.__blkcnt64_t = long -rbx.platform.typedef.__fsblkcnt_t = ulong -rbx.platform.typedef.__fsblkcnt64_t = ulong -rbx.platform.typedef.__fsfilcnt_t = ulong -rbx.platform.typedef.__fsfilcnt64_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__loff_t = long -rbx.platform.typedef.*__qaddr_t = long -rbx.platform.typedef.*__caddr_t = char -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__socklen_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.quad_t = long -rbx.platform.typedef.u_quad_t = ulong -rbx.platform.typedef.loff_t = long -rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.id_t = uint rbx.platform.typedef.in_addr_t = uint rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.ino_t = ulong +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.key_t = int +rbx.platform.typedef.loff_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = ulong -rbx.platform.typedef.uid_t = uint rbx.platform.typedef.off_t = long rbx.platform.typedef.pid_t = int -rbx.platform.typedef.id_t = uint +rbx.platform.typedef.pthread_key_t = uint +rbx.platform.typedef.pthread_once_t = int +rbx.platform.typedef.pthread_t = ulong +rbx.platform.typedef.quad_t = long +rbx.platform.typedef.register_t = long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long -rbx.platform.typedef.daddr_t = int -rbx.platform.typedef.key_t = int +rbx.platform.typedef.suseconds_t = long rbx.platform.typedef.time_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = pointer -rbx.platform.typedef.size_t = ulong -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_int16_t = ushort rbx.platform.typedef.u_int32_t = uint rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = long -rbx.platform.typedef.__sig_atomic_t = int -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.__fd_mask = long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.pthread_t = ulong -rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.pthread_once_t = int -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.__rlimit_resource_t = int -rbx.platform.typedef.__rusage_who_t = int -rbx.platform.typedef.__priority_which_t = int +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ushort = ushort diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-netbsd/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-netbsd/types.conf index c4df68adbee..15a0d61380f 100644 --- a/lib/ruby/stdlib/ffi/platform/x86_64-netbsd/types.conf +++ b/lib/ruby/stdlib/ffi/platform/x86_64-netbsd/types.conf @@ -1,128 +1,128 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__int_least8_t = char -rbx.platform.typedef.__uint_least8_t = uchar -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint -rbx.platform.typedef.__int_least64_t = long_long -rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__int_fast8_t = int -rbx.platform.typedef.__uint_fast8_t = uint -rbx.platform.typedef.__int_fast16_t = int -rbx.platform.typedef.__uint_fast16_t = uint -rbx.platform.typedef.__int_fast32_t = int -rbx.platform.typedef.__uint_fast32_t = uint -rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__uintptr_t = ulong -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__register_t = int -rbx.platform.typedef.__vaddr_t = ulong -rbx.platform.typedef.__paddr_t = ulong -rbx.platform.typedef.__vsize_t = ulong -rbx.platform.typedef.__psize_t = ulong rbx.platform.typedef.__clock_t = int rbx.platform.typedef.__clockid_t = int -rbx.platform.typedef.__off_t = long_long -rbx.platform.typedef.__ptrdiff_t = long -rbx.platform.typedef.__size_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__time_t = int -rbx.platform.typedef.__timer_t = int -rbx.platform.typedef.__wchar_t = int -rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__rune_t = int -rbx.platform.typedef.__wctrans_t = pointer -rbx.platform.typedef.__wctype_t = pointer rbx.platform.typedef.__cpuid_t = ulong rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = int rbx.platform.typedef.__fixpt_t = uint rbx.platform.typedef.__gid_t = uint rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__in_addr_t = uint rbx.platform.typedef.__in_port_t = ushort rbx.platform.typedef.__ino_t = uint +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long rbx.platform.typedef.__key_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint +rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = int rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long +rbx.platform.typedef.__suseconds_t = int rbx.platform.typedef.__swblk_t = int +rbx.platform.typedef.__time_t = int +rbx.platform.typedef.__timer_t = int rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.__suseconds_t = int -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.cpuid_t = ulong -rbx.platform.typedef.register_t = int -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.vaddr_t = ulong -rbx.platform.typedef.paddr_t = ulong -rbx.platform.typedef.vsize_t = ulong -rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.daddr_t = int +rbx.platform.typedef.clock_t = int +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong rbx.platform.typedef.daddr32_t = int rbx.platform.typedef.daddr64_t = long_long +rbx.platform.typedef.daddr_t = int rbx.platform.typedef.dev_t = int rbx.platform.typedef.fixpt_t = uint rbx.platform.typedef.gid_t = uint rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.ino_t = uint +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char +rbx.platform.typedef.intptr_t = long rbx.platform.typedef.key_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = int rbx.platform.typedef.rlim_t = ulong_long -rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = int -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.sa_family_t = uchar -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.clock_t = int -rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.segsz_t = int rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = int +rbx.platform.typedef.swblk_t = int rbx.platform.typedef.time_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.__fd_mask = int +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-openbsd/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-openbsd/types.conf index f8419bd3e56..6abc9c09a82 100644 --- a/lib/ruby/stdlib/ffi/platform/x86_64-openbsd/types.conf +++ b/lib/ruby/stdlib/ffi/platform/x86_64-openbsd/types.conf @@ -1,50 +1,10 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar -rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef.__int_least8_t = char -rbx.platform.typedef.__uint_least8_t = uchar -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint -rbx.platform.typedef.__int_least64_t = long_long -rbx.platform.typedef.__uint_least64_t = ulong_long -rbx.platform.typedef.__int_fast8_t = int -rbx.platform.typedef.__uint_fast8_t = uint -rbx.platform.typedef.__int_fast16_t = int -rbx.platform.typedef.__uint_fast16_t = uint -rbx.platform.typedef.__int_fast32_t = int -rbx.platform.typedef.__uint_fast32_t = uint -rbx.platform.typedef.__int_fast64_t = long_long -rbx.platform.typedef.__uint_fast64_t = ulong_long -rbx.platform.typedef.__intptr_t = long -rbx.platform.typedef.__uintptr_t = ulong -rbx.platform.typedef.__intmax_t = long_long -rbx.platform.typedef.__uintmax_t = ulong_long -rbx.platform.typedef.__register_t = long -rbx.platform.typedef.__vaddr_t = ulong -rbx.platform.typedef.__paddr_t = ulong -rbx.platform.typedef.__vsize_t = ulong -rbx.platform.typedef.__psize_t = ulong -rbx.platform.typedef.__ptrdiff_t = long -rbx.platform.typedef.__size_t = ulong -rbx.platform.typedef.__ssize_t = long -rbx.platform.typedef.__wchar_t = int -rbx.platform.typedef.__wint_t = int -rbx.platform.typedef.__rune_t = int -rbx.platform.typedef.__wctrans_t = pointer -rbx.platform.typedef.__wctype_t = pointer rbx.platform.typedef.__blkcnt_t = long_long rbx.platform.typedef.__blksize_t = int rbx.platform.typedef.__clock_t = long_long rbx.platform.typedef.__clockid_t = int rbx.platform.typedef.__cpuid_t = ulong rbx.platform.typedef.__dev_t = int +rbx.platform.typedef.__fd_mask = uint rbx.platform.typedef.__fixpt_t = uint rbx.platform.typedef.__fsblkcnt_t = ulong_long rbx.platform.typedef.__fsfilcnt_t = ulong_long @@ -53,82 +13,122 @@ rbx.platform.typedef.__id_t = uint rbx.platform.typedef.__in_addr_t = uint rbx.platform.typedef.__in_port_t = ushort rbx.platform.typedef.__ino_t = ulong_long +rbx.platform.typedef.__int16_t = short +rbx.platform.typedef.__int32_t = int +rbx.platform.typedef.__int64_t = long_long +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_fast16_t = int +rbx.platform.typedef.__int_fast32_t = int +rbx.platform.typedef.__int_fast64_t = long_long +rbx.platform.typedef.__int_fast8_t = int +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__int_least64_t = long_long +rbx.platform.typedef.__int_least8_t = char +rbx.platform.typedef.__intmax_t = long_long +rbx.platform.typedef.__intptr_t = long rbx.platform.typedef.__key_t = long rbx.platform.typedef.__mode_t = uint rbx.platform.typedef.__nlink_t = uint rbx.platform.typedef.__off_t = long_long +rbx.platform.typedef.__paddr_t = ulong rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__psize_t = ulong +rbx.platform.typedef.__ptrdiff_t = long +rbx.platform.typedef.__register_t = long rbx.platform.typedef.__rlim_t = ulong_long +rbx.platform.typedef.__rune_t = int rbx.platform.typedef.__sa_family_t = uchar rbx.platform.typedef.__segsz_t = int +rbx.platform.typedef.__size_t = ulong rbx.platform.typedef.__socklen_t = uint +rbx.platform.typedef.__ssize_t = long rbx.platform.typedef.__suseconds_t = long rbx.platform.typedef.__swblk_t = int rbx.platform.typedef.__time_t = long_long rbx.platform.typedef.__timer_t = int rbx.platform.typedef.__uid_t = uint +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_fast16_t = uint +rbx.platform.typedef.__uint_fast32_t = uint +rbx.platform.typedef.__uint_fast64_t = ulong_long +rbx.platform.typedef.__uint_fast8_t = uint +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef.__uint_least64_t = ulong_long +rbx.platform.typedef.__uint_least8_t = uchar +rbx.platform.typedef.__uintmax_t = ulong_long +rbx.platform.typedef.__uintptr_t = ulong rbx.platform.typedef.__useconds_t = uint -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong -rbx.platform.typedef.cpuid_t = ulong -rbx.platform.typedef.register_t = long -rbx.platform.typedef.int8_t = char -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.int16_t = short -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.int32_t = int -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.quad_t = long_long -rbx.platform.typedef.u_quad_t = ulong_long -rbx.platform.typedef.qaddr_t = pointer -rbx.platform.typedef.vaddr_t = ulong -rbx.platform.typedef.paddr_t = ulong -rbx.platform.typedef.vsize_t = ulong -rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.__vaddr_t = ulong +rbx.platform.typedef.__vsize_t = ulong +rbx.platform.typedef.__wchar_t = int +rbx.platform.typedef.__wctrans_t = pointer +rbx.platform.typedef.__wctype_t = pointer +rbx.platform.typedef.__wint_t = int rbx.platform.typedef.blkcnt_t = long_long rbx.platform.typedef.blksize_t = int rbx.platform.typedef.caddr_t = string +rbx.platform.typedef.clock_t = long_long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cpuid_t = ulong rbx.platform.typedef.daddr32_t = int rbx.platform.typedef.daddr_t = long_long rbx.platform.typedef.dev_t = int rbx.platform.typedef.fixpt_t = uint +rbx.platform.typedef.fsblkcnt_t = ulong_long +rbx.platform.typedef.fsfilcnt_t = ulong_long rbx.platform.typedef.gid_t = uint rbx.platform.typedef.id_t = uint +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort rbx.platform.typedef.ino_t = ulong_long +rbx.platform.typedef.int16_t = short +rbx.platform.typedef.int32_t = int +rbx.platform.typedef.int64_t = long_long +rbx.platform.typedef.int8_t = char rbx.platform.typedef.key_t = long rbx.platform.typedef.mode_t = uint rbx.platform.typedef.nlink_t = uint +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.paddr_t = ulong +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.psize_t = ulong +rbx.platform.typedef.qaddr_t = pointer +rbx.platform.typedef.quad_t = long_long +rbx.platform.typedef.register_t = long rbx.platform.typedef.rlim_t = ulong_long +rbx.platform.typedef.sa_family_t = uchar rbx.platform.typedef.segsz_t = int -rbx.platform.typedef.swblk_t = int -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.fsblkcnt_t = ulong_long -rbx.platform.typedef.fsfilcnt_t = ulong_long -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.clock_t = long_long -rbx.platform.typedef.clockid_t = int -rbx.platform.typedef.pid_t = int +rbx.platform.typedef.sigset_t = uint rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.swblk_t = int rbx.platform.typedef.time_t = long_long rbx.platform.typedef.timer_t = int -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.__fd_mask = uint -rbx.platform.typedef.sigset_t = uint -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.sa_family_t = uchar +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_quad_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.vaddr_t = ulong +rbx.platform.typedef.vsize_t = ulong diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-solaris/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-solaris/types.conf index f461b7ec904..a7890d16966 100644 --- a/lib/ruby/stdlib/ffi/platform/x86_64-solaris/types.conf +++ b/lib/ruby/stdlib/ffi/platform/x86_64-solaris/types.conf @@ -1,122 +1,122 @@ -rbx.platform.typedef.lock_t = uchar -rbx.platform.typedef.int8_t = char +rbx.platform.typedef.*caddr_t = char +rbx.platform.typedef.blkcnt64_t = long +rbx.platform.typedef.blkcnt_t = long +rbx.platform.typedef.blksize_t = int +rbx.platform.typedef.clock_t = long +rbx.platform.typedef.clockid_t = int +rbx.platform.typedef.cnt_t = short +rbx.platform.typedef.cpu_flag_t = ushort +rbx.platform.typedef.ctid_t = int +rbx.platform.typedef.daddr_t = long +rbx.platform.typedef.datalink_id_t = uint +rbx.platform.typedef.dev_t = ulong +rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.disp_lock_t = uchar +rbx.platform.typedef.fd_mask = long +rbx.platform.typedef.fds_mask = long +rbx.platform.typedef.fsblkcnt64_t = ulong +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt64_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = uint +rbx.platform.typedef.hrtime_t = long_long +rbx.platform.typedef.id_t = int +rbx.platform.typedef.in_addr_t = uint +rbx.platform.typedef.in_port_t = ushort +rbx.platform.typedef.index_t = short +rbx.platform.typedef.ino64_t = ulong +rbx.platform.typedef.ino_t = ulong rbx.platform.typedef.int16_t = short rbx.platform.typedef.int32_t = int rbx.platform.typedef.int64_t = long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong -rbx.platform.typedef.intmax_t = long -rbx.platform.typedef.uintmax_t = ulong -rbx.platform.typedef.intptr_t = long -rbx.platform.typedef.uintptr_t = ulong -rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int8_t = char rbx.platform.typedef.int_fast16_t = int rbx.platform.typedef.int_fast32_t = int rbx.platform.typedef.int_fast64_t = long -rbx.platform.typedef.uint_fast8_t = uchar -rbx.platform.typedef.uint_fast16_t = uint -rbx.platform.typedef.uint_fast32_t = uint -rbx.platform.typedef.uint_fast64_t = ulong -rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.int_fast8_t = char rbx.platform.typedef.int_least16_t = short rbx.platform.typedef.int_least32_t = int rbx.platform.typedef.int_least64_t = long -rbx.platform.typedef.uint_least8_t = uchar -rbx.platform.typedef.uint_least16_t = ushort -rbx.platform.typedef.uint_least32_t = uint -rbx.platform.typedef.uint_least64_t = ulong -rbx.platform.typedef.longlong_t = long_long -rbx.platform.typedef.u_longlong_t = ulong_long -rbx.platform.typedef.t_scalar_t = int -rbx.platform.typedef.t_uscalar_t = uint -rbx.platform.typedef.uchar_t = uchar -rbx.platform.typedef.ushort_t = ushort -rbx.platform.typedef.uint_t = uint -rbx.platform.typedef.ulong_t = ulong -rbx.platform.typedef.*caddr_t = char -rbx.platform.typedef.daddr_t = long -rbx.platform.typedef.cnt_t = short -rbx.platform.typedef.ptrdiff_t = long -rbx.platform.typedef.pfn_t = ulong -rbx.platform.typedef.pgcnt_t = ulong -rbx.platform.typedef.spgcnt_t = long -rbx.platform.typedef.use_t = uchar -rbx.platform.typedef.sysid_t = short -rbx.platform.typedef.index_t = short -rbx.platform.typedef.off_t = long -rbx.platform.typedef.off64_t = long -rbx.platform.typedef.ino_t = ulong -rbx.platform.typedef.blkcnt_t = long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.ino64_t = ulong -rbx.platform.typedef.blkcnt64_t = long -rbx.platform.typedef.fsblkcnt64_t = ulong -rbx.platform.typedef.fsfilcnt64_t = ulong -rbx.platform.typedef.blksize_t = int -rbx.platform.typedef.pad64_t = long -rbx.platform.typedef.upad64_t = ulong -rbx.platform.typedef.offset_t = long_long -rbx.platform.typedef.u_offset_t = ulong_long -rbx.platform.typedef.len_t = ulong_long -rbx.platform.typedef.diskaddr_t = ulong_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long +rbx.platform.typedef.intptr_t = long +rbx.platform.typedef.ipaddr_t = uint rbx.platform.typedef.k_fltset_t = uint -rbx.platform.typedef.id_t = int +rbx.platform.typedef.key_t = int +rbx.platform.typedef.len_t = ulong_long rbx.platform.typedef.lgrp_id_t = int -rbx.platform.typedef.useconds_t = uint -rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.lock_t = uchar +rbx.platform.typedef.longlong_t = long_long rbx.platform.typedef.major_t = uint rbx.platform.typedef.minor_t = uint -rbx.platform.typedef.pri_t = short -rbx.platform.typedef.cpu_flag_t = ushort -rbx.platform.typedef.o_mode_t = ushort +rbx.platform.typedef.mode_t = uint +rbx.platform.typedef.model_t = uint +rbx.platform.typedef.nfds_t = ulong +rbx.platform.typedef.nlink_t = uint rbx.platform.typedef.o_dev_t = short -rbx.platform.typedef.o_uid_t = ushort rbx.platform.typedef.o_gid_t = ushort +rbx.platform.typedef.o_ino_t = ushort +rbx.platform.typedef.o_mode_t = ushort rbx.platform.typedef.o_nlink_t = short rbx.platform.typedef.o_pid_t = short -rbx.platform.typedef.o_ino_t = ushort -rbx.platform.typedef.key_t = int -rbx.platform.typedef.mode_t = uint -rbx.platform.typedef.uid_t = uint -rbx.platform.typedef.gid_t = uint -rbx.platform.typedef.datalink_id_t = uint -rbx.platform.typedef.taskid_t = int -rbx.platform.typedef.projid_t = int +rbx.platform.typedef.o_uid_t = ushort +rbx.platform.typedef.off64_t = long +rbx.platform.typedef.off_t = long +rbx.platform.typedef.offset_t = long_long +rbx.platform.typedef.pad64_t = long +rbx.platform.typedef.pfn_t = ulong +rbx.platform.typedef.pgcnt_t = ulong +rbx.platform.typedef.pid_t = int rbx.platform.typedef.poolid_t = int -rbx.platform.typedef.zoneid_t = int -rbx.platform.typedef.ctid_t = int -rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.pri_t = short +rbx.platform.typedef.projid_t = int rbx.platform.typedef.pthread_key_t = uint -rbx.platform.typedef.dev_t = ulong -rbx.platform.typedef.nlink_t = uint -rbx.platform.typedef.pid_t = int +rbx.platform.typedef.pthread_t = uint +rbx.platform.typedef.ptrdiff_t = long +rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort rbx.platform.typedef.size_t = ulong +rbx.platform.typedef.socklen_t = uint +rbx.platform.typedef.spgcnt_t = long rbx.platform.typedef.ssize_t = long +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.sysid_t = short +rbx.platform.typedef.t_scalar_t = int +rbx.platform.typedef.t_uscalar_t = uint +rbx.platform.typedef.taskid_t = int rbx.platform.typedef.time_t = long -rbx.platform.typedef.clock_t = long -rbx.platform.typedef.clockid_t = int rbx.platform.typedef.timer_t = int -rbx.platform.typedef.unchar = uchar -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort rbx.platform.typedef.u_int = uint rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.hrtime_t = long_long -rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.fds_mask = long -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.socklen_t = uint -rbx.platform.typedef.nfds_t = ulong -rbx.platform.typedef.disp_lock_t = uchar -rbx.platform.typedef.model_t = uint -rbx.platform.typedef.in_port_t = ushort -rbx.platform.typedef.in_addr_t = uint -rbx.platform.typedef.ipaddr_t = uint -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef.rlim64_t = ulong_long +rbx.platform.typedef.u_longlong_t = ulong_long +rbx.platform.typedef.u_offset_t = ulong_long +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uchar_t = uchar +rbx.platform.typedef.uid_t = uint +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong +rbx.platform.typedef.uint8_t = uchar +rbx.platform.typedef.uint_fast16_t = uint +rbx.platform.typedef.uint_fast32_t = uint +rbx.platform.typedef.uint_fast64_t = ulong +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong +rbx.platform.typedef.uint_least8_t = uchar +rbx.platform.typedef.uint_t = uint +rbx.platform.typedef.uintmax_t = ulong +rbx.platform.typedef.uintptr_t = ulong +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.ulong_t = ulong +rbx.platform.typedef.unchar = uchar +rbx.platform.typedef.upad64_t = ulong +rbx.platform.typedef.use_t = uchar +rbx.platform.typedef.useconds_t = uint +rbx.platform.typedef.ushort = ushort +rbx.platform.typedef.ushort_t = ushort +rbx.platform.typedef.zoneid_t = int diff --git a/lib/ruby/stdlib/ffi/platform/x86_64-windows/types.conf b/lib/ruby/stdlib/ffi/platform/x86_64-windows/types.conf index 24e391d26be..66085afc247 100644 --- a/lib/ruby/stdlib/ffi/platform/x86_64-windows/types.conf +++ b/lib/ruby/stdlib/ffi/platform/x86_64-windows/types.conf @@ -1,120 +1,120 @@ -rbx.platform.typedef.__int8_t = char -rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.*addr_t = char +rbx.platform.typedef.__ULong = ulong +rbx.platform.typedef.__blkcnt32_t = long +rbx.platform.typedef.__blkcnt64_t = long_long +rbx.platform.typedef.__dev16_t = short +rbx.platform.typedef.__dev32_t = ulong +rbx.platform.typedef.__dev_t = short +rbx.platform.typedef.__gid16_t = ushort +rbx.platform.typedef.__gid32_t = ulong +rbx.platform.typedef.__gid_t = ushort +rbx.platform.typedef.__ino32_t = ulong +rbx.platform.typedef.__ino64_t = ulong_long rbx.platform.typedef.__int16_t = short -rbx.platform.typedef.__uint16_t = ushort -rbx.platform.typedef.__int_least16_t = short -rbx.platform.typedef.__uint_least16_t = ushort rbx.platform.typedef.__int32_t = int -rbx.platform.typedef.__uint32_t = uint -rbx.platform.typedef.__int_least32_t = int -rbx.platform.typedef.__uint_least32_t = uint rbx.platform.typedef.__int64_t = long_long -rbx.platform.typedef.__uint64_t = ulong_long -rbx.platform.typedef._off_t = long -rbx.platform.typedef.__dev_t = short +rbx.platform.typedef.__int8_t = char +rbx.platform.typedef.__int_least16_t = short +rbx.platform.typedef.__int_least32_t = int +rbx.platform.typedef.__loff_t = long_long +rbx.platform.typedef.__off_t = long +rbx.platform.typedef.__pid_t = int +rbx.platform.typedef.__time32_t = long +rbx.platform.typedef.__time64_t = long_long +rbx.platform.typedef.__uid16_t = ushort +rbx.platform.typedef.__uid32_t = ulong rbx.platform.typedef.__uid_t = ushort -rbx.platform.typedef.__gid_t = ushort -rbx.platform.typedef._off64_t = long_long -rbx.platform.typedef.fpos_t = long_long -rbx.platform.typedef._fpos_t = long_long +rbx.platform.typedef.__uint16_t = ushort +rbx.platform.typedef.__uint32_t = uint +rbx.platform.typedef.__uint64_t = ulong_long +rbx.platform.typedef.__uint8_t = uchar +rbx.platform.typedef.__uint_least16_t = ushort +rbx.platform.typedef.__uint_least32_t = uint +rbx.platform.typedef._dev_t = uint rbx.platform.typedef._fpos64_t = long_long +rbx.platform.typedef._fpos_t = long_long +rbx.platform.typedef._ino_t = ushort +rbx.platform.typedef._mode_t = ushort +rbx.platform.typedef._off64_t = long_long +rbx.platform.typedef._off_t = long +rbx.platform.typedef._sigset_t = ulong_long rbx.platform.typedef._ssize_t = long_long -rbx.platform.typedef.wchar_t = ushort -rbx.platform.typedef.wint_t = uint -rbx.platform.typedef.wctype_t = ushort -rbx.platform.typedef.ptrdiff_t = long_long -rbx.platform.typedef.size_t = ulong_long -rbx.platform.typedef.__off_t = long -rbx.platform.typedef.__pid_t = int -rbx.platform.typedef.__loff_t = long_long -rbx.platform.typedef.u_char = uchar -rbx.platform.typedef.u_short = ushort -rbx.platform.typedef.u_int = uint -rbx.platform.typedef.u_long = ulong -rbx.platform.typedef.ushort = ushort -rbx.platform.typedef.uint = uint -rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.blkcnt_t = long_long +rbx.platform.typedef.blksize_t = long +rbx.platform.typedef.caddr_t = string rbx.platform.typedef.clock_t = ulong -rbx.platform.typedef.time_t = long_long +rbx.platform.typedef.clockid_t = ulong rbx.platform.typedef.daddr_t = long -rbx.platform.typedef.caddr_t = string -rbx.platform.typedef.pid_t = int -rbx.platform.typedef.ssize_t = int -rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.dev_t = uint +rbx.platform.typedef.errno_t = int rbx.platform.typedef.fd_mask = long -rbx.platform.typedef.clockid_t = ulong -rbx.platform.typedef.timer_t = ulong -rbx.platform.typedef.useconds_t = ulong -rbx.platform.typedef.suseconds_t = long -rbx.platform.typedef.int8_t = char +rbx.platform.typedef.fpos_t = long_long +rbx.platform.typedef.fsblkcnt_t = ulong +rbx.platform.typedef.fsfilcnt_t = ulong +rbx.platform.typedef.gid_t = ulong +rbx.platform.typedef.id_t = ulong +rbx.platform.typedef.ino_t = ushort rbx.platform.typedef.int16_t = short rbx.platform.typedef.int32_t = int rbx.platform.typedef.int64_t = long_long -rbx.platform.typedef.uint8_t = uchar -rbx.platform.typedef.uint16_t = ushort -rbx.platform.typedef.uint32_t = uint -rbx.platform.typedef.uint64_t = ulong_long -rbx.platform.typedef.int_least8_t = char -rbx.platform.typedef.int_least16_t = short -rbx.platform.typedef.int_least32_t = int -rbx.platform.typedef.int_least64_t = long_long -rbx.platform.typedef.uint_least8_t = uchar -rbx.platform.typedef.uint_least16_t = ushort -rbx.platform.typedef.uint_least32_t = uint -rbx.platform.typedef.uint_least64_t = ulong_long -rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int8_t = char rbx.platform.typedef.int_fast16_t = int rbx.platform.typedef.int_fast32_t = int rbx.platform.typedef.int_fast64_t = long_long -rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.int_fast8_t = char +rbx.platform.typedef.int_least16_t = short +rbx.platform.typedef.int_least32_t = int +rbx.platform.typedef.int_least64_t = long_long +rbx.platform.typedef.int_least8_t = char +rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.intptr_t = long_long +rbx.platform.typedef.key_t = long_long +rbx.platform.typedef.loff_t = long_long +rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.nlink_t = ushort +rbx.platform.typedef.off_t = long_long +rbx.platform.typedef.pid_t = int +rbx.platform.typedef.ptrdiff_t = long_long +rbx.platform.typedef.register_t = int +rbx.platform.typedef.rlim_t = ulong +rbx.platform.typedef.sa_family_t = ushort +rbx.platform.typedef.sig_atomic_t = int +rbx.platform.typedef.sigset_t = ulong +rbx.platform.typedef.size_t = ulong_long +rbx.platform.typedef.socklen_t = int +rbx.platform.typedef.ssize_t = int +rbx.platform.typedef.suseconds_t = long +rbx.platform.typedef.time_t = long_long +rbx.platform.typedef.timer_t = ulong +rbx.platform.typedef.u_char = uchar +rbx.platform.typedef.u_int = uint +rbx.platform.typedef.u_int16_t = ushort +rbx.platform.typedef.u_int32_t = uint +rbx.platform.typedef.u_int64_t = ulong_long +rbx.platform.typedef.u_int8_t = uchar +rbx.platform.typedef.u_long = ulong +rbx.platform.typedef.u_short = ushort +rbx.platform.typedef.uid_t = ulong +rbx.platform.typedef.uint = uint +rbx.platform.typedef.uint16_t = ushort +rbx.platform.typedef.uint32_t = uint +rbx.platform.typedef.uint64_t = ulong_long +rbx.platform.typedef.uint8_t = uchar rbx.platform.typedef.uint_fast16_t = uint rbx.platform.typedef.uint_fast32_t = uint rbx.platform.typedef.uint_fast64_t = ulong_long -rbx.platform.typedef.intptr_t = long_long -rbx.platform.typedef.uintptr_t = ulong_long -rbx.platform.typedef.intmax_t = long_long +rbx.platform.typedef.uint_fast8_t = uchar +rbx.platform.typedef.uint_least16_t = ushort +rbx.platform.typedef.uint_least32_t = uint +rbx.platform.typedef.uint_least64_t = ulong_long +rbx.platform.typedef.uint_least8_t = uchar rbx.platform.typedef.uintmax_t = ulong_long -rbx.platform.typedef.off_t = long_long -rbx.platform.typedef.loff_t = long_long -rbx.platform.typedef.__dev16_t = short -rbx.platform.typedef.__dev32_t = ulong -rbx.platform.typedef._dev_t = uint -rbx.platform.typedef.dev_t = uint -rbx.platform.typedef.blksize_t = long -rbx.platform.typedef.__blkcnt32_t = long -rbx.platform.typedef.__blkcnt64_t = long_long -rbx.platform.typedef.blkcnt_t = long_long -rbx.platform.typedef.fsblkcnt_t = ulong -rbx.platform.typedef.fsfilcnt_t = ulong -rbx.platform.typedef.__uid16_t = ushort -rbx.platform.typedef.__uid32_t = ulong -rbx.platform.typedef.uid_t = ulong -rbx.platform.typedef.__gid16_t = ushort -rbx.platform.typedef.__gid32_t = ulong -rbx.platform.typedef.gid_t = ulong -rbx.platform.typedef.__ino32_t = ulong -rbx.platform.typedef.__ino64_t = ulong_long -rbx.platform.typedef.ino_t = ushort -rbx.platform.typedef._ino_t = ushort -rbx.platform.typedef.id_t = ulong -rbx.platform.typedef.key_t = long_long +rbx.platform.typedef.uintptr_t = ulong_long +rbx.platform.typedef.ulong = ulong +rbx.platform.typedef.useconds_t = ulong +rbx.platform.typedef.ushort = ushort rbx.platform.typedef.vm_offset_t = ulong rbx.platform.typedef.vm_size_t = ulong -rbx.platform.typedef.u_int8_t = uchar -rbx.platform.typedef.u_int16_t = ushort -rbx.platform.typedef.u_int32_t = uint -rbx.platform.typedef.u_int64_t = ulong_long -rbx.platform.typedef.register_t = int -rbx.platform.typedef.*addr_t = char -rbx.platform.typedef.socklen_t = int -rbx.platform.typedef.sa_family_t = ushort -rbx.platform.typedef.__ULong = ulong -rbx.platform.typedef.sigset_t = ulong -rbx.platform.typedef.sig_atomic_t = int -rbx.platform.typedef.rlim_t = ulong -rbx.platform.typedef._sigset_t = ulong_long -rbx.platform.typedef.__time32_t = long -rbx.platform.typedef.__time64_t = long_long -rbx.platform.typedef.errno_t = int -rbx.platform.typedef._mode_t = ushort -rbx.platform.typedef.mode_t = ushort +rbx.platform.typedef.wchar_t = ushort +rbx.platform.typedef.wctype_t = ushort +rbx.platform.typedef.wint_t = uint diff --git a/lib/ruby/stdlib/ffi/platform/zlib.rb.ffi b/lib/ruby/stdlib/ffi/platform/zlib.rb.ffi deleted file mode 100644 index 6bfa9ca2714..00000000000 --- a/lib/ruby/stdlib/ffi/platform/zlib.rb.ffi +++ /dev/null @@ -1,1467 +0,0 @@ -## -# The Zlib module contains several classes for compressing and decompressing -# streams, and for working with "gzip" files. -# -# == Classes -# -# Following are the classes that are most likely to be of interest to the -# user: -# - Zlib::Inflate -# - Zlib::Deflate -# - Zlib::GzipReader -# - Zlib::GzipWriter -# -# There are two important base classes for the classes above: Zlib::ZStream -# and Zlib::GzipFile. Everything else is an error class. -# -# == Constants -# -# Here's a list. -# -# Zlib::VERSION -# The Ruby/zlib version string. -# -# Zlib::ZLIB_VERSION -# The string which represents the version of zlib.h. -# -# Zlib::BINARY -# Zlib::ASCII -# Zlib::UNKNOWN -# The integers representing data types which Zlib::ZStream#data_type -# method returns. -# -# Zlib::NO_COMPRESSION -# Zlib::BEST_SPEED -# Zlib::BEST_COMPRESSION -# Zlib::DEFAULT_COMPRESSION -# The integers representing compression levels which are an argument -# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. -# -# Zlib::FILTERED -# Zlib::HUFFMAN_ONLY -# Zlib::DEFAULT_STRATEGY -# The integers representing compression methods which are an argument -# for Zlib::Deflate.new and Zlib::Deflate#params. -# -# Zlib::DEF_MEM_LEVEL -# Zlib::MAX_MEM_LEVEL -# The integers representing memory levels which are an argument for -# Zlib::Deflate.new, Zlib::Deflate#params, and so on. -# -# Zlib::MAX_WBITS -# The default value of windowBits which is an argument for -# Zlib::Deflate.new and Zlib::Inflate.new. -# -# Zlib::NO_FLUSH -# Zlib::SYNC_FLUSH -# Zlib::FULL_FLUSH -# Zlib::FINISH -# The integers to control the output of the deflate stream, which are -# an argument for Zlib::Deflate#deflate and so on. -#-- -# These constants are missing! -# -# Zlib::OS_CODE -# Zlib::OS_MSDOS -# Zlib::OS_AMIGA -# Zlib::OS_VMS -# Zlib::OS_UNIX -# Zlib::OS_VMCMS -# Zlib::OS_ATARI -# Zlib::OS_OS2 -# Zlib::OS_MACOS -# Zlib::OS_ZSYSTEM -# Zlib::OS_CPM -# Zlib::OS_TOPS20 -# Zlib::OS_WIN32 -# Zlib::OS_QDOS -# Zlib::OS_RISCOS -# Zlib::OS_UNKNOWN -# The return values of Zlib::GzipFile#os_code method. - -module Zlib - - @@@ - constants :required => true do |c| - c.include 'zlib.h' - - c.const 'ZLIB_VERSION', '%s', '(char *)', nil, to_s - - c.const 'Z_NO_FLUSH', nil, nil, 'NO_FLUSH' - c.const 'Z_PARTIAL_FLUSH', nil, nil, 'PARTIAL_FLUSH' - c.const 'Z_SYNC_FLUSH', nil, nil, 'SYNC_FLUSH' - c.const 'Z_FULL_FLUSH', nil, nil, 'FULL_FLUSH' - c.const 'Z_FINISH', nil, nil, 'FINISH' - c.const 'Z_BLOCK', nil, nil, 'BLOCK' - - c.const 'Z_OK', nil, nil, 'OK' - c.const 'Z_STREAM_END', nil, nil, 'STREAM_END' - c.const 'Z_NEED_DICT', nil, nil, 'NEED_DICT' - c.const 'Z_ERRNO', nil, nil, 'ERRNO' - c.const 'Z_STREAM_ERROR', nil, nil, 'STREAM_ERROR' - c.const 'Z_DATA_ERROR', nil, nil, 'DATA_ERROR' - c.const 'Z_MEM_ERROR', nil, nil, 'MEM_ERROR' - c.const 'Z_BUF_ERROR', nil, nil, 'BUF_ERROR' - c.const 'Z_VERSION_ERROR', nil, nil, 'VERSION_ERROR' - - c.const 'Z_NO_COMPRESSION', nil, nil, 'NO_COMPRESSION' - c.const 'Z_BEST_SPEED', nil, nil, 'BEST_SPEED' - c.const 'Z_BEST_COMPRESSION', nil, nil, 'BEST_COMPRESSION' - c.const 'Z_DEFAULT_COMPRESSION', nil, nil, 'DEFAULT_COMPRESSION' - - c.const 'Z_FILTERED', nil, nil, 'FILTERED' - c.const 'Z_HUFFMAN_ONLY', nil, nil, 'HUFFMAN_ONLY' - c.const 'Z_RLE', nil, nil, 'RLE' - c.const 'Z_FIXED', nil, nil, 'FIXED' - c.const 'Z_DEFAULT_STRATEGY', nil, nil, 'DEFAULT_STRATEGY' - - c.const 'Z_DEFLATED', nil, nil, 'DEFLATED' - end - @@@ - - @@@ - constants do |c| - c.include 'zconf.h' - - c.const 'MAX_WBITS' - c.const 'MAX_MEM_LEVEL' - c.const 'DEF_MEM_LEVEL' - end - @@@ - - OS_MSDOS = 0x00 - OS_AMIGA = 0x01 - OS_VMS = 0x02 - OS_UNIX = 0x03 - OS_ATARI = 0x05 - OS_OS2 = 0x06 - OS_MACOS = 0x07 - OS_TOPS20 = 0x0a - OS_WIN32 = 0x0b - - OS_VMCMS = 0x04 - OS_ZSYSTEM = 0x08 - OS_CPM = 0x09 - OS_QDOS = 0x0c - OS_RISCOS = 0x0d - OS_UNKNOWN = 0xff - - @@@ - constants do |c| - c.include 'zlib.h' - - c.const 'OS_CODE' - end - @@@ - - unless defined? OS_CODE then - OS_CODE = OS_UNIX - end - - # from zutil.h - unless defined? DEF_MEM_LEVEL then - DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL - end - - class Error < StandardError; end - - class StreamEnd < Error; end - class NeedDict < Error; end - class StreamError < Error; end - class DataError < Error; end - class BufError < Error; end - class VersionError < Error; end - class MemError < Error; end - - ## - # Zlib::ZStream is the abstract class for the stream which handles the - # compressed data. The operations are defined in the subclasses: - # Zlib::Deflate for compression, and Zlib::Inflate for decompression. - # - # An instance of Zlib::ZStream has one stream (struct zstream in the source) - # and two variable-length buffers which associated to the input (next_in) of - # the stream and the output (next_out) of the stream. In this document, - # "input buffer" means the buffer for input, and "output buffer" means the - # buffer for output. - # - # Data input into an instance of Zlib::ZStream are temporally stored into - # the end of input buffer, and then data in input buffer are processed from - # the beginning of the buffer until no more output from the stream is - # produced (i.e. until avail_out > 0 after processing). During processing, - # output buffer is allocated and expanded automatically to hold all output - # data. - # - # Some particular instance methods consume the data in output buffer and - # return them as a String. - # - # Here is an ascii art for describing above: - # - # +================ an instance of Zlib::ZStream ================+ - # || || - # || +--------+ +-------+ +--------+ || - # || +--| output |<---------|zstream|<---------| input |<--+ || - # || | | buffer | next_out+-------+next_in | buffer | | || - # || | +--------+ +--------+ | || - # || | | || - # +===|======================================================|===+ - # | | - # v | - # "output data" "input data" - # - # If an error occurs during processing input buffer, an exception which is a - # subclass of Zlib::Error is raised. At that time, both input and output - # buffer keep their conditions at the time when the error occurs. - # - # == Method Catalogue - # - # Many of the methods in this class are fairly low-level and unlikely to be - # of interest to users. In fact, users are unlikely to use this class - # directly; rather they will be interested in Zlib::Inflate and - # Zlib::Deflate. - # - # The higher level methods are listed below. - # - # - #total_in - # - #total_out - # - #data_type - # - #adler - # - #reset - # - #finish - # - #finished? - # - #close - # - #closed? - - class ZStream < FFI::Struct - - @@@ - struct do |s| - s.include "zlib.h" - - s.name "struct z_stream_s" - s.field :next_in, :pointer - s.field :avail_in, :uint - s.field :total_in, :ulong - - s.field :next_out, :pointer - s.field :avail_out, :uint - s.field :total_out, :ulong - - s.field :msg, :string - s.field :state, :pointer - - s.field :zalloc, :pointer - s.field :zfree, :pointer - s.field :opaque, :pointer - - s.field :data_type, :int - s.field :adler, :ulong - s.field :reserved, :ulong - end - @@@ - - #-- - # HACK from MRI's zlib.c - #++ - - READY = 0x1 - IN_STREAM = 0x2 - FINISHED = 0x4 - CLOSING = 0x8 - UNUSED = 0x10 - - attr_accessor :flags - - attr_reader :input - - attr_reader :output - - def self.inherited(subclass) - subclass.instance_variable_set :@layout, @layout - subclass.instance_variable_set :@size, @size - end - - def initialize - super - - self[:avail_in] = 0 - self[:avail_out] = 0 - self[:next_in] = nil - self[:opaque] = nil - self[:zalloc] = nil - self[:zfree] = nil - - reset_input - @output = nil - @flags = 0 - @func = nil - end - - def closing? - @flags & CLOSING == CLOSING - end - - def detatch_output - if @output.nil? then - data = '' - else - data = @output - - @output = nil - self[:avail_out] = 0 - self[:next_out] = nil - end - - data - end - - ## - # Closes the stream. All operations on the closed stream will raise an - # exception. - - def end - unless ready? then - warn "attempt to close uninitialized stream; ignored." - return nil - end - - if in_stream? then - warn "attempt to close unfinished zstream; reset forced" - reset - end - - reset_input - - err = Zlib.send @func_end, pointer - - Zlib.handle_error err, message - - @flags = 0 - - # HACK this may be wrong - @output = nil - @next_out.free unless @next_out.nil? - @next_out = nil - - nil - end - - alias :close :end - - def expand_output - if @output.nil? then - @output = '' - @next_out = MemoryPointer.new CHUNK if @next_out.nil? - @next_out.write_string "\000" * CHUNK - self[:next_out] = @next_out - else - have = CHUNK - self[:avail_out] - @output << @next_out.read_string(have) - - self[:next_out] = @next_out # Zlib advances self[:next_out] - end - - self[:avail_out] = CHUNK - end - - ## - # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish - # and Zlib::Inflate#finish for details of this behavior. - - def finish - run '', Zlib::FINISH - - detatch_output - end - - ## - # Returns true if the stream is finished. - - def finished? - @flags & FINISHED == FINISHED - end - - ## - # Flushes output buffer and returns all data in that buffer. - - def flush_next_out - detatch_output - end - - def in_stream? - @flags & IN_STREAM == IN_STREAM - end - - def input_empty? - @input.nil? or @input.empty? - end - - ## - # The msg field of the struct - - def message - self[:msg] - end - - def ready - @flags |= READY - end - - def ready? - @flags & READY == READY - end - - ## - # Resets and initializes the stream. All data in both input and output - # buffer are discarded. - - def reset - err = Zlib.send @func_reset, pointer - - Zlib.handle_error err, message - - @flags = READY - - reset_input - end - - def reset_input - @input = nil - end - - def run(data, flush) - if @input.nil? and data.empty? then - data_in = MemoryPointer.new 1 - data_in.write_string "\000", 1 - self[:next_in] = data_in - self[:avail_in] = 0 - else - @input ||= '' - @input << data - - data_in = MemoryPointer.new @input.length - data_in.write_string @input, @input.length - self[:next_in] = data_in - self[:avail_in] = @input.length - end - - expand_output if self[:avail_out] == 0 - - loop do - err = Zlib.send @func_run, pointer, flush - - available = self[:avail_out] - - expand_output # HACK does this work when err is set? - - if err == Zlib::STREAM_END then - @flags &= ~IN_STREAM - @flags |= FINISHED - break - end - - unless err == Zlib::OK then - if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and - self[:avail_out] > 0 then - @flags |= IN_STREAM - break - end - - if self[:avail_in] > 0 then - @input = self[:next_in].read_string(self[:avail_in]) + @input - end - - Zlib.handle_error err, message - end - - if available > 0 then - @flags |= IN_STREAM - break - end - end - - reset_input - - if self[:avail_in] > 0 then - @input = self[:next_in].read_string self[:avail_in] - end - ensure - data_in.free - self[:next_in] = nil - end - - ## - # Returns the number of bytes consumed - - def total_in - self[:total_in] - end - - ## - # Returns the number bytes processed - - def total_out - self[:total_out] - end - - end - - set_ffi_lib 'libz' - - # deflateInit2 is a macro pointing to deflateInit2_ - attach_function :deflateInit2_, [ - :pointer, # z_streamp strm - :int, # int level - :int, # int method - :int, # int windowBits - :int, # int memLevel - :int, # int strategy - :string, # ZLIB_VERSION - :int # (int)sizeof(z_stream) - ], :int - - def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) - deflateInit2_ stream, level, method, window_bits, mem_level, strategy, - ZLIB_VERSION, ZStream.size - end - - attach_function :deflate, [:pointer, :int], :int - attach_function :deflateEnd, [:pointer], :int - attach_function :deflateParams, [:pointer, :int, :int], - :int - attach_function :deflateReset, [:pointer], :int - attach_function :deflateSetDictionary, - [:pointer, :string, :uint], :int - - # inflateInit2 is a macro pointing to inflateInit2_ - attach_function :inflateInit2_, - [:pointer, :int, :string, :int], :int - - def self.inflateInit2(stream, window_bits) - inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size - end - - attach_function :inflate, [:pointer, :int], :int - attach_function :inflateEnd, [:pointer], :int - attach_function :inflateReset, [:pointer], :int - attach_function :inflateSetDictionary, - [:pointer, :string, :uint], :int - - attach_function :adler32_c, :adler32, [:ulong, :string, :uint], - :ulong - attach_function :crc32_c, :crc32, [:ulong, :string, :uint], - :ulong - attach_function :get_crc_table_c, :get_crc_table, [], :pointer - - attach_function :zError, [:int], :string - - # Chunk size for inflation and deflation - - CHUNK = 1024 - - #-- - # HACK from zlib.c - #++ - - GZ_EXTRAFLAG_FAST = 0x4 - GZ_EXTRAFLAG_SLOW = 0x2 - - ## - # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for - # more information. - - class Deflate < ZStream - - ## - # Compresses the given +string+. Valid values of level are - # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, - # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and - # an integer from 0 to 9. - # - # This method is almost equivalent to the following code: - # - # def deflate(string, level) - # z = Zlib::Deflate.new(level) - # dst = z.deflate(string, Zlib::FINISH) - # z.close - # dst - # end - - def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) - deflator = new level - - zipped = deflator.deflate data, Zlib::FINISH - - zipped - ensure - deflator.end - end - - ## - # Creates a new deflate stream for compression. See zlib.h for details of - # each argument. If an argument is nil, the default value of that argument - # is used. - - def initialize(level = Zlib::DEFAULT_COMPRESSION, - window_bits = Zlib::MAX_WBITS, - mem_level = Zlib::DEF_MEM_LEVEL, - strategy = Zlib::DEFAULT_STRATEGY) - level ||= Zlib::DEFAULT_COMPRESSION - window_bits ||= Zlib::MAX_WBITS - mem_level ||= Zlib::DEF_MEM_LEVEL - strategy ||= Zlib::DEFAULT_STRATEGY - - super() - - @func_end = :deflateEnd - @func_reset = :deflateReset - @func_run = :deflate - - err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, - window_bits, mem_level, strategy) - - Zlib.handle_error err, message - - ready - end - - ## - # Same as IO. - - def <<(data) - do_deflate data, Zlib::NO_FLUSH - - self - end - - ## - # Inputs +string+ into the deflate stream and returns the output from the - # stream. On calling this method, both the input and the output buffers - # of the stream are flushed. If +string+ is nil, this method finishes the - # stream, just like Zlib::ZStream#finish. - # - # The value of +flush+ should be either Zlib::NO_FLUSH, - # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or - # Zlib::FINISH. See zlib.h for details. - - def deflate(data, flush = Zlib::NO_FLUSH) - do_deflate data, flush - - detatch_output - end - - ## - # Performs the deflate operation and leaves the compressed data in the - # output buffer - - def do_deflate(data, flush) - if data.nil? then - run '', Zlib::FINISH - else - data = StringValue data - - if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR - run data, flush - end - end - end - - ## - # Finishes compressing the deflate input stream and returns the output - # buffer. - - def finish - run '', Zlib::FINISH - - detatch_output - end - - ## - # This method is equivalent to deflate('', flush). If flush is - # omitted, Zlib::SYNC_FLUSH is used as flush. This method is - # just provided to improve the readability of your Ruby program. - - def flush(flush = Zlib::SYNC_FLUSH) - run '', flush unless flush == Zlib::NO_FLUSH - - detatch_output - end - - ## - # Changes the parameters of the deflate stream. See zlib.h for details. - # The output from the stream by changing the params is preserved in output - # buffer. - - def params(level, strategy) - err = Zlib.deflateParams pointer, level, strategy - - raise Zlib::BufError, 'buffer expansion not implemented' if - err == Zlib::BUF_ERROR - - Zlib.handle_error err, message - - nil - end - - ## - # Sets the preset dictionary and returns +dictionary+. This method is - # available just only after Zlib::Deflate.new or Zlib::ZStream#reset - # method was called. See zlib.h for details. - - def set_dictionary(dictionary) - dict = StringValue dictionary - - err = Zlib.deflateSetDictionary pointer, dict, dict.length - - Zlib.handle_error err, message - - dictionary - end - - end - - ## - # Zlib::GzipFile is an abstract class for handling a gzip formatted - # compressed file. The operations are defined in the subclasses, - # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. - # - # GzipReader should be used by associating an IO, or IO-like, object. - - class GzipFile - - SYNC = Zlib::ZStream::UNUSED - HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 - FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 - - FLAG_MULTIPART = 0x2 - FLAG_EXTRA = 0x4 - FLAG_ORIG_NAME = 0x8 - FLAG_COMMENT = 0x10 - FLAG_ENCRYPT = 0x20 - FLAG_UNKNOWN_MASK = 0xc0 - - EXTRAFLAG_FAST = 0x4 - EXTRAFLAG_SLOW = 0x2 - - MAGIC1 = 0x1f - MAGIC2 = 0x8b - METHOD_DEFLATE = 8 - - ## - # Base class of errors that occur when processing GZIP files. - - class Error < Zlib::Error; end - - ## - # Raised when gzip file footer is not found. - - class NoFooter < Error; end - - ## - # Raised when the CRC checksum recorded in gzip file footer is not - # equivalent to the CRC checksum of the actual uncompressed data. - - class CRCError < Error; end - - ## - # Raised when the data length recorded in the gzip file footer is not - # equivalent to the length of the actual uncompressed data. - - class LengthError < Error; end - - ## - # Accessor for the underlying ZStream - - attr_reader :zstream # :nodoc: - - ## - # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. - - def self.wrap(*args) - obj = new(*args) - - if block_given? then - begin - yield obj - ensure - obj.close if obj.zstream.ready? - end - end - end - - def initialize - @comment = nil - @crc = 0 - @level = nil - @mtime = Time.at 0 - @orig_name = nil - @os_code = Zlib::OS_CODE - end - - ## - # Closes the GzipFile object. This method calls close method of the - # associated IO object. Returns the associated IO object. - - def close - io = finish - - io.close if io.respond_to? :close - - io - end - - ## - # Same as IO - - def closed? - @io.nil? - end - - ## - # Returns comments recorded in the gzip file header, or nil if the - # comment is not present. - - def comment - raise Error, 'closed gzip stream' if @io.nil? - - @comment.dup - end - - def end - return if @zstream.closing? - - @zstream.flags |= Zlib::ZStream::CLOSING - - begin - end_run - ensure - @zstream.end - end - end - - ## - # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method - # never calls the close method of the associated IO object. Returns the - # associated IO object. - - def finish - self.end - - io = @io - @io = nil - @orig_name = nil - @comment = nil - - io - end - - def finished? - @zstream.finished? and @zstream.output.empty? # HACK I think - end - - def footer_finished? - @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == - Zlib::GzipFile::FOOTER_FINISHED - end - - def header_finished? - @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == - Zlib::GzipFile::HEADER_FINISHED - end - - ## - # Returns last modification time recorded in the gzip file header. - - def mtime - Time.at @mtime - end - - ## - # Returns original filename recorded in the gzip file header, or +nil+ if - # original filename is not present. - - def orig_name - raise Error, 'closed gzip stream' if @io.nil? - - @orig_name.dup - end - - end - - ## - # Zlib::GzipReader is the class for reading a gzipped file. GzipReader - # should be used an IO, or -IO-lie, object. - # - # Zlib::GzipReader.open('hoge.gz') {|gz| - # print gz.read - # } - # - # File.open('hoge.gz') do |f| - # gz = Zlib::GzipReader.new(f) - # print gz.read - # gz.close - # end - # - # == Method Catalogue - # - # The following methods in Zlib::GzipReader are just like their counterparts - # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an - # error was found in the gzip file. - # - # - #each - # - #each_line - # - #each_byte - # - #gets - # - #getc - # - #lineno - # - #lineno= - # - #read - # - #readchar - # - #readline - # - #readlines - # - #ungetc - # - # Be careful of the footer of the gzip file. A gzip file has the checksum of - # pre-compressed data in its footer. GzipReader checks all uncompressed data - # against that checksum at the following cases, and if it fails, raises - # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or - # Zlib::GzipFile::LengthError exception. - # - # - When an reading request is received beyond the end of file (the end of - # compressed data). That is, when Zlib::GzipReader#read, - # Zlib::GzipReader#gets, or some other methods for reading returns nil. - # - When Zlib::GzipFile#close method is called after the object reaches the - # end of file. - # - When Zlib::GzipReader#unused method is called after the object reaches - # the end of file. - # - # The rest of the methods are adequately described in their own - # documentation. - - class GzipReader < GzipFile # HACK use a buffer class - - ## - # Creates a GzipReader object associated with +io+. The GzipReader object - # reads gzipped data from +io+, and parses/decompresses them. At least, - # +io+ must have a +read+ method that behaves same as the +read+ method in - # IO class. - # - # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error - # exception. - - def initialize(io) - @io = io - - @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS - - @buffer = '' - - super() - - read_header - end - - def check_footer - @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED - - footer = @zstream.input.slice! 0, 8 - rest = @io.read 8 - footer.length - footer << rest if rest - - raise NoFooter, 'footer is not found' unless footer.length == 8 - - crc, length = footer.unpack 'VV' - - @zstream[:total_in] += 8 # to rewind correctly - - raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc - - raise LengthError, 'invalid compressed data -- length error' unless - length == @zstream.total_out - end - - def end_run - check_footer if @zstream.finished? and not footer_finished? - end - - def eof? - @zstream.finished? and @zstream.input_empty? - end - - def pos - @zstream[:total_out] - @buffer.length - end - - ## - # See Zlib::GzipReader documentation for a description. - - def read(length = nil) - data = @buffer - - while chunk = @io.read(CHUNK) do - inflated = @zstream.inflate(chunk) - @crc = Zlib.crc32 inflated, @crc - data << inflated - - break if length and data.length > length - end - - if length then - @buffer = data.slice! length..-1 - else - @buffer = '' - end - - check_footer if @zstream.finished? and not footer_finished? - - data - rescue Zlib::Error => e - raise GzipFile::Error, e.message - end - - def read_header - header = @io.read 10 - - raise Error, 'not in gzip format' unless header.length == 10 - - magic1, magic2, method, flags, @mtime, extra_flags, @os_code = - header.unpack 'CCCCVCC' - - unless magic1 == Zlib::GzipFile::MAGIC1 and - magic2 == Zlib::GzipFile::MAGIC2 then - raise Error, 'not in gzip format' - end - - unless method == Zlib::GzipFile::METHOD_DEFLATE then - raise Error, "unsupported compression method #{method}" - end - - if flags & Zlib::GzipFile::FLAG_MULTIPART == - Zlib::GzipFile::FLAG_MULTIPART then - raise Error, 'multi-part gzip file is not supported' - end - - if flags & Zlib::GzipFile::FLAG_ENCRYPT == - Zlib::GzipFile::FLAG_ENCRYPT then - raise Error, 'encrypted gzip file is not supported' - end - - if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == - Zlib::GzipFile::FLAG_UNKNOWN_MASK then - raise Error, "unknown flags 0x#{flags.to_s 16}" - end - - if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == - Zlib::GzipFile::EXTRAFLAG_FAST then - @level = Zlib::BEST_SPEED - elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == - Zlib::GzipFile::EXTRAFLAG_SLOW then - @level = Zlib::BEST_COMPRESSION - else - @level = Zlib::DEFAULT_COMPRESSION - end - - if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then - length = @io.read 2 - raise Zlib::GzipFile::Error, 'unexpected end of file' if - length.nil? or length.length != 2 - - length, = length.unpack 'v' - - extra = @io.read length + 2 - - raise Zlib::GzipFile::Error, 'unexpected end of file' if - extra.nil? or extra.length != length + 2 - end - - if flags & Zlib::GzipFile::FLAG_ORIG_NAME == - Zlib::GzipFile::FLAG_ORIG_NAME then - @orig_name = '' - - c = @io.getc - - until c == 0 do - @orig_name << c.chr - c = @io.getc - end - end - - if flags & Zlib::GzipFile::FLAG_COMMENT == - Zlib::GzipFile::FLAG_COMMENT then - @comment = '' - - c = @io.getc - - until c == 0 do - @comment << c.chr - c = @io.getc - end - end - end - - end - - ## - # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should - # be used with an instance of IO, or IO-like, object. - # - # For example: - # - # Zlib::GzipWriter.open('hoge.gz') do |gz| - # gz.write 'jugemu jugemu gokou no surikire...' - # end - # - # File.open('hoge.gz', 'w') do |f| - # gz = Zlib::GzipWriter.new(f) - # gz.write 'jugemu jugemu gokou no surikire...' - # gz.close - # end - # - # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close - # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter - # will be not able to write the gzip footer and will generate a broken gzip - # file. - - class GzipWriter < GzipFile # HACK use a buffer class - - ## - # Set the comment - - attr_writer :comment - - ## - # Set the original name - - attr_writer :orig_name - - ## - # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ - # should be the same as the arguments of Zlib::Deflate.new. The - # GzipWriter object writes gzipped data to +io+. At least, +io+ must - # respond to the +write+ method that behaves same as write method in IO - # class. - - def initialize(io, level = Zlib::DEFAULT_COMPRESSION, - strategy = Zlib::DEFAULT_STRATEGY) - @io = io - - @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, - Zlib::DEF_MEM_LEVEL, strategy - - @buffer = '' - - super() - end - - def end_run - make_header unless header_finished? - - @zstream.run '', Zlib::FINISH - - write_raw - - make_footer - - nil - end - - ## - # Flushes all the internal buffers of the GzipWriter object. The meaning - # of +flush+ is same as in Zlib::Deflate#deflate. - # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use - # giving flush Zlib::NO_FLUSH. - - def flush - true - end - - ## - # Writes out a gzip header - - def make_header - flags = 0 - extra_flags = 0 - - flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name - flags |= Zlib::GzipFile::FLAG_COMMENT if @comment - - extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if - @level == Zlib::BEST_SPEED - - extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if - @level == Zlib::BEST_COMPRESSION - - header = [ - Zlib::GzipFile::MAGIC1, # byte 0 - Zlib::GzipFile::MAGIC2, # byte 1 - Zlib::GzipFile::METHOD_DEFLATE, # byte 2 - flags, # byte 3 - @mtime.to_i, # bytes 4-7 - extra_flags, # byte 8 - @os_code # byte 9 - ].pack 'CCCCVCC' - - @io.write header - - @io.write "#{@orig_name}\0" if @orig_name - @io.write "#{@comment}\0" if @comment - - @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED - end - - ## - # Writes out a gzip footer - - def make_footer - footer = [ - @crc, # bytes 0-3 - @zstream.total_in, # bytes 4-7 - ].pack 'VV' - - @io.write footer - - @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED - end - - ## - # Sets the modification time of this file - - def mtime=(time) - if header_finished? then - raise Zlib::GzipFile::Error, 'header is already written' - end - - @mtime = Integer time - end - - def sync? - @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC - end - - ## - # Same as IO. - - def write(data) - make_header unless header_finished? - - data = String data - - if data.length > 0 or sync? then - @crc = Zlib.crc32_c @crc, data, data.length - - flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH - - @zstream.run data, flush - end - - write_raw - end - - ## - # Same as IO. - - alias << write - - def write_raw - data = @zstream.detatch_output - - unless data.empty? then - @io.write data - @io.flush if sync? and io.respond_to :flush - end - end - - end - - ## - # Zlib:Inflate is the class for decompressing compressed data. Unlike - # Zlib::Deflate, an instance of this class is not able to duplicate (clone, - # dup) itself. - - class Inflate < ZStream - - ## - # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset - # dictionary is needed for decompression. - # - # This method is almost equivalent to the following code: - # - # def inflate(string) - # zstream = Zlib::Inflate.new - # buf = zstream.inflate(string) - # zstream.finish - # zstream.close - # buf - # end - - def self.inflate(data) - inflator = new - - unzipped = inflator.inflate data - - unzipped - ensure - inflator.end - end - - ## - # Creates a new inflate stream for decompression. See zlib.h for details - # of the argument. If +window_bits+ is +nil+, the default value is used. - - def initialize(window_bits = Zlib::MAX_WBITS) - super() - - @func_end = :inflateEnd - @func_reset = :inflateReset - @func_run = :inflate - - err = Zlib.inflateInit2 pointer, window_bits - - Zlib.handle_error err, message # HACK - - ready - end - - ## - # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, - # but returns the Zlib::Inflate object itself. The output from the stream - # is preserved in output buffer. - - def <<(string) - string = StringValue string unless string.nil? - - if finished? then - unless string.nil? then - @input ||= '' - @input << string - end - else - run string, Zlib::SYNC_FLUSH - end - end - - ## - # Inputs +string+ into the inflate stream and returns the output from the - # stream. Calling this method, both the input and the output buffer of - # the stream are flushed. If string is +nil+, this method finishes the - # stream, just like Zlib::ZStream#finish. - # - # Raises a Zlib::NeedDict exception if a preset dictionary is needed to - # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then - # call this method again with an empty string. (???) - - def inflate(data) - data = Type.coerce_to data, String, :to_str unless data.nil? - - if finished? then - if data.nil? then - unzipped = detatch_output - else - @input ||= '' - @input << data - - unzipped = '' - end - else - if data.nil? then - run '', Zlib::FINISH - elsif not data.empty? then - run data, Zlib::SYNC_FLUSH - end - - unzipped = detatch_output - - if finished? and not @input.nil? then - expand_output - end - end - - unzipped - end - - ## - # Sets the preset dictionary and returns +string+. This method is - # available just only after a Zlib::NeedDict exception was raised. See - # zlib.h for details. - - def set_dictionary(dictionary) - dict = StringValue dictionary - - err = Zlib.inflateSetDictionary pointer, dict, dict.length - - Zlib.handle_error err, message - - dictionary - end - - end - - ## - # Calculates Alder-32 checksum for +string+, and returns updated value of - # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If - # +adler+ is omitted, it assumes that the initial value is given to +adler+. - - def self.adler32(string = "", sum = 1) - do_checksum(string, sum, :adler32_c) - end - - ## - # Returns the table for calculating CRC checksum as an array. - - def self.crc_table - get_crc_table_c.read_array_of_long(256).map do |x| - x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned - end - end - - ## - # Calculates CRC checksum for +string+, and returns updated value of +crc+. - # If +string+ is omitted, it returns the CRC initial value. If +crc+ is - # omitted, it assumes that the initial value is given to +crc+. - - def self.crc32(string = "", sum = 0) - do_checksum(string, sum, :crc32_c) - end - - ## - # Generates a checksum using function +type+ - - def self.do_checksum(string, vsum, type) - if vsum - raise RangeError if vsum >= (2 ** 128) - raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0 - sum = vsum - elsif string.nil? - sum = 0 - else - sum = send(type, 0, nil, 0) - end - - send(type, sum, string, string ? string.size : 0) - end - - ## - # Raises an exception of the appropriate class - - def self.handle_error(error, message = nil) - return if error == Zlib::OK - - message = zError error if message.nil? - - klass = case error - when Zlib::STREAM_END then Zlib::StreamEnd - when Zlib::NEED_DICT then Zlib::NeedDict - when Zlib::STREAM_ERROR then Zlib::StreamError - when Zlib::DATA_ERROR then Zlib::DataError - when Zlib::BUF_ERROR then Zlib::BufError - when Zlib::MEM_ERROR then Zlib::MemError - when Errno then Errno.handle message - else - message = "unknown zlib error #{error}: #{message}" - Zlib::Error - end - - raise klass, message - end - -end - diff --git a/lib/ruby/stdlib/ffi/pointer.rb b/lib/ruby/stdlib/ffi/pointer.rb index 2fc510df54b..064cf820dfb 100644 --- a/lib/ruby/stdlib/ffi/pointer.rb +++ b/lib/ruby/stdlib/ffi/pointer.rb @@ -1 +1,160 @@ -# All FFI::Pointer functionality is implemented in java +# +# Copyright (C) 2008, 2009 Wayne Meissner +# Copyright (c) 2007, 2008 Evan Phoenix +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +require 'ffi/platform' +module FFI + class Pointer + + # Pointer size + SIZE = Platform::ADDRESS_SIZE / 8 + + # Return the size of a pointer on the current platform, in bytes + # @return [Numeric] + def self.size + SIZE + end + + # @param [nil,Numeric] len length of string to return + # @return [String] + # Read pointer's contents as a string, or the first +len+ bytes of the + # equivalent string if +len+ is not +nil+. + def read_string(len=nil) + if len + return ''.b if len == 0 + get_bytes(0, len) + else + get_string(0) + end + end + + # @param [Numeric] len length of string to return + # @return [String] + # Read the first +len+ bytes of pointer's contents as a string. + # + # Same as: + # ptr.read_string(len) # with len not nil + def read_string_length(len) + get_bytes(0, len) + end + + # @return [String] + # Read pointer's contents as a string. + # + # Same as: + # ptr.read_string # with no len + def read_string_to_null + get_string(0) + end + + # @param [String] str string to write + # @param [Numeric] len length of string to return + # @return [self] + # Write +len+ first bytes of +str+ in pointer's contents. + # + # Same as: + # ptr.write_string(str, len) # with len not nil + def write_string_length(str, len) + put_bytes(0, str, 0, len) + end + + # @param [String] str string to write + # @param [Numeric] len length of string to return + # @return [self] + # Write +str+ in pointer's contents, or first +len+ bytes if + # +len+ is not +nil+. + def write_string(str, len=nil) + len = str.bytesize unless len + # Write the string data without NUL termination + put_bytes(0, str, 0, len) + end + + # @param [Type] type type of data to read from pointer's contents + # @param [Symbol] reader method to send to +self+ to read +type+ + # @param [Numeric] length + # @return [Array] + # Read an array of +type+ of length +length+. + # @example + # ptr.read_array_of_type(TYPE_UINT8, :read_uint8, 4) # -> [1, 2, 3, 4] + def read_array_of_type(type, reader, length) + ary = [] + size = FFI.type_size(type) + tmp = self + length.times { |j| + ary << tmp.send(reader) + tmp += size unless j == length-1 # avoid OOB + } + ary + end + + # @param [Type] type type of data to write to pointer's contents + # @param [Symbol] writer method to send to +self+ to write +type+ + # @param [Array] ary + # @return [self] + # Write +ary+ in pointer's contents as +type+. + # @example + # ptr.write_array_of_type(TYPE_UINT8, :put_uint8, [1, 2, 3 ,4]) + def write_array_of_type(type, writer, ary) + size = FFI.type_size(type) + ary.each_with_index { |val, i| + break unless i < self.size + self.send(writer, i * size, val) + } + self + end + + # @return [self] + def to_ptr + self + end + + # @param [Symbol,Type] type of data to read + # @return [Object] + # Read pointer's contents as +type+ + # + # Same as: + # ptr.get(type, 0) + def read(type) + get(type, 0) + end + + # @param [Symbol,Type] type of data to read + # @param [Object] value to write + # @return [nil] + # Write +value+ of type +type+ to pointer's content + # + # Same as: + # ptr.put(type, 0) + def write(type, value) + put(type, 0, value) + end + end +end diff --git a/lib/ruby/stdlib/ffi/rbx.rb b/lib/ruby/stdlib/ffi/rbx.rb deleted file mode 100644 index 6e7633bfe01..00000000000 --- a/lib/ruby/stdlib/ffi/rbx.rb +++ /dev/null @@ -1 +0,0 @@ -# This file intentionally left blank diff --git a/lib/ruby/stdlib/ffi/struct.rb b/lib/ruby/stdlib/ffi/struct.rb index 002dbe064dd..0d59eea6dd2 100644 --- a/lib/ruby/stdlib/ffi/struct.rb +++ b/lib/ruby/stdlib/ffi/struct.rb @@ -1,8 +1,9 @@ # -# Copyright (C) 2008, 2009 Wayne Meissner +# Copyright (C) 2008-2010 Wayne Meissner # Copyright (C) 2008, 2009 Andrea Fazzi # Copyright (C) 2008, 2009 Luc Heinrich -# Copyright (c) 2007, 2008 Evan Phoenix +# +# This file is part of ruby-ffi. # # All rights reserved. # @@ -14,7 +15,7 @@ # * Redistributions in binary form must reproduce the above copyright notice # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# * Neither the name of the Evan Phoenix nor the names of its contributors +# * Neither the name of the Ruby FFI project nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # @@ -28,20 +29,97 @@ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# require 'ffi/platform' +require 'ffi/struct_layout' require 'ffi/struct_layout_builder' +require 'ffi/struct_by_reference' module FFI class Struct + + # Get struct size + # @return [Numeric] + def size + self.class.size + end + + # @return [Fixnum] Struct alignment + def alignment + self.class.alignment + end alias_method :align, :alignment + # (see FFI::StructLayout#offset_of) + def offset_of(name) + self.class.offset_of(name) + end + + # (see FFI::StructLayout#members) + def members + self.class.members + end + + # @return [Array] + # Get array of values from Struct fields. + def values + members.map { |m| self[m] } + end + + # (see FFI::StructLayout#offsets) + def offsets + self.class.offsets + end + + # Clear the struct content. + # @return [self] + def clear + pointer.clear + self + end + + # Get {Pointer} to struct content. + # @return [AbstractMemory] + def to_ptr + pointer + end + + # Get struct size + # @return [Numeric] + def self.size + defined?(@layout) ? @layout.size : defined?(@size) ? @size : 0 + end + + # set struct size + # @param [Numeric] size + # @return [size] def self.size=(size) raise ArgumentError, "Size already set" if defined?(@size) || defined?(@layout) @size = size end + # @return (see Struct#alignment) + def self.alignment + @layout.alignment + end + + # (see FFI::Type#members) + def self.members + @layout.members + end + + # (see FFI::StructLayout#offsets) + def self.offsets + @layout.offsets + end + + # (see FFI::StructLayout#offset_of) + def self.offset_of(name) + @layout.offset_of(name) + end + def self.in ptr(:in) end @@ -68,6 +146,7 @@ def self.by_ref(flags = :inout) class ManagedStructConverter < StructByReference + # @param [Struct] struct_class def initialize(struct_class) super(struct_class) @@ -75,6 +154,9 @@ def initialize(struct_class) @method = struct_class.method(:release) end + # @param [Pointer] ptr + # @param [nil] ctx + # @return [Struct] def from_native(ptr, ctx) struct_class.new(AutoPointer.new(ptr, @method)) end @@ -88,7 +170,41 @@ def self.auto_ptr class << self public + # @return [StructLayout] + # @overload layout + # @return [StructLayout] + # Get struct layout. + # @overload layout(*spec) + # @param [Array,Array(Hash)] spec + # @return [StructLayout] + # Create struct layout from +spec+. + # @example Creating a layout from an array +spec+ + # class MyStruct < Struct + # layout :field1, :int, + # :field2, :pointer, + # :field3, :string + # end + # @example Creating a layout from an array +spec+ with offset + # class MyStructWithOffset < Struct + # layout :field1, :int, + # :field2, :pointer, 6, # set offset to 6 for this field + # :field3, :string + # end + # @example Creating a layout from a hash +spec+ (Ruby 1.9 only) + # class MyStructFromHash < Struct + # layout :field1 => :int, + # :field2 => :pointer, + # :field3 => :string + # end + # @example Creating a layout with pointers to functions + # class MyFunctionTable < Struct + # layout :function1, callback([:int, :int], :int), + # :function2, callback([:pointer], :void), + # :field3, :string + # end + # @note Creating a layout from a hash +spec+ is supported only for Ruby 1.9. def layout(*spec) + warn "[DEPRECATION] Struct layout is already defined for class #{self.inspect}. Redefinition as in #{caller[0]} will be disallowed in ffi-2.0." if defined?(@layout) return @layout if spec.size == 0 builder = StructLayoutBuilder.new @@ -101,12 +217,11 @@ def layout(*spec) else array_layout(builder, spec) end - builder.size = @size if defined?(@size) && @size > builder.size - layout = builder.build - @size = layout.size - self.layout = layout unless self == Struct - layout + cspec = builder.build + @layout = cspec unless self == Struct + @size = cspec.size + return cspec end @@ -121,7 +236,7 @@ def packed(packed = 1) @packed = packed end alias :pack :packed - + def aligned(alignment = 1) @min_alignment = alignment end @@ -131,7 +246,7 @@ def enclosing_module begin mod = self.name.split("::")[0..-2].inject(Object) { |obj, c| obj.const_get(c) } (mod < FFI::Library || mod < FFI::Struct || mod.respond_to?(:find_type)) ? mod : nil - rescue Exception => ex + rescue Exception nil end end @@ -160,13 +275,20 @@ def find_type(type, mod = enclosing_module) private + # @param [StructLayoutBuilder] builder + # @param [Hash] spec + # @return [builder] + # Add hash +spec+ to +builder+. def hash_layout(builder, spec) - raise "Ruby version not supported" if RUBY_VERSION =~ /1.8.*/ && !(RUBY_PLATFORM =~ /java/) spec[0].each do |name, type| builder.add name, find_field_type(type), nil - end end + end + # @param [StructLayoutBuilder] builder + # @param [Array] spec + # @return [builder] + # Add array +spec+ to +builder+. def array_layout(builder, spec) i = 0 while i < spec.size @@ -182,8 +304,8 @@ def array_layout(builder, spec) end builder.add name, find_field_type(type), offset - end end end end end +end diff --git a/lib/ruby/stdlib/ffi/struct_by_reference.rb b/lib/ruby/stdlib/ffi/struct_by_reference.rb new file mode 100644 index 00000000000..27f25eca771 --- /dev/null +++ b/lib/ruby/stdlib/ffi/struct_by_reference.rb @@ -0,0 +1,72 @@ +# +# Copyright (C) 2010 Wayne Meissner +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.# + +module FFI + # This class includes the {FFI::DataConverter} module. + class StructByReference + include DataConverter + + attr_reader :struct_class + + # @param [Struct] struct_class + def initialize(struct_class) + unless Class === struct_class and struct_class < FFI::Struct + raise TypeError, 'wrong type (expected subclass of FFI::Struct)' + end + @struct_class = struct_class + end + + # Always get {FFI::Type}::POINTER. + def native_type + FFI::Type::POINTER + end + + # @param [nil, Struct] value + # @param [nil] ctx + # @return [AbstractMemory] Pointer on +value+. + def to_native(value, ctx) + return Pointer::NULL if value.nil? + + unless @struct_class === value + raise TypeError, "wrong argument type #{value.class} (expected #{@struct_class})" + end + + value.pointer + end + + # @param [AbstractMemory] value + # @param [nil] ctx + # @return [Struct] + # Create a struct from content of memory +value+. + def from_native(value, ctx) + @struct_class.new(value) + end + end +end diff --git a/lib/ruby/stdlib/ffi/struct_layout.rb b/lib/ruby/stdlib/ffi/struct_layout.rb new file mode 100644 index 00000000000..d5a78a7a7d7 --- /dev/null +++ b/lib/ruby/stdlib/ffi/struct_layout.rb @@ -0,0 +1,96 @@ +# +# Copyright (C) 2008-2010 Wayne Meissner +# Copyright (C) 2008, 2009 Andrea Fazzi +# Copyright (C) 2008, 2009 Luc Heinrich +# +# This file is part of ruby-ffi. +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +module FFI + + class StructLayout + + # @return [Array + # Get an array of tuples (field name, offset of the field). + def offsets + members.map { |m| [ m, self[m].offset ] } + end + + # @return [Numeric] + # Get the offset of a field. + def offset_of(field_name) + self[field_name].offset + end + + # An enum {Field} in a {StructLayout}. + class Enum < Field + + # @param [AbstractMemory] ptr pointer on a {Struct} + # @return [Object] + # Get an object of type {#type} from memory pointed by +ptr+. + def get(ptr) + type.find(ptr.get_int(offset)) + end + + # @param [AbstractMemory] ptr pointer on a {Struct} + # @param value + # @return [nil] + # Set +value+ into memory pointed by +ptr+. + def put(ptr, value) + ptr.put_int(offset, type.find(value)) + end + + end + + class InnerStruct < Field + def get(ptr) + type.struct_class.new(ptr.slice(self.offset, self.size)) + end + + def put(ptr, value) + raise TypeError, "wrong value type (expected #{type.struct_class})" unless value.is_a?(type.struct_class) + ptr.slice(self.offset, self.size).__copy_from__(value.pointer, self.size) + end + end + + class Mapped < Field + def initialize(name, offset, type, orig_field) + super(name, offset, type) + @orig_field = orig_field + end + + def get(ptr) + type.from_native(@orig_field.get(ptr), nil) + end + + def put(ptr, value) + @orig_field.put(ptr, type.to_native(value, nil)) + end + end + end +end diff --git a/lib/ruby/stdlib/ffi/struct_layout_builder.rb b/lib/ruby/stdlib/ffi/struct_layout_builder.rb index 2d3e4fda40b..4d6a464103a 100644 --- a/lib/ruby/stdlib/ffi/struct_layout_builder.rb +++ b/lib/ruby/stdlib/ffi/struct_layout_builder.rb @@ -1,35 +1,41 @@ # # Copyright (C) 2008-2010 Wayne Meissner # -# Version: EPL 2.0/GPL 2.0/LGPL 2.1 +# This file is part of ruby-ffi. # -# The contents of this file are subject to the Common Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.eclipse.org/legal/cpl-v10.html +# All rights reserved. # -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: # -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the EPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the EPL, the GPL or the LGPL. +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # module FFI + + # Build a {StructLayout struct layout}. class StructLayoutBuilder - attr_reader :size, :alignment - + attr_reader :size + attr_reader :alignment + def initialize @size = 0 @alignment = 1 @@ -39,25 +45,49 @@ def initialize @fields = Array.new end + # Set size attribute with +size+ only if +size+ is greater than attribute value. + # @param [Numeric] size def size=(size) @size = size if size > @size end + # Set alignment attribute with +align+ only if it is greater than attribute value. + # @param [Numeric] align def alignment=(align) @alignment = align if align > @alignment @min_alignment = align end + # Set union attribute. + # Set to +true+ to build a {Union} instead of a {Struct}. + # @param [Boolean] is_union + # @return [is_union] def union=(is_union) @union = is_union end + # Building a {Union} or a {Struct} ? + # + # @return [Boolean] + # def union? @union end + # Set packed attribute + # @overload packed=(packed) Set alignment and packed attributes to + # +packed+. + # + # @param [Fixnum] packed + # + # @return [packed] + # @overload packed=(packed) Set packed attribute. + # @param packed + # + # @return [0,1] + # def packed=(packed) - if packed.is_a?(Fixnum) + if packed.is_a?(0.class) @alignment = packed @packed = packed else @@ -66,7 +96,8 @@ def packed=(packed) end - SCALAR_TYPES = [ + # List of number types + NUMBER_TYPES = [ Type::INT8, Type::UINT8, Type::INT16, @@ -79,9 +110,16 @@ def packed=(packed) Type::UINT64, Type::FLOAT32, Type::FLOAT64, + Type::LONGDOUBLE, Type::BOOL, ] + # @param [String, Symbol] name name of the field + # @param [Array, DataConverter, Struct, StructLayout::Field, Symbol, Type] type type of the field + # @param [Numeric, nil] offset + # @return [self] + # Add a field to the builder. + # @note Setting +offset+ to +nil+ or +-1+ is equivalent to +0+. def add(name, type, offset = nil) if offset.nil? || offset == -1 @@ -99,31 +137,53 @@ def add(name, type, offset = nil) return self end + # @param (see #add) + # @return (see #add) + # Same as {#add}. + # @see #add def add_field(name, type, offset = nil) add(name, type, offset) end - + + # @param (see #add) + # @return (see #add) + # Add a struct as a field to the builder. def add_struct(name, type, offset = nil) add(name, Type::Struct.new(type), offset) end + # @param name (see #add) + # @param type (see #add) + # @param [Numeric] count array length + # @param offset (see #add) + # @return (see #add) + # Add an array as a field to the builder. def add_array(name, type, count, offset = nil) add(name, Type::Array.new(type, count), offset) end + # @return [StructLayout] + # Build and return the struct layout. def build # Add tail padding if the struct is not packed size = @packed ? @size : align(@size, @alignment) - - StructLayout.new(@fields, size, @alignment) + + layout = StructLayout.new(@fields, size, @alignment) + layout.__union! if @union + layout end private - + + # @param [Numeric] offset + # @param [Numeric] align + # @return [Numeric] def align(offset, align) align + ((offset - 1) & ~(align - 1)); end + # @param (see #add) + # @return [StructLayout::Field] def field_for_type(name, offset, type) field_class = case when type.is_a?(Type::Function) @@ -138,7 +198,7 @@ def field_for_type(name, offset, type) when type.is_a?(FFI::Enum) StructLayout::Enum - when SCALAR_TYPES.include?(type) + when NUMBER_TYPES.include?(type) StructLayout::Number when type == Type::POINTER diff --git a/lib/ruby/stdlib/ffi/tools/Rakefile b/lib/ruby/stdlib/ffi/tools/Rakefile deleted file mode 100644 index c3768107d1a..00000000000 --- a/lib/ruby/stdlib/ffi/tools/Rakefile +++ /dev/null @@ -1,58 +0,0 @@ -$VERBOSE = true -$verbose = Rake.application.options.trace - -require 'ffi' -require 'ffi/tools/struct_generator' -require 'ffi/tools/const_generator' -require 'ffi/tools/types_generator' -require 'ffi/tools/generator' -require 'fileutils' -require 'rbconfig' - -arches = [ ] -arch_options = {} -conf_files = [] - -if FFI::Platform.mac? - osx_arches = [ "ppc", "i386" ] - osx_arches << "x86_64" if RbConfig::CONFIG['host_cpu'] == 'x86_64' - osx_arches.each do |arch| - arches << arch - platform_dir = File.join(FFI::Platform::FFI_DIR, "platform", "#{arch}-darwin") - arch_options[arch] = { :platform_dir => platform_dir, :cppflags => "-arch #{arch}"} - end -else - arches = [ FFI::Platform::ARCH ] - arch_options[FFI::Platform::ARCH] = { - :platform_dir => FFI::Platform::CONF_DIR, - :cppflags => FFI::Platform.solaris? ? "-m#{FFI::Platform::ADDRESS_SIZE}" : "" - } -end -arches.each { |arch| - options = arch_options[arch] - platform_conf = File.join(options[:platform_dir], "platform.conf") - types_conf = File.join(options[:platform_dir], "types.conf") - conf_files << platform_conf - file platform_conf do |task| - FileUtils.mkdir_p(File.dirname(task.name), { :mode => 0755 }) - gen_platform_conf task, { :cppflags => options[:cppflags]} - end - file types_conf do |task| - FileUtils.mkdir_p(File.dirname(task.name), { :mode => 0755 }) - File.open(task.name, "w") do |f| - f.puts FFI::TypesGenerator.generate(:cppflags => options[:cppflags]) - end - end - task "gen_ffi_files_#{arch}" do |task| - Dir["#{File.join(FFI::Platform::FFI_DIR, 'platform')}/*.rb.ffi"].each do |file| - rb_name = File.join(options[:platform_dir], File.basename(file, '.ffi')) - FFI::Generator.new file, rb_name, { :cppflags => options[:cppflags] } - end unless FFI::Platform.windows? - end - task "#{arch}" => [ platform_conf, types_conf, "gen_ffi_files_#{arch}" ] -} - -task :default => :build -task :build => arches - -load 'ffi/tools/platform.rake' diff --git a/lib/ruby/stdlib/ffi/tools/const_generator.rb b/lib/ruby/stdlib/ffi/tools/const_generator.rb index e3eb9ba4fb4..fb34d949e48 100644 --- a/lib/ruby/stdlib/ffi/tools/const_generator.rb +++ b/lib/ruby/stdlib/ffi/tools/const_generator.rb @@ -1,28 +1,43 @@ -require 'tmpdir' require 'tempfile' require 'open3' module FFI - ## # ConstGenerator turns C constants into ruby values. - + # + # @example a simple example for stdio + # require 'ffi/tools/const_generator' + # cg = FFI::ConstGenerator.new('stdio') do |gen| + # gen.const(:SEEK_SET) + # gen.const('SEEK_CUR') + # gen.const('seek_end') # this constant does not exist + # end # #calculate called automatically at the end of the block + # + # cg['SEEK_SET'] # => 0 + # cg['SEEK_CUR'] # => 1 + # cg['seek_end'] # => nil + # cg.to_ruby # => "SEEK_SET = 0\nSEEK_CUR = 1\n# seek_end not available" class ConstGenerator @options = {} attr_reader :constants - ## # Creates a new constant generator that uses +prefix+ as a name, and an # options hash. # - # The only option is :required, which if set to true raises an error if a + # The only option is +:required+, which if set to +true+ raises an error if a # constant you have requested was not found. # - # When passed a block, #calculate is automatically called at the end of - # the block, otherwise you must call it yourself. - + # @param [#to_s] prefix + # @param [Hash] options + # @return + # @option options [Boolean] :required + # @overload initialize(prefix, options) + # @overload initialize(prefix, options) { |gen| ... } + # @yieldparam [ConstGenerator] gen new generator is passed to the block + # When passed a block, {#calculate} is automatically called at the end of + # the block, otherwise you must call it yourself. def initialize(prefix = nil, options = {}) - @includes = [] + @includes = ['stdio.h', 'stddef.h'] @constants = {} @prefix = prefix @@ -34,23 +49,40 @@ def initialize(prefix = nil, options = {}) calculate self.class.options.merge(options) end end + # Set class options + # These options are merged with {#initialize} options when it is called with a block. + # @param [Hash] options + # @return [Hash] class options def self.options=(options) @options = options end + # Get class options. + # @return [Hash] class options def self.options @options end + # @param [String] name + # @return constant value (converted if a +converter+ was defined). + # Access a constant by name. def [](name) - @constants[name].value + @constants[name].converted_value end - ## - # Request the value for C constant +name+. +format+ is a printf format - # string to print the value out, and +cast+ is a C cast for the value. - # +ruby_name+ allows you to give the constant an alternate ruby name for - # #to_ruby. +converter+ or +converter_proc+ allow you to convert the - # value from a string to the appropriate type for #to_ruby. - + # Request the value for C constant +name+. + # + # @param [#to_s] name C constant name + # @param [String] format a printf format string to print the value out + # @param [String] cast a C cast for the value + # @param ruby_name alternate ruby name for {#to_ruby} + # + # @overload const(name, format=nil, cast='', ruby_name=nil, converter=nil) + # +converter+ is a Method or a Proc. + # @param [#call] converter convert the value from a string to the appropriate + # type for {#to_ruby}. + # @overload const(name, format=nil, cast='', ruby_name=nil) { |value| ... } + # Use a converter block. This block convert the value from a string to the + # appropriate type for {#to_ruby}. + # @yieldparam value constant value def const(name, format = nil, cast = '', ruby_name = nil, converter = nil, &converter_proc) format ||= '%d' @@ -67,18 +99,19 @@ def const(name, format = nil, cast = '', ruby_name = nil, converter = nil, return const end + # Calculate constants values. + # @param [Hash] options + # @option options [String] :cppflags flags for C compiler + # @return [nil] + # @raise if a constant is missing and +:required+ was set to +true+ (see {#initialize}) def calculate(options = {}) binary = File.join Dir.tmpdir, "rb_const_gen_bin_#{Process.pid}" Tempfile.open("#{@prefix}.const_generator") do |f| - f.puts "#include " - @includes.each do |inc| f.puts "#include <#{inc}>" end - - f.puts "#include \n\n" - f.puts "int main(int argc, char **argv)\n{" + f.puts "\nint main(int argc, char **argv)\n{" @constants.each_value do |const| f.puts <<-EOF @@ -116,17 +149,19 @@ def calculate(options = {}) end end + # Dump constants to +io+. + # @param [#puts] io + # @return [nil] def dump_constants(io) @constants.each do |name, constant| - name = [@prefix, name].join '.' + name = [@prefix, name].join '.' if @prefix io.puts "#{name} = #{constant.converted_value}" end end - ## # Outputs values for discovered constants. If the constant's value was # not discovered it is not omitted. - + # @return [String] def to_ruby @constants.sort_by { |name,| name }.map do |name, constant| if constant.value.nil? then @@ -137,17 +172,28 @@ def to_ruby end.join "\n" end - def include(i) - @includes << i + # Add additional C include file(s) to calculate constants from. + # @note +stdio.h+ and +stddef.h+ automatically included + # @param [List, Array] i include file(s) + # @return [Array] array of include files + def include(*i) + @includes |= i.flatten end end + # This class hold constants for {ConstGenerator} class ConstGenerator::Constant attr_reader :name, :format, :cast attr_accessor :value + # @param [#to_s] name + # @param [String] format a printf format string to print the value out + # @param [String] cast a C cast for the value + # @param ruby_name alternate ruby name for {#to_ruby} + # @param [#call] converter convert the value from a string to the appropriate + # type for {#to_ruby}. def initialize(name, format, cast, ruby_name = nil, converter=nil) @name = name @format = format @@ -157,6 +203,8 @@ def initialize(name, format, cast, ruby_name = nil, converter=nil) @value = nil end + # Return constant value (converted if a +converter+ was defined). + # @return constant value. def converted_value if @converter @converter.call(@value) @@ -165,14 +213,18 @@ def converted_value end end + # get constant ruby name + # @return [String] def ruby_name @ruby_name || @name end + # Get an evaluable string from constant. + # @return [String] def to_ruby "#{ruby_name} = #{converted_value}" end - end + end end diff --git a/lib/ruby/stdlib/ffi/tools/generator.rb b/lib/ruby/stdlib/ffi/tools/generator.rb index 45413f6d201..5552ea597f5 100644 --- a/lib/ruby/stdlib/ffi/tools/generator.rb +++ b/lib/ruby/stdlib/ffi/tools/generator.rb @@ -1,4 +1,51 @@ +require 'ffi/tools/struct_generator' +require 'ffi/tools/const_generator' + module FFI + + ## + # Generate files with C structs for FFI::Struct and C constants. + # + # == A simple example + # + # In file +zlib.rb.ffi+: + # module Zlib + # @@@ + # constants do |c| + # c.include "zlib.h" + # c.const :ZLIB_VERNUM + # end + # @@@ + # + # class ZStream < FFI::Struct + # + # struct do |s| + # s.name "struct z_stream_s" + # s.include "zlib.h" + # + # s.field :next_in, :pointer + # s.field :avail_in, :uint + # s.field :total_in, :ulong + # end + # @@@ + # end + # end + # + # Translate the file: + # require "ffi/tools/generator" + # FFI::Generator.new "zlib.rb.ffi", "zlib.rb" + # + # Generates the file +zlib.rb+ with constant values and offsets: + # module Zlib + # ZLIB_VERNUM = 4784 + # + # class ZStream < FFI::Struct + # layout :next_in, :pointer, 0, + # :avail_in, :uint, 8, + # :total_in, :ulong, 16 + # end + # + # @see FFI::Generator::Task for easy integration in a Rakefile class Generator def initialize(ffi_name, rb_name, options = {}) @@ -16,7 +63,7 @@ def initialize(ffi_name, rb_name, options = {}) indent = $1 original_lines = $2.count "\n" - instance_eval $2 + instance_eval $2, @ffi_name, $`.count("\n") new_lines = [] @constants.each { |c| new_lines << c.to_ruby } @@ -32,7 +79,7 @@ def initialize(ffi_name, rb_name, options = {}) end open @rb_name, 'w' do |f| - f.puts "# This file is generated by rake. Do not edit." + f.puts "# This file is generated from `#{@ffi_name}'. Do not edit." f.puts f.puts new_file end diff --git a/lib/ruby/stdlib/ffi/tools/generator_task.rb b/lib/ruby/stdlib/ffi/tools/generator_task.rb index 07e234fea37..da72968b380 100644 --- a/lib/ruby/stdlib/ffi/tools/generator_task.rb +++ b/lib/ruby/stdlib/ffi/tools/generator_task.rb @@ -1,24 +1,21 @@ -begin - require 'ffi/struct_generator' - require 'ffi/const_generator' - require 'ffi/generator' -rescue LoadError - # from Rakefile - require 'lib/ffi/struct_generator' - require 'lib/ffi/const_generator' - require 'lib/ffi/generator' -end - +require 'ffi/tools/generator' require 'rake' require 'rake/tasklib' -require 'tempfile' ## -# Rake task that calculates C structs for FFI::Struct. - +# Add Rake tasks that generate files with C structs for FFI::Struct and C constants. +# +# @example a simple example for your Rakefile +# require "ffi/tools/generator_task" +# # Add a task to generate my_object.rb out of my_object.rb.ffi +# FFI::Generator::Task.new ["my_object.rb"], cflags: "-I/usr/local/mylibrary" +# +# The generated files are also added to the 'clear' task. +# +# @see FFI::Generator for a description of the file content class FFI::Generator::Task < Rake::TaskLib - def initialize(rb_names) + def initialize(rb_names, options={}) task :clean do rm_f rb_names end rb_names.each do |rb_name| @@ -27,7 +24,7 @@ def initialize(rb_names) file rb_name => ffi_name do |t| puts "Generating #{rb_name}..." if Rake.application.options.trace - FFI::Generator.new ffi_name, rb_name + FFI::Generator.new ffi_name, rb_name, options end end end diff --git a/lib/ruby/stdlib/ffi/tools/platform.rake b/lib/ruby/stdlib/ffi/tools/platform.rake deleted file mode 100644 index 85fd1b89c7e..00000000000 --- a/lib/ruby/stdlib/ffi/tools/platform.rake +++ /dev/null @@ -1,554 +0,0 @@ -require 'ffi/platform' -require 'ffi/tools/struct_generator' -require 'ffi/tools/const_generator' -require 'ffi/tools/types_generator' - -deps = %w[Rakefile] + Dir['lib/ffi/*rb'] - -#file PLATFORM_CONF => deps do |task| -# gen_platform_conf task -#end -def gen_platform_conf(task, options = {}) - FFI::StructGenerator.options = options - FFI::ConstGenerator.options = options - - addrinfo = FFI::StructGenerator.new 'addrinfo' do |s| - s.include 'sys/types.h' - s.include 'sys/socket.h' - s.include 'netdb.h' - s.name 'struct addrinfo' - s.field :ai_flags, :int - s.field :ai_family, :int - s.field :ai_socktype, :int - s.field :ai_protocol, :int - s.field :ai_addrlen, :int - s.field :ai_addr, :pointer - s.field :ai_canonname, :string - s.field :ai_next, :pointer - end unless FFI::Platform::IS_WINDOWS - - dirent = FFI::StructGenerator.new 'dirent' do |s| - s.include "sys/types.h" - s.include "dirent.h" - s.name 'struct dirent' - s.field :d_ino, :ino_t - s.field :d_reclen, :ushort unless FFI::Platform::IS_WINDOWS - s.field :d_name, :char_array - end - - timeval = FFI::StructGenerator.new 'timeval' do |s| - s.include "sys/time.h" - s.name 'struct timeval' - s.field :tv_sec, :time_t - s.field :tv_usec, :suseconds_t - end - - sockaddr_in = FFI::StructGenerator.new 'sockaddr_in' do |s| - s.include "netinet/in.h" - s.include "fcntl.h" - s.include "sys/socket.h" - s.include "sys/stat.h" - s.name 'struct sockaddr_in' - s.field :sin_family, :sa_family_t - s.field :sin_port, :ushort - s.field :sin_addr - s.field :sin_zero, :char_array - end - - sockaddr_un = FFI::StructGenerator.new 'sockaddr_un' do |s| - s.include "sys/un.h" - s.name 'struct sockaddr_un' - s.field :sun_family, :sa_family_t - s.field :sun_path, :char_array - end - - servent = FFI::StructGenerator.new 'servent' do |s| - s.include "netdb.h" - s.name 'struct servent' - s.field :s_name, :pointer - s.field :s_aliases, :pointer - s.field :s_port, :int - s.field :s_proto, :pointer - end - - stat = FFI::StructGenerator.new 'stat' do |s| - s.include "sys/types.h" - s.include "sys/stat.h" - s.name 'struct stat' - s.field :st_dev, :dev_t - s.field :st_ino, :ino_t - s.field :st_mode, :mode_t - s.field :st_nlink, :nlink_t - s.field :st_uid, :uid_t - s.field :st_gid, :gid_t - s.field :st_rdev, :dev_t - s.field :st_size, :off_t - s.field :st_blksize - s.field :st_blocks - s.field :st_atime, :time_t - s.field :st_mtime, :time_t - s.field :st_ctime, :time_t - end - - rlimit = FFI::StructGenerator.new 'rlimit' do |s| - s.include "sys/types.h" - s.include "sys/time.h" - s.include "sys/resource.h" - s.name 'struct rlimit' - s.field :rlim_cur, :rlim_t - s.field :rlim_max, :rlim_t - end - - # FIXME these constants don't have standard names. LOCK_SH == Linux, - # O_SHLOCK on Bsd/Darwin, etc. Binary doesn't exist at all in many non-Unix - # variants. This should come out of something like config.h - - fixme_constants = %w{ - LOCK_SH - LOCK_EX - LOCK_NB - LOCK_UN - BINARY - } - - file_cg = FFI::ConstGenerator.new 'rbx.platform.file' do |cg| - cg.include 'stdio.h' - cg.include 'fcntl.h' - cg.include 'sys/stat.h' - - file_constants = %w[ - O_RDONLY - O_WRONLY - O_RDWR - O_CREAT - O_EXCL - O_NOCTTY - O_TRUNC - O_APPEND - O_NONBLOCK - O_SYNC - S_IRUSR - S_IWUSR - S_IXUSR - S_IRGRP - S_IWGRP - S_IXGRP - S_IROTH - S_IWOTH - S_IXOTH - S_IFMT - S_IFIFO - S_IFCHR - S_IFDIR - S_IFBLK - S_IFREG - S_IFLNK - S_IFSOCK - S_IFWHT - S_ISUID - S_ISGID - ] - - file_constants.each { |c| cg.const c } - end - - io_cg = FFI::ConstGenerator.new 'rbx.platform.io' do |cg| - cg.include 'stdio.h' - - io_constants = %w[ - SEEK_SET - SEEK_CUR - SEEK_END - ] - - io_constants.each { |c| cg.const c } - end - - # Only constants needed by core are added here - fcntl_cg = FFI::ConstGenerator.new 'rbx.platform.fcntl' do |cg| - cg.include 'fcntl.h' - - fcntl_constants = %w[ - F_GETFL - F_SETFL - O_ACCMODE - ] - - fcntl_constants.each { |c| cg.const c } - end - - socket_cg = FFI::ConstGenerator.new 'rbx.platform.socket' do |cg| - cg.include 'sys/types.h' - cg.include 'sys/socket.h' - cg.include 'netdb.h' - cg.include 'netinet/tcp.h' - cg.include 'netinet/in.h' - - socket_constants = %w[ - AF_APPLETALK - AF_ATM - AF_AX25 - AF_CCITT - AF_CHAOS - AF_CNT - AF_COIP - AF_DATAKIT - AF_DEC - AF_DLI - AF_E164 - AF_ECMA - AF_HYLINK - AF_IMPLINK - AF_INET - AF_INET6 - AF_IPX - AF_ISDN - AF_ISO - AF_LAT - AF_LINK - AF_LOCAL - AF_MAX - AF_NATM - AF_NDRV - AF_NETBIOS - AF_NETGRAPH - AF_NS - AF_OSI - AF_PPP - AF_PUP - AF_ROUTE - AF_SIP - AF_SNA - AF_SYSTEM - AF_UNIX - AF_UNSPEC - - AI_ADDRCONFIG - AI_ALL - AI_CANONNAME - AI_DEFAULT - AI_MASK - AI_NUMERICHOST - AI_PASSIVE - AI_V4MAPPED - AI_V4MAPPED_CFG - - EAI_ADDRFAMILY - EAI_AGAIN - EAI_BADFLAGS - EAI_BADHINTS - EAI_FAIL - EAI_FAMILY - EAI_MAX - EAI_MEMORY - EAI_NODATA - EAI_NONAME - EAI_PROTOCOL - EAI_SERVICE - EAI_SOCKTYPE - EAI_SYSTEM - - INADDR_ALLHOSTS_GROUP - INADDR_ANY - INADDR_BROADCAST - INADDR_LOOPBACK - INADDR_MAX_LOCAL_GROUP - INADDR_NONE - INADDR_UNSPEC_GROUP - - IPPORT_RESERVED - IPPORT_USERRESERVED - - IPPROTO_BIP - IPPROTO_EGP - IPPROTO_EON - IPPROTO_GGP - IPPROTO_HELLO - IPPROTO_ICMP - IPPROTO_IDP - IPPROTO_IGMP - IPPROTO_IP - IPPROTO_MAX - IPPROTO_ND - IPPROTO_PUP - IPPROTO_RAW - IPPROTO_TCP - IPPROTO_TP - IPPROTO_UDP - IPPROTO_XTP - - IPX_TYPE - - IP_ADD_MEMBERSHIP - IP_DEFAULT_MULTICAST_LOOP - IP_DEFAULT_MULTICAST_TTL - IP_DROP_MEMBERSHIP - IP_HDRINCL - IP_MAX_MEMBERSHIPS - IP_MULTICAST_IF - IP_MULTICAST_LOOP - IP_MULTICAST_TTL - IP_OPTIONS - IP_RECVDSTADDR - IP_RECVOPTS - IP_RECVRETOPTS - IP_RETOPTS - IP_TOS - IP_TTL - - MSG_COMPAT - MSG_CTRUNC - MSG_DONTROUTE - MSG_DONTWAIT - MSG_EOF - MSG_EOR - MSG_FLUSH - MSG_HAVEMORE - MSG_HOLD - MSG_OOB - MSG_PEEK - MSG_RCVMORE - MSG_SEND - MSG_TRUNC - MSG_WAITALL - - NI_DGRAM - NI_MAXHOST - NI_MAXSERV - NI_NAMEREQD - NI_NOFQDN - NI_NUMERICHOST - NI_NUMERICSERV - - PF_APPLETALK - PF_AX25 - PF_CCITT - PF_CHAOS - PF_CNT - PF_COIP - PF_DATAKIT - PF_DLI - PF_ECMA - PF_HYLINK - PF_IMPLINK - PF_INET - PF_INET6 - PF_IPX - PF_ISDN - PF_ISO - PF_KEY - PF_LAT - PF_LINK - PF_LOCAL - PF_MAX - PF_NATM - PF_NDRV - PF_NETBIOS - PF_NETGRAPH - PF_NS - PF_OSI - PF_PIP - PF_PPP - PF_PUP - PF_ROUTE - PF_RTIP - PF_SIP - PF_SNA - PF_SYSTEM - PF_UNIX - PF_UNSPEC - PF_XTP - - SHUT_RD - SHUT_RDWR - SHUT_WR - - SOCK_DGRAM - SOCK_PACKET - SOCK_RAW - SOCK_RDM - SOCK_SEQPACKET - SOCK_STREAM - - SOL_ATALK - SOL_AX25 - SOL_IP - SOL_IPX - SOL_SOCKET - SOL_TCP - SOL_UDP - - SOPRI_BACKGROUND - SOPRI_INTERACTIVE - SOPRI_NORMAL - - SO_ACCEPTCONN - SO_ACCEPTFILTER - SO_ATTACH_FILTER - SO_BINDTODEVICE - SO_BROADCAST - SO_DEBUG - SO_DETACH_FILTER - SO_DONTROUTE - SO_DONTTRUNC - SO_ERROR - SO_KEEPALIVE - SO_LINGER - SO_NKE - SO_NOSIGPIPE - SO_NO_CHECK - SO_NREAD - SO_OOBINLINE - SO_PASSCRED - SO_PEERCRED - SO_PEERNAME - SO_PRIORITY - SO_RCVBUF - SO_RCVLOWAT - SO_RCVTIMEO - SO_REUSEADDR - SO_REUSEPORT - SO_SECURITY_AUTHENTICATION - SO_SECURITY_ENCRYPTION_NETWORK - SO_SECURITY_ENCRYPTION_TRANSPORT - SO_SNDBUF - SO_SNDLOWAT - SO_SNDTIMEO - SO_TIMESTAMP - SO_TYPE - SO_USELOOPBACK - SO_WANTMORE - SO_WANTOOBFLAG - - TCP_MAXSEG - TCP_NODELAY - ] - - socket_constants.each { |c| cg.const c, "%ld", '(long)' } - end - - process_cg = FFI::ConstGenerator.new 'rbx.platform.process' do |cg| - cg.include 'sys/wait.h' - cg.include 'sys/resource.h' - - process_constants = %w{ - WNOHANG - WUNTRACED - PRIO_PROCESS - PRIO_PGRP - PRIO_USER - RLIMIT_CPU - RLIMIT_FSIZE - RLIMIT_DATA - RLIMIT_STACK - RLIMIT_CORE - RLIMIT_RSS - RLIMIT_NPROC - RLIMIT_NOFILE - RLIMIT_MEMLOCK - RLIMIT_AS - RLIMIT_SBSIZE - } - - process_constants.each { |c| cg.const c } - - long_process_constants = %w[ - RLIM_INFINITY - RLIM_SAVED_MAX - RLIM_SAVED_CUR - ] - - long_process_constants.each { |c| - cg.const c, "%llu", "(unsigned long long)" - } - end - - # The constants come from MRI's signal.c. This means that some of them might - # be missing. - - signal_cg = FFI::ConstGenerator.new 'rbx.platform.signal' do |cg| - cg.include 'signal.h' - cg.include 'sys/signal.h' - - signal_constants = %w{ - SIGHUP - SIGINT - SIGQUIT - SIGILL - SIGTRAP - SIGIOT - SIGABRT - SIGEMT - SIGFPE - SIGKILL - SIGBUS - SIGSEGV - SIGSYS - SIGPIPE - SIGALRM - SIGTERM - SIGURG - SIGSTOP - SIGTSTP - SIGCONT - SIGCHLD - SIGCLD - SIGCHLD - SIGTTIN - SIGTTOU - SIGIO - SIGXCPU - SIGXFSZ - SIGVTALRM - SIGPROF - SIGWINCH - SIGUSR1 - SIGUSR2 - SIGLOST - SIGMSG - SIGPWR - SIGPOLL - SIGDANGER - SIGMIGRATE - SIGPRE - SIGGRANT - SIGRETRACT - SIGSOUND - SIGINFO - } - - signal_constants.each { |c| cg.const c } - end - - zlib_cg = FFI::ConstGenerator.new 'rbx.platform.zlib' do |cg| - cg.include 'zlib.h' - - zlib_constants = %w[ZLIB_VERSION] - - zlib_constants.each { |c| cg.const c, "%s", "(char *)" } - end - - puts "Generating #{task.name}..." if $verbose - - File.open task.name, "w" do |f| - addrinfo.dump_config f unless FFI::Platform::IS_WINDOWS - dirent.dump_config f - timeval.dump_config f - sockaddr_in.dump_config f - sockaddr_un.dump_config f if sockaddr_un.found? - servent.dump_config f - stat.dump_config f - rlimit.dump_config f - - file_cg.dump_constants f - io_cg.dump_constants f - fcntl_cg.dump_constants f - socket_cg.dump_constants f - process_cg.dump_constants f - signal_cg.dump_constants f - zlib_cg.dump_constants f - - f.puts FFI::TypesGenerator.generate options - end - -end diff --git a/lib/ruby/stdlib/ffi/tools/struct_generator.rb b/lib/ruby/stdlib/ffi/tools/struct_generator.rb index 2633c4f8785..7d2a6e5298d 100644 --- a/lib/ruby/stdlib/ffi/tools/struct_generator.rb +++ b/lib/ruby/stdlib/ffi/tools/struct_generator.rb @@ -1,4 +1,3 @@ -require 'tmpdir' require 'tempfile' module FFI @@ -8,15 +7,15 @@ module FFI # # Given the @@@ portion in: # - # module Zlib::ZStream < FFI::Struct + # class Zlib::ZStream < FFI::Struct # @@@ # name "struct z_stream_s" # include "zlib.h" - # + # # field :next_in, :pointer # field :avail_in, :uint # field :total_in, :ulong - # + # # # ... # @@@ # end @@ -91,7 +90,7 @@ def calculate(options = {}) raise "Compilation error generating struct #{@name} (#{@struct_name}):\n#{output}" end end - + output = `#{binary}`.split "\n" File.unlink(binary + (FFI::Platform.windows? ? ".exe" : "")) sizeof = output.shift @@ -130,10 +129,9 @@ def dump_config(io) def generate_layout buf = "" - buf << "self.size = #{@size}\n" @fields.each_with_index do |field, i| - if i < 1 + if buf.empty? buf << "layout :#{field.name}, :#{field.type}, #{field.offset}" else buf << " :#{field.name}, :#{field.type}, #{field.offset}" diff --git a/lib/ruby/stdlib/ffi/tools/types_generator.rb b/lib/ruby/stdlib/ffi/tools/types_generator.rb index d36ba858a7a..f00894532c9 100644 --- a/lib/ruby/stdlib/ffi/tools/types_generator.rb +++ b/lib/ruby/stdlib/ffi/tools/types_generator.rb @@ -1,6 +1,8 @@ require 'tempfile' module FFI + + # @private class TypesGenerator ## @@ -46,26 +48,37 @@ def self.generate(options = {}) Tempfile.open 'ffi_types_generator' do |io| io.puts <<-C #include +#if !(defined(WIN32)) #include +#include #include +#endif C io.close - typedefs = `gcc -E -x c #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c #{io.path}` + cc = ENV['CC'] || 'gcc' + cmd = "#{cc} -E -x c #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c" + if options[:input] + typedefs = File.read(options[:input]) + elsif options[:remote] + typedefs = `ssh #{options[:remote]} #{cmd} - < #{io.path}` + else + typedefs = `#{cmd} #{io.path}` + end end - - code = "" - typedefs.each do |type| + code = [] + + typedefs.each_line do |type| # We only care about single line typedef next unless type =~ /typedef/ # Ignore unions or structs next if type =~ /union|struct/ - + # strip off the starting typedef and ending ; type.gsub!(/^(.*typedef\s*)/, "") type.gsub!(/\s*;\s*$/, "") - + parts = type.split(/\s+/) def_type = parts.join(" ") @@ -87,7 +100,7 @@ def self.generate(options = {}) else final_type = parts.pop end - + def_type = case type when /__QI__/ then "char" when /__HI__/ then "short" @@ -102,22 +115,21 @@ def self.generate(options = {}) final_type = parts.pop def_type = parts.join(" ") end - + if type = TYPE_MAP[def_type] - code << "rbx.platform.typedef.#{final_type} = #{type}\n" + code << "rbx.platform.typedef.#{final_type} = #{type}" TYPE_MAP[final_type] = TYPE_MAP[def_type] else # Fallback to an ordinary pointer if we don't know the type if def_type =~ /\*/ - code << "rbx.platform.typedef.#{final_type} = pointer\n" + code << "rbx.platform.typedef.#{final_type} = pointer" TYPE_MAP[final_type] = :pointer end end end - code + code.sort.join("\n") end - end end diff --git a/lib/ruby/stdlib/ffi/types.rb b/lib/ruby/stdlib/ffi/types.rb index 4c81140e4e9..90f50c1b542 100644 --- a/lib/ruby/stdlib/ffi/types.rb +++ b/lib/ruby/stdlib/ffi/types.rb @@ -1,7 +1,9 @@ # -# Copyright (C) 2008, 2009 Wayne Meissner -# Copyright (C) 2009 Luc Heinrich +# Copyright (C) 2008-2010 Wayne Meissner # Copyright (c) 2007, 2008 Evan Phoenix +# +# This file is part of ruby-ffi. +# # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -12,7 +14,7 @@ # * Redistributions in binary form must reproduce the above copyright notice # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# * Neither the name of the Evan Phoenix nor the names of its contributors +# * Neither the name of the Ruby FFI project nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # @@ -26,18 +28,31 @@ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# see {file:README} module FFI + # @param [Type, DataConverter, Symbol] old type definition used by {FFI.find_type} + # @param [Symbol] add new type definition's name to add + # @return [Type] + # Add a definition type to type definitions. def self.typedef(old, add) TypeDefs[add] = self.find_type(old) end + # (see FFI.typedef) def self.add_typedef(old, add) typedef old, add end + # @param [Type, DataConverter, Symbol] name + # @param [Hash] type_map if nil, {FFI::TypeDefs} is used + # @return [Type] + # Find a type in +type_map+ ({FFI::TypeDefs}, by default) from + # a type objet, a type name (symbol). If +name+ is a {DataConverter}, + # a new {Type::Mapped} is created. def self.find_type(name, type_map = nil) if name.is_a?(Type) name @@ -50,12 +65,12 @@ def self.find_type(name, type_map = nil) elsif name.is_a?(DataConverter) (type_map || TypeDefs)[name] = Type::Mapped.new(name) - else raise TypeError, "unable to resolve type '#{name}'" end end + # List of type definitions TypeDefs.merge!({ # The C void type; only useful for function return types :void => Type::VOID, @@ -99,6 +114,9 @@ def self.find_type(name, type_map = nil) # C double precision float :double => Type::DOUBLE, + # C long double + :long_double => Type::LONGDOUBLE, + # Native memory address :pointer => Type::POINTER, @@ -130,19 +148,31 @@ def self.find_type(name, type_map = nil) :varargs => Type::VARARGS, }) - # Returns a [ String, Pointer ] tuple so the C memory for the string can be freed + # This will convert a pointer to a Ruby string (just like `:string`), but + # also allow to work with the pointer itself. This is useful when you want + # a Ruby string already containing a copy of the data, but also the pointer + # to the data for you to do something with it, like freeing it, in case the + # library handed the memory off to the caller (Ruby-FFI). + # + # It's {typedef}'d as +:strptr+. class StrPtrConverter extend DataConverter native_type Type::POINTER + # @param [Pointer] val + # @param ctx not used + # @return [Array(String, Pointer)] + # Returns a [ String, Pointer ] tuple so the C memory for the string can be freed def self.from_native(val, ctx) [ val.null? ? nil : val.get_string(0), val ] end - end typedef(StrPtrConverter, :strptr) + # @param type +type+ is an instance of class accepted by {FFI.find_type} + # @return [Numeric] + # Get +type+ size, in bytes. def self.type_size(type) find_type(type).size end diff --git a/lib/ruby/stdlib/ffi/union.rb b/lib/ruby/stdlib/ffi/union.rb index 1e7f3264722..38414ab9529 100644 --- a/lib/ruby/stdlib/ffi/union.rb +++ b/lib/ruby/stdlib/ffi/union.rb @@ -1,33 +1,9 @@ # -# Copyright (C) 2009-2010 Wayne Meissner -# Copyright (C) 2009-2010 Andrea Fazzi +# Copyright (C) 2009 Andrea Fazzi # -# Version: EPL 2.0/GPL 2.0/LGPL 2.1 +# This file is part of ruby-ffi. # -# The contents of this file are subject to the Common Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.eclipse.org/legal/cpl-v10.html -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the EPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the EPL, the GPL or the LGPL. -# -# -# This file contains code that was originally under the following license: +# All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -37,7 +13,7 @@ # * Redistributions in binary form must reproduce the above copyright notice # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# * Neither the name of the Evan Phoenix nor the names of its contributors +# * Neither the name of the Ruby FFI project nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # @@ -52,6 +28,7 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # + require 'ffi/struct' module FFI diff --git a/lib/ruby/stdlib/ffi/variadic.rb b/lib/ruby/stdlib/ffi/variadic.rb index 8790467a7dd..24140556c2b 100644 --- a/lib/ruby/stdlib/ffi/variadic.rb +++ b/lib/ruby/stdlib/ffi/variadic.rb @@ -1,41 +1,46 @@ # -# Copyright (C) 2008-2010 Wayne Meissner +# Copyright (C) 2008, 2009 Wayne Meissner +# Copyright (C) 2009 Luc Heinrich # -# Version: EPL 2.0/GPL 2.0/LGPL 2.1 +# This file is part of ruby-ffi. # -# The contents of this file are subject to the Common Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.eclipse.org/legal/cpl-v10.html +# All rights reserved. # -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: # -# Alternatively, the contents of this file may be used under the terms of -# either of the GNU General Public License Version 2 or later (the "GPL"), -# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the EPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the EPL, the GPL or the LGPL. +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of the Ruby FFI project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # module FFI - class VariadicInvoker + class VariadicInvoker def init(arg_types, type_map) @fixed = Array.new @type_map = type_map arg_types.each_with_index do |type, i| - @fixed << type unless type == FFI::NativeType::VARARGS + @fixed << type unless type == Type::VARARGS end end + def call(*args, &block) param_types = Array.new(@fixed) param_values = Array.new diff --git a/lib/ruby/stdlib/ffi/version.rb b/lib/ruby/stdlib/ffi/version.rb new file mode 100644 index 00000000000..84d921d3515 --- /dev/null +++ b/lib/ruby/stdlib/ffi/version.rb @@ -0,0 +1,3 @@ +module FFI + VERSION = '1.11.3' +end diff --git a/spec/ffi/bitmask_spec.rb b/spec/ffi/bitmask_spec.rb new file mode 100644 index 00000000000..4a404b0b39e --- /dev/null +++ b/spec/ffi/bitmask_spec.rb @@ -0,0 +1,585 @@ +# +# This file is part of ruby-ffi. +# For licensing, see LICENSE.SPECS +# + +require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) + +module TestBitmask0 + extend FFI::Library +end + +module TestBitmask1 + extend FFI::Library + ffi_lib TestLibrary::PATH + + bitmask [:c1, :c2, :c3, :c4] + bitmask [:c5, 2, :c6, :c7, :c8] + bitmask [:c9, 2, :c10, :c11, 5, :c12] + bitmask [:c13, 2, :c14, 4, :c15, 6, :c16, 8] + + attach_function :test_untagged_bitmask, [:int], :int +end + +module TestBitmask3 + extend FFI::Library + ffi_lib TestLibrary::PATH + + bitmask :bitmask_type1, [:c1, :c2, :c3, :c4] + bitmask :bitmask_type2, [:c5, 2, :c6, :c7, :c8] + bitmask :bitmask_type3, [:c9, 2, :c10, :c11, 5, :c12] + bitmask :bitmask_type4, [:c13, 2, :c14, 4, :c15, 6, :c16, 8] + + attach_function :test_tagged_typedef_bitmask1, [:bitmask_type1], :bitmask_type1 + attach_function :test_tagged_typedef_bitmask2, [:bitmask_type2], :bitmask_type2 + attach_function :test_tagged_typedef_bitmask3, [:bitmask_type3], :bitmask_type3 + attach_function :test_tagged_typedef_bitmask4, [:bitmask_type4], :bitmask_type4 +end + +module TestBitmask4 + extend FFI::Library + ffi_lib TestLibrary::PATH + + bitmask [:c1, :c2, :c3, :c4] + bitmask :bitmask_type1, [:c5, 6, :c6, :c7, :c8] + bitmask :bitmask_type2, [:c9, 6, :c10, :c11, 14, :c12] + bitmask :bitmask_type3, [:c13, 6, :c14, 14, :c15, 30, :c16, 42] + bitmask FFI::Type::UINT16, :bitmask_type4, [:c17, 6, :c18, :c19, :c20] + bitmask FFI::Type::UINT32, :bitmask_type5, [:c21, 6, :c22, :c23, 14, :c24] + bitmask FFI::Type::UINT64, :bitmask_type6, [:c25, 6, :c26, 14, :c27, 30, :c28, 42] + bitmask FFI::Type::UINT64, [:c29, 42, :c30, :c31, :c32] + + attach_function :test_untagged_nonint_bitmask, [:uint8], :uint8 + attach_function :test_tagged_nonint_bitmask1, [:uint16], :uint16 + attach_function :test_tagged_nonint_bitmask2, [:uint32], :uint32 + attach_function :test_tagged_nonint_bitmask3, [:uint64], :uint64 + attach_function :test_tagged_nonint_bitmask4, :test_tagged_nonint_bitmask1, [:bitmask_type4], :bitmask_type4 + attach_function :test_tagged_nonint_bitmask5, :test_tagged_nonint_bitmask2, [:bitmask_type5], :bitmask_type5 + attach_function :test_tagged_nonint_bitmask6, :test_tagged_nonint_bitmask3, [:bitmask_type6], :bitmask_type6 +end + +describe "A library with no bitmask or enum defined" do + it "returns nil when asked for an enum" do + expect(TestBitmask0.enum_type(:foo)).to be_nil + end +end + +describe "An untagged bitmask" do + it "constants can be used as function parameters and return value" do + expect(TestBitmask1.test_untagged_bitmask(:c1)).to eq(1<<0) + expect(TestBitmask1.test_untagged_bitmask(:c2)).to eq(1<<1) + expect(TestBitmask1.test_untagged_bitmask(:c3)).to eq(1<<2) + expect(TestBitmask1.test_untagged_bitmask(:c4)).to eq(1<<3) + expect(TestBitmask1.test_untagged_bitmask(:c5)).to eq(1<<2) + expect(TestBitmask1.test_untagged_bitmask(:c6)).to eq(1<<3) + expect(TestBitmask1.test_untagged_bitmask(:c7)).to eq(1<<4) + expect(TestBitmask1.test_untagged_bitmask(:c8)).to eq(1<<5) + expect(TestBitmask1.test_untagged_bitmask(:c9)).to eq(1<<2) + expect(TestBitmask1.test_untagged_bitmask(:c10)).to eq(1<<3) + expect(TestBitmask1.test_untagged_bitmask(:c11)).to eq(1<<5) + expect(TestBitmask1.test_untagged_bitmask(:c12)).to eq(1<<6) + expect(TestBitmask1.test_untagged_bitmask(:c13)).to eq(1<<2) + expect(TestBitmask1.test_untagged_bitmask(:c14)).to eq(1<<4) + expect(TestBitmask1.test_untagged_bitmask(:c15)).to eq(1<<6) + expect(TestBitmask1.test_untagged_bitmask(:c16)).to eq(1<<8) + expect(TestBitmask4.test_untagged_nonint_bitmask(:c1)).to eq(1<<0) + expect(TestBitmask4.test_untagged_nonint_bitmask(:c2)).to eq(1<<1) + expect(TestBitmask4.test_untagged_nonint_bitmask(:c3)).to eq(1<<2) + expect(TestBitmask4.test_untagged_nonint_bitmask(:c4)).to eq(1<<3) + expect(TestBitmask4.test_tagged_nonint_bitmask3(:c29)).to eq(1<<42) + expect(TestBitmask4.test_tagged_nonint_bitmask3(:c30)).to eq(1<<43) + expect(TestBitmask4.test_tagged_nonint_bitmask3(:c31)).to eq(1<<44) + expect(TestBitmask4.test_tagged_nonint_bitmask3(:c32)).to eq(1<<45) + end +end + +describe "A tagged typedef bitmask" do + it "is accessible through its tag" do + expect(TestBitmask3.enum_type(:bitmask_type1)).not_to be_nil + expect(TestBitmask3.enum_type(:bitmask_type2)).not_to be_nil + expect(TestBitmask3.enum_type(:bitmask_type3)).not_to be_nil + expect(TestBitmask3.enum_type(:bitmask_type4)).not_to be_nil + expect(TestBitmask4.enum_type(:bitmask_type1)).not_to be_nil + expect(TestBitmask4.enum_type(:bitmask_type2)).not_to be_nil + expect(TestBitmask4.enum_type(:bitmask_type3)).not_to be_nil + expect(TestBitmask4.enum_type(:bitmask_type4)).not_to be_nil + expect(TestBitmask4.enum_type(:bitmask_type5)).not_to be_nil + expect(TestBitmask4.enum_type(:bitmask_type6)).not_to be_nil + end + + it "contains bitmask constants" do + expect(TestBitmask3.enum_type(:bitmask_type1).symbols.length).to eq(4) + expect(TestBitmask3.enum_type(:bitmask_type2).symbols.length).to eq(4) + expect(TestBitmask3.enum_type(:bitmask_type3).symbols.length).to eq(4) + expect(TestBitmask3.enum_type(:bitmask_type4).symbols.length).to eq(4) + expect(TestBitmask4.enum_type(:bitmask_type1).symbols.length).to eq(4) + expect(TestBitmask4.enum_type(:bitmask_type2).symbols.length).to eq(4) + expect(TestBitmask4.enum_type(:bitmask_type3).symbols.length).to eq(4) + expect(TestBitmask4.enum_type(:bitmask_type4).symbols.length).to eq(4) + expect(TestBitmask4.enum_type(:bitmask_type5).symbols.length).to eq(4) + expect(TestBitmask4.enum_type(:bitmask_type6).symbols.length).to eq(4) + end + + it "constants can be used as function parameters and return value" do + expect(TestBitmask3.test_tagged_typedef_bitmask1(:c1)).to eq([:c1]) + expect(TestBitmask3.test_tagged_typedef_bitmask1(:c2)).to eq([:c2]) + expect(TestBitmask3.test_tagged_typedef_bitmask1(:c3)).to eq([:c3]) + expect(TestBitmask3.test_tagged_typedef_bitmask1(:c4)).to eq([:c4]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(:c5)).to eq([:c5]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(:c6)).to eq([:c6]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(:c7)).to eq([:c7]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(:c8)).to eq([:c8]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(:c9)).to eq([:c9]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(:c10)).to eq([:c10]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(:c11)).to eq([:c11]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(:c12)).to eq([:c12]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(:c13)).to eq([:c13]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(:c14)).to eq([:c14]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(:c15)).to eq([:c15]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(:c16)).to eq([:c16]) + expect(TestBitmask4.test_tagged_nonint_bitmask1(:c5)).to eq(1<<6) + expect(TestBitmask4.test_tagged_nonint_bitmask1(:c6)).to eq(1<<7) + expect(TestBitmask4.test_tagged_nonint_bitmask1(:c7)).to eq(1<<8) + expect(TestBitmask4.test_tagged_nonint_bitmask1(:c8)).to eq(1<<9) + expect(TestBitmask4.test_tagged_nonint_bitmask2(:c9)).to eq(1<<6) + expect(TestBitmask4.test_tagged_nonint_bitmask2(:c10)).to eq(1<<7) + expect(TestBitmask4.test_tagged_nonint_bitmask2(:c11)).to eq(1<<14) + expect(TestBitmask4.test_tagged_nonint_bitmask2(:c12)).to eq(1<<15) + expect(TestBitmask4.test_tagged_nonint_bitmask3(:c13)).to eq(1<<6) + expect(TestBitmask4.test_tagged_nonint_bitmask3(:c14)).to eq(1<<14) + expect(TestBitmask4.test_tagged_nonint_bitmask3(:c15)).to eq(1<<30) + expect(TestBitmask4.test_tagged_nonint_bitmask3(:c16)).to eq(1<<42) + expect(TestBitmask4.test_tagged_nonint_bitmask4(:c17)).to eq([:c17]) + expect(TestBitmask4.test_tagged_nonint_bitmask4(:c18)).to eq([:c18]) + expect(TestBitmask4.test_tagged_nonint_bitmask4(:c19)).to eq([:c19]) + expect(TestBitmask4.test_tagged_nonint_bitmask4(:c20)).to eq([:c20]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(:c21)).to eq([:c21]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(:c22)).to eq([:c22]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(:c23)).to eq([:c23]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(:c24)).to eq([:c24]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(:c25)).to eq([:c25]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(:c26)).to eq([:c26]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(:c27)).to eq([:c27]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(:c28)).to eq([:c28]) + end + + it "constants can be combined into list to be used as function parameters and return values" do + expect(TestBitmask3.test_tagged_typedef_bitmask1([:c2,:c4])).to eq([:c2,:c4]) + expect(TestBitmask3.test_tagged_typedef_bitmask2([:c6,:c8])).to eq([:c6,:c8]) + expect(TestBitmask3.test_tagged_typedef_bitmask3([:c10,:c12])).to eq([:c10,:c12]) + expect(TestBitmask3.test_tagged_typedef_bitmask4([:c14,:c16])).to eq([:c14,:c16]) + expect(TestBitmask4.test_tagged_nonint_bitmask4([:c18,:c20])).to eq([:c18,:c20]) + expect(TestBitmask4.test_tagged_nonint_bitmask5([:c22,:c24])).to eq([:c22,:c24]) + expect(TestBitmask4.test_tagged_nonint_bitmask6([:c26,:c28])).to eq([:c26,:c28]) + end + + it "integers can be used instead of constants" do + expect(TestBitmask3.test_tagged_typedef_bitmask1(1<<0)).to eq([:c1]) + expect(TestBitmask3.test_tagged_typedef_bitmask1(1<<1)).to eq([:c2]) + expect(TestBitmask3.test_tagged_typedef_bitmask1(1<<2)).to eq([:c3]) + expect(TestBitmask3.test_tagged_typedef_bitmask1(1<<3)).to eq([:c4]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(1<<2)).to eq([:c5]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(1<<3)).to eq([:c6]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(1<<4)).to eq([:c7]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(1<<5)).to eq([:c8]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(1<<2)).to eq([:c9]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(1<<3)).to eq([:c10]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(1<<5)).to eq([:c11]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(1<<6)).to eq([:c12]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(1<<2)).to eq([:c13]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(1<<4)).to eq([:c14]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(1<<6)).to eq([:c15]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(1<<8)).to eq([:c16]) + expect(TestBitmask4.test_tagged_nonint_bitmask4(1<<6)).to eq([:c17]) + expect(TestBitmask4.test_tagged_nonint_bitmask4(1<<7)).to eq([:c18]) + expect(TestBitmask4.test_tagged_nonint_bitmask4(1<<8)).to eq([:c19]) + expect(TestBitmask4.test_tagged_nonint_bitmask4(1<<9)).to eq([:c20]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(1<<6)).to eq([:c21]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(1<<7)).to eq([:c22]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(1<<14)).to eq([:c23]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(1<<15)).to eq([:c24]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(1<<6)).to eq([:c25]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(1<<14)).to eq([:c26]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(1<<30)).to eq([:c27]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(1<<42)).to eq([:c28]) + end + + it "combination or list of integers can be used instead of constants" do + expect(TestBitmask3.test_tagged_typedef_bitmask1(1<<1|1<<3)).to eq([:c2,:c4]) + expect(TestBitmask3.test_tagged_typedef_bitmask1([1<<1,1<<3])).to eq([:c2,:c4]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(1<<3|1<<5)).to eq([:c6,:c8]) + expect(TestBitmask3.test_tagged_typedef_bitmask2([1<<3,1<<5])).to eq([:c6,:c8]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(1<<3|1<<6)).to eq([:c10,:c12]) + expect(TestBitmask3.test_tagged_typedef_bitmask3([1<<3,1<<6])).to eq([:c10,:c12]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(1<<4|1<<8)).to eq([:c14,:c16]) + expect(TestBitmask3.test_tagged_typedef_bitmask4([1<<4,1<<8])).to eq([:c14,:c16]) + expect(TestBitmask4.test_tagged_nonint_bitmask4(1<<7|1<<9)).to eq([:c18,:c20]) + expect(TestBitmask4.test_tagged_nonint_bitmask4([1<<7,1<<9])).to eq([:c18,:c20]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(1<<7|1<<15)).to eq([:c22,:c24]) + expect(TestBitmask4.test_tagged_nonint_bitmask5([1<<7,1<<15])).to eq([:c22,:c24]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(1<<14|1<<42)).to eq([:c26,:c28]) + expect(TestBitmask4.test_tagged_nonint_bitmask6([1<<14,1<<42])).to eq([:c26,:c28]) + end + + it "mixed list of integers and constants can be used instead of constants" do + expect(TestBitmask3.test_tagged_typedef_bitmask1([:c2,1<<3])).to eq([:c2,:c4]) + expect(TestBitmask3.test_tagged_typedef_bitmask2([:c6,1<<5])).to eq([:c6,:c8]) + expect(TestBitmask3.test_tagged_typedef_bitmask3([:c10,1<<6])).to eq([:c10,:c12]) + expect(TestBitmask3.test_tagged_typedef_bitmask4([:c14,1<<8])).to eq([:c14,:c16]) + expect(TestBitmask4.test_tagged_nonint_bitmask4([:c18,1<<9])).to eq([:c18,:c20]) + expect(TestBitmask4.test_tagged_nonint_bitmask5([:c22,1<<15])).to eq([:c22,:c24]) + expect(TestBitmask4.test_tagged_nonint_bitmask6([:c26,1<<42])).to eq([:c26,:c28]) + end + + it "remainder is given if some undefined mask are returned" do + expect(TestBitmask3.test_tagged_typedef_bitmask1(1<<1|1<<3|1<<4)).to eq([:c2,:c4,1<<4]) + expect(TestBitmask3.test_tagged_typedef_bitmask1([1<<1,1<<3,1<<4])).to eq([:c2,:c4,1<<4]) + expect(TestBitmask3.test_tagged_typedef_bitmask2(1<<3|1<<5|1<<6)).to eq([:c6,:c8,1<<6]) + expect(TestBitmask3.test_tagged_typedef_bitmask2([1<<3,1<<5,1<<6])).to eq([:c6,:c8,1<<6]) + expect(TestBitmask3.test_tagged_typedef_bitmask3(1<<3|1<<6|1<<7)).to eq([:c10,:c12,1<<7]) + expect(TestBitmask3.test_tagged_typedef_bitmask3([1<<3,1<<6,1<<7])).to eq([:c10,:c12,1<<7]) + expect(TestBitmask3.test_tagged_typedef_bitmask4(1<<4|1<<8|1<<9)).to eq([:c14,:c16,1<<9]) + expect(TestBitmask3.test_tagged_typedef_bitmask4([1<<4,1<<8,1<<9])).to eq([:c14,:c16,1<<9]) + expect(TestBitmask4.test_tagged_nonint_bitmask4(1<<7|1<<9|1<<10)).to eq([:c18,:c20,1<<10]) + expect(TestBitmask4.test_tagged_nonint_bitmask4([1<<7,1<<9,1<<10])).to eq([:c18,:c20,1<<10]) + expect(TestBitmask4.test_tagged_nonint_bitmask5(1<<7|1<<15|1<<16)).to eq([:c22,:c24,1<<16]) + expect(TestBitmask4.test_tagged_nonint_bitmask5([1<<7,1<<15,1<<16])).to eq([:c22,:c24,1<<16]) + expect(TestBitmask4.test_tagged_nonint_bitmask6(1<<14|1<<42|1<<43)).to eq([:c26,:c28,1<<43]) + expect(TestBitmask4.test_tagged_nonint_bitmask6([1<<14,1<<42,1<<43])).to eq([:c26,:c28,1<<43]) + end + + it "wrong constants rejected" do + expect { TestBitmask3.test_tagged_typedef_bitmask1([:c2,:c4,:c5]) }.to raise_error(ArgumentError) + expect { TestBitmask3.test_tagged_typedef_bitmask2([:c6,:c8,:c9]) }.to raise_error(ArgumentError) + expect { TestBitmask3.test_tagged_typedef_bitmask3([:c10,:c12,:c13]) }.to raise_error(ArgumentError) + expect { TestBitmask3.test_tagged_typedef_bitmask4([:c14,:c16,:c17]) }.to raise_error(ArgumentError) + expect { TestBitmask4.test_tagged_nonint_bitmask4([:c18,:c20,:c21]) }.to raise_error(ArgumentError) + expect { TestBitmask4.test_tagged_nonint_bitmask5([:c22,:c24,:c25]) }.to raise_error(ArgumentError) + expect { TestBitmask4.test_tagged_nonint_bitmask6([:c26,:c28,:c29]) }.to raise_error(ArgumentError) + end + +end + +describe "All bitmasks" do + it "have autonumbered constants when defined with names only" do + expect(TestBitmask1.enum_value(:c1)).to eq(1<<0) + expect(TestBitmask1.enum_value(:c2)).to eq(1<<1) + expect(TestBitmask1.enum_value(:c3)).to eq(1<<2) + expect(TestBitmask1.enum_value(:c4)).to eq(1<<3) + + expect(TestBitmask3.enum_value(:c1)).to eq(1<<0) + expect(TestBitmask3.enum_value(:c2)).to eq(1<<1) + expect(TestBitmask3.enum_value(:c3)).to eq(1<<2) + expect(TestBitmask3.enum_value(:c4)).to eq(1<<3) + + expect(TestBitmask4.enum_value(:c1)).to eq(1<<0) + expect(TestBitmask4.enum_value(:c2)).to eq(1<<1) + expect(TestBitmask4.enum_value(:c3)).to eq(1<<2) + expect(TestBitmask4.enum_value(:c4)).to eq(1<<3) + end + + it "can have an explicit first constant and autonumbered subsequent constants" do + expect(TestBitmask1.enum_value(:c5)).to eq(1<<2) + expect(TestBitmask1.enum_value(:c6)).to eq(1<<3) + expect(TestBitmask1.enum_value(:c7)).to eq(1<<4) + expect(TestBitmask1.enum_value(:c8)).to eq(1<<5) + + expect(TestBitmask3.enum_value(:c5)).to eq(1<<2) + expect(TestBitmask3.enum_value(:c6)).to eq(1<<3) + expect(TestBitmask3.enum_value(:c7)).to eq(1<<4) + expect(TestBitmask3.enum_value(:c8)).to eq(1<<5) + + expect(TestBitmask4.enum_value(:c5)).to eq(1<<6) + expect(TestBitmask4.enum_value(:c6)).to eq(1<<7) + expect(TestBitmask4.enum_value(:c7)).to eq(1<<8) + expect(TestBitmask4.enum_value(:c8)).to eq(1<<9) + + expect(TestBitmask4.enum_value(:c29)).to eq(1<<42) + expect(TestBitmask4.enum_value(:c30)).to eq(1<<43) + expect(TestBitmask4.enum_value(:c31)).to eq(1<<44) + expect(TestBitmask4.enum_value(:c32)).to eq(1<<45) + end + + it "can have a mix of explicit and autonumbered constants" do + expect(TestBitmask1.enum_value(:c9)).to eq(1<<2) + expect(TestBitmask1.enum_value(:c10)).to eq(1<<3) + expect(TestBitmask1.enum_value(:c11)).to eq(1<<5) + expect(TestBitmask1.enum_value(:c12)).to eq(1<<6) + + expect(TestBitmask3.enum_value(:c9)).to eq(1<<2) + expect(TestBitmask3.enum_value(:c10)).to eq(1<<3) + expect(TestBitmask3.enum_value(:c11)).to eq(1<<5) + expect(TestBitmask3.enum_value(:c12)).to eq(1<<6) + + expect(TestBitmask4.enum_value(:c9)).to eq(1<<6) + expect(TestBitmask4.enum_value(:c10)).to eq(1<<7) + expect(TestBitmask4.enum_value(:c11)).to eq(1<<14) + expect(TestBitmask4.enum_value(:c12)).to eq(1<<15) + + expect(TestBitmask4.enum_value(:c21)).to eq(1<<6) + expect(TestBitmask4.enum_value(:c22)).to eq(1<<7) + expect(TestBitmask4.enum_value(:c23)).to eq(1<<14) + expect(TestBitmask4.enum_value(:c24)).to eq(1<<15) + end + + it "can have all its constants explicitely valued" do + expect(TestBitmask1.enum_value(:c13)).to eq(1<<2) + expect(TestBitmask1.enum_value(:c14)).to eq(1<<4) + expect(TestBitmask1.enum_value(:c15)).to eq(1<<6) + expect(TestBitmask1.enum_value(:c16)).to eq(1<<8) + + expect(TestBitmask3.enum_value(:c13)).to eq(1<<2) + expect(TestBitmask3.enum_value(:c14)).to eq(1<<4) + expect(TestBitmask3.enum_value(:c15)).to eq(1<<6) + expect(TestBitmask3.enum_value(:c16)).to eq(1<<8) + + expect(TestBitmask4.enum_value(:c13)).to eq(1<<6) + expect(TestBitmask4.enum_value(:c14)).to eq(1<<14) + expect(TestBitmask4.enum_value(:c15)).to eq(1<<30) + expect(TestBitmask4.enum_value(:c16)).to eq(1<<42) + + expect(TestBitmask4.enum_value(:c25)).to eq(1<<6) + expect(TestBitmask4.enum_value(:c26)).to eq(1<<14) + expect(TestBitmask4.enum_value(:c27)).to eq(1<<30) + expect(TestBitmask4.enum_value(:c28)).to eq(1<<42) + end + + it "return a list containing a constant corresponding to a specific value" do + bitmask = TestBitmask3.enum_type(:bitmask_type1) + expect(bitmask[1<<0]).to eq([:c1]) + expect(bitmask[1<<1]).to eq([:c2]) + expect(bitmask[1<<2]).to eq([:c3]) + expect(bitmask[1<<3]).to eq([:c4]) + + bitmask = TestBitmask3.enum_type(:bitmask_type2) + expect(bitmask[1<<2]).to eq([:c5]) + expect(bitmask[1<<3]).to eq([:c6]) + expect(bitmask[1<<4]).to eq([:c7]) + expect(bitmask[1<<5]).to eq([:c8]) + + bitmask = TestBitmask3.enum_type(:bitmask_type3) + expect(bitmask[1<<2]).to eq([:c9]) + expect(bitmask[1<<3]).to eq([:c10]) + expect(bitmask[1<<5]).to eq([:c11]) + expect(bitmask[1<<6]).to eq([:c12]) + + bitmask = TestBitmask3.enum_type(:bitmask_type4) + expect(bitmask[1<<2]).to eq([:c13]) + expect(bitmask[1<<4]).to eq([:c14]) + expect(bitmask[1<<6]).to eq([:c15]) + expect(bitmask[1<<8]).to eq([:c16]) + + bitmask = TestBitmask4.enum_type(:bitmask_type1) + expect(bitmask[1<<6]).to eq([:c5]) + expect(bitmask[1<<7]).to eq([:c6]) + expect(bitmask[1<<8]).to eq([:c7]) + expect(bitmask[1<<9]).to eq([:c8]) + + bitmask = TestBitmask4.enum_type(:bitmask_type2) + expect(bitmask[1<<6]).to eq([:c9]) + expect(bitmask[1<<7]).to eq([:c10]) + expect(bitmask[1<<14]).to eq([:c11]) + expect(bitmask[1<<15]).to eq([:c12]) + + bitmask = TestBitmask4.enum_type(:bitmask_type3) + expect(bitmask[1<<6]).to eq([:c13]) + expect(bitmask[1<<14]).to eq([:c14]) + expect(bitmask[1<<30]).to eq([:c15]) + expect(bitmask[1<<42]).to eq([:c16]) + + bitmask = TestBitmask4.enum_type(:bitmask_type4) + expect(bitmask[1<<6]).to eq([:c17]) + expect(bitmask[1<<7]).to eq([:c18]) + expect(bitmask[1<<8]).to eq([:c19]) + expect(bitmask[1<<9]).to eq([:c20]) + + bitmask = TestBitmask4.enum_type(:bitmask_type5) + expect(bitmask[1<<6]).to eq([:c21]) + expect(bitmask[1<<7]).to eq([:c22]) + expect(bitmask[1<<14]).to eq([:c23]) + expect(bitmask[1<<15]).to eq([:c24]) + + bitmask = TestBitmask4.enum_type(:bitmask_type6) + expect(bitmask[1<<6]).to eq([:c25]) + expect(bitmask[1<<14]).to eq([:c26]) + expect(bitmask[1<<30]).to eq([:c27]) + expect(bitmask[1<<42]).to eq([:c28]) + end + + it "return a list containing constants corresponding to a specific value combination of values" do + bitmask = TestBitmask3.enum_type(:bitmask_type1) + expect(bitmask[1<<0|1<<1|1<<2|1<<3]).to eq([:c1,:c2,:c3,:c4]) + expect(bitmask[1<<0,1<<1,1<<2,1<<3]).to eq([:c1,:c2,:c3,:c4]) + expect(bitmask[-1]).to eq([:c1,:c2,:c3,:c4]) + expect(bitmask[1<<1|1<<3]).to eq([:c2,:c4]) + expect(bitmask[1<<1,1<<3]).to eq([:c2,:c4]) + expect(bitmask[1<<3|1<<5]).to eq([:c4]) + expect(bitmask[1<<3,1<<5]).to eq([:c4]) + + bitmask = TestBitmask3.enum_type(:bitmask_type2) + expect(bitmask[1<<2|1<<3|1<<4|1<<5]).to eq([:c5,:c6,:c7,:c8]) + expect(bitmask[1<<2,1<<3,1<<4,1<<5]).to eq([:c5,:c6,:c7,:c8]) + expect(bitmask[-1]).to eq([:c5,:c6,:c7,:c8]) + expect(bitmask[1<<3|1<<5]).to eq([:c6,:c8]) + expect(bitmask[1<<3,1<<5]).to eq([:c6,:c8]) + expect(bitmask[1<<5|1<<6]).to eq([:c8]) + expect(bitmask[1<<5,1<<6]).to eq([:c8]) + + bitmask = TestBitmask3.enum_type(:bitmask_type3) + expect(bitmask[1<<2|1<<3|1<<5|1<<6]).to eq([:c9,:c10,:c11,:c12]) + expect(bitmask[1<<2,1<<3,1<<5,1<<6]).to eq([:c9,:c10,:c11,:c12]) + expect(bitmask[-1]).to eq([:c9,:c10,:c11,:c12]) + expect(bitmask[1<<3|1<<6]).to eq([:c10,:c12]) + expect(bitmask[1<<3,1<<6]).to eq([:c10,:c12]) + expect(bitmask[1<<6|1<<7]).to eq([:c12]) + expect(bitmask[1<<6,1<<7]).to eq([:c12]) + + bitmask = TestBitmask3.enum_type(:bitmask_type4) + expect(bitmask[1<<2|1<<4|1<<6|1<<8]).to eq([:c13,:c14,:c15,:c16]) + expect(bitmask[1<<2,1<<4,1<<6,1<<8]).to eq([:c13,:c14,:c15,:c16]) + expect(bitmask[-1]).to eq([:c13,:c14,:c15,:c16]) + expect(bitmask[1<<4|1<<8]).to eq([:c14,:c16]) + expect(bitmask[1<<4,1<<8]).to eq([:c14,:c16]) + expect(bitmask[1<<8|1<<9]).to eq([:c16]) + expect(bitmask[1<<8,1<<9]).to eq([:c16]) + + bitmask = TestBitmask4.enum_type(:bitmask_type1) + expect(bitmask[1<<6|1<<7|1<<8|1<<9]).to eq([:c5,:c6,:c7,:c8]) + expect(bitmask[1<<6,1<<7,1<<8,1<<9]).to eq([:c5,:c6,:c7,:c8]) + expect(bitmask[-1]).to eq([:c5,:c6,:c7,:c8]) + expect(bitmask[1<<7|1<<9]).to eq([:c6,:c8]) + expect(bitmask[1<<7,1<<9]).to eq([:c6,:c8]) + expect(bitmask[1<<9|1<<10]).to eq([:c8]) + expect(bitmask[1<<9,1<<10]).to eq([:c8]) + + bitmask = TestBitmask4.enum_type(:bitmask_type2) + expect(bitmask[1<<6|1<<7|1<<14|1<<15]).to eq([:c9,:c10,:c11,:c12]) + expect(bitmask[1<<6,1<<7,1<<14,1<<15]).to eq([:c9,:c10,:c11,:c12]) + expect(bitmask[-1]).to eq([:c9,:c10,:c11,:c12]) + expect(bitmask[1<<7|1<<15]).to eq([:c10,:c12]) + expect(bitmask[1<<7,1<<15]).to eq([:c10,:c12]) + expect(bitmask[1<<15|1<<16]).to eq([:c12]) + expect(bitmask[1<<15,1<<16]).to eq([:c12]) + + bitmask = TestBitmask4.enum_type(:bitmask_type3) + expect(bitmask[1<<6|1<<14|1<<30|1<<42]).to eq([:c13,:c14,:c15,:c16]) + expect(bitmask[1<<6,1<<14,1<<30,1<<42]).to eq([:c13,:c14,:c15,:c16]) + expect(bitmask[-1]).to eq([:c13,:c14,:c15,:c16]) + expect(bitmask[1<<14|1<<42]).to eq([:c14,:c16]) + expect(bitmask[1<<14,1<<42]).to eq([:c14,:c16]) + expect(bitmask[1<<42|1<<43]).to eq([:c16]) + expect(bitmask[1<<42,1<<43]).to eq([:c16]) + + bitmask = TestBitmask4.enum_type(:bitmask_type4) + expect(bitmask[1<<6|1<<7|1<<8|1<<9]).to eq([:c17,:c18,:c19,:c20]) + expect(bitmask[1<<6,1<<7,1<<8,1<<9]).to eq([:c17,:c18,:c19,:c20]) + expect(bitmask[-1]).to eq([:c17,:c18,:c19,:c20]) + expect(bitmask[1<<7|1<<9]).to eq([:c18,:c20]) + expect(bitmask[1<<7,1<<9]).to eq([:c18,:c20]) + expect(bitmask[1<<9|1<<10]).to eq([:c20]) + expect(bitmask[1<<9,1<<10]).to eq([:c20]) + + bitmask = TestBitmask4.enum_type(:bitmask_type5) + expect(bitmask[1<<6|1<<7|1<<14|1<<15]).to eq([:c21,:c22,:c23,:c24]) + expect(bitmask[1<<6,1<<7,1<<14,1<<15]).to eq([:c21,:c22,:c23,:c24]) + expect(bitmask[-1]).to eq([:c21,:c22,:c23,:c24]) + expect(bitmask[1<<7|1<<15]).to eq([:c22,:c24]) + expect(bitmask[1<<7,1<<15]).to eq([:c22,:c24]) + expect(bitmask[1<<15|1<<16]).to eq([:c24]) + expect(bitmask[1<<15,1<<16]).to eq([:c24]) + + bitmask = TestBitmask4.enum_type(:bitmask_type6) + expect(bitmask[1<<6|1<<14|1<<30|1<<42]).to eq([:c25,:c26,:c27,:c28]) + expect(bitmask[1<<6,1<<14,1<<30,1<<42]).to eq([:c25,:c26,:c27,:c28]) + expect(bitmask[-1]).to eq([:c25,:c26,:c27,:c28]) + expect(bitmask[1<<14|1<<42]).to eq([:c26,:c28]) + expect(bitmask[1<<14,1<<42]).to eq([:c26,:c28]) + expect(bitmask[1<<42|1<<43]).to eq([:c28]) + expect(bitmask[1<<42,1<<43]).to eq([:c28]) + end + + it "return [] for values that don't have a symbol" do + bitmask = TestBitmask3.enum_type(:bitmask_type1) + expect(bitmask[1<<4]).to eq([]) + + bitmask = TestBitmask3.enum_type(:bitmask_type2) + expect(bitmask[1<<0]).to eq([]) + expect(bitmask[1<<1]).to eq([]) + expect(bitmask[1<<6]).to eq([]) + + bitmask = TestBitmask3.enum_type(:bitmask_type3) + expect(bitmask[1<<0]).to eq([]) + expect(bitmask[1<<1]).to eq([]) + expect(bitmask[1<<4]).to eq([]) + expect(bitmask[1<<7]).to eq([]) + + bitmask = TestBitmask3.enum_type(:bitmask_type4) + expect(bitmask[1<<0]).to eq([]) + expect(bitmask[1<<1]).to eq([]) + expect(bitmask[1<<3]).to eq([]) + expect(bitmask[1<<5]).to eq([]) + expect(bitmask[1<<7]).to eq([]) + expect(bitmask[1<<9]).to eq([]) + + bitmask = TestBitmask4.enum_type(:bitmask_type1) + expect(bitmask[1<<0]).to eq([]) + expect(bitmask[1<<5]).to eq([]) + expect(bitmask[1<<10]).to eq([]) + + bitmask = TestBitmask4.enum_type(:bitmask_type2) + expect(bitmask[1<<0]).to eq([]) + expect(bitmask[1<<5]).to eq([]) + expect(bitmask[1<<8]).to eq([]) + expect(bitmask[1<<13]).to eq([]) + expect(bitmask[1<<16]).to eq([]) + + bitmask = TestBitmask4.enum_type(:bitmask_type3) + expect(bitmask[1<<0]).to eq([]) + expect(bitmask[1<<5]).to eq([]) + expect(bitmask[1<<7]).to eq([]) + expect(bitmask[1<<13]).to eq([]) + expect(bitmask[1<<15]).to eq([]) + expect(bitmask[1<<29]).to eq([]) + expect(bitmask[1<<31]).to eq([]) + expect(bitmask[1<<41]).to eq([]) + expect(bitmask[1<<43]).to eq([]) + + bitmask = TestBitmask4.enum_type(:bitmask_type4) + expect(bitmask[1<<0]).to eq([]) + expect(bitmask[1<<5]).to eq([]) + expect(bitmask[1<<10]).to eq([]) + + bitmask = TestBitmask4.enum_type(:bitmask_type5) + expect(bitmask[1<<0]).to eq([]) + expect(bitmask[1<<5]).to eq([]) + expect(bitmask[1<<8]).to eq([]) + expect(bitmask[1<<13]).to eq([]) + expect(bitmask[1<<16]).to eq([]) + + bitmask = TestBitmask4.enum_type(:bitmask_type6) + expect(bitmask[1<<0]).to eq([]) + expect(bitmask[1<<5]).to eq([]) + expect(bitmask[1<<7]).to eq([]) + expect(bitmask[1<<13]).to eq([]) + expect(bitmask[1<<15]).to eq([]) + expect(bitmask[1<<29]).to eq([]) + expect(bitmask[1<<31]).to eq([]) + expect(bitmask[1<<41]).to eq([]) + expect(bitmask[1<<43]).to eq([]) + end + + it "duplicate bitmask keys rejected" do + expect do + Module.new do + extend FFI::Library + bitmask [ :a, 2, :b, 5, :a, 0 ] + end + end.to raise_error(ArgumentError, /duplicate/) + expect do + Module.new do + extend FFI::Library + bitmask FFI::Type::UINT64, [ :a, 2, :b, 5, :a, 0 ] + end + end.to raise_error(ArgumentError, /duplicate/) + end +end diff --git a/spec/ffi/buffer_spec.rb b/spec/ffi/buffer_spec.rb index 5f22a621436..b2ea6ee2d95 100644 --- a/spec/ffi/buffer_spec.rb +++ b/spec/ffi/buffer_spec.rb @@ -138,6 +138,14 @@ end describe "Reading/Writing binary strings" do + it "Buffer#write_bytes and read_bytes" do + str = "hello\0world" + buf = FFI::Buffer.new 11 + buf.write_bytes(str) + s2 = buf.read_bytes(11) + expect(s2).to eq(str) + end + it "Buffer#put_bytes" do str = "hello\0world" buf = FFI::Buffer.new 1024 @@ -165,19 +173,19 @@ it "Buffer#put_bytes with index > str.length" do str = "hello\0world" buf = FFI::Buffer.new 1024 - expect { buf.put_bytes(0, str, 12); }.to raise_error + expect { buf.put_bytes(0, str, 12); }.to raise_error(IndexError) end it "Buffer#put_bytes with length > str.length" do str = "hello\0world" buf = FFI::Buffer.new 1024 - expect { buf.put_bytes(0, str, 0, 12); }.to raise_error + expect { buf.put_bytes(0, str, 0, 12); }.to raise_error(RangeError) end it "Buffer#put_bytes with negative index" do str = "hello\0world" buf = FFI::Buffer.new 1024 - expect { buf.put_bytes(0, str, -1, 12); }.to raise_error + expect { buf.put_bytes(0, str, -1, 12); }.to raise_error(RangeError) end it "Buffer#write_bytes" do @@ -207,19 +215,19 @@ it "Buffer#write_bytes with index > str.length" do str = "hello\0world" buf = FFI::Buffer.new 1024 - expect { buf.write_bytes(str, 12) }.to raise_error + expect { buf.write_bytes(str, 12) }.to raise_error(IndexError) end it "Buffer#put_bytes with length > str.length" do str = "hello\0world" buf = FFI::Buffer.new 1024 - expect { buf.put_bytes(0, str, 0, 12) }.to raise_error + expect { buf.put_bytes(0, str, 0, 12) }.to raise_error(RangeError) end it "Buffer#write_bytes with negative index" do str = "hello\0world" buf = FFI::Buffer.new 1024 - expect { buf.write_bytes(str, -1, 12) }.to raise_error + expect { buf.write_bytes(str, -1, 12) }.to raise_error(RangeError) end end diff --git a/spec/ffi/callback_spec.rb b/spec/ffi/callback_spec.rb index bc9b55a8c78..b6ddafc4860 100644 --- a/spec/ffi/callback_spec.rb +++ b/spec/ffi/callback_spec.rb @@ -5,769 +5,879 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) -describe "Callback" do -# module LibC -# extend FFI::Library -# callback :qsort_cmp, [ :pointer, :pointer ], :int -# attach_function :qsort, [ :pointer, :int, :int, :qsort_cmp ], :int -# end -# it "arguments get passed correctly" do -# p = MemoryPointer.new(:int, 2) -# p.put_array_of_int32(0, [ 1 , 2 ]) -# args = [] -# cmp = proc do |p1, p2| args.push(p1.get_int(0)); args.push(p2.get_int(0)); 0; end -# # this is a bit dodgey, as it relies on qsort passing the args in order -# LibC.qsort(p, 2, 4, cmp) -# args.should == [ 1, 2 ] -# end -# -# it "Block can be substituted for Callback as last argument" do -# p = MemoryPointer.new(:int, 2) -# p.put_array_of_int32(0, [ 1 , 2 ]) -# args = [] -# # this is a bit dodgey, as it relies on qsort passing the args in order -# LibC.qsort(p, 2, 4) do |p1, p2| -# args.push(p1.get_int(0)) -# args.push(p2.get_int(0)) -# 0 -# end -# args.should == [ 1, 2 ] -# end - module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - class S8F32S32 < FFI::Struct - layout :s8, :char, :f32, :float, :s32, :int - end - - callback :cbVrS8, [ ], :char - callback :cbVrU8, [ ], :uchar - callback :cbVrS16, [ ], :short - callback :cbVrU16, [ ], :ushort - callback :cbVrS32, [ ], :int - callback :cbVrU32, [ ], :uint - callback :cbVrL, [ ], :long - callback :cbVrUL, [ ], :ulong - callback :cbVrS64, [ ], :long_long - callback :cbVrU64, [ ], :ulong_long - callback :cbVrP, [], :pointer - callback :cbVrZ, [], :bool - callback :cbCrV, [ :char ], :void - callback :cbSrV, [ :short ], :void - callback :cbIrV, [ :int ], :void - callback :cbLrV, [ :long ], :void - callback :cbULrV, [ :ulong ], :void - callback :cbLrV, [ :long_long ], :void - callback :cbVrT, [ ], S8F32S32.by_value - callback :cbTrV, [ S8F32S32.by_value ], :void - callback :cbYrV, [ S8F32S32.ptr ], :void - callback :cbVrY, [ ], S8F32S32.ptr - - attach_function :testCallbackVrS8, :testClosureVrB, [ :cbVrS8 ], :char - attach_function :testCallbackVrU8, :testClosureVrB, [ :cbVrU8 ], :uchar - attach_function :testCallbackVrS16, :testClosureVrS, [ :cbVrS16 ], :short - attach_function :testCallbackVrU16, :testClosureVrS, [ :cbVrU16 ], :ushort - attach_function :testCallbackVrS32, :testClosureVrI, [ :cbVrS32 ], :int - attach_function :testCallbackVrU32, :testClosureVrI, [ :cbVrU32 ], :uint - attach_function :testCallbackVrL, :testClosureVrL, [ :cbVrL ], :long - attach_function :testCallbackVrZ, :testClosureVrZ, [ :cbVrZ ], :bool - attach_function :testCallbackVrUL, :testClosureVrL, [ :cbVrUL ], :ulong - attach_function :testCallbackVrS64, :testClosureVrLL, [ :cbVrS64 ], :long_long - attach_function :testCallbackVrU64, :testClosureVrLL, [ :cbVrU64 ], :ulong_long - attach_function :testCallbackVrP, :testClosureVrP, [ :cbVrP ], :pointer - attach_function :testCallbackVrY, :testClosureVrP, [ :cbVrY ], S8F32S32.ptr - attach_function :testCallbackVrT, :testClosureVrT, [ :cbVrT ], S8F32S32.by_value - attach_function :testCallbackTrV, :testClosureTrV, [ :cbTrV, S8F32S32.ptr ], :void - attach_variable :cbVrS8, :gvar_pointer, :cbVrS8 - attach_variable :pVrS8, :gvar_pointer, :pointer - attach_function :testGVarCallbackVrS8, :testClosureVrB, [ :pointer ], :char - attach_function :testOptionalCallbackCrV, :testOptionalClosureBrV, [ :cbCrV, :char ], :void +module CallbackSpecs + describe "Callback" do + # module LibC + # extend FFI::Library + # callback :qsort_cmp, [ :pointer, :pointer ], :int + # attach_function :qsort, [ :pointer, :int, :int, :qsort_cmp ], :int + # end + # it "arguments get passed correctly" do + # p = MemoryPointer.new(:int, 2) + # p.put_array_of_int32(0, [ 1 , 2 ]) + # args = [] + # cmp = proc do |p1, p2| args.push(p1.get_int(0)); args.push(p2.get_int(0)); 0; end + # # this is a bit dodgey, as it relies on qsort passing the args in order + # LibC.qsort(p, 2, 4, cmp) + # args.should == [ 1, 2 ] + # end + # + # it "Block can be substituted for Callback as last argument" do + # p = MemoryPointer.new(:int, 2) + # p.put_array_of_int32(0, [ 1 , 2 ]) + # args = [] + # # this is a bit dodgey, as it relies on qsort passing the args in order + # LibC.qsort(p, 2, 4) do |p1, p2| + # args.push(p1.get_int(0)) + # args.push(p2.get_int(0)) + # 0 + # end + # args.should == [ 1, 2 ] + # end + module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + class S8F32S32 < FFI::Struct + layout :s8, :char, :f32, :float, :s32, :int + end - end + callback :cbVrS8, [ ], :char + callback :cbVrU8, [ ], :uchar + callback :cbVrS16, [ ], :short + callback :cbVrU16, [ ], :ushort + callback :cbVrS32, [ ], :int + callback :cbVrU32, [ ], :uint + callback :cbVrL, [ ], :long + callback :cbVrUL, [ ], :ulong + callback :cbVrS64, [ ], :long_long + callback :cbVrU64, [ ], :ulong_long + callback :cbVrP, [], :pointer + callback :cbVrZ, [], :bool + callback :cbCrV, [ :char ], :void + callback :cbSrV, [ :short ], :void + callback :cbIrV, [ :int ], :void + callback :cbLrV, [ :long ], :void + callback :cbULrV, [ :ulong ], :void + callback :cbLrV, [ :long_long ], :void + callback :cbVrT, [ ], S8F32S32.by_value + callback :cbTrV, [ S8F32S32.by_value ], :void + callback :cbYrV, [ S8F32S32.ptr ], :void + callback :cbVrY, [ ], S8F32S32.ptr + + attach_function :testCallbackVrS8, :testClosureVrB, [ :cbVrS8 ], :char + attach_function :testCallbackVrU8, :testClosureVrB, [ :cbVrU8 ], :uchar + attach_function :testCallbackVrS16, :testClosureVrS, [ :cbVrS16 ], :short + attach_function :testCallbackVrU16, :testClosureVrS, [ :cbVrU16 ], :ushort + attach_function :testCallbackVrS32, :testClosureVrI, [ :cbVrS32 ], :int + attach_function :testCallbackVrU32, :testClosureVrI, [ :cbVrU32 ], :uint + attach_function :testCallbackVrL, :testClosureVrL, [ :cbVrL ], :long + attach_function :testCallbackVrZ, :testClosureVrZ, [ :cbVrZ ], :bool + attach_function :testCallbackVrUL, :testClosureVrL, [ :cbVrUL ], :ulong + attach_function :testCallbackVrS64, :testClosureVrLL, [ :cbVrS64 ], :long_long + attach_function :testCallbackVrU64, :testClosureVrLL, [ :cbVrU64 ], :ulong_long + attach_function :testCallbackVrP, :testClosureVrP, [ :cbVrP ], :pointer + attach_function :testCallbackReturningFunction, :testClosureVrP, [ :cbVrP ], :cbVrP + attach_function :testCallbackVrY, :testClosureVrP, [ :cbVrY ], S8F32S32.ptr + attach_function :testCallbackVrT, :testClosureVrT, [ :cbVrT ], S8F32S32.by_value + attach_function :testCallbackTrV, :testClosureTrV, [ :cbTrV, S8F32S32.ptr ], :void + attach_variable :cbVrS8, :gvar_pointer, :cbVrS8 + attach_variable :pVrS8, :gvar_pointer, :pointer + attach_function :testGVarCallbackVrS8, :testClosureVrB, [ :pointer ], :char + attach_function :testOptionalCallbackCrV, :testOptionalClosureBrV, [ :cbCrV, :char ], :void - it "returning :char (0)" do - expect(LibTest.testCallbackVrS8 { 0 }).to eq(0) - end + end - it "returning :char (127)" do - expect(LibTest.testCallbackVrS8 { 127 }).to eq(127) - end + it "returning :char (0)" do + expect(LibTest.testCallbackVrS8 { 0 }).to eq(0) + end - it "returning :char (-128)" do - expect(LibTest.testCallbackVrS8 { -128 }).to eq(-128) - end - # test wrap around - it "returning :char (128)" do - expect(LibTest.testCallbackVrS8 { 128 }).to eq(-128) - end + it "returning :char (127)" do + expect(LibTest.testCallbackVrS8 { 127 }).to eq(127) + end - it "returning :char (255)" do - expect(LibTest.testCallbackVrS8 { 0xff }).to eq(-1) - end + it "returning :char (-128)" do + expect(LibTest.testCallbackVrS8 { -128 }).to eq(-128) + end + # test wrap around + it "returning :char (128)" do + expect(LibTest.testCallbackVrS8 { 128 }).to eq(-128) + end - it "returning :uchar (0)" do - expect(LibTest.testCallbackVrU8 { 0 }).to eq(0) - end + it "returning :char (255)" do + expect(LibTest.testCallbackVrS8 { 0xff }).to eq(-1) + end - it "returning :uchar (0xff)" do - expect(LibTest.testCallbackVrU8 { 0xff }).to eq(0xff) - end + it "returning :uchar (0)" do + expect(LibTest.testCallbackVrU8 { 0 }).to eq(0) + end - it "returning :uchar (-1)" do - expect(LibTest.testCallbackVrU8 { -1 }).to eq(0xff) - end + it "returning :uchar (0xff)" do + expect(LibTest.testCallbackVrU8 { 0xff }).to eq(0xff) + end - it "returning :uchar (128)" do - expect(LibTest.testCallbackVrU8 { 128 }).to eq(128) - end + it "returning :uchar (-1)" do + expect(LibTest.testCallbackVrU8 { -1 }).to eq(0xff) + end - it "returning :uchar (-128)" do - expect(LibTest.testCallbackVrU8 { -128 }).to eq(128) - end + it "returning :uchar (128)" do + expect(LibTest.testCallbackVrU8 { 128 }).to eq(128) + end - it "returning :short (0)" do - expect(LibTest.testCallbackVrS16 { 0 }).to eq(0) - end + it "returning :uchar (-128)" do + expect(LibTest.testCallbackVrU8 { -128 }).to eq(128) + end - it "returning :short (0x7fff)" do - expect(LibTest.testCallbackVrS16 { 0x7fff }).to eq(0x7fff) - end - # test wrap around - it "returning :short (0x8000)" do - expect(LibTest.testCallbackVrS16 { 0x8000 }).to eq(-0x8000) - end + it "returning :short (0)" do + expect(LibTest.testCallbackVrS16 { 0 }).to eq(0) + end - it "returning :short (0xffff)" do - expect(LibTest.testCallbackVrS16 { 0xffff }).to eq(-1) - end + it "returning :short (0x7fff)" do + expect(LibTest.testCallbackVrS16 { 0x7fff }).to eq(0x7fff) + end + # test wrap around + it "returning :short (0x8000)" do + expect(LibTest.testCallbackVrS16 { 0x8000 }).to eq(-0x8000) + end - it "returning :ushort (0)" do - expect(LibTest.testCallbackVrU16 { 0 }).to eq(0) - end + it "returning :short (0xffff)" do + expect(LibTest.testCallbackVrS16 { 0xffff }).to eq(-1) + end - it "returning :ushort (0x7fff)" do - expect(LibTest.testCallbackVrU16 { 0x7fff }).to eq(0x7fff) - end + it "returning :ushort (0)" do + expect(LibTest.testCallbackVrU16 { 0 }).to eq(0) + end - it "returning :ushort (0x8000)" do - expect(LibTest.testCallbackVrU16 { 0x8000 }).to eq(0x8000) - end + it "returning :ushort (0x7fff)" do + expect(LibTest.testCallbackVrU16 { 0x7fff }).to eq(0x7fff) + end - it "returning :ushort (0xffff)" do - expect(LibTest.testCallbackVrU16 { 0xffff }).to eq(0xffff) - end + it "returning :ushort (0x8000)" do + expect(LibTest.testCallbackVrU16 { 0x8000 }).to eq(0x8000) + end - it "returning :ushort (-1)" do - expect(LibTest.testCallbackVrU16 { -1 }).to eq(0xffff) - end + it "returning :ushort (0xffff)" do + expect(LibTest.testCallbackVrU16 { 0xffff }).to eq(0xffff) + end - it "returning :int (0)" do - expect(LibTest.testCallbackVrS32 { 0 }).to eq(0) - end + it "returning :ushort (-1)" do + expect(LibTest.testCallbackVrU16 { -1 }).to eq(0xffff) + end - it "returning :int (0x7fffffff)" do - expect(LibTest.testCallbackVrS32 { 0x7fffffff }).to eq(0x7fffffff) - end - # test wrap around - it "returning :int (-0x80000000)" do - expect(LibTest.testCallbackVrS32 { -0x80000000 }).to eq(-0x80000000) - end + it "returning :int (0)" do + expect(LibTest.testCallbackVrS32 { 0 }).to eq(0) + end - it "returning :int (-1)" do - expect(LibTest.testCallbackVrS32 { -1 }).to eq(-1) - end + it "returning :int (0x7fffffff)" do + expect(LibTest.testCallbackVrS32 { 0x7fffffff }).to eq(0x7fffffff) + end + # test wrap around + it "returning :int (-0x80000000)" do + expect(LibTest.testCallbackVrS32 { -0x80000000 }).to eq(-0x80000000) + end - it "returning :uint (0)" do - expect(LibTest.testCallbackVrU32 { 0 }).to eq(0) - end + it "returning :int (-1)" do + expect(LibTest.testCallbackVrS32 { -1 }).to eq(-1) + end - it "returning :uint (0x7fffffff)" do - expect(LibTest.testCallbackVrU32 { 0x7fffffff }).to eq(0x7fffffff) - end - # test wrap around - it "returning :uint (0x80000000)" do - expect(LibTest.testCallbackVrU32 { 0x80000000 }).to eq(0x80000000) - end + it "returning :uint (0)" do + expect(LibTest.testCallbackVrU32 { 0 }).to eq(0) + end - it "returning :uint (0xffffffff)" do - expect(LibTest.testCallbackVrU32 { 0xffffffff }).to eq(0xffffffff) - end + it "returning :uint (0x7fffffff)" do + expect(LibTest.testCallbackVrU32 { 0x7fffffff }).to eq(0x7fffffff) + end + # test wrap around + it "returning :uint (0x80000000)" do + expect(LibTest.testCallbackVrU32 { 0x80000000 }).to eq(0x80000000) + end - it "returning :uint (-1)" do - expect(LibTest.testCallbackVrU32 { -1 }).to eq(0xffffffff) - end + it "returning :uint (0xffffffff)" do + expect(LibTest.testCallbackVrU32 { 0xffffffff }).to eq(0xffffffff) + end - it "returning :long (0)" do - expect(LibTest.testCallbackVrL { 0 }).to eq(0) - end + it "returning :uint (-1)" do + expect(LibTest.testCallbackVrU32 { -1 }).to eq(0xffffffff) + end - it "returning :long (0x7fffffff)" do - expect(LibTest.testCallbackVrL { 0x7fffffff }).to eq(0x7fffffff) - end - # test wrap around - it "returning :long (-0x80000000)" do - expect(LibTest.testCallbackVrL { -0x80000000 }).to eq(-0x80000000) - end + it "returning :long (0)" do + expect(LibTest.testCallbackVrL { 0 }).to eq(0) + end - it "returning :long (-1)" do - expect(LibTest.testCallbackVrL { -1 }).to eq(-1) - end + it "returning :long (0x7fffffff)" do + expect(LibTest.testCallbackVrL { 0x7fffffff }).to eq(0x7fffffff) + end + # test wrap around + it "returning :long (-0x80000000)" do + expect(LibTest.testCallbackVrL { -0x80000000 }).to eq(-0x80000000) + end - it "returning :ulong (0)" do - expect(LibTest.testCallbackVrUL { 0 }).to eq(0) - end + it "returning :long (-1)" do + expect(LibTest.testCallbackVrL { -1 }).to eq(-1) + end - it "returning :ulong (0x7fffffff)" do - expect(LibTest.testCallbackVrUL { 0x7fffffff }).to eq(0x7fffffff) - end - # test wrap around - it "returning :ulong (0x80000000)" do - expect(LibTest.testCallbackVrUL { 0x80000000 }).to eq(0x80000000) - end + it "returning :ulong (0)" do + expect(LibTest.testCallbackVrUL { 0 }).to eq(0) + end - it "returning :ulong (0xffffffff)" do - expect(LibTest.testCallbackVrUL { 0xffffffff }).to eq(0xffffffff) - end + it "returning :ulong (0x7fffffff)" do + expect(LibTest.testCallbackVrUL { 0x7fffffff }).to eq(0x7fffffff) + end + # test wrap around + it "returning :ulong (0x80000000)" do + expect(LibTest.testCallbackVrUL { 0x80000000 }).to eq(0x80000000) + end - it "Callback returning :ulong (-1)" do - if FFI::Platform::LONG_SIZE == 32 - expect(LibTest.testCallbackVrUL { -1 }).to eq(0xffffffff) - else - expect(LibTest.testCallbackVrUL { -1 }).to eq(0xffffffffffffffff) + it "returning :ulong (0xffffffff)" do + expect(LibTest.testCallbackVrUL { 0xffffffff }).to eq(0xffffffff) end - end - it "returning :long_long (0)" do - expect(LibTest.testCallbackVrS64 { 0 }).to eq(0) - end + it "Callback returning :ulong (-1)" do + if FFI::Platform::LONG_SIZE == 32 + expect(LibTest.testCallbackVrUL { -1 }).to eq(0xffffffff) + else + expect(LibTest.testCallbackVrUL { -1 }).to eq(0xffffffffffffffff) + end + end - it "returning :long_long (0x7fffffffffffffff)" do - expect(LibTest.testCallbackVrS64 { 0x7fffffffffffffff }).to eq(0x7fffffffffffffff) - end - # test wrap around - it "returning :long_long (-0x8000000000000000)" do - expect(LibTest.testCallbackVrS64 { -0x8000000000000000 }).to eq(-0x8000000000000000) - end + it "returning :long_long (0)" do + expect(LibTest.testCallbackVrS64 { 0 }).to eq(0) + end - it "returning :long_long (-1)" do - expect(LibTest.testCallbackVrS64 { -1 }).to eq(-1) - end + it "returning :long_long (0x7fffffffffffffff)" do + expect(LibTest.testCallbackVrS64 { 0x7fffffffffffffff }).to eq(0x7fffffffffffffff) + end + # test wrap around + it "returning :long_long (-0x8000000000000000)" do + expect(LibTest.testCallbackVrS64 { -0x8000000000000000 }).to eq(-0x8000000000000000) + end - it "returning bool" do - expect(LibTest.testCallbackVrZ { true }).to be true - end + it "returning :long_long (-1)" do + expect(LibTest.testCallbackVrS64 { -1 }).to eq(-1) + end - it "returning :pointer (nil)" do - expect(LibTest.testCallbackVrP { nil }).to be_null - end + it "returning bool" do + expect(LibTest.testCallbackVrZ { true }).to be true + end - it "returning :pointer (MemoryPointer)" do - p = FFI::MemoryPointer.new :long - expect(LibTest.testCallbackVrP { p }).to eq(p) - end + it "returning :pointer (nil)" do + expect(LibTest.testCallbackVrP { nil }).to be_null + end - it "returning struct by value" do - s = LibTest::S8F32S32.new - s[:s8] = 0x12 - s[:s32] = 0x1eefbeef - s[:f32] = 1.234567 - ret = LibTest.testCallbackVrT { s } - expect(ret[:s8]).to eq(s[:s8]) - expect(ret[:f32]).to eq(s[:f32]) - expect(ret[:s32]).to eq(s[:s32]) + it "returning :pointer (MemoryPointer)" do + p = FFI::MemoryPointer.new :long + expect(LibTest.testCallbackVrP { p }).to eq(p) + end - end + it "returning a callback function" do + ret = LibTest.testCallbackReturningFunction { FFI::Pointer.new(42) } + expect(ret).to be_kind_of(FFI::Function) + expect(ret.address).to eq(42) + end - it "struct by value parameter" do - s = LibTest::S8F32S32.new - s[:s8] = 0x12 - s[:s32] = 0x1eefbeef - s[:f32] = 1.234567 - s2 = LibTest::S8F32S32.new + it "returning struct by value" do + skip "Segfault on 32 bit MINGW" if RUBY_PLATFORM == 'i386-mingw32' + s = LibTest::S8F32S32.new + s[:s8] = 0x12 + s[:s32] = 0x1eefbeef + s[:f32] = 1.234567 + ret = LibTest.testCallbackVrT { s } + expect(ret[:s8]).to eq(s[:s8]) + expect(ret[:f32]).to eq(s[:f32]) + expect(ret[:s32]).to eq(s[:s32]) - LibTest.testCallbackTrV(s) do |struct| - s2[:s8] = struct[:s8] - s2[:f32] = struct[:f32] - s2[:s32] = struct[:s32] end - expect(s2[:s8]).to eql 0x12 - expect(s2[:s32]).to eql 0x1eefbeef - expect(s2[:f32]).to be_within(0.0000001).of 1.234567 - end + it "struct by value parameter" do + s = LibTest::S8F32S32.new + s[:s8] = 0x12 + s[:s32] = 0x1eefbeef + s[:f32] = 1.234567 + s2 = LibTest::S8F32S32.new + + LibTest.testCallbackTrV(s) do |struct| + s2[:s8] = struct[:s8] + s2[:f32] = struct[:f32] + s2[:s32] = struct[:s32] + end + + expect(s2[:s8]).to eql 0x12 + expect(s2[:s32]).to eql 0x1eefbeef + expect(s2[:f32]).to be_within(0.0000001).of 1.234567 + end - - it "global variable" do - proc = Proc.new { 0x1e } - LibTest.cbVrS8 = proc - expect(LibTest.testGVarCallbackVrS8(LibTest.pVrS8)).to eq(0x1e) - end - describe "When the callback is considered optional by the underlying library" do - it "should handle receiving 'nil' in place of the closure" do - expect(LibTest.testOptionalCallbackCrV(nil, 13)).to be_nil + it "global variable" do + proc = Proc.new { 0x1e } + LibTest.cbVrS8 = proc + expect(LibTest.testGVarCallbackVrS8(LibTest.pVrS8)).to eq(0x1e) end - end - describe 'when inlined' do - it 'could be anonymous' do - module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - attach_function :testAnonymousCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char + describe "When the callback is considered optional by the underlying library" do + it "should handle receiving 'nil' in place of the closure" do + expect(LibTest.testOptionalCallbackCrV(nil, 13)).to be_nil end - expect(LibTest.testAnonymousCallbackVrS8 { 0 }).to eq(0) end - end - - describe "as return value" do - it "should not blow up when a callback is defined that returns a callback" do - expect(module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - callback :cb_return_type_1, [ :short ], :short - callback :cb_lookup_1, [ :short ], :cb_return_type_1 - attach_function :testReturnsCallback_1, :testReturnsClosure, [ :cb_lookup_1, :short ], :cb_return_type_1 - end).to be_an_instance_of FFI::Function + describe 'when inlined' do + it 'could be anonymous' do + module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + attach_function :testAnonymousCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char + end + expect(LibTest.testAnonymousCallbackVrS8 { 0 }).to eq(0) + end end - it "should return a callback" do - module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - callback :cb_return_type, [ :int ], :int - callback :cb_lookup, [ ], :cb_return_type - attach_function :testReturnsCallback, :testReturnsClosure, [ :cb_lookup, :int ], :int - end - - lookup_proc_called = false - return_proc_called = false + describe "as return value" do - return_proc = Proc.new do |a| - return_proc_called = true - a * 2 - end - lookup_proc = Proc.new do - lookup_proc_called = true - return_proc + it "should not blow up when a callback is defined that returns a callback" do + expect(module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + callback :cb_return_type_1, [ :short ], :short + callback :cb_lookup_1, [ :short ], :cb_return_type_1 + attach_function :testReturnsCallback_1, :testReturnsClosure, [ :cb_lookup_1, :short ], :cb_return_type_1 + end).to be_an_instance_of FFI::Function end - val = LibTest.testReturnsCallback(lookup_proc, 0x1234) - expect(val).to eq(0x1234 * 2) - expect(lookup_proc_called).to be true - expect(return_proc_called).to be true - end + it "should return a callback" do + module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + callback :cb_return_type, [ :int ], :int + callback :cb_lookup, [ ], :cb_return_type + attach_function :testReturnsCallback, :testReturnsClosure, [ :cb_lookup, :int ], :int + end - it "should return a method callback" do - module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - callback :cb_return_type, [ :int ], :int - callback :cb_lookup, [ ], :cb_return_type - attach_function :testReturnsCallback_2, :testReturnsClosure, [ :cb_lookup, :int ], :int - end - module MethodCallback - def self.lookup - method(:perform) + lookup_proc_called = false + return_proc_called = false + + return_proc = Proc.new do |a| + return_proc_called = true + a * 2 end - def self.perform num - num * 2 + lookup_proc = Proc.new do + lookup_proc_called = true + return_proc end + + val = LibTest.testReturnsCallback(lookup_proc, 0x1234) + expect(val).to eq(0x1234 * 2) + expect(lookup_proc_called).to be true + expect(return_proc_called).to be true end - expect(LibTest.testReturnsCallback_2(MethodCallback.method(:lookup), 0x1234)).to eq(0x2468) - end + it "should return a method callback" do + module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + callback :cb_return_type, [ :int ], :int + callback :cb_lookup, [ ], :cb_return_type + attach_function :testReturnsCallback_2, :testReturnsClosure, [ :cb_lookup, :int ], :int + end + module MethodCallback + def self.lookup + method(:perform) + end + def self.perform num + num * 2 + end + end - it 'should not blow up when a callback takes a callback as argument' do - expect(module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - callback :cb_argument, [ :int ], :int - callback :cb_with_cb_argument, [ :cb_argument, :int ], :int - attach_function :testCallbackAsArgument_2, :testArgumentClosure, [ :cb_with_cb_argument, :int ], :int - end).to be_an_instance_of FFI::Function - end - it 'should be able to use the callback argument' do - module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - callback :cb_argument, [ :int ], :int - callback :cb_with_cb_argument, [ :cb_argument, :int ], :int - attach_function :testCallbackAsArgument, :testArgumentClosure, [ :cb_with_cb_argument, :cb_argument, :int ], :int - end - callback_arg_called = false - callback_with_callback_arg_called = false - callback_arg = Proc.new do |val| - callback_arg_called = true - val * 2 + expect(LibTest.testReturnsCallback_2(MethodCallback.method(:lookup), 0x1234)).to eq(0x2468) end - callback_with_callback_arg = Proc.new do |cb, val| - callback_with_callback_arg_called = true - cb.call(val) + + it 'should not blow up when a callback takes a callback as argument' do + expect(module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + callback :cb_argument, [ :int ], :int + callback :cb_with_cb_argument, [ :cb_argument, :int ], :int + attach_function :testCallbackAsArgument_2, :testArgumentClosure, [ :cb_with_cb_argument, :int ], :int + end).to be_an_instance_of FFI::Function end - val = LibTest.testCallbackAsArgument(callback_with_callback_arg, callback_arg, 0xff1) - expect(val).to eq(0xff1 * 2) - expect(callback_arg_called).to be true - expect(callback_with_callback_arg_called).to be true - end - it 'function returns callable object' do - module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - callback :funcptr, [ :int ], :int - attach_function :testReturnsFunctionPointer, [ ], :funcptr + it 'should be able to use the callback argument' do + module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + callback :cb_argument, [ :int ], :int + callback :cb_with_cb_argument, [ :cb_argument, :int ], :int + attach_function :testCallbackAsArgument, :testArgumentClosure, [ :cb_with_cb_argument, :cb_argument, :int ], :int + end + callback_arg_called = false + callback_with_callback_arg_called = false + callback_arg = Proc.new do |val| + callback_arg_called = true + val * 2 + end + callback_with_callback_arg = Proc.new do |cb, val| + callback_with_callback_arg_called = true + cb.call(val) + end + val = LibTest.testCallbackAsArgument(callback_with_callback_arg, callback_arg, 0xff1) + expect(val).to eq(0xff1 * 2) + expect(callback_arg_called).to be true + expect(callback_with_callback_arg_called).to be true + end + it 'function returns callable object' do + module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + callback :funcptr, [ :int ], :int + attach_function :testReturnsFunctionPointer, [ ], :funcptr + end + f = LibTest.testReturnsFunctionPointer + expect(f.call(3)).to eq(6) end - f = LibTest.testReturnsFunctionPointer - expect(f.call(3)).to eq(6) end end - end +module CallbackWithSpecs + describe "Callback with " do + # + # Test callbacks that take an argument, returning void + # + module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + class S8F32S32 < FFI::Struct + layout :s8, :char, :f32, :float, :s32, :int + end -describe "Callback with " do - # - # Test callbacks that take an argument, returning void - # - module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - - class S8F32S32 < FFI::Struct - layout :s8, :char, :f32, :float, :s32, :int - end - - callback :cbS8rV, [ :char ], :void - callback :cbU8rV, [ :uchar ], :void - callback :cbS16rV, [ :short ], :void - callback :cbU16rV, [ :ushort ], :void - - callback :cbZrV, [ :bool ], :void - callback :cbS32rV, [ :int ], :void - callback :cbU32rV, [ :uint ], :void - - callback :cbLrV, [ :long ], :void - callback :cbULrV, [ :ulong ], :void - callback :cbArV, [ :string ], :void - callback :cbPrV, [ :pointer], :void - callback :cbYrV, [ S8F32S32.ptr ], :void - - callback :cbS64rV, [ :long_long ], :void - attach_function :testCallbackCrV, :testClosureBrV, [ :cbS8rV, :char ], :void - attach_function :testCallbackU8rV, :testClosureBrV, [ :cbU8rV, :uchar ], :void - attach_function :testCallbackSrV, :testClosureSrV, [ :cbS16rV, :short ], :void - attach_function :testCallbackU16rV, :testClosureSrV, [ :cbU16rV, :ushort ], :void - attach_function :testCallbackZrV, :testClosureZrV, [ :cbZrV, :bool ], :void - attach_function :testCallbackIrV, :testClosureIrV, [ :cbS32rV, :int ], :void - attach_function :testCallbackU32rV, :testClosureIrV, [ :cbU32rV, :uint ], :void - - attach_function :testCallbackLrV, :testClosureLrV, [ :cbLrV, :long ], :void - attach_function :testCallbackULrV, :testClosureULrV, [ :cbULrV, :ulong ], :void - - attach_function :testCallbackLLrV, :testClosureLLrV, [ :cbS64rV, :long_long ], :void - attach_function :testCallbackArV, :testClosurePrV, [ :cbArV, :string ], :void - attach_function :testCallbackPrV, :testClosurePrV, [ :cbPrV, :pointer], :void - attach_function :testCallbackYrV, :testClosurePrV, [ :cbYrV, S8F32S32.in ], :void - end + callback :cbS8rV, [ :char ], :void + callback :cbU8rV, [ :uchar ], :void + callback :cbS16rV, [ :short ], :void + callback :cbU16rV, [ :ushort ], :void + + callback :cbZrV, [ :bool ], :void + callback :cbS32rV, [ :int ], :void + callback :cbU32rV, [ :uint ], :void + + callback :cbLrV, [ :long ], :void + callback :cbULrV, [ :ulong ], :void + callback :cbArV, [ :string ], :void + callback :cbPrV, [ :pointer], :void + callback :cbYrV, [ S8F32S32.ptr ], :void + + callback :cbS64rV, [ :long_long ], :void + attach_function :testCallbackCrV, :testClosureBrV, [ :cbS8rV, :char ], :void + attach_function :testCallbackU8rV, :testClosureBrV, [ :cbU8rV, :uchar ], :void + attach_function :testCallbackSrV, :testClosureSrV, [ :cbS16rV, :short ], :void + attach_function :testCallbackU16rV, :testClosureSrV, [ :cbU16rV, :ushort ], :void + attach_function :testCallbackZrV, :testClosureZrV, [ :cbZrV, :bool ], :void + attach_function :testCallbackIrV, :testClosureIrV, [ :cbS32rV, :int ], :void + attach_function :testCallbackU32rV, :testClosureIrV, [ :cbU32rV, :uint ], :void + + attach_function :testCallbackLrV, :testClosureLrV, [ :cbLrV, :long ], :void + attach_function :testCallbackULrV, :testClosureULrV, [ :cbULrV, :ulong ], :void + + attach_function :testCallbackLLrV, :testClosureLLrV, [ :cbS64rV, :long_long ], :void + attach_function :testCallbackArV, :testClosurePrV, [ :cbArV, :string ], :void + attach_function :testCallbackPrV, :testClosurePrV, [ :cbPrV, :pointer], :void + attach_function :testCallbackYrV, :testClosurePrV, [ :cbYrV, S8F32S32.in ], :void + end - it "function with Callback plus another arg should raise error if no arg given" do - expect { LibTest.testCallbackCrV { |*a| }}.to raise_error - end + it "function with Callback plus another arg should raise error if no arg given" do + expect { LibTest.testCallbackCrV { |*a| }}.to raise_error(ArgumentError) + end - it ":char (0) argument" do - v = 0xdeadbeef - LibTest.testCallbackCrV(0) { |i| v = i } - expect(v).to eq(0) - end + it ":char (0) argument" do + v = 0xdeadbeef + LibTest.testCallbackCrV(0) { |i| v = i } + expect(v).to eq(0) + end - it ":char (127) argument" do - v = 0xdeadbeef - LibTest.testCallbackCrV(127) { |i| v = i } - expect(v).to eq(127) - end + it ":char (127) argument" do + v = 0xdeadbeef + LibTest.testCallbackCrV(127) { |i| v = i } + expect(v).to eq(127) + end - it ":char (-128) argument" do - v = 0xdeadbeef - LibTest.testCallbackCrV(-128) { |i| v = i } - expect(v).to eq(-128) - end + it ":char (-128) argument" do + v = 0xdeadbeef + LibTest.testCallbackCrV(-128) { |i| v = i } + expect(v).to eq(-128) + end - it ":char (-1) argument" do - v = 0xdeadbeef - LibTest.testCallbackCrV(-1) { |i| v = i } - expect(v).to eq(-1) - end + it ":char (-1) argument" do + v = 0xdeadbeef + LibTest.testCallbackCrV(-1) { |i| v = i } + expect(v).to eq(-1) + end - it ":uchar (0) argument" do - v = 0xdeadbeef - LibTest.testCallbackU8rV(0) { |i| v = i } - expect(v).to eq(0) - end + def testCallbackU8rV(value) + v1 = 0xdeadbeef + LibTest.testCallbackU8rV(value) { |i| v1 = i } + expect(v1).to eq(value) - it ":uchar (127) argument" do - v = 0xdeadbeef - LibTest.testCallbackU8rV(127) { |i| v = i } - expect(v).to eq(127) - end + # Using a FFI::Function (v2) should be consistent with the direct callback (v1) + v2 = 0xdeadbeef + fun = FFI::Function.new(:void, [:uchar]) { |i| v2 = i } + LibTest.testCallbackU8rV(fun, value) + expect(v2).to eq(value) + end - it ":uchar (128) argument" do - v = 0xdeadbeef - LibTest.testCallbackU8rV(128) { |i| v = i } - expect(v).to eq(128) - end + it ":uchar (0) argument" do + testCallbackU8rV(0) + end - it ":uchar (255) argument" do - v = 0xdeadbeef - LibTest.testCallbackU8rV(255) { |i| v = i } - expect(v).to eq(255) - end + it ":uchar (127) argument" do + testCallbackU8rV(127) + end - it ":short (0) argument" do - v = 0xdeadbeef - LibTest.testCallbackSrV(0) { |i| v = i } - expect(v).to eq(0) - end + it ":uchar (128) argument" do + testCallbackU8rV(128) + end - it ":short (0x7fff) argument" do - v = 0xdeadbeef - LibTest.testCallbackSrV(0x7fff) { |i| v = i } - expect(v).to eq(0x7fff) - end + it ":uchar (255) argument" do + testCallbackU8rV(255) + end - it ":short (-0x8000) argument" do - v = 0xdeadbeef - LibTest.testCallbackSrV(-0x8000) { |i| v = i } - expect(v).to eq(-0x8000) - end + it ":short (0) argument" do + v = 0xdeadbeef + LibTest.testCallbackSrV(0) { |i| v = i } + expect(v).to eq(0) + end - it ":short (-1) argument" do - v = 0xdeadbeef - LibTest.testCallbackSrV(-1) { |i| v = i } - expect(v).to eq(-1) - end + it ":short (0x7fff) argument" do + v = 0xdeadbeef + LibTest.testCallbackSrV(0x7fff) { |i| v = i } + expect(v).to eq(0x7fff) + end - it ":ushort (0) argument" do - v = 0xdeadbeef - LibTest.testCallbackU16rV(0) { |i| v = i } - expect(v).to eq(0) - end + it ":short (-0x8000) argument" do + v = 0xdeadbeef + LibTest.testCallbackSrV(-0x8000) { |i| v = i } + expect(v).to eq(-0x8000) + end - it ":ushort (0x7fff) argument" do - v = 0xdeadbeef - LibTest.testCallbackU16rV(0x7fff) { |i| v = i } - expect(v).to eq(0x7fff) - end + it ":short (-1) argument" do + v = 0xdeadbeef + LibTest.testCallbackSrV(-1) { |i| v = i } + expect(v).to eq(-1) + end - it ":ushort (0x8000) argument" do - v = 0xdeadbeef - LibTest.testCallbackU16rV(0x8000) { |i| v = i } - expect(v).to eq(0x8000) - end + it ":ushort (0) argument" do + v = 0xdeadbeef + LibTest.testCallbackU16rV(0) { |i| v = i } + expect(v).to eq(0) + end - it ":ushort (0xffff) argument" do - v = 0xdeadbeef - LibTest.testCallbackU16rV(0xffff) { |i| v = i } - expect(v).to eq(0xffff) - end + it ":ushort (0x7fff) argument" do + v = 0xdeadbeef + LibTest.testCallbackU16rV(0x7fff) { |i| v = i } + expect(v).to eq(0x7fff) + end - it ":bool (true) argument" do - v = false - LibTest.testCallbackZrV(true) { |i| v = i } - expect(v).to be true - end + it ":ushort (0x8000) argument" do + v = 0xdeadbeef + LibTest.testCallbackU16rV(0x8000) { |i| v = i } + expect(v).to eq(0x8000) + end - it ":int (0) argument" do - v = 0xdeadbeef - LibTest.testCallbackIrV(0) { |i| v = i } - expect(v).to eq(0) - end + it ":ushort (0xffff) argument" do + v = 0xdeadbeef + LibTest.testCallbackU16rV(0xffff) { |i| v = i } + expect(v).to eq(0xffff) + end - it ":int (0x7fffffff) argument" do - v = 0xdeadbeef - LibTest.testCallbackIrV(0x7fffffff) { |i| v = i } - expect(v).to eq(0x7fffffff) - end + it ":bool (true) argument" do + v = false + LibTest.testCallbackZrV(true) { |i| v = i } + expect(v).to be true + end - it ":int (-0x80000000) argument" do - v = 0xdeadbeef - LibTest.testCallbackIrV(-0x80000000) { |i| v = i } - expect(v).to eq(-0x80000000) - end + it ":int (0) argument" do + v = 0xdeadbeef + LibTest.testCallbackIrV(0) { |i| v = i } + expect(v).to eq(0) + end - it ":int (-1) argument" do - v = 0xdeadbeef - LibTest.testCallbackIrV(-1) { |i| v = i } - expect(v).to eq(-1) - end + it ":int (0x7fffffff) argument" do + v = 0xdeadbeef + LibTest.testCallbackIrV(0x7fffffff) { |i| v = i } + expect(v).to eq(0x7fffffff) + end - it ":uint (0) argument" do - v = 0xdeadbeef - LibTest.testCallbackU32rV(0) { |i| v = i } - expect(v).to eq(0) - end + it ":int (-0x80000000) argument" do + v = 0xdeadbeef + LibTest.testCallbackIrV(-0x80000000) { |i| v = i } + expect(v).to eq(-0x80000000) + end - it ":uint (0x7fffffff) argument" do - v = 0xdeadbeef - LibTest.testCallbackU32rV(0x7fffffff) { |i| v = i } - expect(v).to eq(0x7fffffff) - end + it ":int (-1) argument" do + v = 0xdeadbeef + LibTest.testCallbackIrV(-1) { |i| v = i } + expect(v).to eq(-1) + end - it ":uint (0x80000000) argument" do - v = 0xdeadbeef - LibTest.testCallbackU32rV(0x80000000) { |i| v = i } - expect(v).to eq(0x80000000) - end + it ":uint (0) argument" do + v = 0xdeadbeef + LibTest.testCallbackU32rV(0) { |i| v = i } + expect(v).to eq(0) + end - it ":uint (0xffffffff) argument" do - v = 0xdeadbeef - LibTest.testCallbackU32rV(0xffffffff) { |i| v = i } - expect(v).to eq(0xffffffff) - end + it ":uint (0x7fffffff) argument" do + v = 0xdeadbeef + LibTest.testCallbackU32rV(0x7fffffff) { |i| v = i } + expect(v).to eq(0x7fffffff) + end - it ":long (0) argument" do - v = 0xdeadbeef - LibTest.testCallbackLrV(0) { |i| v = i } - expect(v).to eq(0) - end + it ":uint (0x80000000) argument" do + v = 0xdeadbeef + LibTest.testCallbackU32rV(0x80000000) { |i| v = i } + expect(v).to eq(0x80000000) + end - it ":long (0x7fffffff) argument" do - v = 0xdeadbeef - LibTest.testCallbackLrV(0x7fffffff) { |i| v = i } - expect(v).to eq(0x7fffffff) - end + it ":uint (0xffffffff) argument" do + v = 0xdeadbeef + LibTest.testCallbackU32rV(0xffffffff) { |i| v = i } + expect(v).to eq(0xffffffff) + end - it ":long (-0x80000000) argument" do - v = 0xdeadbeef - LibTest.testCallbackLrV(-0x80000000) { |i| v = i } - expect(v).to eq(-0x80000000) - end + it ":long (0) argument" do + v = 0xdeadbeef + LibTest.testCallbackLrV(0) { |i| v = i } + expect(v).to eq(0) + end - it ":long (-1) argument" do - v = 0xdeadbeef - LibTest.testCallbackLrV(-1) { |i| v = i } - expect(v).to eq(-1) - end + it ":long (0x7fffffff) argument" do + v = 0xdeadbeef + LibTest.testCallbackLrV(0x7fffffff) { |i| v = i } + expect(v).to eq(0x7fffffff) + end - it ":ulong (0) argument" do - v = 0xdeadbeef - LibTest.testCallbackULrV(0) { |i| v = i } - expect(v).to eq(0) - end + it ":long (-0x80000000) argument" do + v = 0xdeadbeef + LibTest.testCallbackLrV(-0x80000000) { |i| v = i } + expect(v).to eq(-0x80000000) + end - it ":ulong (0x7fffffff) argument" do - v = 0xdeadbeef - LibTest.testCallbackULrV(0x7fffffff) { |i| v = i } - expect(v).to eq(0x7fffffff) - end + it ":long (-1) argument" do + v = 0xdeadbeef + LibTest.testCallbackLrV(-1) { |i| v = i } + expect(v).to eq(-1) + end - it ":ulong (0x80000000) argument" do - v = 0xdeadbeef - LibTest.testCallbackULrV(0x80000000) { |i| v = i } - expect(v).to eq(0x80000000) - end + it ":ulong (0) argument" do + v = 0xdeadbeef + LibTest.testCallbackULrV(0) { |i| v = i } + expect(v).to eq(0) + end - it ":ulong (0xffffffff) argument" do - v = 0xdeadbeef - LibTest.testCallbackULrV(0xffffffff) { |i| v = i } - expect(v).to eq(0xffffffff) - end + it ":ulong (0x7fffffff) argument" do + v = 0xdeadbeef + LibTest.testCallbackULrV(0x7fffffff) { |i| v = i } + expect(v).to eq(0x7fffffff) + end - it ":long_long (0) argument" do - v = 0xdeadbeef - LibTest.testCallbackLLrV(0) { |i| v = i } - expect(v).to eq(0) - end + it ":ulong (0x80000000) argument" do + v = 0xdeadbeef + LibTest.testCallbackULrV(0x80000000) { |i| v = i } + expect(v).to eq(0x80000000) + end - it ":long_long (0x7fffffffffffffff) argument" do - v = 0xdeadbeef - LibTest.testCallbackLLrV(0x7fffffffffffffff) { |i| v = i } - expect(v).to eq(0x7fffffffffffffff) - end + it ":ulong (0xffffffff) argument" do + v = 0xdeadbeef + LibTest.testCallbackULrV(0xffffffff) { |i| v = i } + expect(v).to eq(0xffffffff) + end - it ":long_long (-0x8000000000000000) argument" do - v = 0xdeadbeef - LibTest.testCallbackLLrV(-0x8000000000000000) { |i| v = i } - expect(v).to eq(-0x8000000000000000) - end + it ":long_long (0) argument" do + v = 0xdeadbeef + LibTest.testCallbackLLrV(0) { |i| v = i } + expect(v).to eq(0) + end - it ":long_long (-1) argument" do - v = 0xdeadbeef - LibTest.testCallbackLLrV(-1) { |i| v = i } - expect(v).to eq(-1) - end + it ":long_long (0x7fffffffffffffff) argument" do + v = 0xdeadbeef + LibTest.testCallbackLLrV(0x7fffffffffffffff) { |i| v = i } + expect(v).to eq(0x7fffffffffffffff) + end - it ":string argument" do - v = nil - LibTest.testCallbackArV("Hello, World") { |i| v = i } - expect(v).to eq("Hello, World") - end + it ":long_long (-0x8000000000000000) argument" do + v = 0xdeadbeef + LibTest.testCallbackLLrV(-0x8000000000000000) { |i| v = i } + expect(v).to eq(-0x8000000000000000) + end - it ":string (nil) argument" do - v = "Hello, World" - LibTest.testCallbackArV(nil) { |i| v = i } - expect(v).to be_nil - end + it ":long_long (-1) argument" do + v = 0xdeadbeef + LibTest.testCallbackLLrV(-1) { |i| v = i } + expect(v).to eq(-1) + end - it ":pointer argument" do - v = nil - magic = FFI::Pointer.new(0xdeadbeef) - LibTest.testCallbackPrV(magic) { |i| v = i } - expect(v).to eq(magic) - end + it ":string argument" do + v = nil + LibTest.testCallbackArV("Hello, World") { |i| v = i } + expect(v).to eq("Hello, World") + end - it ":pointer (nil) argument" do - v = "Hello, World" - LibTest.testCallbackPrV(nil) { |i| v = i } - expect(v).to eq(FFI::Pointer::NULL) - end + it ":string (nil) argument" do + v = "Hello, World" + LibTest.testCallbackArV(nil) { |i| v = i } + expect(v).to be_nil + end - it "struct by reference argument" do - v = nil - magic = LibTest::S8F32S32.new - LibTest.testCallbackYrV(magic) { |i| v = i } - expect(v.class).to eq(magic.class) - expect(v.pointer).to eq(magic.pointer) - end + it ":pointer argument" do + v = nil + magic = FFI::Pointer.new(0xdeadbeef) + LibTest.testCallbackPrV(magic) { |i| v = i } + expect(v).to eq(magic) + end - it "struct by reference argument with nil value" do - v = LibTest::S8F32S32.new - LibTest.testCallbackYrV(nil) { |i| v = i } - expect(v.is_a?(FFI::Struct)).to be true - expect(v.pointer).to eq(FFI::Pointer::NULL) - end + it ":pointer (nil) argument" do + v = "Hello, World" + LibTest.testCallbackPrV(nil) { |i| v = i } + expect(v).to eq(FFI::Pointer::NULL) + end + + it "struct by reference argument" do + v = nil + magic = LibTest::S8F32S32.new + LibTest.testCallbackYrV(magic) { |i| v = i } + expect(v.class).to eq(magic.class) + expect(v.pointer).to eq(magic.pointer) + end + + it "struct by reference argument with nil value" do + v = LibTest::S8F32S32.new + LibTest.testCallbackYrV(nil) { |i| v = i } + expect(v.is_a?(FFI::Struct)).to be true + expect(v.pointer).to eq(FFI::Pointer::NULL) + end - it "varargs parameters are rejected" do - expect { - Module.new do + it "varargs parameters are rejected" do + expect { + Module.new do + extend FFI::Library + ffi_lib TestLibrary::PATH + callback :cbVrL, [ :varargs ], :long + end + }.to raise_error(ArgumentError) + end + + # + # Test stdcall convention with function and callback. + # This is Windows 32-bit only. + # + if FFI::Platform::OS =~ /windows|cygwin/ && FFI::Platform::ARCH == 'i386' + module LibTestStdcall extend FFI::Library ffi_lib TestLibrary::PATH - callback :cbVrL, [ :varargs ], :long + ffi_convention :stdcall + + callback :cbStdcall, [ :pointer, :long ], :void + attach_function :testCallbackStdcall, 'testClosureStdcall', [ :pointer, :cbStdcall, :long ], :bool end - }.to raise_error(ArgumentError) + + it "stdcall convention" do + v = 0xdeadbeef + po = FFI::MemoryPointer.new :long + pr = proc{|a,i| v = a,i; i } + res = LibTestStdcall.testCallbackStdcall(po, pr, 0x7fffffff) + expect(v).to eq([po, 0x7fffffff]) + expect(res).to be true + end + end end +end - # - # Test stdcall convention with function and callback. - # This is Windows 32-bit only. - # - if FFI::Platform::OS =~ /windows|cygwin/ && FFI::Platform::ARCH == 'i386' - module LibTestStdcall +module CallbackInteropSpecs + describe "Callback interop" do + require 'fiddle' + require 'fiddle/import' + require 'timeout' + + module LibTestFFI extend FFI::Library ffi_lib TestLibrary::PATH - ffi_convention :stdcall + attach_function :testCallbackVrV, :testClosureVrV, [ :pointer ], :void + attach_function :testCallbackVrV_blocking, :testClosureVrV, [ :pointer ], :void, blocking: true + end - callback :cbStdcall, [ :pointer, :long ], :void - attach_function :testCallbackStdcall, 'testClosureStdcall', [ :pointer, :cbStdcall, :long ], :bool + module LibTestFiddle + extend Fiddle::Importer + dlload TestLibrary::PATH + extern 'void testClosureVrV(void *fp)' end - it "stdcall convention" do - v = 0xdeadbeef - po = FFI::MemoryPointer.new :long - pr = proc{|a,i| v = a,i; i } - res = LibTestStdcall.testCallbackStdcall(po, pr, 0x7fffffff) - expect(v).to eq([po, 0x7fffffff]) - expect(res).to be true + def assert_callback_in_same_thread_called_once + called = 0 + thread = nil + yield proc { + called += 1 + thread = Thread.current + } + expect(called).to eq(1) + expect(thread).to eq(Thread.current) + end + + it "from ffi to ffi" do + assert_callback_in_same_thread_called_once do |block| + func = FFI::Function.new(:void, [:pointer], &block) + LibTestFFI.testCallbackVrV(FFI::Pointer.new(func.to_i)) + end + end + + it "from ffi to ffi with blocking:true" do + assert_callback_in_same_thread_called_once do |block| + func = FFI::Function.new(:void, [:pointer], &block) + LibTestFFI.testCallbackVrV_blocking(FFI::Pointer.new(func.to_i)) + end + end + + # https://github.com/ffi/ffi/issues/527 + if RUBY_VERSION.split('.').map(&:to_i).pack("C*") >= [2,3,0].pack("C*") || RUBY_PLATFORM =~ /java/ + it "from fiddle to ffi" do + assert_callback_in_same_thread_called_once do |block| + func = FFI::Function.new(:void, [:pointer], &block) + LibTestFiddle.testClosureVrV(Fiddle::Pointer[func.to_i]) + end + end + end + + it "from ffi to fiddle" do + assert_callback_in_same_thread_called_once do |block| + func = LibTestFiddle.bind_function(:cbVrV, Fiddle::TYPE_VOID, [], &block) + LibTestFFI.testCallbackVrV(FFI::Pointer.new(func.to_i)) + end + end + + it "from ffi to fiddle with blocking:true" do + assert_callback_in_same_thread_called_once do |block| + func = LibTestFiddle.bind_function(:cbVrV, Fiddle::TYPE_VOID, [], &block) + LibTestFFI.testCallbackVrV_blocking(FFI::Pointer.new(func.to_i)) + end + end + + it "from fiddle to fiddle" do + assert_callback_in_same_thread_called_once do |block| + func = LibTestFiddle.bind_function(:cbVrV, Fiddle::TYPE_VOID, [], &block) + LibTestFiddle.testClosureVrV(Fiddle::Pointer[func.to_i]) + end + end + + # https://github.com/ffi/ffi/issues/527 + if RUBY_ENGINE == 'ruby' && RUBY_VERSION.split('.').map(&:to_i).pack("C*") >= [2,3,0].pack("C*") + it "C outside ffi call stack does not deadlock [#527]" do + path = File.join(File.dirname(__FILE__), "embed-test/embed-test.rb") + pid = spawn(RbConfig.ruby, "-Ilib", path, { [:out, :err] => "embed-test.log" }) + begin + Timeout.timeout(10){ Process.wait(pid) } + rescue Timeout::Error + Process.kill(9, pid) + raise + else + if $?.exitstatus != 0 + raise "external process failed:\n#{ File.read("embed-test.log") }" + end + end + + expect(File.read("embed-test.log")).to match(/callback called with \["hello", 5, 0\]/) + end end end end diff --git a/spec/ffi/embed-test/embed-test.rb b/spec/ffi/embed-test/embed-test.rb new file mode 100755 index 00000000000..17b4a74ac95 --- /dev/null +++ b/spec/ffi/embed-test/embed-test.rb @@ -0,0 +1,51 @@ +#!/usr/bin/env ruby +# +# This file is part of ruby-ffi. +# For licensing, see LICENSE.SPECS +# + +# This test specifically avoids calling native code through FFI. +# Instead, the stock extension mechanism is used. The reason is +# that the C extension initializes FFI and then calls a callback +# which deadlocked in earlier FFI versions, see +# https://github.com/ffi/ffi/issues/527 + +require 'rbconfig' +require 'ffi' + +EXT = File.expand_path("ext/embed_test.#{RbConfig::CONFIG['DLEXT']}", File.dirname(__FILE__)) +old = Dir.pwd +Dir.chdir(File.dirname(EXT)) + +nul = File.open(File::NULL) +make = system('type gmake', { :out => nul, :err => nul }) && 'gmake' || 'make' + +# create Makefile +system(RbConfig.ruby, "extconf.rb") + +# compile extension +unless system(make) + raise "Unable to compile \"#{EXT}\"" +end + +Dir.chdir(old) + +puts "load #{EXT}" +require EXT + +module LibWrap + extend FFI::Library + ffi_lib EXT + callback :completion_function, [:string, :long, :uint8], :void + attach_function :do_work, [:pointer, :completion_function], :int + Callback = Proc.new do |buf_ptr, count, code| + puts "callback called with #{[buf_ptr, count, code].inspect}" + nil + end +end + +puts "call do_work()" +LibWrap.do_work("test", LibWrap::Callback) + +puts "call testfunc()" +EmbedTest::testfunc diff --git a/spec/ffi/embed-test/ext/embed.c b/spec/ffi/embed-test/ext/embed.c new file mode 100644 index 00000000000..11023f965fa --- /dev/null +++ b/spec/ffi/embed-test/ext/embed.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2017 Thomas Martitz + * Copyright (C) 2008-2017, Ruby FFI project contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Ruby FFI project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +typedef void completion_function(const char *buffer, long count, unsigned char code); + +static completion_function *ruby_func; + +#ifdef _WIN32 + __declspec(dllexport) +#endif +int do_work(const char *buffer, completion_function *fn) +{ + ruby_func = fn; + return 0; +} + +static VALUE testfunc(VALUE args); + +void Init_embed_test(void) +{ + VALUE mod = rb_define_module("EmbedTest"); + rb_define_module_function(mod, "testfunc", testfunc, 0); +} + +static VALUE testfunc(VALUE self) +{ + printf("testfunc() called\n"); + ruby_func("hello", 5, 0); + return Qnil; +} diff --git a/spec/ffi/embed-test/ext/extconf.rb b/spec/ffi/embed-test/ext/extconf.rb new file mode 100644 index 00000000000..6327e0ac5c3 --- /dev/null +++ b/spec/ffi/embed-test/ext/extconf.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# +# This file is part of ruby-ffi. +# For licensing, see LICENSE.SPECS +# + +if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx' + require "mkmf" + + create_makefile("embed_test") +end diff --git a/spec/ffi/enum_spec.rb b/spec/ffi/enum_spec.rb index 55ff13a6bb0..93c349e0d45 100644 --- a/spec/ffi/enum_spec.rb +++ b/spec/ffi/enum_spec.rb @@ -417,7 +417,17 @@ module TestEnum4 end it "duplicate enum keys rejected" do - expect { enum [ :a, 0xfee1dead, :b, 0xdeadbeef, :a, 0 ] }.to raise_error - expect { enum FFI::Type::UINT64, [ :a, 0xfee1dead, :b, 0xdeadbeef, :a, 0 ] }.to raise_error + expect do + Module.new do + extend FFI::Library + enum [ :a, 0xfee1dead, :b, 0xdeadbeef, :a, 0 ] + end + end.to raise_error(ArgumentError, /duplicate/) + expect do + Module.new do + extend FFI::Library + enum FFI::Type::UINT64, [ :a, 0xfee1dead, :b, 0xdeadbeef, :a, 0 ] + end + end.to raise_error(ArgumentError, /duplicate/) end end diff --git a/spec/ffi/errno_spec.rb b/spec/ffi/errno_spec.rb index 61cbda2e0aa..4170f92ba89 100644 --- a/spec/ffi/errno_spec.rb +++ b/spec/ffi/errno_spec.rb @@ -10,11 +10,28 @@ module LibTest extend FFI::Library ffi_lib TestLibrary::PATH attach_function :setLastError, [ :int ], :void + attach_function :setErrno, [ :int ], :void end - it "FFI.errno contains errno from last function" do + it "FFI.errno contains errno from last function, FFI::LastError.winapi_error works differently per OS" do + # setup + LibTest.setErrno(0) LibTest.setLastError(0) LibTest.setLastError(0x12345678) - expect(FFI.errno).to eq(0x12345678) + # cases + case FFI::Platform::OS + when "cygwin" + expect(FFI::LastError.winapi_error).to eq(0x12345678) + LibTest.setErrno(0x2A) + expect(FFI.errno).to eq(0x2A) + when "windows" + expect(FFI::LastError.winapi_error).to eq(0x12345678) + expect(FFI.errno).to eq(0x12345678) + else + # Linux, and else + expect {FFI::LastError.winapi_error}.to raise_exception(NoMethodError) + expect {FFI::LastError.winapi_error = 0}.to raise_exception(NoMethodError) + expect(FFI.errno).to eq(0x12345678) + end end end diff --git a/spec/ffi/ffi_spec.rb b/spec/ffi/ffi_spec.rb index bb93f376570..1ff50457526 100644 --- a/spec/ffi/ffi_spec.rb +++ b/spec/ffi/ffi_spec.rb @@ -25,4 +25,10 @@ end end + + describe "VERSION" do + it "should be kind of version" do + expect( FFI::VERSION ).to match(/^\d+\.\d+.\d+$/) + end + end end diff --git a/spec/ffi/fixtures/BitmaskTest.c b/spec/ffi/fixtures/BitmaskTest.c new file mode 100644 index 00000000000..17ad0aa2cd1 --- /dev/null +++ b/spec/ffi/fixtures/BitmaskTest.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 Brice Videau. All rights reserved. + * + * For licensing, see LICENSE.SPECS + */ +#include + +int test_untagged_bitmask(int val) { + return val; +} + +int test_untagged_typedef_bitmask(int val) { + return val; +} + +uint8_t test_untagged_nonint_bitmask(uint8_t val) { + return val; +} + +uint16_t test_tagged_nonint_bitmask1(uint16_t val) { + return val; +} + +uint32_t test_tagged_nonint_bitmask2(uint32_t val) { + return val; +} + +uint64_t test_tagged_nonint_bitmask3(uint64_t val) { + return val; +} + +typedef enum {c1 = (1<<0), c2 = (1<<1), c3 = (1<<2), c4 = (1<<3)} bitmask_type1; +int test_tagged_typedef_bitmask1(int val) { + return val; +} + +typedef enum {c5 = (1<<2), c6 = (1<<3), c7 = (1<<4), c8 = (1<<5)} bitmask_type2; +int test_tagged_typedef_bitmask2(int val) { + return val; +} + +typedef enum {c9 = (1<<2), c10 = (1<<3), c11 = (1<<5), c12 = (1<<6)} bitmask_type3; +int test_tagged_typedef_bitmask3(int val) { + return val; +} + +typedef enum {c13 = (1<<2), c14 = (1<<4), c15 = (1<<6), c16 = (1<<8)} bitmask_type4; +int test_tagged_typedef_bitmask4(int val) { + return val; +} + diff --git a/spec/ffi/fixtures/ClosureTest.c b/spec/ffi/fixtures/ClosureTest.c index 64ea2b431d2..dfeabde6699 100644 --- a/spec/ffi/fixtures/ClosureTest.c +++ b/spec/ffi/fixtures/ClosureTest.c @@ -50,6 +50,21 @@ P(D, double); P(P, const void*); P(UL, unsigned long); +#if defined(_WIN32) && !defined(_WIN64) +bool __stdcall testClosureStdcall(long *a1, void __stdcall(*closure)(void *, long), long a2) { \ + void* sp_pre; + void* sp_post; + + asm volatile (" movl %%esp,%0" : "=g" (sp_pre)); + (*closure)(a1, a2); + asm volatile (" movl %%esp,%0" : "=g" (sp_post)); + + /* %esp before pushing parameters on the stack and after the call returns + * should be equal, if both sides respects the stdcall convention */ + return sp_pre == sp_post; +} +#endif + void testOptionalClosureBrV(void (*closure)(char), char a1) { if (closure) { diff --git a/spec/ffi/fixtures/FunctionTest.c b/spec/ffi/fixtures/FunctionTest.c index b4d45bbb403..1dd918581ee 100644 --- a/spec/ffi/fixtures/FunctionTest.c +++ b/spec/ffi/fixtures/FunctionTest.c @@ -6,14 +6,17 @@ #ifdef _WIN32 #include -#define sleep(x) Sleep(x) #endif #ifndef _WIN32 #include #include +#include +#include #endif +#include "PipeHelper.h" + int testAdd(int a, int b) { return a + b; @@ -24,10 +27,79 @@ int testFunctionAdd(int a, int b, int (*f)(int, int)) return f(a, b); }; -void testBlocking(int seconds) { - sleep(seconds); +struct testBlockingData { + FD_TYPE pipe1[2]; + FD_TYPE pipe2[2]; }; +struct testBlockingData *testBlockingOpen() +{ + struct testBlockingData *self = malloc(sizeof(struct testBlockingData)); + + if( pipeHelperCreatePipe(self->pipe1) == -1 ) return NULL; + if( pipeHelperCreatePipe(self->pipe2) == -1 ) return NULL; + return self; +} + +char testBlockingWR(struct testBlockingData *self, char c) { + if( pipeHelperWriteChar(self->pipe1[1], c) != 1) + return 0; + return pipeHelperReadChar(self->pipe2[0], 10); +} + +char testBlockingRW(struct testBlockingData *self, char c) { + char d = pipeHelperReadChar(self->pipe1[0], 10); + if( pipeHelperWriteChar(self->pipe2[1], c) != 1) + return 0; + return d; +} + +void testBlockingClose(struct testBlockingData *self) { + pipeHelperClosePipe(self->pipe1[0]); + pipeHelperClosePipe(self->pipe1[1]); + pipeHelperClosePipe(self->pipe2[0]); + pipeHelperClosePipe(self->pipe2[1]); + free(self); +} + +static int sum_varargs(va_list args) { + char sum = 0; + int arg; + while ((arg = va_arg(args, int)) != 0) { + sum += arg; + } + va_end(args); + return sum; +} + +/* Write c to pipe1 and return the value read from pipe2, or 0 if there’s + * an error such as a timeout, or if c does not equal the sum of the + * zero-terminated list of char arguments. */ +char testBlockingWRva(struct testBlockingData *self, char c, ...) { + va_list args; + va_start(args, c); + if (sum_varargs(args) != c) { + return 0; + } + + if( pipeHelperWriteChar(self->pipe1[1], c) != 1) + return 0; + return pipeHelperReadChar(self->pipe2[0], 10); +} + +char testBlockingRWva(struct testBlockingData *self, char c, ...) { + va_list args; + va_start(args, c); + if (sum_varargs(args) != c) { + return 0; + } + + char d = pipeHelperReadChar(self->pipe1[0], 10); + if( pipeHelperWriteChar(self->pipe2[1], c) != 1) + return 0; + return d; +} + struct async_data { void (*fn)(int); int value; @@ -55,4 +127,16 @@ void testAsyncCallback(void (*fn)(int), int value) #else (*fn)(value); #endif -} +} + +#if defined(_WIN32) && !defined(_WIN64) +struct StructUCDP { + unsigned char a1; + double a2; + void *a3; +}; + +void __stdcall testStdcallManyParams(long *a1, char a2, short int a3, int a4, __int64 a5, + struct StructUCDP a6, struct StructUCDP *a7, float a8, double a9) { +} +#endif diff --git a/spec/ffi/fixtures/GNUmakefile b/spec/ffi/fixtures/GNUmakefile index d7304191665..20899d117dd 100644 --- a/spec/ffi/fixtures/GNUmakefile +++ b/spec/ffi/fixtures/GNUmakefile @@ -23,8 +23,6 @@ PREFIX = lib LIBEXT ?= so LIBNAME = $(PREFIX)test.$(LIBEXT) -export MACOSX_DEPLOYMENT_TARGET=10.4 - CCACHE := $(strip $(realpath $(shell which ccache 2> /dev/null))) TEST_SRCS = $(wildcard $(SRC_DIR)/*.c) diff --git a/spec/ffi/fixtures/LastErrorTest.c b/spec/ffi/fixtures/LastErrorTest.c index 02ce4a8bcc1..10275bc25c5 100644 --- a/spec/ffi/fixtures/LastErrorTest.c +++ b/spec/ffi/fixtures/LastErrorTest.c @@ -10,12 +10,14 @@ # include #endif -int setLastError(int error) { -#if defined(_WIN32) || defined(__WIN32__) +void setLastError(int error) { +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) SetLastError(error); #else errno = error; #endif - return -1; } +void setErrno(int error) { + errno = error; +} diff --git a/spec/ffi/fixtures/PipeHelper.h b/spec/ffi/fixtures/PipeHelper.h new file mode 100644 index 00000000000..4a0211130f9 --- /dev/null +++ b/spec/ffi/fixtures/PipeHelper.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2015 Lars Kanis. All rights reserved. + * + * For licensing, see LICENSE.SPECS + */ + +#ifndef PIPEHELPER_H +#define PIPEHELPER_H + +#ifdef _WIN32 +#define FD_TYPE HANDLE +#else +#define FD_TYPE int +#endif + +int pipeHelperCreatePipe(FD_TYPE pipefd[2]); +char pipeHelperReadChar(FD_TYPE fd, int timeout); +int pipeHelperWriteChar(FD_TYPE fd, char c); +void pipeHelperClosePipe(FD_TYPE fd); + +#endif diff --git a/spec/ffi/fixtures/PipeHelperPosix.c b/spec/ffi/fixtures/PipeHelperPosix.c new file mode 100644 index 00000000000..c1252b44e19 --- /dev/null +++ b/spec/ffi/fixtures/PipeHelperPosix.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2015 Lars Kanis. All rights reserved. + * + * For licensing, see LICENSE.SPECS + */ + +#ifndef _WIN32 +#include +#include +#include "PipeHelper.h" + +int pipeHelperCreatePipe(FD_TYPE pipefd[2]) +{ + return pipe(pipefd); +} + +char pipeHelperReadChar(FD_TYPE fd, int timeout) +{ + char d; + struct timeval time = {timeout, 0}; // timeout after x seconds + fd_set read_fds; + FD_ZERO(&read_fds); + FD_SET(fd, &read_fds); + + if(select(fd + 1, &read_fds, NULL, NULL, &time) <= 0) + return 0; + + if( read(fd, &d, 1) != 1) + return 0; + return d; +} + +int pipeHelperWriteChar(FD_TYPE fd, char c) +{ + return write(fd, &c, 1); +} + +void pipeHelperClosePipe(FD_TYPE fd) { + close(fd); +} +#endif diff --git a/spec/ffi/fixtures/PipeHelperWindows.c b/spec/ffi/fixtures/PipeHelperWindows.c new file mode 100644 index 00000000000..0bdbd2ec8c4 --- /dev/null +++ b/spec/ffi/fixtures/PipeHelperWindows.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2007 Wayne Meissner. All rights reserved. + * + * For licensing, see LICENSE.SPECS + */ + +#ifdef _WIN32 +#include +#include +#include "PipeHelper.h" + +int pipeHelperCreatePipe(FD_TYPE pipefd[2]) +{ + char name[ MAX_PATH ]; + static int pipe_idx = 0; + sprintf( name, "\\\\.\\Pipe\\pipeHelper-%u-%i", + (unsigned int)GetCurrentProcessId(), pipe_idx++ ); + + pipefd[0] = CreateNamedPipe( name, PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, + PIPE_TYPE_BYTE | PIPE_WAIT, + 1, // Number of pipes + 5, // Out buffer size + 5, // In buffer size + 60 * 1000, // Timeout in ms + NULL ); + if(pipefd[0] == INVALID_HANDLE_VALUE) + return -1; + + pipefd[1] = CreateFile( name, GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if(pipefd[1] == INVALID_HANDLE_VALUE) { + CloseHandle( pipefd[0] ); + return -1; + } + return 0; +} + +char pipeHelperReadChar(FD_TYPE fd, int timeout) +{ + char d; + OVERLAPPED ovl; + ZeroMemory(&ovl, sizeof(ovl)); + ovl.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + if( ReadFile(fd, &d, 1, NULL, &ovl) == 0) { + DWORD recvd = 0;; + DWORD res = WaitForSingleObject(ovl.hEvent, timeout * 1000); + if( res != WAIT_OBJECT_0 ) { + CloseHandle(ovl.hEvent); + return 0; + } + if( GetOverlappedResult(fd, &ovl, &recvd, FALSE) == 0 ) { + CloseHandle(ovl.hEvent); + return 0; + } + } + CloseHandle(ovl.hEvent); + return d; +} + +int pipeHelperWriteChar(FD_TYPE fd, char c) +{ + DWORD written; + return WriteFile(fd, &c, 1, &written, NULL) == 0 ? 0 : 1; +} + +void pipeHelperClosePipe(FD_TYPE fd) { + CloseHandle(fd); +} + +#endif diff --git a/spec/ffi/fixtures/PointerTest.c b/spec/ffi/fixtures/PointerTest.c index 7237ab20e71..a7f392a1a32 100644 --- a/spec/ffi/fixtures/PointerTest.c +++ b/spec/ffi/fixtures/PointerTest.c @@ -12,15 +12,12 @@ #include typedef void* ptr; typedef void* pointer; -#ifdef _WIN32 -typedef char* caddr_t; -#endif #define RET(T) T ptr_ret_##T(void* arg1, int offset) { \ - T tmp; memcpy(&tmp, (caddr_t) arg1 + offset, sizeof(tmp)); return tmp; \ + T tmp; memcpy(&tmp, (char *) arg1 + offset, sizeof(tmp)); return tmp; \ } #define SET(T) void ptr_set_##T(void* arg1, int offset, T value) { \ - memcpy((caddr_t) arg1 + offset, &value, sizeof(value)); \ + memcpy((char *) arg1 + offset, &value, sizeof(value)); \ } #define TEST(T) SET(T) RET(T) @@ -33,19 +30,19 @@ TEST(double); TEST(pointer); void* -ptr_return_array_element(void **ptrArray, int arrayIndex) +ptr_return_array_element(void **ptrArray, int arrayIndex) { return ptrArray[arrayIndex]; } void ptr_set_array_element(void **ptrArray, int arrayIndex, void *value) -{ +{ ptrArray[arrayIndex] = value; } void* -ptr_malloc(int size) +ptr_malloc(int size) { return calloc(1, size); } diff --git a/spec/ffi/fixtures/compile.rb b/spec/ffi/fixtures/compile.rb new file mode 100644 index 00000000000..16892e0fccf --- /dev/null +++ b/spec/ffi/fixtures/compile.rb @@ -0,0 +1,70 @@ +# +# This file is part of ruby-ffi. +# For licensing, see LICENSE.SPECS +# + +require 'rbconfig' +require 'fileutils' +require 'ffi' + +module TestLibrary + CPU = case RbConfig::CONFIG['host_cpu'].downcase + when /i[3456]86/ + # Darwin always reports i686, even when running in 64bit mode + if RbConfig::CONFIG['host_os'] =~ /darwin/ && 0xfee1deadbeef.is_a?(Fixnum) + "x86_64" + else + "i386" + end + when /amd64|x86_64/ + "x86_64" + when /ppc64|powerpc64/ + "powerpc64" + when /ppc|powerpc/ + "powerpc" + when /^arm/ + "arm" + else + RbConfig::CONFIG['host_cpu'] + end + + OS = case RbConfig::CONFIG['host_os'].downcase + when /linux/ + "linux" + when /darwin/ + "darwin" + when /freebsd/ + "freebsd" + when /openbsd/ + "openbsd" + when /dragonfly/ + "dragonflybsd" + when /sunos|solaris/ + "solaris" + when /mswin|mingw/ + "win32" + else + RbConfig::CONFIG['host_os'].downcase + end + + def self.compile_library(path, lib) + dir = File.expand_path(path, File.dirname(__FILE__)) + lib = "#{dir}/#{lib}" + unless File.exist?(lib) + output = nil + FileUtils.cd(dir) do + make = ENV['MAKE'] || (system('which gmake >/dev/null') ? 'gmake' : 'make') + output = system(*%{#{make} CPU=#{CPU} OS=#{OS}}.tap{|x| puts x.inspect}) + end + + unless $?.success? + puts "ERROR:\n#{output}" + raise "Unable to compile #{lib.inspect}" + end + end + + lib + end + + PATH = compile_library(".", "libtest.#{FFI::Platform::LIBSUFFIX}") +end diff --git a/spec/ffi/function_spec.rb b/spec/ffi/function_spec.rb index ab08f35782a..dd4d2eaaf6d 100644 --- a/spec/ffi/function_spec.rb +++ b/spec/ffi/function_spec.rb @@ -12,7 +12,7 @@ module LibTest attach_function :testFunctionAdd, [:int, :int, :pointer], :int end before do - @libtest = FFI::DynamicLibrary.open(TestLibrary::PATH, + @libtest = FFI::DynamicLibrary.open(TestLibrary::PATH, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_GLOBAL) end @@ -22,7 +22,7 @@ module LibTest end it 'raises an error when passing a wrong signature' do - expect { FFI::Function.new([], :int).new { } }.to raise_error TypeError + expect { FFI::Function.new([], :int).new { } }.to raise_error TypeError end it 'returns a native pointer' do @@ -63,15 +63,20 @@ class << self; self; end end it 'can wrap a blocking function' do - fp = FFI::Function.new(:void, [ :int ], @libtest.find_function('testBlocking'), :blocking => true) - threads = 10.times.map do |x| - Thread.new do - time = Time.now - fp.call(2) - expect(Time.now - time).to be >= 2 - end + fpOpen = FFI::Function.new(:pointer, [ ], @libtest.find_function('testBlockingOpen')) + fpRW = FFI::Function.new(:char, [ :pointer, :char ], @libtest.find_function('testBlockingRW'), :blocking => true) + fpWR = FFI::Function.new(:char, [ :pointer, :char ], @libtest.find_function('testBlockingWR'), :blocking => true) + fpClose = FFI::Function.new(:void, [ :pointer ], @libtest.find_function('testBlockingClose')) + handle = fpOpen.call + expect(handle).not_to be_null + begin + thWR = Thread.new { fpWR.call(handle, 63) } + thRW = Thread.new { fpRW.call(handle, 64) } + expect(thWR.value).to eq(64) + expect(thRW.value).to eq(63) + ensure + fpClose.call(handle) end - threads.each { |t| t.join } end it 'autorelease flag is set to true by default' do diff --git a/spec/ffi/library_spec.rb b/spec/ffi/library_spec.rb index 4359b932557..ff18f9b711b 100644 --- a/spec/ffi/library_spec.rb +++ b/spec/ffi/library_spec.rb @@ -73,7 +73,7 @@ class StructUCDP < FFI::Struct end }.to raise_error(LoadError) end - + end unless RbConfig::CONFIG['target_os'] =~ /mswin|mingw/ @@ -83,7 +83,7 @@ class StructUCDP < FFI::Struct m.extend FFI::Library attach_function :getpid, [ ], :uint end - }.to raise_error + }.to raise_error(LoadError) end it "attach_function :getpid from this process" do @@ -96,6 +96,16 @@ class StructUCDP < FFI::Struct }.not_to raise_error end + it "loads library using symbol" do + expect { + expect(Module.new do |m| + m.extend FFI::Library + ffi_lib :c + attach_function :getpid, [ ], :uint + end.getpid).to eq(Process.pid) + }.not_to raise_error + end + it "attach_function :getpid from [ 'c', 'libc.so.6'] " do expect { expect(Module.new do |m| @@ -249,12 +259,12 @@ def gvar_test(name, type, val) expect(lib.get).to eq(val) end + class GlobalStruct < FFI::Struct + layout :data, :long + end + [ 0, 0x7fffffff, -0x80000000, -1 ].each do |i| it "structure" do - class GlobalStruct < FFI::Struct - layout :data, :long - end - lib = Module.new do |m| m.extend FFI::Library ffi_lib TestLibrary::PATH diff --git a/spec/ffi/long_double.rb b/spec/ffi/long_double.rb index b16613b2472..a763ed753c8 100644 --- a/spec/ffi/long_double.rb +++ b/spec/ffi/long_double.rb @@ -19,8 +19,8 @@ module LibTest end it "returns first parameter with high precision" do - ld = BigDecimal.new("1.234567890123456789") - tolerance = BigDecimal.new("0.0000000000000000001") + ld = BigDecimal("1.234567890123456789") + tolerance = BigDecimal("0.0000000000000000001") expect(LibTest.ret_f128(ld)).to be_within(tolerance).of(ld) end diff --git a/spec/ffi/managed_struct_spec.rb b/spec/ffi/managed_struct_spec.rb index 99e0f54a034..f11c67a9837 100644 --- a/spec/ffi/managed_struct_spec.rb +++ b/spec/ffi/managed_struct_spec.rb @@ -38,7 +38,8 @@ def self.release expect(ClassWithSelfRef.new(ManagedStructTestLib.ptr_from_address(0x12345678)).class).to eq(ClassWithSelfRef) end - it "should release memory properly" do + # see #427 + it "should release memory properly", :broken => true do class PleaseReleaseMe < FFI::ManagedStruct layout :i, :int @@count = 0 diff --git a/spec/ffi/number_spec.rb b/spec/ffi/number_spec.rb index acb9562265f..ed091d4f5af 100644 --- a/spec/ffi/number_spec.rb +++ b/spec/ffi/number_spec.rb @@ -145,32 +145,32 @@ module LibTest describe "Integer parameter range checking" do [ 128, -129 ].each do |i| it ":char call(:char (#{i}))" do - expect { expect(LibTest.ret_int8_t(i)).to eq(i) }.to raise_error + expect { expect(LibTest.ret_s8(i)).to eq(i) }.to raise_error(Exception) { |error| expect([RSpec::Expectations::ExpectationNotMetError, RangeError]).to be_include(error.class) } end end [ -1, 256 ].each do |i| it ":uchar call(:uchar (#{i}))" do - expect { expect(LibTest.ret_u_int8_t(i)).to eq(i) }.to raise_error + expect { expect(LibTest.ret_u8(i)).to eq(i) }.to raise_error(Exception) { |error| expect([RSpec::Expectations::ExpectationNotMetError, RangeError]).to be_include(error.class) } end end [ 0x8000, -0x8001 ].each do |i| it ":short call(:short (#{i}))" do - expect { expect(LibTest.ret_int16_t(i)).to eq(i) }.to raise_error + expect { expect(LibTest.ret_s16(i)).to eq(i) }.to raise_error(Exception) { |error| expect([RSpec::Expectations::ExpectationNotMetError, RangeError]).to be_include(error.class) } end end [ -1, 0x10000 ].each do |i| it ":ushort call(:ushort (#{i}))" do - expect { expect(LibTest.ret_u_int16_t(i)).to eq(i) }.to raise_error + expect { expect(LibTest.ret_u16(i)).to eq(i) }.to raise_error(Exception) { |error| expect([RSpec::Expectations::ExpectationNotMetError, RangeError]).to be_include(error.class) } end end [ 0x80000000, -0x80000001 ].each do |i| it ":int call(:int (#{i}))" do - expect { expect(LibTest.ret_int32_t(i)).to eq(i) }.to raise_error + expect { expect(LibTest.ret_s32(i)).to eq(i) }.to raise_error(Exception) { |error| expect([RSpec::Expectations::ExpectationNotMetError, RangeError]).to be_include(error.class) } end end [ -1, 0x100000000 ].each do |i| - it ":ushort call(:ushort (#{i}))" do - expect { expect(LibTest.ret_u_int32_t(i)).to eq(i) }.to raise_error + it ":uint call(:uint (#{i}))" do + expect { expect(LibTest.ret_u32(i)).to eq(i) }.to raise_error(Exception) { |error| expect([RSpec::Expectations::ExpectationNotMetError, RangeError]).to be_include(error.class) } end end end diff --git a/spec/ffi/platform_spec.rb b/spec/ffi/platform_spec.rb index 7c567191deb..64bd7bd2170 100644 --- a/spec/ffi/platform_spec.rb +++ b/spec/ffi/platform_spec.rb @@ -6,7 +6,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) describe "FFI::Platform::LIBSUFFIX" do - case OS + case TestLibrary::OS when "linux" it "returns 'so'" do expect(FFI::Platform::LIBSUFFIX).to eq('so') @@ -23,7 +23,7 @@ end describe "FFI::Platform::IS_WINDOWS" do - case OS + case TestLibrary::OS when "linux" it "returns false" do expect(FFI::Platform::IS_WINDOWS).to be false @@ -41,12 +41,12 @@ describe "FFI::Platform::ARCH" do it "returns the architecture type" do - expect(FFI::Platform::ARCH).to eq(CPU) + expect(FFI::Platform::ARCH).to eq(TestLibrary::CPU) end end describe "FFI::Platform::OS" do - case OS + case TestLibrary::OS when "linux" it "returns 'linux' as a string" do expect(FFI::Platform::OS).to eq('linux') @@ -63,7 +63,7 @@ end describe "FFI::Platform.windows?" do - case OS + case TestLibrary::OS when "linux" it "returns false" do expect(FFI::Platform.windows?).to be false @@ -80,7 +80,7 @@ end describe "FFI::Platform.mac?" do - case OS + case TestLibrary::OS when "linux" it "returns false" do expect(FFI::Platform.mac?).to be false @@ -97,7 +97,7 @@ end describe "FFI::Platform.unix?" do - case OS + case TestLibrary::OS when "linux" it "returns true" do expect(FFI::Platform.unix?).to be true diff --git a/spec/ffi/pointer_spec.rb b/spec/ffi/pointer_spec.rb index fc5bb85e041..a1c0a92d57d 100644 --- a/spec/ffi/pointer_spec.rb +++ b/spec/ffi/pointer_spec.rb @@ -55,11 +55,18 @@ def to_ptr end it "Fixnum cannot be used as a Pointer argument" do - expect { PointerTestLib.ptr_ret_int32(0, 0) }.to raise_error + expect { PointerTestLib.ptr_ret_int32_t(0, 0) }.to raise_error(ArgumentError) end it "Bignum cannot be used as a Pointer argument" do - expect { PointerTestLib.ptr_ret_int32(0xfee1deadbeefcafebabe, 0) }.to raise_error + expect { PointerTestLib.ptr_ret_int32_t(0xfee1deadbeefcafebabe, 0) }.to raise_error(ArgumentError) + end + + it "#to_ptr" do + memory = FFI::MemoryPointer.new :pointer + expect(memory.to_ptr).to eq(memory) + + expect(FFI::Pointer::NULL.to_ptr).to eq(FFI::Pointer::NULL) end describe "pointer type methods" do @@ -87,7 +94,26 @@ def to_ptr expect(array[j].address).to eq(address) end end - + + it "#write_array_of_type for uint8" do + values = [10, 227, 32] + memory = FFI::MemoryPointer.new FFI::TYPE_UINT8, values.size + memory.write_array_of_type(FFI::TYPE_UINT8, :put_uint8, values) + array = memory.read_array_of_type(FFI::TYPE_UINT8, :read_uint8, values.size) + values.each_with_index do |val, j| + expect(array[j]).to eq(val) + end + end + + it "#write_array_of_type for uint32" do + values = [10, 227, 32] + memory = FFI::MemoryPointer.new FFI::TYPE_UINT32, values.size + memory.write_array_of_type(FFI::TYPE_UINT32, :put_uint32, values) + array = memory.read_array_of_type(FFI::TYPE_UINT32, :read_uint32, values.size) + values.each_with_index do |val, j| + expect(array[j]).to eq(val) + end + end end describe 'NULL' do @@ -138,15 +164,6 @@ def to_ptr expect(FFI::MemoryPointer.new(:int, 1).type_size).to eq(FFI.type_size(:int)) end end - - it "is not eql? for purposes of hash lookup (GH-2995)" do - a = FFI::Pointer.new(0) - b = FFI::Pointer.new(0) - - expect(a == b).to eq true - expect(a.eql? b).to eq false - expect(Hash[a,true][b]).to eq nil - end end describe "AutoPointer" do @@ -179,7 +196,8 @@ class AutoPointerSubclass < FFI::AutoPointer def self.release(ptr); end end - it "cleanup via default release method" do + # see #427 + it "cleanup via default release method", :broken => true do expect(AutoPointerSubclass).to receive(:release).at_least(loop_count-wiggle_room).times AutoPointerTestHelper.reset loop_count.times do @@ -191,7 +209,8 @@ def self.release(ptr); end AutoPointerTestHelper.gc_everything loop_count end - it "cleanup when passed a proc" do + # see #427 + it "cleanup when passed a proc", :broken => true do # NOTE: passing a proc is touchy, because it's so easy to create a memory leak. # # specifically, if we made an inline call to @@ -209,7 +228,8 @@ def self.release(ptr); end AutoPointerTestHelper.gc_everything loop_count end - it "cleanup when passed a method" do + # see #427 + it "cleanup when passed a method", :broken => true do expect(AutoPointerTestHelper).to receive(:release).at_least(loop_count-wiggle_room).times AutoPointerTestHelper.reset loop_count.times do diff --git a/spec/ffi/rbx/attach_function_spec.rb b/spec/ffi/rbx/attach_function_spec.rb index 1ab880ea167..eda640fbe11 100644 --- a/spec/ffi/rbx/attach_function_spec.rb +++ b/spec/ffi/rbx/attach_function_spec.rb @@ -5,29 +5,32 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) -class Timeval < FFI::Struct - layout :tv_sec, :ulong, 0, :tv_usec, :ulong, 4 -end +module RbxAttachFunctionSpecs + unless FFI::Platform.windows? + class Timeval < FFI::Struct + layout :tv_sec, :ulong, 0, :tv_usec, :ulong, 4 + end -module LibC - extend FFI::Library - ffi_lib FFI::Library::LIBC + module LibC + extend FFI::Library + ffi_lib FFI::Library::LIBC - attach_function :gettimeofday, [:pointer, :pointer], :int -end + attach_function :gettimeofday, [:pointer, :pointer], :int + end -describe FFI::Library, "#attach_function" do - it "correctly returns a value for gettimeofday" do - t = Timeval.new - time = LibC.gettimeofday(t.pointer, nil) - expect(time).to be_kind_of(Integer) - end - - it "correctly populates a struct for gettimeofday" do - t = Timeval.new - time = LibC.gettimeofday(t.pointer, nil) - expect(t[:tv_sec]).to be_kind_of(Numeric) - expect(t[:tv_usec]).to be_kind_of(Numeric) + describe FFI::Library, "#attach_function" do + it "correctly returns a value for gettimeofday" do + t = Timeval.new + time = LibC.gettimeofday(t.pointer, nil) + expect(time).to be_kind_of(Integer) + end + + it "correctly populates a struct for gettimeofday" do + t = Timeval.new + LibC.gettimeofday(t.pointer, nil) + expect(t[:tv_sec]).to be_kind_of(Numeric) + expect(t[:tv_usec]).to be_kind_of(Numeric) + end + end end end - diff --git a/spec/ffi/rbx/memory_pointer_spec.rb b/spec/ffi/rbx/memory_pointer_spec.rb index 0fe35977422..9e41b851690 100644 --- a/spec/ffi/rbx/memory_pointer_spec.rb +++ b/spec/ffi/rbx/memory_pointer_spec.rb @@ -34,6 +34,11 @@ module CTest m = FFI::MemoryPointer.from_string("FFI is Awesome") expect(m.read_string).to eq("FFI is Awesome") end + + it "reads back an empty string" do + expect(FFI::Pointer::NULL.read_string(0)).to eq('') + expect(FFI::Pointer::NULL.read_string(0).encoding).to eq(Encoding::BINARY) + end it "makes a pointer for a certain number of bytes" do m = FFI::MemoryPointer.new(8) @@ -52,22 +57,86 @@ module CTest m = FFI::MemoryPointer.new(:int) m.write_int(1) expect(m.read_int).to eq(1) + expect(m.read :int).to eq(1) + expect(m.read FFI::Type::INT).to eq(1) end - + + it "allows writing as a sized int" do + m = FFI::MemoryPointer.new(:uint32) + m.write_uint32(1) + expect(m.read_uint32).to eq(1) + expect(m.read :uint32).to eq(1) + expect(m.read FFI::Type::UINT32).to eq(1) + + m = FFI::MemoryPointer.new(:uint32) + m.write :uint32, 1 + expect(m.read :uint32).to eq(1) + + m = FFI::MemoryPointer.new(:int64) + m.write_int64(1) + expect(m.read_int64).to eq(1) + expect(m.read :int64).to eq(1) + expect(m.read FFI::Type::INT64).to eq(1) + + m = FFI::MemoryPointer.new(:int64) + m.write :int64, 1 + expect(m.read :int64).to eq(1) + end + it "allows writing as a long" do m = FFI::MemoryPointer.new(:long) m.write_long(10) expect(m.read_long).to eq(10) + expect(m.read :long).to eq(10) + expect(m.read FFI::Type::LONG).to eq(10) + + m.write :long, 10 + expect(m.read :long).to eq(10) end - + + it "allows writing as a size_t" do + m = FFI::MemoryPointer.new(:size_t) + m.write(:size_t, 10) + expect(m.read :size_t).to eq(10) + end + + it "allows writing as a bool" do + m = FFI::MemoryPointer.new(:bool) + m.write(:bool, true) + expect(m.read :bool).to eq(true) + expect(m.read FFI::Type::BOOL).to eq(true) + + m.write(:bool, false) + expect(m.read :bool).to eq(false) + expect(m.read FFI::Type::BOOL).to eq(false) + end + + it "allows writing a custom typedef" do + FFI.typedef :uint, :fubar_t + FFI.typedef :size_t, :fubar2_t + + m = FFI::MemoryPointer.new(:fubar_t) + m.write(:fubar_t, 10) + expect(m.read :fubar_t).to eq(10) + + m = FFI::MemoryPointer.new(:fubar2_t) + m.write(:fubar2_t, 10) + expect(m.read :fubar2_t).to eq(10) + end + + it "raises an error if you try to read an undefined type" do + m = FFI::MemoryPointer.new(:long) + expect { m.read(:undefined_type) }.to raise_error(ArgumentError) + end + it "raises an error if you try putting a long into a pointer of size 1" do m = FFI::MemoryPointer.new(1) - expect { m.write_long(10) }.to raise_error + expect { m.write_long(10) }.to raise_error(IndexError) end - + it "raises an error if you try putting an int into a pointer of size 1" do m = FFI::MemoryPointer.new(1) - expect { m.write_int(10) }.to raise_error + expect { m.write_int(10) }.to raise_error(IndexError) end # it "does not raise IndexError for opaque pointers" do # m = FFI::MemoryPointer.new(8) diff --git a/spec/ffi/rbx/struct_spec.rb b/spec/ffi/rbx/struct_spec.rb index a7ed85b444a..c2a51fa48c2 100644 --- a/spec/ffi/rbx/struct_spec.rb +++ b/spec/ffi/rbx/struct_spec.rb @@ -5,14 +5,16 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) -class Timeval < FFI::Struct - layout :tv_sec, :ulong, 0, :tv_usec, :ulong, 4 -end +module RbxStructSpecs + class Timeval < FFI::Struct + layout :tv_sec, :ulong, 0, :tv_usec, :ulong, 4 + end -describe FFI::Struct do - it "allows setting fields" do - t = Timeval.new - t[:tv_sec] = 12 - expect(t[:tv_sec]).to eq(12) + describe FFI::Struct do + it "allows setting fields" do + t = Timeval.new + t[:tv_sec] = 12 + expect(t[:tv_sec]).to eq(12) + end end end diff --git a/spec/ffi/spec_helper.rb b/spec/ffi/spec_helper.rb index 00c43ecaead..69a596ea7fb 100644 --- a/spec/ffi/spec_helper.rb +++ b/spec/ffi/spec_helper.rb @@ -3,82 +3,13 @@ # For licensing, see LICENSE.SPECS # -require 'rbconfig' -require 'fileutils' -require 'ffi' +require_relative 'fixtures/compile' -CPU = case RbConfig::CONFIG['host_cpu'].downcase - when /i[3456]86/ - # Darwin always reports i686, even when running in 64bit mode - if RbConfig::CONFIG['host_os'] =~ /darwin/ && 0xfee1deadbeef.is_a?(Fixnum) - "x86_64" - else - "i386" - end - - when /amd64|x86_64/ - "x86_64" - - when /ppc64|powerpc64/ - "powerpc64" - - when /ppc|powerpc/ - "powerpc" - - when /^arm/ - "arm" - - else - RbConfig::CONFIG['host_cpu'] - end - -OS = case RbConfig::CONFIG['host_os'].downcase - when /linux/ - "linux" - when /darwin/ - "darwin" - when /freebsd/ - "freebsd" - when /openbsd/ - "openbsd" - when /sunos|solaris/ - "solaris" - when /mswin|mingw/ - "win32" - else - RbConfig::CONFIG['host_os'].downcase - end - -def compile_library(path, lib) - - dir = File.expand_path(path, File.dirname(__FILE__)) - lib = "#{dir}/#{lib}" - if !File.exists?(lib) - ldshared = RbConfig::CONFIG["LDSHARED"] || "clang -dynamic -bundle" - libs = RbConfig::CONFIG["LIBS"] - dldflags = RbConfig::CONFIG["DLDFLAGS"] || "-Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress" - - puts Dir.pwd, dir, File.dirname(__FILE__) - - output = nil - FileUtils.cd(dir) do - output = system(*%{#{system('which gmake >/dev/null') && 'gmake' || 'make'} CPU=#{CPU} OS=#{OS} }.tap{|x| puts x.inspect}) - end - - if $?.exitstatus != 0 - puts "ERROR:\n#{output}" - raise "Unable to compile \"#{lib}\"" - end - end - - lib +RSpec.configure do |c| + c.filter_run_excluding :broken => true end -require "ffi" - module TestLibrary - PATH = compile_library("fixtures", "libtest.#{FFI::Platform::LIBSUFFIX}") - def self.force_gc if RUBY_PLATFORM =~ /java/ java.lang.System.gc @@ -89,6 +20,7 @@ def self.force_gc end end end + module LibTest extend FFI::Library ffi_lib TestLibrary::PATH diff --git a/spec/ffi/string_spec.rb b/spec/ffi/string_spec.rb index fac11f00b5b..ade0d86f916 100644 --- a/spec/ffi/string_spec.rb +++ b/spec/ffi/string_spec.rb @@ -11,41 +11,22 @@ module StrLibTest ffi_lib TestLibrary::PATH attach_function :ptr_ret_pointer, [ :pointer, :int], :string attach_function :string_equals, [ :string, :string ], :int + attach_function :pointer_string_equals, :string_equals, [ :pointer, :string ], :int attach_function :string_dummy, [ :string ], :void attach_function :string_null, [ ], :string end - it "MemoryPointer#get_string returns a tainted string" do - mp = FFI::MemoryPointer.new 1024 - mp.put_string(0, "test\0") - str = mp.get_string(0) - expect(str.tainted?).to be true - end - - it "String returned by a method is tainted" do - mp = FFI::MemoryPointer.new :pointer - sp = FFI::MemoryPointer.new 1024 - sp.put_string(0, "test") - mp.put_pointer(0, sp) - str = StrLibTest.ptr_ret_pointer(mp, 0) - expect(str).to eq("test") - expect(str).to be_tainted + it "A String can be passed to a :pointer argument" do + str = "string buffer" + expect(StrLibTest.pointer_string_equals(str, str)).to eq(1) + expect(StrLibTest.pointer_string_equals(str + "a", str)).to eq(0) end it "Poison null byte raises error" do s = "123\0abc" - expect { StrLibTest.string_equals(s, s) }.to raise_error + expect { StrLibTest.string_equals(s, s) }.to raise_error(ArgumentError) end - it "Tainted String parameter should throw a SecurityError" do - $SAFE = 1 - str = "test" - str.taint - begin - expect(LibTest.string_equals(str, str)).to be false - rescue SecurityError - end - end if false it "casts nil as NULL pointer" do expect(StrLibTest.string_dummy(nil)).to be_nil end @@ -101,7 +82,7 @@ module StrLibTest a << f end ptrary.write_array_of_pointer(ary) - expect { ptrary.get_array_of_string(0, 6) }.to raise_error + expect { ptrary.get_array_of_string(0, 6) }.to raise_error(IndexError) end it "raises an IndexError when trying to read an array of strings using a negative offset" do @@ -113,6 +94,6 @@ module StrLibTest a << f end ptrary.write_array_of_pointer(ary) - expect { ptrary.get_array_of_string(-1) }.to raise_error + expect { ptrary.get_array_of_string(-1) }.to raise_error(IndexError) end end diff --git a/spec/ffi/struct_spec.rb b/spec/ffi/struct_spec.rb index 9cb08bc7ec3..45e10ec8818 100644 --- a/spec/ffi/struct_spec.rb +++ b/spec/ffi/struct_spec.rb @@ -5,6 +5,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) +module StructSpecs describe "Struct aligns fields correctly" do it "char, followed by an int" do class CIStruct < FFI::Struct @@ -35,430 +36,463 @@ class LLIStruct < FFI::Struct end end -describe "Struct tests" do - StructTypes = { - 's8' => :char, - 's16' => :short, - 's32' => :int, - 's64' => :long_long, - 'long' => :long, - 'f32' => :float, - 'f64' => :double - } - module LibTest - extend FFI::Library - ffi_lib TestLibrary::PATH - attach_function :ptr_ret_pointer, [ :pointer, :int], :string - begin - attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int - rescue FFI::NotFoundError - # NetBSD uses #define instead of typedef for these - attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :pointer, :int ], :int - end - attach_function :ptr_from_address, [ :ulong ], :pointer - attach_function :string_equals, [ :string, :string ], :int - [ 's8', 's16', 's32', 's64', 'f32', 'f64', 'long' ].each do |t| - attach_function "struct_align_#{t}", [ :pointer ], StructTypes[t] - end - end - class PointerMember < FFI::Struct - layout :pointer, :pointer - end - class StringMember < FFI::Struct - layout :string, :string - end - - it "Struct#[:pointer]" do - magic = 0x12345678 - mp = FFI::MemoryPointer.new :long - mp.put_long(0, magic) - smp = FFI::MemoryPointer.new :pointer - smp.put_pointer(0, mp) - s = PointerMember.new smp - expect(s[:pointer]).to eq(mp) - end - - it "Struct#[:pointer].nil? for NULL value" do - magic = 0x12345678 - mp = FFI::MemoryPointer.new :long - mp.put_long(0, magic) - smp = FFI::MemoryPointer.new :pointer - smp.put_pointer(0, nil) - s = PointerMember.new smp - expect(s[:pointer].null?).to be true - end - - it "Struct#[:pointer]=" do - magic = 0x12345678 - mp = FFI::MemoryPointer.new :long - mp.put_long(0, magic) - smp = FFI::MemoryPointer.new :pointer - s = PointerMember.new smp - s[:pointer] = mp - expect(smp.get_pointer(0)).to eq(mp) - end - - it "Struct#[:pointer]=struct" do - smp = FFI::MemoryPointer.new :pointer - s = PointerMember.new smp - expect { s[:pointer] = s }.not_to raise_error Exception - expect { foo = s[:pointer] }.not_to raise_error Exception - end - - it "Struct#[:pointer]=nil" do - smp = FFI::MemoryPointer.new :pointer - s = PointerMember.new smp - s[:pointer] = nil - expect(smp.get_pointer(0)).to be_null - end - - it "Struct#[:string]" do - magic = "test" - mp = FFI::MemoryPointer.new 1024 - mp.put_string(0, magic) - smp = FFI::MemoryPointer.new :pointer - smp.put_pointer(0, mp) - s = StringMember.new smp - expect(s[:string]).to eq(magic) - end - - it "Struct#[:string].nil? for NULL value" do - smp = FFI::MemoryPointer.new :pointer - smp.put_pointer(0, nil) - s = StringMember.new smp - expect(s[:string]).to be_nil - end - - it "Struct#layout works with :name, :type pairs" do - class PairLayout < FFI::Struct - layout :a, :int, :b, :long_long - end - ll_off = (FFI::TYPE_UINT64.alignment == 4 ? 4 : 8) - expect(PairLayout.size).to eq((ll_off + 8)) - mp = FFI::MemoryPointer.new(PairLayout.size) - s = PairLayout.new mp - s[:a] = 0x12345678 - expect(mp.get_int(0)).to eq(0x12345678) - s[:b] = 0xfee1deadbeef - expect(mp.get_int64(ll_off)).to eq(0xfee1deadbeef) - end - - it "Struct#layout works with :name, :type, offset tuples" do - class PairLayout < FFI::Struct - layout :a, :int, 0, :b, :long_long, 4 - end - expect(PairLayout.size).to eq((FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)) - mp = FFI::MemoryPointer.new(PairLayout.size) - s = PairLayout.new mp - s[:a] = 0x12345678 - expect(mp.get_int(0)).to eq(0x12345678) - s[:b] = 0xfee1deadbeef - expect(mp.get_int64(4)).to eq(0xfee1deadbeef) - end - - it "Struct#layout works with mixed :name,:type and :name,:type,offset" do - class MixedLayout < FFI::Struct - layout :a, :int, :b, :long_long, 4 +module StructSpecsStructTests + describe "Struct tests" do + StructTypes = { + 's8' => :char, + 's16' => :short, + 's32' => :int, + 's64' => :long_long, + 'long' => :long, + 'f32' => :float, + 'f64' => :double + } + module LibTest + extend FFI::Library + ffi_lib TestLibrary::PATH + attach_function :ptr_ret_pointer, [ :pointer, :int], :string + begin + attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int + rescue FFI::NotFoundError + # NetBSD uses #define instead of typedef for these + attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :pointer, :int ], :int + end + attach_function :ptr_from_address, [ :ulong ], :pointer + attach_function :string_equals, [ :string, :string ], :int + [ 's8', 's16', 's32', 's64', 'f32', 'f64', 'long' ].each do |t| + attach_function "struct_align_#{t}", [ :pointer ], StructTypes[t] + end + end + class PointerMember < FFI::Struct + layout :pointer, :pointer + end + class StringMember < FFI::Struct + layout :string, :string end - expect(MixedLayout.size).to eq((FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)) - mp = FFI::MemoryPointer.new(MixedLayout.size) - s = MixedLayout.new mp - s[:a] = 0x12345678 - expect(mp.get_int(0)).to eq(0x12345678) - s[:b] = 0xfee1deadbeef - expect(mp.get_int64(4)).to eq(0xfee1deadbeef) - end - - rb_maj, rb_min = RUBY_VERSION.split('.') - if rb_maj.to_i >= 1 && rb_min.to_i >= 9 || RUBY_PLATFORM =~ /java/ - it "Struct#layout withs with a hash of :name => type" do - class HashLayout < FFI::Struct - layout :a => :int, :b => :long_long + + it "Struct#[:pointer]" do + magic = 0x12345678 + mp = FFI::MemoryPointer.new :long + mp.put_long(0, magic) + smp = FFI::MemoryPointer.new :pointer + smp.put_pointer(0, mp) + s = PointerMember.new smp + expect(s[:pointer]).to eq(mp) + end + + it "Struct#[:pointer].nil? for NULL value" do + magic = 0x12345678 + mp = FFI::MemoryPointer.new :long + mp.put_long(0, magic) + smp = FFI::MemoryPointer.new :pointer + smp.put_pointer(0, nil) + s = PointerMember.new smp + expect(s[:pointer].null?).to be true + end + + it "Struct#[:pointer]=" do + magic = 0x12345678 + mp = FFI::MemoryPointer.new :long + mp.put_long(0, magic) + smp = FFI::MemoryPointer.new :pointer + s = PointerMember.new smp + s[:pointer] = mp + expect(smp.get_pointer(0)).to eq(mp) + end + + it "Struct#[:pointer]=struct" do + smp = FFI::MemoryPointer.new :pointer + s = PointerMember.new smp + expect { s[:pointer] = s }.not_to raise_error Exception + expect { s[:pointer].nil? }.not_to raise_error Exception + end + + it "Struct#[:pointer]=nil" do + smp = FFI::MemoryPointer.new :pointer + s = PointerMember.new smp + s[:pointer] = nil + expect(smp.get_pointer(0)).to be_null + end + + it "Struct#[:string]" do + magic = "test" + mp = FFI::MemoryPointer.new 1024 + mp.put_string(0, magic) + smp = FFI::MemoryPointer.new :pointer + smp.put_pointer(0, mp) + s = StringMember.new smp + expect(s[:string]).to eq(magic) + end + + it "Struct#[:string].nil? for NULL value" do + smp = FFI::MemoryPointer.new :pointer + smp.put_pointer(0, nil) + s = StringMember.new smp + expect(s[:string]).to be_nil + end + + it "Struct#layout works with :name, :type pairs" do + s = Class.new(FFI::Struct) do + layout :a, :int, :b, :long_long end ll_off = (FFI::TYPE_UINT64.alignment == 4 ? 4 : 8) - expect(HashLayout.size).to eq(ll_off + 8) - mp = FFI::MemoryPointer.new(HashLayout.size) - s = HashLayout.new mp + expect(s.size).to eq((ll_off + 8)) + mp = FFI::MemoryPointer.new(s.size) + s = s.new mp s[:a] = 0x12345678 expect(mp.get_int(0)).to eq(0x12345678) s[:b] = 0xfee1deadbeef expect(mp.get_int64(ll_off)).to eq(0xfee1deadbeef) end - end - it "subclass overrides initialize without calling super" do - class InitializeWithoutSuper < FFI::Struct - layout :a, :int, :b, :long_long, :d, [:double, 2] - - def initialize(a, b) - self[:a] = a - self[:b] = b - self[:d][0] = 1.2 - self[:d][1] = 3.4 + it "Struct#layout works with :name, :type, offset tuples" do + s = Class.new(FFI::Struct) do + layout :a, :int, 0, :b, :long_long, 4 end - + expect(s.size).to eq((FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)) + mp = FFI::MemoryPointer.new(s.size) + s = s.new mp + s[:a] = 0x12345678 + expect(mp.get_int(0)).to eq(0x12345678) + s[:b] = 0xfee1deadbeef + expect(mp.get_int64(4)).to eq(0xfee1deadbeef) end - s = InitializeWithoutSuper.new(0x1eefbeef, 0xdeadcafebabe) - expect(s[:a]).to eq(0x1eefbeef) - expect(s[:b]).to eq(0xdeadcafebabe) - end - it "Can use Struct subclass as parameter type" do - expect(module StructParam - extend FFI::Library - ffi_lib TestLibrary::PATH - class TestStruct < FFI::Struct - layout :c, :char + it "Struct#layout works with mixed :name,:type and :name,:type,offset" do + class MixedLayout < FFI::Struct + layout :a, :int, :b, :long_long, 4 end - attach_function :struct_field_s8, [ TestStruct.in ], :char - end).to be_an_instance_of FFI::Function - end + expect(MixedLayout.size).to eq((FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)) + mp = FFI::MemoryPointer.new(MixedLayout.size) + s = MixedLayout.new mp + s[:a] = 0x12345678 + expect(mp.get_int(0)).to eq(0x12345678) + s[:b] = 0xfee1deadbeef + expect(mp.get_int64(4)).to eq(0xfee1deadbeef) + end - it "Can use Struct subclass as IN parameter type" do - expect(module StructParam2 - extend FFI::Library - ffi_lib TestLibrary::PATH - class TestStruct < FFI::Struct - layout :c, :char + rb_maj, rb_min = RUBY_VERSION.split('.') + if rb_maj.to_i >= 1 && rb_min.to_i >= 9 || RUBY_PLATFORM =~ /java/ + it "Struct#layout withs with a hash of :name => type" do + class HashLayout < FFI::Struct + layout :a => :int, :b => :long_long + end + ll_off = (FFI::TYPE_UINT64.alignment == 4 ? 4 : 8) + expect(HashLayout.size).to eq(ll_off + 8) + mp = FFI::MemoryPointer.new(HashLayout.size) + s = HashLayout.new mp + s[:a] = 0x12345678 + expect(mp.get_int(0)).to eq(0x12345678) + s[:b] = 0xfee1deadbeef + expect(mp.get_int64(ll_off)).to eq(0xfee1deadbeef) end - attach_function :struct_field_s8, [ TestStruct.in ], :char - end).to be_an_instance_of FFI::Function - end + end + + it "subclass overrides initialize without calling super" do + class InitializeWithoutSuper < FFI::Struct + layout :a, :int, :b, :long_long, :d, [:double, 2] + + def initialize(a, b) + self[:a] = a + self[:b] = b + self[:d][0] = 1.2 + self[:d][1] = 3.4 + end - it "Can use Struct subclass as OUT parameter type" do - expect(module StructParam3 - extend FFI::Library - ffi_lib TestLibrary::PATH - class TestStruct < FFI::Struct - layout :c, :char end - attach_function :struct_field_s8, [ TestStruct.out ], :char - end).to be_an_instance_of FFI::Function - end + s = InitializeWithoutSuper.new(0x1eefbeef, 0xdeadcafebabe) + expect(s[:a]).to eq(0x1eefbeef) + expect(s[:b]).to eq(0xdeadcafebabe) + end - it "can be passed directly as a :pointer parameter" do - class TestStruct < FFI::Struct - layout :i, :int + it "Can use Struct subclass as parameter type" do + expect(module StructParam + extend FFI::Library + ffi_lib TestLibrary::PATH + class TestStruct < FFI::Struct + layout :c, :char + end + attach_function :struct_field_s8, [ TestStruct.in ], :char + end).to be_an_instance_of FFI::Function end - s = TestStruct.new - s[:i] = 0x12 - expect(LibTest.ptr_ret_int32_t(s, 0)).to eq(0x12) - end - it ":char member aligned correctly" do - class AlignChar < FFI::Struct - layout :c, :char, :v, :char + it "Can use Struct subclass as IN parameter type" do + expect(module StructParam2 + extend FFI::Library + ffi_lib TestLibrary::PATH + class TestStruct < FFI::Struct + layout :c, :char + end + attach_function :struct_field_s8, [ TestStruct.in ], :char + end).to be_an_instance_of FFI::Function end - s = AlignChar.new - s[:v] = 0x12 - expect(LibTest.struct_align_s8(s.pointer)).to eq(0x12) - end - it ":short member aligned correctly" do - class AlignShort < FFI::Struct - layout :c, :char, :v, :short + it "Can use Struct subclass as OUT parameter type" do + expect(module StructParam3 + extend FFI::Library + ffi_lib TestLibrary::PATH + class TestStruct < FFI::Struct + layout :c, :char + end + attach_function :struct_field_s8, [ TestStruct.out ], :char + end).to be_an_instance_of FFI::Function end - s = AlignShort.alloc_in - s[:v] = 0x1234 - expect(LibTest.struct_align_s16(s.pointer)).to eq(0x1234) - end - it ":int member aligned correctly" do - class AlignInt < FFI::Struct - layout :c, :char, :v, :int + it "can be passed directly as a :pointer parameter" do + class TestStruct < FFI::Struct + layout :i, :int + end + s = TestStruct.new + s[:i] = 0x12 + expect(LibTest.ptr_ret_int32_t(s, 0)).to eq(0x12) end - s = AlignInt.alloc_in - s[:v] = 0x12345678 - expect(LibTest.struct_align_s32(s.pointer)).to eq(0x12345678) - end - it ":long_long member aligned correctly" do - class AlignLongLong < FFI::Struct - layout :c, :char, :v, :long_long + it ":char member aligned correctly" do + class AlignChar < FFI::Struct + layout :c, :char, :v, :char + end + s = AlignChar.new + s[:v] = 0x12 + expect(LibTest.struct_align_s8(s.pointer)).to eq(0x12) end - s = AlignLongLong.alloc_in - s[:v] = 0x123456789abcdef0 - expect(LibTest.struct_align_s64(s.pointer)).to eq(0x123456789abcdef0) - end - it ":long member aligned correctly" do - class AlignLong < FFI::Struct - layout :c, :char, :v, :long + it ":short member aligned correctly" do + class AlignShort < FFI::Struct + layout :c, :char, :v, :short + end + s = AlignShort.alloc_in + s[:v] = 0x1234 + expect(LibTest.struct_align_s16(s.pointer)).to eq(0x1234) end - s = AlignLong.alloc_in - s[:v] = 0x12345678 - expect(LibTest.struct_align_long(s.pointer)).to eq(0x12345678) - end - it ":float member aligned correctly" do - class AlignFloat < FFI::Struct - layout :c, :char, :v, :float + it ":int member aligned correctly" do + class AlignInt < FFI::Struct + layout :c, :char, :v, :int + end + s = AlignInt.alloc_in + s[:v] = 0x12345678 + expect(LibTest.struct_align_s32(s.pointer)).to eq(0x12345678) end - s = AlignFloat.alloc_in - s[:v] = 1.23456 - expect((LibTest.struct_align_f32(s.pointer) - 1.23456).abs).to be < 0.00001 - end - it ":double member aligned correctly" do - class AlignDouble < FFI::Struct - layout :c, :char, :v, :double + it ":long_long member aligned correctly" do + class AlignLongLong < FFI::Struct + layout :c, :char, :v, :long_long + end + s = AlignLongLong.alloc_in + s[:v] = 0x123456789abcdef0 + expect(LibTest.struct_align_s64(s.pointer)).to eq(0x123456789abcdef0) end - s = AlignDouble.alloc_in - s[:v] = 1.23456789 - expect((LibTest.struct_align_f64(s.pointer) - 1.23456789).abs).to be < 0.00000001 - end - it ":ulong, :pointer struct" do - class ULPStruct < FFI::Struct - layout :ul, :ulong, :p, :pointer + it ":long member aligned correctly" do + class AlignLong < FFI::Struct + layout :c, :char, :v, :long + end + s = AlignLong.alloc_in + s[:v] = 0x12345678 + expect(LibTest.struct_align_long(s.pointer)).to eq(0x12345678) end - s = ULPStruct.alloc_in - s[:ul] = 0xdeadbeef - s[:p] = LibTest.ptr_from_address(0x12345678) - expect(s.pointer.get_ulong(0)).to eq(0xdeadbeef) - end - def test_num_field(type, v) - klass = Class.new(FFI::Struct) - klass.layout :v, type, :dummy, :long - s = klass.new - s[:v] = v - expect(s.pointer.send("get_#{type.to_s}", 0)).to eq(v) - s.pointer.send("put_#{type.to_s}", 0, 0) - expect(s[:v]).to eq(0) - end - def self.int_field_test(type, values) - values.each do |v| - it "#{type} field r/w (#{v.to_s(16)})" do - test_num_field(type, v) + it ":float member aligned correctly" do + class AlignFloat < FFI::Struct + layout :c, :char, :v, :float end + s = AlignFloat.alloc_in + s[:v] = 1.23456 + expect((LibTest.struct_align_f32(s.pointer) - 1.23456).abs).to be < 0.00001 end - end - int_field_test(:char, [ 0, 127, -128, -1 ]) - int_field_test(:uchar, [ 0, 0x7f, 0x80, 0xff ]) - int_field_test(:short, [ 0, 0x7fff, -0x8000, -1 ]) - int_field_test(:ushort, [ 0, 0x7fff, 0x8000, 0xffff ]) - int_field_test(:int, [ 0, 0x7fffffff, -0x80000000, -1 ]) - int_field_test(:uint, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ]) - int_field_test(:long_long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ]) - int_field_test(:ulong_long, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ]) - if FFI::Platform::LONG_SIZE == 32 - int_field_test(:long, [ 0, 0x7fffffff, -0x80000000, -1 ]) - int_field_test(:ulong, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ]) - else - int_field_test(:long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ]) - int_field_test(:ulong, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ]) - end - it ":float field r/w" do - klass = Class.new(FFI::Struct) - klass.layout :v, :float, :dummy, :long + it ":double member aligned correctly" do + class AlignDouble < FFI::Struct + layout :c, :char, :v, :double + end + s = AlignDouble.alloc_in + s[:v] = 1.23456789 + expect((LibTest.struct_align_f64(s.pointer) - 1.23456789).abs).to be < 0.00000001 + end - s = klass.new - value = 1.23456 - s[:v] = value - expect((s.pointer.get_float(0) - value).abs).to be < 0.0001 - end + it ":ulong, :pointer struct" do + class ULPStruct < FFI::Struct + layout :ul, :ulong, :p, :pointer + end + s = ULPStruct.alloc_in + s[:ul] = 0xdeadbeef + s[:p] = LibTest.ptr_from_address(0x12345678) + expect(s.pointer.get_ulong(0)).to eq(0xdeadbeef) + end + def test_num_field(type, v) + klass = Class.new(FFI::Struct) + klass.layout :v, type, :dummy, :long + + s = klass.new + s[:v] = v + expect(s.pointer.send("get_#{type.to_s}", 0)).to eq(v) + s.pointer.send("put_#{type.to_s}", 0, 0) + expect(s[:v]).to eq(0) + end + def self.int_field_test(type, values) + values.each do |v| + it "#{type} field r/w (#{v.to_s(16)})" do + test_num_field(type, v) + end + end + end + int_field_test(:char, [ 0, 127, -128, -1 ]) + int_field_test(:uchar, [ 0, 0x7f, 0x80, 0xff ]) + int_field_test(:short, [ 0, 0x7fff, -0x8000, -1 ]) + int_field_test(:ushort, [ 0, 0x7fff, 0x8000, 0xffff ]) + int_field_test(:int, [ 0, 0x7fffffff, -0x80000000, -1 ]) + int_field_test(:uint, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ]) + int_field_test(:long_long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ]) + int_field_test(:ulong_long, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ]) + if FFI::Platform::LONG_SIZE == 32 + int_field_test(:long, [ 0, 0x7fffffff, -0x80000000, -1 ]) + int_field_test(:ulong, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ]) + else + int_field_test(:long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ]) + int_field_test(:ulong, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ]) + end + + it ":float field r/w" do + klass = Class.new(FFI::Struct) + klass.layout :v, :float, :dummy, :long + + s = klass.new + value = 1.23456 + s[:v] = value + expect((s.pointer.get_float(0) - value).abs).to be < 0.0001 + end + + it ":double field r/w" do + klass = Class.new(FFI::Struct) + klass.layout :v, :double, :dummy, :long + + s = klass.new + value = 1.23456 + s[:v] = value + expect((s.pointer.get_double(0) - value).abs).to be < 0.0001 + end + module EnumFields + extend FFI::Library + TestEnum = enum :test_enum, [:c1, 10, :c2, 20, :c3, 30, :c4, 40] + class TestStruct < FFI::Struct + layout :a, :int, :c, :test_enum, + :d, [ TestEnum, TestEnum.symbols.length ] + end + end - it ":double field r/w" do - klass = Class.new(FFI::Struct) - klass.layout :v, :double, :dummy, :long + it ":enum field r/w" do + s = EnumFields::TestStruct.new + s[:c] = :c3 - s = klass.new - value = 1.23456 - s[:v] = value - expect((s.pointer.get_double(0) - value).abs).to be < 0.0001 - end - module EnumFields - extend FFI::Library - TestEnum = enum :test_enum, [:c1, 10, :c2, 20, :c3, 30, :c4, 40] - class TestStruct < FFI::Struct - layout :a, :int, :c, :test_enum, - :d, [ TestEnum, TestEnum.symbols.length ] + expect(s.pointer.get_uint(FFI::Type::INT32.size)).to eq(30) + expect(s[:c]).to eq(:c3) end - end - it ":enum field r/w" do - s = EnumFields::TestStruct.new - s[:c] = :c3 + it "array of :enum field" do + s = EnumFields::TestStruct.new + EnumFields::TestEnum.symbols.each_with_index do |val, i| + s[:d][i] = val + end - expect(s.pointer.get_uint(FFI::Type::INT32.size)).to eq(30) - expect(s[:c]).to eq(:c3) - end + EnumFields::TestEnum.symbols.each_with_index do |val, i| + expect(s.pointer.get_uint(FFI::Type::INT32.size * (2 + i))).to eq(EnumFields::TestEnum[val]) + end - it "array of :enum field" do - s = EnumFields::TestStruct.new - EnumFields::TestEnum.symbols.each_with_index do |val, i| - s[:d][i] = val + s[:d].each_with_index do |val, i| + expect(val).to eq(EnumFields::TestEnum.symbols[i]) + end end - EnumFields::TestEnum.symbols.each_with_index do |val, i| - expect(s.pointer.get_uint(FFI::Type::INT32.size * (2 + i))).to eq(EnumFields::TestEnum[val]) + module CallbackMember + extend FFI::Library + ffi_lib TestLibrary::PATH + callback :add, [ :int, :int ], :int + callback :sub, [ :int, :int ], :int + class TestStruct < FFI::Struct + layout :add, :add, + :sub, :sub + end + attach_function :struct_call_add_cb, [TestStruct.in, :int, :int], :int + attach_function :struct_call_sub_cb, [TestStruct.in, :int, :int], :int end - s[:d].each_with_index do |val, i| - expect(val).to eq(EnumFields::TestEnum.symbols[i]) + it "Can have CallbackInfo struct field" do + s = CallbackMember::TestStruct.new + add_proc = lambda { |a, b| a+b } + sub_proc = lambda { |a, b| a-b } + s[:add] = add_proc + s[:sub] = sub_proc + expect(CallbackMember.struct_call_add_cb(s, 40, 2)).to eq(42) + expect(CallbackMember.struct_call_sub_cb(s, 44, 2)).to eq(42) end - end - module CallbackMember - extend FFI::Library - ffi_lib TestLibrary::PATH - callback :add, [ :int, :int ], :int - callback :sub, [ :int, :int ], :int - class TestStruct < FFI::Struct - layout :add, :add, - :sub, :sub + it "Can return its members as a list" do + s = Class.new(FFI::Struct) do + layout :a, :int, :b, :int, :c, :int + end + expect(s.members).to include(:a, :b, :c) end - attach_function :struct_call_add_cb, [TestStruct.in, :int, :int], :int - attach_function :struct_call_sub_cb, [TestStruct.in, :int, :int], :int - end - - it "Can have CallbackInfo struct field" do - s = CallbackMember::TestStruct.new - add_proc = lambda { |a, b| a+b } - sub_proc = lambda { |a, b| a-b } - s[:add] = add_proc - s[:sub] = sub_proc - expect(CallbackMember.struct_call_add_cb(s, 40, 2)).to eq(42) - expect(CallbackMember.struct_call_sub_cb(s, 44, 2)).to eq(42) - end - it "Can return its members as a list" do - class TestStruct < FFI::Struct - layout :a, :int, :b, :int, :c, :int + it "Can return its instance members and values as lists" do + s = Class.new(FFI::Struct) do + layout :a, :int, :b, :int, :c, :int + end + s = s.new + expect(s.members).to include(:a, :b, :c) + s[:a] = 1 + s[:b] = 2 + s[:c] = 3 + expect(s.values).to include(1, 2, 3) end - expect(TestStruct.members).to include(:a, :b, :c) - end - it "Can return its instance members and values as lists" do - class TestStruct < FFI::Struct - layout :a, :int, :b, :int, :c, :int + it 'should return an ordered field/offset pairs array' do + s = Class.new(FFI::Struct) do + layout :a, :int, :b, :int, :c, :int + end + s = s.new + expect(s.offsets).to eq([[:a, 0], [:b, 4], [:c, 8]]) + expect(s.offsets).to eq([[:a, 0], [:b, 4], [:c, 8]]) end - s = TestStruct.new - expect(s.members).to include(:a, :b, :c) - s[:a] = 1 - s[:b] = 2 - s[:c] = 3 - expect(s.values).to include(1, 2, 3) - end - it 'should return an ordered field/offset pairs array' do - class TestStruct < FFI::Struct - layout :a, :int, :b, :int, :c, :int + it "Struct#offset_of returns offset of field within struct" do + s = Class.new(FFI::Struct) do + layout :a, :int, :b, :int, :c, :int + end + expect(s.offset_of(:a)).to eq(0) + expect(s.offset_of(:b)).to eq(4) + expect(s.offset_of(:c)).to eq(8) + end + + if FFI::VERSION < "2" + it "warns about redefinition of struct layouts" do + expect do + Class.new(FFI::Struct) do + layout :a, :int + layout :a, :int + end + end.to output(/Redefinition .* will be disallowed in ffi-2.0/).to_stderr + end + else + it "denies redefinition of struct layouts" do + expect do + Class.new(FFI::Struct) do + layout :a, :int + layout :a, :int + end + end.to raise_error(/struct layout already defined/) + end end - s = TestStruct.new - expect(s.offsets).to eq([[:a, 0], [:b, 4], [:c, 8]]) - expect(TestStruct.offsets).to eq([[:a, 0], [:b, 4], [:c, 8]]) - end - it "Struct#offset_of returns offset of field within struct" do - class TestStruct < FFI::Struct - layout :a, :int, :b, :int, :c, :int + it "allows redefinition of struct layouts in derived classes" do + a = Class.new(FFI::Struct) do + layout :a, :char + end + b = Class.new(a) do + layout :a, :char, :b, :char + end + expect(a.members).to eq([:a]) + expect(b.members).to eq([:a, :b]) end - expect(TestStruct.offset_of(:a)).to eq(0) - expect(TestStruct.offset_of(:b)).to eq(4) - expect(TestStruct.offset_of(:c)).to eq(8) end end @@ -793,40 +827,40 @@ class BuggedStruct < FFI::Struct describe "Struct allocation" do it "MemoryPointer.new(Struct, 2)" do - class S < FFI::Struct + s = Class.new(FFI::Struct) do layout :i, :uint end - p = FFI::MemoryPointer.new(S, 2) + p = FFI::MemoryPointer.new(s, 2) expect(p.total).to eq(8) expect(p.type_size).to eq(4) p.put_uint(4, 0xdeadbeef) - expect(S.new(p[1])[:i]).to eq(0xdeadbeef) + expect(s.new(p[1])[:i]).to eq(0xdeadbeef) expect(p[1].address).to eq((p[0].address + 4)) end it "Buffer.new(Struct, 2)" do - class S < FFI::Struct + s = Class.new(FFI::Struct) do layout :i, :uint end - p = FFI::Buffer.new(S, 2) + p = FFI::Buffer.new(s, 2) expect(p.total).to eq(8) expect(p.type_size).to eq(4) p.put_uint(4, 0xdeadbeef) - expect(S.new(p[1])[:i]).to eq(0xdeadbeef) + expect(s.new(p[1])[:i]).to eq(0xdeadbeef) end it "null? should be true when initialized with NULL pointer" do - class S < FFI::Struct + s = Class.new(FFI::Struct) do layout :i, :uint end - expect(S.new(FFI::Pointer::NULL)).to be_null + expect(s.new(FFI::Pointer::NULL)).to be_null end it "null? should be false when initialized with non-NULL pointer" do - class S < FFI::Struct + s = Class.new(FFI::Struct) do layout :i, :uint end - expect(S.new(FFI::MemoryPointer.new(S))).not_to be_null + expect(s.new(FFI::MemoryPointer.new(s))).not_to be_null end it "supports :bool as a struct member" do @@ -855,7 +889,7 @@ class S < FFI::Struct Class.new(FFI::Struct) do layout :data, [ :char, 0 ], :count, :int end - }.to raise_error + }.to raise_error(TypeError) end it "can access elements of array" do @@ -875,8 +909,9 @@ class S < FFI::Struct end s = struct_class.new(FFI::MemoryPointer.new(1024)) s[:data][0] = 0x1eadbeef - expect { s[:data][1] = 0x12345678 }.to raise_error + expect { s[:data][1] = 0x12345678 }.to raise_error(IndexError) expect(s[:data][0]).to eq(0x1eadbeef) - expect { expect(s[:data][1]).to == 0x12345678 }.to raise_error + expect { expect(s[:data][1]).to == 0x12345678 }.to raise_error(IndexError) end end +end diff --git a/spec/ffi/variadic_spec.rb b/spec/ffi/variadic_spec.rb index 41382801138..0c7292e5c6e 100644 --- a/spec/ffi/variadic_spec.rb +++ b/spec/ffi/variadic_spec.rb @@ -13,6 +13,11 @@ module LibTest enum :enum_type2, [:c3, 42, :c4] attach_function :pack_varargs, [ :buffer_out, :string, :varargs ], :void attach_function :pack_varargs2, [ :buffer_out, :enum_type1, :string, :varargs ], :enum_type1 + + attach_function :testBlockingOpen, [ ], :pointer + attach_function :testBlockingRWva, [ :pointer, :char, :varargs ], :char, :blocking => true + attach_function :testBlockingWRva, [ :pointer, :char, :varargs ], :char, :blocking => true + attach_function :testBlockingClose, [ :pointer ], :void end it "takes enum arguments" do @@ -27,6 +32,20 @@ module LibTest expect(LibTest.pack_varargs2(buf, :c1, "ii", :int, :c3, :int, :c4)).to eq(:c2) end + it 'can wrap a blocking function with varargs' do + pending("not supported in 1.8") if RUBY_VERSION =~ /^1\.8\..*/ + handle = LibTest.testBlockingOpen + expect(handle).not_to be_null + begin + thWR = Thread.new { LibTest.testBlockingWRva(handle, 63, :int, 40, :int, 23, :int, 0) } + thRW = Thread.new { LibTest.testBlockingRWva(handle, 64, :int, 40, :int, 24, :int, 0) } + expect(thWR.value).to eq(64) + expect(thRW.value).to eq(63) + ensure + LibTest.testBlockingClose(handle) + end + end + [ 0, 127, -128, -1 ].each do |i| it "call variadic with (:char (#{i})) argument" do buf = FFI::Buffer.new :long_long