anchor.diff:    (event-code (:pointer :uint))
     (modifier :int))
   
  -(defun push-events-to-hash-table (info first-event-code hash-table)
  -  (with-foreign-object (code :uint)
  -    (setf (mem-ref code :uint) first-event-code)
  -    (loop for event = (papi-code-to-event (mem-ref code :uint) info)
  -          do (setf (gethash (event-name event) hash-table) event)
  -          while (zerop (papi-enum-event code 0)))))
  -
  -(defun push-all-events-to-hash-table (hash-table)
  +(defconstant +papi-enum-event+ 0)
  +(defconstant +papi-enum-first+ 1)
  +(defconstant +papi-preset-enum-avail+ 2)
  +
  +(defun papi-events-to-hash-table ()
     (initialize-papi-if-necessary)
  -  (with-foreign-object (info 'event-info)
  -    (push-events-to-hash-table info +first-preset-event-code+ hash-table)
  -    (push-events-to-hash-table info +first-native-event-code+ hash-table)))
  -
  -(defvar *events* (make-hash-table))
  +  (with-foreign-objects ((info 'event-info)
  +                         (code :uint))
  +    (let ((hash-table (make-hash-table)))
  +      (flet ((push-events (mask enumerator)
  +               (setf (mem-ref code :uint) mask)
  +               (papi-enum-event code +papi-enum-first+)
  +               (loop for event = (papi-code-to-event (mem-ref code :uint) info)
  +                     do (setf (gethash (event-name event) hash-table) event)
  +                     while (ignore-errors
  +                             ;; Sometimes PAPI-ENUM-EVENT signals
  +                             ;; PAPI-EBUG, not sure why...
  +                             (zerop (papi-enum-event code enumerator))))))
  +        (push-events +papi-preset-mask+ +papi-preset-enum-avail+)
  +        (push-events +papi-native-mask+ +papi-enum-event+))
  +      hash-table)))
  +
  +(defvar *events* (papi-events-to-hash-table))
   
   (defmacro define-event (name description)
     `(setf (gethash ,name *events*)
  
positive.code:         nil
          string)))
  
  (defconstant +first-native-event-code+ #x40000000)
  (defconstant +first-preset-event-code+ #x80000000)
  
  (defun native-code-p (code)
    (<= +first-native-event-code+ code (1- +first-preset-event-code+)))
  
  (defun papi-code-to-event (code info)
    (when (zerop (papi-get-event-info code info))
  
negative.code: ;;;; -*- coding: utf-8; indent-tabs-mode: nil -*-
  
  (defpackage #:perfpiece
    (:use #:cl #:cffi)
    (:import-from #:alexandria
                  #:make-keyword #:switch #:when-let #:with-unique-names
                  #:symbolicate #:mean #:standard-deviation #:once-only))
  
  (in-package #:perfpiece)
  
  ;;;; Errors
  