[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 1/3] livepach: Add .livepatch.hooks functions and test-case
>>> On 11.08.16 at 12:56, <ian.jackson@xxxxxxxxxxxxx> wrote: > Jan Beulich writes ("Re: [Xen-devel] [PATCH v2 1/3] livepach: Add > .livepatch.hooks functions and test-case"): >> On 10.08.16 at 11:46, <JBeulich@xxxxxxxx> wrote: >> > Odd. I've tried this simple example: >> > >> > typedef int fn_t(void); > ... >> > const fn_t**cfn; > > Ie, > const int **cfn(void); > >> > for(i = 0; !rc && i < ps->n; ++i) >> > rc = ps->cfn[i](); > > From `(gcc-4)Function Attributes': > > `const' > Many functions do not examine any values except their arguments, > and have no effects except the return value. Basically this is > just slightly more strict class than the `pure' attribute below, > since function is not allowed to read global memory. > > Note that a function that has pointer arguments and examines the > data pointed to must _not_ be declared `const'. Likewise, a > function that calls a non-`const' function usually must not be > `const'. It does not make sense for a `const' function to return > `void'. > > The attribute `const' is not implemented in GCC versions earlier > than 2.5. An alternative way to declare that a function has no > side effects, which works in the current version and in some older > versions, is as follows: > > typedef int intfn (); > > extern const intfn square; > > This approach does not work in GNU C++ from 2.6.0 on, since the > language specifies that the `const' must be attached to the return > value. > > Ie, gcc has always treated a function marked const as having no > unexpected inputs and no side effects. Oh, I've always assumed that would be __attribute__((const)) only, but what you quote above proves me wrong. Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |