@@ -216,7 +216,7 @@ struct timeval {
216
216
long tv_usec ; /* microseconds */
217
217
};
218
218
219
- unsigned long timeval_to_jiffies (const struct timeval * tv )
219
+ static inline unsigned long timeval_to_jiffies (const struct timeval * tv )
220
220
{
221
221
return timespec64_to_jiffies (& (struct timespec64 ){
222
222
tv -> tv_sec ,
@@ -225,6 +225,20 @@ unsigned long timeval_to_jiffies(const struct timeval *tv)
225
225
}
226
226
#endif
227
227
228
+ #ifndef HAVE_STRLCPY
229
+ static inline size_t strlcpy (char * dest , const char * src , size_t size )
230
+ {
231
+ size_t ret = strlen (src );
232
+
233
+ if (size ) {
234
+ size_t len = (ret >= size ) ? size - 1 : ret ;
235
+ __builtin_memcpy (dest , src , len );
236
+ dest [len ] = '\0' ;
237
+ }
238
+ return ret ;
239
+ }
240
+ #endif
241
+
228
242
#if LINUX_VERSION_CODE < KERNEL_VERSION (2 ,6 ,35 )
229
243
# ifdef ktime_to_timeval
230
244
/* ktime_to_timeval is defined on 64bit and inline on 32bit cpu */
@@ -380,10 +394,10 @@ static int sockaddr_cmp(const struct sockaddr_storage *sa1, const struct sockadd
380
394
return 0 ;
381
395
}
382
396
383
- #ifndef IN6PTON_XDIGIT
397
+ #ifndef HAVE_IN6_PTON
384
398
#define hex_to_bin compat_hex_to_bin
385
399
/* lib/hexdump.c */
386
- int hex_to_bin (char ch )
400
+ static inline int hex_to_bin (char ch )
387
401
{
388
402
if ((ch >= '0' ) && (ch <= '9' ))
389
403
return ch - '0' ;
@@ -593,7 +607,7 @@ int in6_pton(const char *src, int srclen,
593
607
* end = s ;
594
608
return ret ;
595
609
}
596
- #endif /* IN6PTON_XDIGIT */
610
+ #endif /* HAVE_IN6_PTON */
597
611
598
612
#if LINUX_VERSION_CODE >= KERNEL_VERSION (4 ,2 ,0 )
599
613
# define sock_create_kern (f , t , p , s ) sock_create_kern(&init_net, f, t, p, s)
@@ -712,40 +726,6 @@ static inline void do_gettimeofday(struct timeval *tv)
712
726
}
713
727
#endif
714
728
715
- #define TOLOWER (x ) ((x) | 0x20)
716
- unsigned long long strtoul (const char * cp , char * * endp , unsigned int base )
717
- {
718
- unsigned long long result = 0 ;
719
-
720
- if (!base ) {
721
- if (cp [0 ] == '0' ) {
722
- if (TOLOWER (cp [1 ]) == 'x' && isxdigit (cp [2 ]))
723
- base = 16 ;
724
- else
725
- base = 8 ;
726
- } else {
727
- base = 10 ;
728
- }
729
- }
730
-
731
- if (base == 16 && cp [0 ] == '0' && TOLOWER (cp [1 ]) == 'x' )
732
- cp += 2 ;
733
-
734
- while (isxdigit (* cp )) {
735
- unsigned int value ;
736
-
737
- value = isdigit (* cp ) ? * cp - '0' : TOLOWER (* cp ) - 'a' + 10 ;
738
- if (value >= base )
739
- break ;
740
- result = result * base + value ;
741
- cp ++ ;
742
- }
743
- if (endp )
744
- * endp = (char * )cp ;
745
-
746
- return result ;
747
- }
748
-
749
729
#if LINUX_VERSION_CODE >= KERNEL_VERSION (5 ,12 ,0 )
750
730
/*
751
731
* find_module() is unexported in v5.12:
0 commit comments