1 /*
2 Copyright (C) 2016-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4maau32.ctr
12 */
13 
14 #ifndef DK4MAAU32_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4MAAU32_H_INCLUDED 1
17 
18 
19 /**	@file	dk4maau32.h	Operations on uint32_t data.
20 
21 	CRT on Windows: Optional.
22 */
23 
24 
25 #ifndef DK4CONF_H_INCLUDED
26 #if DK4_BUILDING_DKTOOLS4
27 #include "dk4conf.h"
28 #else
29 #include <dktools-4/dk4conf.h>
30 #endif
31 #endif
32 
33 #ifndef DK4TYPES_H_INCLUDED
34 #if DK4_BUILDING_DKTOOLS4
35 #include <libdk4base/dk4types.h>
36 #else
37 #include <dktools-4/dk4types.h>
38 #endif
39 #endif
40 
41 #ifndef DK4ERROR_H_INCLUDED
42 #if DK4_BUILDING_DKTOOLS4
43 #include <libdk4base/dk4error.h>
44 #else
45 #include <dktools-4/dk4error.h>
46 #endif
47 #endif
48 
49 #if DK4_HAVE_STDLIB_H
50 #ifndef	DK4_STDLIB_H_INCLUDED
51 #include <stdlib.h>
52 #define	DK4_STDLIB_H_INCLUDED 1
53 #endif
54 #endif
55 
56 #if DK4_HAVE_SYS_TYPES_H
57 #ifndef	DK4_SYS_TYPES_H_INCLUDED
58 #include <sys/types.h>
59 #define	DK4_SYS_TYPES_H_INCLUDED 1
60 #endif
61 #endif
62 
63 #if DK4_HAVE_STDINT_H
64 #ifndef	DK4_STDINT_H_INCLUDED
65 #include <stdint.h>
66 #define	DK4_STDINT_H_INCLUDED 1
67 #endif
68 #endif
69 
70 #ifndef	UINT32_MAX
71 #define	UINT32_MAX	((uint32_t)4294967295UL)
72 #endif
73 
74 #ifdef	__cplusplus
75 extern "C" {
76 #endif
77 
78 /**	Addition of uint32_t.
79 	@param	a	Left operand.
80 	@param	b	Right operand.
81 	@param	erp	Error report, may be NULL.
82 	@return	Operation result.
83 
84 	Error codes:
85 	- DK4_E_INVALID_ARGUMENTS<br>
86 	  if a or b is out of range
87 	- DK4_E_MATH_OVERFLOW<br>
88 	  if a mathematical overfow occured.
89 */
90 uint32_t
91 dk4ma_uint32_t_add(uint32_t a, uint32_t b, dk4_er_t *erp);
92 
93 /**	Substraction of uint32_t.
94 	@param	a	Left operand.
95 	@param	b	Right operand.
96 	@param	erp	Error report, may be NULL.
97 	@return	Operation result.
98 
99 	Error codes:
100 	- DK4_E_INVALID_ARGUMENTS<br>
101 	  if a or b is out of range
102 	- DK4_E_MATH_OVERFLOW<br>
103 	  if a mathematical overfow occured.
104 */
105 uint32_t
106 dk4ma_uint32_t_sub(uint32_t a, uint32_t b, dk4_er_t *erp);
107 
108 /**	Multiplication of uint32_t.
109 	@param	a	Left operand.
110 	@param	b	Right operand.
111 	@param	erp	Error report, may be NULL.
112 	@return	Operation result.
113 
114 	Error codes:
115 	- DK4_E_INVALID_ARGUMENTS<br>
116 	  if a or b is out of range
117 	- DK4_E_MATH_OVERFLOW<br>
118 	  if a mathematical overfow occured.
119 */
120 uint32_t
121 dk4ma_uint32_t_mul(uint32_t a, uint32_t b, dk4_er_t *erp);
122 
123 /**	Division of uint32_t.
124 	@param	a	Left operand.
125 	@param	b	Right operand.
126 	@param	erp	Error report, may be NULL.
127 	@return	Operation result.
128 
129 	Error codes:
130 	- DK4_E_INVALID_ARGUMENTS<br>
131 	  if a or b is out of range
132 	- DK4_E_MATH_OVERFLOW<br>
133 	  if a mathematical overfow occured,
134 	- DK4_E_MATH_DIVZERO<br>
135 	  if b is 0.
136 */
137 uint32_t
138 dk4ma_uint32_t_div(uint32_t a, uint32_t b, dk4_er_t *erp);
139 
140 /**	Convert dk4_um_t value to uint32_t.
141 	@param	u	Value to convert.
142 	@param	erp	Error report, may be NULL.
143 	@return	Conversion result.
144 
145 	Error codes: DK4_E_MATH_OVERFLOW.
146 */
147 uint32_t
148 dk4ma_uint32_from(dk4_um_t u, dk4_er_t *erp);
149 
150 /**	Convert double to signed char.
151 	@param	d	Value to convert.
152 	@param	erp	Error report, may be NULL.
153 	@return	Conversion result.
154 
155 	Error codes: DK4_E_OVERFLOW.
156 */
157 uint32_t
158 dk4ma_uint32_from_double(double d, dk4_er_t *erp);
159 
160 #ifdef	__cplusplus
161 }
162 #endif
163 
164 
165 
166 #endif
167