xref: /freebsd/share/man/man3/Q_SIGNSHFT.3 (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
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.\" $FreeBSD$
27.\"
28.Dd July 8, 2018
29.Dt Q_SIGNSHFT 3
30.Os
31.Sh NAME
32.Nm Q_SIGNSHFT ,
33.Nm Q_SSIGN ,
34.Nm Q_CRAWMASK ,
35.Nm Q_SRAWMASK ,
36.Nm Q_GCRAW ,
37.Nm Q_GCVAL ,
38.Nm Q_SCVAL
39.Nd fixed-point math functions which manipulate the control/sign data bits
40.Sh SYNOPSIS
41.In sys/qmath.h
42.Ft uint32_t
43.Fn Q_SIGNSHFT "QTYPE q"
44.Ft QTYPE
45.Fn Q_SSIGN "QTYPE q" "bool isneg"
46.Ft ITYPE
47.Fn Q_CRAWMASK "QTYPE q"
48.Ft ITYPE
49.Fn Q_SRAWMASK "QTYPE q"
50.Ft ITYPE
51.Fn Q_GCRAW "QTYPE q"
52.Ft ITYPE
53.Fn Q_GCVAL "QTYPE q"
54.Ft QTYPE
55.Fn Q_SCVAL "QTYPE q" "ITYPE cv"
56.Sh DESCRIPTION
57.Fn Q_SIGNSHFT
58gets the bit position of
59.Fa q Ap s
60sign bit relative to bit zero.
61.Pp
62.Fn Q_SSIGN
63sets the sign bit of
64.Fa q
65based on the boolean
66.Fa isneg .
67.Pp
68.Fn Q_CRAWMASK
69and
70.Fn Q_SRAWMASK
71return
72.Fa q Ns -specific
73bit masks for
74.Fa q Ap s
75control bits and sign bit respectively.
76.Pp
77.Fn Q_GCRAW
78and
79.Fn Q_GCVAL
80get the raw masked control bits and value of
81.Fa q Ap s
82control bits respectively.
83.Pp
84.Fn Q_SCVAL
85sets
86.Fa q Ap s
87control bits to the value
88.Fa cv .
89.Pp
90All of those functions operate on
91the following data types:
92.Vt s8q_t ,
93.Vt u8q_t ,
94.Vt s16q_t ,
95.Vt u16q_t ,
96.Vt s32q_t ,
97.Vt u32q_t ,
98.Vt s64q_t ,
99and
100.Vt u64q_t ,
101which are referred to generically as
102.Fa QTYPE .
103The
104.Fa ITYPE
105refers to the
106.Xr stdint 7
107integer types.
108.Pp
109For more details, see
110.Xr qmath 3 .
111.Sh RETURN VALUES
112.Fn Q_SIGNSHFT
113returns the sign bit's position as an integer.
114.Pp
115.Fn Q_SSIGN
116returns the value of
117.Fa q
118post change.
119.Pp
120.Fn Q_CRAWMASK ,
121.Fn Q_SRAWMASK ,
122.Fn Q_GCRAW
123and
124.Fn Q_GCVAL
125return their respective values as integers of the same underlying ITYPE as
126.Fa q .
127.Pp
128.Fn Q_SCVAL
129returns the value of
130.Fa q
131post change.
132.Sh SEE ALSO
133.Xr errno 2 ,
134.Xr qmath 3 ,
135.Xr stdint 7
136.Sh HISTORY
137The
138.Xr qmath 3
139functions first appeared in
140.Fx 13.0 .
141.Sh AUTHORS
142.An -nosplit
143The
144.Xr qmath 3
145functions and this manual page were written by
146.An Lawrence Stewart Aq Mt lstewart@FreeBSD.org
147and sponsored by Netflix, Inc.
148