]> git.sesse.net Git - vlc/blob - src/misc/linux_specific.c
Blacklist glibc 2.10-2.10.1 for 686
[vlc] / src / misc / linux_specific.c
1 /*****************************************************************************
2  * linux_specific.c: Linux-specific initialization
3  *****************************************************************************
4  * Copyright © 2008 Rémi Denis-Courmont
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
24
25 #include <stdio.h>
26 #include <string.h>
27 #include <sys/stat.h>
28
29 #include <vlc_common.h>
30 #include "../libvlc.h"
31
32 #if 0
33 #include <assert.h>
34 #include <pthread.h>
35
36 static void set_libvlc_path (void)
37 {
38     static char libvlc_path[PATH_MAX];
39
40     assert (strlen (LIBDIR) < sizeof (libvlc_path));
41     strcpy (libvlc_path, LIBDIR); /* fail safe */
42     psz_vlcpath = libvlc_path;
43
44     /* Find the path to libvlc (i.e. ourselves) */
45     FILE *maps = fopen ("/proc/self/maps", "rt");
46     if (maps == NULL)
47         return;
48
49     for (;;)
50     {
51         char buf[5000], *dir, *end;
52
53         if (fgets (buf, sizeof (buf), maps) == NULL)
54             break;
55
56         dir = strchr (buf, '/');
57         if (dir == NULL)
58             continue;
59         end = strrchr (dir, '/');
60         if (end == NULL)
61             continue;
62         if (strncmp (end + 1, "libvlc.so.", 10))
63             continue;
64
65         *end = '\0';
66         printf ("libvlc at %s\n", dir);
67         if (strlen (dir) < sizeof (libvlc_path))
68             strcpy (libvlc_path, dir);
69         break;
70     }
71
72     fclose (maps);
73 }
74 #endif
75
76 #ifdef __GLIBC__
77 # include <gnu/libc-version.h>
78 # include <stdlib.h>
79 #endif
80
81 void system_Init (libvlc_int_t *libvlc, int *argc, const char *argv[])
82 {
83 #ifdef __GLIBC__
84     const char *glcv = gnu_get_libc_version ();
85
86     /* gettext in glibc 2.5-2.7 is not thread-safe. LibVLC keeps crashing,
87      * especially in sterror_r(). Even if we have NLS disabled, the calling
88      * process might have called setlocale(). */
89     if (strverscmp (glcv, "2.5") >= 0 && strverscmp (glcv, "2.8") < 0)
90     {
91         fputs ("LibVLC has detected an unusable buggy GNU/libc version.\n",
92                stderr);
93         fputs ("Please update to version 2.8 or newer.\n", stderr);
94         fflush (stderr);
95 #ifndef DISABLE_BUGGY_GLIBC_CHECK
96         abort ();
97 #endif
98     }
99
100 # ifdef __i386__
101     /* glibc 2.10, 2.10.1 fail in pthread_cond_wait on 686 */
102     struct stat st;
103     if (strverscmp (glcv, "2.10") >= 0
104      && strverscmp (glcv, "2.10.1") <= 0 /* update version when fixed */
105      && !stat ("/lib/i686/cmov/libpthread.so.0", &st))
106     {
107         fputs ("LibVLC has detected an unusable buggy GNU/libc version.\n",
108                stderr);
109         fputs ("Please remove GNU/libc acceleration for 686.\n", stderr);
110         fflush (stderr);
111 #  ifndef DISABLE_BUGGY_GLIBC_CHECK
112         abort ();
113 #  endif
114     }
115 # endif
116 #endif
117
118 #if 0
119     static pthread_once_t once = PTHREAD_ONCE_INIT;
120     pthread_once (&once, set_libvlc_path);
121 #endif
122     (void)libvlc; (void)argc; (void)argv;
123 }
124
125 void system_Configure (libvlc_int_t *libvlc, int *argc, const char *argv[])
126 {
127     (void)libvlc; (void)argc; (void)argv;
128 }
129
130 void system_End (libvlc_int_t *libvlc)
131 {
132     (void)libvlc;
133 }
134