xref: /freebsd/share/man/man3/Q_SIGNSHFT.3 (revision 7899f917b1c0ea178f1d2be0cfb452086d079d23)
1.\"
2.\" Copyright (c) 2018 Netflix, Inc.
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions, and the following disclaimer,
10.\"    without modification, immediately at the beginning of the file.
11.\" 2. The name of the author may not be used to endorse or promote products
12.\"    derived from this software without specific prior written permission.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.Dd July 8, 2018
27.Dt Q_SIGNSHFT 3
28.Os
29.Sh NAME
30.Nm Q_SIGNSHFT ,
31.Nm Q_SSIGN ,
32.Nm Q_CRAWMASK ,
33.Nm Q_SRAWMASK ,
34.Nm Q_GCRAW ,
35.Nm Q_GCVAL ,
36.Nm Q_SCVAL
37.Nd fixed-point math functions which manipulate the control/sign data bits
38.Sh SYNOPSIS
39.In sys/qmath.h
40.Ft uint32_t
41.Fn Q_SIGNSHFT "QTYPE q"
42.Ft QTYPE
43.Fn Q_SSIGN "QTYPE q" "bool isneg"
44.Ft ITYPE
45.Fn Q_CRAWMASK "QTYPE q"
46.Ft ITYPE
47.Fn Q_SRAWMASK "QTYPE q"
48.Ft ITYPE
49.Fn Q_GCRAW "QTYPE q"
50.Ft ITYPE
51.Fn Q_GCVAL "QTYPE q"
52.Ft QTYPE
53.Fn Q_SCVAL "QTYPE q" "ITYPE cv"
54.Sh DESCRIPTION
55.Fn Q_SIGNSHFT
56gets the bit position of
57.Fa q Ap s
58sign bit relative to bit zero.
59.Pp
60.Fn Q_SSIGN
61sets the sign bit of
62.Fa q
63based on the boolean
64.Fa isneg .
65.Pp
66.Fn Q_CRAWMASK
67and
68.Fn Q_SRAWMASK
69return
70.Fa q Ns -specific
71bit masks for
72.Fa q Ap s
73control bits and sign bit respectively.
74.Pp
75.Fn Q_GCRAW
76and
77.Fn Q_GCVAL
78get the raw masked control bits and value of
79.Fa q Ap s
80control bits respectively.
81.Pp
82.Fn Q_SCVAL
83sets
84.Fa q Ap s
85control bits to the value
86.Fa cv .
87.Pp
88All of those functions operate on
89the following data types:
90.Vt s8q_t ,
91.Vt u8q_t ,
92.Vt s16q_t ,
93.Vt u16q_t ,
94.Vt s32q_t ,
95.Vt u32q_t ,
96.Vt s64q_t ,
97and
98.Vt u64q_t ,
99which are referred to generically as
100.Fa QTYPE .
101The
102.Fa ITYPE
103refers to the
104.Xr stdint 7
105integer types.
106.Pp
107For more details, see
108.Xr qmath 3 .
109.Sh RETURN VALUES
110.Fn Q_SIGNSHFT
111returns the sign bit's position as an integer.
112.Pp
113.Fn Q_SSIGN
114returns the value of
115.Fa q
116post change.
117.Pp
118.Fn Q_CRAWMASK ,
119.Fn Q_SRAWMASK ,
120.Fn Q_GCRAW
121and
122.Fn Q_GCVAL
123return their respective values as integers of the same underlying ITYPE as
124.Fa q .
125.Pp
126.Fn Q_SCVAL
127returns the value of
128.Fa q
129post change.
130.Sh SEE ALSO
131.Xr errno 2 ,
132.Xr qmath 3 ,
133.Xr stdint 7
134.Sh HISTORY
135The
136.Xr qmath 3
137functions first appeared in
138.Fx 13.0 .
139.Sh AUTHORS
140.An -nosplit
141The
142.Xr qmath 3
143functions and this manual page were written by
144.An Lawrence Stewart Aq Mt lstewart@FreeBSD.org
145and sponsored by Netflix, Inc.
146