1

all. I am reading the source code of linux kernel and find one line which I do not understand:

file: /net/sched/sch_generic.c

location: the definition of struct Qdisc:

struct Qdisc
{
    int             (*enqueue)(struct sk_buff *skb, struct Qdisc *dev);
    struct sk_buff *    (*dequeue)(struct Qdisc *dev);
    unsigned        flags;
#define TCQ_F_BUILTIN   1
#define TCQ_F_THROTTLED 2
#define TCQ_F_INGRESS   4
    int         padded;
    struct Qdisc_ops    *ops;
    u32         handle;
    u32         parent;
    atomic_t        refcnt;

....

what is the meaning of int (*enqueue)(struct sk_buff *skb, struct Qdisc *dev)

(first line)? Is enqueue a pointer?

JFMR
  • 23,265
  • 4
  • 52
  • 76
Jake
  • 31
  • 4
  • 1
    [`int (*enqueue)(struct sk_buff *skb, struct Qdisc *dev);`](https://cdecl.org/?q=int+%28*enqueue%29%28struct+sk_buff+*%2C+struct+Qdisc+*%29%3B) – Stargateur Dec 19 '17 at 12:34
  • If you don't know what a function pointer is, you shouldn't be reading the Linux kernel source. Arguably, _nobody_ should be reading the Linux kernel source. – Lundin Dec 19 '17 at 12:35

2 Answers2

3
int (*enqueue)(struct sk_buff *skb, struct Qdisc *dev)

enqueue is a pointer to a function that returns intand takes a pointer to struct sk_buff and a pointer to struct Qdisc.

JFMR
  • 23,265
  • 4
  • 52
  • 76
2

enqueue is a pointer to a function taking (struct sk_buff *skb, struct Qdisc *dev) and returning int.

Vittorio Romeo
  • 90,666
  • 33
  • 258
  • 416