[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [MiNT] MiNTlibs for PureC
> From: owner-mint@fishpool.com [mailto:owner-mint@fishpool.com]On Behalf
> Of Helmut_Karlowski@mausd.gun.de
> Sent: Friday, September 10, 1999 11:40 PM
> To: mint@fishpool.com
> Subject: [MiNT] MiNTlibs for PureC
>
>
> Hallo Thomas,
>
> TB>> If 'name' doesn't exist, open returns -4, not -1.
> TB>
> TB>Then this is a bug in open(), as for /any/ error, -1 is to be returned,
> TB>with errno set to the corresponding error code.
>
> Agreed!
>
> The reason for this behaviour is to be found in fcntl.h #87:
>
> /* smallest valid gemdos handle */
> /* note handle is only word (16 bit) negative, not long negative,
> and since Fopen etc are declared as returning long in osbind.h
> the sign-extension will not happen -- thanks ers
> */
> #ifdef __MSHORT__
> #define __SMALLEST_VALID_HANDLE (-3)
> #else
> #define __SMALLEST_VALID_HANDLE (0)
> #endif
>
> So the -1 would have to be rplaced by __SMALLEST_VALID_HANDLE -1
> whenever a file-handle is returned !?
>
> Sure there are devices with negative handles but are they returned by
> open et al and/or does mintlib have to support this?
If open() is supposed to support these devices (and I think it is), the only
clean way to fix this seems to map the special handle -1 to something else.
This has the drawback that this "other" handle can't be used with the
standard GEMDOS calls, but maybe one can live with that...