]> git.sesse.net Git - vlc/blob - src/misc/linux_specific.c
update.c: ifdef some win32 specific code
[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
28 #include <vlc_common.h>
29 #include "../libvlc.h"
30
31 #if 0
32 #include <assert.h>
33 #include <pthread.h>
34 #include <limits.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     char *line = NULL;
50     size_t linelen = 0;
51     uintptr_t needle = (uintptr_t)set_libvlc_path;
52
53     for (;;)
54     {
55         ssize_t len = getline (&line, &linelen, maps);
56         if (len == -1)
57             break;
58
59         void *start, *end;
60         if (sscanf (line, "%p-%p", &start, &end) < 2)
61             continue;
62         if (needle < (uintptr_t)start || (uintptr_t)end <= needle)
63             continue;
64         char *dir = strchr (line, '/');
65         if (dir == NULL)
66             continue;
67         char *file = strrchr (line, '/');
68         if (end == NULL)
69             continue;
70         *file = '\0';
71         printf ("libvlc at %s\n", dir);
72         if (strlen (dir) < sizeof (libvlc_path))
73             strcpy (libvlc_path, dir);
74         break;
75     }
76     free (line);
77     fclose (maps);
78 }
79 #endif
80
81 #ifdef __GLIBC__
82 # include <gnu/libc-version.h>
83 # include <stdlib.h>
84 #endif
85
86 void system_Init (libvlc_int_t *libvlc, int *argc, const char *argv[])
87 {
88 #ifdef __GLIBC__
89     const char *glcv = gnu_get_libc_version ();
90
91     /* gettext in glibc 2.5-2.7 is not thread-safe. LibVLC keeps crashing,
92      * especially in sterror_r(). Even if we have NLS disabled, the calling
93      * process might have called setlocale(). */
94     if (strverscmp (glcv, "2.5") >= 0 && strverscmp (glcv, "2.8") < 0)
95     {
96         fputs ("LibVLC has detected an unusable buggy GNU/libc version.\n"
97                "Please update to version 2.8 or newer.\n", stderr);
98         fflush (stderr);
99 #ifndef DISABLE_BUGGY_GLIBC_CHECK
100         abort ();
101 #endif
102     }
103 #endif
104
105 #if 0
106     static pthread_once_t once = PTHREAD_ONCE_INIT;
107     pthread_once (&once, set_libvlc_path);
108 #endif
109     (void)libvlc; (void)argc; (void)argv;
110 }
111
112 void system_Configure (libvlc_int_t *libvlc, int *argc, const char *argv[])
113 {
114     (void)libvlc; (void)argc; (void)argv;
115 }
116
117 void system_End (libvlc_int_t *libvlc)
118 {
119     (void)libvlc;
120 }
121