]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/SafeIntLib.h
MdePkg SafeIntLib: Update API definition to use the same output name
[mirror_edk2.git] / MdePkg / Include / Library / SafeIntLib.h
1 /** @file
2 This library provides helper functions to prevent integer overflow during
3 type conversion, addition, subtraction, and multiplication.
4
5 Copyright (c) 2017, Microsoft Corporation
6
7 All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 **/
28 #ifndef __INT_SAFE_LIB_H__
29 #define __INT_SAFE_LIB_H__
30
31 //
32 // It is common for -1 to be used as an error value
33 //
34 #define INT8_ERROR ((INT8) -1)
35 #define UINT8_ERROR MAX_UINT8
36 #define CHAR8_ERROR ((CHAR8)(MAX_INT8))
37 #define INT16_ERROR ((INT16) -1)
38 #define UINT16_ERROR MAX_UINT16
39 #define CHAR16_ERROR MAX_UINT16
40 #define INT32_ERROR ((INT32) -1)
41 #define UINT32_ERROR MAX_UINT32
42 #define INT64_ERROR ((INT64) -1)
43 #define UINT64_ERROR MAX_UINT64
44 #define INTN_ERROR ((INTN) -1)
45 #define UINTN_ERROR MAX_UINTN
46
47 //
48 // CHAR16 is defined to be the same as UINT16, so for CHAR16
49 // operations redirect to the UINT16 ones:
50 //
51 #define SafeInt8ToChar16 SafeInt8ToUint16
52 #define SafeInt16ToChar16 SafeInt16ToUint16
53 #define SafeInt32ToChar16 SafeInt32ToUint16
54 #define SafeUint32ToChar16 SafeUint32ToUint16
55 #define SafeInt64ToChar16 SafeInt64ToUint16
56 #define SafeUint64ToChar16 SafeUint64ToUint16
57 #define SafeIntnToChar16 SafeIntnToUint16
58 #define SafeUintnToChar16 SafeUintnToUint16
59
60 #define SafeChar16ToInt8 SafeUint16ToInt8
61 #define SafeChar16ToUint8 SafeUint16ToUint8
62 #define SafeChar16ToChar8 SafeUint16ToChar8
63 #define SafeChar16ToInt16 SafeUint16ToInt16
64
65 #define SafeChar16Mult SafeUint16Mult
66 #define SafeChar16Sub SafeUint16Sub
67 #define SafeChar16Add SafeUint16Add
68
69 //
70 // Conversion functions
71 //
72 // There are three reasons for having conversion functions:
73 //
74 // 1. We are converting from a signed type to an unsigned type of the same
75 // size, or vice-versa.
76 //
77 // 2. We are converting to a smaller type, and we could therefore possibly
78 // overflow.
79 //
80 // 3. We are converting to a bigger type, and we are signed and the type we are
81 // converting to is unsigned.
82 //
83
84 /**
85 INT8 -> UINT8 conversion
86
87 Converts the value specified by Operand to a value specified by Result type
88 and stores the converted value into the caller allocated output buffer
89 specified by Result. The caller must pass in a Result buffer that is at
90 least as large as the Result type.
91
92 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
93
94 If the conversion results in an overflow or an underflow condition, then
95 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
96
97 @param[in] Operand Operand to be converted to new type
98 @param[out] Result Pointer to the result of conversion
99
100 @retval RETURN_SUCCESS Successful conversion
101 @retval RETURN_BUFFER_TOO_SMALL Overflow
102 @retval RETURN_INVALID_PARAMETER Result is NULL
103 **/
104 RETURN_STATUS
105 EFIAPI
106 SafeInt8ToUint8 (
107 IN INT8 Operand,
108 OUT UINT8 *Result
109 );
110
111 /**
112 INT8 -> CHAR8 conversion
113
114 Converts the value specified by Operand to a value specified by Result type
115 and stores the converted value into the caller allocated output buffer
116 specified by Result. The caller must pass in a Result buffer that is at
117 least as large as the Result type.
118
119 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
120
121 If the conversion results in an overflow or an underflow condition, then
122 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
123
124 @param[in] Operand Operand to be converted to new type
125 @param[out] Result Pointer to the result of conversion
126
127 @retval RETURN_SUCCESS Successful conversion
128 @retval RETURN_BUFFER_TOO_SMALL Overflow
129 @retval RETURN_INVALID_PARAMETER Result is NULL
130 **/
131 RETURN_STATUS
132 EFIAPI
133 SafeInt8ToChar8 (
134 IN INT8 Operand,
135 OUT CHAR8 *Result
136 );
137
138 /**
139 INT8 -> UINT16 conversion
140
141 Converts the value specified by Operand to a value specified by Result type
142 and stores the converted value into the caller allocated output buffer
143 specified by Result. The caller must pass in a Result buffer that is at
144 least as large as the Result type.
145
146 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
147
148 If the conversion results in an overflow or an underflow condition, then
149 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
150
151 @param[in] Operand Operand to be converted to new type
152 @param[out] Result Pointer to the result of conversion
153
154 @retval RETURN_SUCCESS Successful conversion
155 @retval RETURN_BUFFER_TOO_SMALL Overflow
156 @retval RETURN_INVALID_PARAMETER Result is NULL
157 **/
158 RETURN_STATUS
159 EFIAPI
160 SafeInt8ToUint16 (
161 IN INT8 Operand,
162 OUT UINT16 *Result
163 );
164
165 /**
166 INT8 -> UINT32 conversion
167
168 Converts the value specified by Operand to a value specified by Result type
169 and stores the converted value into the caller allocated output buffer
170 specified by Result. The caller must pass in a Result buffer that is at
171 least as large as the Result type.
172
173 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
174
175 If the conversion results in an overflow or an underflow condition, then
176 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
177
178 @param[in] Operand Operand to be converted to new type
179 @param[out] Result Pointer to the result of conversion
180
181 @retval RETURN_SUCCESS Successful conversion
182 @retval RETURN_BUFFER_TOO_SMALL Overflow
183 @retval RETURN_INVALID_PARAMETER Result is NULL
184 **/
185 RETURN_STATUS
186 EFIAPI
187 SafeInt8ToUint32 (
188 IN INT8 Operand,
189 OUT UINT32 *Result
190 );
191
192 /**
193 INT8 -> UINTN conversion
194
195 Converts the value specified by Operand to a value specified by Result type
196 and stores the converted value into the caller allocated output buffer
197 specified by Result. The caller must pass in a Result buffer that is at
198 least as large as the Result type.
199
200 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
201
202 If the conversion results in an overflow or an underflow condition, then
203 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
204
205 @param[in] Operand Operand to be converted to new type
206 @param[out] Result Pointer to the result of conversion
207
208 @retval RETURN_SUCCESS Successful conversion
209 @retval RETURN_BUFFER_TOO_SMALL Overflow
210 @retval RETURN_INVALID_PARAMETER Result is NULL
211 **/
212 RETURN_STATUS
213 EFIAPI
214 SafeInt8ToUintn (
215 IN INT8 Operand,
216 OUT UINTN *Result
217 );
218
219 /**
220 INT8 -> UINT64 conversion
221
222 Converts the value specified by Operand to a value specified by Result type
223 and stores the converted value into the caller allocated output buffer
224 specified by Result. The caller must pass in a Result buffer that is at
225 least as large as the Result type.
226
227 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
228
229 If the conversion results in an overflow or an underflow condition, then
230 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
231
232 @param[in] Operand Operand to be converted to new type
233 @param[out] Result Pointer to the result of conversion
234
235 @retval RETURN_SUCCESS Successful conversion
236 @retval RETURN_BUFFER_TOO_SMALL Overflow
237 @retval RETURN_INVALID_PARAMETER Result is NULL
238 **/
239 RETURN_STATUS
240 EFIAPI
241 SafeInt8ToUint64 (
242 IN INT8 Operand,
243 OUT UINT64 *Result
244 );
245
246 /**
247 UINT8 -> INT8 conversion
248
249 Converts the value specified by Operand to a value specified by Result type
250 and stores the converted value into the caller allocated output buffer
251 specified by Result. The caller must pass in a Result buffer that is at
252 least as large as the Result type.
253
254 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
255
256 If the conversion results in an overflow or an underflow condition, then
257 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
258
259 @param[in] Operand Operand to be converted to new type
260 @param[out] Result Pointer to the result of conversion
261
262 @retval RETURN_SUCCESS Successful conversion
263 @retval RETURN_BUFFER_TOO_SMALL Overflow
264 @retval RETURN_INVALID_PARAMETER Result is NULL
265 **/
266 RETURN_STATUS
267 EFIAPI
268 SafeUint8ToInt8 (
269 IN UINT8 Operand,
270 OUT INT8 *Result
271 );
272
273 /**
274 UINT8 -> CHAR8 conversion
275
276 Converts the value specified by Operand to a value specified by Result type
277 and stores the converted value into the caller allocated output buffer
278 specified by Result. The caller must pass in a Result buffer that is at
279 least as large as the Result type.
280
281 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
282
283 If the conversion results in an overflow or an underflow condition, then
284 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
285
286 @param[in] Operand Operand to be converted to new type
287 @param[out] Result Pointer to the result of conversion
288
289 @retval RETURN_SUCCESS Successful conversion
290 @retval RETURN_BUFFER_TOO_SMALL Overflow
291 @retval RETURN_INVALID_PARAMETER Result is NULL
292 **/
293 RETURN_STATUS
294 EFIAPI
295 SafeUint8ToChar8 (
296 IN UINT8 Operand,
297 OUT CHAR8 *Result
298 );
299
300 /**
301 INT16 -> INT8 conversion
302
303 Converts the value specified by Operand to a value specified by Result type
304 and stores the converted value into the caller allocated output buffer
305 specified by Result. The caller must pass in a Result buffer that is at
306 least as large as the Result type.
307
308 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
309
310 If the conversion results in an overflow or an underflow condition, then
311 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
312
313 @param[in] Operand Operand to be converted to new type
314 @param[out] Result Pointer to the result of conversion
315
316 @retval RETURN_SUCCESS Successful conversion
317 @retval RETURN_BUFFER_TOO_SMALL Overflow
318 @retval RETURN_INVALID_PARAMETER Result is NULL
319 **/
320 RETURN_STATUS
321 EFIAPI
322 SafeInt16ToInt8 (
323 IN INT16 Operand,
324 OUT INT8 *Result
325 );
326
327 /**
328 INT16 -> CHAR8 conversion
329
330 Converts the value specified by Operand to a value specified by Result type
331 and stores the converted value into the caller allocated output buffer
332 specified by Result. The caller must pass in a Result buffer that is at
333 least as large as the Result type.
334
335 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
336
337 If the conversion results in an overflow or an underflow condition, then
338 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
339
340 @param[in] Operand Operand to be converted to new type
341 @param[out] Result Pointer to the result of conversion
342
343 @retval RETURN_SUCCESS Successful conversion
344 @retval RETURN_BUFFER_TOO_SMALL Overflow
345 @retval RETURN_INVALID_PARAMETER Result is NULL
346 **/
347 RETURN_STATUS
348 EFIAPI
349 SafeInt16ToChar8 (
350 IN INT16 Operand,
351 OUT CHAR8 *Result
352 );
353
354 /**
355 INT16 -> UINT8 conversion
356
357 Converts the value specified by Operand to a value specified by Result type
358 and stores the converted value into the caller allocated output buffer
359 specified by Result. The caller must pass in a Result buffer that is at
360 least as large as the Result type.
361
362 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
363
364 If the conversion results in an overflow or an underflow condition, then
365 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
366
367 @param[in] Operand Operand to be converted to new type
368 @param[out] Result Pointer to the result of conversion
369
370 @retval RETURN_SUCCESS Successful conversion
371 @retval RETURN_BUFFER_TOO_SMALL Overflow
372 @retval RETURN_INVALID_PARAMETER Result is NULL
373 **/
374 RETURN_STATUS
375 EFIAPI
376 SafeInt16ToUint8 (
377 IN INT16 Operand,
378 OUT UINT8 *Result
379 );
380
381 /**
382 INT16 -> UINT16 conversion
383
384 Converts the value specified by Operand to a value specified by Result type
385 and stores the converted value into the caller allocated output buffer
386 specified by Result. The caller must pass in a Result buffer that is at
387 least as large as the Result type.
388
389 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
390
391 If the conversion results in an overflow or an underflow condition, then
392 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
393
394 @param[in] Operand Operand to be converted to new type
395 @param[out] Result Pointer to the result of conversion
396
397 @retval RETURN_SUCCESS Successful conversion
398 @retval RETURN_BUFFER_TOO_SMALL Overflow
399 @retval RETURN_INVALID_PARAMETER Result is NULL
400 **/
401 RETURN_STATUS
402 EFIAPI
403 SafeInt16ToUint16 (
404 IN INT16 Operand,
405 OUT UINT16 *Result
406 );
407
408 /**
409 INT16 -> UINT32 conversion
410
411 Converts the value specified by Operand to a value specified by Result type
412 and stores the converted value into the caller allocated output buffer
413 specified by Result. The caller must pass in a Result buffer that is at
414 least as large as the Result type.
415
416 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
417
418 If the conversion results in an overflow or an underflow condition, then
419 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
420
421 @param[in] Operand Operand to be converted to new type
422 @param[out] Result Pointer to the result of conversion
423
424 @retval RETURN_SUCCESS Successful conversion
425 @retval RETURN_BUFFER_TOO_SMALL Overflow
426 @retval RETURN_INVALID_PARAMETER Result is NULL
427 **/
428 RETURN_STATUS
429 EFIAPI
430 SafeInt16ToUint32 (
431 IN INT16 Operand,
432 OUT UINT32 *Result
433 );
434
435 /**
436 INT16 -> UINTN conversion
437
438 Converts the value specified by Operand to a value specified by Result type
439 and stores the converted value into the caller allocated output buffer
440 specified by Result. The caller must pass in a Result buffer that is at
441 least as large as the Result type.
442
443 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
444
445 If the conversion results in an overflow or an underflow condition, then
446 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
447
448 @param[in] Operand Operand to be converted to new type
449 @param[out] Result Pointer to the result of conversion
450
451 @retval RETURN_SUCCESS Successful conversion
452 @retval RETURN_BUFFER_TOO_SMALL Overflow
453 @retval RETURN_INVALID_PARAMETER Result is NULL
454 **/
455 RETURN_STATUS
456 EFIAPI
457 SafeInt16ToUintn (
458 IN INT16 Operand,
459 OUT UINTN *Result
460 );
461
462 /**
463 INT16 -> UINT64 conversion
464
465 Converts the value specified by Operand to a value specified by Result type
466 and stores the converted value into the caller allocated output buffer
467 specified by Result. The caller must pass in a Result buffer that is at
468 least as large as the Result type.
469
470 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
471
472 If the conversion results in an overflow or an underflow condition, then
473 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
474
475 @param[in] Operand Operand to be converted to new type
476 @param[out] Result Pointer to the result of conversion
477
478 @retval RETURN_SUCCESS Successful conversion
479 @retval RETURN_BUFFER_TOO_SMALL Overflow
480 @retval RETURN_INVALID_PARAMETER Result is NULL
481 **/
482 RETURN_STATUS
483 EFIAPI
484 SafeInt16ToUint64 (
485 IN INT16 Operand,
486 OUT UINT64 *Result
487 );
488
489 /**
490 UINT16 -> INT8 conversion
491
492 Converts the value specified by Operand to a value specified by Result type
493 and stores the converted value into the caller allocated output buffer
494 specified by Result. The caller must pass in a Result buffer that is at
495 least as large as the Result type.
496
497 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
498
499 If the conversion results in an overflow or an underflow condition, then
500 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
501
502 @param[in] Operand Operand to be converted to new type
503 @param[out] Result Pointer to the result of conversion
504
505 @retval RETURN_SUCCESS Successful conversion
506 @retval RETURN_BUFFER_TOO_SMALL Overflow
507 @retval RETURN_INVALID_PARAMETER Result is NULL
508 **/
509 RETURN_STATUS
510 EFIAPI
511 SafeUint16ToInt8 (
512 IN UINT16 Operand,
513 OUT INT8 *Result
514 );
515
516 /**
517 UINT16 -> CHAR8 conversion
518
519 Converts the value specified by Operand to a value specified by Result type
520 and stores the converted value into the caller allocated output buffer
521 specified by Result. The caller must pass in a Result buffer that is at
522 least as large as the Result type.
523
524 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
525
526 If the conversion results in an overflow or an underflow condition, then
527 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
528
529 @param[in] Operand Operand to be converted to new type
530 @param[out] Result Pointer to the result of conversion
531
532 @retval RETURN_SUCCESS Successful conversion
533 @retval RETURN_BUFFER_TOO_SMALL Overflow
534 @retval RETURN_INVALID_PARAMETER Result is NULL
535 **/
536 RETURN_STATUS
537 EFIAPI
538 SafeUint16ToChar8 (
539 IN UINT16 Operand,
540 OUT CHAR8 *Result
541 );
542
543 /**
544 UINT16 -> UINT8 conversion
545
546 Converts the value specified by Operand to a value specified by Result type
547 and stores the converted value into the caller allocated output buffer
548 specified by Result. The caller must pass in a Result buffer that is at
549 least as large as the Result type.
550
551 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
552
553 If the conversion results in an overflow or an underflow condition, then
554 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
555
556 @param[in] Operand Operand to be converted to new type
557 @param[out] Result Pointer to the result of conversion
558
559 @retval RETURN_SUCCESS Successful conversion
560 @retval RETURN_BUFFER_TOO_SMALL Overflow
561 @retval RETURN_INVALID_PARAMETER Result is NULL
562 **/
563 RETURN_STATUS
564 EFIAPI
565 SafeUint16ToUint8 (
566 IN UINT16 Operand,
567 OUT UINT8 *Result
568 );
569
570 /**
571 UINT16 -> INT16 conversion
572
573 Converts the value specified by Operand to a value specified by Result type
574 and stores the converted value into the caller allocated output buffer
575 specified by Result. The caller must pass in a Result buffer that is at
576 least as large as the Result type.
577
578 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
579
580 If the conversion results in an overflow or an underflow condition, then
581 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
582
583 @param[in] Operand Operand to be converted to new type
584 @param[out] Result Pointer to the result of conversion
585
586 @retval RETURN_SUCCESS Successful conversion
587 @retval RETURN_BUFFER_TOO_SMALL Overflow
588 @retval RETURN_INVALID_PARAMETER Result is NULL
589 **/
590 RETURN_STATUS
591 EFIAPI
592 SafeUint16ToInt16 (
593 IN UINT16 Operand,
594 OUT INT16 *Result
595 );
596
597 /**
598 INT32 -> INT8 conversion
599
600 Converts the value specified by Operand to a value specified by Result type
601 and stores the converted value into the caller allocated output buffer
602 specified by Result. The caller must pass in a Result buffer that is at
603 least as large as the Result type.
604
605 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
606
607 If the conversion results in an overflow or an underflow condition, then
608 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
609
610 @param[in] Operand Operand to be converted to new type
611 @param[out] Result Pointer to the result of conversion
612
613 @retval RETURN_SUCCESS Successful conversion
614 @retval RETURN_BUFFER_TOO_SMALL Overflow
615 @retval RETURN_INVALID_PARAMETER Result is NULL
616 **/
617 RETURN_STATUS
618 EFIAPI
619 SafeInt32ToInt8 (
620 IN INT32 Operand,
621 OUT INT8 *Result
622 );
623
624 /**
625 INT32 -> CHAR8 conversion
626
627 Converts the value specified by Operand to a value specified by Result type
628 and stores the converted value into the caller allocated output buffer
629 specified by Result. The caller must pass in a Result buffer that is at
630 least as large as the Result type.
631
632 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
633
634 If the conversion results in an overflow or an underflow condition, then
635 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
636
637 @param[in] Operand Operand to be converted to new type
638 @param[out] Result Pointer to the result of conversion
639
640 @retval RETURN_SUCCESS Successful conversion
641 @retval RETURN_BUFFER_TOO_SMALL Overflow
642 @retval RETURN_INVALID_PARAMETER Result is NULL
643 **/
644 RETURN_STATUS
645 EFIAPI
646 SafeInt32ToChar8 (
647 IN INT32 Operand,
648 OUT CHAR8 *Result
649 );
650
651 /**
652 INT32 -> UINT8 conversion
653
654 Converts the value specified by Operand to a value specified by Result type
655 and stores the converted value into the caller allocated output buffer
656 specified by Result. The caller must pass in a Result buffer that is at
657 least as large as the Result type.
658
659 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
660
661 If the conversion results in an overflow or an underflow condition, then
662 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
663
664 @param[in] Operand Operand to be converted to new type
665 @param[out] Result Pointer to the result of conversion
666
667 @retval RETURN_SUCCESS Successful conversion
668 @retval RETURN_BUFFER_TOO_SMALL Overflow
669 @retval RETURN_INVALID_PARAMETER Result is NULL
670 **/
671 RETURN_STATUS
672 EFIAPI
673 SafeInt32ToUint8 (
674 IN INT32 Operand,
675 OUT UINT8 *Result
676 );
677
678 /**
679 INT32 -> INT16 conversion
680
681 Converts the value specified by Operand to a value specified by Result type
682 and stores the converted value into the caller allocated output buffer
683 specified by Result. The caller must pass in a Result buffer that is at
684 least as large as the Result type.
685
686 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
687
688 If the conversion results in an overflow or an underflow condition, then
689 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
690
691 @param[in] Operand Operand to be converted to new type
692 @param[out] Result Pointer to the result of conversion
693
694 @retval RETURN_SUCCESS Successful conversion
695 @retval RETURN_BUFFER_TOO_SMALL Overflow
696 @retval RETURN_INVALID_PARAMETER Result is NULL
697 **/
698 RETURN_STATUS
699 EFIAPI
700 SafeInt32ToInt16 (
701 IN INT32 Operand,
702 OUT INT16 *Result
703 );
704
705 /**
706 INT32 -> UINT16 conversion
707
708 Converts the value specified by Operand to a value specified by Result type
709 and stores the converted value into the caller allocated output buffer
710 specified by Result. The caller must pass in a Result buffer that is at
711 least as large as the Result type.
712
713 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
714
715 If the conversion results in an overflow or an underflow condition, then
716 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
717
718 @param[in] Operand Operand to be converted to new type
719 @param[out] Result Pointer to the result of conversion
720
721 @retval RETURN_SUCCESS Successful conversion
722 @retval RETURN_BUFFER_TOO_SMALL Overflow
723 @retval RETURN_INVALID_PARAMETER Result is NULL
724 **/
725 RETURN_STATUS
726 EFIAPI
727 SafeInt32ToUint16 (
728 IN INT32 Operand,
729 OUT UINT16 *Result
730 );
731
732
733 /**
734 INT32 -> UINT32 conversion
735
736 Converts the value specified by Operand to a value specified by Result type
737 and stores the converted value into the caller allocated output buffer
738 specified by Result. The caller must pass in a Result buffer that is at
739 least as large as the Result type.
740
741 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
742
743 If the conversion results in an overflow or an underflow condition, then
744 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
745
746 @param[in] Operand Operand to be converted to new type
747 @param[out] Result Pointer to the result of conversion
748
749 @retval RETURN_SUCCESS Successful conversion
750 @retval RETURN_BUFFER_TOO_SMALL Overflow
751 @retval RETURN_INVALID_PARAMETER Result is NULL
752 **/
753 RETURN_STATUS
754 EFIAPI
755 SafeInt32ToUint32 (
756 IN INT32 Operand,
757 OUT UINT32 *Result
758 );
759
760 /**
761 INT32 -> UINTN conversion
762
763 Converts the value specified by Operand to a value specified by Result type
764 and stores the converted value into the caller allocated output buffer
765 specified by Result. The caller must pass in a Result buffer that is at
766 least as large as the Result type.
767
768 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
769
770 If the conversion results in an overflow or an underflow condition, then
771 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
772
773 @param[in] Operand Operand to be converted to new type
774 @param[out] Result Pointer to the result of conversion
775
776 @retval RETURN_SUCCESS Successful conversion
777 @retval RETURN_BUFFER_TOO_SMALL Overflow
778 @retval RETURN_INVALID_PARAMETER Result is NULL
779 **/
780 RETURN_STATUS
781 EFIAPI
782 SafeInt32ToUintn (
783 IN INT32 Operand,
784 OUT UINTN *Result
785 );
786
787 /**
788 INT32 -> UINT64 conversion
789
790 Converts the value specified by Operand to a value specified by Result type
791 and stores the converted value into the caller allocated output buffer
792 specified by Result. The caller must pass in a Result buffer that is at
793 least as large as the Result type.
794
795 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
796
797 If the conversion results in an overflow or an underflow condition, then
798 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
799
800 @param[in] Operand Operand to be converted to new type
801 @param[out] Result Pointer to the result of conversion
802
803 @retval RETURN_SUCCESS Successful conversion
804 @retval RETURN_BUFFER_TOO_SMALL Overflow
805 @retval RETURN_INVALID_PARAMETER Result is NULL
806 **/
807 RETURN_STATUS
808 EFIAPI
809 SafeInt32ToUint64 (
810 IN INT32 Operand,
811 OUT UINT64 *Result
812 );
813
814 /**
815 UINT32 -> INT8 conversion
816
817 Converts the value specified by Operand to a value specified by Result type
818 and stores the converted value into the caller allocated output buffer
819 specified by Result. The caller must pass in a Result buffer that is at
820 least as large as the Result type.
821
822 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
823
824 If the conversion results in an overflow or an underflow condition, then
825 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
826
827 @param[in] Operand Operand to be converted to new type
828 @param[out] Result Pointer to the result of conversion
829
830 @retval RETURN_SUCCESS Successful conversion
831 @retval RETURN_BUFFER_TOO_SMALL Overflow
832 @retval RETURN_INVALID_PARAMETER Result is NULL
833 **/
834 RETURN_STATUS
835 EFIAPI
836 SafeUint32ToInt8 (
837 IN UINT32 Operand,
838 OUT INT8 *Result
839 );
840
841 /**
842 UINT32 -> CHAR8 conversion
843
844 Converts the value specified by Operand to a value specified by Result type
845 and stores the converted value into the caller allocated output buffer
846 specified by Result. The caller must pass in a Result buffer that is at
847 least as large as the Result type.
848
849 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
850
851 If the conversion results in an overflow or an underflow condition, then
852 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
853
854 @param[in] Operand Operand to be converted to new type
855 @param[out] Result Pointer to the result of conversion
856
857 @retval RETURN_SUCCESS Successful conversion
858 @retval RETURN_BUFFER_TOO_SMALL Overflow
859 @retval RETURN_INVALID_PARAMETER Result is NULL
860 **/
861 RETURN_STATUS
862 EFIAPI
863 SafeUint32ToChar8 (
864 IN UINT32 Operand,
865 OUT CHAR8 *Result
866 );
867
868 /**
869 UINT32 -> UINT8 conversion
870
871 Converts the value specified by Operand to a value specified by Result type
872 and stores the converted value into the caller allocated output buffer
873 specified by Result. The caller must pass in a Result buffer that is at
874 least as large as the Result type.
875
876 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
877
878 If the conversion results in an overflow or an underflow condition, then
879 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
880
881 @param[in] Operand Operand to be converted to new type
882 @param[out] Result Pointer to the result of conversion
883
884 @retval RETURN_SUCCESS Successful conversion
885 @retval RETURN_BUFFER_TOO_SMALL Overflow
886 @retval RETURN_INVALID_PARAMETER Result is NULL
887 **/
888 RETURN_STATUS
889 EFIAPI
890 SafeUint32ToUint8 (
891 IN UINT32 Operand,
892 OUT UINT8 *Result
893 );
894
895 /**
896 UINT32 -> INT16 conversion
897
898 Converts the value specified by Operand to a value specified by Result type
899 and stores the converted value into the caller allocated output buffer
900 specified by Result. The caller must pass in a Result buffer that is at
901 least as large as the Result type.
902
903 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
904
905 If the conversion results in an overflow or an underflow condition, then
906 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
907
908 @param[in] Operand Operand to be converted to new type
909 @param[out] Result Pointer to the result of conversion
910
911 @retval RETURN_SUCCESS Successful conversion
912 @retval RETURN_BUFFER_TOO_SMALL Overflow
913 @retval RETURN_INVALID_PARAMETER Result is NULL
914 **/
915 RETURN_STATUS
916 EFIAPI
917 SafeUint32ToInt16 (
918 IN UINT32 Operand,
919 OUT INT16 *Result
920 );
921
922 /**
923 UINT32 -> UINT16 conversion
924
925 Converts the value specified by Operand to a value specified by Result type
926 and stores the converted value into the caller allocated output buffer
927 specified by Result. The caller must pass in a Result buffer that is at
928 least as large as the Result type.
929
930 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
931
932 If the conversion results in an overflow or an underflow condition, then
933 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
934
935 @param[in] Operand Operand to be converted to new type
936 @param[out] Result Pointer to the result of conversion
937
938 @retval RETURN_SUCCESS Successful conversion
939 @retval RETURN_BUFFER_TOO_SMALL Overflow
940 @retval RETURN_INVALID_PARAMETER Result is NULL
941 **/
942 RETURN_STATUS
943 EFIAPI
944 SafeUint32ToUint16 (
945 IN UINT32 Operand,
946 OUT UINT16 *Result
947 );
948
949 /**
950 UINT32 -> INT32 conversion
951
952 Converts the value specified by Operand to a value specified by Result type
953 and stores the converted value into the caller allocated output buffer
954 specified by Result. The caller must pass in a Result buffer that is at
955 least as large as the Result type.
956
957 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
958
959 If the conversion results in an overflow or an underflow condition, then
960 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
961
962 @param[in] Operand Operand to be converted to new type
963 @param[out] Result Pointer to the result of conversion
964
965 @retval RETURN_SUCCESS Successful conversion
966 @retval RETURN_BUFFER_TOO_SMALL Overflow
967 @retval RETURN_INVALID_PARAMETER Result is NULL
968 **/
969 RETURN_STATUS
970 EFIAPI
971 SafeUint32ToInt32 (
972 IN UINT32 Operand,
973 OUT INT32 *Result
974 );
975
976 /**
977 UINT32 -> INTN conversion
978
979 Converts the value specified by Operand to a value specified by Result type
980 and stores the converted value into the caller allocated output buffer
981 specified by Result. The caller must pass in a Result buffer that is at
982 least as large as the Result type.
983
984 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
985
986 If the conversion results in an overflow or an underflow condition, then
987 Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
988
989 @param[in] Operand Operand to be converted to new type
990 @param[out] Result Pointer to the result of conversion
991
992 @retval RETURN_SUCCESS Successful conversion
993 @retval RETURN_BUFFER_TOO_SMALL Overflow
994 @retval RETURN_INVALID_PARAMETER Result is NULL
995 **/
996 RETURN_STATUS
997 EFIAPI
998 SafeUint32ToIntn (
999 IN UINT32 Operand,
1000 OUT INTN *Result
1001 );
1002
1003 /**
1004 INTN -> INT8 conversion
1005
1006 Converts the value specified by Operand to a value specified by Result type
1007 and stores the converted value into the caller allocated output buffer
1008 specified by Result. The caller must pass in a Result buffer that is at
1009 least as large as the Result type.
1010
1011 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1012
1013 If the conversion results in an overflow or an underflow condition, then
1014 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1015
1016 @param[in] Operand Operand to be converted to new type
1017 @param[out] Result Pointer to the result of conversion
1018
1019 @retval RETURN_SUCCESS Successful conversion
1020 @retval RETURN_BUFFER_TOO_SMALL Overflow
1021 @retval RETURN_INVALID_PARAMETER Result is NULL
1022 **/
1023 RETURN_STATUS
1024 EFIAPI
1025 SafeIntnToInt8 (
1026 IN INTN Operand,
1027 OUT INT8 *Result
1028 );
1029
1030 /**
1031 INTN -> CHAR8 conversion
1032
1033 Converts the value specified by Operand to a value specified by Result type
1034 and stores the converted value into the caller allocated output buffer
1035 specified by Result. The caller must pass in a Result buffer that is at
1036 least as large as the Result type.
1037
1038 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1039
1040 If the conversion results in an overflow or an underflow condition, then
1041 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1042
1043 @param[in] Operand Operand to be converted to new type
1044 @param[out] Result Pointer to the result of conversion
1045
1046 @retval RETURN_SUCCESS Successful conversion
1047 @retval RETURN_BUFFER_TOO_SMALL Overflow
1048 @retval RETURN_INVALID_PARAMETER Result is NULL
1049 **/
1050 RETURN_STATUS
1051 EFIAPI
1052 SafeIntnToChar8 (
1053 IN INTN Operand,
1054 OUT CHAR8 *Result
1055 );
1056
1057 /**
1058 INTN -> UINT8 conversion
1059
1060 Converts the value specified by Operand to a value specified by Result type
1061 and stores the converted value into the caller allocated output buffer
1062 specified by Result. The caller must pass in a Result buffer that is at
1063 least as large as the Result type.
1064
1065 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1066
1067 If the conversion results in an overflow or an underflow condition, then
1068 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1069
1070 @param[in] Operand Operand to be converted to new type
1071 @param[out] Result Pointer to the result of conversion
1072
1073 @retval RETURN_SUCCESS Successful conversion
1074 @retval RETURN_BUFFER_TOO_SMALL Overflow
1075 @retval RETURN_INVALID_PARAMETER Result is NULL
1076 **/
1077 RETURN_STATUS
1078 EFIAPI
1079 SafeIntnToUint8 (
1080 IN INTN Operand,
1081 OUT UINT8 *Result
1082 );
1083
1084 /**
1085 INTN -> INT16 conversion
1086
1087 Converts the value specified by Operand to a value specified by Result type
1088 and stores the converted value into the caller allocated output buffer
1089 specified by Result. The caller must pass in a Result buffer that is at
1090 least as large as the Result type.
1091
1092 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1093
1094 If the conversion results in an overflow or an underflow condition, then
1095 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1096
1097 @param[in] Operand Operand to be converted to new type
1098 @param[out] Result Pointer to the result of conversion
1099
1100 @retval RETURN_SUCCESS Successful conversion
1101 @retval RETURN_BUFFER_TOO_SMALL Overflow
1102 @retval RETURN_INVALID_PARAMETER Result is NULL
1103 **/
1104 RETURN_STATUS
1105 EFIAPI
1106 SafeIntnToInt16 (
1107 IN INTN Operand,
1108 OUT INT16 *Result
1109 );
1110
1111 /**
1112 INTN -> UINT16 conversion
1113
1114 Converts the value specified by Operand to a value specified by Result type
1115 and stores the converted value into the caller allocated output buffer
1116 specified by Result. The caller must pass in a Result buffer that is at
1117 least as large as the Result type.
1118
1119 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1120
1121 If the conversion results in an overflow or an underflow condition, then
1122 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1123
1124 @param[in] Operand Operand to be converted to new type
1125 @param[out] Result Pointer to the result of conversion
1126
1127 @retval RETURN_SUCCESS Successful conversion
1128 @retval RETURN_BUFFER_TOO_SMALL Overflow
1129 @retval RETURN_INVALID_PARAMETER Result is NULL
1130 **/
1131 RETURN_STATUS
1132 EFIAPI
1133 SafeIntnToUint16 (
1134 IN INTN Operand,
1135 OUT UINT16 *Result
1136 );
1137
1138 /**
1139 INTN -> INT32 conversion
1140
1141 Converts the value specified by Operand to a value specified by Result type
1142 and stores the converted value into the caller allocated output buffer
1143 specified by Result. The caller must pass in a Result buffer that is at
1144 least as large as the Result type.
1145
1146 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1147
1148 If the conversion results in an overflow or an underflow condition, then
1149 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1150
1151 @param[in] Operand Operand to be converted to new type
1152 @param[out] Result Pointer to the result of conversion
1153
1154 @retval RETURN_SUCCESS Successful conversion
1155 @retval RETURN_BUFFER_TOO_SMALL Overflow
1156 @retval RETURN_INVALID_PARAMETER Result is NULL
1157 **/
1158 RETURN_STATUS
1159 EFIAPI
1160 SafeIntnToInt32 (
1161 IN INTN Operand,
1162 OUT INT32 *Result
1163 );
1164
1165 /**
1166 INTN -> UINT32 conversion
1167
1168 Converts the value specified by Operand to a value specified by Result type
1169 and stores the converted value into the caller allocated output buffer
1170 specified by Result. The caller must pass in a Result buffer that is at
1171 least as large as the Result type.
1172
1173 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1174
1175 If the conversion results in an overflow or an underflow condition, then
1176 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1177
1178 @param[in] Operand Operand to be converted to new type
1179 @param[out] Result Pointer to the result of conversion
1180
1181 @retval RETURN_SUCCESS Successful conversion
1182 @retval RETURN_BUFFER_TOO_SMALL Overflow
1183 @retval RETURN_INVALID_PARAMETER Result is NULL
1184 **/
1185 RETURN_STATUS
1186 EFIAPI
1187 SafeIntnToUint32 (
1188 IN INTN Operand,
1189 OUT UINT32 *Result
1190 );
1191
1192 /**
1193 INTN -> UINTN conversion
1194
1195 Converts the value specified by Operand to a value specified by Result type
1196 and stores the converted value into the caller allocated output buffer
1197 specified by Result. The caller must pass in a Result buffer that is at
1198 least as large as the Result type.
1199
1200 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1201
1202 If the conversion results in an overflow or an underflow condition, then
1203 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1204
1205 @param[in] Operand Operand to be converted to new type
1206 @param[out] Result Pointer to the result of conversion
1207
1208 @retval RETURN_SUCCESS Successful conversion
1209 @retval RETURN_BUFFER_TOO_SMALL Overflow
1210 @retval RETURN_INVALID_PARAMETER Result is NULL
1211 **/
1212 RETURN_STATUS
1213 EFIAPI
1214 SafeIntnToUintn (
1215 IN INTN Operand,
1216 OUT UINTN *Result
1217 );
1218
1219 /**
1220 INTN -> UINT64 conversion
1221
1222 Converts the value specified by Operand to a value specified by Result type
1223 and stores the converted value into the caller allocated output buffer
1224 specified by Result. The caller must pass in a Result buffer that is at
1225 least as large as the Result type.
1226
1227 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1228
1229 If the conversion results in an overflow or an underflow condition, then
1230 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1231
1232 @param[in] Operand Operand to be converted to new type
1233 @param[out] Result Pointer to the result of conversion
1234
1235 @retval RETURN_SUCCESS Successful conversion
1236 @retval RETURN_BUFFER_TOO_SMALL Overflow
1237 @retval RETURN_INVALID_PARAMETER Result is NULL
1238 **/
1239 RETURN_STATUS
1240 EFIAPI
1241 SafeIntnToUint64 (
1242 IN INTN Operand,
1243 OUT UINT64 *Result
1244 );
1245
1246 /**
1247 UINTN -> INT8 conversion
1248
1249 Converts the value specified by Operand to a value specified by Result type
1250 and stores the converted value into the caller allocated output buffer
1251 specified by Result. The caller must pass in a Result buffer that is at
1252 least as large as the Result type.
1253
1254 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1255
1256 If the conversion results in an overflow or an underflow condition, then
1257 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1258
1259 @param[in] Operand Operand to be converted to new type
1260 @param[out] Result Pointer to the result of conversion
1261
1262 @retval RETURN_SUCCESS Successful conversion
1263 @retval RETURN_BUFFER_TOO_SMALL Overflow
1264 @retval RETURN_INVALID_PARAMETER Result is NULL
1265 **/
1266 RETURN_STATUS
1267 EFIAPI
1268 SafeUintnToInt8 (
1269 IN UINTN Operand,
1270 OUT INT8 *Result
1271 );
1272
1273 /**
1274 UINTN -> CHAR8 conversion
1275
1276 Converts the value specified by Operand to a value specified by Result type
1277 and stores the converted value into the caller allocated output buffer
1278 specified by Result. The caller must pass in a Result buffer that is at
1279 least as large as the Result type.
1280
1281 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1282
1283 If the conversion results in an overflow or an underflow condition, then
1284 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1285
1286 @param[in] Operand Operand to be converted to new type
1287 @param[out] Result Pointer to the result of conversion
1288
1289 @retval RETURN_SUCCESS Successful conversion
1290 @retval RETURN_BUFFER_TOO_SMALL Overflow
1291 @retval RETURN_INVALID_PARAMETER Result is NULL
1292 **/
1293 RETURN_STATUS
1294 EFIAPI
1295 SafeUintnToChar8 (
1296 IN UINTN Operand,
1297 OUT CHAR8 *Result
1298 );
1299
1300 /**
1301 UINTN -> UINT8 conversion
1302
1303 Converts the value specified by Operand to a value specified by Result type
1304 and stores the converted value into the caller allocated output buffer
1305 specified by Result. The caller must pass in a Result buffer that is at
1306 least as large as the Result type.
1307
1308 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1309
1310 If the conversion results in an overflow or an underflow condition, then
1311 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1312
1313 @param[in] Operand Operand to be converted to new type
1314 @param[out] Result Pointer to the result of conversion
1315
1316 @retval RETURN_SUCCESS Successful conversion
1317 @retval RETURN_BUFFER_TOO_SMALL Overflow
1318 @retval RETURN_INVALID_PARAMETER Result is NULL
1319 **/
1320 RETURN_STATUS
1321 EFIAPI
1322 SafeUintnToUint8 (
1323 IN UINTN Operand,
1324 OUT UINT8 *Result
1325 );
1326
1327 /**
1328 UINTN -> INT16 conversion
1329
1330 Converts the value specified by Operand to a value specified by Result type
1331 and stores the converted value into the caller allocated output buffer
1332 specified by Result. The caller must pass in a Result buffer that is at
1333 least as large as the Result type.
1334
1335 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1336
1337 If the conversion results in an overflow or an underflow condition, then
1338 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1339
1340 @param[in] Operand Operand to be converted to new type
1341 @param[out] Result Pointer to the result of conversion
1342
1343 @retval RETURN_SUCCESS Successful conversion
1344 @retval RETURN_BUFFER_TOO_SMALL Overflow
1345 @retval RETURN_INVALID_PARAMETER Result is NULL
1346 **/
1347 RETURN_STATUS
1348 EFIAPI
1349 SafeUintnToInt16 (
1350 IN UINTN Operand,
1351 OUT INT16 *Result
1352 );
1353
1354 /**
1355 UINTN -> UINT16 conversion
1356
1357 Converts the value specified by Operand to a value specified by Result type
1358 and stores the converted value into the caller allocated output buffer
1359 specified by Result. The caller must pass in a Result buffer that is at
1360 least as large as the Result type.
1361
1362 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1363
1364 If the conversion results in an overflow or an underflow condition, then
1365 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1366
1367 @param[in] Operand Operand to be converted to new type
1368 @param[out] Result Pointer to the result of conversion
1369
1370 @retval RETURN_SUCCESS Successful conversion
1371 @retval RETURN_BUFFER_TOO_SMALL Overflow
1372 @retval RETURN_INVALID_PARAMETER Result is NULL
1373 **/
1374 RETURN_STATUS
1375 EFIAPI
1376 SafeUintnToUint16 (
1377 IN UINTN Operand,
1378 OUT UINT16 *Result
1379 );
1380
1381 /**
1382 UINTN -> INT32 conversion
1383
1384 Converts the value specified by Operand to a value specified by Result type
1385 and stores the converted value into the caller allocated output buffer
1386 specified by Result. The caller must pass in a Result buffer that is at
1387 least as large as the Result type.
1388
1389 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1390
1391 If the conversion results in an overflow or an underflow condition, then
1392 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1393
1394 @param[in] Operand Operand to be converted to new type
1395 @param[out] Result Pointer to the result of conversion
1396
1397 @retval RETURN_SUCCESS Successful conversion
1398 @retval RETURN_BUFFER_TOO_SMALL Overflow
1399 @retval RETURN_INVALID_PARAMETER Result is NULL
1400 **/
1401 RETURN_STATUS
1402 EFIAPI
1403 SafeUintnToInt32 (
1404 IN UINTN Operand,
1405 OUT INT32 *Result
1406 );
1407
1408 /**
1409 UINTN -> UINT32 conversion
1410
1411 Converts the value specified by Operand to a value specified by Result type
1412 and stores the converted value into the caller allocated output buffer
1413 specified by Result. The caller must pass in a Result buffer that is at
1414 least as large as the Result type.
1415
1416 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1417
1418 If the conversion results in an overflow or an underflow condition, then
1419 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1420
1421 @param[in] Operand Operand to be converted to new type
1422 @param[out] Result Pointer to the result of conversion
1423
1424 @retval RETURN_SUCCESS Successful conversion
1425 @retval RETURN_BUFFER_TOO_SMALL Overflow
1426 @retval RETURN_INVALID_PARAMETER Result is NULL
1427 **/
1428 RETURN_STATUS
1429 EFIAPI
1430 SafeUintnToUint32 (
1431 IN UINTN Operand,
1432 OUT UINT32 *Result
1433 );
1434
1435 /**
1436 UINTN -> INTN conversion
1437
1438 Converts the value specified by Operand to a value specified by Result type
1439 and stores the converted value into the caller allocated output buffer
1440 specified by Result. The caller must pass in a Result buffer that is at
1441 least as large as the Result type.
1442
1443 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1444
1445 If the conversion results in an overflow or an underflow condition, then
1446 Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1447
1448 @param[in] Operand Operand to be converted to new type
1449 @param[out] Result Pointer to the result of conversion
1450
1451 @retval RETURN_SUCCESS Successful conversion
1452 @retval RETURN_BUFFER_TOO_SMALL Overflow
1453 @retval RETURN_INVALID_PARAMETER Result is NULL
1454 **/
1455 RETURN_STATUS
1456 EFIAPI
1457 SafeUintnToIntn (
1458 IN UINTN Operand,
1459 OUT INTN *Result
1460 );
1461
1462 /**
1463 UINTN -> INT64 conversion
1464
1465 Converts the value specified by Operand to a value specified by Result type
1466 and stores the converted value into the caller allocated output buffer
1467 specified by Result. The caller must pass in a Result buffer that is at
1468 least as large as the Result type.
1469
1470 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1471
1472 If the conversion results in an overflow or an underflow condition, then
1473 Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1474
1475 @param[in] Operand Operand to be converted to new type
1476 @param[out] Result Pointer to the result of conversion
1477
1478 @retval RETURN_SUCCESS Successful conversion
1479 @retval RETURN_BUFFER_TOO_SMALL Overflow
1480 @retval RETURN_INVALID_PARAMETER Result is NULL
1481 **/
1482 RETURN_STATUS
1483 EFIAPI
1484 SafeUintnToInt64 (
1485 IN UINTN Operand,
1486 OUT INT64 *Result
1487 );
1488
1489 /**
1490 INT64 -> INT8 conversion
1491
1492 Converts the value specified by Operand to a value specified by Result type
1493 and stores the converted value into the caller allocated output buffer
1494 specified by Result. The caller must pass in a Result buffer that is at
1495 least as large as the Result type.
1496
1497 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1498
1499 If the conversion results in an overflow or an underflow condition, then
1500 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1501
1502 @param[in] Operand Operand to be converted to new type
1503 @param[out] Result Pointer to the result of conversion
1504
1505 @retval RETURN_SUCCESS Successful conversion
1506 @retval RETURN_BUFFER_TOO_SMALL Overflow
1507 @retval RETURN_INVALID_PARAMETER Result is NULL
1508 **/
1509 RETURN_STATUS
1510 EFIAPI
1511 SafeInt64ToInt8 (
1512 IN INT64 Operand,
1513 OUT INT8 *Result
1514 );
1515
1516 /**
1517 INT64 -> CHAR8 conversion
1518
1519 Converts the value specified by Operand to a value specified by Result type
1520 and stores the converted value into the caller allocated output buffer
1521 specified by Result. The caller must pass in a Result buffer that is at
1522 least as large as the Result type.
1523
1524 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1525
1526 If the conversion results in an overflow or an underflow condition, then
1527 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1528
1529 @param[in] Operand Operand to be converted to new type
1530 @param[out] Result Pointer to the result of conversion
1531
1532 @retval RETURN_SUCCESS Successful conversion
1533 @retval RETURN_BUFFER_TOO_SMALL Overflow
1534 @retval RETURN_INVALID_PARAMETER Result is NULL
1535 **/
1536 RETURN_STATUS
1537 EFIAPI
1538 SafeInt64ToChar8 (
1539 IN INT64 Operand,
1540 OUT CHAR8 *Result
1541 );
1542
1543 /**
1544 INT64 -> UINT8 conversion
1545
1546 Converts the value specified by Operand to a value specified by Result type
1547 and stores the converted value into the caller allocated output buffer
1548 specified by Result. The caller must pass in a Result buffer that is at
1549 least as large as the Result type.
1550
1551 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1552
1553 If the conversion results in an overflow or an underflow condition, then
1554 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1555
1556 @param[in] Operand Operand to be converted to new type
1557 @param[out] Result Pointer to the result of conversion
1558
1559 @retval RETURN_SUCCESS Successful conversion
1560 @retval RETURN_BUFFER_TOO_SMALL Overflow
1561 @retval RETURN_INVALID_PARAMETER Result is NULL
1562 **/
1563 RETURN_STATUS
1564 EFIAPI
1565 SafeInt64ToUint8 (
1566 IN INT64 Operand,
1567 OUT UINT8 *Result
1568 );
1569
1570 /**
1571 INT64 -> INT16 conversion
1572
1573 Converts the value specified by Operand to a value specified by Result type
1574 and stores the converted value into the caller allocated output buffer
1575 specified by Result. The caller must pass in a Result buffer that is at
1576 least as large as the Result type.
1577
1578 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1579
1580 If the conversion results in an overflow or an underflow condition, then
1581 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1582
1583 @param[in] Operand Operand to be converted to new type
1584 @param[out] Result Pointer to the result of conversion
1585
1586 @retval RETURN_SUCCESS Successful conversion
1587 @retval RETURN_BUFFER_TOO_SMALL Overflow
1588 @retval RETURN_INVALID_PARAMETER Result is NULL
1589 **/
1590 RETURN_STATUS
1591 EFIAPI
1592 SafeInt64ToInt16 (
1593 IN INT64 Operand,
1594 OUT INT16 *Result
1595 );
1596
1597 /**
1598 INT64 -> UINT16 conversion
1599
1600 Converts the value specified by Operand to a value specified by Result type
1601 and stores the converted value into the caller allocated output buffer
1602 specified by Result. The caller must pass in a Result buffer that is at
1603 least as large as the Result type.
1604
1605 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1606
1607 If the conversion results in an overflow or an underflow condition, then
1608 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1609
1610 @param[in] Operand Operand to be converted to new type
1611 @param[out] Result Pointer to the result of conversion
1612
1613 @retval RETURN_SUCCESS Successful conversion
1614 @retval RETURN_BUFFER_TOO_SMALL Overflow
1615 @retval RETURN_INVALID_PARAMETER Result is NULL
1616 **/
1617 RETURN_STATUS
1618 EFIAPI
1619 SafeInt64ToUint16 (
1620 IN INT64 Operand,
1621 OUT UINT16 *Result
1622 );
1623
1624 /**
1625 INT64 -> INT32 conversion
1626
1627 Converts the value specified by Operand to a value specified by Result type
1628 and stores the converted value into the caller allocated output buffer
1629 specified by Result. The caller must pass in a Result buffer that is at
1630 least as large as the Result type.
1631
1632 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1633
1634 If the conversion results in an overflow or an underflow condition, then
1635 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1636
1637 @param[in] Operand Operand to be converted to new type
1638 @param[out] Result Pointer to the result of conversion
1639
1640 @retval RETURN_SUCCESS Successful conversion
1641 @retval RETURN_BUFFER_TOO_SMALL Overflow
1642 @retval RETURN_INVALID_PARAMETER Result is NULL
1643 **/
1644 RETURN_STATUS
1645 EFIAPI
1646 SafeInt64ToInt32 (
1647 IN INT64 Operand,
1648 OUT INT32 *Result
1649 );
1650
1651 /**
1652 INT64 -> UINT32 conversion
1653
1654 Converts the value specified by Operand to a value specified by Result type
1655 and stores the converted value into the caller allocated output buffer
1656 specified by Result. The caller must pass in a Result buffer that is at
1657 least as large as the Result type.
1658
1659 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1660
1661 If the conversion results in an overflow or an underflow condition, then
1662 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1663
1664 @param[in] Operand Operand to be converted to new type
1665 @param[out] Result Pointer to the result of conversion
1666
1667 @retval RETURN_SUCCESS Successful conversion
1668 @retval RETURN_BUFFER_TOO_SMALL Overflow
1669 @retval RETURN_INVALID_PARAMETER Result is NULL
1670 **/
1671 RETURN_STATUS
1672 EFIAPI
1673 SafeInt64ToUint32 (
1674 IN INT64 Operand,
1675 OUT UINT32 *Result
1676 );
1677
1678 /**
1679 INT64 -> INTN conversion
1680
1681 Converts the value specified by Operand to a value specified by Result type
1682 and stores the converted value into the caller allocated output buffer
1683 specified by Result. The caller must pass in a Result buffer that is at
1684 least as large as the Result type.
1685
1686 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1687
1688 If the conversion results in an overflow or an underflow condition, then
1689 Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1690
1691 @param[in] Operand Operand to be converted to new type
1692 @param[out] Result Pointer to the result of conversion
1693
1694 @retval RETURN_SUCCESS Successful conversion
1695 @retval RETURN_BUFFER_TOO_SMALL Overflow
1696 @retval RETURN_INVALID_PARAMETER Result is NULL
1697 **/
1698 RETURN_STATUS
1699 EFIAPI
1700 SafeInt64ToIntn (
1701 IN INT64 Operand,
1702 OUT INTN *Result
1703 );
1704
1705 /**
1706 INT64 -> UINTN conversion
1707
1708 Converts the value specified by Operand to a value specified by Result type
1709 and stores the converted value into the caller allocated output buffer
1710 specified by Result. The caller must pass in a Result buffer that is at
1711 least as large as the Result type.
1712
1713 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1714
1715 If the conversion results in an overflow or an underflow condition, then
1716 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1717
1718 @param[in] Operand Operand to be converted to new type
1719 @param[out] Result Pointer to the result of conversion
1720
1721 @retval RETURN_SUCCESS Successful conversion
1722 @retval RETURN_BUFFER_TOO_SMALL Overflow
1723 @retval RETURN_INVALID_PARAMETER Result is NULL
1724 **/
1725 RETURN_STATUS
1726 EFIAPI
1727 SafeInt64ToUintn (
1728 IN INT64 Operand,
1729 OUT UINTN *Result
1730 );
1731
1732 /**
1733 INT64 -> UINT64 conversion
1734
1735 Converts the value specified by Operand to a value specified by Result type
1736 and stores the converted value into the caller allocated output buffer
1737 specified by Result. The caller must pass in a Result buffer that is at
1738 least as large as the Result type.
1739
1740 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1741
1742 If the conversion results in an overflow or an underflow condition, then
1743 Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1744
1745 @param[in] Operand Operand to be converted to new type
1746 @param[out] Result Pointer to the result of conversion
1747
1748 @retval RETURN_SUCCESS Successful conversion
1749 @retval RETURN_BUFFER_TOO_SMALL Overflow
1750 @retval RETURN_INVALID_PARAMETER Result is NULL
1751 **/
1752 RETURN_STATUS
1753 EFIAPI
1754 SafeInt64ToUint64 (
1755 IN INT64 Operand,
1756 OUT UINT64 *Result
1757 );
1758
1759 /**
1760 UINT64 -> INT8 conversion
1761
1762 Converts the value specified by Operand to a value specified by Result type
1763 and stores the converted value into the caller allocated output buffer
1764 specified by Result. The caller must pass in a Result buffer that is at
1765 least as large as the Result type.
1766
1767 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1768
1769 If the conversion results in an overflow or an underflow condition, then
1770 Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1771
1772 @param[in] Operand Operand to be converted to new type
1773 @param[out] Result Pointer to the result of conversion
1774
1775 @retval RETURN_SUCCESS Successful conversion
1776 @retval RETURN_BUFFER_TOO_SMALL Overflow
1777 @retval RETURN_INVALID_PARAMETER Result is NULL
1778 **/
1779 RETURN_STATUS
1780 EFIAPI
1781 SafeUint64ToInt8 (
1782 IN UINT64 Operand,
1783 OUT INT8 *Result
1784 );
1785
1786 /**
1787 UINT64 -> CHAR8 conversion
1788
1789 Converts the value specified by Operand to a value specified by Result type
1790 and stores the converted value into the caller allocated output buffer
1791 specified by Result. The caller must pass in a Result buffer that is at
1792 least as large as the Result type.
1793
1794 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1795
1796 If the conversion results in an overflow or an underflow condition, then
1797 Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1798
1799 @param[in] Operand Operand to be converted to new type
1800 @param[out] Result Pointer to the result of conversion
1801
1802 @retval RETURN_SUCCESS Successful conversion
1803 @retval RETURN_BUFFER_TOO_SMALL Overflow
1804 @retval RETURN_INVALID_PARAMETER Result is NULL
1805 **/
1806 RETURN_STATUS
1807 EFIAPI
1808 SafeUint64ToChar8 (
1809 IN UINT64 Operand,
1810 OUT CHAR8 *Result
1811 );
1812
1813 /**
1814 UINT64 -> UINT8 conversion
1815
1816 Converts the value specified by Operand to a value specified by Result type
1817 and stores the converted value into the caller allocated output buffer
1818 specified by Result. The caller must pass in a Result buffer that is at
1819 least as large as the Result type.
1820
1821 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1822
1823 If the conversion results in an overflow or an underflow condition, then
1824 Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1825
1826 @param[in] Operand Operand to be converted to new type
1827 @param[out] Result Pointer to the result of conversion
1828
1829 @retval RETURN_SUCCESS Successful conversion
1830 @retval RETURN_BUFFER_TOO_SMALL Overflow
1831 @retval RETURN_INVALID_PARAMETER Result is NULL
1832 **/
1833 RETURN_STATUS
1834 EFIAPI
1835 SafeUint64ToUint8 (
1836 IN UINT64 Operand,
1837 OUT UINT8 *Result
1838 );
1839
1840 /**
1841 UINT64 -> INT16 conversion
1842
1843 Converts the value specified by Operand to a value specified by Result type
1844 and stores the converted value into the caller allocated output buffer
1845 specified by Result. The caller must pass in a Result buffer that is at
1846 least as large as the Result type.
1847
1848 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1849
1850 If the conversion results in an overflow or an underflow condition, then
1851 Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1852
1853 @param[in] Operand Operand to be converted to new type
1854 @param[out] Result Pointer to the result of conversion
1855
1856 @retval RETURN_SUCCESS Successful conversion
1857 @retval RETURN_BUFFER_TOO_SMALL Overflow
1858 @retval RETURN_INVALID_PARAMETER Result is NULL
1859 **/
1860 RETURN_STATUS
1861 EFIAPI
1862 SafeUint64ToInt16 (
1863 IN UINT64 Operand,
1864 OUT INT16 *Result
1865 );
1866
1867 /**
1868 UINT64 -> UINT16 conversion
1869
1870 Converts the value specified by Operand to a value specified by Result type
1871 and stores the converted value into the caller allocated output buffer
1872 specified by Result. The caller must pass in a Result buffer that is at
1873 least as large as the Result type.
1874
1875 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1876
1877 If the conversion results in an overflow or an underflow condition, then
1878 Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1879
1880 @param[in] Operand Operand to be converted to new type
1881 @param[out] Result Pointer to the result of conversion
1882
1883 @retval RETURN_SUCCESS Successful conversion
1884 @retval RETURN_BUFFER_TOO_SMALL Overflow
1885 @retval RETURN_INVALID_PARAMETER Result is NULL
1886 **/
1887 RETURN_STATUS
1888 EFIAPI
1889 SafeUint64ToUint16 (
1890 IN UINT64 Operand,
1891 OUT UINT16 *Result
1892 );
1893
1894 /**
1895 UINT64 -> INT32 conversion
1896
1897 Converts the value specified by Operand to a value specified by Result type
1898 and stores the converted value into the caller allocated output buffer
1899 specified by Result. The caller must pass in a Result buffer that is at
1900 least as large as the Result type.
1901
1902 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1903
1904 If the conversion results in an overflow or an underflow condition, then
1905 Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1906
1907 @param[in] Operand Operand to be converted to new type
1908 @param[out] Result Pointer to the result of conversion
1909
1910 @retval RETURN_SUCCESS Successful conversion
1911 @retval RETURN_BUFFER_TOO_SMALL Overflow
1912 @retval RETURN_INVALID_PARAMETER Result is NULL
1913 **/
1914 RETURN_STATUS
1915 EFIAPI
1916 SafeUint64ToInt32 (
1917 IN UINT64 Operand,
1918 OUT INT32 *Result
1919 );
1920
1921 /**
1922 UINT64 -> UINT32 conversion
1923
1924 Converts the value specified by Operand to a value specified by Result type
1925 and stores the converted value into the caller allocated output buffer
1926 specified by Result. The caller must pass in a Result buffer that is at
1927 least as large as the Result type.
1928
1929 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1930
1931 If the conversion results in an overflow or an underflow condition, then
1932 Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1933
1934 @param[in] Operand Operand to be converted to new type
1935 @param[out] Result Pointer to the result of conversion
1936
1937 @retval RETURN_SUCCESS Successful conversion
1938 @retval RETURN_BUFFER_TOO_SMALL Overflow
1939 @retval RETURN_INVALID_PARAMETER Result is NULL
1940 **/
1941 RETURN_STATUS
1942 EFIAPI
1943 SafeUint64ToUint32 (
1944 IN UINT64 Operand,
1945 OUT UINT32 *Result
1946 );
1947
1948 /**
1949 UINT64 -> INTN conversion
1950
1951 Converts the value specified by Operand to a value specified by Result type
1952 and stores the converted value into the caller allocated output buffer
1953 specified by Result. The caller must pass in a Result buffer that is at
1954 least as large as the Result type.
1955
1956 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1957
1958 If the conversion results in an overflow or an underflow condition, then
1959 Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1960
1961 @param[in] Operand Operand to be converted to new type
1962 @param[out] Result Pointer to the result of conversion
1963
1964 @retval RETURN_SUCCESS Successful conversion
1965 @retval RETURN_BUFFER_TOO_SMALL Overflow
1966 @retval RETURN_INVALID_PARAMETER Result is NULL
1967 **/
1968 RETURN_STATUS
1969 EFIAPI
1970 SafeUint64ToIntn (
1971 IN UINT64 Operand,
1972 OUT INTN *Result
1973 );
1974
1975 /**
1976 UINT64 -> UINTN conversion
1977
1978 Converts the value specified by Operand to a value specified by Result type
1979 and stores the converted value into the caller allocated output buffer
1980 specified by Result. The caller must pass in a Result buffer that is at
1981 least as large as the Result type.
1982
1983 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
1984
1985 If the conversion results in an overflow or an underflow condition, then
1986 Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
1987
1988 @param[in] Operand Operand to be converted to new type
1989 @param[out] Result Pointer to the result of conversion
1990
1991 @retval RETURN_SUCCESS Successful conversion
1992 @retval RETURN_BUFFER_TOO_SMALL Overflow
1993 @retval RETURN_INVALID_PARAMETER Result is NULL
1994 **/
1995 RETURN_STATUS
1996 EFIAPI
1997 SafeUint64ToUintn (
1998 IN UINT64 Operand,
1999 OUT UINTN *Result
2000 );
2001
2002 /**
2003 UINT64 -> INT64 conversion
2004
2005 Converts the value specified by Operand to a value specified by Result type
2006 and stores the converted value into the caller allocated output buffer
2007 specified by Result. The caller must pass in a Result buffer that is at
2008 least as large as the Result type.
2009
2010 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2011
2012 If the conversion results in an overflow or an underflow condition, then
2013 Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2014
2015 @param[in] Operand Operand to be converted to new type
2016 @param[out] Result Pointer to the result of conversion
2017
2018 @retval RETURN_SUCCESS Successful conversion
2019 @retval RETURN_BUFFER_TOO_SMALL Overflow
2020 @retval RETURN_INVALID_PARAMETER Result is NULL
2021 **/
2022 RETURN_STATUS
2023 EFIAPI
2024 SafeUint64ToInt64 (
2025 IN UINT64 Operand,
2026 OUT INT64 *Result
2027 );
2028
2029 //
2030 // Addition functions
2031 //
2032
2033 /**
2034 UINT8 addition
2035
2036 Performs the requested operation using the input parameters into a value
2037 specified by Result type and stores the converted value into the caller
2038 allocated output buffer specified by Result. The caller must pass in a
2039 Result buffer that is at least as large as the Result type.
2040
2041 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2042
2043 If the requested operation results in an overflow or an underflow condition,
2044 then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2045
2046 @param[in] Augend A number to which addend will be added
2047 @param[in] Addend A number to be added to another
2048 @param[out] Result Pointer to the result of addition
2049
2050 @retval RETURN_SUCCESS Successful addition
2051 @retval RETURN_BUFFER_TOO_SMALL Overflow
2052 @retval RETURN_INVALID_PARAMETER Result is NULL
2053 **/
2054 RETURN_STATUS
2055 EFIAPI
2056 SafeUint8Add (
2057 IN UINT8 Augend,
2058 IN UINT8 Addend,
2059 OUT UINT8 *Result
2060 );
2061
2062 /**
2063 UINT16 addition
2064
2065 Performs the requested operation using the input parameters into a value
2066 specified by Result type and stores the converted value into the caller
2067 allocated output buffer specified by Result. The caller must pass in a
2068 Result buffer that is at least as large as the Result type.
2069
2070 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2071
2072 If the requested operation results in an overflow or an underflow condition,
2073 then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2074
2075 @param[in] Augend A number to which addend will be added
2076 @param[in] Addend A number to be added to another
2077 @param[out] Result Pointer to the result of addition
2078
2079 @retval RETURN_SUCCESS Successful addition
2080 @retval RETURN_BUFFER_TOO_SMALL Overflow
2081 @retval RETURN_INVALID_PARAMETER Result is NULL
2082 **/
2083 RETURN_STATUS
2084 EFIAPI
2085 SafeUint16Add (
2086 IN UINT16 Augend,
2087 IN UINT16 Addend,
2088 OUT UINT16 *Result
2089 );
2090
2091 /**
2092 UINT32 addition
2093
2094 Performs the requested operation using the input parameters into a value
2095 specified by Result type and stores the converted value into the caller
2096 allocated output buffer specified by Result. The caller must pass in a
2097 Result buffer that is at least as large as the Result type.
2098
2099 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2100
2101 If the requested operation results in an overflow or an underflow condition,
2102 then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2103
2104 @param[in] Augend A number to which addend will be added
2105 @param[in] Addend A number to be added to another
2106 @param[out] Result Pointer to the result of addition
2107
2108 @retval RETURN_SUCCESS Successful addition
2109 @retval RETURN_BUFFER_TOO_SMALL Overflow
2110 @retval RETURN_INVALID_PARAMETER Result is NULL
2111 **/
2112 RETURN_STATUS
2113 EFIAPI
2114 SafeUint32Add (
2115 IN UINT32 Augend,
2116 IN UINT32 Addend,
2117 OUT UINT32 *Result
2118 );
2119
2120 /**
2121 UINTN addition
2122
2123 Performs the requested operation using the input parameters into a value
2124 specified by Result type and stores the converted value into the caller
2125 allocated output buffer specified by Result. The caller must pass in a
2126 Result buffer that is at least as large as the Result type.
2127
2128 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2129
2130 If the requested operation results in an overflow or an underflow condition,
2131 then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2132
2133 @param[in] Augend A number to which addend will be added
2134 @param[in] Addend A number to be added to another
2135 @param[out] Result Pointer to the result of addition
2136
2137 @retval RETURN_SUCCESS Successful addition
2138 @retval RETURN_BUFFER_TOO_SMALL Overflow
2139 @retval RETURN_INVALID_PARAMETER Result is NULL
2140 **/
2141 RETURN_STATUS
2142 EFIAPI
2143 SafeUintnAdd (
2144 IN UINTN Augend,
2145 IN UINTN Addend,
2146 OUT UINTN *Result
2147 );
2148
2149 /**
2150 UINT64 addition
2151
2152 Performs the requested operation using the input parameters into a value
2153 specified by Result type and stores the converted value into the caller
2154 allocated output buffer specified by Result. The caller must pass in a
2155 Result buffer that is at least as large as the Result type.
2156
2157 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2158
2159 If the requested operation results in an overflow or an underflow condition,
2160 then Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2161
2162 @param[in] Augend A number to which addend will be added
2163 @param[in] Addend A number to be added to another
2164 @param[out] Result Pointer to the result of addition
2165
2166 @retval RETURN_SUCCESS Successful addition
2167 @retval RETURN_BUFFER_TOO_SMALL Overflow
2168 @retval RETURN_INVALID_PARAMETER Result is NULL
2169 **/
2170 RETURN_STATUS
2171 EFIAPI
2172 SafeUint64Add (
2173 IN UINT64 Augend,
2174 IN UINT64 Addend,
2175 OUT UINT64 *Result
2176 );
2177
2178 //
2179 // Subtraction functions
2180 //
2181
2182 /**
2183 UINT8 subtraction
2184
2185 Performs the requested operation using the input parameters into a value
2186 specified by Result type and stores the converted value into the caller
2187 allocated output buffer specified by Result. The caller must pass in a
2188 Result buffer that is at least as large as the Result type.
2189
2190 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2191
2192 If the requested operation results in an overflow or an underflow condition,
2193 then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2194
2195 @param[in] Minuend A number from which another is to be subtracted.
2196 @param[in] Subtrahend A number to be subtracted from another
2197 @param[out] Result Pointer to the result of subtraction
2198
2199 @retval RETURN_SUCCESS Successful subtraction
2200 @retval RETURN_BUFFER_TOO_SMALL Underflow
2201 @retval RETURN_INVALID_PARAMETER Result is NULL
2202 **/
2203 RETURN_STATUS
2204 EFIAPI
2205 SafeUint8Sub (
2206 IN UINT8 Minuend,
2207 IN UINT8 Subtrahend,
2208 OUT UINT8 *Result
2209 );
2210
2211 /**
2212 UINT16 subtraction
2213
2214 Performs the requested operation using the input parameters into a value
2215 specified by Result type and stores the converted value into the caller
2216 allocated output buffer specified by Result. The caller must pass in a
2217 Result buffer that is at least as large as the Result type.
2218
2219 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2220
2221 If the requested operation results in an overflow or an underflow condition,
2222 then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2223
2224 @param[in] Minuend A number from which another is to be subtracted.
2225 @param[in] Subtrahend A number to be subtracted from another
2226 @param[out] Result Pointer to the result of subtraction
2227
2228 @retval RETURN_SUCCESS Successful subtraction
2229 @retval RETURN_BUFFER_TOO_SMALL Underflow
2230 @retval RETURN_INVALID_PARAMETER Result is NULL
2231 **/
2232 RETURN_STATUS
2233 EFIAPI
2234 SafeUint16Sub (
2235 IN UINT16 Minuend,
2236 IN UINT16 Subtrahend,
2237 OUT UINT16 *Result
2238 );
2239
2240 /**
2241 UINT32 subtraction
2242
2243 Performs the requested operation using the input parameters into a value
2244 specified by Result type and stores the converted value into the caller
2245 allocated output buffer specified by Result. The caller must pass in a
2246 Result buffer that is at least as large as the Result type.
2247
2248 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2249
2250 If the requested operation results in an overflow or an underflow condition,
2251 then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2252
2253 @param[in] Minuend A number from which another is to be subtracted.
2254 @param[in] Subtrahend A number to be subtracted from another
2255 @param[out] Result Pointer to the result of subtraction
2256
2257 @retval RETURN_SUCCESS Successful subtraction
2258 @retval RETURN_BUFFER_TOO_SMALL Underflow
2259 @retval RETURN_INVALID_PARAMETER Result is NULL
2260 **/
2261 RETURN_STATUS
2262 EFIAPI
2263 SafeUint32Sub (
2264 IN UINT32 Minuend,
2265 IN UINT32 Subtrahend,
2266 OUT UINT32 *Result
2267 );
2268
2269 /**
2270 UINTN subtraction
2271
2272 Performs the requested operation using the input parameters into a value
2273 specified by Result type and stores the converted value into the caller
2274 allocated output buffer specified by Result. The caller must pass in a
2275 Result buffer that is at least as large as the Result type.
2276
2277 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2278
2279 If the requested operation results in an overflow or an underflow condition,
2280 then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2281
2282 @param[in] Minuend A number from which another is to be subtracted.
2283 @param[in] Subtrahend A number to be subtracted from another
2284 @param[out] Result Pointer to the result of subtraction
2285
2286 @retval RETURN_SUCCESS Successful subtraction
2287 @retval RETURN_BUFFER_TOO_SMALL Underflow
2288 @retval RETURN_INVALID_PARAMETER Result is NULL
2289 **/
2290 RETURN_STATUS
2291 EFIAPI
2292 SafeUintnSub (
2293 IN UINTN Minuend,
2294 IN UINTN Subtrahend,
2295 OUT UINTN *Result
2296 );
2297
2298 /**
2299 UINT64 subtraction
2300
2301 Performs the requested operation using the input parameters into a value
2302 specified by Result type and stores the converted value into the caller
2303 allocated output buffer specified by Result. The caller must pass in a
2304 Result buffer that is at least as large as the Result type.
2305
2306 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2307
2308 If the requested operation results in an overflow or an underflow condition,
2309 then Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2310
2311 @param[in] Minuend A number from which another is to be subtracted.
2312 @param[in] Subtrahend A number to be subtracted from another
2313 @param[out] Result Pointer to the result of subtraction
2314
2315 @retval RETURN_SUCCESS Successful subtraction
2316 @retval RETURN_BUFFER_TOO_SMALL Underflow
2317 @retval RETURN_INVALID_PARAMETER Result is NULL
2318 **/
2319 RETURN_STATUS
2320 EFIAPI
2321 SafeUint64Sub (
2322 IN UINT64 Minuend,
2323 IN UINT64 Subtrahend,
2324 OUT UINT64 *Result
2325 );
2326
2327 //
2328 // Multiplication functions
2329 //
2330
2331 /**
2332 UINT8 multiplication
2333
2334 Performs the requested operation using the input parameters into a value
2335 specified by Result type and stores the converted value into the caller
2336 allocated output buffer specified by Result. The caller must pass in a
2337 Result buffer that is at least as large as the Result type.
2338
2339 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2340
2341 If the requested operation results in an overflow or an underflow condition,
2342 then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2343
2344 @param[in] Multiplicand A number that is to be multiplied by another
2345 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2346 @param[out] Result Pointer to the result of multiplication
2347
2348 @retval RETURN_SUCCESS Successful multiplication
2349 @retval RETURN_BUFFER_TOO_SMALL Overflow
2350 @retval RETURN_INVALID_PARAMETER Result is NULL
2351 **/
2352 RETURN_STATUS
2353 EFIAPI
2354 SafeUint8Mult (
2355 IN UINT8 Multiplicand,
2356 IN UINT8 Multiplier,
2357 OUT UINT8 *Result
2358 );
2359
2360 /**
2361 UINT16 multiplication
2362
2363 Performs the requested operation using the input parameters into a value
2364 specified by Result type and stores the converted value into the caller
2365 allocated output buffer specified by Result. The caller must pass in a
2366 Result buffer that is at least as large as the Result type.
2367
2368 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2369
2370 If the requested operation results in an overflow or an underflow condition,
2371 then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2372
2373 @param[in] Multiplicand A number that is to be multiplied by another
2374 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2375 @param[out] Result Pointer to the result of multiplication
2376
2377 @retval RETURN_SUCCESS Successful multiplication
2378 @retval RETURN_BUFFER_TOO_SMALL Overflow
2379 @retval RETURN_INVALID_PARAMETER Result is NULL
2380 **/
2381 RETURN_STATUS
2382 EFIAPI
2383 SafeUint16Mult (
2384 IN UINT16 Multiplicand,
2385 IN UINT16 Multiplier,
2386 OUT UINT16 *Result
2387 );
2388
2389 /**
2390 UINT32 multiplication
2391
2392 Performs the requested operation using the input parameters into a value
2393 specified by Result type and stores the converted value into the caller
2394 allocated output buffer specified by Result. The caller must pass in a
2395 Result buffer that is at least as large as the Result type.
2396
2397 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2398
2399 If the requested operation results in an overflow or an underflow condition,
2400 then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2401
2402 @param[in] Multiplicand A number that is to be multiplied by another
2403 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2404 @param[out] Result Pointer to the result of multiplication
2405
2406 @retval RETURN_SUCCESS Successful multiplication
2407 @retval RETURN_BUFFER_TOO_SMALL Overflow
2408 @retval RETURN_INVALID_PARAMETER Result is NULL
2409 **/
2410 RETURN_STATUS
2411 EFIAPI
2412 SafeUint32Mult (
2413 IN UINT32 Multiplicand,
2414 IN UINT32 Multiplier,
2415 OUT UINT32 *Result
2416 );
2417
2418 /**
2419 UINTN multiplication
2420
2421 Performs the requested operation using the input parameters into a value
2422 specified by Result type and stores the converted value into the caller
2423 allocated output buffer specified by Result. The caller must pass in a
2424 Result buffer that is at least as large as the Result type.
2425
2426 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2427
2428 If the requested operation results in an overflow or an underflow condition,
2429 then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2430
2431 @param[in] Multiplicand A number that is to be multiplied by another
2432 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2433 @param[out] Result Pointer to the result of multiplication
2434
2435 @retval RETURN_SUCCESS Successful multiplication
2436 @retval RETURN_BUFFER_TOO_SMALL Overflow
2437 @retval RETURN_INVALID_PARAMETER Result is NULL
2438 **/
2439 RETURN_STATUS
2440 EFIAPI
2441 SafeUintnMult (
2442 IN UINTN Multiplicand,
2443 IN UINTN Multiplier,
2444 OUT UINTN *Result
2445 );
2446
2447 /**
2448 UINT64 multiplication
2449
2450 Performs the requested operation using the input parameters into a value
2451 specified by Result type and stores the converted value into the caller
2452 allocated output buffer specified by Result. The caller must pass in a
2453 Result buffer that is at least as large as the Result type.
2454
2455 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2456
2457 If the requested operation results in an overflow or an underflow condition,
2458 then Result is set to UINT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2459
2460 @param[in] Multiplicand A number that is to be multiplied by another
2461 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2462 @param[out] Result Pointer to the result of multiplication
2463
2464 @retval RETURN_SUCCESS Successful multiplication
2465 @retval RETURN_BUFFER_TOO_SMALL Overflow
2466 @retval RETURN_INVALID_PARAMETER Result is NULL
2467 **/
2468 RETURN_STATUS
2469 EFIAPI
2470 SafeUint64Mult (
2471 IN UINT64 Multiplicand,
2472 IN UINT64 Multiplier,
2473 OUT UINT64 *Result
2474 );
2475
2476 //
2477 // Signed operations
2478 //
2479 // Strongly consider using unsigned numbers.
2480 //
2481 // Signed numbers are often used where unsigned numbers should be used.
2482 // For example file sizes and array indices should always be unsigned.
2483 // Subtracting a larger positive signed number from a smaller positive
2484 // signed number with SafeInt32Sub will succeed, producing a negative number,
2485 // that then must not be used as an array index (but can occasionally be
2486 // used as a pointer index.) Similarly for adding a larger magnitude
2487 // negative number to a smaller magnitude positive number.
2488 //
2489 // This library does not protect you from such errors. It tells you if your
2490 // integer operations overflowed, not if you are doing the right thing
2491 // with your non-overflowed integers.
2492 //
2493 // Likewise you can overflow a buffer with a non-overflowed unsigned index.
2494 //
2495
2496 //
2497 // Signed addition functions
2498 //
2499
2500 /**
2501 INT8 Addition
2502
2503 Performs the requested operation using the input parameters into a value
2504 specified by Result type and stores the converted value into the caller
2505 allocated output buffer specified by Result. The caller must pass in a
2506 Result buffer that is at least as large as the Result type.
2507
2508 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2509
2510 If the requested operation results in an overflow or an underflow condition,
2511 then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2512
2513 @param[in] Augend A number to which addend will be added
2514 @param[in] Addend A number to be added to another
2515 @param[out] Result Pointer to the result of addition
2516
2517 @retval RETURN_SUCCESS Successful addition
2518 @retval RETURN_BUFFER_TOO_SMALL Overflow
2519 @retval RETURN_INVALID_PARAMETER Result is NULL
2520 **/
2521 RETURN_STATUS
2522 EFIAPI
2523 SafeInt8Add (
2524 IN INT8 Augend,
2525 IN INT8 Addend,
2526 OUT INT8 *Result
2527 );
2528
2529 /**
2530 CHAR8 Addition
2531
2532 Performs the requested operation using the input parameters into a value
2533 specified by Result type and stores the converted value into the caller
2534 allocated output buffer specified by Result. The caller must pass in a
2535 Result buffer that is at least as large as the Result type.
2536
2537 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2538
2539 If the requested operation results in an overflow or an underflow condition,
2540 then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2541
2542 @param[in] Augend A number to which addend will be added
2543 @param[in] Addend A number to be added to another
2544 @param[out] Result Pointer to the result of addition
2545
2546 @retval RETURN_SUCCESS Successful addition
2547 @retval RETURN_BUFFER_TOO_SMALL Overflow
2548 @retval RETURN_INVALID_PARAMETER Result is NULL
2549 **/
2550 RETURN_STATUS
2551 EFIAPI
2552 SafeChar8Add (
2553 IN CHAR8 Augend,
2554 IN CHAR8 Addend,
2555 OUT CHAR8 *Result
2556 );
2557
2558 /**
2559 INT16 Addition
2560
2561 Performs the requested operation using the input parameters into a value
2562 specified by Result type and stores the converted value into the caller
2563 allocated output buffer specified by Result. The caller must pass in a
2564 Result buffer that is at least as large as the Result type.
2565
2566 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2567
2568 If the requested operation results in an overflow or an underflow condition,
2569 then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2570
2571 @param[in] Augend A number to which addend will be added
2572 @param[in] Addend A number to be added to another
2573 @param[out] Result Pointer to the result of addition
2574
2575 @retval RETURN_SUCCESS Successful addition
2576 @retval RETURN_BUFFER_TOO_SMALL Overflow
2577 @retval RETURN_INVALID_PARAMETER Result is NULL
2578 **/
2579 RETURN_STATUS
2580 EFIAPI
2581 SafeInt16Add (
2582 IN INT16 Augend,
2583 IN INT16 Addend,
2584 OUT INT16 *Result
2585 );
2586
2587 /**
2588 INT32 Addition
2589
2590 Performs the requested operation using the input parameters into a value
2591 specified by Result type and stores the converted value into the caller
2592 allocated output buffer specified by Result. The caller must pass in a
2593 Result buffer that is at least as large as the Result type.
2594
2595 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2596
2597 If the requested operation results in an overflow or an underflow condition,
2598 then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2599
2600 @param[in] Augend A number to which addend will be added
2601 @param[in] Addend A number to be added to another
2602 @param[out] Result Pointer to the result of addition
2603
2604 @retval RETURN_SUCCESS Successful addition
2605 @retval RETURN_BUFFER_TOO_SMALL Overflow
2606 @retval RETURN_INVALID_PARAMETER Result is NULL
2607 **/
2608 RETURN_STATUS
2609 EFIAPI
2610 SafeInt32Add (
2611 IN INT32 Augend,
2612 IN INT32 Addend,
2613 OUT INT32 *Result
2614 );
2615
2616 /**
2617 INTN Addition
2618
2619 Performs the requested operation using the input parameters into a value
2620 specified by Result type and stores the converted value into the caller
2621 allocated output buffer specified by Result. The caller must pass in a
2622 Result buffer that is at least as large as the Result type.
2623
2624 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2625
2626 If the requested operation results in an overflow or an underflow condition,
2627 then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2628
2629 @param[in] Augend A number to which addend will be added
2630 @param[in] Addend A number to be added to another
2631 @param[out] Result Pointer to the result of addition
2632
2633 @retval RETURN_SUCCESS Successful addition
2634 @retval RETURN_BUFFER_TOO_SMALL Overflow
2635 @retval RETURN_INVALID_PARAMETER Result is NULL
2636 **/
2637 RETURN_STATUS
2638 EFIAPI
2639 SafeIntnAdd (
2640 IN INTN Augend,
2641 IN INTN Addend,
2642 OUT INTN *Result
2643 );
2644
2645 /**
2646 INT64 Addition
2647
2648 Performs the requested operation using the input parameters into a value
2649 specified by Result type and stores the converted value into the caller
2650 allocated output buffer specified by Result. The caller must pass in a
2651 Result buffer that is at least as large as the Result type.
2652
2653 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2654
2655 If the requested operation results in an overflow or an underflow condition,
2656 then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2657
2658 @param[in] Augend A number to which addend will be added
2659 @param[in] Addend A number to be added to another
2660 @param[out] Result Pointer to the result of addition
2661
2662 @retval RETURN_SUCCESS Successful addition
2663 @retval RETURN_BUFFER_TOO_SMALL Overflow
2664 @retval RETURN_INVALID_PARAMETER Result is NULL
2665 **/
2666 RETURN_STATUS
2667 EFIAPI
2668 SafeInt64Add (
2669 IN INT64 Augend,
2670 IN INT64 Addend,
2671 OUT INT64 *Result
2672 );
2673
2674 //
2675 // Signed subtraction functions
2676 //
2677
2678 /**
2679 INT8 Subtraction
2680
2681 Performs the requested operation using the input parameters into a value
2682 specified by Result type and stores the converted value into the caller
2683 allocated output buffer specified by Result. The caller must pass in a
2684 Result buffer that is at least as large as the Result type.
2685
2686 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2687
2688 If the requested operation results in an overflow or an underflow condition,
2689 then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2690
2691 @param[in] Minuend A number from which another is to be subtracted.
2692 @param[in] Subtrahend A number to be subtracted from another
2693 @param[out] Result Pointer to the result of subtraction
2694
2695 @retval RETURN_SUCCESS Successful subtraction
2696 @retval RETURN_BUFFER_TOO_SMALL Underflow
2697 @retval RETURN_INVALID_PARAMETER Result is NULL
2698 **/
2699 RETURN_STATUS
2700 EFIAPI
2701 SafeInt8Sub (
2702 IN INT8 Minuend,
2703 IN INT8 Subtrahend,
2704 OUT INT8 *Result
2705 );
2706
2707 /**
2708 CHAR8 Subtraction
2709
2710 Performs the requested operation using the input parameters into a value
2711 specified by Result type and stores the converted value into the caller
2712 allocated output buffer specified by Result. The caller must pass in a
2713 Result buffer that is at least as large as the Result type.
2714
2715 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2716
2717 If the requested operation results in an overflow or an underflow condition,
2718 then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2719
2720 @param[in] Minuend A number from which another is to be subtracted.
2721 @param[in] Subtrahend A number to be subtracted from another
2722 @param[out] Result Pointer to the result of subtraction
2723
2724 @retval RETURN_SUCCESS Successful subtraction
2725 @retval RETURN_BUFFER_TOO_SMALL Underflow
2726 @retval RETURN_INVALID_PARAMETER Result is NULL
2727 **/
2728 RETURN_STATUS
2729 EFIAPI
2730 SafeChar8Sub (
2731 IN CHAR8 Minuend,
2732 IN CHAR8 Subtrahend,
2733 OUT CHAR8 *Result
2734 );
2735
2736 /**
2737 INT16 Subtraction
2738
2739 Performs the requested operation using the input parameters into a value
2740 specified by Result type and stores the converted value into the caller
2741 allocated output buffer specified by Result. The caller must pass in a
2742 Result buffer that is at least as large as the Result type.
2743
2744 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2745
2746 If the requested operation results in an overflow or an underflow condition,
2747 then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2748
2749 @param[in] Minuend A number from which another is to be subtracted.
2750 @param[in] Subtrahend A number to be subtracted from another
2751 @param[out] Result Pointer to the result of subtraction
2752
2753 @retval RETURN_SUCCESS Successful subtraction
2754 @retval RETURN_BUFFER_TOO_SMALL Underflow
2755 @retval RETURN_INVALID_PARAMETER Result is NULL
2756 **/
2757 RETURN_STATUS
2758 EFIAPI
2759 SafeInt16Sub (
2760 IN INT16 Minuend,
2761 IN INT16 Subtrahend,
2762 OUT INT16 *Result
2763 );
2764
2765 /**
2766 INT32 Subtraction
2767
2768 Performs the requested operation using the input parameters into a value
2769 specified by Result type and stores the converted value into the caller
2770 allocated output buffer specified by Result. The caller must pass in a
2771 Result buffer that is at least as large as the Result type.
2772
2773 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2774
2775 If the requested operation results in an overflow or an underflow condition,
2776 then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2777
2778 @param[in] Minuend A number from which another is to be subtracted.
2779 @param[in] Subtrahend A number to be subtracted from another
2780 @param[out] Result Pointer to the result of subtraction
2781
2782 @retval RETURN_SUCCESS Successful subtraction
2783 @retval RETURN_BUFFER_TOO_SMALL Underflow
2784 @retval RETURN_INVALID_PARAMETER Result is NULL
2785 **/
2786 RETURN_STATUS
2787 EFIAPI
2788 SafeInt32Sub (
2789 IN INT32 Minuend,
2790 IN INT32 Subtrahend,
2791 OUT INT32 *Result
2792 );
2793
2794 /**
2795 INTN Subtraction
2796
2797 Performs the requested operation using the input parameters into a value
2798 specified by Result type and stores the converted value into the caller
2799 allocated output buffer specified by Result. The caller must pass in a
2800 Result buffer that is at least as large as the Result type.
2801
2802 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2803
2804 If the requested operation results in an overflow or an underflow condition,
2805 then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2806
2807 @param[in] Minuend A number from which another is to be subtracted.
2808 @param[in] Subtrahend A number to be subtracted from another
2809 @param[out] Result Pointer to the result of subtraction
2810
2811 @retval RETURN_SUCCESS Successful subtraction
2812 @retval RETURN_BUFFER_TOO_SMALL Underflow
2813 @retval RETURN_INVALID_PARAMETER Result is NULL
2814 **/
2815 RETURN_STATUS
2816 EFIAPI
2817 SafeIntnSub (
2818 IN INTN Minuend,
2819 IN INTN Subtrahend,
2820 OUT INTN *Result
2821 );
2822
2823 /**
2824 INT64 Subtraction
2825
2826 Performs the requested operation using the input parameters into a value
2827 specified by Result type and stores the converted value into the caller
2828 allocated output buffer specified by Result. The caller must pass in a
2829 Result buffer that is at least as large as the Result type.
2830
2831 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2832
2833 If the requested operation results in an overflow or an underflow condition,
2834 then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2835
2836 @param[in] Minuend A number from which another is to be subtracted.
2837 @param[in] Subtrahend A number to be subtracted from another
2838 @param[out] Result Pointer to the result of subtraction
2839
2840 @retval RETURN_SUCCESS Successful subtraction
2841 @retval RETURN_BUFFER_TOO_SMALL Underflow
2842 @retval RETURN_INVALID_PARAMETER Result is NULL
2843 **/
2844 RETURN_STATUS
2845 EFIAPI
2846 SafeInt64Sub (
2847 IN INT64 Minuend,
2848 IN INT64 Subtrahend,
2849 OUT INT64 *Result
2850 );
2851
2852 //
2853 // Signed multiplication functions
2854 //
2855
2856 /**
2857 INT8 multiplication
2858
2859 Performs the requested operation using the input parameters into a value
2860 specified by Result type and stores the converted value into the caller
2861 allocated output buffer specified by Result. The caller must pass in a
2862 Result buffer that is at least as large as the Result type.
2863
2864 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2865
2866 If the requested operation results in an overflow or an underflow condition,
2867 then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2868
2869 @param[in] Multiplicand A number that is to be multiplied by another
2870 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2871 @param[out] Result Pointer to the result of multiplication
2872
2873 @retval RETURN_SUCCESS Successful multiplication
2874 @retval RETURN_BUFFER_TOO_SMALL Overflow
2875 @retval RETURN_INVALID_PARAMETER Result is NULL
2876 **/
2877 RETURN_STATUS
2878 EFIAPI
2879 SafeInt8Mult (
2880 IN INT8 Multiplicand,
2881 IN INT8 Multiplier,
2882 OUT INT8 *Result
2883 );
2884
2885 /**
2886 CHAR8 multiplication
2887
2888 Performs the requested operation using the input parameters into a value
2889 specified by Result type and stores the converted value into the caller
2890 allocated output buffer specified by Result. The caller must pass in a
2891 Result buffer that is at least as large as the Result type.
2892
2893 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2894
2895 If the requested operation results in an overflow or an underflow condition,
2896 then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2897
2898 @param[in] Multiplicand A number that is to be multiplied by another
2899 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2900 @param[out] Result Pointer to the result of multiplication
2901
2902 @retval RETURN_SUCCESS Successful multiplication
2903 @retval RETURN_BUFFER_TOO_SMALL Overflow
2904 @retval RETURN_INVALID_PARAMETER Result is NULL
2905 **/
2906 RETURN_STATUS
2907 EFIAPI
2908 SafeChar8Mult (
2909 IN CHAR8 Multiplicand,
2910 IN CHAR8 Multiplier,
2911 OUT CHAR8 *Result
2912 );
2913
2914 /**
2915 INT16 multiplication
2916
2917 Performs the requested operation using the input parameters into a value
2918 specified by Result type and stores the converted value into the caller
2919 allocated output buffer specified by Result. The caller must pass in a
2920 Result buffer that is at least as large as the Result type.
2921
2922 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2923
2924 If the requested operation results in an overflow or an underflow condition,
2925 then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2926
2927 @param[in] Multiplicand A number that is to be multiplied by another
2928 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2929 @param[out] Result Pointer to the result of multiplication
2930
2931 @retval RETURN_SUCCESS Successful multiplication
2932 @retval RETURN_BUFFER_TOO_SMALL Overflow
2933 @retval RETURN_INVALID_PARAMETER Result is NULL
2934 **/
2935 RETURN_STATUS
2936 EFIAPI
2937 SafeInt16Mult (
2938 IN INT16 Multiplicand,
2939 IN INT16 Multiplier,
2940 OUT INT16 *Result
2941 );
2942
2943 /**
2944 INT32 multiplication
2945
2946 Performs the requested operation using the input parameters into a value
2947 specified by Result type and stores the converted value into the caller
2948 allocated output buffer specified by Result. The caller must pass in a
2949 Result buffer that is at least as large as the Result type.
2950
2951 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2952
2953 If the requested operation results in an overflow or an underflow condition,
2954 then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2955
2956 @param[in] Multiplicand A number that is to be multiplied by another
2957 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2958 @param[out] Result Pointer to the result of multiplication
2959
2960 @retval RETURN_SUCCESS Successful multiplication
2961 @retval RETURN_BUFFER_TOO_SMALL Overflow
2962 @retval RETURN_INVALID_PARAMETER Result is NULL
2963 **/
2964 RETURN_STATUS
2965 EFIAPI
2966 SafeInt32Mult (
2967 IN INT32 Multiplicand,
2968 IN INT32 Multiplier,
2969 OUT INT32 *Result
2970 );
2971
2972 /**
2973 INTN multiplication
2974
2975 Performs the requested operation using the input parameters into a value
2976 specified by Result type and stores the converted value into the caller
2977 allocated output buffer specified by Result. The caller must pass in a
2978 Result buffer that is at least as large as the Result type.
2979
2980 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
2981
2982 If the requested operation results in an overflow or an underflow condition,
2983 then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
2984
2985 @param[in] Multiplicand A number that is to be multiplied by another
2986 @param[in] Multiplier A number by which the multiplicand is to be multiplied
2987 @param[out] Result Pointer to the result of multiplication
2988
2989 @retval RETURN_SUCCESS Successful multiplication
2990 @retval RETURN_BUFFER_TOO_SMALL Overflow
2991 @retval RETURN_INVALID_PARAMETER Result is NULL
2992 **/
2993 RETURN_STATUS
2994 EFIAPI
2995 SafeIntnMult (
2996 IN INTN Multiplicand,
2997 IN INTN Multiplier,
2998 OUT INTN *Result
2999 );
3000
3001 /**
3002 INT64 multiplication
3003
3004 Performs the requested operation using the input parameters into a value
3005 specified by Result type and stores the converted value into the caller
3006 allocated output buffer specified by Result. The caller must pass in a
3007 Result buffer that is at least as large as the Result type.
3008
3009 If Result is NULL, RETURN_INVALID_PARAMETER is returned.
3010
3011 If the requested operation results in an overflow or an underflow condition,
3012 then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
3013
3014 @param[in] Multiplicand A number that is to be multiplied by another
3015 @param[in] Multiplier A number by which the multiplicand is to be multiplied
3016 @param[out] Result Pointer to the result of multiplication
3017
3018 @retval RETURN_SUCCESS Successful multiplication
3019 @retval RETURN_BUFFER_TOO_SMALL Overflow
3020 @retval RETURN_INVALID_PARAMETER Result is NULL
3021 **/
3022 RETURN_STATUS
3023 EFIAPI
3024 SafeInt64Mult (
3025 IN INT64 Multiplicand,
3026 IN INT64 Multiplier,
3027 OUT INT64 *Result
3028 );
3029
3030 #endif // __INT_SAFE_LIB_H__