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 
40     /* Request failed because unexpected ssl certificate received */
41     BAD_CERTIFICATE = -4
42 } status_t;
43 
44 #define ARRAY_SIZE(X) (sizeof(X)/sizeof(X[0]))
45 
46 #ifndef MIN
47 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
48 #endif
49 
50 #ifndef MAX
51 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
52 #endif
53 
54 /*
55  * Return a the pointer of an enclosing structure from the address of one of its members, where
56  * "class" is the enclosing structure type, "member" is the name of structure member, and
57  * "pointer" is that member's pointer.
58  */
59 #define IMPL(class, member, pointer) ( (class *)( ((uint32)pointer) - offsetof(class, member) ) )
60 
61 typedef unsigned char ubyte;
62 typedef unsigned char uint8;
63 typedef unsigned short uint16;
64 typedef signed short sint16;
65 typedef signed long sint32;
66 typedef unsigned long uint32;
67 typedef unsigned long long uint64;
68 
69 /** A job handle */
70 typedef unsigned long wJob_t;
71 
72 #endif // __WTYPES_H__