This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 04/09/2015 09:20 AM, Friedrich Lobenstock wrote: > Hello! > > The documentation, eg. the online version at > <https://sourceware.org/newlib/libc.html#index-open>, is wrong in > regards to the implementation of open(). > > In the documentation the signature of open() is defined as: > int open(const char *name, int flags, int mode) That's documented merely as a minimum implementation; it always fails, so it doesn't matter whether va_args is parsed compatibly or anything else. I see nothing wrong with that documentation being a bare minimum, although you could go even further and write it as just: int open(const char *ignored1, int ignored2) { return -1; } and still get the same linking behavior. > > BUT in the library in sys/_default_fcntl.h (included via fcntl.h) its > signature is defined as follows: > int open (const char *, int, ...) This is the correct form standardized by POSIX. > > For a minimal implementation which just returns -1 this doesn't matter, > but not when one want's evaluate the other options after parameter "name". > > For libgloss/open.c it doesn't actually matter, but it's interface > should also be updated, I guess. Patches welcome. > > PS: I came across this "bug" after looking at the compilers assembly > code and wondering why on earth it is passing parameters on the stack, > while the called function is expecting parameters in registers. va_arg passing often involves the stack, even when registers are otherwise sufficient, based on platform ABI rules. As long as you aren't going to use the arguments, it doesn't matter ABI-wise if your signature for those unused arguments differs from the callers idea; but you are right that if the parameters are going to be used, then the correct signature should be used. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |