1 /*
2  * Copyright (c) 2021 Nordic Semiconductor
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief socket types definitionis
10  */
11 
12 #ifndef ZEPHYR_INCLUDE_NET_SOCKET_TYPES_H_
13 #define ZEPHYR_INCLUDE_NET_SOCKET_TYPES_H_
14 
15 /**
16  * @brief BSD Sockets compatible API
17  * @defgroup bsd_sockets BSD Sockets compatible API
18  * @ingroup networking
19  * @{
20  */
21 
22 #include <zephyr/types.h>
23 
24 /** @cond INTERNAL_HIDDEN */
25 
26 #ifdef CONFIG_NEWLIB_LIBC
27 
28 #include <newlib.h>
29 
30 #ifdef __NEWLIB__
31 #include <sys/_timeval.h>
32 #else /* __NEWLIB__ */
33 #include <sys/types.h>
34 /* workaround for older Newlib 2.x, as it lacks sys/_timeval.h */
35 struct timeval {
36 	time_t tv_sec;
37 	suseconds_t tv_usec;
38 };
39 #endif /* __NEWLIB__ */
40 
41 #else /* CONFIG_NEWLIB_LIBC */
42 
43 #if defined(CONFIG_ARCH_POSIX) && defined(CONFIG_EXTERNAL_LIBC)
44 #include <bits/types/struct_timeval.h>
45 #else
46 #include <sys/_timeval.h>
47 #endif
48 
49 #endif /* CONFIG_NEWLIB_LIBC */
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 #define zsock_timeval timeval
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 /** @endcond */
62 
63 /**
64  * @}
65  */
66 
67 #endif /* ZEPHYR_INCLUDE_NET_SOCKET_TYPES_H_ */
68