• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  * Copyright (C) 2016 Mopria Alliance, Inc.
4  * Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
5  *
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  */
18 #ifndef __WTYPES_H__
19 #define __WTYPES_H__
20 
21 #include <stddef.h>
22 #include <stdbool.h>
23 
24 /*
25  * A return type for functions.
26  */
27 typedef enum {
28     /* Request succeeded */
29     OK = 0,
30 
31     /* Request failed due to an unspecified error */
32     ERROR = -1,
33 
34     /* Request failed because it was cancelled */
35     CANCELLED = -2,
36 
37     /* Request failed because corrupt data was detected */
38     CORRUPT = -3,
39 } status_t;
40 
41 #define ARRAY_SIZE(X) (sizeof(X)/sizeof(X[0]))
42 
43 #ifndef MIN
44 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
45 #endif
46 
47 #ifndef MAX
48 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
49 #endif
50 
51 /*
52  * Return a the pointer of an enclosing structure from the address of one of its members, where
53  * "class" is the enclosing structure type, "member" is the name of structure member, and
54  * "pointer" is that member's pointer.
55  */
56 #define IMPL(class, member, pointer) ( (class *)( ((uint32)pointer) - offsetof(class, member) ) )
57 
58 typedef unsigned char ubyte;
59 typedef unsigned char uint8;
60 typedef unsigned short uint16;
61 typedef signed short sint16;
62 typedef signed long sint32;
63 typedef unsigned long uint32;
64 typedef unsigned long long uint64;
65 
66 /** A job handle */
67 typedef unsigned long wJob_t;
68 
69 #endif // __WTYPES_H__