Pure function for only some arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is it possible to declare an extern function pure for just some
arguments?

To clarify, let's assume I have a function

  extern int *func (int);

and I want it to be pure for func (0), func (1), func (3), but not for
func (2).  Is this possible?

Will something like this work?

static inline int *
func (int i)
{
  if (i == 2)
    {
      extern int *func_alias_1 (int) __asm__ ("func");
      return func_alias_1 (i);
    }
  else
    {
      extern int *func_alias_2 (int) __asm__ ("func") __attribute__ ((pure));
      return func_alias_2 (i);
    }
}

Thanks,
Florian




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux