Upgrade to Pro — share decks privately, control downloads, hide ads and more …

C á Go Go

Avatar for ecin ecin
January 23, 2013

C á Go Go

Calling out to C libraries from within Go is simple and supported as part of the standard distribution. Let's look at an example that wraps a user-land Dtrace library (libusdt). Included are things to keep in mind when dealing with C code.

Avatar for ecin

ecin

January 23, 2013

Other Decks in Programming

Transcript

  1. Dtrace fmt.Printf() on steroids Can track function calls and meanin

    ful information about those calls (usually ar uments) Dtrace probes can be put anywhere in your code (i.e. can live in userland) To create a Dtrace probe, import a C header
  2. Dtrace Provider: has n probes, identified by two strin s:

    name and module Probe: has .Fire(), identified by two strin s: function and name; the parameters that .Fire() takes are defined when the probe is created
  3. c o http:// olan .or /cmd/c o/ Part of the

    standard Go distribution Enables the creation of Go packa es that call C code. Kinda ma ical.
  4. All functions and structs in the C header files are

    now accessible from the C packa e