mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* ext/fiddle/conversions.c (generic_to_value): ffi_arg and ffi_sarg
should be used to handle shorter return value. fix [Bug #3861] [ruby-core:32504] * ext/fiddle/closure.c (callback): ditto * ext/fiddle/conversions.h (fiddle_generic): ditto * ext/fiddle/conversions.c (value_to_generic): char, short and int are strictly distinguished on big-endian CPU, e.g. sparc64. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									e26cead1e9
								
							
						
					
					
						commit
						4d71d34855
					
				
					 4 changed files with 28 additions and 5 deletions
				
			
		
							
								
								
									
										13
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
					@ -1,3 +1,16 @@
 | 
				
			||||||
 | 
					Tue Aug  9 14:25:47 2011  Naohisa Goto  <ngotogenome@gmail.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* ext/fiddle/conversions.c (generic_to_value): ffi_arg and ffi_sarg
 | 
				
			||||||
 | 
						  should be used to handle shorter return value. fix [Bug #3861]
 | 
				
			||||||
 | 
						  [ruby-core:32504]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* ext/fiddle/closure.c (callback): ditto
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* ext/fiddle/conversions.h (fiddle_generic): ditto
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* ext/fiddle/conversions.c (value_to_generic): char, short and int
 | 
				
			||||||
 | 
						  are strictly distinguished on big-endian CPU, e.g. sparc64.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Tue Aug  9 11:21:08 2011  Narihiro Nakamura  <authornari@gmail.com>
 | 
					Tue Aug  9 11:21:08 2011  Narihiro Nakamura  <authornari@gmail.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	* gc.c (gc_lazy_sweep): if sweep target slots are not found, we
 | 
						* gc.c (gc_lazy_sweep): if sweep target slots are not found, we
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -110,14 +110,13 @@ callback(ffi_cif *cif, void *resp, void **args, void *ctx)
 | 
				
			||||||
	*(long *)resp = NUM2LONG(ret);
 | 
						*(long *)resp = NUM2LONG(ret);
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
      case TYPE_CHAR:
 | 
					      case TYPE_CHAR:
 | 
				
			||||||
	*(char *)resp = NUM2INT(ret);
 | 
					      case TYPE_SHORT:
 | 
				
			||||||
 | 
					      case TYPE_INT:
 | 
				
			||||||
 | 
						*(ffi_sarg *)resp = NUM2INT(ret);
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
      case TYPE_VOIDP:
 | 
					      case TYPE_VOIDP:
 | 
				
			||||||
	*(void **)resp = NUM2PTR(ret);
 | 
						*(void **)resp = NUM2PTR(ret);
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
      case TYPE_INT:
 | 
					 | 
				
			||||||
	*(int *)resp = NUM2INT(ret);
 | 
					 | 
				
			||||||
	break;
 | 
					 | 
				
			||||||
      case TYPE_DOUBLE:
 | 
					      case TYPE_DOUBLE:
 | 
				
			||||||
	*(double *)resp = NUM2DBL(ret);
 | 
						*(double *)resp = NUM2DBL(ret);
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,11 @@ value_to_generic(int type, VALUE src, fiddle_generic * dst)
 | 
				
			||||||
	dst->pointer = NUM2PTR(rb_Integer(src));
 | 
						dst->pointer = NUM2PTR(rb_Integer(src));
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
      case TYPE_CHAR:
 | 
					      case TYPE_CHAR:
 | 
				
			||||||
 | 
						dst->schar = NUM2INT(src);
 | 
				
			||||||
 | 
						break;
 | 
				
			||||||
      case TYPE_SHORT:
 | 
					      case TYPE_SHORT:
 | 
				
			||||||
 | 
						dst->sshort = NUM2INT(src);
 | 
				
			||||||
 | 
						break;
 | 
				
			||||||
      case TYPE_INT:
 | 
					      case TYPE_INT:
 | 
				
			||||||
	dst->sint = NUM2INT(src);
 | 
						dst->sint = NUM2INT(src);
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
| 
						 | 
					@ -103,9 +107,14 @@ generic_to_value(VALUE rettype, fiddle_generic retval)
 | 
				
			||||||
        return rb_funcall(cPointer, rb_intern("[]"), 1,
 | 
					        return rb_funcall(cPointer, rb_intern("[]"), 1,
 | 
				
			||||||
          PTR2NUM((void *)retval.pointer));
 | 
					          PTR2NUM((void *)retval.pointer));
 | 
				
			||||||
      case TYPE_CHAR:
 | 
					      case TYPE_CHAR:
 | 
				
			||||||
 | 
						if (signed_p) return INT2NUM((char)retval.fffi_sarg);
 | 
				
			||||||
 | 
						return INT2NUM((unsigned char)retval.fffi_arg);
 | 
				
			||||||
      case TYPE_SHORT:
 | 
					      case TYPE_SHORT:
 | 
				
			||||||
 | 
						if (signed_p) return INT2NUM((short)retval.fffi_sarg);
 | 
				
			||||||
 | 
						return INT2NUM((unsigned short)retval.fffi_arg);
 | 
				
			||||||
      case TYPE_INT:
 | 
					      case TYPE_INT:
 | 
				
			||||||
	return INT2NUM(retval.sint);
 | 
						if (signed_p) return INT2NUM((int)retval.fffi_sarg);
 | 
				
			||||||
 | 
						return UINT2NUM((unsigned int)retval.fffi_arg);
 | 
				
			||||||
      case TYPE_LONG:
 | 
					      case TYPE_LONG:
 | 
				
			||||||
	if (signed_p) return LONG2NUM(retval.slong);
 | 
						if (signed_p) return LONG2NUM(retval.slong);
 | 
				
			||||||
	return ULONG2NUM(retval.ulong);
 | 
						return ULONG2NUM(retval.ulong);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef union
 | 
					typedef union
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    ffi_arg  fffi_arg;     /* rvalue smaller than unsigned long */
 | 
				
			||||||
 | 
					    ffi_sarg fffi_sarg;    /* rvalue smaller than signed long */
 | 
				
			||||||
    unsigned char uchar;   /* ffi_type_uchar */
 | 
					    unsigned char uchar;   /* ffi_type_uchar */
 | 
				
			||||||
    signed char   schar;   /* ffi_type_schar */
 | 
					    signed char   schar;   /* ffi_type_schar */
 | 
				
			||||||
    unsigned short ushort; /* ffi_type_sshort */
 | 
					    unsigned short ushort; /* ffi_type_sshort */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue