[Libclc-developers] Re: libclc questions
Status: Planning
Brought to you by:
augestad
|
From: Michael B.A. <mb...@io...> - 2003-03-17 10:23:25
|
I subscribed to the libclc-developers list and sent this message there. On Sun, 16 Mar 2003 22:18:58 +0100 Bj=F8rn Augestad <bo...@me...> wrote: > >>>Why does libclc define it's own error codes? What libclc function could > >>>possibly return CLC_ENODEV? If a platform does not have ISO C and POSIX > >>>error codes available there is probably a reason for it. > >> > >>As an example, malloc() doesn't have to set errno to ENOMEM. If we have= =20 > >>a function which can fail for 2 or more reasons and one of them is "Out= =20 > >>of memory", we must set errno to ENOMEM and CLC_EFOO. Since we cannot=20 > >>rely on the precense of ENOMEM, we need to use CLC_ENOMEM. We try to=20 > >=20 > >=20 > > A malloc() implementation with no ENOMEM? Interesting! Which platform > > is that? >=20 > The DeathStation 9000 :-) > Seriously, malloc is not, prior to e.g. Unix98, required to set errno to= =20 > ENOMEM. This means that we cannot assume that errno contains a=20 > reasonable value if malloc() fails. We must therefore set it ourselves.=20 > Since we don't know about POSIX (we're pure ANSI C, remember) we must=20 > set it to CLC_ENOMEM. Oh well... But the standards do not say that malloc will not set errno to ENOMEM and every malloc ever written _does_ use ENOMEM. Same goes for probably every other ISO function you'll use. You're introducing a technically unncessary level of indirection that contributes to an overall non-standard experience for the sake of a standard. Why are you going to make 99.9999% of the users deal with two different namespaces of error codes for some imaginary platform that doesn't exist? Following the letter of the law for this is just being pedantic. Mike --=20 A program should be written to model the concepts of the task it performs rather than the physical world or a process because this maximizes the potential for it to be applied to tasks that are conceptually similar and, more important, to tasks that have not yet been conceived.=20 |