/**
 03/10/2011
 Jaroslaw Wojtasik

 noCuda

 errors.c
 **/

#include "errors.cuh"
#include <stdio.h>

//==============================================
//== Globals

static ErrorCode gCurrError;

//==============================================
//== Functions

/*
 * Sets Error code to be retrived as the last one.
 */
ErrorCode SetLastErrorCode( ErrorCode error ) {
	gCurrError = error;
	return gCurrError;
}

/*
 * Returns the last set error code.
 */
ErrorCode GetLastErrorCode( void ) {
	return gCurrError;
}

char * ErrorDesc( ErrorCode errorType ) {
	char * res = NULL;
	switch ( errorType ) {
		case errOk: {
			res = "No Error";
		} break;
		case errGeneral: {
			res = "General Error";
		} break;
		case errFileNotFound: {
			res = "File Not Found";
		} break;
		case errFileCorupted: {
			res = "File Corupted";
		} break;
		case errFileWrite: {
			res = "File Write Error"; 
		} break;
		case errFileRead: {
			res = "File Read Error";
		} break;
		case errNoMemory: {
			res = "Out Of Memory";
		} break;
		case errDataNotReady: {
			res = "Data Not Ready";
		} break;
		case errNoData: {
			res = "No Data";
		} break;
		default: {
			res = "Unknown Error";
		}
	} // switch

	return res;
}

	.file	"tmpxft_0037a881_00000000-6_errors.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z16SetLastErrorCode9ErrorCode
	.type	_Z16SetLastErrorCode9ErrorCode, @function
_Z16SetLastErrorCode9ErrorCode:
.LFB2027:
	.cfi_startproc
	endbr64
	movl	%edi, _ZL10gCurrError(%rip)
	movl	%edi, %eax
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z16SetLastErrorCode9ErrorCode, .-_Z16SetLastErrorCode9ErrorCode
	.globl	_Z16GetLastErrorCodev
	.type	_Z16GetLastErrorCodev, @function
_Z16GetLastErrorCodev:
.LFB2028:
	.cfi_startproc
	endbr64
	movl	_ZL10gCurrError(%rip), %eax
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z16GetLastErrorCodev, .-_Z16GetLastErrorCodev
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"No Error"
.LC1:
	.string	"General Error"
.LC2:
	.string	"File Not Found"
.LC3:
	.string	"File Corupted"
.LC4:
	.string	"File Write Error"
.LC5:
	.string	"File Read Error"
.LC6:
	.string	"Out Of Memory"
.LC7:
	.string	"Data Not Ready"
.LC8:
	.string	"No Data"
.LC9:
	.string	"Unknown Error"
	.text
	.globl	_Z9ErrorDesc9ErrorCode
	.type	_Z9ErrorDesc9ErrorCode, @function
_Z9ErrorDesc9ErrorCode:
.LFB2029:
	.cfi_startproc
	endbr64
	cmpl	$9, %edi
	ja	.L5
	leaq	.L7(%rip), %rdx
	movl	%edi, %edi
	movslq	(%rdx,%rdi,4), %rax
	addq	%rdx, %rax
	notrack jmp	*%rax
	.section	.rodata
	.align 4
	.align 4
.L7:
	.long	.L15-.L7
	.long	.L16-.L7
	.long	.L13-.L7
	.long	.L12-.L7
	.long	.L11-.L7
	.long	.L10-.L7
	.long	.L9-.L7
	.long	.L8-.L7
	.long	.L5-.L7
	.long	.L6-.L7
	.text
.L15:
	leaq	.LC0(%rip), %rax
	ret
.L13:
	leaq	.LC2(%rip), %rax
	ret
.L12:
	leaq	.LC3(%rip), %rax
	ret
.L11:
	leaq	.LC4(%rip), %rax
	ret
.L10:
	leaq	.LC5(%rip), %rax
	ret
.L9:
	leaq	.LC6(%rip), %rax
	ret
.L8:
	leaq	.LC7(%rip), %rax
	ret
.L6:
	leaq	.LC8(%rip), %rax
	ret
.L5:
	leaq	.LC9(%rip), %rax
	ret
.L16:
	leaq	.LC1(%rip), %rax
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z9ErrorDesc9ErrorCode, .-_Z9ErrorDesc9ErrorCode
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2055:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZL10gCurrError
	.comm	_ZL10gCurrError,4,4
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

/**
 03/10/2011
 Jaroslaw Wojtasik

 noCuda

 errors.c
 **/


#include <hip/hip_runtime.h>
#include "errors.cuh"
#include <stdio.h>

//==============================================
//== Globals

static ErrorCode gCurrError;

//==============================================
//== Functions

/*
 * Sets Error code to be retrived as the last one.
 */
ErrorCode SetLastErrorCode( ErrorCode error ) {
	gCurrError = error;
	return gCurrError;
}

/*
 * Returns the last set error code.
 */
ErrorCode GetLastErrorCode( void ) {
	return gCurrError;
}

char * ErrorDesc( ErrorCode errorType ) {
	char * res = NULL;
	switch ( errorType ) {
		case errOk: {
			res = "No Error";
		} break;
		case errGeneral: {
			res = "General Error";
		} break;
		case errFileNotFound: {
			res = "File Not Found";
		} break;
		case errFileCorupted: {
			res = "File Corupted";
		} break;
		case errFileWrite: {
			res = "File Write Error"; 
		} break;
		case errFileRead: {
			res = "File Read Error";
		} break;
		case errNoMemory: {
			res = "Out Of Memory";
		} break;
		case errDataNotReady: {
			res = "Data Not Ready";
		} break;
		case errNoData: {
			res = "No Data";
		} break;
		default: {
			res = "Unknown Error";
		}
	} // switch

	return res;
}

	.text
	.file	"errors.hip"
	.globl	_Z16SetLastErrorCode9ErrorCode  # -- Begin function _Z16SetLastErrorCode9ErrorCode
	.type	_Z16SetLastErrorCode9ErrorCode,@function
_Z16SetLastErrorCode9ErrorCode:         # @_Z16SetLastErrorCode9ErrorCode
	.cfi_startproc
# %bb.0:
	movl	%edi, %eax
	movl	%edi, _ZL10gCurrError(%rip)
	retq
.Lfunc_end0:
	.size	_Z16SetLastErrorCode9ErrorCode, .Lfunc_end0-_Z16SetLastErrorCode9ErrorCode
	.cfi_endproc
                                        # -- End function
	.globl	_Z16GetLastErrorCodev           # -- Begin function _Z16GetLastErrorCodev
	.type	_Z16GetLastErrorCodev,@function
_Z16GetLastErrorCodev:                  # @_Z16GetLastErrorCodev
	.cfi_startproc
# %bb.0:
	movl	_ZL10gCurrError(%rip), %eax
	retq
.Lfunc_end1:
	.size	_Z16GetLastErrorCodev, .Lfunc_end1-_Z16GetLastErrorCodev
	.cfi_endproc
                                        # -- End function
	.globl	_Z9ErrorDesc9ErrorCode          # -- Begin function _Z9ErrorDesc9ErrorCode
	.type	_Z9ErrorDesc9ErrorCode,@function
_Z9ErrorDesc9ErrorCode:                 # @_Z9ErrorDesc9ErrorCode
	.cfi_startproc
# %bb.0:
	movl	$.L.str.9, %eax
	cmpl	$9, %edi
	ja	.LBB2_2
# %bb.1:                                # %switch.lookup
	movl	%edi, %eax
	movq	.Lswitch.table._Z9ErrorDesc9ErrorCode(,%rax,8), %rax
.LBB2_2:
	retq
.Lfunc_end2:
	.size	_Z9ErrorDesc9ErrorCode, .Lfunc_end2-_Z9ErrorDesc9ErrorCode
	.cfi_endproc
                                        # -- End function
	.type	_ZL10gCurrError,@object         # @_ZL10gCurrError
	.local	_ZL10gCurrError
	.comm	_ZL10gCurrError,4,4
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"No Error"
	.size	.L.str, 9

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"General Error"
	.size	.L.str.1, 14

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"File Not Found"
	.size	.L.str.2, 15

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"File Corupted"
	.size	.L.str.3, 14

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"File Write Error"
	.size	.L.str.4, 17

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"File Read Error"
	.size	.L.str.5, 16

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Out Of Memory"
	.size	.L.str.6, 14

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Data Not Ready"
	.size	.L.str.7, 15

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"No Data"
	.size	.L.str.8, 8

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Unknown Error"
	.size	.L.str.9, 14

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lswitch.table._Z9ErrorDesc9ErrorCode,@object # @switch.table._Z9ErrorDesc9ErrorCode
	.section	.rodata,"a",@progbits
	.p2align	3, 0x0
.Lswitch.table._Z9ErrorDesc9ErrorCode:
	.quad	.L.str
	.quad	.L.str.1
	.quad	.L.str.2
	.quad	.L.str.3
	.quad	.L.str.4
	.quad	.L.str.5
	.quad	.L.str.6
	.quad	.L.str.7
	.quad	.L.str.9
	.quad	.L.str.8
	.size	.Lswitch.table._Z9ErrorDesc9ErrorCode, 80

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
