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