   "
   ([kernel x & values]
    (if (integer? x)
-     (loop [i x values values]
+     (loop [i (long x) values values]
        (if-let [val (first values)]
          (do (set-arg! kernel i val)
              (recur (inc i) (next values)))

  ([queue cl host blocking offset ^objects wait-events event]
   (with-check
     (CL/clEnqueueWriteBuffer queue (cl-mem cl) blocking offset
                              (min (size cl) (size host)) (ptr host)
                              (if wait-events (alength wait-events) 0)
                              wait-events event)
     queue))

  [queue cl blocking offset req-size flags ^objects wait-events event]
  (let [err (int-array 1)
        res (CL/clEnqueueMapBuffer queue (cl-mem cl) blocking flags offset
                                   (min (long req-size) (- (long (size cl)) (long offset)))
                                   (if wait-events (alength wait-events) 0)
                                   wait-events event err)]
    (with-check-arr err (.order res (ByteOrder/nativeOrder)))))
