lkml.org 
[lkml]   [2000]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: 2.4.0-test9: minixfs causing oopsen when out of inodes
Date
From
Daniel Phillips <news-innominate.list.linux.kernel@innominate.de> said:

[...]

> It would be nice if we could return a struct consisting of the error and
> result. I'm not sure if this is allowed in C now or not. It didn't
> work when I tried it with gcc: it seems to consider a struct-valued
> function to be a void-valued. Odd.

Odd? It works, has to: It's part of ANSI C. It is implemented by giving the
function a (hidden) pointer to a struct to be filled in, so this is much
slower than just stuffing a value into a register and returning. Plus it
won't work for syscalls with their arguments in registers, for obvious
reasons. Check this out (i686, RH 6.9.5 using kgcc and gcc give right
results):

#include <stdio.h>

struct s {
int error, result;
};

struct s f();

main()
{
struct s x = {0, 0};

x = f();
printf("error: %d, result: %d\n", x.error, x.result);
}

struct s f()
{
struct s xx;

xx.error = 1;
xx.result = 117;
return xx;
}
--
Horst von Brand vonbrand@sleipnir.valparaiso.cl
Casilla 9G, Vin~a del Mar, Chile +56 32 672616
\
 
 \ /
  Last update: 2005-03-22 12:39    [W:0.086 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site