4 * Copyright 2001-2009 Texas Instruments, Inc. - http://www.ti.com/
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 /****************************************************************************/
21 /* MODULE: cu_osapi.h */
24 /****************************************************************************/
28 #include "cu_ostypes.h"
36 #define OSAL_SUCCESS 0
37 #define OSAL_FAILURE 1
38 #define OS_GETINPUTSTRING_CONTINUE TRUE+1
41 #define max(a,b) ((a>b)?a:b)
43 /* replaces IFNAMSIZ in Linux */
44 #define IF_NAME_SIZE 16
47 * TODO : supp declares its OS abstarction with primitive types, so these must
48 * be specifically declared here, and only if they weren't defined before by someone
52 typedef unsigned char u8;
53 typedef unsigned short u16;
54 typedef unsigned long u32;
55 typedef unsigned long long u64;
58 #define BIT(x) (1 << (x))
74 enum { CU_MSG_DEBUG, CU_MSG_INFO1, CU_MSG_WARNING, CU_MSG_ERROR, CU_MSG_INFO2};
76 /****************************************************************************************
78 ****************************************************************************************/
79 PVOID os_MemoryCAlloc(U32 Number, U32 Size);
80 PVOID os_MemoryAlloc(U32 Size);
81 VOID os_MemoryFree(PVOID pMemPtr);
82 PVOID os_memset(PVOID s, U8 c, U32 n);
83 PVOID os_memcpy(PVOID dest, const PVOID src, U32 n);
84 S32 os_memcmp(const PVOID s1, const PVOID s2, S32 n);
86 /****************************************************************************************
88 ****************************************************************************************/
89 PVOID os_fopen (const PS8 path, os_fopen_mode_e mode);
90 S32 os_fclose (PVOID stream);
91 S32 os_getFileSize (PVOID file);
92 PS8 os_fgets (PS8 s, S32 size, PVOID stream);
93 S32 os_fread (PVOID ptr, S32 size, S32 nmemb, PVOID stream);
94 S32 os_fwrite (PVOID ptr, S32 size, S32 nmemb, PVOID stream);
96 /****************************************************************************************
98 ****************************************************************************************/
99 PS8 os_strcpy(PS8 dest, const PS8 src);
100 PS8 os_strncpy(PS8 dest, const PS8 src, S32 n);
101 S32 os_strcmp(const PS8 s1, const PS8 s2);
102 S32 os_strncmp(const PS8 s1, const PS8 s2, U32 n);
103 S32 os_sscanf(const PS8 str, const PS8 format, ...);
104 S32 os_sprintf(PS8 str, const PS8 format, ...);
105 PS8 os_strcat(PS8 dest, const PS8 src);
106 U32 os_strlen(const PS8 s);
107 PS8 os_strchr(const PS8 s, S32 c);
108 S32 os_strtol(const PS8 nptr, PPS8 endptr, S32 base);
109 U32 os_strtoul(const PS8 nptr, PPS8 endptr, S32 base);
110 S32 os_tolower(S32 c);
111 S32 os_isupper(S32 c);
112 S32 os_toupper(S32 c);
113 S32 os_atoi(const PS8 str);
115 /****************************************************************************************
117 ****************************************************************************************/
118 S32 os_Printf(const PS8 buffer);
119 VOID os_error_printf(S32 debug_level, const PS8 arg_list ,...);
121 /****************************************************************************************
122 * Miscelanous OS API *
123 ****************************************************************************************/
124 S32 os_getInputString(PS8 inbuf, S32 len);
125 VOID os_Catch_CtrlC_Signal(PVOID SignalCB);
127 VOID os_OsSpecificCmdParams(S32 argc, PS8* argv);
128 VOID os_InitOsSpecificModules(VOID);
129 VOID os_DeInitOsSpecificModules(VOID);
130 TI_SIZE_T os_get_last_error(VOID);
132 #endif /* _CUOSAPI_H_ */