Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b613e0d authored by Adrian Ratiu's avatar Adrian Ratiu
Browse files

osi: compat: fix build with glibc >= 2.38

Starting with version 2.38, glibc is providing its own
definition and implementation for the strlcpy fun.

Therefore we add a test to avoid redefining it in floss
if glibc > 2.38.

This is required so we can upgrade CrOS to glibc 2.39.

Bug: 324437695
Test: mma -j32
Flags: Execption, trivial
Change-Id: I22fd00470db03b183e20469fdc382e61e6d99985
parent dfc6602d
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -28,7 +28,10 @@
/* Get thread identification. */
/* Get thread identification. */
pid_t gettid(void) throw();
pid_t gettid(void) throw();


/* glibc>=2.38 supplies its own strlcpy which conflicts with this declaration */
#if !(__GLIBC_PREREQ(2, 38))
/* Copy src to string dst of size siz. */
/* Copy src to string dst of size siz. */
size_t strlcpy(char* dst, const char* src, size_t siz);
size_t strlcpy(char* dst, const char* src, size_t siz);
#endif /* !(__GLIBC_PREREQ(2, 38)) */


#endif
#endif
+6 −3
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@


#if __GLIBC__
#if __GLIBC__
pid_t gettid(void) throw() { return syscall(SYS_gettid); }
pid_t gettid(void) throw() { return syscall(SYS_gettid); }
#endif


/* These functions from bionic
/* These functions from bionic
 *
 *
@@ -56,7 +55,10 @@ pid_t gettid(void) throw() { return syscall(SYS_gettid); }
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
 */


#if __GLIBC__
/*
 * Glibc added strlcpy() starting with 2.38, so skip it if glibc >= 2.38.
 */
#if !(__GLIBC_PREREQ(2, 38))
/*
/*
 * Copy src to string dst of size siz.  At most siz-1 characters
 * Copy src to string dst of size siz.  At most siz-1 characters
 * will be copied.  Always NUL terminates (unless siz == 0).
 * will be copied.  Always NUL terminates (unless siz == 0).
@@ -87,4 +89,5 @@ size_t strlcpy(char* dst, const char* src, size_t siz) {


  return s - src - 1; /* count does not include NUL */
  return s - src - 1; /* count does not include NUL */
}
}
#endif
#endif /* !(__GLIBC_PREREQ(2, 38)) */
#endif /* __GLIBC__ */