1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms 5 * of the Common Development and Distribution License 6 * (the "License"). You may not use this file except 7 * in compliance with the License. 8 * 9 * You can obtain a copy of the license at 10 * src/OPENSOLARIS.LICENSE 11 * or http://www.opensolaris.org/os/licensing. 12 * See the License for the specific language governing 13 * permissions and limitations under the License. 14 * 15 * When distributing Covered Code, include this CDDL 16 * HEADER in each file and include the License file at 17 * usr/src/OPENSOLARIS.LICENSE. If applicable, 18 * add the following below this CDDL HEADER, with the 19 * fields enclosed by brackets "[]" replaced with your 20 * own identifying information: Portions Copyright [yyyy] 21 * [name of copyright owner] 22 * 23 * CDDL HEADER END 24 */ 25 26/* 27 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31/* 32 * benchmark fcntl getfl 33 */ 34 35#include <unistd.h> 36#include <stdlib.h> 37#include <stdio.h> 38#include <sys/types.h> 39#include <fcntl.h> 40 41#include "libmicro.h" 42 43#define DEFF "/dev/null" 44 45static char *optf = DEFF; 46static int fd = -1; 47 48int 49benchmark_init() 50{ 51 (void) sprintf(lm_optstr, "f:"); 52 lm_tsdsize = 0; 53 54 (void) sprintf(lm_usage, 55 " [-f file-to-fcntl (default %s)]\n" 56 "notes: measures fcntl()\n", 57 DEFF); 58 59 return (0); 60} 61 62int 63benchmark_optswitch(int opt, char *optarg) 64{ 65 switch (opt) { 66 case 'f': 67 optf = optarg; 68 break; 69 default: 70 return (-1); 71 } 72 return (0); 73} 74 75int 76benchmark_initrun() 77{ 78 if ((fd = open(optf, O_RDONLY)) == -1) { 79 perror("open"); 80 exit(1); 81 } 82 return (0); 83} 84 85/*ARGSUSED*/ 86int 87benchmark(void *tsd, result_t *res) 88{ 89 int i; 90 int flags; 91 92 for (i = 0; i < lm_optB; i++) { 93 if (fcntl(fd, F_GETFL, &flags) == -1) 94 res->re_errors++; 95 } 96 res->re_count = i; 97 98 return (0); 99} 100