Skip to content

Commit

Permalink
BUILD: Fix compilation on later glibc versions
Browse files Browse the repository at this point in the history
strlcat/strlcpy added to glibc 2.38
  • Loading branch information
meag committed Dec 11, 2023
1 parent edf58af commit 8065129
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/qtv.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,14 @@ int qvsnprintf(char *buffer, size_t count, const char *format, va_list argptr);

#endif

#if defined(__linux__) || defined(_WIN32) || defined(__CYGWIN__)
#if defined(__linux__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
#if __GLIBC__ < 2 || __GLIBC_MINOR__ < 38
#define QTV_NEED_BSD_CPY_FUNCTIONS
size_t strlcpy(char* dst, const char* src, size_t siz);
size_t strlcat(char* dst, char* src, size_t siz);
#endif
#elif defined(__linux__) || defined(_WIN32) || defined(__CYGWIN__)
#define QTV_NEED_BSD_CPY_FUNCTIONS
size_t strlcpy (char *dst, const char *src, size_t siz);
size_t strlcat (char *dst, char *src, size_t siz);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int strendswith(const char *s1, const char *s2)
return strcmp(s1 + (len1 - len2), s2);
}

#if defined(__linux__) || defined(_WIN32) || defined(__CYGWIN__)
#ifdef QTV_NEED_BSD_CPY_FUNCTIONS

/*
* Functions strlcpy, strlcat
Expand Down Expand Up @@ -130,7 +130,7 @@ size_t strlcat(char *dst, char *src, size_t siz)
return(dlen + (s - src)); /* count does not include NUL */
}

#endif // defined(__linux__) || defined(_WIN32) || defined(__CYGWIN__)
#endif // defined(QTV_NEED_BSD_CPY_FUNCTIONS)

ullong Sys_Milliseconds(void)
{
Expand Down

0 comments on commit 8065129

Please sign in to comment.