X
Xiangliang Meng
Hi, all.
As far as I know, the speical arithmetic operator on void pointer is an
externsion in GNU CC. However, I could not find the relative topics in C99.
Would someone like to help me find them out?
in linux\mm\Slab.c,
typedef struct slab_s {
struct list_head list;
unsigned long colouroff;
void *s_mem; /* including colour offset */
unsigned int inuse; /* num of objs active in slab */
kmem_bufctl_t free;
} slab_t;
static inline void kmem_cache_init_objs (kmem_cache_t * cachep,
slab_t * slabp, unsigned long ctor_flags)
{
int i;
for (i = 0; i < cachep->num; i++) {
void* objp = slabp->s_mem+cachep->objsize*i; // it's one of the
externsions to the C Language Family in GNU CC
....
}
Arithmetic on void- and function-pointers
----------------------------------------------------------------------------
----
In GNU C, addition and subtraction operations are supported on pointers to
void and on pointers to functions. This is done by treating the size of a
void or of a function as 1.
A consequence of this is that sizeof is also allowed on void and on function
types, and returns 1. The option, ¡®-Wpointer-arith¡¯, requests a warning if
these extensions are used.
Thanks,
Best Regards,
Xiangliang Meng
As far as I know, the speical arithmetic operator on void pointer is an
externsion in GNU CC. However, I could not find the relative topics in C99.
Would someone like to help me find them out?
in linux\mm\Slab.c,
typedef struct slab_s {
struct list_head list;
unsigned long colouroff;
void *s_mem; /* including colour offset */
unsigned int inuse; /* num of objs active in slab */
kmem_bufctl_t free;
} slab_t;
static inline void kmem_cache_init_objs (kmem_cache_t * cachep,
slab_t * slabp, unsigned long ctor_flags)
{
int i;
for (i = 0; i < cachep->num; i++) {
void* objp = slabp->s_mem+cachep->objsize*i; // it's one of the
externsions to the C Language Family in GNU CC
....
}
Arithmetic on void- and function-pointers
----------------------------------------------------------------------------
----
In GNU C, addition and subtraction operations are supported on pointers to
void and on pointers to functions. This is done by treating the size of a
void or of a function as 1.
A consequence of this is that sizeof is also allowed on void and on function
types, and returns 1. The option, ¡®-Wpointer-arith¡¯, requests a warning if
these extensions are used.
Thanks,
Best Regards,
Xiangliang Meng