-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Less compiler warning, more dtrace, set_dur does rollback on failure,…
… added license header
- Loading branch information
Showing
6 changed files
with
118 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,77 @@ | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include "plan_probes.h" | ||
|
||
/* | ||
* CDDL HEADER START | ||
* | ||
* The contents of this file are subject to the terms of the Common Development | ||
* and Distribution License (the "License"). You may not use this file except | ||
* in compliance with the License. | ||
* | ||
* You can obtain a copy of the license at src/PLAN.LICENSE. See the License | ||
* for the specific language governing permissions and limitations under the | ||
* License. | ||
* | ||
* When distributing Covered Code, include this CDDL HEADER in each file and | ||
* include the License file at src/PLAN.LICENSE. If applicable, add the | ||
* following below this CDDL HEADER, with the fields enclosed by brackets "[]" | ||
* replaced with your own identifying information: | ||
* Portions Copyright [yyyy] [name of copyright owner] | ||
* | ||
* CDDL HEADER END | ||
*/ | ||
|
||
void atomic_read(int fd, void *buf, size_t sz) | ||
/* | ||
* Copyright (c) 2011, Nick Zivkovic. All rights reserved. | ||
*/ | ||
|
||
|
||
/* | ||
* My build of illumos doesn't have the new "dynamic tracemem" feature, so I | ||
* have use this probing method below, to see what is about to be | ||
* read/written. | ||
*/ | ||
|
||
void | ||
atomic_read(int fd, void *buf, size_t sz) | ||
{ | ||
int total_read = 0; | ||
int red = 0; | ||
int probe_ix = 0; | ||
int probe_sz = (sz/8) ? (sz/8) : 1; | ||
probe_sz += (sz%8) ? 1 : 0; | ||
|
||
while (PLAN_ATOMIC_READ_ENABLED() && probe_ix < probe_sz && buf && sz) { | ||
PLAN_ATOMIC_READ(fd, ((uint64_t*)buf)[probe_ix], sz); | ||
probe_ix++; | ||
} | ||
|
||
do { | ||
red = read(fd, buf, sz); | ||
red = read(fd, buf, (sz-red)); | ||
total_read += red; | ||
} while (total_read < sz && red != -1); | ||
} | ||
|
||
|
||
void atomic_write(int fd, void *buf, size_t sz) | ||
void | ||
atomic_write(int fd, void *buf, size_t sz) | ||
{ | ||
|
||
int total_written = 0; | ||
int written = 0; | ||
int probe_ix = 0; | ||
int probe_sz = (sz/8) ? (sz/8) : 1; | ||
probe_sz += (sz%8) ? 1 : 0; | ||
|
||
while (PLAN_ATOMIC_WRITE_ENABLED() && probe_ix < probe_sz && buf | ||
&& sz) { | ||
PLAN_ATOMIC_WRITE(fd, ((uint64_t*)buf)[probe_ix], sz); | ||
probe_ix++; | ||
} | ||
|
||
do { | ||
written = write(fd, buf, sz); | ||
written = write(fd, buf, (sz-written)); | ||
total_written += written; | ||
} while (total_written < sz && written != -1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters