twiddle.c revision 278602
1133754Sdfr/*-
2133754Sdfr * Copyright (c) 1986, 1988, 1991, 1993
3133754Sdfr *	The Regents of the University of California.  All rights reserved.
4133754Sdfr * (c) UNIX System Laboratories, Inc.
5133754Sdfr * All or some portions of this file are derived from material licensed
6133754Sdfr * to the University of California by American Telephone and Telegraph
7133754Sdfr * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8133754Sdfr * the permission of UNIX System Laboratories, Inc.
9133754Sdfr *
10133754Sdfr * Redistribution and use in source and binary forms, with or without
11133754Sdfr * modification, are permitted provided that the following conditions
12133754Sdfr * are met:
13133754Sdfr * 1. Redistributions of source code must retain the above copyright
14133754Sdfr *    notice, this list of conditions and the following disclaimer.
15133754Sdfr * 2. Redistributions in binary form must reproduce the above copyright
16133754Sdfr *    notice, this list of conditions and the following disclaimer in the
17133754Sdfr *    documentation and/or other materials provided with the distribution.
18133754Sdfr * 4. Neither the name of the University nor the names of its contributors
19133754Sdfr *    may be used to endorse or promote products derived from this software
20133754Sdfr *    without specific prior written permission.
21133754Sdfr *
22133754Sdfr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23133754Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24133754Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25133754Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26133754Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27133754Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28133754Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29133754Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30133754Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31133754Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32133754Sdfr * SUCH DAMAGE.
33150065Sstefanf *
34150065Sstefanf *	@(#)subr_prf.c	8.3 (Berkeley) 1/21/94
35133754Sdfr */
36133754Sdfr
37133754Sdfr#include <sys/cdefs.h>
38133754Sdfr__FBSDID("$FreeBSD: stable/10/lib/libstand/twiddle.c 278602 2015-02-11 22:55:24Z ian $");
39147673Speter
40133754Sdfr#include <sys/types.h>
41#include "stand.h"
42
43/* Extra functions from NetBSD standalone printf.c */
44
45static u_int globaldiv;
46
47void
48twiddle(u_int callerdiv)
49{
50	static u_int callercnt, globalcnt, pos;
51
52	callercnt++;
53	if (callerdiv > 1 && (callercnt % callerdiv) != 0)
54		return;
55
56	globalcnt++;
57	if (globaldiv > 1 && (globalcnt % globaldiv) != 0)
58		return;
59
60	putchar("|/-\\"[pos++ & 3]);
61	putchar('\b');
62}
63
64void
65twiddle_divisor(u_int gdiv)
66{
67
68	globaldiv = gdiv;
69}
70