4 * Implementation of a MinGW.org specific helper routine, to manipulate
5 * supplementary output format control flags other than those specified
6 * for the Microsoft output format control API.
10 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
11 * Copyright (C) 2015, MinGW.org Project.
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
21 * The above copyright notice, this permission notice, and the following
22 * disclaimer shall be included in all copies or substantial portions of
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
31 * DEALINGS IN THE SOFTWARE.
36 /* MinGW uses this public symbol to represent both Microsoft's exponent
37 * digit format flag, and supplementary MinGW.org specific flags.
39 extern unsigned int __mingw_output_format_flags;
41 /* The MinGW.org specific output format flag management API function.
42 * This provides both get and set capabilities for the MinGW specified
43 * flags; it has no effect on the Microsoft specified flags; use their
44 * _get_output_format() and _set_output_format() API functions when it
45 * is desired to manipulate them.
47 unsigned int _mingw_output_format_control
48 ( unsigned int flags_to_keep, unsigned int flags_to_set )
50 /* Return value is always based on current flag state.
52 unsigned int retval = __mingw_output_format_flags;
54 /* Adjust flags as specified by the mask of flags to keep,
55 * and add in any extra flags to set; always keep the state
56 * of the Microsoft specified flag bits, and decline to set
57 * them to any new state.
59 __mingw_output_format_flags &= flags_to_keep | _EXPONENT_DIGIT_MASK;
60 __mingw_output_format_flags |= flags_to_set & ~_EXPONENT_DIGIT_MASK;
62 /* Finally, exclude the Microsoft specified bits from the
63 * state to be returned, and return the original state of
64 * the MinGW specified bits.
66 return retval & ~_EXPONENT_DIGIT_MASK;
69 /* $RCSfile$: end of file */