The software described in this documentation is either in Extended Support or Sustaining Support. See for more information.
Oracle recommends that you upgrade the software described by this documentation as soon as possible.

11.6.6 Pointers and External Variables

The implementation of pointers in the D language gives you the ability to create and manipulate the memory addresses of data objects in the operating system kernel, and to store the contents of those data objects in variables and associative arrays. The syntax of D pointers is the same as the syntax of pointers in ANSI-C. For example, the following statement declares a D global variable named p that is a pointer to an integer.

int *p;

This declaration means that p itself is a 64-bit integer whose value is the address in memory of another integer.

If you want to create a pointer to a data object inside the kernel, you can compute its address by using the & reference operator. For example, the kernel source code declares an unsigned long max_pfn variable. You can access the value of such an external variable in the D language by prefixing it with the ` (backquote) scope operator:

value = `max_pfn;

If more than one kernel module declares a variable with the same name, prefix the scoped external variable with the name of the module. For example, foo`bar would refer to the address of the bar() function provided by the module foo.

You can extract the address of an external variable by applying the & operator and store it as a pointer:

p = &`max_pfn;

You can use the * dereference operator to refer to the object that a pointer addresses:

value = *p;

You cannot apply the & operator to DTrace objects such as associative arrays, built-in functions, and variables. If you create composite structures, it is possible to construct expressions that retrieve the kernel addresses of DTrace objects. However, DTrace does not guarantee to preserve the addresses of such objects across probe firings.

You cannot use the * dereference operator on the left-hand side of an assignment expression. You may only assign values directly to D variables by name or by applying the array index operator [] to a scalar array or an associative array.

You cannot use pointers to perform indirect function calls. You may only call DTrace functions directly by name.