diff options
author | Anthony Green <green@moxielogic.com> | 2021-03-23 11:31:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-23 11:31:08 -0400 |
commit | 205cf01b57972fdc8c090fc79192b464dc43fc0d (patch) | |
tree | 7be40eeb5610861a795dc339d5c0dc02ab70d707 /doc/libffi.texi | |
parent | d271dbe0a8b230e566fa3385babdc9cc0ca214ea (diff) | |
download | libffi-205cf01b57972fdc8c090fc79192b464dc43fc0d.tar.gz |
Bug #680. Don't accept floats or small ints as var args. (#628)
* Bug #680. Don't accept floats or small ints as var args.
* Bug #680. Don't accept floats or small ints as var args.
* Bug #680. Don't accept floats or small ints as var args.
Diffstat (limited to 'doc/libffi.texi')
-rw-r--r-- | doc/libffi.texi | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/doc/libffi.texi b/doc/libffi.texi index bd30593..79f9377 100644 --- a/doc/libffi.texi +++ b/doc/libffi.texi @@ -18,7 +18,7 @@ This manual is for libffi, a portable foreign function interface library. -Copyright @copyright{} 2008--2019 Anthony Green and Red Hat, Inc. +Copyright @copyright{} 2008--2019, 2021 Anthony Green and Red Hat, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -176,6 +176,11 @@ variadic arguments. It must be greater than zero. @var{ntotalargs} the total number of arguments, including variadic and fixed arguments. @var{argtypes} must have this many elements. +@code{ffi_prep_cif_var} will return @code{FFI_BAD_ARGTYPE} if any of +the variable argument types are @code{ffi_type_float} (promote to +@code{ffi_type_double} first), or any integer type small than an int +(promote to an int-sized type first). + Note that, different cif's must be prepped for calls to the same function when different numbers of arguments are passed. @@ -249,26 +254,26 @@ int main() void *values[1]; char *s; ffi_arg rc; - - /* Initialize the argument info vectors */ + + /* Initialize the argument info vectors */ args[0] = &ffi_type_pointer; values[0] = &s; - + /* Initialize the cif */ - if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_sint, args) == FFI_OK) @{ s = "Hello World!"; ffi_call(&cif, puts, &rc, values); /* rc now holds the result of the call to puts */ - - /* values holds a pointer to the function's arg, so to - call puts() again all we need to do is change the + + /* values holds a pointer to the function's arg, so to + call puts() again all we need to do is change the value of s */ s = "This is cool!"; ffi_call(&cif, puts, &rc, values); @} - + return 0; @} @end example @@ -624,7 +629,7 @@ Here is the corresponding code to describe this struct to tm_type.size = tm_type.alignment = 0; tm_type.type = FFI_TYPE_STRUCT; tm_type.elements = &tm_type_elements; - + for (i = 0; i < 9; i++) tm_type_elements[i] = &ffi_type_sint; @@ -887,7 +892,7 @@ writable and executable addresses. @node Closure Example @section Closure Example -A trivial example that creates a new @code{puts} by binding +A trivial example that creates a new @code{puts} by binding @code{fputs} with @code{stdout}. @example |