On Sat, 6 Jun 2009, Andy Walls wrote: > +Alternatively, you can create the unsigned short array dynamically: > + > +struct v4l2_subdev *sd = v4l2_i2c_subdev(v4l2_dev, adapter, > + "module_foo", "chipid", 0, V4L2_I2C_ADDRS(0x10, 0x12)); > > Strictly speaking, that's not "dynamically" in the sense of the > generated machine code - everything is going to come from the local > stack and the initialized data space. The compiler will probably be > smart enough to generate an unnamed array in the initialized data space > anyway, avoiding the use of local stack for the array. :) No such luck, gcc will create an array on the stack and then initialize it with a series of move word instructions. It isn't even smart enough to turn: movw $1, (%esp) movw $2, 2(%esp) movw $3, 4(%esp) movw $-1, 6(%esp) into: movl $0x00020001, (%esp) movl $0xffff0003, 4(%esp) Now, if you use a different syntax, and change this: #define V4L2_I2C_ADDRS(addr, addrs...) \ ((const unsigned short []){ addr, ## addrs, -1 }) #define bar(addrs...) _bar(V4L2_I2C_ADDRS(addrs)) into this: #define bar(addr, addrs...) \ ({ const unsigned short _a[] = {addr, ## addrs, -1}; _bar(_a); }) If all the values are constants, then for the latter method only gcc will will create an array in the initialized data segment and use that. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html